Plan: operator tools leave xtask; direct work lives in canopy-manage (#3399)
Status: Done (2026-11-24) — the four units are built; no operator job is an xtask verb
Closes: #3399 (by U4)
Issues: #3399 (parent) · U1 #3562 · U2 #3563 · U3 #3564 · U4 #3565 · relates to #3561, #1304, #3384
This is a Design + Scope plan: GitLab owns tracking, the unit issues carry the implementer brief, and the plan freezes when U1 starts.
Problem
xtask is the developer’s task runner: it needs a checkout and a Rust toolchain, has no release version, and links canopy-test-lib as a normal dependency (xtask/Cargo.toml). Operator pages nonetheless send a production operator to it:
-
cargo xtask migrate applyandmigrate rewrap-keks, "the deploy-time jobs" (xtask/src/cmd/migrate.rs), readservices/<svc>/migrationsfrom a checkout. -
cargo xtask gen-signing-keysmints a program service’s production signing pair (runbooks/signing-key-rotation.adoc). -
cargo xtask secrets generate-signing-key, a dev-secrets helper, is whatsecurity-operations.adocnames for minting a canopy-identity client key. -
cargo xtask identity checkis canopy-identity’s deploy gate (idp-integration.adoc). -
chain-genesis,sweep-finalize-orphans,backfill-hohandreanchor-issued-expiryare operator one-shots.
The service image ships no xtask and no toolchain, so none of these can run where a deployment’s credentials are. The three chain-migration-split compose one-shots already show it: they run cargo xtask migrate apply in an image that has carried no cargo since #3274.
Decisions already taken
Maintainer rulings on #3399 (2026-11-14 and 2026-11-24):
-
canopy-cli stays the API-only operator tool, plus offline file checks (ADR-007 Amendment 5). A new binary carries direct-database and key-material jobs. xtask keeps neither kind.
-
The new binary is
canopy-manage, matching craig’scraig-manage(craig ADR-088). -
identity checkgoes tocanopy-manage: it signs a grant with a service’s private client key. -
sweep-finalize-orphans,backfill-hohandreanchor-issued-expiryare deleted as spent. canopy-persons'POST /v1/households/{id}/compensate-finalize-orphan, which only the sweep calls, is deleted with it. -
chain-genesisis deleted from xtask and ported nowhere. The rest of chain-v2 is #3561. -
A production client key is minted by a new
canopy-manage gen-client-key;cargo xtask secrets generate-signing-keystays for dev secrets. -
No alias: a moved verb leaves xtask in the merge request that moves it.
Design
Where each verb goes
| xtask verb | Destination | Why |
|---|---|---|
|
|
Write a service database with the migration credential and the KEK. |
|
|
Production key material. |
(none) |
|
Production key material; replaces the dev helper on the operator page. |
|
|
Needs a service’s private client key. |
|
deleted |
Ruling 5. |
|
deleted |
Ruling 4. |
|
stay |
|
|
stay |
Start conformance containers from a checkout; a pre-release developer step. |
|
stay |
Act on the checkout’s |
|
stays |
Edits the checkout’s |
The canopy-manage crate
tools/canopy-manage, a workspace member with a library and a binary canopy-manage, as canopy-cli is laid out. One subcommand per job.
-
Dependencies. canopy-db, sqlx, canopy-crypto-shred, canopy-signing, canopy-auth, canopy-secrets, canopy-common, canopy-reference.
canopy-test-libonly under[dev-dependencies]. A unit test reads the resolved normal-dependency graph and refusescanopy-test-liband any package underservices/, the waytools/canopy-cli/src/dependency_boundary.rsholds canopy-cli’s boundary. -
No default target. A verb refuses to start unless told what to act on. Nothing in the crate reads
.ports.env,.keys/or names a devstack. A developer runs the same verb against the devstack by setting the same variables an operator sets. -
Released with the services. It joins
lanes::BINARY_PACKAGESandBINARY_NAMES(22 to 23), the rootDockerfilegains itsCOPYbesidecanopy(and its comment’s count of COPY lines is corrected), the release build line in.gitlab-ci.ymlnames it, andROUTERLESS_BINARIES(xtask/src/devstack_binaries.rs) lists it.shipped_featuresthen holds it to the services' rule (notest-*feature) with no further change, since that gate builds everyBINARY_PACKAGESmember but the CLI and the broker. -
Lints.
db_pools,http_clients,secret_loadsandretention_deletesalready scantools/.
migrate apply and rewrap-keks
Behaviour is xtask/src/cmd/migrate.rs's apply and rewrap_keks, moved, with two changes forced by having no checkout:
-
Migrations are compiled in. Today the verb loads
services/<svc>/migrationsfrom disk withMigrator::new.canopy-manageembeds each service’s directory withsqlx::migrate!(one staticMigratorper service, keyed by service name), so the image needs no source tree and applies exactly the migrations of the release it was built from. An unknown--serviceis refused naming the valid ones. A test listsservices/*/migrationsand fails when a directory has no embedded migrator. -
The URL is required.
CANOPY_MIGRATE__DATABASE_URLstays the variable (never argv). Unset or empty refuses; the devstack fallback (chain_service,.ports.env) is removed.
Unchanged: the KEK preflight for sealing services before any pool opens (#1464), validate_database_name (ADR-001), the one-connection pool through DbPool::connect_with and its TLS gate, ensure_idempotency_schema before the migrator (#1463), rewrap-keks refusing without _PREVIOUS and exiting non-zero when a DEK could not be rewrapped.
The three chain-migration-split services in docker-compose.yml switch from Dockerfile.integration and cargo xtask migrate apply to the service image and /app/canopy-manage migrate apply --service <svc>. They stay profile-gated and dormant.
gen-signing-keys and gen-client-key
gen-signing-keys --program <role> --output-dir <dir> moves with KeyRole and its seven tests. --output-dir becomes required: the .keys default is a checkout path. The private half is still written owner-only, through canopy_common::owner_only. xtask’s the_dev_key_roster_is_every_signing_role (xtask/src/devstack_guard.rs) reads KeyRole::valid_names() from canopy-manage’s library, so xtask depends on canopy-manage.
gen-client-key --client <id> --output-dir <dir> is new. <id> must parse as a canopy_auth::ConfidentialClient. It generates a P-256 key, writes the PKCS#8 private PEM owner-only as <id>.pem, and prints the variable it belongs in (canopy_auth::client_key_secret) and the public JWK x and y in the unpadded base64url form canopy-security’s identity-clients.yaml takes. It prints no private material.
identity check
The three checks (metadata, keys, mint) and their 603 lines of tests move from xtask/src/cmd/identity/check.rs unchanged in meaning. Two inputs change:
-
The key comes only from the secret provider, under
client_key_secret(client). TheDevstack::prove_identityfallback to.keys/stays behind in xtask’s devstack code, which other bring-up paths use; canopy-manage has no such branch. -
httpURLs are admitted only whenCANOPY_ENV=development, the rulecanopy_api::bootstrap::identity_planeapplies to a service, in place of the devstack proof.
cargo xtask identity keeps conformance and matrix.
Deletions
-
chain-genesis:xtask/src/cmd/chain_genesis.rs,xtask/src/chain_genesis.rs,xtask/tests/chain_genesis_test.rs.block_on, whichperfalso calls, moves to an xtask module of its own.chain_serviceanddevstack_urlhave no caller oncemigrate applyhas moved, so U1 keeps those two inmigrate.rsand U3 deletes them.crates/canopy-chainis untouched (#3561). -
The three one-shots, with
xtask/src/reanchor_issued_expiry.rs,xtask/tests/reanchor_issued_expiry_test.rsand theSweepFinalizeOrphansarm ofthe_cli_resolves_path_arguments_before_anchoring(xtask/src/cmd/validate.rs). -
canopy-persons: the route registration and handler
compensate_finalize_orphan(services/canopy-persons/src/api/mod.rs),paths::COMPENSATE_FINALIZE_ORPHAN,OrphanCompensationResponse,services/canopy-persons/tests/finalize_orphan_test.rs, and any store function left with no caller (thedead_codelint names them; a function the finalize saga’s cancel path still calls stays). The OpenAPI snapshot,authorization-inventory.adocandapi/canopy-persons.adoclose the row. -
Docs:
runbooks/finalize-orphan-sweep.adocand its nav entry; every other mention is found by search, not from a list (rg 'sweep-finalize-orphans|backfill-hoh|reanchor-issued-expiry|chain-genesis|compensate-finalize-orphan'overdocs/modules/ROOT/pagesoutsideplans/andadrs/, overservices/,crates/,tools/anddocs/modules/ROOT/openapi). Known today:finalize-reconciler.adoc,deployment-guide.adoc,security-operations.adoc,configuration-reference.adoc,services.adoc,shared-crates.adoc,api/canopy-persons.adoc(the route row and three prose mentions),api/canopy-enrollment.adoc,data-models/canopy-enrollment.adoc,tooling/xtask-catalog.adoc, and doc comments in canopy-enrollment that reachopenapi/enrollment.json(regenerated). The search returning nothing is U1’s acceptance. ADR-038 and ADR-025 name the sweep in accepted text, which stays; each gains a one-line dated note that the sweep and its route were removed.
ADR-007 Amendment 6 and the guard
ADR-007 gains Amendment 6: an operator’s tool is never an xtask verb; API work is canopy-cli’s; work below the API is canopy-manage’s, which has no default target and ships in the service image; a moved verb keeps no alias. It also corrects, in a dated note, Amendment 5’s last bullet, which names the binary canopy-admin.
Two tests in xtask hold it, both reading a cargo xtask <verb> mention across a line break and taking the sub-verb for migrate, identity, config, secrets and dev:
-
every_xtask_command_a_page_names_exists, over every page underdocs/modules/ROOT/pagesexceptplans/andadrs/(dated records): each mention must parse as a verb of xtask’s own clapCommand. A moved or deleted verb no longer parses, so no page anywhere can keep naming one. Only a mention inside backticks or a listing block counts: link text such as "cargo xtask catalog" (local-dev.adoc,developer-guide.adoc) is prose, not a command. This is what catchescoding-conventions.adoc,developer-guide.adoc,implementation-guide.adoc,nist-architecture-mapping.adoc,data-models/*.adocand any page a list would miss. -
no_operator_page_sends_an_operator_to_xtask, over the operator pages:deployment-guide.adoc,security-operations.adoc,configuration-reference.adoc,migrations.adoc,idp-integration.adoc,implementation-guide.adoc,jurisdiction-onboarding.adoc,tooling/canopy-cli.adoc,tooling/canopy-manage.adocand every page underrunbooks/. Each verb they name needs a row in a table of developer verbs with its reason (for exampledev: the devstack;config fetch: acts on a checkout). A verb named with no row fails; a row no page names fails.
Tests
| Category | Tests |
|---|---|
Unit (boundary) |
|
Unit (target) |
|
Unit (moved) |
|
Unit (keys) |
|
Unit (identity) |
|
Routed (postgres) |
|
Contract |
The persons OpenAPI snapshot without the route; |
Regression |
|
Build |
|
Not run locally (the car’s): the release job’s image build, the stack-calling targets, and the e2e journeys.
Risks
| Risk | Mode | Mitigation |
|---|---|---|
An operator runs |
fail-closed |
There is no default: unset or empty refuses ( |
A new service’s migrations are not embedded, so its job applies nothing. |
fail-closed |
An unknown service is refused, and |
canopy-manage’s image is older than the service’s, and applies an older migration set. |
silent |
One image carries both, at one version; |
Test fixtures reach a tool that writes production data. |
fail-closed |
|
A deployment still holds pre-saga finalize orphans, NULL heads of household or un-reanchored issued rows. |
silent |
Ruled out by the maintainer: no deployment holds such data. The changelog names the three removed verbs and the release that last carried them. |
The removed persons route is still called. |
fail-closed |
Its only caller is the removed sweep; a call answers 404. No worker surface or CLI verb names it (searched). |
A developer loses the devstack shortcut for |
fail-closed |
The verbs refuse and name the variable; |
An operator page drifts back to an xtask verb. |
fail-closed |
|
|
fail-closed |
Owner-only write; the test asserts the output carries no PEM. |
Scope
| Unit | Work | Status |
|---|---|---|
U1 |
Delete |
Done (2026-11-24) |
U2 |
The |
Done (2026-11-24) |
U3 |
|
Done (2026-11-24) |
U4 |
|
Done (2026-11-24) |
Units are stacked in this order. Out of scope: the rest of chain-v2 (#3561); whether xtask can drop canopy-test-lib as a normal dependency, which is measured after U4 and filed if it can.
Delivery
-
Doc pages:
tooling/canopy-manage.adoc(new, in nav) is the canonical page, and ADR-007. Every page that names a moved verb is rewritten in the unit that moves it;every_xtask_command_a_page_names_existsfails until none is left, so the set is whatever that test finds. Known today, beside the operator pages listed under the guard:tooling/xtask-catalog.adoc,local-dev.adoc,shared-crates.adoc,services.adoc,coding-conventions.adoc,developer-guide.adoc,nist-architecture-mapping.adoc,data-models/index.adocanddata-models/canopy-{applications,security,verification,web}.adoc. Code comments and error text that name a moved command (crates/canopy-api/src/bootstrap.rs,idempotency.rs,crates/canopy-db/src/idempotency_schema.rs) are rewritten with it. -
CHANGELOG.adoc== Unreleased: one entry per unit; each names the old command line and the new one, or the removal. -
This plan page with its nav entry, merged before U1.
-
The close: U4’s MR closes #3399; merge SHAs are noted on it. #3561 is noted that
chain-genesisis gone.
Errata
-
Erratum (2026-11-24), U1:
chain_serviceanddevstack_urlwere not kept inmigrate.rsuntil U3. They depended on acanopy-chaintype, so a list of the three services with a database instance of their own replaces them; the devstack URL fallback is unchanged, and U3 still removes it. -
Erratum (2026-11-24), U1: xtask’s library target and
xtask/tests/existed only for the two deleted cores, so both are gone, and thextask-unix-guardscansxtask/srcalone. -
Erratum (2026-11-24), U1:
every_xtask_command_a_page_names_existsfound two pages namingcargo xtask ci, retired earlier; both are corrected in U1. -
Erratum (2026-11-24), U2: xtask takes canopy-manage as a development dependency only, since a test alone reads
KeyRole::valid_names(). Thecargo treereader the two boundary tests share moved from canopy-cli tocanopy_test_lib::dependency_tree. -
Erratum (2026-11-24), U3: the routed tests apply into an empty schema of the service's test database, not an empty database, as every other postgres test here does. The sealing-service KEK was missing from the tanf and medicaid compose one-shots, which the job would have refused; they now pass it.
-
Erratum (2026-11-24), U4:
Devstack::prove_identityand the devstack key-file reader had no caller butidentity check, soxtask/src/devstack_target.rsis deleted, not kept;secret-loadsloses the exemption that type granted. The developer-verb table has a row per top-level verb, which lists its developer sub-verbs where only some are (migrate,identity,config).