Repository navigation
Cite NZ spec sources by symbol or stable record, never by a drifting line - #1282
Merged
Merged
Conversation
Invariant: No resource in the NZ spec package (packages/microcosm-build/src/microcosm/build/nz/, JSON and spec/*.yaml) cites a line number of a file in this repository. Another repository's file may be cited by line only when the same resource pins that file at a commit, in a mapping whose path names the file and whose commit is 7–40 lowercase hex. Rebuild #1141 on current main without merging its branch. Replace all local Python/JSON/Markdown line locators with symbols, exact JSON records, or a documentation heading. Preserve resource meanings and field shapes. Guard all extensions, nested values/keys, foreign pins, symbol resolution and JSON pointers; add properties and differentials. Regenerate only changed NZ golden resource hashes and fingerprint: benefit_unit_rule.json: 5c1cf16daaae482ea3ec53495f4c2e4ae452d928c6240a5284dbbf30cd2dfe37 -> a9e8cbfd38a64d2f8db0002fe8c31bb5a18fb34dbe59fa943336487ce95e2ca8 reporting_classifiers.json: b5af9e4737af4717d86aedfe651df8b3c18c3875763726e7a6a0b9b1168ed133 -> 789a07acd1b6724a12bbd9584ab9fa05bb01d0b675cc3a0fbc837b066dbec49e scenarios.json: 30f96f3063773d77e3c70119c8f5d99d3528eca87428903da00ca071ab34cfaf -> 9c70241a6203b3a66dc09587c8b955d9d421bbe32f018ea1542e7639f4c7507c country_fingerprint: 3208901a27e6f09885e5990517c80e2d418425d937aa33fb0f6dacbbf290dd23 -> 5e97ffb44bc37ebd3809e7f6cf2ad253ef4308339338b96b4bd78746a9c1888d package_fingerprint: 07ab080d68771a207290c83a9040b294f0775c96b74022938c9da13aa713ba20 -> bba0d1ac41b972314bfa5f95adb9884c462296713af50f68d3969246a0c6f112 No other repository pins moved; searched full hashes and 8-char prefixes. package_fingerprint is derived; no file pins it. spec_sha256 and documentation_sha256 are unchanged. Validation: 542 passed, 1 skipped across eight final targeted test-file runs; all four required mutants fail their intended tests and are restored. Ruff check/format and git diff --check pass. Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Extend NZ JSON citations with exactly-one keyed record selectors, conjunctions, RFC 6901 escaping and pointer suffixes. Refuse record-array index traversal in both citation scanning and resolution; retain scalar-array indexing. Use unique input identities in the closure and canonical_input in Axiom bindings (engine_input is not unique). Change only the three evidence strings. Regenerate the NZ golden; only reporting_classifiers.json and fingerprint move: reporting_classifiers.json: 789a07acd1b6724a12bbd9584ab9fa05bb01d0b675cc3a0fbc837b066dbec49e -> d1a5011e2163a4ceec5f030e155a02f7bc4a3bc0ad59f06fb7a406993319512f country_fingerprint: 5e97ffb44bc37ebd3809e7f6cf2ad253ef4308339338b96b4bd78746a9c1888d -> 9259333d5b7c212209654cebabc06122a8bc2dbe2cb1c776af17c6d02f1200fe Full hashes and 8-character prefixes checked; no stale tracked pins remain. Tests: test_nz_spec_package.py 279 passed; test_country_spec.py 135 passed; test_nz_axiom_input_closure.py 17 passed, 1 skipped. Total: 431 passed, 1 skipped. Initial regressions: 20 failed on the original resolver/resources. All four required mutants fail their intended tests and are restored byte for byte (1 index, 1 wrong-record, 3 scratch duplicate, 1 exactly-one failures). Ruff check/format, CI test-layout and graph-burndown verification, and git diff --check pass. Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
MaxGhenis
marked this pull request as ready for review
October 15, 2026 04:28
Share the file-line locator grammar between regular and extensionless files. Recognize Markdown and quote wrappers, forward/reverse L locators, punctuation, and range/list spellings. Document recognized forms and scope. Add deep mapping-key/value regressions and extend Hypothesis generation across wrappers and dash variants. Preserve symbol, JSON-pointer and keyed record citations, with explicit negative controls. Validation: NZ spec 619 passed; country spec 135 passed; NZ closure 17 passed, 1 skipped. Physical control and three restored mutants fail as intended. Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Attribute link locators to the destination and every filename in the label. Exempt a citation only when all attributed files are pinned foreign sources. Keep JSON pointer and keyed-selector fragments opaque to the line scanner. Document the prose-citation threat model and exercise its in-scope examples, deep key/value regressions, and generated link attribution and exemptions. Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Parse HTTP(S) file URLs in Markdown destinations and bare prose, including GitHub blob/raw forms, raw.githubusercontent.com, and line/column fragments. Retain repository identity so microcosm URLs are always local and foreign URLs require the existing same-resource path and commit pin. Leave unparseable links available for full-text scanning. Extend deep key and value regressions and the link attribution property across URL forms. Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Keep basename pin matching for prose while requiring exact paths for URL citations. Parse line fragments by their positive grammar and preserve raw fallback scanning when a fragment is not understood. Cover punctuation, common URL wrappers, encoded paths, lowercase and short ranges, commit permalinks, and tree/blame routes with regressions and properties. Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Contributor
Author
|
Merged by the NZ hub (session local_e407a527) at 7b6d122 with --squash. Gates: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #1141 and #1142. Their owner session is gone and both conflicted with main. This PR rebuilds #1141's guard fresh on main (121fd4d) and extends it to every NZ line citation main gained since then.
Invariant
No resource in the NZ spec package (
packages/microcosm-build/src/microcosm/build/nz/, JSON andspec/*.yaml) cites a line number of a file in this repository. Another repository's file may be cited by line only when the same resource pins that file at a commit. The pin is a mapping whosepathnames the file and whosecommitis 7–40 lowercase hex.#1141 limited this to
.pyfiles. This PR covers every extension, so it includes JSON line ranges such asaxiom_input_closure.json:1045-1052.Changes
benefit_unit_rule.jsonpointer blockconcepts.py:889-928concepts.py, the# --- Relationshipsblock,_pointer("partner_person_id")through_pointer("reference_person_id")benefit_unit_rule.jsondescriptionexecutor.py:638-645,:1549-1554,population_kernels.py:208-232microcosm.graph.executor._structural_columns,._validate_population_declaration,microcosm.build.transport.population_kernels.TransportCreateKernelbenefit_unit_rule.jsonparent-1 rule, hours evidenceconcepts.py:900-907,:1069-1083,policyengine_us_concepts.py:352-362,transport.py:843-849,policyengine-us.md:31reporting_classifiers.jsonimplementationpopulation_kernels.py:209-228,transport.py:843-856TransportCreateKernel,read_populace_us_donorreporting_classifiers.jsonevidence ×3axiom_input_closure.json:1045-1052,:1183-1204,nz.json:670-688,concepts.py:990-1000,1040-1051axiom_input_closure.json#/entries[input=…],nz.json#/bindings[canonical_input=…]) and symbolsscenarios.jsonMC12 noteops main run.py:168WEEKS_IN_MODEL_YEARin opsnz-lane/emtr_reproduction/run.pyatba6e7d6e. The hub read it there: line 168 isWEEKS_IN_MODEL_YEAR = D365 / D7, withD365 = Decimal(365)andD7 = Decimal(7)Tests (engine-free,
test_nz_spec_package.py)as_rate_bridge.json'srun.pylines and theengine_source_pins.rsfiles.microcosm.*symbol imports. Everyfile.json#/pointerresolves at HEAD.#/array[field=value,…], RFC 6901 escaping, optional pointer suffix) must match exactly one record. An index step into an array of mappings is refused in both scanning and resolution, because positions drift the way line numbers do. A Hypothesis property inserts the target at any position among distinct-keyed records and checks that the selector still finds it while the index form is refused. Inserting a dummy record at index 0 of the closure and ofnz.jsonleaves all three citations resolving to the same records. Keys:input, which is unique in the current NZ closure (140 of 140). The code's identity is the compositeInputRef(input, entity, module)(input_closure.py:345, duplicates refused at:480), and the resolver refuses any future ambiguity.canonical_input(89 distinct;engine_inputrepeats)./entries/99'sinputisnz_super_shares_residence_with_person_at_least_adult_age. Each cited symbol still does what the resource says.concepts.py:889-928, renaming a cited symbol, a pointer to a missing key, and a foreign pin changed tomain.Results at 9813c9e, each from a single-file run with JUnit counts:
test_nz_spec_package.py279 passed,test_country_spec.py135 passed,test_nz_axiom_input_closure.py17 passed, 1 skipped (optional real-engine probe). At 11fc476, the four transport-kernel files (24 / 30 / 30 / 31) andtest_spec_engine_country_bundles.py(21) also passed; this fix round didn't touch them. Before the fix, the new selector tests failed 20 of 20 against the index-based code. That count is from the fix lane's run, so it is author-reported and has no CI receipt.Re-pins
tests/golden/nz_country_spec.json:benefit_unit_rule.json5c1cf16d…→a9e8cbfd…reporting_classifiers.jsonb5af9e47…→d1a5011e…scenarios.json30f96f30…→9c70241a…3208901a…→9259333d…The NZ
package_fingerprint(07ab080d…→e2f1d71e…at 9813c9e;bba0d1ac…was the intermediate value at 11fc476) is derived (spec_engine/loader.py:434), and no file pins it. A search of full hashes and 8-character prefixes found no other pins.spec_sha256anddocumentation_sha256are unchanged.Status
#/entries/99,#/entries/115andnz.json#/bindings/40.L-prefixed spellings such as`concepts.py` lines 889-928andconcepts.py (L889-L928). Fix round 2 (b1be0d9) fixed it: the wrapper,L-prefix, reverse-order, dash andll.spellings are all refused.test_nz_spec_package.pyreports 619 passed. The old recognizer failed 172 of the 192 new regression cases, and the three recognizer mutants each went red.[upstream.rs](concepts.py) lines 889-928borrowed a pinned foreign file's exemption, which is a soundness bug.file.py:L12was flagged, a false positive.test_nz_spec_package.pyreports 662 passed.[source](https://github.com/PolicyEngine/microcosm/blob/main/…/concepts.py#L889-L928)were dropped from attribution.#Lfragments are read as line locators.{path, commit}pin whosepathequals the URL's file path. A pin naming only the file name does not cover a URL; this is deliberate.test_nz_spec_package.pyreports 947 passed.:!?…—after a bare URL hid its#Lfragment.pathis exactly that file's path. File-name matching remains for plain prose only.#Lfragments are parsed by grammar, so trailing punctuation can't hide them.?plain=1,#L5-10,blameand permalink URLs, and pin-path normalization. The parent commit got 206 of them wrong; this commit gets all 421 right.test_nz_spec_package.pyreports 1,189 passed.Out of scope: #1146, the US/UK guard, is orphaned too and also carries #1141's NZ part. It is tracked separately and should drop its NZ files on rebase.
🤖 Generated with Claude Code