Plan: CHIP Is Its Own Signed Program (#2319)
- Context
- Scope
- Design
- D1 — The served program is a typed, orchestrator-gated input
- D2 — Operation identity (#2673)
- D3 — Key program vs claimed program
- D4 — Operation binding
- D5 — Events
- D6 — The newest read is per (person, program)
- D7 — Slots
- D8 — Screening is a separate pass
- D9 — CHIP inputs and projection
- D10 — canopy-web, the seed and notices
- D11 — CMD orders the pair
- Migrations
- Units (weights by complexity) — U1 → U2 ‖ U3 → U4
- Verification
- Documentation Updates
- Review log
Status: Done (2026-10-21) — !1700, !1702, !1701, !1704
Epic: &135
Issues: #2942 U1 (w8) · #2673 U2 (w8) · #2943 U3 (w3) · #2319 U4 (w8)
Branches: feat/medicaid-served-program (U1) · fix/medicaid-operation-idempotency (U2) · feat/notices-served-program (U3) · feat/chip-signed-program (U4)
This is a Design + Scope plan: GitLab owns tracking, the child issues carry the implementer brief, and the plan freezes when U1 starts.
Erratum (2026-10-21, U2): D2’s Candidate::Adopted keeps one envelope; the operation read’s envelopes become one adopted candidate each (read_back_refusal returns Vec<Candidate>, which the dispatch loop already collects per program), so each passes the existing per-envelope intake. The plural read’s bearer audience is a parameter of a generic read_signed, which read_envelope (canopy-snap’s reads) and fetch_operation_envelopes (canopy-medicaid’s) both call.
Erratum (2026-10-21, U4): D10’s seed step changes nothing. The seed files no Medicaid application: phase 17 writes Medicaid rows against SNAP filings, and phase 18’s single-program Medicaid request stays valid. The CMD journey’s household has no child, so it asserts that both programs are re-determined and that no CHIP approval stays live; the PeachCare child’s transitions are the two infra tests. The #853 journey binds each NOA to its decision by subject and program; the reason text is pinned by canopy-notices' render tests, since the e2e container reads no PDF text. The worker Notices tab’s hidden CHIP letters are pre-existing and fixed separately (#2946).
Erratum (2026-10-21, U4): a_dispatch_with_no_claimed_operation_binds_no_medicaid_envelope is not its own test. It is the unclaimed case of the routing unit test a_medicaid_served_envelope_binds_only_the_claimed_operation (quarantine.rs), because every interactive dispatch claims an operation. The re-land conflict test splits in two: the conflict half stays on Medicaid, with each landing signing its dispatch’s operation, and the identical half moves to SNAP, which binds no operation yet (#2947). Out-of-scope follow-ups are filed: #2947 (SNAP operation binding), #2948 (portal wizard), #2949 (Medicaid signed coverage start).
Context
canopy-medicaid cannot tell a CHIP run from a Medicaid run. It signs program: medicaid and no operation_id, and stores the JWS but not the bytes it signed (services/canopy-medicaid/src/store/mod.rs create_determination). canopy-eligibility’s ProgramServiceRegistry::signing_program maps Chip to Medicaid both for the verifying key and for the claim quarantine.rs routing_mismatch binds. PeachCare, the only CHIP-track group, is assignable on a medicaid dispatch. A run naming both programs duplicates rows and medicaid.determined events, races on the per-person supersession chain (medicaid_determinations_supersession_uq) and reads an unfiltered newest row.
Nothing dispatches chip today: canopy-web files Medicaid/CHIP as medicaid (services/canopy-web/src/api/actions_intake.rs selected_programs) and CMD change orders name ["medicaid"] (services/canopy-medicaid/src/events.rs stage_determination_order). Eligibility’s program_determinations_operation_uq is UNIQUE (operation_id), but medicaid answers one envelope per subject. Replay adoption (#2439) and body-mismatch read-back (#2676) are SNAP-only (orchestrator.rs replayed_operation, mismatched_operation), which #2673 records as medicaid’s open idempotency hole.
Governing records: ADR-002 (Amendment 5’s CHIP paragraph becomes false), ADR-035 (its byte-identical-context as-built note becomes false), ADR-003 (codes are data), ADR-016 (forward-only migrations).
Maintainer rulings (#2319): (1) CHIP signs program: chip; (2) each slot attests only its own program — the Medicaid slot excludes PeachCare; (3) any Medicaid group denies CHIP under a new code; (4) persist the served program — column, per-(person, program) supersession, newest read, events, FTI ChipEligibility; (5) sign and bind operation_id; (6) a notice per decision — each slot’s outcome is its own NOA (42 CFR 457.340(e), 435.917); (7) no in-place transition for existing filings — Medicaid is not live (UAT is SNAP-only), devstacks reseed, a pre-cutover filing stays Medicaid-only (the #1984 precedent).
Scope
In scope: the served program end to end (contract, persistence, events, worker view); medicaid operation identity and replay adoption (#2673); notice routing per served program; slot semantics and the medicaid_eligible code; eligibility’s program and operation binding; CHIP dispatch from canopy-web, the seed and CMD orders.
Out of scope: canopy-portal’s applicant wizard (files SNAP only — pages/apply.rs; a follow-up feature); binding operation_id on snap’s returned envelopes (follow-up); a signed medicaid benefit basis (medicaid applies none); a per-person medicaid_assigned_group (stays a household scalar); narrowing ruling 3’s screen to fewer Medicaid groups.
Design
D1 — The served program is a typed, orchestrator-gated input
canopy_reference::enums::MedicaidProgram { Medicaid, Chip } (serde snake_case, ToSchema, From<MedicaidProgram> for Program, TryFrom<String> for #[sqlx(try_from)]). canopy-medicaid’s ApplicationContext.served_program is required (no serde default; a body without it is the extractor’s 422). Naming chip without ConfidentialClient::Eligibility is a 403 from handlers.rs enforce_provenance_gates, the gate trigger and as_of use; a direct caller may name medicaid. The generic eligibility ApplicationContext gains served_program: Option<MedicaidProgram> (skip_serializing_if, the postponement precedent); only the Medicaid and Chip arms of map_context (mappers/mod.rs) set it.
D2 — Operation identity (#2673)
canopy-medicaid’s ApplicationContext.operation_id: Option<DeterminationOperationId> is orchestrator-only (403 otherwise). Every subject’s envelope signs it. Every row written from U2 on stores signed_payload — SignableDetermination::canonical_signing_payload() (crates/canopy-signing/src/envelope.rs), computed once at signing, as canopy-snap stores since #1984 — and, when the dispatch carried one, operation_id; legacy rows keep both NULL, which the CHECK permits only without an operation. A 23505 on medicaid_determinations_operation_subject_uq is 409 operation_already_determined and rolls back every row and event. GET /v1/determination-operations/{operation_id}/envelopes answers Vec<DeterminationEnvelope> ordered by person, admitted to OPERATION_MINTER (eligibility’s system token), 404 coded operation_not_determined. DeterminationEnvelope and OPERATION_NOT_DETERMINED move from canopy-contracts-snap/src/envelope.rs to canopy-contracts-eligibility/src/envelope.rs; snap’s consumers update (no re-export). Medicaid signs no benefit_effective_date or basis — it applies none.
Eligibility’s replayed_operation and mismatched_operation (orchestrator.rs) admit Medicaid-served programs. A plural fetch_operation_envelopes reads canopy-medicaid’s route; read_envelope takes the token audience from ProgramServiceRegistry::service(program) instead of its hard-coded CanopyService::Snap. adopt_replayed_operation and resolve_body_mismatch call the read the dispatched program needs, and Candidate::Adopted carries envelopes: Vec<DeterminationEnvelope> (one for snap). Adoption verifies and records each envelope through the path a fresh response takes.
D3 — Key program vs claimed program
ProgramServiceRegistry::signing_program becomes key_program (Chip → Medicaid), used only for verify_with_history; TrustedRouting::signing_program becomes key_program() and serves only that verification (quarantine.rs verify path). routing_mismatch and every other binding site compare envelope.program with routing.program, the dispatched program. The services/canopy-eligibility/src/store/models.rs rebuild uses the dispatched program; settle_matrix::served_by_medicaid keys on ProgramServiceRegistry::service(p) == CanopyService::Medicaid.
D4 — Operation binding
TrustedRouting gains operation: Option<DeterminationOperationId>, the dispatch’s claim (claims_by_program; the bulk arm’s case operation). For a Medicaid-served program routing_mismatch answers "operation_id" when the routing has no operation or the envelope names another. quarantined_determinations.dispatched_operation_id records the claim so quarantine_ops.rs routing_of can rebuild it; a quarantine without one fails reverify (provenance_rejected).
D5 — Events
medicaid.determined keeps its routing key; the payload gains "program": "medicaid" | "chip", and the EventEnvelope asserts with_programs([served slug]) — canopy-security scopes an audit row from the envelope assertion or the routing key, never the payload (services/canopy-security/src/event_parsing.rs derive_programs). The redaction event asserts the row’s program.
D6 — The newest read is per (person, program)
list_newest_per_subject is DISTINCT ON (person_id, program) with program on every row. canopy-web collapses each subject to its covering slot — an approved row wins, else the newer — in a pure covering_row_per_subject (determination_view.rs). That is sound because every dispatch path runs the pair together (D10, D11), so each program’s newest row is its determination of record. canopy-portal already picks per (program, person_id) from eligibility’s rows (home.rs authoritative_rows) and needs no change.
D7 — Slots
After the cascade, in canopy-medicaid’s evaluate_member: the Medicaid pick is the hierarchy (hierarchy_pick, extracted) over eligible groups whose MedicaidCategory::program() — derived from track(), "chip" → Chip — is Medicaid. The Medicaid slot approves on it or denies. The CHIP slot is screened out (medicaid_eligible; 42 USC 1397jj(b)(1)©, 42 CFR 457.310(b)(2)) whenever a Medicaid pick exists, else takes the hierarchy over the CHIP-track groups. src/determine/slot.rs holds SlotVerdict { Assigned { category, rationale }, MedicaidEligible, Unassigned } and a pure slot_outcome. Each slot’s denial evidence names only its own groups; the full 38-group cascade is still persisted (PAMMS 2052).
D8 — Screening is a separate pass
The cascade’s per-COA reasons resolve as today (resolve_denial_reasons, medicaid_eligible: false), so no group’s persisted explanation changes. When the CHIP slot is screened out, resolve_screening_reasons evaluates the ruleset once more per CHIP-track COA with medicaid_eligible: true; those pairs are exactly the CHIP slot’s denial_reasons_by_coa, a CHIP-track group that passed its own criteria included (the ineligible-group collector is not used). medicaid-denial-reasons.json gains input c-medicaid-eligible (input.medicaid_eligible, '' on every existing row) and a first rule r-medicaid-eligible (== true → "medicaid_eligible"). The rule names no group: the neutrality-gate counts are unchanged. The label (medicaid_labels.rs MedicaidEligible): "You qualify for Medicaid, which covers you instead of this program."
D9 — CHIP inputs and projection
SOLQ enrichment (orchestrator.rs medicaid_requested) fires when medicaid or chip is requested, so a CHIP-only run screens on the same SSA facts. The medicaid_assigned_group projection (orchestrator intake; quarantine_ops.rs reconcile_combined_result) reads Medicaid-served programs, so a PeachCare-only child keeps a group.
D10 — canopy-web, the seed and notices
canopy-web files Medicaid/CHIP as Program::Medicaid.storage_slugs() and runs the requested slugs within it (applications.rs run paths, program_in_request_set) — screen-and-enroll, 42 CFR 457.350; canopy-applications already accepts chip. tools/canopy-seed files chip beside every medicaid request. canopy-notices gains a served_program discriminator (payload key program) tiered with status, per the recipe in event_routing.rs (typed EventRouting field, PayloadDiscriminators key, tier); both rulesets/{georgia,default}/notices/manifest.toml route served_program = "chip" approvals and denials to the existing templates.chip.noa-{approval,denial} (regulatory_basis = "42 CFR 457.340(e)", addressing = "responsible_adult_for_minor"); generator.rs renders denial_reasons_by_coa for Program::Chip.
D11 — CMD orders the pair
CmdOrder gains programs: Vec<MedicaidProgram>, which stage_determination_order names instead of ["medicaid"]. api/cmd_handlers.rs ingest_cmd_update resolves it first, on its own transaction and before the CMD row is inserted: store::programs_served(&mut tx, application_id), the programs among the application’s newest determinations per (person, program), in Program order. An empty set — an application with no determination to redetermine — is ApiError::UnprocessableEntity coded cmd_application_undetermined (422); nothing is written, because the transaction is dropped uncommitted.
Migrations
-- canopy-medicaid, U1 (expand: the default covers pre-U1 writers during the roll)
ALTER TABLE medicaid_determinations
ADD COLUMN program TEXT NOT NULL DEFAULT 'medicaid' CHECK (program IN ('medicaid','chip'));
CREATE INDEX idx_medicaid_determinations_person_program_latest
ON medicaid_determinations (household_id, person_id, program, determined_at DESC, id DESC);
DROP INDEX idx_medicaid_determinations_person_latest;
-- canopy-medicaid, U2 (contract the default; operation identity)
ALTER TABLE medicaid_determinations ALTER COLUMN program DROP DEFAULT;
ALTER TABLE medicaid_determinations ADD COLUMN operation_id UUID, ADD COLUMN signed_payload BYTEA,
ADD CONSTRAINT medicaid_determinations_operation_signed_ck
CHECK (operation_id IS NULL OR signed_payload IS NOT NULL);
CREATE UNIQUE INDEX medicaid_determinations_operation_subject_uq
ON medicaid_determinations (operation_id, person_id) WHERE operation_id IS NOT NULL;
-- canopy-eligibility, U2
DROP INDEX program_determinations_operation_uq;
CREATE UNIQUE INDEX program_determinations_operation_subject_uq
ON program_determinations (operation_id, person_id) NULLS NOT DISTINCT
WHERE operation_id IS NOT NULL;
-- canopy-eligibility, U4
ALTER TABLE quarantined_determinations ADD COLUMN dispatched_operation_id UUID;
Every raw writer of medicaid_determinations binds program: tools/canopy-seed/src/sql.rs, services/canopy-medicaid/tests/medicaid_test.rs and the services/canopy-medicaid/src/store/mod.rs test fixtures insert_det, insert_det_for_household and the invalid-status fixture (which still trips 23514).
Units (weights by complexity) — U1 → U2 ‖ U3 → U4
Weights: 1 trivial · 2 small · 3 medium · 5 large · 8 very large. One unit = one MR = one child issue, one signed commit per step.
U1 (w8) — The served program is carried and persisted (#2942)
Deploy eligibility → medicaid → web (rolling: old medicaid ignores served_program; its writers hit the column default).
-
D1. ADR-035 erratum line. Tests:
-
each_medicaid_program_is_its_program_token; roundtrip proptests over both variants in both contracts crates. -
household_program_bodies_are_the_generic_context_byte_for_byteanda_medicaid_or_chip_body_differs_only_by_naming_its_served_programreplacemappers/mod.rs192–216 (wrong under ruling 1 — said in the commit). -
a_chip_assertion_is_orchestrator_only; integration 403 and 422.
-
-
D5, D6 (store), the
programcolumn.create_determinationbindsprogram;latest_determination_ids_by_household(db, household, program);determination_householdreturns(household_id, program); priors per program; a pin to another program’s row is 422cross_program_previous_determination; snapshot purposeChipEligibilityfor chip. Tests:-
create_determination_binds_its_program,supersession_chains_per_person_and_program,the_newest_read_keeps_each_subjects_newest_per_program. -
Concurrency:
a_medicaid_and_a_chip_run_for_one_household_both_commit. -
a_pin_naming_another_programs_determination_is_refused,a_chip_snapshot_is_audited_under_chip_eligibility. -
the_determined_event_names_and_asserts_its_served_program(regeneratedmedicaid_determined_denied_{luz,harriet}.json),a_redaction_asserts_the_determinations_program.
-
-
D6 (web). Tests:
a_subject_approved_in_either_program_shows_covered,a_subject_denied_in_both_shows_the_newer_denial,household_status_counts_subjects_not_programs.
U2 (w8) — A medicaid determination is idempotent on its operation (#2673)
Deploy eligibility → medicaid (rolling: new medicaid’s per-subject operations would trip the old eligibility index on the second subject).
-
D2, medicaid. Tests:
-
a_replayed_operation_writes_no_rows_or_events(two POSTs, one operation, different Idempotency-Keys). -
the_operation_read_serves_every_subjects_signed_bytes(each JWS verifies over its served bytes),only_eligibility_reads_an_operation. -
an_operation_assertion_is_orchestrator_only,an_operation_row_without_signed_bytes_is_refused.
-
-
D2, eligibility. The per-subject index;
OPERATION_SLOT(quarantine_ops.rs) follows its name; the order path’sread_back_refusal→adopt_replayed_operation/resolve_body_mismatch(orchestrator.rs) gain the Medicaid read. The bulk arm is untouched: it dispatches SNAP only (bulk/arm.rs). The CMD runbook’s "duplicate-safe" claim becomes true; the authorization inventory gains the system-only route. Tests:-
Fault injection:
a_medicaid_dispatch_that_commits_then_loses_its_response_is_adopted(the retry’s 409 adopts every subject; one combined result, nofailed_terminal). -
a_medicaid_body_mismatch_reads_back_the_operation,every_subject_of_a_medicaid_dispatch_records_under_its_one_operation.
-
U3 (w3) — Notices route by served program (#2943)
Deploys alone (every event carries program since U1). D10, notices. Tests: a_chip_outcome_routes_to_the_chip_letter (both statuses), a_chip_denial_prints_its_reason_lines (asserts the rendered text), a_medicaid_outcome_still_routes_to_the_medicaid_letter, the manifest checks for both rulesets.
U4 (w8) — CHIP is its own signed program (#2319)
-
D8 vocabulary.
rulesets/{georgia,default,test-max}/medicaid-denial-reasons.jsonkept identical;DenialReasonsInput.medicaid_eligible. Tests: the existing totality and label tests; newdenial_reasons_input_struct_matches_ruleset_refs. -
D7, D8 slots. Envelope, snapshot and
program_inputcarry the served program. Tests:-
the_medicaid_slot_never_assigns_a_chip_group,a_chip_eligible_child_with_no_medicaid_group_is_denied_medicaid,the_chip_slot_approves_only_a_chip_group. -
the_chip_slot_is_screened_out_by_any_medicaid_group(refugee, ranked below PeachCare, included). -
screening_leaves_every_groups_cascade_reason_unchanged,a_screened_out_peachcare_that_passed_its_criteria_still_carries_evidence,the_screening_reason_comes_from_the_ruleset,each_slots_evidence_names_only_its_own_groups. -
each_envelope_signs_its_served_program; integrationpost_determine_chip_slot_screens_out_a_medicaid_eligible_child;post_determine_peachcare_child_at_200_pct_fplserveschip, with a Medicaid-slot denial companion.
-
-
D11. Tests:
-
a_paired_application_orders_both_programs,a_medicaid_only_application_orders_medicaid. -
a_change_report_for_an_undetermined_application_is_refused(422cmd_application_undetermined, nomedicaid_cmd_eventsrow, no outbox row). -
Infra:
a_chip_to_medicaid_change_supersedes_the_chip_approval,a_chip_to_uncovered_change_denies_both.
-
-
D3, D4, D9. ADR-002 Amendment 6 (as built) with an Amendment 5 erratum line; the
services/canopy-security/src/signing_authz.rsdoc comment (every CHIP artifact signs asprogram=medicaid) is corrected. Mocks:mock_determinesignsserved_program;forge_determinereceivesDispatch { application_id, household_id, operation_id }. Tests:-
Rewritten under ruling 1 (said in the commit):
a_chip_dispatch_binds_only_an_envelope_claiming_chip,only_chip_borrows_another_programs_key,a_chip_envelope_claiming_chip_under_the_medicaid_key_is_of_record(invertingorchestrator_dispatch_test.rs5084–5148),a_chip_envelope_promotes_as_chip_under_the_medicaid_key. -
New binding:
a_medicaid_envelope_signing_another_operation_is_provenance_rejected,a_dispatch_with_no_claimed_operation_binds_no_medicaid_envelope,reverify_binds_the_dispatched_operation,a_quarantine_without_a_dispatched_operation_fails_reverify. -
New inputs:
a_chip_only_run_is_enriched_with_solq,a_peachcare_only_child_keeps_the_assigned_group.
-
-
D10 web and seed. Tests:
-
a_medicaid_chip_filing_requests_both_programs,a_medicaid_chip_run_dispatches_both_requested_programs. -
The #853 journey files both programs and asserts six NOAs with their templates and reason text — Mateo: Medicaid approval, CHIP screening denial; Sofia: Medicaid denial, PeachCare approval; Luz: both denials.
-
The CMD redetermination journey ends a PeachCare child’s change with no live CHIP approval.
-
Cutover (pre-1.0, no compatibility arms; U2 and U3 live first): deploy canopy-eligibility alone — safe, since post-U2 medicaid signs its operation and the old web and CMD dispatch only medicaid, whose claim binds. Then let open medicaid orders settle, scale canopy-medicaid to zero (which also stops CMD order production), deploy canopy-medicaid and canopy-web, and scale up. A partial order is wrong either way: new medicaid behind the old web denies PeachCare children with no CHIP slot; the new web in front of old medicaid gets chip envelopes claiming medicaid, which eligibility quarantines. Medicaid is not live, so the window costs no traffic. The CHANGELOG entry carries this procedure and ruling 7.
Residual: open quarantines at cutover fail reverify (provenance_rejected) and are dismissed; pre-U4 chip rows in program_determinations keep bytes claiming medicaid and still verify from signed_payload. T-MSIS chip_indicator stays track-derived; from U4 at most one slot approves per paired run. Ruling 6 sends two letters per subject on a paired run.
Verification
-
Per unit:
cargo fmt --all, clippy-D warnings,cargo xtask quality-budgets,neutrality-lint,migrations-lint,test-lanes-lint --static,check-docs,plan-lint;cargo xtask dev reloadthenapi-docs --update, eachopenapi/*.jsondiff reviewed. -
CANOPY_TEST_INFRA=required cargo nextest run --run-ignored=allover the touched crates on the devstack. -
Playwright in Docker: the #853 journey and the CMD redetermination journey.
-
After U4, a devstack walkthrough of the Castellano household (the six outcomes above, no quarantine rows,
CHIP_ELIGinfti_audit_log), a killed-response replay adopted, and a seeded legacy chip quarantine failing reverify and dismissed. -
cargo xtask validate— the pre-push battery is green before each push.
Documentation Updates
-
api/canopy-medicaid.adoc(served program, operation, the envelopes route, slot semantics, event keys),data-models/canopy-medicaid.adoc;api/anddata-models/canopy-eligibility.adoc(key vs claimed program, operation binding, the index);api/canopy-notices.adoc;federal-requirements.adoc(snapshot purpose per program);runbooks/cmd-change-report-rollout.adoc; the authorization inventory -
ADR-002 Amendment 6 and an Amendment 5 erratum; ADR-035 erratum
-
CHANGELOG.adoc— an entry under== Unreleasedper unit -
walkthroughs/journey-medicaid-chip-screen-and-enroll-medicaid-first.adoc, if its captures change
Review log
Before this page, the maintainer reviewed the plan-mode draft (2026-10-21): 11 findings, one dependency and two corrections, all resolved here (D2’s replay adoption, the deploy orders and cutover, D8, D9, D11, D5’s envelope assertion, rulings 6 and 7, the raw-SQL inventory).
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 |
Anthropic |
claude-opus-5-5 |
no-ship — two blockers, fixed: D11’s empty-set refusal (now a coded 422 before any write, with a test) and U2’s |