Skip to content

Fix leap-day cadence and fractional cadence rounding - #671

Draft
MaxGhenis wants to merge 2 commits into
masterfrom
uprate-cadence-rounding
Draft

MaxGhenis wants to merge 2 commits into
masterfrom
uprate-cadence-rounding

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Agent-written for Max, by a Codex cloud task for Max Ghenis; no person has reviewed it yet.

Changes

  • Find the latest February 29 when an annual cadence ends on leap day, even if the index has newer observations. test_cadence_uses_latest_leap_day covers a later observation and the eight-year gap across 2100.
  • Divide cadence amounts by fractional intervals using exact decimal values. test_flat_index_cadence_rounds_to_exact_cents[aligned-downwards] checks that a flat index preserves 0.29.
  • Tell authors who write a bare integer rounding interval to use a float or a mapping. test_chained_rounding_interval_forms covers the guidance and both valid forms.
  • Multiply cadence intervals before converting to the projected scalar type. test_flat_index_cadence_rounds_to_exact_cents covers the downward and upward bounds, nearest rounding, and an exact half that rounds to even.

Chained projections without cadence still return float artifacts after rounding: a flat index with downward 0.01 rounding on 0.7 gives 0.7000000000000001. The chained reference property compares exact float representations, so this change leaves that path as it is.

Open PRs #667, #669 and #670 also edit uprate_parameters.py and test_uprating.py.

Checks

  • All 11 new regression cases passed.
  • The parameter and period suite passed all 701 tests.
  • The full suite passed 4,333 tests, with four skips and three expected failures.
  • Ruff formatting and lint checks passed.

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits November 30, 2026 12:05
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Agent review for Max, written by Codex and posted by Antigravity for Max Ghenis (exact reviewed head 25a14b8490ca809bda08b7dd7210717aaa0fde5c).

VERDICT: REQUEST_CHANGES
HEAD: 25a14b8

Annual cadence can read the wrong index date, and fractional rounding can increase a projected amount while the index stays flat. Both regressions reproduce after a clean merge with current master.

Findings

  • P1 — uprate_parameters.py:995 and :1049. Reverse relativedelta offsets can shift configured annual dates. A February 28 end and March 29 enactment configured in 2003 read February 29 in 2004, yielding 150.0 instead of 125.0. A separate cross-year case checks February 27 instead of February 28 and raises ValueError: no valid start, end pair found instead of projecting 125.0. Construct annual dates from the configured month, day, and year offset. Use the same rule for validating and reading index dates, with explicit handling for dates absent in the target year. Validation · Projection
  • P1 — uprate_parameters.py:869 and :1079. Starting at 0.4 with an annual index of 100 → 320 → 320 and upward rounding to 0.3333333333333333, the head projects 1.3333333333333333 and then 1.6666666666666665. Both projections should be 1.3333333333333333. The first output’s float representation sits above the exact four-interval amount, so the next iteration rounds it up again. Keep the exact rounded amount for the next iteration and convert it when storing the dated value. Scalar conversion · Carry-forward
  • P2 — docs/usage/parameters.md:91. The chained-mode guide describes rounding a floating-point amount. With a flat index, 0.29 and downward 0.01 rounding give 0.29 with cadence and 0.28 through the documented floating-point calculation. Document the exact-decimal rule for cadence with float intervals. Uprating guide
  • P3 — changelog.d/uprate-cadence-rounding.fixed.md:1. The fragment has three sentences, while the PR guide asks for one concise sentence. Condense it after addressing the date regression. The .fixed.md name matches Towncrier and CI accepted it. CONTRIBUTING.md:12 points to the legacy changelog_entry.yaml, which returned HTTP 404. There is no axiom: requirement. PR guide · Contributing guide

Scope and description

I reviewed the full diff against merge base baf74aa5030f88c766654e4c3bde00db7ddc49e2. The throwaway merge with master a310bdf64169d8610a548562690a8de58d46b4ef was clean and matched GitHub’s merge tree. I used Codex from the GPT-6 family. The exact model and effort setting were unavailable.

Government-source verification was inapplicable. The changed values and dates are synthetic fixtures, and the operation projects dated parameter values independently of household composition or filing status. Core loads these projections through TaxBenefitSystem, and variable uprating can read them by parameter name. A literal search found cadence metadata in Core’s implementation, documentation, and tests, with no named production policy variable using the changed fixtures. A variable configured to read an affected projection could inherit the error. Parameter loading · Variable lookup

The description’s four listed changes are supported by their tests. They cover leap-day lookup across 2100, exact fractional division, the bare-integer exception note, and multiplication before scalar conversion with half-to-even rounding. The ordinary chained result of 0.7000000000000001 reproduced, and the reference property compares scalar type and repr. The description omits the second commit’s month-end and non-flat-index cases. Its counts are stale for this head. The current figures are 17 new cases, 707 parameter and period tests passed locally, and 4,338 passed in CI with four skipped and three xfailed. Ruff format and lint both passed. PR description · CI run

All three overlapping PR references resolve on the project’s GitHub repository. Each PR was open and touched both listed files. GitHub showed no reviews or comments on #671. Authorship and review outside GitHub remain unverified. The Claude Code link returned HTTP 200 at its official vendor page. #667 · #669 · #670 · Claude Code

Tests

Check Result
tests/core/parameters/operations/test_uprating.py, the only changed test file Head and throwaway merge each had 44 passed, 0 failed, exit 0
tests/core/parameters and tests/core/test_periods.py 707 passed, 0 failed, exit 0
Three regression comparisons below Merge base 3 passed. Head and merge each 3 failed with the outputs above. The comparison script exited 0 after recording results.
Zero amount, zero index numerator, zero denominator, negative half 4 passed, 0 failed, exit 0. The zero denominator raised the expected ValueError.
Ruff format, Ruff lint, and git diff --check All exited 0

All changed test files ran locally. Full-suite evidence came from GitHub CI. The scratch checkout and temporary directories were removed.

Proposed regression cases

Use cadence as at_defined_interval, amount and index as their respective values maps, and expect as assertions on the projected amount.

- case: configured_annual_end_day
  cadence: {start: "2003-01-01", end: "2003-02-28", enactment: "2003-03-29"}
  amount: {"2004-02-28": 100}
  index: {"2004-01-01": 100, "2004-02-28": 125, "2004-02-29": 150}
  expect: {"2004-03-29": 125.0}

- case: configured_annual_start_day
  cadence: {start: "2004-02-28", end: "2005-03-01", enactment: "2005-03-02"}
  amount: {"2006-03-01": 100}
  index: {"2005-02-28": 100, "2006-03-01": 125}
  expect: {"2006-03-02": 125.0}

- case: flat_index_after_fractional_rounding
  cadence: {start: "2026-05-01", end: "2027-05-01", enactment: "2027-07-01"}
  rounding: {interval: 0.3333333333333333, type: upwards}
  amount: {"2026-07-01": 0.4}
  index: {"2026-05-01": 100, "2027-05-01": 320, "2028-05-01": 320}
  expect: {"2027-07-01": 1.3333333333333333, "2028-07-01": 1.3333333333333333}

This branch has not been deployed

No deployments
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