Skip to content

Bind UK Scenario receipts to their data-load phases - #752

Merged
MaxGhenis merged 1 commit into
mainfrom
fix/phased-scenario-receipts
Nov 12, 2026
Merged

MaxGhenis merged 1 commit into
mainfrom
fix/phased-scenario-receipts

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Fixes #751

The UK engine can apply a Scenario's parameters before data loading and its modifier afterwards, while the aggregate timing flag reads False. The existing receipt binder hashes that flag and can describe the wrong execution order.

Add phased_scenario_reform_identity, which binds the engine's actual phase split. It keeps existing scenario/v1 digests for single-phase inputs and uses policyengine-uk.phased_scenario/v1 for two effective phases. It also handles a mixed-timing sum whose parameters all run before loading and leave no effective after-load part. The legacy binder rejects timing mismatches, and composition v1 refuses phased members.

The API reuses the existing modifier checks. Its live handle rechecks the original Scenario after parameter, timing, modifier or default changes. The public export, JSON schema and receipt documentation include the new representation.

Invariants:

  • Each identity follows parts_by_data_load(); the mixed split includes common parameters once, before loading.
  • Changes to either effective phase affect the digest or trigger a binding error.
  • Existing valid single-phase and composition identities keep their digests.
  • Both Scenario APIs reject unsupported dated reform objects rather than omitting them.

Validation: 57 focused tests pass, including 29 new API tests and 28 existing receipt/composition regressions. A direct comparison against the original source matches all 20 existing identities tested. Schema generation, formatting and lint checks on the changed files pass.

The full-source snapshot passes make format. Its make lint passes with Ruff 0.14.6; Ruff 0.12.11 from the existing lockfile reports the same 67 UP038 findings on the raw base and this proposal, with no new findings. The CI workflow installs Ruff without a version pin. Repository CI still needs to run at the PR head. Keep this PR in draft.

axiom: n/a: provenance contract; no policy-rule changes.

@MaxGhenis
MaxGhenis marked this pull request as ready for review November 12, 2026 19:50
@MaxGhenis
MaxGhenis merged commit 6c55903 into main Nov 12, 2026
14 checks passed
@MaxGhenis
MaxGhenis deleted the fix/phased-scenario-receipts branch November 12, 2026 19:53
anth-volk added a commit that referenced this pull request Nov 13, 2026
Main moved to 6.19.0 (#752, #754, #756, #758). Only the two TRACE TROs
conflicted; both were regenerated from the merged manifest with
`bundle.py generate --include-tros --strict-tros`, so they now name
bundle 6.19.0 and its manifest digest. `bundle.py check --published-spm
--include-tros --strict-tros` and `uv lock --check` pass.

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.

Preserve UK Scenario data-load phases in execution receipts

1 participant