Skip to content

Take over Microcosm's Orrery projection - #9

Merged
anth-volk merged 3 commits into
mainfrom
claude/orrery-projection
Oct 19, 2026
Merged

anth-volk merged 3 commits into
mainfrom
claude/orrery-projection

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8

Summary

Copies Microcosm's Orrery projection into the collector, so the collector's future Orrery worker can turn a build's saved compiler schema (graph.schema.json) and execution overlay (graph.execution.json) into Orrery JSON without Microcosm's content store, numpy or pandas. Tests compare the copy's output with Orrery JSON saved from Microcosm's own projection and require identical bytes.

Nothing in the service calls the projection yet. The worker, its image, validation with Orrery's Node validator and publication are later changes.

What was copied, and from where

The source is PolicyEngine/microcosm#1295 at its head, 8d159a8c5653ad63affb1a5d2e39034f877db2ff (#1295 is still open), from packages/microcosm-graph/src/microcosm/graph/. #1295 is what makes the projection need only the standard library.

Module State in the copy
orrery.py Changed: keeps orrery_document_from_schema, orrery_json_from_schema and every helper they call, unchanged. It leaves out main and its file-reading and reference-rebasing helpers, because the command's --evidence/--store option reads the content store, and orrery_document/orrery_json, which compile a Graph object first.
orrery_evidence.py, execution_overlay.py, presentation.py, schema.py, serialize.py, decl.py, canonical.py, expansion.py Unchanged. schema.py, serialize.py, decl.py and expansion.py are needed because the projection checks a schema by recompiling its embedded graph.

provenance.py records the repository, commit and directory, each source file's git blob ID, and what orrery.py leaves out. A test checks that every unchanged module still has its source's blob ID. The adapter identifier the projection writes at metadata.adapter, microcosm.graph.orrery.v1, is unchanged, and a test checks it. The README's new "Orrery projection" section says where a later version comes from (Microcosm's main, until Microcosm removes its copy) and how to take it.

Where it lives

telemetry_collector/orrery/projection/:

  • The wheel ships one import package, telemetry_collector, and tests/test_packaging.py requires that, so carried-over calibration-diagnostics commits keep merging. A second top-level package would break that.
  • telemetry_collector/orrery/ leaves room for the worker's validation and publication modules beside projection.
  • The copied modules keep their Microcosm file names, so their relative imports work unchanged and each file can be compared with its source by blob ID.

The modules are in the container image, because the Dockerfile copies telemetry_collector, but the application doesn't import them.

Evidence that the output is byte-identical

tools/generate-orrery-projection-fixtures.py ran Microcosm's projection at 8d159a8 (Python 3.14.6) and saved each input with the Orrery JSON Microcosm wrote from it, under tests/fixtures/orrery_projection/. tests/test_orrery_projection.py loads the saved overlay with the copied reader, projects with the copy, and compares bytes.

Case Overlay Expected output Result
toy-recorded-execution: Microcosm's toy country with grouped presentation, a scope boundary and source references; the overlay holds a computing phase and its replay, loaded from saved run evidence the way UK finalize loads it yes 191,154 bytes identical
toy-declarations-only: the same schema without an overlay no 57,409 bytes identical
toy-failed-check: one phase whose threshold check fails; no presentation contract yes 122,309 bytes identical
declaration-features-titled: rewrites, expansion, reweighting, an artifact input, numbers outside JavaScript's safe range, and a title no 29,534 bytes identical
uk-calibration-summaries: UK calibration nodes on a three-household fixture, with UK's artifact summaries and one failed summary provider yes 131,853 bytes identical
uk-full-dense-declarations: the complete UK dense graph's declarations and presentation contract (5,805 nodes, 21,620 edges) no 18,899,459 bytes (stored gzip-compressed) identical

Limits, found on toy-recorded-execution: the generator searched for the smallest value of each limit at which Microcosm still projects it. The copy writes the same bytes at that value and raises the same error one below it:

Limit Smallest accepted Error one below
_MAX_NODES 40 Orrery adapter: node limit.
_MAX_EDGES 71 Orrery adapter: edge limit.
_MAX_OUTPUT_BYTES 320,674 Orrery adapter: prospective metadata size.

A test also checks that the defaults match Microcosm's (20,000 nodes, 100,000 edges, 64 MiB output, and the schema reader's limits).

As a check that the comparison is sensitive, I changed one value the projection writes (metadata.truncated) locally and ran the file: 9 failed (all six cases and the three limits), and it passed again once the value was put back.

The inputs are synthetic: Microcosm's test fixtures and the UK graph declarations, with overlays from running those fixtures. They hold no build data. I checked them for local paths and machine names; there are none. The fixtures total 2.8 MB, 2.2 MB of it the gzip-compressed UK dense schema and output.

Other tests in the file, ported from #1295's: the copied overlay reader refuses another protocol, a non-object, duplicate keys, non-finite numbers, non-UTF-8 bytes, a FIFO and a file over the byte limit, and it reads each saved overlay back to the same canonical bytes. A static check confirms that the copied modules import only the standard library and each other.

Commits (red, then green)

Commit Red Green
Project saved schemas and overlays to Orrery JSON as Microcosm does tests/test_orrery_projection.py failed to import (ModuleNotFoundError: telemetry_collector.orrery), so none of its 23 tests could run 23 passed
Record the Microcosm commit and files the projection was copied from tests/test_orrery_projection_provenance.py failed to import (ModuleNotFoundError: ...projection.provenance), so none of its 5 tests could run 5 passed (and the 23 above still pass)
Name the projection's Microcosm source with the collector's own word The existing check test_collector_uses_store_vocabulary (tests/test_deployment_workflow.py) refuses the word "repository" in the collector's own files. That file isn't changed here, so I didn't run it locally. A text search with the same exemptions found 6 occurrences in 4 of this branch's files. The search finds none; the 28 tests above still pass. CI runs the check itself.

After each commit, I ran the new test files again: 23 passed, then 28, then 28.

Tests run locally

  • uv run pytest -q tests/test_orrery_projection.py tests/test_orrery_projection_provenance.py: 28 passed, about 2.4 s.
  • ruff check and ruff format --check on every changed Python file, which passed. The copied modules pass both unchanged.
  • bash tools/check-changelog.sh, which passed.

I didn't run the rest of the suite; CI runs it.

Dependencies and deployment

No new dependencies: pyproject.toml, uv.lock, the Dockerfile and the workflows are unchanged, and the change reads no environment variables. Deployment stays switched off: COLLECTOR_DEPLOY_ENABLED is untouched.

Related pull requests

🤖 Generated with Claude Code

anth-volk and others added 3 commits October 20, 2026 00:24
The collector's Orrery worker is to project a build's saved compiler
schema (graph.schema.json) and execution overlay (graph.execution.json),
instead of the build machine doing it. Microcosm's projection lives in
microcosm-graph, which is not published, and that package needs numpy,
pandas and the content store. PolicyEngine/microcosm#1295 made the
projection importable with only the standard library.

Copy the projection's modules from #1295's head, 8d159a8, into
telemetry_collector/orrery/projection, keeping their names and contents.
orrery.py leaves out the command-line entry point, whose overlay option
reads the content store, and the two functions that compile a Graph
object before projecting it; the other eight modules are unchanged.

tools/generate-orrery-projection-fixtures.py runs Microcosm's projection
on six inputs and saves each input with the Orrery JSON it produced:
Microcosm's toy country with and without an execution overlay, a failed
threshold check, a schema exercising rewrites, expansion and numbers
JavaScript cannot hold, UK calibration nodes with artifact summaries, and
the complete UK dense graph's declarations. It also records the smallest
node, edge and output-size limits at which the toy overlay still projects.
tests/test_orrery_projection.py projects the saved files with the copy
and requires identical bytes, and identical errors one below each limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The projection copy must stay identical to Microcosm's until Microcosm
removes its own, and later Orrery publications are to record which
projection wrote them. Neither was possible from the code alone.

Add provenance.py: the Microcosm repository, commit (#1295's head,
8d159a8) and source directory; each copied module's source git blob ID;
what orrery.py leaves out; and the adapter identifier the projection
writes at metadata.adapter, microcosm.graph.orrery.v1, unchanged from
Microcosm. Tests check that every unchanged module still has its source's
blob ID, that no module is copied without a record, that the saved
expected outputs came from the same commit, and that the projection
writes that adapter identifier.

The README's new "Orrery projection" section says where the projection
comes from until Microcosm removes its copy, and how to take a later
version and regenerate the expected outputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/test_deployment_workflow.py refuses the word "repository" in the
collector's own source and documentation files; it allows it only in
GitHub's expression context and in the OIDC claim and attribute names.
The provenance record used it in a constant, in the fixture index's key
and in the generator and test that read them.

Name them MICROCOSM_REPO and "microcosm_repo". The fixture index is
otherwise unchanged and still matches the generator's output format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk merged commit 5cf1898 into main Oct 19, 2026
4 checks passed
@anth-volk
anth-volk deleted the claude/orrery-projection branch October 19, 2026 21:19
anth-volk added a commit that referenced this pull request Oct 19, 2026
Brings in the Orrery projection (#9) and the 0.3.0 release commit, so the
branch is up to date with main as the ruleset requires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Oct 19, 2026
Brings in main (the Orrery projection, #9, and the 0.3.0 release commit)
through the contract branch, so this branch is up to date as the ruleset
requires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Oct 20, 2026
Brings in the Orrery projection (#9) and the 0.3.0 release. No conflicts;
none of main's new commits touch the extraction tool, its tests or the
push workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Take over Microcosm's Orrery projection

1 participant