Do reported regional amounts reconcile before any envelope change is proposed?
For operators reviewing regional plans: preserve unknown costs, compare exact declared-unit envelopes, and inspect conservative transfer proposals without executing them.
01
Supply planned and reported amounts
Amounts are exact whole-number strings in one declared unit. Unknown reported costs stay null and hold all proposals.
The browser bundles this exact engine and existing Hypernova analyzer. Proposals follow input order, conserve units and leave uncovered deficits visible.
{"revision":"4e51d6aee7b901e42115d44380a15caacb44e940","sources":[{"file":"demo/zenith-sapience/scenario.json","content":"{\n \"schema\": \"agijobs.zenith-regional-reconciliation.v1\",\n \"title\": \"Reconcile regional infrastructure work before proposing budget changes\",\n \"unit\": \"declared budget units\",\n \"totalUnits\": \"100000\",\n \"regions\": [\n { \"id\": \"north\", \"name\": \"North\", \"allocationUnits\": \"40000\" },\n { \"id\": \"central\", \"name\": \"Central\", \"allocationUnits\": \"35000\" },\n { \"id\": \"south\", \"name\": \"South\", \"allocationUnits\": \"25000\" }\n ],\n \"jobs\": [\n {\n \"id\": \"relay\",\n \"label\": \"Relay inspection\",\n \"regionId\": \"north\",\n \"plannedUnits\": \"35000\",\n \"reportedUnits\": \"45000\"\n },\n {\n \"id\": \"backup\",\n \"label\": \"Backup maintenance\",\n \"regionId\": \"central\",\n \"plannedUnits\": \"30000\",\n \"reportedUnits\": \"25000\"\n },\n {\n \"id\": \"archive\",\n \"label\": \"Archive migration\",\n \"regionId\": \"south\",\n \"plannedUnits\": \"20000\",\n \"reportedUnits\": null\n }\n ]\n}\n","format":"json","sha256":"0131e9e16b5cbbd2634149f14a324cfb3cf65e762e33fe2a817e7946c4d1a733","bytes":928,"download":"/AGIJobsv0/examples/0131e9e16b5cbbd2-scenario.json","source":"https://github.com/MontrealAI/AGIJobsv0/blob/4e51d6aee7b901e42115d44380a15caacb44e940/demo/zenith-sapience/scenario.json"},{"file":"demo/zenith-sapience/engine.mjs","content":"import {\n analyze,\n parseSource,\n} from '../zenith-sapience-initiative-supra-sovereign-hypernova-governance/workbench/core.mjs';\nimport { parseStrictJson } from './strict-json.mjs';\nconst exact = (x, fields, name) => {\n if (\n !x ||\n Array.isArray(x) ||\n typeof x !== 'object' ||\n Object.keys(x).length !== fields.length ||\n fields.some((k) => !Object.hasOwn(x, k))\n )\n throw Error(`${name}: missing or unknown fields`);\n};\nconst label = (x, max = 100) =>\n typeof x === 'string' &&\n x.trim().length > 0 &&\n x.length <= max &&\n !/[\\u0000-\\u001f\\u007f-\\u009f\\u2028-\\u202e\\u2066-\\u2069]/.test(x);\nconst money = (x) => typeof x === 'string' && /^(0|[1-9][0-9]{0,23})$/.test(x);\nconst id = (x) => typeof x === 'string' && /^[a-z][a-z0-9-]{0,39}$/.test(x);\nexport function evaluate(input) {\n exact(\n input,\n ['schema', 'title', 'unit', 'totalUnits', 'regions', 'jobs'],\n 'scenario'\n );\n if (\n input.schema !== 'agijobs.zenith-regional-reconciliation.v1' ||\n !label(input.title, 200) ||\n !label(input.unit, 40) ||\n !money(input.totalUnits)\n )\n throw Error('Invalid scenario identity or total');\n if (\n !Array.isArray(input.regions) ||\n input.regions.length < 1 ||\n input.regions.length > 30 ||\n !Array.isArray(input.jobs) ||\n input.jobs.length < 1 ||\n input.jobs.length > 100\n )\n throw Error('Supply 1–30 regions and 1–100 jobs');\n const regionIds = new Set(),\n regionNames = new Set(),\n jobIds = new Set();\n for (const r of input.regions) {\n exact(r, ['id', 'name', 'allocationUnits'], 'region');\n if (\n !id(r.id) ||\n !label(r.name) ||\n !money(r.allocationUnits) ||\n regionIds.has(r.id) ||\n regionNames.has(r.name)\n )\n throw Error('Invalid or duplicate region');\n regionIds.add(r.id);\n regionNames.add(r.name);\n }\n for (const j of input.jobs) {\n exact(\n j,\n ['id', 'label', 'regionId', 'plannedUnits', 'reportedUnits'],\n 'job'\n );\n if (\n !id(j.id) ||\n !label(j.label) ||\n !regionIds.has(j.regionId) ||\n !money(j.plannedUnits) ||\n (j.reportedUnits !== null && !money(j.reportedUnits)) ||\n jobIds.has(j.id)\n )\n throw Error('Invalid job or reported amount');\n jobIds.add(j.id);\n }\n const plan = {\n initiative: input.title,\n timingPolicy: 'duration-after-dependencies',\n budget: {\n currency: input.unit,\n total: input.totalUnits,\n allocations: Object.fromEntries(\n input.regions.map((r) => [r.name, r.allocationUnits])\n ),\n },\n regions: input.regions.map((r) => ({ id: r.id, name: r.name })),\n jobs: input.jobs.map((j) => ({\n id: j.id,\n title: j.label,\n region: j.regionId,\n reward: j.plannedUnits,\n deadlineDays: 1,\n dependencies: [],\n })),\n };\n const planned = analyze(parseSource(JSON.stringify(plan)));\n const unknownJobIds = input.jobs\n .filter((j) => j.reportedUnits === null)\n .map((j) => j.id);\n const reportedComplete = unknownJobIds.length === 0;\n const reported = reportedComplete\n ? analyze(\n parseSource(\n JSON.stringify({\n ...plan,\n jobs: plan.jobs.map((j, i) => ({\n ...j,\n reward: input.jobs[i].reportedUnits,\n })),\n })\n )\n )\n : null;\n const regions = input.regions.map((r) => {\n const jobs = input.jobs.filter((j) => j.regionId === r.id),\n known = jobs.filter((j) => j.reportedUnits !== null),\n complete = known.length === jobs.length;\n const sum = (values) => String(values.reduce((a, n) => a + BigInt(n), 0n));\n const plannedUnits = sum(jobs.map((j) => j.plannedUnits)),\n knownReportedUnits = sum(known.map((j) => j.reportedUnits));\n return {\n id: r.id,\n name: r.name,\n allocationUnits: r.allocationUnits,\n plannedUnits,\n knownReportedUnits,\n reportedComplete: complete,\n unknownJobIds: jobs\n .filter((j) => j.reportedUnits === null)\n .map((j) => j.id),\n reportedVarianceUnits: complete\n ? String(BigInt(knownReportedUnits) - BigInt(plannedUnits))\n : null,\n reportedHeadroomUnits: complete\n ? String(BigInt(r.allocationUnits) - BigInt(knownReportedUnits))\n : null,\n };\n });\n const allocationBalanced = planned.budget.allocated === input.totalUnits;\n const proposals = [];\n let uncoveredDeficitUnits = null;\n if (reportedComplete && allocationBalanced) {\n const donors = regions\n .filter((r) => BigInt(r.reportedHeadroomUnits) > 0n)\n .map((r) => ({ id: r.id, remaining: BigInt(r.reportedHeadroomUnits) }));\n let uncovered = 0n;\n for (const r of regions.filter(\n (r) => BigInt(r.reportedHeadroomUnits) < 0n\n )) {\n let deficit = -BigInt(r.reportedHeadroomUnits);\n for (const donor of donors) {\n const amount = donor.remaining < deficit ? donor.remaining : deficit;\n if (amount > 0n) {\n proposals.push({\n fromRegionId: donor.id,\n toRegionId: r.id,\n units: String(amount),\n });\n donor.remaining -= amount;\n deficit -= amount;\n }\n }\n uncovered += deficit;\n }\n uncoveredDeficitUnits = String(uncovered);\n }\n const proposalHoldReasons = [];\n if (!reportedComplete) proposalHoldReasons.push('reported-costs-incomplete');\n if (!allocationBalanced)\n proposalHoldReasons.push('regional-allocations-do-not-match-total');\n const after = regions.map((r) => ({\n id: r.id,\n proposedAllocationUnits: String(\n BigInt(r.allocationUnits) +\n proposals\n .filter((p) => p.toRegionId === r.id)\n .reduce((a, p) => a + BigInt(p.units), 0n) -\n proposals\n .filter((p) => p.fromRegionId === r.id)\n .reduce((a, p) => a + BigInt(p.units), 0n)\n ),\n }));\n if (\n after.reduce((a, r) => a + BigInt(r.proposedAllocationUnits), 0n) !==\n BigInt(planned.budget.allocated)\n )\n throw Error('Proposal conservation failed');\n return {\n schema: 'agijobs.zenith-regional-result.v1',\n title: input.title,\n unit: input.unit,\n planned,\n reported,\n regions,\n reportedComplete,\n unknownJobIds,\n allocationBalanced,\n proposalHoldReasons,\n proposals,\n proposedAllocations: after,\n uncoveredDeficitUnits,\n fullyFundedAfterProposal:\n reportedComplete && allocationBalanced && uncoveredDeficitUnits === '0',\n conserved: true,\n costAttested: false,\n transfersExecuted: false,\n productionApproved: false,\n settlementApproved: false,\n assumptions: [\n 'Reported costs are supplied values, not verified invoices.',\n 'Transfer proposals follow region input order and conserve the declared unit.',\n 'Unknown reported costs remain unknown and hold all transfer proposals.',\n 'No exchange rate, token conversion, transfer or execution is performed.',\n ],\n };\n}\nexport function parseScenario(text) {\n const input = parseStrictJson(text);\n evaluate(input);\n return input;\n}\n","format":"text","sha256":"2f50ae8002683caf44022d0987d534d4ce04915997d4fdc188d3840c4ed0b406","bytes":7051,"download":"/AGIJobsv0/examples/2f50ae8002683caf-engine.mjs","source":"https://github.com/MontrealAI/AGIJobsv0/blob/4e51d6aee7b901e42115d44380a15caacb44e940/demo/zenith-sapience/engine.mjs"},{"file":"demo/zenith-sapience/README.md","content":"# AGI Jobs v0 (v2) — Demo → Zenith Sapience\n\n> AGI Jobs v0 (v2) is our sovereign intelligence engine; this module extends that superintelligent machine with specialised capabilities for `demo/zenith-sapience`.\n\n## Run the regional budget reconciliation desk\n\nThis offline workspace reuses the existing Hypernova workbench's exact-integer analyzer to compare regional budget envelopes, planned job amounts and supplied reported amounts. It produces reviewable transfer proposals in one declared unit. It does not move money, convert tokens, verify invoices or authorize work.\n\n```sh\nnode demo/zenith-sapience/run.mjs\nnode demo/zenith-sapience/run.mjs path/to/scenario.json\nnode --test test/pages/zenith-reconciliation.test.mjs\n```\n\nUse the repository's pinned Node version. This entry point uses standard Node modules and existing repository code; no provider credentials are required. Input amounts are nonnegative integer strings, with up to 24 digits. JSON imports reject duplicate keys, noninteger numeric tokens, excessive nesting, unknown fields and invalid identifiers.\n\nThe default example intentionally leaves one reported job amount unknown. Its reported total remains `null`, regional subtotals are explicitly known-only, and all transfer proposals are held. Unknown is never silently treated as zero. Supply a declared amount to complete reconciliation; this is still a reported value, not an attested invoice.\n\nWhen all reported amounts are present and regional envelopes match the declared total, the desk detects regional shortfalls even if the overall budget has headroom. It proposes transfers from regions with spare allocation, following region input order. Proposals conserve the declared unit and cannot draw more than a donor's reported headroom. If total resources are insufficient, partial proposals remain visible alongside the exact uncovered deficit and `fullyFundedAfterProposal: false`.\n\nAn empty proposal list can mean either no deficit or a hold; inspect `proposalHoldReasons` and `fullyFundedAfterProposal`. No currency conversion or automatic budget action is performed. `costAttested`, `transfersExecuted`, `productionApproved` and `settlementApproved` are always false. A fully funded proposal only describes consistency of supplied numbers.\n\nThe CLI prints the result and SHA-256 of the exact scenario bytes. Exit `0` means reported costs are complete and proposed allocations cover them; `1` means missing reports, unbalanced envelopes or an uncovered deficit; `2` means invalid or unreadable input. The reused analyzer's one-day scheduling fields are internal synthetic placeholders, not a delivery forecast.\n\n## Preserved design context\n\nThe broader mission-stream designs and architecture diagrams below remain available. The bounded capability implemented here is regional budget reconciliation; these designs do not establish production or societal-scale execution.\n\n## Overview\n\n- **Path:** `demo/zenith-sapience/README.md`\n- **Module Focus:** Anchors Demo → Zenith Sapience inside the AGI Jobs v0 (v2) lattice so teams can orchestrate economic, governance, and operational missions with deterministic guardrails.\n- **Integration Role:** Interfaces with the unified owner control plane, telemetry mesh, and contract registry to deliver end-to-end resilience.\n\n## Capabilities\n\n- Provides opinionated configuration and assets tailored to `demo/zenith-sapience` while remaining interoperable with the global AGI Jobs v0 (v2) runtime.\n- Ships with safety-first defaults so non-technical operators can activate the experience without compromising security or compliance.\n- Publishes ready-to-automate hooks for CI, observability, and ledger reconciliation.\n\n## Systems Map\n\n```mermaid\nflowchart LR\n Operators((Mission Owners)) --> demo_zenith_sapience[[Demo → Zenith Sapience]]\n demo_zenith_sapience --> Core[[\"AGI Jobs v0 (v2) Core Intelligence\"]]\n Core --> Observability[[Unified CI / CD & Observability]]\n Core --> Governance[[Owner Control Plane]]\n```\n\n## Working With This Module\n\n1. From the repository root run `npm install` once to hydrate all workspaces.\n2. Inspect the scripts under `scripts/` or this module's `package.json` entry (where applicable) to discover targeted automation for `demo/zenith-sapience`.\n3. Execute `npm test` and `npm run lint --if-present` before pushing to guarantee a fully green AGI Jobs v0 (v2) CI signal.\n4. Capture mission telemetry with `make operator:green` or the module-specific runbooks documented in [`OperatorRunbook.md`](../../OperatorRunbook.md).\n\n## Directory Guide\n\n### Key Files\n\n- `architecture.md`\n- `assurance-matrix.md`\n- `mission-streams.md`\n\n## Quality & Governance\n\n- Every change must land through a pull request with all required checks green (unit, integration, linting, security scan).\n- Reference [`RUNBOOK.md`](../../RUNBOOK.md) and [`OperatorRunbook.md`](../../OperatorRunbook.md) for escalation patterns and owner approvals.\n- Keep secrets outside the tree; use the secure parameter stores wired to the AGI Jobs v0 (v2) guardian mesh.\n\n## Next Steps\n\n- Review this module's issue board for open automation, data, or research threads.\n- Link new deliverables back to the central manifest via `npm run release:manifest`.\n- Publish artefacts (dashboards, mermaid charts, datasets) into `reports/` for downstream intelligence alignment.\n","format":"text","sha256":"3fb2efe3412d42be26d4aa40d06db2f4ee9d47ccbf037c524693c93177bb3503","bytes":5359,"download":"/AGIJobsv0/examples/3fb2efe3412d42be-README.md","source":"https://github.com/MontrealAI/AGIJobsv0/blob/4e51d6aee7b901e42115d44380a15caacb44e940/demo/zenith-sapience/README.md"}]}
FROM READING TO A REPRODUCIBLE RUN
Try the selected path.
Node.js workspace
Run from the repository root after nvm install, nvm use and npm ci. Use the versions pinned in .nvmrc and package.json. Commands below describe the selected path; optional app/server packages can have their own locked dependencies.
JSON reports known-only subtotals, unknown amounts, regional variances, proposal holds and any remaining deficit. Fully funded is true only when complete balanced data has no uncovered deficit.
The source inspector above reads bundled repository material. Local commands run separately on your computer. Recorded examples may contain historical timestamps, placeholders and simulated metrics.
MAKE IT YOUR OWN
One useful experiment.
Supply the missing report, inspect the proposed 5000-unit transfer, then raise that report beyond available envelopes to expose a remaining deficit.
THE SYSTEM, MADE VISIBLE
Architecture & relationships
Architecture diagram · source preserved belowView original Mermaid source
flowchart LR
Operators((Mission Owners)) --> demo_zenith_sapience[[Demo → Zenith Sapience]]
demo_zenith_sapience --> Core[["AGI Jobs v0 (v2) Core Intelligence"]]
Core --> Observability[[Unified CI / CD & Observability]]
Core --> Governance[[Owner Control Plane]]
WHEN SOMETHING DOESN’T MATCH
Troubleshooting
A command or service fails
Start at the first error, confirm the working directory and pinned toolchain, then follow the linked component guide. Optional packages and provider services have separate prerequisites.
A report looks successful but lacks evidence
Check its source revision, configuration, timestamps and underlying events. Historical fixtures and generated plans do not prove a fresh execution.
TRACE THE CHECKS
Verification & next steps
This directory has no standalone test source files. Follow the shared implementation and its behavioral tests before making correctness claims.