Skip to content

E21-33: the role provisioner's process, mandate-provisionerd (DEC-2350 S4b-2) - #2307

Closed
kunwarshivam wants to merge 4 commits into
claude/v2-provisioner-implfrom
claude/v2-provisionerd
Closed

kunwarshivam wants to merge 4 commits into
claude/v2-provisioner-implfrom
claude/v2-provisionerd

Conversation

@kunwarshivam

Copy link
Copy Markdown
Owner

Story

E21-33, DEC-2350 S4b-2: the process that runs #2306's Provisioner in the cell. It is one PR, not a DEC-77 pair, in the shape of deployd's #1582, as the coordinator agreed. It is stacked on #2306 (base claude/v2-provisioner-impl, 0b252923). It adds 882 lines, about 350 of them tests and the Cargo.lock lines; over the ~400 guideline, flagged.

mandate-provisionerd run --workspace <id> --namespace <ns> --probe <socket> [--vault-address <a> --vault-dir <d> | --fixture], and probe livez|readyz.

  • Journal: the Postgres control stream (MANDATE_JOURNAL_DSN), through mandate-deployd's own PgControl. Both processes write ctl:<workspace> the same way: take the epoch, read the head, append. The alerts go through StderrAlerts, a code and a runbook only.
  • Vault:
    • Trusts only the CA mounted in --vault-dir (ca.crt).
    • Logs in by AppRole as Identity::Provisioner, with provisioner.role-id and provisioner.secret-id read through read_mounted_credentials. They are read again at every login, so a rotated secret id is picked up.
    • Logs in again every hour. The provisioner's token lives LEASE_SECS, a day. A refused re-login is retried after 60 s, not once a pass.
  • No lapsed token (the coordinator's condition):
    • Renewal stops using a session EXPIRY_MARGIN_SECS (300 s) before its day ends. That end is reckoned from the client's login time, which is never later than the vault's.
    • If no login replaced the session by then, the pass is skipped. The process logs role_provisioner_session_expired and stops as failed, so it is restarted and logs in afresh. It never calls the vault with a stale token.
    • A compile-time assertion keeps RELOGIN_SECS < LEASE_SECS - EXPIRY_MARGIN_SECS.
  • --fixture (the coordinator's condition):
    • It runs over an in-memory journal and a FixtureVault that keeps nothing.
    • fixture_allowed(asked, cfg!(debug_assertions)) refuses it in a release build, with fixture_not_built. That mirrors the stub issuer's release pin.
    • FixtureVault, its module, MemoryControl's import and the fixture run itself are compiled only into debug builds.
  • --namespace: a flag rather than read from the ServiceAccount file, so the chart (S4c) can switch off token automount for a pod whose only egress is the vault.
  • Layers (the coordinator's condition): mandate-provisionerd is at layer 10, above mandate-deployd (8) and mandate-provisioner (9). Neither of those depends on the other, so reusing PgControl adds no cycle. The forbidden list is the same as both.

Spec clause → test

Spec clause or invariant Test name
A pass that could not finish is a heartbeat; a refused record stops the process process::a_pass_that_could_not_finish_is_a_heartbeat_and_a_refused_record_stops_the_process
The session is renewed hourly, and a refused login retried a minute later process::the_session_is_renewed_hourly_and_a_refused_login_a_minute_later
A session near its token's end is never used, however many logins were refused process::a_session_near_its_tokens_end_is_never_used
A release build refuses the fixture process::a_release_build_refuses_the_fixture
A vault directory without the CA or the credentials refuses the start, with a code and no content process::a_vault_directory_without_the_ca_or_the_credentials_refuses_the_start, binary::a_vault_directory_without_the_ca_refuses_the_start
The fixture vault makes and removes every role process::the_fixture_vault_makes_and_removes_every_role
Missing flags are refused binary::without_a_probe_socket_a_workspace_a_namespace_or_a_vault_the_process_refuses
Probes answer; SIGTERM drains; an unopened stream is reported once binary::the_process_answers_its_probes_and_drains_on_sigterm, binary::a_probe_with_no_process_behind_it_fails_and_an_unknown_probe_is_refused

Dependencies

None new. It uses workspace crates, secrecy (already registered; it holds the mounted CA as read) and tokio.

Journal events added

None. The provisioner's §9.33 records are S3's.

Not done

  • S4c, the chart: the role-provisioner process, vault-only egress, the AppRole Secret mount, and no ServiceAccount token.
  • A CI release-build check of the binary like the stub issuer's stub-release. The refusal is unit-tested and the fixture is compiled out, so a separate CI job would only re-prove the build profile. I can add it if wanted.

Decisions needed

None.

Safety checklist (safety-critical changes)

  • No floats in money or quantity paths
  • No clock reads or randomness in the core (the host clock is read only in main.rs, ES-05)
  • No unwrap, expect, or panics on trading paths
  • Ordering: inputs processed in journal order
  • Replay: same inputs give identical outputs
  • No secrets or trading content in logs or notifications (stderr lines are codes only)
  • No x-planned or (planned: ...) marker added to a value the code already serves, or a reviewer signed it off (DEC-683)

Checks

  • cargo xtask ci lint against claude/v2-provisioner-impl: green.
  • cargo xtask ci mutants against claude/v2-provisioner-impl: 30 tested, 25 caught, 5 unviable, 0 missed.
  • cargo clippy --release -p mandate-provisionerd --all-targets -- -D warnings: clean.
  • cargo nextest run -p mandate-provisionerd: 10 passed.
  • Review agent report attached

Generated by Claude Code

The provisioner over the Postgres control stream, written as mandate-deployd
writes it, and the vault, logged in by AppRole as the provisioner and again every
hour. A session near its token's end that no login replaced stops the process,
failed, so it never calls the vault with a lapsed token. --fixture runs it over
memory and a vault that keeps nothing, and a release build refuses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF

Copy link
Copy Markdown
Owner Author

Closing as included: this head is an ancestor of #2311, which landed as 0b2c139 (DEC-77).


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants