Skip to content

Add an optional freshness check for dated facts in scenario packs - #103

Open
avalyset wants to merge 1 commit into
SimulaMet:devfrom
avalyset:feat/fact-freshness
Open

avalyset wants to merge 1 commit into
SimulaMet:devfrom
avalyset:feat/fact-freshness

Conversation

@avalyset

@avalyset avalyset commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

#102 fixed a G value that had been wrong in nav_aap for five months. Nothing in a pack records when a figure was last checked or when it needs checking again, so nothing flagged it.

This adds an optional convention for that. A scenario can list the dated facts it relies on in metadata.facts, each with its value, source URL and quote, when it was verified, and a review_by date set by the rule's own rhythm: G every 1 May, tax rates and the copayment cap every 1 January. stale_facts(packs, as_of) returns the facts past their review_by.

It is opt-in: packs without facts are untouched. It reads no clock, and the tests use fixed dates, so CI won't turn red on a calendar date. I've filled it in only for our own packs, for the figures that change yearly.

Run with as_of set to 2 May 2027, it returns the G-derived facts in nav_aap: the check that would have caught the 130 030 typo.

Tests: 1368 passed, 17 skipped: the 1350 passed and 17 skipped of the base at 7a0877d, plus the 18 new ones.

A scenario can now list the dated facts it relies on in metadata.facts:
claim, value, valid_from, verified_at, review_by, source_url and
source_quote. stale_facts(packs, as_of) returns the facts whose review_by
is before as_of. It reads no clock, so the tests use fixed dates.

review_by follows the rule's own rhythm: G-derived rates every 1 May, tax
rates and the copayment cap every 1 January. A figure fixed in statute
has review_by None and is never returned; a missing review_by key is an
error, so a misspelt key cannot hide a fact from the check.

Filled in for the yearly rates in nav_aap, skatteetaten, helfo and
lanekassen, verified 2026-10-07. Like the rest of metadata, the field
never reaches the models.

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