Skip to content

Tighten NZ's ageing and declarations tests after #1488 and #1507 - #1517

Merged
MaxGhenis merged 1 commit into
mainfrom
nzhub/nz-test-nits
Nov 5, 2026
Merged

MaxGhenis merged 1 commit into
mainfrom
nzhub/nz-test-nits

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Tests only. This PR carries cloud review 220's nit 1 on #1507 and review 216's nits 2 and 3 on #1488; each needed its PR in main first.

What changes

  • The P1 rounding test (test_nz_reference_aging.py, review 220's nit 1).

    • The gap. The old test_p1_rounds_once_and_the_truncated_numerator_refuses used p1_ty2026_to_ty2027_central. Truncation changes that factor's numerator (1029852 against 1029853), but rounding N to cents, rounding the projected quarters to cents and rounding q to six digits all give 1029853, so the test couldn't tell one rounding from any of them.
    • A new helper, _p1_numerators, computes a P1 profile's numerator in millionths at 60 digits under one half-even rounding, and under truncation and each of those three intermediate roundings.
    • test_p1_rounds_once_and_refuses_truncated_or_intermediate_numerators runs for the low, central and high profiles. It checks that one rounding gives _EXPECTED's numerator, then declares each alternative that differs and expects the resolver to refuse it ("expected factor mismatch"). It needs the feed, so CI skips it.
    • test_p1_profiles_separate_one_rounding_from_each_alternative needs no feed, so it runs in CI. It checks that across the three profiles every alternative differs from one rounding at least once.
    Profile One rounding Truncated N to cents Quarters to cents q to six digits
    low 1028904 1028903 1028901 1028903 1028904
    central 1029853 1029852 1029853 1029853 1029853
    high 1030799 1030799 1030800 1030800 1030800
  • The docstring of test_every_calibration_node_has_its_own_standin_as_the_only_writer (test_nz_transport_declarations.py, review 216's nit 2). It said composition checks the measurement proof on the skeleton alone. Since Prove extension calibration nodes' measurement producers in compose #1488, compose_transport_graph also runs _check_measurement_proofs on the extended graph with extension_nodes, where the compiled graph has to prove each nz.v.<V>.calibrate producer.

  • add_measurement goes (nit 3), with its two calls in _nz_composition_spec_and_config. It inserted a compile-only producer "until G declares one". NZ's packaged transport_graph.json and all eight calibration scenarios in scenarios.json now declare ird_taxable_income_ty2027_v1 through their stand-ins (nz.income.standin, nz.v.<V>.income.standin), so its early return fired on every call.

  • Formatting. NZ: re-declare the ageing factors from the September 2026 QES #1507 left one assert unformatted in each of test_nz_reference_aging.py and test_nz_money_normalization.py. ruff format (0.15.16, the version CI pins) now formats both files, and neither syntax tree changes. CI's lint job runs ruff check, which doesn't check formatting.

Invariants

  • The resolver refuses differing numerators. For each P1 profile, the resolver accepts the numerator from one half-even rounding of the exact ratio and refuses every alternative scheme whose numerator differs.
  • The three profiles together separate every alternative. The feed-free test checks this at the encoded 2.7% central growth, the PREFU 2026 rate that the generator requires (tools/generate_nz_reference_aging.py:131). A growth re-declaration has to update that literal in _p1_numerators too; the generator's check and test_root_enclosure_certifies_no_rounded_quarters_and_irrational_root carry the same 2.7. With the new numbers in place, the test fails if they stop separating any of the four schemes.
  • No runtime file changes. _MEASUREMENT stays, since six other tests in the file use it. With add_measurement's early return firing on every call, removing it leaves each graph's node list as it was.

Checks

  • Local, with NZ's pinned feed 89178aaf. The hub ran these one process at a time under its memory guard (-n 0). The tree was 78907367, a local commit of main 3e7a7045 plus NZ: re-declare the ageing factors from the September 2026 QES #1507 plus this change. Main has since gained Test low counts and digests, and anchors listed second, in later reports #1513 and Sign off the local cuts' target-fit rows (dbacb023, 83802786), and the company car base #1491, and neither changes an NZ file:
    • test_nz_reference_aging.py: 25 passed in 19.5 s, none skipped, so the feed-gated refusal tests ran;
    • test_nz_transport_declarations.py: 62 passed in 180 s.
  • CI: run 41931933866 on e48af5a0 passed all 11 checks. The 3.13 engine-free leg's pytest command names all three changed files and reports 25,886 passed, 291 skipped, 3 xfailed and none failed. The feed-gated tests skip there; the separation test has no skip path, so it ran. Main has since gained Add binding-local views to the Axiom adapter, registry, compose and closure (S2b PR 1) #1482, which shares no file with this PR; the merge audit comment gives the check.
  • Review: GPT-6.1 Sol (Subfleet job 20261104-170839-nz-nits-review) reviewed the same patch (c78112a7e..83b4fe2d9; this PR's patch-id matches). Verdict: APPROVE_WITH_NITS, needs Max: no.
    • It recomputed all 15 numerators in the table above and traced each refusal case to the resolver's factor comparison (reference_factors.py:611-614).
    • It confirmed that each incorrect resolver fails a profile: truncation fails low and central; N or the quarters rounded to cents fails low and high; q rounded to six digits fails high.
    • It confirmed that add_measurement returned early on all nine calls, and that the formatting hunks leave the syntax trees unchanged.
    • Its two nits concerned this body's wording, and this body carries both fixes.

🤖 Generated with Claude Code

Cloud review 220's nit 1 on #1507: test_nz_reference_aging.py's
test_p1_rounds_once_and_the_truncated_numerator_refuses used
p1_ty2026_to_ty2027_central. Its truncated numerator differs from the
declared one, but all three intermediate roundings match it, so the
test couldn't tell one rounding from rounding N or the projected
quarters to cents, or q to six digits. A new helper, _p1_numerators,
computes each P1 profile's numerator under one half-even rounding and
under truncation and those three roundings. The parametrized refusal
test sets each differing alternative as the declared numerator and
expects the resolver to refuse it. A feed-free test checks that the
three profiles between them separate one rounding from every
alternative.

Review 216's nits 2 and 3 on #1488:
- The docstring of
  test_every_calibration_node_has_its_own_standin_as_the_only_writer
  said composition checks the measurement proof on the skeleton alone.
  Since #1488, composition also runs _check_measurement_proofs on the
  extended graph, where the compiled graph has to prove each
  nz.v.<V>.calibrate producer.
- add_measurement inserted a compile-only producer "until G declares
  one". NZ's transport graph and all eight calibration scenarios now
  declare the measurement through their stand-ins, so the helper
  returned at once on every call. It and its two calls go.

#1507 left one assert unformatted in each of test_nz_reference_aging.py
and test_nz_money_normalization.py; ruff format now formats both files,
and neither syntax tree changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis merged commit 9b51a8b into main Nov 5, 2026
11 checks passed
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Merged by the NZ hub (session local_e407a527) at e48af5a with --merge. Gates: gh pr checks exit 0; MERGEABLE; not draft; no CHANGES_REQUESTED review. Reviewed head: e48af5a. Review: the GPT-6.1 Sol review (Subfleet 20261104-170839-nz-nits-review) returned APPROVE_WITH_NITS with needs Max: no and asked for no code change; body r3 carries both prose fixes. Head e48af5a has patch-id 2d3aa4a50f3731b6, equal to the reviewed c78112a7e..83b4fe2d9. CI run 41931933866 on e48af5a, whose parent is main fc5bb90, so the run tested this head's own tree: 11 of 11 passed. Main has since gained #1482 (5c57c51), which shares no file with this PR, and the merge is clean (tree c9691037). The removed add_measurement helper returned at once on both fc5bb90 and 5c57c51: the transport graph and all eight calibration scenarios already hold the ird_taxable_income_ty2027_v1 row, in blobs #1482 leaves unchanged, and load_transport_spec returns that JSON as it stands. The rest is a docstring, ruff format's re-wrap of one assert in each of two files, and the P1 rounding tests, which import nothing #1482 changed. The Belgium hub ran main's copies of all three files on 5c57c51's tree abff51a7, and they pass; it also confirmed the docstring describes #1488 correctly. A merge commit keeps the reviewed commit message.

@MaxGhenis
MaxGhenis deleted the nzhub/nz-test-nits branch November 5, 2026 01:10
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