Plan: Drop the decision-stamp column defaults in the services epic &138 scans (#3007)
Status: Done (2026-10-26) — !1796
Epic: none — follow-up to &138 (Close the ambient-clock class)
Issues: #3007 (parent) · U1 #3013 (w3) · U2 #3014 (w5) · out of scope: #3015
Branches: fix/eligibility-decision-stamp-defaults, fix/applications-decision-stamp-defaults
This is a Design + Scope plan: GitLab owns tracking, the child issues carry the implementer brief, and the plan freezes when U1 starts.
Context
#2589 dropped the clock default of every stamp the program services' production INSERTs bind (services/canopy-wic/migrations/20270209000000_decision_stamps_no_default.sql and its siblings in snap, tanf, medicaid and caps). It added a clock-default check to cargo xtask migrations-lint (check_clock_defaults in xtask/src/cmd/migrations_lint.rs). It also gave each of those services a catalog test built on crates/canopy-test-lib/src/stamps.rs; the WIC copy is services/canopy-wic/tests/wic_test.rs:2287. Since then, an insert that forgets a stamp fails with a not_null_violation that names the column.
Epic &138 put six more services under check 6: canopy-wic, -renewals, -appeals, -persons, -eligibility and -applications. Check 6 reads Rust and SQL string literals, so it cannot see a column default.
U6 (#3004) found the consequence live:
-
create_combined_resultand the determination-of-record insert left out their stamps; -
the defaults filled them from the database clock;
-
only a pinned-clock test noticed.
U6 binds those stamps now, but the defaults remain. The archived &138 plan keeps column defaults out of scope. Its U7 erratum hands applications.submitted_at and administrative_denials.denied_at to this issue. Its U8 erratum keeps application_reopen_episodes.reopened_at on the database clock (#2703).
Two of the six services are done already. #2589 covered canopy-wic. #2582 and #2587 dropped canopy-persons' bound stamps in services/canopy-persons/migrations/20270117000000_redaction_keys_created_at_no_default.sql and its two successors. Those drops are tested in services/canopy-persons/src/api/compensation_infra_tests.rs:247 and services/canopy-persons/src/store/dek_stamp_infra_tests.rs:405. The § Audit below classifies the 105 defaulted timestamp columns that remain across the six services.
Maintainer rulings (2026-10-26, on #3007).
-
Only decision stamps bound from the decision clock lose their default; stamps bound from an operational read keep theirs (D1).
-
application_interviews.created_atfolds into U2. The two canopy-renewals stamps go to #3015. -
quarantined_determinations.received_atis bound from the run’s instant (U1). -
applications.submitted_atrecords the inserting request’s decision-clock instant, which is the meaning the default had, now from the injected clock (U2).
Scope
In scope:
-
The § Audit, the record of acceptance criterion 1 for all six services.
-
U1: canopy-eligibility binds
quarantined_determinations.received_atand drops five defaults. -
U2: canopy-applications binds
applications.submitted_at,administrative_denials.denied_atandapplication_interviews.created_at, and drops five defaults. -
In those two services, a test that an insert naming no stamp is refused.
Out of scope:
-
No migration and no new test for canopy-wic, -persons, -renewals or -appeals. #2589 and #2587 finished wic and persons, and no production INSERT in renewals or appeals names any defaulted column.
-
Stamps bound from an operational read (D1). They keep their defaults.
-
Two decision-bearing canopy-renewals stamps that no code binds:
snap_periodic_reports.created_at(the pipeline’s go-live epoch) andsnap_change_reports.reported_at(the contract’s reporting event time). Each needs a code change and a ruling, so both go to #3015. -
Stamps that stay on the database clock by design (D3).
-
Widening the migrations check (D4).
Design
D1 — which defaults go. A default goes when its column is a decision stamp and every production INSERT binds it from the decision clock; that is the issue’s rule. Some stamps are bound from an allowlisted operational read:
-
canopy-persons'
*_versions.recorded_at; -
eligibility_requests.requested_atanddetermination_operations.claimed_at; -
application_sections.created_atandupdated_at.
These keep their defaults. Check 6 already classifies them as operational, with the reason in their allowlist entries, and a fallback to the database clock changes no decision.
D2 — bind first, then drop. Four decision stamps still fall to their default, so each unit ships the binding and the migration together:
-
quarantined_determinations.received_at, which #3007 names, though no code binds it today; -
applications.submitted_atandadministrative_denials.denied_at, from the &138 U7 erratum; -
application_interviews.created_at, which the NOMI M2 discriminator reads (folded in by the 2026-10-26 ruling).
Each binds an instant its caller already read. No unit adds a clock read, a check-6 allowlist entry or a B8 movement.
D3 — stamps that stay on the database clock. Two comparisons need the database clock on both sides:
-
the reopen void step compares
application_programs.created_atwithapplication_reopen_episodes.reopened_at(services/canopy-applications/src/store/reopen.rs:560, #2703, &138 U8); -
the materiality guard compares
snap_certifications.created_atwith the persons host’s envelope stamp (services/canopy-renewals/src/subscriber.rs:297, #2196).
A steerable clock on one side would void the wrong rows or suppress the wrong nudges.
D4 — the migrations check already covers all six. check_clock_defaults applies the version cutoff CLOCK_DEFAULT_FREE_FROM_VERSION (20270209000000) to every file under services//migrations and crates/, with no service list. Its test a_database_owned_stamp_may_keep_its_clock_default refuses a default in a migration of a service that does not exist yet. Both new migrations are versioned past the cutoff, so the check scans them. They only drop defaults, so it finds nothing. No change.
D5 — migration shape. Each unit adds one file, services/canopy-<svc>/migrations/<version>_decision_stamps_no_default.sql:
-
<version>is the next freeYYYYMMDDhhmmssafter the newest migration in the tree when the unit starts. At drafting the newest is20270210000000, in canopy-verification. -
It is forward-only (ADR-016) and contains
ALTER TABLE … ALTER COLUMN … DROP DEFAULTstatements only. That is a catalog change: no table rewrite, and existing rows are untouched. -
The header comment follows the WIC file’s. It adds one paragraph naming the columns that keep their defaults, grouped by the § Audit reason (acceptance criterion 2).
D6 — tests. Each unit mirrors services/canopy-wic/tests/wic_test.rs:2287-2331:
-
a
BOUND_STAMPSconst, and a testno_bound_stamp_falls_back_to_the_database_clock; -
the test asserts that
canopy_test_lib::stamps::unbound_stampsis empty over anEphemeralSchema::new_for_serviceschema; -
it asserts that an insert leaving out exactly one stamp is refused for that column (
stamps::not_null_column); -
it guards on
canopy_test_lib::infrastructure_available()and is never#[ignore](AGENTS.md override).
Each newly bound stamp also gets a pinned-clock assertion to the microsecond. The pinned instant is DecisionClock::fixed(at) with a sub-second part, built as U6’s a_pinned_run_scores_ages_on_its_legal_day_and_stamps_its_instant builds it.
D7 — fixtures. A raw test INSERT that leaves out a stamp whose default goes must now name it:
-
use SQL
now()where the test relied on the default’s instant (test code is outside check 6); -
use the test’s own instant where the test orders rows.
No assertion changes. The integration lane reports any missed fixture loudly: a 23502 error that names the column.
Audit
Classes:
-
A — a decision stamp that every production INSERT binds from the decision clock. Its default is dropped.
-
B — a decision stamp that no INSERT binds. It is either bound and then dropped, or out of scope.
-
C — operational. It keeps its default for the reason given.
"Production INSERT" means every INSERT INTO <table> outside #[cfg(test)] modules. The only writers of these services' tables from outside the service are tools/canopy-seed/src/sql.rs and one canopy-portal infra test (U1).
canopy-eligibility — 24 columns: 4 A, 1 B (U1), 19 C
| Column | Class | Evidence |
|---|---|---|
|
A |
the only production insert, |
|
A |
the only production insert, |
|
B → U1 |
|
|
C |
bound from allowlisted operational reads: the staleness key and the ADR-038 claim |
|
C |
row bookkeeping: no insert names them and no decision reads them |
|
C |
circuit-breaker and retry machinery (allowlisted in U6) |
|
C |
audit instants recorded beside the act; no decision reads them |
|
C |
|
canopy-applications — 38 columns: 2 A, 3 B (U2), 33 C
| Column | Class | Evidence |
|---|---|---|
|
A |
the only production insert, |
|
A |
|
|
B → U2 |
the &138 U7 erratum hands it to #3007; the insert omits it |
|
B → U2 |
the U7 erratum hands it to #3007. |
|
B → U2 |
the NOMI M2 discriminator reads the superseding row’s |
|
C |
the #2703 void horizon (D3); |
|
C |
bound from the allowlisted |
|
C |
bookkeeping, list order or audit; the decision values beside them ( |
|
C |
workload routing, outside any case |
|
C |
credentials, recovery and draft retention (ADR-026), outside any case |
|
C |
ADR-038 lease and saga, scan-queue, shadow-ledger and window-fence machinery |
|
C |
|
canopy-renewals — 15 columns, none bound by any production INSERT
| Column | Class | Evidence |
|---|---|---|
|
C |
the #2196 ordering against the envelope stamp (D3) |
|
B → out |
|
|
B → out |
its contract names it the reporting event time ( |
|
C |
bookkeeping and list order |
|
C |
an arrival-order tie-break ( |
|
C |
window-fence bookkeeping; |
canopy-appeals — 17 columns, none bound by any production INSERT
| Column | Class | Evidence |
|---|---|---|
|
C |
bookkeeping, list order and the convergence-sweep cutoffs allowlisted in U4; the bound decision inputs are |
|
C |
audit timeline order; the rep-overturn retry reads the latest event’s type, never its instant ( |
|
C |
ADR-038 work queue, window fence; |
canopy-persons (9 columns) and canopy-wic (2 columns)
-
canopy-persons:
-
income_versions,asset_versions,expense_versions,address_versionsandhousehold_member_versions.recorded_atare class C. Every version insert binds them from the allowlisted transaction-time read (&138 D6). -
finalize_operation_generations.created_atandfinalize_receipts.created_atare class C: ADR-038 bookkeeping. -
event_outbox.enqueued_atandevent_inbox.enqueued_atare class C.
-
-
canopy-wic: only
event_outbox.enqueued_atandevent_inbox.enqueued_atremain, both class C.
Units (weights by complexity) — U1 ‖ U2
Weights: 1 trivial · 2 small · 3 medium · 5 large · 8 very large. One unit = one independently shippable MR = one child issue. The two units touch different services; they share only CHANGELOG lines.
U1 (w3, #3013) — canopy-eligibility binds the quarantine receipt and drops five defaults
Files: services/canopy-eligibility/migrations/<version>_decision_stamps_no_default.sql (new), services/canopy-eligibility/src/quarantine.rs, services/canopy-eligibility/src/orchestrator.rs, services/canopy-eligibility/src/bulk/arm.rs, the fixtures below, services/canopy-eligibility/tests/eligibility_test.rs, services/canopy-eligibility/tests/orchestrator_dispatch_test.rs.
-
Migration (D5). Drop the defaults of
program_determinations.received_atandcreated_at,combined_results.assembled_atandcreated_at, andquarantined_determinations.received_at. The comment’s kept list is the eligibility class-C rows. -
Binding.
-
quarantineandquarantine_bytestake a new last parameter,received_at: DateTime<Utc>, and bind it as the INSERT’s twelfth column. -
In
orchestrator.rs,quarantine_envelopegainsreceived_at.intake_receivedpassesinput.received_at.adopted_envelopegains the parameter fromintake_envelope. -
In
bulk/arm.rs, the dispatch quarantine (services/canopy-eligibility/src/bulk/arm.rs:452) passesctx.now, andquarantine_adoptionpassesadoption.ctx.now. -
Test callers to update:
services/canopy-eligibility/src/api/quarantine_tests.rs:291,services/canopy-eligibility/tests/alert_scoping_test.rs:221,services/canopy-eligibility/tests/quarantine_resolution_test.rs:194andservices/canopy-eligibility/tests/quarantine_concurrency_test.rs:126.
-
-
Fixtures (D7). Paths are under
services/canopy-eligibility/unless given in full.-
program_determinations:tests/determination_index_scan_test.rs:82,tests/latest_determinations_per_program_test.rs:140,tests/alert_scoping_test.rs:78,tests/case_status_per_program_test.rs:67and:214, andtests/quarantine_resolution_test.rs:239(created_atonly). -
The canopy-portal infra test that writes the devstack eligibility database:
services/canopy-portal/src/home.rs:2244. -
combined_results:src/api/quarantine_tests.rs:258,tests/order_substrate_test.rs:313and:352(created_atonly),tests/quarantine_resolution_test.rs:135andtests/quarantine_concurrency_test.rs:94. -
canopy-seed already names all five stamps (
tools/canopy-seed/src/sql.rs:2215,:2271,:2316).
-
-
Tests.
-
In
eligibility_test.rs, the D6 test over the five stamps. Its probe inserts aneligibility_requestsrow (that table keeps its defaults), then acombined_resultsrow that namesassembled_atbut notcreated_at. The second insert is refused forcreated_at, which is the shape of the U6 regression. -
In
orchestrator_dispatch_test.rs'sdecision_clockmodule, adda_pinned_run_quarantines_at_its_instant. It is set up like its sibling, except the verifier holds a different SNAP key (from a secondgen_program_key). The envelope is quarantined, and the row’sreceived_atisat.
-
U2 (w5, #3014) — canopy-applications binds the filing, denial and interview instants and drops five defaults
Files: services/canopy-applications/migrations/<version>_decision_stamps_no_default.sql (new), services/canopy-applications/src/store/mod.rs, services/canopy-applications/src/api/mod.rs, services/canopy-applications/src/finalize_saga.rs, services/canopy-applications/src/store/administrative_denials.rs, services/canopy-applications/src/api/administrative_denials.rs, services/canopy-applications/src/api/administrative_denial_support.rs, services/canopy-applications/src/scheduler.rs, services/canopy-applications/src/store/interviews.rs, services/canopy-applications/src/api/interviews.rs, the fixtures below, services/canopy-applications/tests/application_test.rs, services/canopy-applications/tests/finalize_saga_test.rs, services/canopy-applications/tests/interviews_http_test.rs.
-
Migration (D5). Drop the defaults of
applications.submitted_atandreceived_at,administrative_denials.denied_at,application_agency_pends.pended_atandapplication_interviews.created_at. -
submitted_at.-
In
services/canopy-applications/src/store/mod.rs, addpub struct FilingStamps { submitted_at, received_at: DateTime<Utc>, legal_filed_date: NaiveDate, legal_filed_basis: LegalFiledBasis }(Copy). It replaces the three filing parameters, because an eighth parameter oncreate_application_with_idwould cross clippy’s seven-argument limit. -
The new signatures are
create_application(executor, req, stamps, renewal)andcreate_application_with_id(executor, id, req, stamps, renewal). The INSERT bindssubmitted_at. -
submitted_atis the inserting request’s one clock read, which is what the default recorded, now taken from the decision clock. That read isnowin the intake handler andnowinrun_final_tx;received_atstays the resolved receipt. The fourth caller is intests/finalize_saga_test.rs.
-
-
denied_at.-
NewAdministrativeDenialgainspub denied_at: DateTime<Utc>, whichinsert_on_slotbinds. -
resolve_denialreads the clock once:let now = deps.clock.now(); let legal_today = canopy_common::clock::date_in(now, deps.tz.0);replaces the read atservices/canopy-applications/src/api/administrative_denials.rs:251.new_denialthen takesdenied_at. -
In the day-30 deny arm,
DenyInputsgainsdenied_at, whichenforce_denysets fromtick.nowandapply_denycopies. -
Test constructors gain the field:
services/canopy-applications/src/api/mod.rs:4411,services/canopy-applications/src/store/administrative_denials.rs:478, andservices/canopy-applications/src/scheduler.rs:5567and:5620.
-
-
application_interviews.created_at.-
NewInterview(services/canopy-applications/src/store/interviews.rs:100) gainspub created_at: DateTime<Utc>.create_interview, the only production INSERT, binds it. -
schedule_interviewandreschedule_interviewpass the one decision-clock read each already makes (let now = clock.now();,services/canopy-applications/src/api/interviews.rs:168and:270). No clock read is added. -
The two unit-test callers in
store/interviews.rs(:818,:884) pass a fixed instant.
-
-
received_atandpended_atare class A: this unit only drops their defaults and updates fixtures. -
Fixtures (D7). Find them with
grep -rn 'INSERT INTO <table>'underservices/canopy-applications.-
applications: about 28 test-module andtests/inserts namesubmitted_atandreceived_at. -
administrative_denials: about 14 inserts namedenied_at. They are inservices/canopy-applications/src/scheduler.rsand intests/actor_columns_test.rs,tests/administrative_denial_test.rs,tests/recert_reopen_drift_test.rs,tests/reopen_http_test.rsandtests/scheduler_run_http_test.rs. -
application_agency_pends:src/store/postponement.rs:1915and:2043, andtests/postponement_http_test.rs:1210, namepended_at. -
application_interviews: the test-module inserts inservices/canopy-applications/src/events.rs,services/canopy-applications/src/store/mod.rsandservices/canopy-applications/src/scheduler.rs, and those intests/actor_columns_test.rs,tests/administrative_denial_test.rs,tests/day30_enforce_http_test.rs,tests/interviews_http_test.rs,tests/reopen_http_test.rsandtests/scheduler_run_http_test.rs, namecreated_at. Where a test orders a superseding row after its predecessor, it uses its own increasing instants. -
canopy-seed names
submitted_atandreceived_atalready (tools/canopy-seed/src/sql.rs:1082) and seeds no denial, pend or interview.
-
-
Tests.
-
In
application_test.rs, the D6 test over the five stamps. Its probe inserts anapplicationsrow that namesreceived_atbut notsubmitted_at; the insert is refused forsubmitted_at. -
Also in
application_test.rs, an intake throughcommon::build_in_process_app_atwithDecisionClock::fixed(pinned), built as atservices/canopy-applications/tests/interviews_http_test.rs:1675. It posts a SNAP application whosereceived_atis one day beforepinned. The 201 echoessubmitted_at == pinnedand the backdatedreceived_at. -
a_pinned_finalize_files_on_the_legal_day_and_stamps_the_instantalso asserts the row’ssubmitted_at. -
A new infra test in
store/administrative_denials.rsassertsdenied_atto the microsecond. -
In
interviews_http_test.rs, a schedule throughbuild_in_process_app_atwithDecisionClock::fixed(pinned), built as the test at:1675. The stored row’screated_atequalspinnedto the microsecond. -
In
scheduler.rs, add a variant ofa_reopened_row_with_a_past_due_critical_item_is_denied_on_its_episodewhose deps carryDecisionClock::fixed(pinned), wherepinnedis noon oflegal()with a sub-second part. It asserts that the episode’s denial hasdenied_at == pinned.
-
Risks
-
An INSERT the audit missed — fail-closed (today: silent). Such an insert fails at run time with a 23502 naming the column, instead of stamping from the database clock unnoticed. That flip is the point of the change, but it surfaces late. Mitigation: the audit enumerated every writer of each dropped table across the repository (the § Audit header); the integration and e2e lanes drive the writers, and canopy-seed’s demo load replays into the migrated schema at
dev restart. -
Rolling upgrade — fail-closed. A replica still on the old image after the new one has migrated fails the inserts that relied on a default (the eligibility quarantine; the applications filing, denial and interview) until it is replaced. No row is written wrong. Mitigation: the project is pre-1.0 and the devstack restarts every service together, so the plan adds no shim.
-
The denial route has no pinned in-process test — silent if
resolve_denialreads the clock twice, sincedenied_atandlegal_denied_datecould then disagree by a day across midnight. Mitigation:build_in_process_app_atwires no persons client and the route fails closed without a recipient, so the store test, the day-30 test and the single read inresolve_denialcover it, and review checks that one line. -
The 40-line ceiling — fail-closed (clippy refuses the build). A touched function that crosses it (for example
resolve_denial) is split, not suppressed.
Verification
-
cargo xtask test: the unit and integration lanes pass, including the D6 tests (see Testing). -
cargo xtask migrations-lintis clean, and its count of grandfathered defaults is unchanged. -
cargo xtask test-lanes-lint --staticis clean with no allowlist change. -
cargo xtask dev restart(a schema change wipes data), thencargo xtask e2e. -
cargo xtask validate, withCANOPY_CARGO_FEATURES=canopy-api/test-clock,canopy-api/test-fault. -
Close: the unit that merges second sets Status
Done (YYYY-MM-DD) — !N, moves this plan and its nav entry underplans/archive/, passescargo xtask plan-lint --done, and carriesCloses #3007. The first unit carriesRelates to #3007.
Documentation Updates
-
canopy-eligibility data model (U1) and canopy-applications data model (U2): a
== Migration filesbullet each, in #2589’s form -
CHANGELOG.adoc: one=== Fixedentry per unit under== Unreleased. U1’s entry also records the audit outcome for wic, persons, renewals and appeals: nothing left to drop. -
No change to the
api/pages or the Service Catalog: no route, wire field or table changes, as with #2589
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 |
Anthropic |
Claude Fable 5.1, gadhs/pi’s plan review at exit_plan_mode |
FLAGS (2026-10-26), fixed: § Risks did not label each risk fail-open, fail-closed or silent (labels added). P2 flagged the unit files the 12-file, 200 KB review-context cap left unsupplied; the reviewer read them in the tree and found every seam as described. |
2 |
Gemini 4 Argon, pi’s integrated second-vendor review |
FLAGS (2026-10-26), P2 only: the same unsupplied unit files, each read in the tree and found to match. No edit. |