Skip to content

E21-30 tests: the executor's start on Alpaca's paper host, pending (DEC-2306) - #2008

Merged
kunwar-vp merged 4 commits into
mainfrom
claude/lv-live-rows-executor-start-tests
Oct 21, 2026
Merged

kunwar-vp merged 4 commits into
mainfrom
claude/lv-live-rows-executor-start-tests

Conversation

@kunwarshivam

@kunwarshivam kunwarshivam commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Story

E21-30, lane LV slice LV-2b (claim #1897), the tests half of a DEC-77 pair. Decision: DEC-2306 items 1 to 3 (the paper broker, the vault credential, no lease no broker).

Reshaped for Kubernetes auth. The coordinator approved V2's option B (row 23): executors log in to OpenBao by Kubernetes auth, bound to their ServiceAccount. There is no mounted AppRole secret-id. vault_login therefore takes the token reader and the login as injected functions. The process passes mandate-vault's, which is being agreed with V2, and the test scripts them. Everything after the login is unchanged.

mandate-executord/src/credential.rs gains the start sequence for --broker alpaca-paper, as stubs:

  • paper_settings(flag, fixture): None for the fixture broker. For alpaca-paper, a VaultMount from --vault-address and --vault-dir (where the vault's CA is mounted). Refusals:
    • broker_unknown for any other broker value
    • broker_conflict for alpaca-paper over the in-memory journal
    • vault_address_missing and vault_dir_missing for the missing flags
  • vault_config(mount): the vault's configuration, its CA read whole from the mount's ca.crt. A refused CA file is vault_ca_unreadable.
  • vault_login(service_account_token, login, connection): reads the pod's ServiceAccount token first (vault_credentials_unreadable, with nothing dialled), then logs in as Identity::Executor(connection) with it (vault_login_failed).
  • paper_broker(vault, connection, now): the lease on the connection, the token it decodes to, and AlpacaBroker over paper_transport, with a RunLease. A lease whose secret does not decode is given back to the vault before the start is refused.
  • lease_verdict(tick):
    • Unchanged keeps the run going.
    • Rotated gives credential_rotated; the supervisor's restart takes the new lease.
    • Lost gives credential_lost.
    • A tick error gives its own code.
  • RunLease::pass(now): ticks once a pass until a verdict stops the run, then gives the same code without asking the vault again.
  • RunLease::give_back(): revokes the lease.

Also here: the secrecy row in docs/dependencies.md names mandate-executord and corrects its stale "2 crates" to 12.

Spec clause → test

Spec clause or invariant Test name
DEC-2306 item 1: the flags name the paper run and its vault; never over the in-memory journal paper_start::the_flags_name_the_paper_run_and_its_vault (pending)
The vault's CA is read whole from the mount; a group-readable or missing one is refused paper_start::the_vault_ca_is_read_from_the_mount (pending)
Kubernetes auth: the ServiceAccount token is read before any dial, and the login is as the connection's executor paper_start::the_login_reads_the_service_account_token_before_dialling (pending)
Items 2 and 3: the lease is on the checked connection, and the broker runs over its token paper_start::the_broker_runs_over_the_leased_token (pending)
Item 3: a refused lease refuses the start; an undecodable one is given back, then refuses it paper_start::a_refused_or_undecodable_lease_refuses_the_start (pending)
Item 3: only an unchanged credential keeps the run going paper_start::only_an_unchanged_credential_keeps_the_run_going (pending)
Item 3: an outage keeps the lease; its expiry stops the run once and for good paper_start::the_run_lease_stops_the_run_once_and_for_good (pending)
A stopped run gives its lease back paper_start::a_stopped_run_gives_its_lease_back (pending)

The vault and the login in these tests are scripted, the mount is a temporary directory, and the token entry is written out literally. Nothing dials a host (DEC-2306 item 5).

Dependencies

None.

Journal events added

None.

Not done

Decisions needed

None. On a rotated credential the process drains and stops rather than swapping the transport mid-run, the conservative reading of DEC-2306 item 3.

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 (the todo!() stub of RunLease::pass is the DEC-137 form)
  • Ordering: the lease is taken before the account stream; the token is read before any dial
  • Replay: same inputs give identical outputs
  • No secrets or trading content in logs or notifications: refusals are codes only
  • No x-planned or (planned: ...) marker added

Checks

  • mandate-executord clippy -D warnings, fmt, markers, layers, deps
  • All 8 pending tests fail at a stub
  • Review agent report: the coordinator's review

Independent review

PASS by a Cursor session (deepseek-ai/DeepSeek-V4.1-Flash-1017), which did not author the change. Checked out 91ee50e6 and ran:

  • cargo nextest run -p mandate-executord: 98 pass, 8 skipped.
  • --run-ignored only: 8 fail, every one on Err("unimplemented") — the stub's own report, not a fixture or parse error (DEC-110, DEC-137).
  • cargo xtask ci pending: all 57 fail at a stub, which is what the gate requires.
  • clippy -p mandate-executord --all-targets -D warnings and cargo fmt --all --check: clean.

Read against DEC-77: this is the tests half. It adds the eight stubs (each returning the crate's Unimplemented) and the eight pending tests that fail on them; the implementation PR (#2009) removes the stubs. The stub's detection shape is the one xtask recognises (is_stub_function). No test was weakened and no DELIBERATE row was added.

Coordinator-approved-head: 0323f03

…EC-2306)

LV-2b's tests half. credential.rs gains five stubs, the start sequence
in alpaca-paper:
- paper_settings: --broker, --vault-address, --vault-dir
- vault_config: the CA read from the mount
- vault_login: the mounted AppRole credentials read before any dial
- paper_broker: the lease on the checked connection and the broker over
  its token; an undecodable lease is given back
- lease_verdict: what each lease tick means for the run

Their six pending tests use a scripted vault and a temporary mount, so
nothing dials a host. The secrecy row in docs/dependencies.md names
mandate-executord and its count of crates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lp178JBQK9jnN93ufjoJM4
…EC-2306)

The coordinator approved V2's option B: executors log in with OpenBao
Kubernetes auth, bound to their ServiceAccount, with no mounted AppRole
secret-id. vault_login now takes the token reader and the login as
injected functions. It reads the pod's ServiceAccount token first and
dials only with it, as the connection's executor. Its pending test
scripts both instead of writing AppRole files. The mount holds only the
vault's CA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lp178JBQK9jnN93ufjoJM4
@kunwar-vp
kunwar-vp merged commit a6e2dcf into main Oct 21, 2026
36 checks passed
@kunwar-vp
kunwar-vp deleted the claude/lv-live-rows-executor-start-tests branch October 21, 2026 04:18
@kunwar-vp kunwar-vp mentioned this pull request Oct 21, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants