Add academic_year period type to the source-package contract - #136
Open
juaristi22 wants to merge 1 commit into
Open
Add academic_year period type to the source-package contract#136juaristi22 wants to merge 1 commit into
juaristi22 wants to merge 1 commit into
Conversation
UK student-finance publications (SLC/DfE EES) assert academic-year
periods; the vocabulary had no way to state that without re-labelling
AY 2024/25 as a calendar or fiscal year. Adds academic_year to
ledger.core.ALLOWED_PERIOD_TYPES, documents the opening-year integer
convention (FY2024-25 -> 2024, AY 2024/25 -> 2024) beside the
vocabulary and in the consumer schema's period.type description (both
byte-identical schema copies), and proves the contract end to end:
validate_fact accepts academic_year and rejects unknown types, and an
academic_year fact set builds into a consumer artifact, loads, and
resolves at {type: academic_year, value: 2024}.
The JSON schema deliberately gains a description, not an enum: the
single enforcement point for the vocabulary stays validate_fact.
Closes PolicyEngine#131.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #131.
Lane:
ledger-contract-maintainer(.github/ledger-agents.yml) — judgesledger-contract+ledger-boundary. This is the one contract change the UK target migration needs, isolated per #131 so no data wave drags through contract review. Unblocks the SLC packages in #132 (wave 1) and #133 (slc_repayments).What changed
ledger/core.py—academic_yearjoinsALLOWED_PERIOD_TYPES, with a comment documenting the period-integer convention for split-label years: the stored integer is the opening year of the publisher's label — UK FY2024-25 →fiscal_year 2024(the existingpackages/hmrc/vat_firm_targets_2024_25precedent), AY 2024/25 →academic_year 2024. Publishers that label a fiscal year with a single year keep that label year (US federal FY2025 → 2025).docs/schemas/consumer_fact.v1.schema.json+policyengine_ledger/schemas/consumer_fact.v1.schema.json— byte-identicaldescriptionadded toperiod.typedocumenting the vocabulary and the opening-year convention. Deliberately a description, not an enum: the single enforcement point for the vocabulary staysvalidate_fact; the schema documents, it does not duplicate the gate.test_ledger_core.py:academic_yearfacts validate; unknown period types still fail withmalformed_period.test_ledger_consumer_contract.py: full round trip — twoacademic_yearfacts →write_consumer_facts_jsonl→build_consumer_artifact(profile shipped through the artifact) →load_consumer_artifact(schema-validates every row) →resolve_profile_targetsat{type: academic_year, value: 2024}resolves the exact fact onfactbasis.Behavior notes
CONSUMER_FACT_SCHEMA_SHA256derives from the packaged schema bytes, so it moves with this change. Newly built artifacts carry the new sha;load_consumer_artifactwill reject artifacts whose manifests pin the old sha — the designed exact-contract behavior. Existing consumer artifacts need a rebuild with the matching wheel.Checks
uv run ruff check ledger policyengine_ledger db scripts tests(repo-pinned, CI scope) — clean.uv run pytest -q— green on this branch (614 passed, 1 skipped).🤖 Generated with Claude Code