Plan: TANF months are counted, and the pack owns its limits and review cadence (#3511, plan 2 of 2)
Status: Done (2026-11-22) — five units; months are counted, and the limit, the review cadence and payment rules are the pack's decisions'
Epic: &128
Issues: #3511 (parent) · U1 #3518 · U2 #3519 · U3 #3520 · U4 #3521 · U5 #3522 · follow-up #3523
Closes: #3511 (by U5)
Branches: feat/tanf-month-ledger, feat/tanf-pack-counters, refactor/tanf-state-limit-is-the-packs, refactor/tanf-review-cadence, feat/tanf-payment-history-facts
This is a Design + Scope plan: GitLab owns tracking, the unit issues carry the implementer brief, and the plan freezes when U1 starts.
Context
Plan 1 (Plan: the TANF determination is the pack’s (#2210, plan 1 of 2)) made a TANF determination the pack’s. It left four things fixed in canopy, and one thing missing:
-
Nothing counts a month.
tanf_time_limits.months_usedis written only when a clock is created (services/canopy-tanf/src/store/mod.rs,get_or_create_time_limit). No job, event or route advances it, so the federal 60-month limit never moves past a seeded value (compliance/action-catalogue/tanf.toml,tanf.responsibility.accrue-countable-month). -
The State’s limit is one fixed key,
[tanf].time_limit_months, snapshotted onto each clock asstate_limit_monthsand sent ascontext.thresholds.state_time_limit_months. -
The certification period is one fixed key,
[tanf].certification_months, whichdetermineadds to the evaluation date. -
A pack can count nothing of its own (a disregard allowed 4 months in 12, a lockout after a one-time payment).
-
A decision sees one case. It is handed no payment history.
Maintainer rulings, 2026-11-22: accrual is part of this plan; a counted month is counted from a ledger that a monthly job writes from the approved determination in force.
Scope
In: the month ledger and its job; pack-declared counters; the State’s limit and the review cadence as the pack’s decisions' answers; payment-history facts.
Out, each to an issue:
-
the other rows of #818 (out-of-state months, hardship extensions and their 20 percent cap, staffings, notices) and removing a month already counted in error; recording an exclusion is in (U1);
-
scheduling or acting on a review date (#824); this plan only records it;
-
a rule applied when a supplemental payment is recorded (#3515) and a sanction applied across units (#3512);
-
facts canopy does not capture (an open employment-services case, an adult’s education and work history): #3523;
-
a TANF issuance record. Until one exists the ledger counts months assistance was authorized, and cannot see a returned or unpaid benefit.
No compatibility: no alias for a removed key, column, input or output.
Design
The ledger (U1)
One table, tanf_counted_months (person_id, counter, month, determination_id, recorded_at), primary key (person_id, counter, month). month is the first day of a calendar month. A row means: this month counts toward this counter for this person. Rows are inserted and never updated or deleted by this plan.
tanf_time_limits.months_used is renamed opening_months (months on record before the ledger began) and last_counted_month is dropped. A person’s federal count is opening_months (zero with no clock row) plus their ledger rows for the counter federal; wherever this plan says "federal count" or federal_months it means that sum. On both read contracts months_used and last_counted_month stay on the wire, now computed (the sum; the newest federal ledger month), so canopy-web’s Time Limits tab needs no change in U1. The job creates the clock row of a person it first counts a month for, so a counted spouse is on file for both routes.
The 60-month check covers the head and the spouse. Today determine checks the applicant’s clock alone. 264.1(a)(1) bars a family that includes a head of household or spouse who has 60 months, so U1 checks the federal count of the applicant and of every member whose relationship is spouse, and denies time_limit when any non-exempt one has reached the limit.
The job (U1)
canopy-tanf gains its first background task, fenced to one run per day across replicas (canopy_db::window_fence::run_daily_fenced, with the shared scheduler_runs migration), and a manual trigger POST /v1/tanf/scheduler/run as canopy-renewals has.
Each run processes every calendar month that has ended in the legal timezone and is after the watermark, oldest first, one transaction per month, then advances the watermark (tanf_accrual_months). The migration sets the watermark to the month before it runs, so no month before deployment is counted retroactively.
For a month, per household, the determination that counts is the newest one determined on or before the month’s last day whose verdict in determination_verdicts is recorded, when it is approved, effective on or before that day and not expired on it. This is canopy-eligibility’s in-force rule (determination_in_force, services/canopy-eligibility/src/member_facts.rs) with a cut-off at the month’s end, which that rule lacks: without it a run that catches up would judge an old month by a later determination. A determination that issued no benefit counts no month.
The federal counter is canopy’s. Its code, federal, is reserved, and its rule is 45 CFR 264.1 (read 2026-11-22, eCFR current to 2026-11-19):
-
Who. A month counts for each
includedmember who is the head of household or whose relationship isspouse, adult or minor (264.1(a)(1), (a)(2)); for no one else (264.1(b)(1)(i)). -
Which funds. Only a month paid in whole or part with federal TANF funds counts (264.1(b)(2)). Which funds pay a grant is the State’s choice, so
tanf-benefit-calculationreturnsfederally_funded(a boolean, required; 502 without it), stored on the determination. A month of a determination that is not federally funded counts toward no federal row. -
Months that must not count. A month an adult lived in Indian country or a Native Alaskan village where at least half the adults were not employed must not count (264.1(b)(1)(ii)), and canopy captures no such fact. U1 therefore adds
POST /v1/time-limits/{person_id}/exclusionsand aGETof the same path, admitted as the service’s other worker writes and reads are (WRITER,READERinservices/canopy-tanf/src/api/mod.rs). The body is{ counter, first_month, last_month, reason }; it answers 201, 422unknown_counterorunknown_exclusion_reason, and 422 for a range that ends before it starts. A reason is acodeof the pack’s[[tanf.count_exclusions]]rows (code,label; pack-list pattern; a pack may declare none). Exclusions are inserted and never changed. The job counts no month an exclusion covers, for the federal counter or a pack’s. The clock’sexemptflag is honoured as today. -
What is assistance. A nonrecurrent short-term benefit is not assistance (45 CFR 260.31(b)(1)): a supplemental payment counts no month, and only a determination’s monthly grant does.
No decision is asked who counts.
Pack counters (U2)
[[tanf.counters]]
code = "earnings_disregard" # [a-z0-9_]{1,64}; unique; not "federal"
label = "Months of the earnings disregard"
window_months = 12 # optional: also count within the last N months
tanf-unit-member may return counted_toward, a list of counter codes, for a member. canopy-tanf stores it on the member’s unit row and the job writes one ledger row per code for each month the determination counts. A code with no row refuses the determination (502, nothing stored). A pack that declares no counter returns none.
tanf-eligibility is handed, on each of input.members[], federal_months and counters.<code> = { total, in_window, months_since_last } (in_window null without window_months; months_since_last null when never counted), as of the evaluation date.
The State’s limit (U3)
Removed: [tanf].time_limit_months, tanf_time_limits.state_limit_months and its boot backfill, context.thresholds.state_time_limit_months (so tanf-eligibility is sent no threshold), and state_limit_months on both read contracts. canopy-web’s Time Limits tab (services/canopy-web/src/api/case_detail/tanf_tabs.rs, member_time_limit) then shows the count against the federal limit alone; showing a pack’s own limit there is a later change, since canopy no longer knows it. The federal limit stays enforced by canopy-tanf whatever the decision answers.
A pack states its own limit in tanf-eligibility: against input.time_limit_months_used (the applicant’s federal count, kept) and a value it names, or against a counter of its own. Georgia’s 48 months are a lower limit on the same months the federal clock counts, so Georgia needs a value and one changed cell, and no counter.
A choice to review: today a clock keeps the State limit it was created under (#2941). After this unit a decision reads the pack’s current value, so a pack that changes its limit changes it for everyone at their next determination. The pinned configuration a determination ran on is already signed into it.
Review cadence (U4)
Removed: [tanf].certification_months. tanf-benefit-calculation returns certification_months (a whole number, or null for a determination with no end) and review_months (a whole number, required). canopy-tanf computes both dates from the evaluation date with the arithmetic it has, stores a null expiration_date for an open-ended determination (every read already treats null as open), and signs the review date as the envelope’s renewal_date, which is always empty today. The decision is no longer sent effective_date and expiration_date to pass through.
Payment history (U5)
tanf-eligibility is handed, on each of input.members[], supplemental_payments.<code> = { count, months_since_last } for payments recorded with the member as payee, read from tanf_supplemental_payments, counting those whose effective_date is on or before the evaluation date; months_since_last is whole calendar months from the newest such date. Every code the pack declares is present, with count 0 and a null months_since_last when none is recorded, so a decision never reads an absent key. A code the pack has since dropped is still handed.
Georgia and Texas
Announce each contract on canopy/rules; Georgia’s agent writes its change as a held commit; verify from a git archive; run the case table on it; pin in the unit’s MR. U1, U3 and U4 need a Georgia commit (a decision’s inputs or outputs change); U2 and U5 need none. Texas is not pinned.
Units
| Unit | Change | Status |
|---|---|---|
U1 |
The ledger, the renamed opening column, the daily job and its trigger, the federal counter with |
Done (2026-11-22) |
U2 |
|
Done (2026-11-22) |
U3 |
The State’s limit leaves canopy; Georgia pinned |
Done (2026-11-22) |
U4 |
Review cadence from the grant decision; Georgia pinned |
Done (2026-11-22) |
U5 |
Payment-history facts; plan Done; closes #3511 |
Done (2026-11-22) |
One MR per unit, in order, stacked. U1 to U4 relate to #3511.
Risks
| Risk | Mode | Mitigation |
|---|---|---|
A month is counted twice (a replayed run, two replicas) |
fail-closed |
The primary key refuses a second row; the daily fence admits one run. Concurrency test: two runs of one month leave one row per person and counter. |
A month is never counted (the job is down for weeks) |
silent |
The watermark makes the next run process every ended month since; test: a run three months late writes all three. |
A month counted for a determination later disowned or still held |
silent |
Only determinations with a recorded verdict count; test with a held and a disowned one. |
A month federal law says must not count is counted (state-funded assistance; residence in Indian country) |
silent |
|
A pack’s own limit or cadence does not match its State’s manual |
silent |
canopy cannot check a manual. Each value is cited in the pack ( |
Authorized but unpaid months are counted |
silent |
Stated limit of this plan, in the ADR and the data-model page; the ledger keeps the determination id so a later issuance record can reconcile it. |
Existing clocks lose their count in the rename |
fail-closed |
Migration test seeds clocks, migrates, and reads the same |
Georgia’s verdicts change in U3 or U4 |
silent |
Plan 1’s case table (25 households) must pass unchanged on the reference pack and pinned Georgia; the 48-month row is in it. |
A pack’s limit change applies to clocks started under the old limit |
silent |
Named above as a choice; recorded in the ADR and the changelog. |
A decision names a counter the pack does not declare, or reads one it is not sent |
fail-closed |
502 at the determination for a returned code; the boot check and |
An open-ended determination reaches a reader that assumes an end date |
fail-open |
Audit every reader of |
Verification
-
Concurrency: two concurrent runs of one month; a run concurrent with a determination being recorded.
-
Who counts (integration, one table of households through the job): an included head and an included spouse each get a federal row; a child, an excluded head, a deemed stepparent and an exempt person get none; a determination that issued no benefit, one not federally funded, one held and one disowned write none; a month inside an exclusion writes none and the months at each edge do; a later denial does not change an earlier month a late run then counts.
-
Never (each its own test): no month before the migration’s watermark is counted; a supplemental payment writes no ledger row; a ledger or exclusion row is never updated or deleted (the store has no such statement, and a second insert is refused); the determination is denied
time_limitwhen the applicant or the spouse has 60 federal months, whatever the eligibility decision answers. -
Regression: the case table unchanged in every unit; the migration keeps each clock’s count; a late run catches up.
-
Contract (wire): round-trips for the time-limit contracts without
state_limit_months, the trigger and exclusion routes, the eligibility input’s new member fields; OpenAPI snapshots. -
Pack and boot checks: a decision reading
counters.<code>for an undeclared code is refused at boot and reported bytanf-decisions; the shipped packs have no finding. -
Property: the windowed count and
months_since_lastover arbitrary sets of months (never negative;in_windowno more thantotalor the window). -
Refusal (unit): a counter row that is malformed, repeated or named
federalrefuses boot; an undeclared returned code is 502 with nothing stored; a missingreview_monthsorfederally_fundedis 502; an exclusion with an undeclared reason is 422. -
Fixture packs differ:
test-maxdeclares a windowed counter and an open-ended certification;defaultdeclares neither. -
Every new pin is proved by a mutant.
Documentation Updates
-
The ADR (U1);
architecture.adoc. -
rulesets.adoc(counters, the limit, the cadence),jurisdiction-onboarding.adoc,api/canopy-tanf.adoc,data-models/canopy-tanf.adoc,services.adoc,authorization-inventory.adoc(the trigger and exclusion routes). -
compliance/action-catalogue/tanf.toml: bindtanf.responsibility.accrue-countable-monthand drop its allowlist entry. -
CHANGELOG.adoc: oneChangedentry per unit, naming what a pack must now carry. -
Close: U5’s MR closes #3511; Status becomes
Done (date).
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 |
anthropic |
claude-fable-5-2 |
FLAGS (P2): dropping |
2 |
gemini-4-carbon |
FLAGS (P2): the in-force rule had no cut-off at the month’s end, so a late run would judge an old month by a later determination; only the applicant’s clock was created and checked, leaving a counted spouse unread and unchecked; the exclusion route’s path, admission and rows, the payment facts' date anchor and empty form, and tests for the pack and boot checks were unstated. P1, P3, P4 pass. |
The plan presented for approval carried these resolutions: months_used and last_counted_month stay on the wire, computed; the job creates a counted person’s clock row; the 60-month check covers the applicant and the spouse, as 45 CFR 264.1(a)(1) requires; the in-force rule gains a month-end cut-off; the exclusion route, its admission and its pack rows are specified; the payment facts state their date anchor and their empty form; each always/never claim names its test. Before review, the federal counter was checked against the text of 45 CFR 264.1 and 260.31, which added the federally-funded test, the count exclusions and the rule that a supplemental payment counts no month. The maintainer approved it on 2026-11-22.
Errata
-
Erratum (2026-11-22): "Georgia’s 48 months are a lower limit on the same months the federal clock counts" is not so. By Georgia’s report its manual counts some payments as several months toward the 48 and leaves out months the federal clock counts. U3 is unchanged (Georgia’s results stay as today); adding months outside the monthly job is #818’s.
-
Erratum (2026-11-22): U1’s exclusion route also answers 422
invalid_month_rangefor a month that is not written as its first day. A pack cannot yet tell a State-funded unit from another, so it answersfederally_fundedalike for all its grants (#3525). -
Erratum (2026-11-22): U4’s audit found two readers that did assume an end or a deadline, where the plan said every read already treats null as open. The approval letter printed a placeholder for a missing end date, so
tanf.determinednow carriescertification_open_endedand the letter states that there is no end date. The applicant portal read anyrenewal_dateas a renewal deadline, so a TANF review day would have raised the renewal hero and a "Renew by" line; it now shows "Review due" and raises no hero.