Skip to content

Harden Axiom adapter references and kernel hash coverage (NZ v0, G1b) - #1139

Merged
MaxGhenis merged 2 commits into
mainfrom
nzhub/g1b-axiom-adapter-hardening
Oct 9, 2026
Merged

MaxGhenis merged 2 commits into
mainfrom
nzhub/g1b-axiom-adapter-hardening

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Follow-ups to the reviews of microcosm#1118 (G1, the Axiom graph adapter, merged 4121f27). Findings 1–6 of review-microcosm-1118/out-053144.md and finding 6 of out-033221.md.

  • Submodules. A RuleSpec root containing a gitlink is refused, clean or edited; edits inside a submodule that git status misses no longer pass.
  • Inherited git environment. Git runs with the repository-local environment variables removed, and the root must be its repository's top level, so GIT_DIR/GIT_WORK_TREE cannot point the check at a clean decoy or another HEAD.
  • Byte-level checkout check. Committed paths, unfiltered bytes and executable modes are checked against the declared commit, which also catches edits hidden by index flags, the stat cache, a clean filter, a filesystem monitor, a nested .git entry or a replace ref. SHA-256 repositories are accepted and checked byte for byte.
  • Module path. The resolved module path is recorded with the reference; a link repointed after the reference blocks the next compile and a second reference.
  • Kernel hash. It depends only on the set of bound adapter classes, not on binding order or ref names; classes sharing a __qualname__ are ordered by module. Both surviving mutants from the review (sort by ref name; sort by qualname alone) are now killed.
  • Docs. Native text and date outputs are documented as numpy arrays; the changelog's checkout claim matches what is checked.

Invariants (Hypothesis property tests)

  • A referenced adapter compiles only from bytes that hash to the recorded tree digest (test_property_it_compiles_only_from_the_referenced_bytes).
  • A git root is accepted iff its index, worktree and HEAD are exactly the declared commit with no gitlinks or flagged entries, whatever the caller's git environment (test_property_accepted_iff_the_root_holds_exactly_the_commit).
  • The kernel implementation hash depends on the set of adapter classes only (test_property_the_hash_depends_only_on_the_bound_classes).
  • Differential: computed blob ids equal git hash-object (test_differential_blob_ids_equal_git_hash_object).

Tests (build lane)

test_axiom_graph_adapter.py and test_rules_kernels.py, one file at a time: 183 passed, 4 skipped (the existing real-engine graph tests; no local engine). Test evidence by kind is listed under "Review fix" below. ruff check/format and tools/ci_test_plan.py verify clean. Full report: lane report (hub copy at ~/reviews/nz-hub/jobs/new-g1b/report-cont2.md).

Out of scope: an Axiom engine CI job (plan R12), the household-only-weights contract (G2), frozen graph files, frame/kernels.py.

Shared files and owners

packages/microcosm-frame/src/microcosm/frame/adapters/axiom.py and rules_kernels.py tests only; axiom.py is also edited by draft #826 and #822 (Max's sessions). No uk_runtime/us_runtime, frozen graph file or frame/kernels.py change.

Part of the Microcosm NZ v0 graph plan (Max ruling d962), package G1b. Built by the NZ hub on Subfleet build lanes: Claude Opus 5.5 wrote most of it and a GPT-6.1 Sol lane finished it after a provider error (both in the commit trailer); the hub verified scope before committing.

Review fix (head b06217f)

GPT-6.1 Sol review (Subfleet 20261008-095817) at 0c7e90d: REQUEST_CHANGES for one defect, fixed in b06217f and independently verified (APPROVE_WITH_NITS).

  • Unicode-equivalent names. Git on macOS with core.precomposeunicode=true records precomposed names (usually NFC) while the file system lists the NFD name a file was created under; comparing the two path sets as strings refused that clean checkout. Committed paths now pair with files one to one: identical names first, then the single canonically equivalent file the committed path opens, confirmed with Path.samefile. Ambiguous and unmatched names are refused, one directory entry never answers for two committed names, and the byte, executable-mode and directory-digest checks are unchanged. Names that differ only in case are not equivalent.
  • Scope of the exact-commit claim. The check reads the commit's paths and blob names from the repository's object database and assumes that database is intact; deliberate tampering with it (a substituted tree object) is out of scope, and the recorded directory digest still pins the bytes present.
  • Test evidence by kind. Regression tests, red on main's aafc628f adapter source and green here: the submodule, inherited git environment, module-path, hidden byte/mode and replace-ref checkout tests. Regression tests red on 0c7e90d and green here on macOS: the decomposed-name acceptance, hidden-change and property tests. Positive controls that pass on main by design: test_native_outputs_are_numpy_arrays_text_and_dates_included and test_a_module_link_left_alone_compiles_the_referenced_file. Mutant coverage for the unchanged rules_kernels.py: all three kernel-hash tests fail under the sort-by-reference-name mutant; test_classes_sharing_a_qualname_are_ordered_by_module and the property test also fail under sort-by-qualname-alone.
  • Tests at b06217f: test_axiom_graph_adapter.py 162 passed, 5 skipped (4 need a local Axiom engine; 1 needs a normalization-sensitive file system); test_rules_kernels.py 29 passed. Not observed on Linux: the three macOS end-to-end tests are expected to skip in CI, and the distinct-NFC/NFD-files test to run there.

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits October 7, 2026 15:08
Reject submodules, repository-environment redirection, and changed resolved
module paths. Check committed paths, unfiltered bytes and executable modes,
including edits hidden from Git status. Clarify array and checkout claims.

Property-test compile pins, checkout integrity and reference-name-independent
kernel hashes, with same-qualname adapters from different modules and Git blob
differential checks. Both reviewed hash-order mutants are killed.

Validation: 183 passed, 4 real-engine skips in the two targeted files;
main regressions reproduced, lint/format/test-plan checks passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
On macOS with core.precomposeunicode=true, git records a path in NFC while
the file system lists the NFD name the file was created under. The checkout
check compared the two path sets as strings and refused a clean checkout
("2 path(s) differ"). Committed paths now pair with files one to one:
identical names first, then the single canonically equivalent entry that
the committed path opens (Path.samefile). Ambiguous or unmatched names are
refused; the byte, executable-mode and directory-digest checks are
unchanged, and nothing is normalized wholesale.

Regression tests build the clean macOS case under tmp_path and show that a
hidden edit or mode change to the paired file is still refused. A commit
holding both spellings of one name is refused where one file opens under
both. A property test checks the pairing against a brute-force matching on
the real file system. The changelog and docstrings now state that the
exact-commit check assumes an intact object database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis merged commit ab6c8a2 into main Oct 9, 2026
10 checks passed
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Merged by the NZ hub (session local_e407a527) at b06217f with --merge. Gates: gh pr checks exit 0; MERGEABLE; not draft; no CHANGES_REQUESTED review. Reviewed head: b06217f. Independent review: in-session Opus 5.5 builder + separate verifier (jobs/wf-fixes-1008-journal.jsonl) returned APPROVE_WITH_NITS at b06217f; nits applied in that head (one-to-one NFC/NFD pairing confirmed by samefile, changelog scoped to an intact object database). Earlier G1b Subfleet review findings resolved. All 10 checks green, MERGEABLE/CLEAN, no CHANGES_REQUESTED.

MaxGhenis added a commit that referenced this pull request Oct 9, 2026
Two conflicts:
- docs/concept-schema-transport-adr.md: keep both sides. Main's status
  text (#1130) describes the transport reader; G4 adds that benefit-unit
  construction from the concept pointers is built for New Zealand. Main's
  closing bullet listed 13 of New Zealand's 80 module bindings as deferred
  until unit construction exists; G4 builds it, so the bullet now says New
  Zealand's group bindings execute on built units, Belgium's and the US/UK
  group bindings stay deferred, and a country pack is still needed.
- packages/microcosm-build/tests/golden/nz_country_spec.json: regenerated
  from the loaded spec (canonical_json_bytes(_loaded_spec_summary("nz"))),
  not hand-merged. Resource hashes are the union of both sides (G4's
  axiom_input_closure.json and country_package.json, #1138's gates.json);
  fingerprint 09ed486f...

Tests (one file at a time, after `uv sync --all-packages --locked
--inexact` for main's new sqlalchemy dependency): country spec 135,
NZ input closure 17 (1 skipped), NZ spec package 71, transport gate
bindings 110, group encode 78, unit construction 38, input closure 52,
concept mapping 168; all passed.

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.

1 participant