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 apply and migrate rewrap-keks, "the deploy-time jobs" (xtask/src/cmd/migrate.rs), read services/<svc>/migrations from a checkout.

  • cargo xtask gen-signing-keys mints a program service’s production signing pair (runbooks/signing-key-rotation.adoc).

  • cargo xtask secrets generate-signing-key, a dev-secrets helper, is what security-operations.adoc names for minting a canopy-identity client key.

  • cargo xtask identity check is canopy-identity’s deploy gate (idp-integration.adoc).

  • chain-genesis, sweep-finalize-orphans, backfill-hoh and reanchor-issued-expiry are 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):

  1. 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.

  2. The new binary is canopy-manage, matching craig’s craig-manage (craig ADR-088).

  3. identity check goes to canopy-manage: it signs a grant with a service’s private client key.

  4. sweep-finalize-orphans, backfill-hoh and reanchor-issued-expiry are deleted as spent. canopy-persons' POST /v1/households/{id}/compensate-finalize-orphan, which only the sweep calls, is deleted with it.

  5. chain-genesis is deleted from xtask and ported nowhere. The rest of chain-v2 is #3561.

  6. A production client key is minted by a new canopy-manage gen-client-key; cargo xtask secrets generate-signing-key stays for dev secrets.

  7. No alias: a moved verb leaves xtask in the merge request that moves it.

Design

Where each verb goes

xtask verb Destination Why

migrate apply, migrate rewrap-keks

canopy-manage migrate apply, canopy-manage rewrap-keks

Write a service database with the migration credential and the KEK.

gen-signing-keys

canopy-manage gen-signing-keys

Production key material.

(none)

canopy-manage gen-client-key (new)

Production key material; replaces the dev helper on the operator page.

identity check

canopy-manage identity check

Needs a service’s private client key.

chain-genesis

deleted

Ruling 5.

sweep-finalize-orphans, backfill-hoh, reanchor-issued-expiry

deleted

Ruling 4.

migrate snapshot, rollback, list

stay

pg_dump wrappers over devstack containers; their module doc says dev and CI only.

identity conformance, identity matrix

stay

Start conformance containers from a checkout; a pre-release developer step.

config fetch, config bump

stay

Act on the checkout’s config-sources.lock; a deployment’s fetch is canopy-config-fetch.

secrets

stays

Edits the checkout’s secrets/dev.yaml.

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-lib only under [dev-dependencies]. A unit test reads the resolved normal-dependency graph and refuses canopy-test-lib and any package under services/, the way tools/canopy-cli/src/dependency_boundary.rs holds 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_PACKAGES and BINARY_NAMES (22 to 23), the root Dockerfile gains its COPY beside canopy (and its comment’s count of COPY lines is corrected), the release build line in .gitlab-ci.yml names it, and ROUTERLESS_BINARIES (xtask/src/devstack_binaries.rs) lists it. shipped_features then holds it to the services' rule (no test-* feature) with no further change, since that gate builds every BINARY_PACKAGES member but the CLI and the broker.

  • Lints. db_pools, http_clients, secret_loads and retention_deletes already scan tools/.

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>/migrations from disk with Migrator::new. canopy-manage embeds each service’s directory with sqlx::migrate! (one static Migrator per 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 --service is refused naming the valid ones. A test lists services/*/migrations and fails when a directory has no embedded migrator.

  • The URL is required. CANOPY_MIGRATE__DATABASE_URL stays 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). The Devstack::prove_identity fallback to .keys/ stays behind in xtask’s devstack code, which other bring-up paths use; canopy-manage has no such branch.

  • http URLs are admitted only when CANOPY_ENV=development, the rule canopy_api::bootstrap::identity_plane applies 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, which perf also calls, moves to an xtask module of its own. chain_service and devstack_url have no caller once migrate apply has moved, so U1 keeps those two in migrate.rs and U3 deletes them. crates/canopy-chain is untouched (#3561).

  • The three one-shots, with xtask/src/reanchor_issued_expiry.rs, xtask/tests/reanchor_issued_expiry_test.rs and the SweepFinalizeOrphans arm of the_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 (the dead_code lint names them; a function the finalize saga’s cancel path still calls stays). The OpenAPI snapshot, authorization-inventory.adoc and api/canopy-persons.adoc lose the row.

  • Docs: runbooks/finalize-orphan-sweep.adoc and 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' over docs/modules/ROOT/pages outside plans/ and adrs/, over services/, crates/, tools/ and docs/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 reach openapi/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 under docs/modules/ROOT/pages except plans/ and adrs/ (dated records): each mention must parse as a verb of xtask’s own clap Command. 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 catches coding-conventions.adoc, developer-guide.adoc, implementation-guide.adoc, nist-architecture-mapping.adoc, data-models/*.adoc and 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.adoc and every page under runbooks/. Each verb they name needs a row in a table of developer verbs with its reason (for example dev: 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)

canopy_manage_links_no_test_library_and_no_service.

Unit (target)

migrate_apply_refuses_without_a_database_url (unset and empty); an_unknown_service_is_refused_naming_the_valid_ones; every_service_migration_directory_is_embedded.

Unit (moved)

migrate.rs's apply and rewrap tests, gen_signing_keys.rs's seven, identity/check/tests.rs, each moved with its code and none weakened.

Unit (keys)

gen_client_key_writes_an_owner_only_pkcs8_key_and_prints_its_jwk (the printed x, y are the written key’s public point; the output holds no private PEM); an_unknown_client_is_refused; gen_signing_keys_requires_an_output_directory.

Unit (identity)

an_http_issuer_is_refused_outside_development; a_missing_client_key_is_refused_naming_its_variable.

Routed (postgres)

migrate_apply_applies_a_services_embedded_migrations_to_an_empty_database and a_second_apply_changes_nothing, on an ephemeral database.

Contract

The persons OpenAPI snapshot without the route; delegated-routes, route-authz audit and call-graph clean.

Regression

no_operator_page_sends_an_operator_to_xtask: it fails on today’s pages, which name cargo xtask migrate apply in deployment-guide.adoc. every_xtask_command_a_page_names_exists lands in U1 and fails on any page still naming a deleted verb; its own unit tests cover a wrapped mention, a sub-verb and an unknown verb.

Build

the_service_image_copies_every_shipped_binary (new, in xtask/src/lanes.rs): the root Dockerfile's COPY target/car/bin/ lines are BINARY_NAMES without the token broker and the configuration fetcher, which ship in images of their own. The Dockerfile's comment says such a test exists; a search of xtask found none. Also every_binary_package_names_its_binary at 23, ci-config-lint, shipped-features.

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 migrate apply with no URL and it reaches a default database.

fail-closed

There is no default: unset or empty refuses (migrate_apply_refuses_without_a_database_url).

A new service’s migrations are not embedded, so its job applies nothing.

fail-closed

An unknown service is refused, and every_service_migration_directory_is_embedded fails the build.

canopy-manage’s image is older than the service’s, and applies an older migration set.

silent

One image carries both, at one version; tooling/canopy-manage.adoc says to run the tool from the image being deployed.

Test fixtures reach a tool that writes production data.

fail-closed

canopy_manage_links_no_test_library_and_no_service; shipped-features.

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 identity check and migrate apply.

fail-closed

The verbs refuse and name the variable; local-dev.adoc gives the devstack command line with its variables.

An operator page drifts back to an xtask verb.

fail-closed

no_operator_page_sends_an_operator_to_xtask.

gen-client-key prints or leaves private material readable.

fail-closed

Owner-only write; the test asserts the output carries no PEM.

Scope

Unit Work Status

U1

Delete chain-genesis, the three one-shots and the persons route, with their tests, docs and runbook; block_on to its own xtask module; every_xtask_command_a_page_names_exists.

Done (2026-11-24)

U2

The canopy-manage crate, its boundary test, its place in the image and the release build; gen-signing-keys moved; gen-client-key; ADR-007 Amendment 6; tooling/canopy-manage.adoc and nav.

Done (2026-11-24)

U3

migrate apply and rewrap-keks moved, migrations embedded, URL required; the compose one-shots; migrate.rs keeps snapshot, rollback and list.

Done (2026-11-24)

U4

identity check moved; no_operator_page_sends_an_operator_to_xtask; every operator page and runbook on the new commands; closes #3399.

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_exists fails 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.adoc and data-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-genesis is gone.

Errata

  • Erratum (2026-11-24), U1: chain_service and devstack_url were not kept in migrate.rs until U3. They depended on a canopy-chain type, 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 the xtask-unix-guard scans xtask/src alone.

  • Erratum (2026-11-24), U1: every_xtask_command_a_page_names_exists found two pages naming cargo 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(). The cargo tree reader the two boundary tests share moved from canopy-cli to canopy_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_identity and the devstack key-file reader had no caller but identity check, so xtask/src/devstack_target.rs is deleted, not kept; secret-loads loses 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).

Edit this page · default