Which infrastructure requests still fit when capacity drops?
For infrastructure planners: compare normal and outage allocation while protecting reserves, respecting declared priority and explaining every deferred request.
01
Set capacity and protected reserve
Supply energy and compute planning units. A shortfall in either protected reserve pauses all dispatch in that snapshot.
The Python wrapper uses the existing Omega resource engine. Highest priority goes first, with input-order ties and indivisible requests; greedy selection is not globally optimal.
The browser mirrors the bounded rules with full-result parity tests. Normal and outage plans are independent hypothetical snapshots, not observed cancellations or physical recovery.
{"revision":"4e51d6aee7b901e42115d44380a15caacb44e940","sources":[{"file":"demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/scenario.json","content":"{\n \"schema\": \"agijobs.celestial-resource-contingency.v1\",\n \"title\": \"Keep communications and backups available during a capacity outage\",\n \"normalCapacity\": {\"energyUnits\": 100, \"computeUnits\": 100},\n \"outageCapacity\": {\"energyUnits\": 65, \"computeUnits\": 55},\n \"protectedReserve\": {\"energyUnits\": 10, \"computeUnits\": 10},\n \"jobs\": [\n {\"id\":\"communications\",\"label\":\"Communications relay\",\"priority\":100,\"energyUnits\":25,\"computeUnits\":15},\n {\"id\":\"backup\",\"label\":\"Verified backup copy\",\"priority\":90,\"energyUnits\":20,\"computeUnits\":25},\n {\"id\":\"indexing\",\"label\":\"Search index refresh\",\"priority\":50,\"energyUnits\":30,\"computeUnits\":30},\n {\"id\":\"archive\",\"label\":\"Archive compression\",\"priority\":20,\"energyUnits\":10,\"computeUnits\":20}\n ]\n}\n","format":"json","sha256":"dc1fbaf586e52a5054ab91408664e4af8d4073f83a40f2373f8c7cd29ad60f46","bytes":759,"download":"/AGIJobsv0/examples/dc1fbaf586e52a50-scenario.json","source":"https://github.com/MontrealAI/AGIJobsv0/blob/4e51d6aee7b901e42115d44380a15caacb44e940/demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/scenario.json"},{"file":"demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/run.py","content":"\"\"\"Bounded infrastructure capacity rehearsal using the existing reservation engine.\"\"\"\n\nfrom __future__ import annotations\nimport argparse\nimport hashlib\nimport importlib.util\nimport json\nfrom pathlib import Path\nimport re\nimport sys\n\nROOT = Path(__file__).resolve().parents[2]\nENGINE = (\n ROOT\n / \"demo/Kardashev-II Omega-Grade-α-AGI Business-3/kardashev_ii_omega_grade_alpha_agi_business_3_demo/resources.py\"\n)\n\n\ndef exact(value, keys, name):\n if not isinstance(value, dict) or set(value) != set(keys):\n raise ValueError(f\"{name} has missing or unknown fields\")\n\n\ndef integer(value, name, maximum=1000000):\n if type(value) is not int or not 0 <= value <= maximum:\n raise ValueError(f\"{name} must be an integer from 0 to {maximum}\")\n return value\n\n\ndef parse_scenario(raw):\n if len(raw) > 1000000:\n raise ValueError(\"Scenario exceeds 1 MB\")\n\n def pairs(items):\n result = {}\n for key, value in items:\n if key in result:\n raise ValueError(f\"Duplicate JSON key: {key}\")\n result[key] = value\n return result\n\n def reject(value):\n raise ValueError(f\"Non-finite number: {value}\")\n\n return json.loads(\n raw.decode(\"utf-8\"), object_pairs_hook=pairs, parse_constant=reject\n )\n\n\ndef evaluate(scenario):\n exact(\n scenario,\n [\n \"schema\",\n \"title\",\n \"normalCapacity\",\n \"outageCapacity\",\n \"protectedReserve\",\n \"jobs\",\n ],\n \"scenario\",\n )\n if scenario[\"schema\"] != \"agijobs.celestial-resource-contingency.v1\":\n raise ValueError(\"Unsupported scenario schema\")\n if (\n not isinstance(scenario[\"title\"], str)\n or not scenario[\"title\"].strip()\n or len(scenario[\"title\"]) > 200\n ):\n raise ValueError(\"Title must contain 1 to 200 characters\")\n dimensions = [\"energyUnits\", \"computeUnits\"]\n for field in [\"normalCapacity\", \"outageCapacity\", \"protectedReserve\"]:\n exact(scenario[field], dimensions, field)\n for dim in dimensions:\n integer(scenario[field][dim], f\"{field}.{dim}\")\n for dim in dimensions:\n if scenario[\"outageCapacity\"][dim] > scenario[\"normalCapacity\"][dim]:\n raise ValueError(\"Outage capacity cannot exceed normal capacity\")\n if scenario[\"protectedReserve\"][dim] > scenario[\"normalCapacity\"][dim]:\n raise ValueError(\"Protected reserve cannot exceed normal capacity\")\n jobs = scenario[\"jobs\"]\n if not isinstance(jobs, list) or not 1 <= len(jobs) <= 50:\n raise ValueError(\"Supply 1 to 50 infrastructure jobs\")\n seen = set()\n for job in jobs:\n exact(job, [\"id\", \"label\", \"priority\", *dimensions], \"job\")\n if (\n not isinstance(job[\"id\"], str)\n or not re.fullmatch(r\"[a-z][a-z0-9-]{0,39}\", job[\"id\"])\n or job[\"id\"] in seen\n ):\n raise ValueError(\n \"Job identifiers must be unique bounded lowercase identifiers\"\n )\n seen.add(job[\"id\"])\n if (\n not isinstance(job[\"label\"], str)\n or not job[\"label\"].strip()\n or len(job[\"label\"]) > 100\n ):\n raise ValueError(\"Job labels must contain 1 to 100 characters\")\n integer(job[\"priority\"], \"priority\", 100)\n for dim in dimensions:\n integer(job[dim], dim)\n if job[\"energyUnits\"] + job[\"computeUnits\"] == 0:\n raise ValueError(\"Each job must request at least one resource unit\")\n spec = importlib.util.spec_from_file_location(\n \"celestial_existing_resources\", ENGINE\n )\n module = importlib.util.module_from_spec(spec)\n sys.modules[spec.name] = module\n spec.loader.exec_module(module)\n ordered = sorted(enumerate(jobs), key=lambda item: (-item[1][\"priority\"], item[0]))\n\n def allocate(capacity):\n manager = module.ResourceManager(\n capacity[\"energyUnits\"], capacity[\"computeUnits\"], 0\n )\n held = {\n d: min(capacity[d], scenario[\"protectedReserve\"][d]) for d in dimensions\n }\n shortfall = {d: scenario[\"protectedReserve\"][d] - held[d] for d in dimensions}\n manager.reserve_budget(\n \"__protected__\", energy=held[\"energyUnits\"], compute=held[\"computeUnits\"]\n )\n rows = []\n for _, job in ordered:\n reasons = []\n if any(shortfall.values()):\n reasons.append(\"protected-reserve-shortfall\")\n else:\n if job[\"energyUnits\"] > manager.energy_available:\n reasons.append(\"energy-capacity\")\n if job[\"computeUnits\"] > manager.compute_available:\n reasons.append(\"compute-capacity\")\n if not reasons:\n manager.reserve_budget(\n job[\"id\"], energy=job[\"energyUnits\"], compute=job[\"computeUnits\"]\n )\n rows.append(\n {\n \"id\": job[\"id\"],\n \"label\": job[\"label\"],\n \"priority\": job[\"priority\"],\n \"status\": \"deferred\" if reasons else \"reserved\",\n \"reasons\": reasons,\n **{d: job[d] for d in dimensions},\n }\n )\n remaining = {\n \"energyUnits\": int(manager.energy_available),\n \"computeUnits\": int(manager.compute_available),\n }\n allocated = {\n d: sum(row[d] for row in rows if row[\"status\"] == \"reserved\")\n for d in dimensions\n }\n conserved = all(\n capacity[d] == held[d] + allocated[d] + remaining[d] for d in dimensions\n )\n if not conserved:\n raise RuntimeError(\"Resource conservation check failed\")\n return {\n \"capacity\": dict(capacity),\n \"reserveHeld\": held,\n \"reserveShortfall\": shortfall,\n \"dispatchPaused\": any(shortfall.values()),\n \"jobs\": rows,\n \"allocated\": allocated,\n \"remaining\": remaining,\n \"conserved\": conserved,\n }\n\n normal, outage = allocate(scenario[\"normalCapacity\"]), allocate(\n scenario[\"outageCapacity\"]\n )\n selected = lambda phase: [\n row[\"id\"] for row in phase[\"jobs\"] if row[\"status\"] == \"reserved\"\n ]\n before, after = selected(normal), selected(outage)\n return {\n \"schema\": \"agijobs.celestial-resource-result.v1\",\n \"title\": scenario[\"title\"],\n \"normal\": normal,\n \"outage\": outage,\n \"displacedIds\": [i for i in before if i not in after],\n \"newlySelectedIds\": [i for i in after if i not in before],\n \"allocationOrder\": [job[\"id\"] for _, job in ordered],\n \"assumptions\": [\n \"Higher priority first; ties preserve input order.\",\n \"Jobs are indivisible; greedy selection is not a global optimizer.\",\n \"Plans are independent snapshots; displaced means a changed plan, not an actual cancellation.\",\n \"Resource units are declared planning units, not measured physical capacity.\",\n ],\n \"executionAttested\": False,\n \"productionApproved\": False,\n \"settlementApproved\": False,\n }\n\n\ndef main():\n parser = argparse.ArgumentParser(description=__doc__)\n parser.add_argument(\n \"scenario\",\n nargs=\"?\",\n type=Path,\n default=Path(__file__).with_name(\"scenario.json\"),\n )\n args = parser.parse_args()\n try:\n with args.scenario.open(\"rb\") as source:\n raw = source.read(1000001)\n result = evaluate(parse_scenario(raw))\n result[\"scenarioSha256\"] = hashlib.sha256(raw).hexdigest()\n print(json.dumps(result, indent=2, ensure_ascii=False))\n return 1 if result[\"outage\"][\"dispatchPaused\"] else 0\n except (ValueError, OSError, RecursionError) as error:\n print(f\"Cannot plan resource contingency: {error}\", file=sys.stderr)\n return 2\n\n\nif __name__ == \"__main__\":\n raise SystemExit(main())\n","format":"text","sha256":"2deeb3a30813d416e2841b07ecf344156bad4956422b9c362069b9411a33f3c5","bytes":8080,"download":"/AGIJobsv0/examples/2deeb3a30813d416-run.py","source":"https://github.com/MontrealAI/AGIJobsv0/blob/4e51d6aee7b901e42115d44380a15caacb44e940/demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/run.py"},{"file":"demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/README.md","content":"# AGI Jobs v0 (v2) — Demo → Celestial Sovereign Orbital AGI OS Grand Demonstration\n\n> AGI Jobs v0 (v2) is our sovereign intelligence engine; this module extends that superintelligent machine with specialised capabilities for `demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION`.\n\n## Run the resource outage planning desk\n\nThis bounded, offline rehearsal compares infrastructure job reservations before and during a declared capacity outage. It reuses the existing Omega demo's `ResourceManager.reserve_budget` engine. It does not control satellites, energy systems, compute workers, wallets or production jobs.\n\n```sh\npython demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/run.py\npython demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/run.py path/to/scenario.json\npython -m pytest test/simulation/test_celestial_contingency.py\n```\n\nPython 3.12 and the standard library run the rehearsal; the repository's test dependencies provide pytest. Input is strict JSON with unique keys, bounded integers, unique job identifiers and explicit normal/outage capacities. Energy and compute units are declared planning units, not measured physical quantities or token balances.\n\nThe default normal plan reserves communications, backups, indexing and archive compression. The outage plan keeps communications and backups while deferring the two lower-priority requests. Every phase reports held reserve, shortfall, allocated and remaining units, and verifies conservation independently of the reservation engine. If the outage cannot cover the protected reserve, all dispatch is paused, even if some capacity remains in the other resource.\n\nHigher priority wins; equal priority preserves input order. Jobs are indivisible. A large request that does not fit is deferred while later smaller requests may fit. This greedy rule does not promise global optimality. The two plans are independent snapshots: a displaced job represents a changed plan, not an actual cancellation, successful recovery or execution. No monetary reward, price, transfer or stake operation is invoked.\n\nThe CLI prints a JSON result with the SHA-256 of the exact input bytes. Exit `0` means a valid plan; `1` means protected-reserve shortfall pauses outage dispatch; `2` means invalid or unreadable input. Deferred jobs may remain in an otherwise valid plan. All execution, production and settlement approval flags stay false.\n\n## Preserved design context\n\nThe original diagram and design below describe broader goals. The implemented capability is the bounded resource reservation comparison above.\n\n## Overview\n- **Path:** `demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/README.md`\n- **Module Focus:** Anchors Demo → Celestial Sovereign Orbital AGI OS Grand Demonstration 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- Provides opinionated configuration and assets tailored to `demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION` 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```mermaid\nflowchart LR\n Operators((Mission Owners)) --> demo_CELESTIAL_SOVEREIGN_ORBITAL_AGI_OS_GRAND_DEMONSTRATION[[Demo → Celestial Sovereign Orbital AGI OS Grand Demonstration]]\n demo_CELESTIAL_SOVEREIGN_ORBITAL_AGI_OS_GRAND_DEMONSTRATION --> 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\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/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION`.\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\nThis folder preserves the design guide; use the related executable workflow linked above.\n\n## Quality & Governance\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- 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":"5ccbef8cf784e5876d267b7a80bf2d02207225b7147d8e4a83a34c9bcda97921","bytes":5314,"download":"/AGIJobsv0/examples/5ccbef8cf784e587-README.md","source":"https://github.com/MontrealAI/AGIJobsv0/blob/4e51d6aee7b901e42115d44380a15caacb44e940/demo/CELESTIAL-SOVEREIGN-ORBITAL-AGI-OS-GRAND-DEMONSTRATION/README.md"}]}
FROM READING TO A REPRODUCIBLE RUN
Try the selected path.
Python, no demo package install
Run from the repository root with Python 3.12. This selected entry point uses the Python standard library. Keep output in a separate directory so that you can compare runs.
JSON shows reserved and deferred requests, protected reserve shortfall, conserved resources and changed selections. Exit 1 indicates a protected-reserve shortfall; no physical execution or settlement is authorized.
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.
Lower outage energy below the protected reserve to pause all dispatch, then restore capacity. Change a request priority and compare which requests fit.
THE SYSTEM, MADE VISIBLE
Architecture & relationships
Architecture diagram · source preserved belowView original Mermaid source
flowchart LR
Operators((Mission Owners)) --> demo_CELESTIAL_SOVEREIGN_ORBITAL_AGI_OS_GRAND_DEMONSTRATION[[Demo → Celestial Sovereign Orbital AGI OS Grand Demonstration]]
demo_CELESTIAL_SOVEREIGN_ORBITAL_AGI_OS_GRAND_DEMONSTRATION --> Core[["AGI Jobs v0 (v2) Core Intelligence"]]
Core --> Observability[[Unified CI / CD & Observability]]
Core --> Governance[[Owner Control Plane]]
WHEN SOMETHING DOESN’T MATCH
Troubleshooting
Import or dependency error
Confirm the active virtual environment and the selected demo’s requirements. Run python -m pip check; do not install unrelated demo requirements over a working environment.
Unexpected result or missing file
Check the selected entry point, configuration and output argument. Keep the seed and implementation fixed before comparing outcomes.
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.