Plan: SNAP expungement follows the designated approach, with account activity (#1744)

Status: Done (2026-10-28) — !1830
Epic: none (T2; relates to &79, the EBT rail)
Issues: #1744 (T2, parent) · U1 → #3075 (w2) · U2 → #3076 (w5)
Branches: fix/snap-expungement-approach

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-28): D8’s test publisher counts as a crate-sited publish to cargo xtask mq-topology, which scans canopy-test-lib as source, so canopy-exchange, the producer D3 names, gets the one-key write grant ^(ebt\.account_activity\.observed)$ in devstack/rabbitmq/definitions.json now; #1553/24 inherits it.

Erratum (2026-10-28): D5’s log names the envelope id and the counts, never the EBT account id, which is a financial identifier the security baseline keeps out of logs.

Erratum (2026-10-28): D6’s race is closed by D5’s notice reset (the write’s existing expungement_notice_dispatched_on IS NOT NULL then matches nothing); the write’s expiry_date < today is a second guard against a date moved without a notice reset, pinned by its own test. The U2 list’s < to ⇐ mutation is killed by a row whose expiry equals the new date, not the third fixture row.

Erratum (2026-10-28): U2’s migration adds the partial index idx_snap_enrollments_ebt_account, with an EXPLAIN test, so an observation finds the account’s enrollments without scanning them all.

Context

7 CFR 274.2(i)(1) offers two expungement approaches, and a State designates one in its State plan and uses it for every household. Under (i) inactive accounts, each allotment is expunged "as each benefit allotment ages to nine months since the date of issuance or since the last date of account activity, whichever date is later", an active account is never expunged, and activity after expungement begins "start[s] the account aging process over again for the remaining benefits". Under (ii) unused benefits, an allotment is expunged 274 days after issuance "regardless of any account activity". Georgia’s manual describes (i): PAMMS 3805, Expunged Benefits: "After 9 months of inactivity, benefits are expunged from the account one month at a time, first in, first out, as each month ages to 274 days. Any client-initiated debit or credit will stop the expungement process, and the 274-day clock resets to zero." (rulesets/georgia/.policy-cache/dfcs-snap/modules/snap/pages/3805.adoc:83-84).

canopy runs (ii). issuance::benefit_expiry_date (services/canopy-enrollment/src/issuance.rs:155) stamps snap_benefit_issuances.expiry_date as the issuance day plus snap.issuance.expungement_days (274 in rulesets/georgia/jurisdiction.toml:290), and the daily pass in services/canopy-enrollment/src/expungement.rs notices a row within shared.timing.expungement_advance_notice_days of that date (store::find_approaching_expungement, store.rs:1375) and expunges it after it, once the notice has been dispatched (#2407; expunge_decision, store::find_expired_issuances at store.rs:1433, store::mark_issuance_expunged at store.rs:1505). Nothing records the designation, and nothing can move a date, because canopy ingests no EBT account activity.

Georgia’s rail is file-based. The EBT processor (EBTAS) sends the State a daily inactive-accounts file and a daily expunge file, and there is no real-time account query (Georgia Gateway External Partner Interface Catalog, EBT — FIS / Conduent / Xerox (EBTAS)). ADR-045 places that rail in canopy-exchange as routed evidence and keeps "the issuance ledger (settlement, expungement)" in canopy-enrollment; the EBT commands and the EBTAS file dialect are #1553 and its children 23 and 24, which are T5. EbtAdapter (services/canopy-enrollment/src/ebt.rs:21) models issuance only. snap_enrollments.ebt_account_id (canopy-enrollment Data Model) is the account an enrollment issues to; it is nullable, and the settlement loop falls back to a EBT-NOOP- placeholder when it is null.

Rulings (maintainer, 2026-10-28)

  • Q1, where activity comes from: an inbound event canopy-enrollment consumes now, ebt.account_activity.observed; canopy-exchange publishes it from the EBTAS file under #1553/24. Rejected: a last-activity query on EbtAdapter (Georgia has no such query, and it would put the processor on the daily pass’s path), and deferring #1744 to #1553.

  • Q2, an account with no activity observation: age from issuance, as today, and make the blind spot visible with a WARN and a counter. Rejected: holding the row (with no feed, nothing in Georgia would ever expunge).

Scope

In scope:

  • The designation as pack data, snap.issuance.expungement_approach, cited in every pack.

  • An inbound activity contract and its consumer: on activity, every unexpunged issuance of the account moves to activity plus expungement_days, and a notice sent for a date that moved is reset.

  • Visibility of expungements made without any activity observation, under the inactive-account approach.

  • The federal-requirements row, the enrollment API and data-model pages, and the CHANGELOG.

Out of scope:

  • Publishing the event. canopy-exchange’s EBTAS ingress (#1553/24) does that; this plan lands the consumer first (binding-first; cargo xtask mq-topology accepts a consumer that precedes its producer).

  • The remaining balance per allotment and the "amount at risk" in the notice (the #1744 note of 2026-09-11): FIFO consumption is the processor’s knowledge and arrives with #1553’s balance query.

  • Reconciling canopy’s ledger against the processor’s expunge file: #1553/24.

  • Off-line storage (7 CFR 274.2(h)) and the death-match expungement (274.2(i)(4)).

Design

D1 — the designation is pack data. snap.issuance.expungement_approach is a required string in [snap.issuance]: "inactive_account" (274.2(i)(1)(i)) or "unused_benefits" (274.2(i)(1)(ii)). rulesets/georgia/jurisdiction.toml carries inactive_account, cited in rulesets/georgia/citations.toml to PAMMS 3805 (source_ref the 3805 page, the quoted paragraph in notes, federal_citation = "7 CFR 274.2(i)(1)(i)", the page’s existing source_sha256). Georgia’s State plan is not in the policy cache, so the citation names PAMMS 3805 as the pinned local manual (AGENTS.md, 2026-10-24: pack values follow the pinned local manual). rulesets/default carries unused_benefits, the one approach a deployment with no activity feed can run exactly, cited to 274.2(i)(1)(ii). test-min carries unused_benefits and test-max inactive_account, so both arms run in the lanes. rulesets/federal has no jurisdiction.toml (it holds federal data files), so it carries nothing: a State designates. cargo xtask policy audit, the battery’s blocking policy-audit stage, checks that every pack’s new key has its citation.

D2 — the type. issuance.rs gains pub enum ExpungementApproach { InactiveAccount, UnusedBenefits } with from_key, mirroring ProrationRounding (issuance.rs:42), and IssuanceParams gains pub expungement_approach: ExpungementApproach. params.rs reads it beside proration_rounding (params.rs:155); a missing or unknown value is a boot error naming the key and both values. ExpungementTiming (expungement.rs) gains the same field, so the pass knows the approach without the whole IssuanceParams. Every IssuanceParams { .. } and ExpungementTiming { .. } literal names the approach: grep -rn 'IssuanceParams {' services/canopy-enrollment/src finds them (today auto_enroll.rs, adverse_actions.rs, api/issue_guards_tests.rs and the expungement tests).

D3 — the contract. crates/canopy-contracts-enrollment/src/events.rs gains pub const EBT_ACCOUNT_ACTIVITY_OBSERVED: &str = "ebt.account_activity.observed" and EbtAccountActivityObservedV1 { ebt_account_id: String, activity_on: NaiveDate, source: ActivitySource }, where ActivitySource is a closed vocabulary (processor_inactive_accounts_file, processor_transaction_feed, operator). activity_on is the last client-initiated debit or credit the source reports, a jurisdiction-legal date; the file’s inactive-days figure converts to a date at the publisher. The contract lives in the enrollment contracts crate because it is what enrollment accepts on its ledger; the producer is a rail, not a service with a contract crate. The module doc says so, and names #1553/24 as the producer. Roundtrip proptest and a key pin, as the crate’s other events have.

D4 — the activity table. Migration services/canopy-enrollment/migrations/<stamp>_ebt_account_activity.sql: snap_ebt_account_activity (ebt_account_id TEXT PRIMARY KEY, last_activity_on DATE NOT NULL, observed_at TIMESTAMPTZ NOT NULL, source TEXT NOT NULL). observed_at is bound by the consumer from the envelope’s timestamp, never a column default (cargo xtask migrations-lint). The upsert keeps the later last_activity_on: a file replayed or delivered out of order never moves a date backwards.

D5 — the consumer. ENROLLMENT_EVENT_KEYS (services/canopy-enrollment/src/main.rs:41) gains the key, and the handler dispatches it to a new services/canopy-enrollment/src/ebt_activity.rs, pub async fn record_activity(envelope, tx, params: &IssuanceParams) → anyhow::Result<ActivityOutcome>, in the inbox transaction (ENROLLMENT_EVENT_KEYS feeds the subscription and the recognized-set guard together, so the guard follows). The handler:

  1. parses the typed payload (a malformed one is Err, so it dead-letters, as the determination handler does);

  2. upserts D4;

  3. under UnusedBenefits, stops there: the observation is recorded and no date moves;

  4. under InactiveAccount, computes new_expiry = activity_on + expungement_days (canopy_common::date::add_days, a typed error on overflow) and runs one UPDATE snap_benefit_issuances i SET expiry_date = $new, expungement_notice_sent_at = NULL, expungement_notice_event_id = NULL, expungement_notice_dispatched_on = NULL FROM snap_enrollments e WHERE e.id = i.enrollment_id AND e.ebt_account_id = $account AND i.issuance_status = 'issued' AND i.expunged_at IS NULL AND i.expiry_date < $new. The max is the expiry_date < $new predicate: an allotment issued after the activity keeps its own later date. Clearing the three notice columns together satisfies the #2407 CHECK, and the pass notices the row again 30 days before its new date, which 274.2(i)(2) owes: the earlier notice named a date that is no longer scheduled. ActivityOutcome { rows_moved: u64 } is logged with the account id and the count only.

A row the ledger already expunged is not touched (274.2(i)(3): expunged benefits are not reinstated); the handler counts them in canopy_enrollment_ebt_activity_after_expunge_total for #1553/24’s reconciliation.

D6 — the pass and a concurrent activity. The daily pass reads a batch (store::find_expired_issuances) and then writes each row (store::mark_issuance_expunged, store.rs:1505). An activity event can move a row between the two. The write closes that: it gains today and re-asserts AND expiry_date < $today beside its existing expungement_notice_dispatched_on IS NOT NULL. Under READ COMMITTED an UPDATE that meets a row another transaction holds waits for that transaction and re-evaluates its predicate on the committed row, so an activity that commits first leaves the write matching nothing (Ok(None), today’s ExpiredOutcome::Unchanged), whether it committed before the read or during it. In the other order the row is already expunged and D5 leaves it alone. expunge passes today through.

D7 — visibility of the blind spot (ruling Q2). Under InactiveAccount, expunge (expungement.rs:296) learns whether the row’s account has a D4 observation (store::find_expired_issuances left-joins snap_ebt_account_activity through the enrollment and returns account_observed: bool). A row expunged with account_observed == false increments ExpungeTally.unobserved; the pass logs the count at WARN when it is non-zero ("expunged with no account activity ever observed; the activity feed (#1553/24) is not connected, or the account is unknown to it"), and metrics.rs exposes the counter canopy_enrollment_expunged_without_activity_observation_total, built like canopy_enrollment_backdated_first_issuance_total (metrics.rs:38). Under UnusedBenefits the count stays zero and the WARN never fires.

D8 — the test publisher. crates/canopy-test-lib/src/ebt_activity.rs, pub async fn publish_activity(ebt_account_id, activity_on, source), publishes the D3 event as canopy_test_lib::verdicts::publish does (verdicts.rs:74: a lapin channel as the admin AMQP login, publisher confirms, straight to canopy.events), so a devstack test can act as the rail. No ACL change: nobody in production publishes the key until #1553/24, whose MR adds it to canopy-exchange’s write regex.

D9 — no API change. No route is added; a worker-portal activity entry is not this plan’s (an operator source exists in D3 for that future). The OpenAPI snapshot does not change.

D10 — docs. Federal Requirements Mapping Benefit Issuance row for 274.2(i)(1) states the designated approach per pack and how activity moves the date; canopy-enrollment Data Model gains the D4 table and the expiry_date semantics under each approach; canopy-enrollment API Reference Expungement paragraph and Events Consumed gain the key; Canopy Service Catalog enrollment row’s consumed events; CHANGELOG === Changed for U1 and === Added for U2. ADR-045 already says the rail is routed evidence and enrollment keeps the expungement policy, so no ADR changes.

Units (weights by complexity) — U1 → U2, one MR

Weights: 1 trivial · 2 small · 3 medium · 5 large · 8 very large. One unit = one child issue. Both units land in one MR, one commit per unit, a deliberate departure from the template’s one-MR-per-unit: the maintainer’s standing direction batches issues that touch the same code onto one branch so they share a battery, U1 alone changes no behaviour, and U2 depends on U1’s type. The MR carries Closes #1744 and both children.

U1 (w2) — the designation as pack data

Files: rulesets/{georgia,default,test-min,test-max}/jurisdiction.toml and citations.toml; services/canopy-enrollment/src/{issuance.rs,params.rs,expungement.rs}; the IssuanceParams fixtures in auto_enroll.rs and the expungement tests; docs/modules/ROOT/pages/federal-requirements.adoc.

D1, D2 and the federal-requirements row. Tests: from_key accepts both values and refuses another; params boots test-min and test-max to different approaches and refuses a pack missing the key (mirror the proration_rounding boot test); cargo xtask policy audit passes for every pack.

U2 (w5) — account activity moves the clock

Files: crates/canopy-contracts-enrollment/src/events.rs and crates/canopy-contracts-enrollment/tests/roundtrip.rs; services/canopy-enrollment/migrations/<stamp>_ebt_account_activity.sql; services/canopy-enrollment/src/{main.rs,ebt_activity.rs (new),expungement.rs,store.rs,metrics.rs}; crates/canopy-test-lib/src/{lib.rs,ebt_activity.rs (new)}; docs/modules/ROOT/pages/{data-models/canopy-enrollment.adoc,api/canopy-enrollment.adoc,services.adoc}; CHANGELOG.adoc.

D3 to D8 and D10. Tests, each infra-guarded on canopy_test_lib::infrastructure_available() as expungement.rs's own infra tests are, never #[ignore]:

  • Contract: roundtrip proptest; the key pin; ActivitySource rejects an unknown token.

  • Activity moves the clock (inactive_account): three issued rows on one account, dated 2027-01-01, 2027-02-01 and 2027-12-01, each with expiry_date issuance + 274; activity on 2027-06-01 moves the first two to 2028-03-01 (2027-06-01 + 274) and leaves the third at 2028-08-31. A row of another account is untouched.

  • A moved row is re-noticed: a row with all three notice columns set, past its original expiry and so expunge-eligible, is moved by activity; the next pass neither expunges it nor finds it expired, and notices it again 30 days before the new date with a fresh event id.

  • Never backwards: activity on 2027-03-01 after activity on 2027-06-01 changes nothing (last_activity_on stays 2027-06-01, no row moves).

  • An expunged row stays expunged: activity after expungement leaves expunged_at set and increments the counter.

  • unused_benefits ignores activity: the same three rows, the same activity; every expiry_date is unchanged and the observation row exists.

  • The blind spot (D7): under inactive_account, an expunge of a row whose account has no observation increments unobserved, and one whose account has an observation does not. The unit-lane test asserts ExpungeTally.unobserved directly.

  • Concurrency (D6): a row past expiry with its notice dispatched. One transaction runs the D5 UPDATE for its account and stays open; the pass is started; the test waits until pg_locks shows the pass’s write blocked on the row (the pattern of canopy-tanf’s api::determination_events::infra_tests::a_verdict_in_flight_during_the_staging_still_releases_its_events), commits the activity, and then observes the pass finish with the row unexpunged, its expiry_date moved and ExpiredOutcome::Unchanged counted. A second case commits the activity before the pass reads and asserts the same end state.

  • Guard: the key is recognised (not parked) and a malformed payload is Err.

Mutations named in the child issue: the handler skipping the UPDATE (the clock test fails); < to ⇐ in the predicate (the third row moves); the notice columns not cleared (the re-notice test fails); the upsert keeping the earlier date (never-backwards fails); the approach branch inverted (the unused_benefits test fails); the write’s expiry_date < $today dropped and the notice columns not cleared (the concurrency test expunges the row).

Verification

  1. cargo xtask test — the unit and integration lanes pass (see Testing); canopy-enrollment’s integration lane runs the U2 infra tests on the devstack.

  2. cargo xtask dev restart (the U2 migration), then cargo xtask e2e.

  3. cargo xtask migrations-lint, cargo xtask mq-topology (the new key is a dead binding, consumer-first), and cargo xtask policy audit.

  4. cargo xtask validate — the pre-push battery is green.

  5. Close: the MR merges with Closes #1744 and both children; the close note on #1744 names the merge SHA and the Risks caveat that the feed is #1553/24’s.

Documentation Updates

  • Antora canonical pages — api/canopy-enrollment.adoc (Events Consumed, Expungement), data-models/canopy-enrollment.adoc (the D4 table, expiry_date under each approach) and Service Catalog (enrollment’s consumed events)

  • federal-requirements.adoc — the 274.2(i)(1) row states the designation per pack

  • CHANGELOG.adoc — entries under == Unreleased (U1 Changed, U2 Added)

  • No ADR change (ADR-045 already places the rail in exchange and the expungement policy in enrollment)

Risks

  • The feed is not connected yet. Until #1553/24, Georgia’s canopy ages every account from issuance, as it does today: fail-open for an active account canopy never heard about, whose ledger row is marked expunged early. Mitigation: D7 counts and WARNs on every such expungement, so the gap is never silent, and the processor’s expunge file reconciles the ledger when the rail lands. The #1744 close note says so.

  • Late files. A file arriving after a row expunged cannot reinstate it (274.2(i)(3)): fail-closed for the household until reconciliation. Mitigation: the D5 counter is the reconciliation’s input, and the pass has already sent the 30-day notice before any expungement.

  • A moved row and a running pass. Without D6 the pass could expunge a row an activity had just moved: fail-open, silent. Mitigation: the write re-asserts the date, and the concurrency test pins it.

  • Which account. Activity is keyed by ebt_account_id, which is null on enrollments that never settled to a real account; those never move. That is fail-closed and correct: they have no processor account to be active.

Review log

round vendor resolved model verdict

1

Anthropic

claude-fable-5-1

FLAGS (2): the Risks entries named no fail-open/fail-closed/silent mode; no issue-close step; no concurrency test for a moved row versus the pass’s read-then-write; several named files not supplied as review context. Fixed in the draft (D6 with its test, the Risks vocabulary, Verification step 5, the review context).

2

Google

gemini-4-argon

FLAGS (2): the same Risks and close-step findings; the one-MR override of the template unexplained; D8 misdescribed verdicts::publish (it publishes through lapin confirms, not an outbox); two IssuanceParams literals missed; Q2 said gauge where D7 is a counter. Fixed in the draft.

Edit this page · default