Skip to content

Add NZ transport scaffold and real-Axiom Frame bridge - #821

Closed
MaxGhenis wants to merge 3 commits into
mainfrom
codex/nz-transport-microcosm
Closed

MaxGhenis wants to merge 3 commits into
mainfrom
codex/nz-transport-microcosm

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Fixes #820. Related to #343; the broader NZ population, calibration, publication, and official-score replication work remains open.

Scope

  • Add a spec-only NZ country package with an immutable public US donor pin, reviewed WFF Axiom contract, cell-pinned Chronicle WFF/IWTC family-count references, explicit unfinished gates, and the agreed calibration-dashboard country block.
  • Add a closed person/household/family export contract: 11 substantive family inputs, 10 explicit unrelated padding fields, household-only stored weights, and formula-owned output exclusions.
  • Extend the shared Axiom adapter with canonical RuleSpec roots, explicit AxiomPeriod dates, bounded exact Decimal-to-native conversion, lossless Decimal HDF persistence, and group-parent ownership/nesting validation.
  • Exercise real Axiom software on three synthetic families in two households with unequal weights. Missing substantive inputs, missing/misplaced relationship columns, and formula-owned poisoned exports fail closed.
  • Document the reusable parallel Chronicle + Axiom + external-score lanes, followed by Microcosm/calibration/dashboard and PolicyEngine/Scorecard replication.

Verification

  • Final focused adapter/NZ tests: 65 passed, 4 optional skips.
  • Shared RulesEngine, materialization, and spec-schema tests: 33 passed, 9 optional-engine skips.
  • NZ typed-bundle re-emission round trip: passed.
  • Ruff, git diff checks, and CI test-file partition verification: passed.
  • Native engine source commit: bb4b5684870547756078a62f1866a77c5b56f7f3. RuleSpec pin: 3b663b3e6eb6408351154990be0c4b92d42c92da (upstream PR).
  • Independent review reproduced a misplaced-family-link bypass; this PR includes regressions and fixes for misplacement and deletion of a required link.

The fixture reproduces the upstream entitlement deltas 568.50 and 438.50 NZD and uses Frame-resolved family weights [2, 7, 7]; weighted fixture totals are 1,137 and 3,069.50 NZD. These are test results, not NZ population estimates.

Not a release

No donor population was downloaded, no calibration ran, and no Hugging Face release or dashboard data was fabricated. The country kernels remain contract-only and the planner refuses missing implementations.

Before the first solvable candidate: authenticate the donor; implement shared donor/family/geography operators; bind the 11 evidenced NZD/family/period fields and receipt states; activate cell-level facts with reviewed period/geography bridges and country thresholds. Treasury source activation remains pending immutable corpus publication and protected validation. Before an official fiscal-score replication, bridge annual entitlement to the published fiscal-year cash/accrual quantity, including impairment and payment tails.

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Independent merge-delta re-review APPROVE at 9f7dead: upstream mandatory explicit RuleSpec roots and canonical fixtures are preserved; NZ period, Decimal, and relationship checks remain intact. Independent focused checks: 79 passed / 4 optional skips. PolicyEngine's downstream adapter also passes all 30 focused tests against this exact Microcosm head and rulespec-nz 3b663b3 using the real HDF5 codec and native Axiom runtime. These are integration fixtures, not a calibrated NZ population or published budget score. CI remains the merge gate.

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Closing in favour of the graph-native Microcosm NZ v0 (Max's ruling d962; plan: NZ hub notes/1007/microcosm-nz-graph-plan.md). This PR predates packages/microcosm-graph, and its operation lists in build/nz/source_stages.json belong to the stage runtime the graph replaced. The live parts are split out:

@MaxGhenis MaxGhenis closed this Oct 7, 2026
MaxGhenis added a commit that referenced this pull request Oct 7, 2026
Finding 1. The hold-out check is now a validator,
holdout_leaks(cal, precal, holdout), in test_nz_spec_package.py. A
calibration or pre-calibration reference leaks when it:
- has a hold-out name;
- shares a Ledger identifier with a hold-out reference;
- resolves through a selector that one fact could satisfy together with
  a hold-out selector;
- belongs to a hold-out family.
Identifiers are compared across the fact-key and source-record-id fields,
as ledger_targets._ledger_fact_index resolves them. Selectors include
scaled_by_ratio operands (reference_fact_selectors). As in
_fact_matches_selector, a list matches by membership and an empty value
is a wildcard. A Hypothesis test plants a fresh name, identifier,
selector or family in either upstream set and requires a refusal. It
uses cross-field identifiers, five overlapping selector shapes, and
ratio operands on either side. The example test on the committed data
stays, and each row is now asserted to be identity with no operands.

Finding 2. Every refusal branch of crosswalk_errors, scenario_errors and
the modal_area tie check has a Hypothesis negative case. The new cases
found two holes, now closed:
- a crosswalk ta_code of None or a non-string passed;
- a rent_stock_factor of inf or True passed as a positive number.

Finding 3. The rulespec-commit scanner now treats a 7-40 hex run as a
mention when it is:
- anywhere in a string that contains "rulespec" (any case);
- any key or value below a key containing "rulespec";
- in a record whose repository contains "rulespec", in any spelling;
- under a key containing "commit" outside a foreign record;
- an all-digit SHA that YAML reads as an integer, or a hex mapping key.
The string rule is wider than the requested 40-character window, because
the package's own "git diff 6fe181fc 8dc2507" sentence sat 102
characters from "rulespec". A test plants five phrasings into the
package payloads: the two the review found and three found by the review
of this fix-up. On the committed package the scanner still finds only
the two reviewed commits. The docstring names both reviewed commits
instead of "the one pin".

Finding 4 and further wording:
- axiom_rules_bindings.json, as_rate_bridge.json, benefit_unit_rule.json,
  currency_bridge.json, export_contract.json, source_stages.json and
  spec/sources.yaml no longer describe unwritten code (packages G1, G4,
  G5a, G6 and G7) as running.
- MC11a reads "proposed (awaiting D1)".
- benefit_unit_rule.json cites executor _structural_columns and
  _validate_population_declaration: family_household_id is not
  structural. The unreachable parent_2 branch is replaced by the
  parent-1 rule and the parent_order check.
- docs/nz-take-up-engine-plan.md: the "nz appears only in" line, the
  crosswalk row (a placeholder with rows: []), the existing geography
  kernels and the MC11a wording.
- docs/nz-calibration-targets.md drops "only" from the TAWA WFF
  sentences and marks DistributionExplorer as a comparator, not a
  calibration target.
- release_contract.json no longer credits reform_validation.json with
  #821's official-score comparisons.
source_stages.json is re-receipted in sources.yaml, and the NZ golden is
regenerated.

Tests: 322 passed across the PR's nine targeted test files.
test_nz_spec_package.py has 70 tests, up from 44. Before the round-2
review, all 57 mutants of the validators turned a test red. On the code
round 2 changed, 10 of 10 did; an 11th survived only because its clause
was redundant, and that clause is removed.

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.

Add the NZ transport contract and real-Axiom Frame bridge

1 participant