Plan: SNAP and WIC eligibility decisions live once, in the federal layer (#3367)
Status: Done (2026-11-11) — the four SNAP and WIC decisions are federal; Medicaid, CHIP, TANF and CAPS wait on #3373
Closes: #3367
Epic: &167
Issues: #3367 (parent) · #3369 U1 (w2) · #3370 U2 (w3) · #3371 U3 (w3) · #3372 U4 (w2); U4 closes the parent. Out of scope, filed: #3373 (classify the Medicaid, CHIP, TANF and CAPS decisions)
Branches: refactor/ruleset-bare-names, feat/decision-contract-at-boot, refactor/federal-snap-wic-decisions, feat/declared-ruleset-overrides
This is a Design + Scope plan: GitLab owns tracking, the child issues carry the implementer brief, and the plan freezes when U1 starts. It runs after #3365 and before plan config-git-source U4 (#3262), so the federal and Georgia configuration repositories are seeded with SNAP and WIC already in their final shape (maintainer, 2026-11-10).
Context
A jurisdiction pack holds up to 16 JDM decisions. The federal layer (rulesets/federal/) holds tables and six narrow decisions, none of the program eligibility decisions. Each pack was made by copying Georgia’s, so "identical across packs" does not show that a decision is federal.
What makes a decision federal is the law: the program’s rules are uniform nationally and a state varies them only through options federal law enumerates. canopy records those options in compliance/federal-options/<program>.toml (ADR-032).
SNAP and WIC meet that test. snap-eligibility, snap-benefit-calculation, snap-self-employment-deduction and wic-eligibility carry no state identity outside _description text. Their state variation arrives as context.thresholds.* values the service builds from the pack’s jurisdiction.toml (build_snap_eligibility_thresholds, services/canopy-snap/src/determine.rs; build_wic_eligibility_thresholds, services/canopy-wic/src/eligibility_ruleset.rs). The one structural difference between packs is BBCE: Georgia’s and the reference pack’s snap-eligibility have the BBCE arm, and it is reached only when context.thresholds.bbce_gross_income_limit != null (switch s-bbce-pack), which is the snap.bbce election expressed as data. These four are also the decisions the out-of-tree Texas pack carries, and its copies have drifted: its snap-eligibility lacks the #3361 no-benefit row and the #3319 medical-threshold condition.
Medicaid, CHIP, TANF and CAPS do not, as written. Their decisions name Georgia’s programs in their logic (Pathways, P4HB, PeachCare, the EDWP, NOW and COMP waivers in medicaid-eligibility-hierarchy, medicaid-magi, medicaid-cmd-cascade-priority) or rest on a state-designed formula (tanf-eligibility and tanf-benefit-calculation on a Standard of Need and family maximum; TANF is a block grant). They need a federal skeleton separated from the state’s design, which is design work tied to #655, not a move. They stay in the packs.
snap-certification-period is jurisdiction policy by design and stays in each pack.
Two mechanisms are missing for a decision to live apart from the pack and from the service. canopy-rules resolves a decision by its embedded name (NamedFilesystemLoader::from_snapshot, services/canopy-rules/src/engine.rs), and five decisions carry a pack prefix there that services build from the jurisdiction. And whether a decision’s context.thresholds. and input. references match what the service supplies is checked only by unit tests (canopy_test_lib::threshold_sync), against files in the same checkout.
Scope
In scope:
-
Bare names for every decision; no service builds a ruleset name from a jurisdiction.
-
A boot-time contract check in canopy-snap and canopy-wic.
-
The four SNAP and WIC decisions live once in the federal layer, with a copy in the
test-federalfixture layer; packs delete theirs. -
A pack declares each lower-layer decision it shadows; an undeclared collision refuses the boot.
Out of scope:
-
The Medicaid, CHIP, TANF and CAPS decisions, and the state wording four of them emit: #3373 classifies each against its option registry and plans the split.
-
snap-certification-period. -
Changing any rule’s outcome.
-
The Texas repository’s edits: its agent deletes its four copies after U3, told on the
ruleschannel.
Design
U1 (w2) — Bare names
Every decision’s name equals its file stem, in all in-tree packs. Services ask for a constant: certification_period::ruleset_name (canopy-snap) and the format!("{}-caps-eligibility", …) in services/canopy-caps/src/determine.rs are replaced by constants, as are the SNAP eligibility, self-employment and WIC lookups and the name in services/canopy-caps/src/derivation.rs. The rule is enforced by cargo xtask rules check (xtask/src/cmd/rules.rs, the compile pass that already reads each decision’s name and visits every layer under both roots, Georgia’s included): a decision whose name is not its file stem fails the check, naming the file. neutrality_lint's narrower detect_default_json_name (reference pack only; the lint never scans Georgia, UNSCANNED_LAYERS) is deleted in its favour. rulesets.adoc "Adding a ruleset" drops the {jurisdiction}- rule.
Stored snapshots name the old rulesets in their derivation graphs. Before 1.0 a deployment re-seeds; no alias is kept.
U2 (w3) — The decision contract, checked at boot
extract_threshold_refs and extract_input_refs move from crates/canopy-test-lib/src/threshold_sync.rs to a new canopy_rules_client::contract module; canopy-test-lib calls them from there. The module adds:
pub struct Supplied<'a> { pub thresholds: &'a serde_json::Value, pub inputs: &'a [&'a str] }
pub fn check(decision: &str, raw_jdm: &str, supplied: &Supplied<'_>) -> Result<(), ContractError>;
// ContractError::Unsupplied { decision, kind: Thresholds | Inputs, names: Vec<String> }
check fails when the decision reads a context.thresholds.<path> or input.<name> the service does not supply, naming every missing one. Supplying more than a decision reads is allowed (a federal decision may stop reading a value).
canopy-snap and canopy-wic call it in main after loading parameters, for each decision they evaluate, on the file the configuration snapshot resolves (ConfigSnapshot::resolve("<name>.json")), with the thresholds object built from the loaded parameters and the service’s list of input keys. The builders are build_snap_eligibility_thresholds (snap-eligibility), build_wic_eligibility_thresholds (wic-eligibility), and for snap-self-employment-deduction the two-key object services/canopy-snap/src/se_deduction.rs sends (standard_deduction_pct, standard_deduction_enabled), lifted into a build_se_deduction_thresholds(&SnapParameters) function the evaluation and the check share. snap-benefit-calculation reads no threshold; its check covers inputs only. A failure refuses the boot with the error. The existing unit tests keep checking the fixture packs through the same function.
Erratum (2026-11-11): no service evaluates snap-benefit-calculation (a pass-through stub), so it has no boot check; canopy-snap checks the four decisions it does evaluate, snap-certification-period and snap-alien-eligibility included.
U3 (w3) — The four decisions move
-
snap-eligibilitybecomes one file: Georgia’s, which has the BBCE arm. The implementer shows with the parity test that test-min and test-max, whose copies lack the arm, decide every corpus row as before under Georgia’s file. If any output differs, the unit stops and the difference goes to the maintainer. -
git mvthe four files fromrulesets/georgia/torulesets/federal/; rewrite_descriptiontext to cite the CFR only (the PAMMS cites are rows of Georgia’scitations.tomlalready). Copy the four intofixtures/config/test-federal/. Delete the copies indefault,test-maxandtest-min. -
compliance/*.tomlrows that name a moved file by path follow it. -
ADR-003 and ADR-006 gain an amendment each: a decision is federal when its only state variation is options in the program’s federal option registry, supplied as pack data; otherwise it is the pack’s.
Erratum (2026-11-11): the unified file changed six corpus rows each for test-max and test-min, the rows that supply a BBCE election as thresholds, which their old copies ignored. The maintainer accepted it (BBCE is a State option the fixture elects) and those rows were re-recorded; no other row changed. test-min, which shipped no wic-eligibility, now resolves the federal one, so its recording gains that decision's rows. The federal text is the reference pack's copy, whose descriptions already cited the CFR only; its logic equals Georgia's.
U4 (w2) — Declared overrides
canopy-config.toml gains overrides = ["<decision name>", …], default empty: a field on RawManifest and Manifest (crates/canopy-config/src/manifest.rs), carried onto Layer as pub overrides: BTreeSet<String> where load_layer already copies manifest.kind (crates/canopy-config/src/snapshot.rs).
NamedFilesystemLoader::from_snapshot already groups the listed files by layer, lowest first. It passes from_files each file with its layer’s overrides (the signature becomes from_files(files: &[(PathBuf, &BTreeSet<String>)]); the test callers pass an empty set). In the collision branch of from_files, where a later file’s name replaces an earlier one’s, the replacement is refused unless the later file’s set contains the name; the error names both files and the manifest key. cargo xtask rules check prints each declared override. No in-tree pack declares one.
Erratum (2026-11-11): U4 was built before U3, which waits on a maintainer decision (#3371); it does not depend on U3. from_snapshot lists each layer’s directory itself, so a lower layer’s decision under the same file name is seen and needs the declaration too. Two files of one layer carrying one name are refused. U3, the last unit, sets Status to Done and closes #3367.
Risks
| Risk | Class | Mitigation and the test that pins it |
|---|---|---|
Unifying or moving a decision changes a determination. |
silent |
Parity test (U1, U3): committed outputs per pack for a committed input corpus, recorded on main before U1. |
The federal repository changes a decision to read a value a deployed canopy does not supply. |
fail-closed |
The service refuses to boot naming the value (U2). Contract test: a decision reading an unsupplied threshold, and one reading an unsupplied input, each refuse. |
A pack keeps a stale copy of a federal decision, as Texas’s did. |
fail-closed |
An undeclared name collision refuses the boot (U4). Contract test. |
A declared override drifts from the federal decision it replaces. |
fail-open |
Not prevented: an override is the pack’s decision. |
The |
silent |
Regression test (U3), in a |
A state-designed decision is later moved to the federal layer by its sameness across packs. |
silent |
The neutrality lint already scans the federal layer for pack identity; the ADR amendments state the rule. No new gate. |
A stored snapshot names a ruleset that no longer exists. |
fail-closed |
Re-seed, as for every snapshot change before 1.0; |
Tests
-
Regression (parity), U1 and U3:
services/canopy-rules/src/engine.rs,pack_infra_tests::every_pack_decides_the_corpus_as_before. For each in-tree pack and each of its SNAP and WIC decisions, the inputs ofcrates/canopy-test-lib/fixtures/rulesets/for that decision, plus the boundary rows of the existing per-pack engine tests, evaluate to outputs committed beside them. Recorded on main before U1; no later unit re-records them. -
Contract, U1: a decision whose
namediffers from its file stem failsrules check, naming the file (unit test inxtask/src/cmd/rules.rs), and the real layers pass it (pack_infra_tests); the existingjurisdiction_gate_catches_a_pack_qualified_ruleset_name_in_production_code. -
Contract, U2:
canopy_rules_client::contractunit tests: an unsupplied threshold and an unsupplied input are each refused by name; a superset passes. One test per service that its real decisions and its real builder pass. -
Regression, U3: the byte-identity test above; under null BBCE thresholds no output of
snap-eligibilitycarries a BBCE basis. -
Contract, U4: an undeclared collision refuses naming both files; the same collision declared loads, the higher layer winning.
Delivery
Each unit is one MR that Closes its child issue and lands through the train, with a CHANGELOG.adoc == Unreleased entry. Docs with the change: rulesets.adoc (where a decision lives and why, bare names, the contract, overrides), api/canopy-rules.adoc (the collision refusal), shared-crates.adoc (canopy_rules_client::contract), jurisdiction-onboarding.adoc (a new pack carries no SNAP or WIC decision but snap-certification-period), and the two ADR amendments in U3. U4 sets this plan’s Status to Done and closes #3367. The Georgia and Texas agents are told on rules when U1 and U3 merge.