CMD Change-Report Pipeline — Rollout & Operations

For an operator deploying or running the change-report pipeline (archived plan): determination.requested with kind = order (crates/canopy-contracts-eligibility/src/events.rs) → the eligibility order substrate → the signed change-report re-determination → determination.completed (origin echo) → the Medicaid CMD settle. Constants below live under services/canopy-eligibility/src/orders/ unless another file is named.

Preconditions

  • CANOPY_MQ_PREFETCH_COUNT=1 on every canopy-eligibility replica: the determination.requested consumers attach on every boot regardless of bulk_runs_enabled, and boot refuses any other prefetch (BulkSettings::validate_consumer_environment, services/canopy-eligibility/src/bulk/config.rs).

  • No bulk run in previewing / enacting during the eligibility deploy window, or pause the run: an in-flight envelope from before #1504 (no kind tag) fails to parse on the new consumer, is nack-requeued, and dead-letters after the consumer’s attempt budget (bulk_max_attempts, default 5); an affected bulk case recovers through the worker’s redispatch-TTL republish (bulk_redispatch_ttl_secs, default 1800 s).

Steps (binding-first order)

  1. Broker ACLs. Add determination.requested to canopy-medicaid’s topic-write regex on canopy.events — the canopy-medicaid user in devstack/rabbitmq/definitions.json is the template. In production change the vhost user BEFORE any producer deploy, or the broker ACCESS_REFUSEs the publish.

  2. canopy-eligibility — the consumer and the order sweep.

  3. canopy-medicaid and canopy-web — the producers.

Verify

  • determination_orders (eligibility DB, migration 20261125000000_determination_orders.sql) is the durable ledger: pending → dispatched → succeeded | failed_retryable | failed_terminal; UNIQUE (origin_source, origin_ref) is the dedup identity.

  • Retry pacing is server-side in next_attempt_at: 60 s doubling, capped at 1 h, ±10 % jitter (orders/store.rs). The attempt cap is ORDER_MAX_ATTEMPTS = 12 (orders/mod.rs) — roughly an eight-hour horizon, so a busy household’s 409 chain cannot terminalize a re-determination inside one working session. The always-on sweep (SWEEP_INTERVAL = 60 s, orders/sweep.rs) re-publishes due orders and abandons claims older than twice the self-call timeout; MQ never hot-loops an order. Settles are fenced on the claim’s own timestamp token, so a zombie executor cannot settle a successor’s claim.

  • A terminal failure logs determination order failed terminally (tracing::error, orders/mod.rs) with the origin identity — the DLQ-equivalent to alert on.

Recovery

  • Terminal failure, cause fixed. Reset the row; the next sweep re-runs it under the epoch’s same operation, and the re-run is duplicate-safe however long after the failure it runs: canopy-medicaid holds one determination per operation and subject (#2673), so a re-execution of a dispatch whose first execution committed is 409 operation_already_determined and writes nothing, and the orchestrator adopts the committed determinations by the operation. This holds for an epoch whose first execution ran at a canopy-medicaid that records operations; one that committed before #2673 has none to read back. The deterministic dispatch key’s idempotency cache (24 hours) and the result-replay adoption query are the faster paths, not the guard:

    UPDATE determination_orders
       SET state = 'failed_retryable', attempt_count = 0, next_attempt_at = now()
     WHERE id = …;
  • Crash. No operator action: redelivery converges on the order row, and a completed-but-unsettled run is adopted through the (origin_source, origin_ref) correlation on eligibility_requests, never re-executed.

  • Duplicate orders. A requester resubmitting the same change under a new origin ref (the worker resubmits the CMD form after a partial failure) creates a second order. Both settle against the same facts; the second signed determination supersedes the first with previous_determination_id linkage. Expected and harmless — do not "clean up" the first order.

Program scope caution

A CMD order names the programs its application determined: medicaid, and chip beside it for a paired Medicaid/CHIP filing (#2319). A change report for an application with no determination is refused 422 cmd_application_undetermined before anything is written; the worker files and determines the application first.

An order’s programs list is unrestricted, and the orchestrator stamps the order’s trigger into the context every program receives. snap refuses a trigger-carrying context when its replica cannot emit the signed policy attestation (422 attestation_disabled, services/canopy-snap/src/api/determine_policy.rs), so an order that includes snap on a non-attesting fleet burns its retry budget and terminalizes. Keep orders scoped to programs whose provenance plumbing is live; snap requires CANOPY_SNAP__EMIT_POLICY_ATTESTATION=true (emit_policy_attestation, services/canopy-snap/src/config.rs).

Rollback

Reverse the deploy order: producers off first, the consumer drains the queue, the ACLs stay (harmless).

NOTE
History — #1504 made the determination.requested consumers and the order sweep unconditional; #1506 / #1507 added the Medicaid and worker-portal producers.
Edit this page · default