State Machines

Overview

For a developer or policy analyst: this page draws the status vocabulary and transitions of twelve entities, in fourteen diagrams (the determination verdict has no transitions to draw), and names for each the enum, migration CHECK constraint or store predicate that defines the vocabulary and the function that performs every edge. Where a CHECK admits a value that no function writes, the section says so instead of drawing it.

Enforcement lives at two layers. The vocabulary is a database CHECK constraint for eleven of the twelve — an off-vocabulary write fails at commit whatever the caller sent; the determination verdict is also a Rust enum every reader decodes through, and the fair-hearing status is a TEXT column with no CHECK. Transitions are never a CHECK’s job — a CHECK constrains values, not edges — so wherever an edge is guarded, the guard is code or a plpgsql function, and an out-of-order request surfaces one of three ways:

  • 409 (or 400) where a handler or store classifies the row’s current status around the write: the appeals handlers (ApiError::Conflict / ApiError::BadRequest in the modules under services/canopy-appeals/src/api/), the verification cancel and resolve compare-and-set arms, the application record-back’s already_administratively_denied, the document scan-override and rescan handlers, and the report-run and chain-verify enqueues when the target already has an active run or job;

  • 404 where a store UPDATE … WHERE status … predicate matches zero rows (appeal transitions in services/canopy-appeals/src/store.rs, IPV cases in services/canopy-appeals/src/ipv/store.rs);

  • a RAISE from a plpgsql function where the transition is a database function fenced by a claim token — the report-run and chain-verify job substrates — which the Rust wrappers map to a typed fence outcome.

Machine Vocabulary enforced by

Determination verdict (every program)

code and DB — the DeterminationStatus enum, crates/canopy-reference/src/enums.rs, and a CHECK on each program’s determination table

SNAP enrollment

DB — CHECK snap_enrollments_status_check

Fair hearing (appeal)

neither — TEXT column, no CHECK; the store predicates are the vocabulary

IPV case

DB — CHECK in the create_ipv_tables migration

Certification period

DB — CHECK snap_certs_status_check

Benefit issuance

DB — CHECK snap_issuances_status_check

Application

DB — CHECK applications_status_check and application_programs_status_check

Verification request / IEVS hit

DB — inline CHECKs on verifications.status and ievs_hits.status

Report run / generation

DB — inline CHECKs plus the state-matrix CHECKs

Chain-verify job

DB — inline CHECK plus the state-matrix CHECKs

Document scan

DB — CHECK ck_docs_scan_status plus the provenance CHECKs

WIC mid-certification termination

DB — CHECK wic_participant_terminations_status_check plus the cancel CHECKs

Determination Status

A determination’s status is not a lifecycle: it is the producing program’s signed verdict, fixed when the program signs it (ADR-002). A later event produces a new determination that supersedes it (ADR-028 §57); nothing transitions a determination’s status in place.

Valid statuses: approved, denied, sanctioned, withheld (#628; withheld is ADR-052: eligible and not admitted, written only where a jurisdiction's extension module holds a person back, which no service does yet). canopy-snap signs only approved and denied; canopy-tanf signs sanctioned for an active work sanction (42 USC 607(e)).

Source: canopy-reference/src/enums.rs::DeterminationStatus (as_str, TryFrom refusing any other token); every determination table carries a CHECK over the same three tokens — program_determinations (canopy-eligibility), snap_determinations, tanf_determinations, medicaid_determinations, caps_determinations.determination_status, wic_determinations.determination_status — as do the cohort_cases preview pair, the recert_nudges status pair and tanf_acf199_snapshots.case_status. The states the enum once also listed live where they are modelled: why a case was denied is a denial reason code, the ABAWD clock is canopy-snap’s abawd_tracking (tracking / exhausted), an IPV disqualification is a canopy-appeals IPV case (below), and pending verification, pending appeal, withdrawal and termination are verification, appeal, application and enrollment states (the sections below).

SNAP Enrollment Status

Diagram

Valid statuses: pending_issuance, active, suspended, terminated, expired

Source: the snap_enrollments_status_check constraint in services/canopy-enrollment/migrations/20260401000000_create_enrollment_tables.sql defines the vocabulary; the status writes live in services/canopy-enrollment/src/store.rs.

Fair Hearing (Appeal) Status

Diagram

Valid statuses: pending, scheduled, decided, withdrawal_pending, withdrawn

Source: appeal_requests.status is TEXT NOT NULL DEFAULT 'pending' with no CHECK constraint (services/canopy-appeals/migrations/20260401000000_create_appeals_tables.sql). The vocabulary and every edge above are the WHERE … status predicates of schedule_hearing, record_decision, request_withdrawal, confirm_withdrawal, reinstate_appeal and finalize_withdrawal in services/canopy-appeals/src/store.rs, plus the handler guards under services/canopy-appeals/src/api/ (a postponement on an appeal that is not pending/scheduled → 404; a Superior Court final appeal on an appeal that is not decided → 400, a second one → 409).

Note: Continued benefits are elected within [appeals] continued_benefits_election_days of the notice date (14 in Georgia; 7 CFR 273.15(k) sets the floor). The election is a flag on the appeal record, not a separate status.

IPV (Intentional Program Violation) Case Status

Diagram

Valid statuses: referred, adh_scheduled, adh_notice_sent, adh_completed, waiver_accepted, court_referred, disqualified, cleared, withdrawn

NOTE
court_referred is consumable (→ disqualified) but no live path produces it today — the schema’s CHECK constraint admits it for future court-referral intake; no transition edge creates it (#1493).

Transition validation enforced in: the per-transition WHERE clauses in services/canopy-appeals/src/ipv/store.rs — the store predicates are the single enforcement authority (the enforced matrix is documented on that module’s doc, #1493; a wrong-status attempt matches zero rows and surfaces as the API’s 404/409).

Certification Period Status

Diagram

Valid statuses: active, recertifying, terminated, expired

Source: the snap_certs_status_check constraint in services/canopy-renewals/migrations/20260401000000_create_renewals_tables.sql.

Benefit Issuance Status

Diagram

Valid statuses: pending, issued, cancelled, and failed — reserved (#1553): the real-adapter settler is its writer-to-be; no store write produces it in the noop-adapter era.

Source: the snap_issuances_status_check constraint — four values in services/canopy-enrollment/migrations/20260401000000_create_enrollment_tables.sql, widened to admit cancelled by services/canopy-enrollment/migrations/20261221000000_expiry_sweep_and_combined_allotment.sql, narrowed by services/canopy-enrollment/migrations/20270104000000_issuance_status_drop_reversed.sql (#2128: reversed dropped — no writer, no owner, no reversal path in the service); the status writes live in services/canopy-enrollment/src/store.rs.

NOTE
Expungement of benefits unused for nine months (7 USC §2016(h)(12)©; 7 CFR 274.2(i)) is not a status: it stamps expunged_at and expunged_amount on the issued row (services/canopy-enrollment/src/expungement.rs).

Application Status

Two tables carry it. application_programs.status is the per-program machine — every transition below is a program-row write — and applications.status is a roll-up recomputed from the active program rows in the same transaction as each of those writes.

Program row (application_programs.status)

Diagram

Valid statuses: pending, processing, data_collected, determined, approved, denied, withdrawn, voided

Source: the application_programs_status_check constraint — seven values in services/canopy-applications/migrations/20260601000001_extend_applications_status.sql, dropped and re-added with voided by services/canopy-applications/migrations/20261220000000_reopen_substrate.sql; the column default is 'pending' (20260401000000_create_applications_tables.sql). The edges are, under services/canopy-applications/src/store/: set_application_program_status (mod.rs; the complete-data-collection handler in api/sections.rs calls it with data_collected), record_determination (mod.rs; the status is the caller’s, closed to RecordedProgramStatus = approved | denied (src/domain.rs, #3202); #2150) — the worker BFF maps the eligibility program result at that boundary (record_back_outcome, services/canopy-web/src/api/applications.rs; the table below) and logs-and-skips any other token (recordable_status) — so the CHECK never sees a foreign token; the predicate refuses a row that carries an administrative denial, which the handler reports as 409 already_administratively_denied, and a row that already carries a newer determination id, reported as 409 determination_superseded (#2324)), record_administrative_denial (administrative_denials.rs), reopen_program_row (reopen.rs, WHERE status = 'denied' and the denial’s episode is open, from write_reopen in api/reopen.rs), void_snap_row (reopen.rs, WHERE status <> ALL(TERMINAL_PROGRAM_STATUSES), from the reopen saga’s step_void in reopen_saga.rs) and withdraw_application (mod.rs, from DELETE /v1/applications/{id}; #2149): every active row of the application leaves the live set (active = false) in the same statement as the parent — a row still outside TERMINAL_PROGRAM_STATUSES takes withdrawn, a decided row keeps its status. TERMINAL_PROGRAM_STATUSES (domain.rs) is determined, approved, denied, withdrawn, voided.

canopy-applications' record-back mapping (recorded_outcome, services/canopy-applications/src/domain.rs; #2170, option A; moved from canopy-web by #3202), from the orchestrator’s status — a ProgramOutcome whose verdict is a canopy_reference::enums::DeterminationStatus, the vocabulary status_bucket (services/canopy-eligibility/src/orchestrator.rs) files into programs_approved / programs_denied — to the row record_determination writes:

Eligibility status Row status Row denial_reason_codes

approved

approved

the program service’s codes, unchanged

denied

denied

the program service’s codes, unchanged

sanctioned

denied

sanctioned first, then the program service’s codes

pending_verification, input_unsatisfiable (no verdict)

not recorded

none — no determination of record, so no verdict is published and the case stays in the worker queue

A sanctioned verdict records as denied rather than widening the CHECK and RecordedProgramStatus: the roll-up already treats denied as terminal, the mapping is additive on the wire and reversible, and the outcome eligibility actually stated survives on the row as its first denial reason code.

NOTE
determined is admitted by the CHECK but no write in services/canopy-applications/src produces it on a program row — it is the roll-up’s token. set_application_program_status, record_determination and record_administrative_denial guard on active = true, not on the current status: the edges drawn are the ones the handlers reach, not a store-enforced matrix.

Roll-up (applications.status)

Diagram

Valid statuses: submitted, processing, data_collected, determined, withdrawn, denied, approved

Source: the applications_status_check constraint in services/canopy-applications/migrations/20260601000001_extend_applications_status.sql; the column default is 'submitted' (20260401000000_create_applications_tables.sql) and create_application_with_id (services/canopy-applications/src/store/mod.rs) names no status. recompute_application_status (store/mod.rs) writes processing and determined — it runs inside the transaction of every program-row write above, only an open reopen episode may pull a determined parent back to processing, and a parent already in TERMINAL_APPLICATION_STATUSES (domain.rs: withdrawn) is never overwritten (#2149; refused in Rust before the roll-up arithmetic and by the UPDATE’s own predicate, write_rolled_up_status: status <> ALL(TERMINAL_APPLICATION_STATUSES)) — and withdraw_application (store/mod.rs, WHERE active = true) writes withdrawn and clears active, closing the program rows in the same statement (above). A record-back that lands after the withdrawal therefore finds no live row and is refused 409 application_withdrawn (classify_absent_row, api/record_back.rs); canopy-applications' determination consumer acks it and writes nothing (#3202).

NOTE
data_collected, denied and approved are admitted by the CHECK but no write in services/canopy-applications/src produces them on applications.status; they are program-row tokens.

Verification Request Status

Verification item (verifications.status)

Diagram

Valid statuses: pending, in_progress, completed, cancelled

Source: the inline CHECK on verifications.status in services/canopy-verification/migrations/20260526001500_create_verification_tables.sql; insert_open_item (services/canopy-verification/src/store.rs) names no status, so a new item takes the column default. The edges are compare-and-set UPDATEs in store.rs, each predicated on status IN ('pending', 'in_progress'): resolve_verification (→ completed), cancel_verification and cancel_open_verifications (→ cancelled); unresolve_verifications_for_document (WHERE status = 'completed') reopens the items linked to a document whose acceptance was revoked, from handle_acceptance_revoked in events.rs. The handlers' transition tables (api/context.rs for cancel, api/verifications.rs for resolve): a repeat of the same transition is a 200 no-op; cancelling a completed item or resolving a cancelled one is 409 with the current row.

NOTE
in_progress is admitted by the CHECK and consumed by every predicate above, but no write in services/canopy-verification/src produces it.

IEVS hit (ievs_hits.status)

Diagram

Valid statuses: unreviewed, reviewed, resolved, false_positive

Source: the inline CHECK on ievs_hits.status in services/canopy-verification/migrations/20260526001500_create_verification_tables.sql. record_ievs_hit (services/canopy-verification/src/store.rs) inserts the row and list_recent_ievs_hits reads status = 'unreviewed'. No UPDATE ievs_hits exists under services/, tools/ or crates/, so reviewed, resolved and false_positive are admitted by the CHECK only — no edge produces them.

Report Run and Generation State

A report run is the job; its generation is the output the run stages and, on success, publishes. The two rows are created together, and the run’s terminal transitions drive the generation’s.

Run (report_runs.state)

Diagram

Valid statuses (report_runs.state): queued, running, done, error

Source: the inline CHECK, the state-matrix CHECKs (a running row has a claim owner, a terminal row has finished_at, an error row has an error_code, a queued row is pristine, done requires the counters to reconcile) and the partial unique index report_runs_active_target_uq in services/canopy-reporting/migrations/20261101000001_report_runs.sql. Every edge is a plpgsql function: report_run_enqueue (redefined by 20261207000000_enqueue_pins_atomic.sql), report_run_claim and report_run_finalize (both redefined by 20261110000002_abandon_failed_run_generations.sql) and report_run_reap (20261101000001, batched by 20270119000000_batched_reaps.sql, #2963). The Rust wrappers are enqueue, claim, finalize_in and reap in services/canopy-reporting/src/store/runs.rs; the worker pass calls reap from worker/mod.rs. A finalize, checkpoint or heartbeat with a stale claim token RAISEs (stale claim token … (fenced)); report_run_abandon records a reason without changing state. An enqueue whose target already has a queued or running run returns that run, which api/runs_enqueue.rs reports as 409.

Generation (report_generations.state)

Diagram

Valid statuses (report_generations.state): staged, published, superseded, abandoned

Source: the inline CHECK and the report_generations_published_uq partial unique index (one published per kind and period) in services/canopy-reporting/migrations/20261101000000_report_generations.sql. promote_in (services/canopy-reporting/src/store/promote.rs) locks the target and refuses one that is not staged (lock_staged_target), supersedes the prior published row (supersede_prior), then publishes (publish); report_run_finalize and report_run_claim (20261110000002_abandon_failed_run_generations.sql) write abandoned, only from staged. Generation rows are never deleted: reporting_janitor_reap (20261111000001_janitor_security_definer.sql, batched by 20270119000000_batched_reaps.sql, #2963) deletes a superseded or abandoned generation’s output rows past retention and leaves the generation row as provenance, so the diagram has no exit.

Chain-Verify Job State

Diagram

Valid statuses (chain_verify_jobs.state): queued, running, done, error

Source: the inline CHECK, the state-matrix CHECKs (running ⇔ a claim owner, terminal ⇔ finished_at, done requires run_id, error ⇔ an error_code, queued is pristine) and the partial unique index chain_verify_jobs_active_target_uq in services/canopy-security/migrations/20261015000000_chain_verification_projections.sql, which also defines every transition as a SECURITY DEFINER function: chain_job_enqueue, chain_job_claim, chain_job_finalize and chain_job_reap (chain_job_enqueue as replaced by 20261212000000_chain_job_enqueue_target_under_lock.sql, which reads the active target under the enqueue lock before the queue cap, #2659). The Rust wrappers are enqueue, claim and finalize_in in services/canopy-security/src/chain_verify/jobs.rs; in chain_verify/host.rs, leased_pass claims, finalize_job_done, finalize_job_error_with_run and finalize_job finalize, and run_job_segment maps a reclaim past job_max_attempts to crashed. The verify handler in services/canopy-security/src/api/chain_verify_jobs.rs reports an already-active target as 409 with the existing job’s handle.

NOTE
done and error rows leave the table only through chain_job_reap (7-day floor; rows behind a still-latched incident are exempt; at most a batch of jobs per call, which jobs::reap repeats until a call comes back short, 20270119000000_chain_job_reap_batched.sql, #2963). The audit family’s verifier pass calls it through jobs::reap (services/canopy-security/src/chain_verify/jobs.rs) from reap_jobs_if_due in chain_verify/host.rs — on the task’s first pass, then once a day, a failed attempt retried after a minute — with the window CANOPY_SECURITY__CHAIN_JOB_REAP_DAYS (default 7; 7..=90); the FTI family tasks never reap (#2148).

Document Scan Status

Diagram

Valid statuses (application_documents.scan_status): pending, clean, infected, skipped, error

Source: the ck_docs_scan_status constraint in services/canopy-applications/migrations/20261106000000_document_scan_quarantine.sql, which dropped the noop set of 20260605000000_create_application_documents.sql and added the provenance CHECKs (clean / infected / skipped require a backend and scanned_at; error requires scanned_at and a detail or last error; acceptance requires clean, or skipped with an override). The writes are in services/canopy-applications/src/store/documents.rs: insert_document writes 'pending'; claim_next_scan and defer_scan leave the status pending (the claim triple and scan_due_at move); settle_scan writes the verdict, fenced on the claim token, the generation and scan_status = 'pending'; requeue_scan resets any settled row to pending under a bumped generation (the rescan handler in api/documents_scan.rs; an already-pending row is 409); requeue_noop_settled_batch does the same at boot for rows the noop backend settled. The verdict strings come from services/canopy-applications/src/scan_worker.rs: attempt maps the scanner’s Clean / Infected / Skipped, and run_one settles error for a missing object, a content-identity mismatch or a spent retry budget (scan_attempts >= max_attempts, counted at claim).

NOTE
the scan override (override_scan, the scan-override handler in api/documents_scan.rs) is not a transition: it stamps scan_override_* on a skipped row and only there (ck_docs_scan_override_only_skipped); any other state, or a second override, is 409.

WIC Mid-Certification Termination Status

Diagram

Valid statuses (wic_participant_terminations.status): scheduled, cancelled (#2391), enacted, reversed (#3387). The lifecycle sweep's enact leg (services/canopy-wic/src/lifecycle_sweep/enact.rs) moves a due termination to enacted and its certification record to terminated, in one transaction, when the record is current and its period has not ended, the live letter has dispatch evidence and was on time, and no hearing hold stands. A worker's cancel of an enacted termination is refused 409 termination_enacted. canopy-appeals' cancel on the hold route reverses it (7 CFR 246.9(k)(3)): the termination becomes reversed, and its record returns to the status it had and names no termination, unless the record's period has ended or the person already holds a newer certification, in which case the record is left terminated. reversal_outcome keeps which (restored or nothing_to_restore). reversed is terminal.

A hearing hold (7 CFR 246.9(g), #3387) is not a status but a row beside the termination (wic_termination_holds, one per appeal, held or released): canopy-appeals places it for an appeal filed before the termination date and releases it when the hearing goes against the household, is dismissed or is withdrawn. While a hold is held the enact leg leaves the termination scheduled; a hold and an enactment take the same record lock, so one commits first and the other sees it. A hold is placed only on a scheduled termination, a released hold is never placed again, and every cancel releases the termination’s standing holds in its own transaction, so a cancelled termination holds nothing.

Source: the wic_participant_terminations_status_check constraint in services/canopy-wic/migrations/20270116000000_wic_terminations.sql, with the cancel CHECKs (a cancelled termination carries cancel_reason, cancelled_at and exactly one actor; a worker cancel is exactly the one naming a worker) and wic_participant_terminations_one_scheduled (at most one scheduled termination per record). The writes are in services/canopy-wic/src/store/terminations.rs and services/canopy-wic/src/terminations.rs: insert_termination writes 'scheduled' (the schedule route, api/terminations/schedule.rs); move_effective sets a repaired termination’s date, the kept one or the new floor when later, never earlier (the settle leg, lifecycle_sweep/settle.rs); every cancel goes through cancel_scheduled_termination_locked, a compare-and-set from scheduled scoped by the termination and its record, from the cancel route (worker), the supersession (api/persist/supersession.rs, superseded), the expire leg (expired), the settle leg (expires_first, or the record’s reason for a record no longer current) and canopy-appeals' cancel command on the hold route (api/termination_holds.rs, appeal_reversed). A compare-and-set miss is a no-op: the cancel route answers an already-cancelled termination’s state, and any other termination is its uniform 404.

Each termination’s letters (wic_termination_notices) are live until closed (superseded_at); at most one is live. Every cancel and every repair closes the live letter, retracting it (wic.termination_notice_superseded) when it has no dispatch evidence under its lock, and a repair writes the replacement. A cancel of a termination one of whose letters has dispatch evidence also stages wic.termination_rescinded, naming the date the last such letter printed (#2451). A letter whose dispatch evidence arrives after its termination was cancelled is rescinded by the stamp that records it (#3018).

Not drawn

The census rg -n "CHECK \((status|state|scan_status) IN" services/*/migrations/ returns 53 rows. Beyond the twelve machines above, the candidates the documentation audit named are listed here with the reason each stays undrawn; the remaining rows (cohort runs, determination orders, CMD events, adverse actions, continued-benefit assessments, periodic reports, WIC certification records, CAPS providers, representative disqualifications and the rest) are outside this page’s scope.

Column Latest CHECK Why not drawn

finalize_operations.state

in_progress, compensating, completed, aborted — services/canopy-applications/migrations/20260714000000_create_finalize_operations.sql

The ADR-038 finalize saga’s lease and recovery record (services/canopy-applications/src/store/finalize_ops.rs); the per-step truth is finalize_steps (20260714000001_create_finalize_steps.sql). A saga-engine record, not a case entity.

postponement_episodes.state, postponement_sagas.state

postponed, completed, reverted, closed and running, awaiting_retry, incomplete, complete — services/canopy-applications/migrations/20261223000000_postponement_episodes.sql

An episode and saga pair whose edges are postponement_saga.rs steps with compensation; application_reopen_episodes.state and reopen_sagas.state (20261220000000_reopen_substrate.sql) share the shape. Not yet read against their writers.

application_interviews.status

scheduled, missed, completed, superseded, cancelled — services/canopy-applications/migrations/20261124000000_application_interviews.sql

cancelled is three arms keyed by closed_reason (ck_interviews_closed_reason: waived, application_terminal, superseded_by_reopen — 20261222000000_reopen_void_audit.sql), each a separate writer in store/interviews.rs; drawing it needs the missed-interview chain read with it.

notice_work_items.status

pending, done, failed, skipped, superseded — services/canopy-notices/migrations/20261224000000_work_item_superseded.sql

A delivery work-queue row; the writers are services/canopy-notices/src/work_items.rs, worker.rs and retractions.rs. A queue record, not a case entity.

audit_archive_runs.state

queued, running, done, error — services/canopy-security/migrations/20261101000000_audit_archive_runs.sql

The #1208 async-archival job table — a single active slot with a token-fenced lease and per-chunk committed progress — the same shape as the chain-verify job above.

chain_epochs.state, chain_incidents.state

installing, active, closing, anchored, closed and latched, resolved — 20260910000000_chain_v2_substrate.sql in canopy-security, canopy-tanf and canopy-medicaid (incidents in canopy-security only)

The ADR-014 chain-v2 epoch and incident lifecycles, identical across the three chain-bearing services — a chain-substrate lifecycle, not a case entity.

Edit this page · default