Repository navigation
Add population-side transport graph kernels (NZ graph G5a) - #1159
Conversation
- Register donor H5, Chronicle facts and RuleSpec tree codecs explicitly. - Add ten neutral population kernels with destination-scale design weights, benefit units, fact-backed quantile maps and atomic geography support. - Delegate concept encoding and scenario allocation to G4; assign receipt flags through determined eligibility, payment screens and spec priorities. - Add synthetic H5 graph properties and wrapped-function differentials for mass, identity, memoization, seed stability, eligibility and runtime refusals. - Clarify that ADR step 6 relies on benefit-unit construction. - Pin the subnormal/large-weight gate example and describe refusal-only overflow behavior. Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
- Build CREATE's schema from the household and the unit rule's entity
instead of naming the country schema, and compute a zero eligible mass's
receipt rate without a float literal, so the transport source rules pass.
- Pin graph string storage (dtype_for_token("string")) in CREATE and in the
column kernels' casts, so pyarrow cannot change artifact dtypes.
- Require quantile band references to be unfiltered count facts on the
ranked unit (the aggregate entity when aggregating).
- Refuse take_up_rates in concepts.encode@1, concepts.encode_groups@1 and
transport.scenario_override@1; takeup.assign@1 owns the keyed draws, so
SeedSource.NONE holds.
- Pass encode_groups the whole mapping so its state/concept name guard
sees bindings outside the selected modules.
- Declare platform_bitwise numerics for geography.support_from_facts@1,
like the atomic geography kernels.
- Say in docstrings that the *_sha256 resource params only move node keys;
donor pins, facts_sha256 and the concept schema digest are checked.
- Tests: unequal band facts with shares derived from the facts; a donor with
two asset holders in one household; band-unit, boundary, take-up, path
filter, collision guard, target filter/entity, codec order, string storage
and stale donor pin refusals.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The #1159 delta review found the CREATE frame's strata Series built without a dtype, so pandas 3 inferred its `str` dtype, whose storage follows whether pyarrow is installed (string_storage=pyarrow on this machine). The graph pins Python storage so that an optional pyarrow cannot change an artifact's physical dtype, and the donor codec already stores strata as object. Build the strata (and the test-support expectation) with dtype=object, and assert the dtype in the CREATE differential; that assertion fails on fd38688. tests: test_transport_population_kernels.py 27 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged by the NZ hub (session local_e407a527) at 7ef990e with --merge. Gates: |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
G5a of the Microcosm NZ graph plan (Max's d962): the population-side transport kernels, country-neutral, as thin wrappers over the merged G3b transport functions (#1130) and G4 concept/unit functions (#1122).
What it adds (
packages/microcosm-build/src/microcosm/build/transport/)codecs.py):populace-us-h5-v1,ledger-consumer-artifact-v1andrulespec-tree-v1, registered by an explicit, idempotentregister_transport_codecs(registry). The donor decodes to a donor-scale Frame; facts and RuleSpec trees stay bytes, asgraph/codecs.pydoes.registry.py:population_kernels.py):transport.create@1,transport.boundary@1,transport.currency@1,transport.quantile_map@1;column_kernels.py):transport.unit_attributes@1,concepts.encode@1,concepts.encode_groups@1,takeup.assign@1,transport.scenario_override@1;geography_kernels.py):geography.support_from_facts@1.NZ_SCHEMAfor every input CREATE accepts, since it requiresrule.entity == "family"), derives source-ID seeds, installs destination-scale design weights and support strata, and lists the columnssplit_for_transportdrops in its receipt.takeup.assign@1implements the contract the G4 input closure declares: code 0 refuses; receipt priorities, exclusion groups and positive-payment screens come from spec data.*_sha256resource params move node keys and are format-checked only. Content is authenticated only for the donor pins (donor_sha256,donor_size),facts_sha256and the concept-schema digest.implementation_hash = source_hash(...)binds the wrapper and the wrapped modules, never the whole-spec fingerprint. Capabilities are deterministic, withKEYEDonly for seed and draw derivation (transport.create@1seeds,takeup.assign@1draws): the three encode kernels refusetake_up_rates, sotakeup.assign@1owns every take-up draw.geography.support_from_facts@1declaresPLATFORM_BITWISE(its NPZ is a deflated zip).consumes_se=False.Invariants (Hypothesis property tests, plus direct-function differentials)
descriptionorcitationmoves no key.run_graphrejects at run time a variant that owns a structural column, aftercompile_graphaccepts it.Tests (one file at a time)
At fd38688 (after the review fixes and the merge of main with #1158), rerun by the hub (population kernels again at 7ef990e: 27):
test_transport_graph.py15 (the source-scan rules: no "nz" word, no float literal inbuild/transport/*.py),test_transport_population_kernels.py27,test_transport_column_kernels.py17,test_transport_codecs_geography.py22,test_transport_gate_bindings.py110,microcosm-frametest_group_encode.py81: all passed.tools/ci_test_plan.py verify: 641 files registered, 0 violations. Ruff check and format pass on the changed files.Carried nits from earlier reviews
docs/concept-schema-transport-adr.md: "which step 6 below encodes" → "relies on" (Build benefit units from concept pointers and execute group encoding (NZ v0, G4) #1122 merge review).test_transport_gate_bindings.py: a Hypothesis@examplewith weights[5e-324, 1e300]; test wording now describes refusal near overflow (Add country-neutral gate bindings for transport gate batteries (NZ v0, G5c) #1138 verifier).gate_bindings.pyalready refuses a nonfinite ratio, so no implementation change.Not in this PR (activation, for G6/G8)
build/nz/benefit_unit_rule.jsonstill has a nullage_limit_years; the composer must pass a reviewed resolved rule.build/nz/precal_references.jsonreferences are placeholders until G8.axiom_input_closure.json; the composer needs a reviewed structured contract.Review
test_transport_graph.pyfailed (anNZ_SCHEMAname and a0.0literal). Non-blocking: two vacuous differentials (household aggregation, band-fact shares), keyed draws in kernels declaringSeedSource.NONE,BITWISEon a deflated NPZ, unpinned string storage, unchecked band-fact units, a pre-filteredencode_groupsmapping, test gaps, and resource-digest wording. No kernel correctness bug.NZ_SCHEMAby value); declared string columns use the graph's pinned Python storage; band facts must be unfiltered counts on the ranked unit; encode kernels refusetake_up_rates; 15 failing test items (from 10 test functions) on 8c8df19, and 17 named mutations caught. Merge of main (Refuse unsigned ids int64 cannot hold; match concept ids as int64 #1158) in fd38688, clean.take_up_ratesrefusal is consistent with plan §2.3 (any unfiltered NZ encode is also refused, fail-closed); Refuse unsigned ids int64 cannot hold; match concept ids as int64 #1158's int64 matching changes nothing the kernels feed. Nits applied in 7ef990e: CREATE strata stored as object (an inferred pandas string dtype followed pyarrow), with a dtype assertion that fails on fd38688; PR-body wording. Not applied (optional): a test for the zero-eligible-mass receipt branch, which is equivalent to the old code.Part of Microcosm NZ v0 (d962), package G5a of the NZ hub's graph plan. Built on a GPT-6.1 Sol Subfleet lane; verified, committed and opened by the NZ hub.
🤖 Generated with Claude Code