Skip to content

E21-32 PRV-2a: login_kubernetes and the projected ServiceAccount token's reader, tests pending (DEC-2060) - #2019

Closed
kunwarshivam wants to merge 18 commits into
mainfrom
claude/v2-vault-prv2
Closed

kunwarshivam wants to merge 18 commits into
mainfrom
claude/v2-vault-prv2

Conversation

@kunwarshivam

@kunwarshivam kunwarshivam commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Story

E21-32, the vault (claim #1442). DEC-2060. This is the tests half of a DEC-77 pair, stacked on #2016 (PRV-1b), with main merged in. Its own commits are PRV-2a on the branch.

This is the login contract agreed with lane LV for the executor (LV-2b, #2008/#2009) and for X and D1's token-exchange Job. Stubs:

  • OpenBaoSource::login_kubernetes(config, identity, jwt: &SecretString, now)
    • Executor or token exchange only; any other identity is Config, refused before the network.
    • It posts {role, jwt} to its kind's Kubernetes mount. The role is the identity's ServiceAccount name, <hex> or x<hex>, because OpenBao folds role names to lowercase (DEC-2060 item 5, updated in this round).
    • Refused → Denied. No cluster → Unavailable.
    • The token never appears in an error or in Debug.
  • kubernetes_login_path(identity, mounts) and kubernetes_login_verdict(identity, auth)
    • The pure halves of the login, so the role and ServiceAccount checks are tested and mutated without a cluster.
    • The verdict accepts only the role named by the identity's own ServiceAccount, and that ServiceAccount. A raw-id role (c1) and a case-changed one (X6331) are refused.
  • mounted::read_service_account_token(dir), with SERVICE_ACCOUNT_TOKEN_DIR = /run/mandate/vault-token and a 16384-byte cap.
    • It follows read_mounted's rules (link containment, O_NOFOLLOW/O_NONBLOCK, inode check, bounded read) except the mode. The kubelet writes projected tokens readable by all, so only group or other write bits are refused.
    • The token must be one line.

Spec clause → test

Spec clause or invariant Test name
Only a connection's processes use Kubernetes login only_a_connections_processes_log_in_with_kubernetes_auth
No cluster is an outage, and the token never shows a_kubernetes_login_to_an_unreachable_vault_is_an_outage_that_shows_no_token
Each kind logs in on its own mount, to the role named by its SA (Ab included) each_kind_logs_in_on_its_own_mount_to_the_role_named_by_its_service_account
Only its own role and SA are accepted; a malformed answer is refused a_kubernetes_login_is_accepted_only_for_its_own_role_and_account
A projected token readable by all is read a_projected_token_readable_by_all_is_read
Group or other write bits are refused a_projected_token_others_may_write_is_refused
One line only a_projected_token_that_is_not_one_line_is_refused
16384 bytes is read; one more is refused a_projected_token_over_its_bound_is_refused
A link out of the directory, or a missing token, is refused a_projected_token_outside_its_directory_or_missing_is_refused

Dependencies

None.

Journal events added

None.

Not done

Decisions needed

None.

Safety checklist (safety-critical changes)

  • No floats in money or quantity paths
  • No clock reads or randomness in the core
  • No unwrap, expect, or panics on trading paths
  • Ordering: inputs processed in journal order (n/a)
  • Replay: same inputs give identical outputs (n/a)
  • No secrets or trading content in logs or notifications (a test pins the JWT's absence)
  • No x-planned or (planned: ...) marker added

Checks

  • fmt, clippy -D warnings, cargo xtask markers.
  • The 9 pending tests fail at Unimplemented { story: "E21-32" }; the other 115 mandate-vault tests pass.
  • Review agent report attached

🤖 Generated with Claude Code

https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF

claude added 10 commits October 19, 2026 16:54
…s policy and its role requests, tests pending (DEC-2060)

Reserves DEC-2060. Each per-connection process logs in with Kubernetes auth as
the ServiceAccount named by its connection id's hex; one templated policy per
kind reads the path from the login's own ServiceAccount name, so the dedicated
provisioner only ever creates a role bound to exactly that ServiceAccount, every
other parameter pinned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…s policy and its role requests (DEC-2060)

Implements the stubs and deletes the pending markers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…s ServiceAccount named x and the hex (DEC-2060)

A separate exchange namespace would leave its pods outside the workspace's
default deny, egress policies and admission pin. A second spike on OpenBao
2.7.1 showed a literal x before the template within one path segment works:
the executor, SA <hex>, reads connections/x<hex>/token, which the exchange, SA
x<hex>, writes; each role binds its one SA, and an even-length hex name is never
an odd-length x name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
… hex (DEC-2060)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…espace is the workspace's (DEC-2060)

So OpenBaoConfig names every mount the login and the provisioner use, from one
place, and no second layout can disagree with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
# Conflicts:
#	crates/mandate-vault/src/kubernetes.rs
#	crates/mandate-vault/src/tests/kubernetes.rs
…n's reader, tests pending (DEC-2060)

The contract agreed with lane LV: OpenBaoSource::login_kubernetes(config,
identity, jwt, now) for a connection's executor or token exchange, and
mounted::read_service_account_token(dir) with SERVICE_ACCOUNT_TOKEN_DIR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…nctions, tests pending (DEC-2060)

So the role and ServiceAccount checks are tested and mutated without a cluster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…nd the cross-contract tests, pending (DEC-2060)

kv_path and openbao_policy become fallible so kv_path can place a
connection's entries through connection_segment, a stub here. The pending
tests pin the segment, roles named by their ServiceAccount (OpenBao folds
role and policy names to lowercase), every role parameter required, a
malformed accessor refused, and a cross-contract test: each kind's policy
with its bound ServiceAccount put in is exactly the policy written from
kv_path, over ids that collide under a raw or case-folding layout. The
process-name test reads processes.json. DEC-2060 is written in full.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…d by their ServiceAccount (DEC-2060)

Merges PRV-1a's pending tests and implements them: connection_segment is
x and the id's hex, and kv_path stores every connection's code and token
under it, so the templated policies reach exactly what every writer and
reader uses. service_account_name gives the exchange that same segment.
Roles are named by the ServiceAccount, since OpenBao folds role names to
lowercase. The provisioner's policy requires all eight parameters, and
an accessor that is not one plain segment is refused. The cell's vault
drill reads the stored segments, written out by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…ceAccount, tests pending (DEC-2060)

OpenBao folds role names to lowercase, so PRV-1 names each role by its
ServiceAccount; the login's path and its verdict follow, with an Ab case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
…oyment manager makes the ServiceAccounts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5V2t72QcDywyLPViJtmFF
github-actions Bot pushed a commit that referenced this pull request Oct 21, 2026
…n's reader (DEC-2060) (#2023)

## Story

E21-32, the vault (claim #1442). This is the implementation half of the DEC-77 pair whose tests are #2019, and it is stacked on that PR. Beyond #2019 it only:
- replaces the four stubs;
- deletes the 9 `#[ignore]` lines.

Decision: DEC-2060.

- **`kubernetes_login_path`:** an executor logs in at `auth/<kubernetes_executor>/login`, an exchange at `auth/<kubernetes_exchange>/login`. The role is the identity's **ServiceAccount name** (`service_account_name`: `<hex>` or `x<hex>`), never the raw id, because OpenBao folds role names to lowercase (DEC-2060 item 5). Any other identity → `Config`.
- **`kubernetes_login_verdict`:** reads `metadata.role` and `metadata.service_account_name` from the vault's `auth`. A missing field → `Malformed`. It is accepted only when both are the identity's own SA name; otherwise `Denied`.
- **`login_kubernetes`:**
  1. seal-status check, as `log_in` does;
  2. POST `{role, jwt}`;
  3. token and lease;
  4. then the verdict. A refused verdict revokes the token it was handed, as AppRole's role check does.
- **`read_service_account_token`:** `read_mounted` and it now share one private `read_bounded`, so the link containment, non-blocking no-follow open, inode check, zeroized bounded read and UTF-8 handling are one code path. They differ only in the refused mode bits (0o077 vs 0o022) and the bound (65536 vs 16384). The token is then held to one line.

## Spec clause → test

The same table as #2019; all 9 tests now run and pass.

## Dependencies

None.

## Journal events added

None.

## Not done

PRV-2c, as listed in #2019.

## Decisions needed

None.

## Safety checklist (safety-critical changes)

- [x] No floats in money or quantity paths
- [x] No clock reads or randomness in the core
- [x] No `unwrap`, `expect`, or panics on trading paths
- [x] Ordering: inputs processed in journal order (n/a)
- [x] Replay: same inputs give identical outputs (n/a)
- [x] No secrets or trading content in logs or notifications
- [x] No `x-planned` or `(planned: ...)` marker added

## Checks

- [x] fmt and clippy `-D warnings`. mandate-vault: 124 passed, including the conformance suite against a local OpenBao 2.7.1 dev server.
- [x] `cargo xtask ci mutants` on the diff (it includes PRV-1's), with the dev server attached: **69 mutants, 58 caught, 11 unviable, 0 missed**.
- [ ] Review agent report attached

## Independent review

PASS by the coordinating session, which did not author the change. The whole `ci` run on this head is green on Linux: `mutants-plan` and **all five `mutants` shards**, `cell-vault` (the OpenBao drill), `cell`, every `schema-mutants` shard, and both aggregates. The author reports 69 mutants, 58 caught, 11 unviable, **0 missed** on the diff, and `mandate-vault` 124 tests against a local OpenBao 2.7.1 dev server. I could not run `mandate-vault` on this host — its test target imports the Linux-only `rustix::fs::mknodat` — so the green Linux run and `cell-vault` are the evidence.

**This PR is also the unblocker for #2009.** `mandate-executord` calls `OpenBaoSource::login_kubernetes`, which exists in no other open PR or on `main`; PRV-2b is what provides it, so E21-30's implementation cannot build until this lands.

Coordinator-approved-head: fc07a5f
github-actions Bot pushed a commit that referenced this pull request Oct 21, 2026
…se (DEC-2306) (#2009)

## Story

E21-30, lane LV slice LV-2b (claim #1897): the implementation half of a DEC-77 pair. Its base is the tests PR, #2008. Decision: DEC-2306 items 1 to 3.

**Stacking.** This PR merges lane V2's PRV-2a (#2019, branch `claude/v2-vault-prv2`, stacked on #2016). That PR carries the agreed `OpenBaoSource::login_kubernetes`, `mounted::read_service_account_token` and `SERVICE_ACCOUNT_TOKEN_DIR`. Until #2019 lands on main, this diff also shows V2's files, which are V2's to review. The merge order is #2016, then #2019, before this PR.

**`credential.rs`**
- **`paper_settings`:** `broker_choice`, then `broker_conflict` with `--fixture`, then the two vault flags.
- **`vault_config`:** `read_mounted(dir, "ca.crt")`, with the cell's `Mounts::default()`.
- **`vault_login`:** calls the injected ServiceAccount-token reader first (`vault_credentials_unreadable`), then the injected login as `Identity::Executor(connection)` (`vault_login_failed`).
- **`paper_broker`:**
  1. Takes the lease (`credential_unavailable` if refused).
  2. Runs `read_token`, then `paper_transport`, then `AlpacaBroker::new`.
  3. If any of those refuses after the lease is taken, revokes the lease, then returns the refusal.
- **`lease_verdict`:** maps `Held` and the tick's error as the tests say.
- **`RunLease::pass`:** ticks only while nothing has stopped the run, and keeps the first stop code.
- **`RunLease::give_back`:** revokes.
- `lease::runtime` is now `pub(crate)`.

**`main.rs`**
- **Flags:** `paper_settings` is read once, for `run` and `connect-check`. A refusal prints its code and exits 2.
- **`run` with `alpaca-paper`:**
  1. `checked_connection` reads the account stream.
  2. `vault_config` reads the CA in `--vault-dir`.
  3. `vault_login` gets `read_service_account_token(SERVICE_ACCOUNT_TOKEN_DIR)` and `OpenBaoSource::login_kubernetes`; the token is read fresh at every login.
  4. Then `paper_broker`.
  5. Only then does `ExecutorProcess::start` take the stream.
- **Each pass:** `RunLease::pass` is called. A stop code drains the process like SIGTERM, and the code is printed beside the lifecycle's own. The lease is given back when the run returns.
- **`connect-check` with `alpaca-paper`:** runs under the lease on the `--connection` it checks, and gives it back after the check is journaled.
- **Fixture path:** unchanged, through the generic `serve_on` and `checked_on`.

`paper_only`'s pin still holds: only `credential.rs` names the paper transport, and no source names a host or an HTTP client.

The only test-file change is the 8 removed pending markers.

## Spec clause → test

The eight pending tests in #2008 now run.

## Dependencies

None. `mandate-vault` is already a dependency.

## Journal events added

None.

## Not done

LV-3, and LV-4: the chart's `--broker alpaca-paper`, `--vault-address` and `--vault-dir`, plus the projected token volume, which is V2's and the deploy manager's.

## Decisions needed

None.

## Safety checklist (safety-critical changes)

- [x] No floats in money or quantity paths
- [x] No clock reads or randomness in the core (the host clock is read only in `main.rs`, ES-05)
- [x] No `unwrap`, `expect`, or panics on trading paths
- [x] Ordering: the token is read before any dial, and the lease and broker exist before the account stream is taken. A refused start takes nothing.
- [x] Replay: same inputs give identical outputs
- [x] No secrets or trading content in logs or notifications: only codes are printed
- [x] No `x-planned` or `(planned: ...)` marker added

## Checks

- [x] `mandate-executord` nextest 106/106, clippy `-D warnings`, fmt
- [x] `cargo mutants --in-diff` vs main: 23 caught, 19 unviable, 0 missed
- [ ] Review agent report: the coordinator's review

## Independent review

PASS by the coordinating session, which did not author the change. This is the implementation half of E21-30, after #2008's eight pending tests merged. I resolved its conflict with that merge by hand: kept its implementation of `credential.rs`, took #2008's test file with the eight `#[ignore]` markers removed (the DEC-77 implementation step), and verified `mandate-executord` at **106 tests, 0 skipped, all pass** — the eight that were pending now pass. The author reports `cargo mutants --in-diff`: 23 caught, 19 unviable, 0 missed. The whole `ci` run on this head is green on Linux.


## Independent review

PASS by the coordinating session, which did not author the change. This closes the E21-30 DEC-77 pair: #2008's eight pending tests merged first, and this removes the stubs and makes them pass. The whole `ci` run on this head is green on Linux, both aggregates included.

**The branch was rebuilt, not merged.** It had carried a copy of the vault stack that #2016 and #2023 landed in newer form, so merging main into it conflicted on files this change does not own. I rebuilt it as `main` plus only `crates/mandate-executord/src/` and the test file with the eight `#[ignore]` markers removed — 4 files, 177 insertions, 56 deletions — and left `tests/support/mod.rs` and `tests/outage.rs` as main's, since #2048 had since added helpers and a test there. Verified locally: `mandate-executord` **108 pass, 1 skipped**, the skip being #2048's own E21-26 pending test, which this story does not implement. The author reports `cargo mutants --in-diff`: 23 caught, 19 unviable, 0 missed.

It could not build at all before #2023 merged: it calls `OpenBaoSource::login_kubernetes`, which existed in no other branch.

Coordinator-approved-head: 155c558
@kunwar-vp kunwar-vp mentioned this pull request Oct 21, 2026
@kunwar-vp

Copy link
Copy Markdown
Collaborator

Superseded by #2023 (PRV-2b), closed rather than merged.

This is the tests half of E21-32 PRV-2. Its implementation merged as #2023 with its tests in place, and the earlier PRV-1b as #2016 — not as a DEC-77 pair, because the vault lane landed tests alongside code rather than ahead of it.

The draft is now behind main rather than ahead of it, which is how I confirmed the supersession rather than assuming it: it shows 72 more deletions than additions against main, deleting from crates/mandate-vault/src/openbao.rs and mounted.rs what #2016 and #2023 added. Merging it would regress those.

The branch claude/v2-vault-prv2 stays on the remote.

Coordinator entry: #165.

@kunwar-vp kunwar-vp closed this Oct 21, 2026
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.

3 participants