Skip to content

test(bep): T133 — Linux hosts hold the proxy's keys, end to end - #3485

Merged
norrietaylor merged 6 commits into
mainfrom
agent/3329-linux-hosts-hold-the-proxy-s-keys-end-to-end
Nov 17, 2026
Merged

norrietaylor merged 6 commits into
mainfrom
agent/3329-linux-hosts-hold-the-proxy-s-keys-end-to-end

Conversation

@minimal-foundry

@minimal-foundry minimal-foundry Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

T133 — Linux hosts hold the proxy's keys, end to end

slice: S18
kind: integration
covers: none
size: L
est: 0 code, 700 tests
executor: agent
difficulty: needs care
model: standard
diagnostics: each proof prints the TPM it ran against, and the bep output of a start it expected to refuse
observability: on a failure the proof prints the bep log lines with the store of each key, so a key generated in the wrong store or a second time shows where
layers:
- e2e:
- crates/bep/tests/linux_custody_tpm_integration.rs (new): starts bep twice against the TPM that BEP_TPM_TCTI names and checks the published fingerprints match, removes the TPM and checks the next start refuses and keeps the key files, and with no TPM and no Secret Service checks the start refuses
test (deferred: tpm): cargo nextest run -p bep --run-ignored ignored-only bep_keeps_its_tpm_keys_across_restarts
test (deferred: tpm): cargo nextest run -p bep --run-ignored ignored-only bep_without_a_tpm_or_keyring_refuses_start
- start:
- crates/bep/tests/linux_custody.rs (new): starts the bep binary on Linux with no TPM named and a secret-tool on PATH that reports no session bus, and checks it prints the no-usable-TPM-and-no-keyring refusal and exits non-zero
test: cargo nextest run -p bep bep_on_linux_with_no_store_prints_the_refusal
produces: none
consumes:
- crates/bep/src/linux_store.rs
proof: On a Linux host with a TPM, bep starts and keeps its keys in the TPM across restarts. On a desktop with no TPM it keeps them in Secret Service, and min auth status names each software key. A host with neither, or a key store it cannot read, refuses to start and says why.
depends on:
- blocked by #3323
- blocked by #3324
- blocked by #3326
- blocked by #3325
- blocked by #3327
- blocked by #3328

Proof

On this branch, a person can run the bep binary on Linux with no TPM and a secret-tool that has no session bus. bep prints the line that says the host has no usable TPM and no unlocked Secret Service keyring, exits non-zero and publishes no identity. The tpm lane test starts bep twice against a real TPM and checks the same fingerprints with store tpm. It then removes the TPM and checks that the start refuses, keeps every key file and leaves the identity as it was. The Secret Service half of the proof (keys in Secret Service, and min auth status names each software key) has no test in this task. The unit tests in linux_store.rs and the earlier T132 work cover it, not an end-to-end run.

Notes from the agent: Deferred (lane: tpm), written but not run: cargo nextest run -p bep --run-ignored ignored-only bep_keeps_its_tpm_keys_across_restarts and cargo nextest run -p bep --run-ignored ignored-only bep_without_a_tpm_or_keyring_refuses_start. I only confirmed with cargo nextest list that both are listed. They return early when BEP_TPM_TCTI is not set. The bep binary does not read BEP_TPM_TCTI. It always uses device:/dev/tpmrm0 (TpmStore::at_home). So the e2e test does not change src. It puts a wrapper for each tpm2* command first on PATH. The wrapper runs the real tool with the TCTI from a state file. For a TCTI that is not device:/dev/tpmrm* or tabrmd, it also flushes transient, loaded and session handles, because swtpm has no resource manager. A test removes the TPM when it writes device:/nonexistent/tpmrm0 to that state file. If the tpm lane does not trust a wrapper, a later task can add a TCTI override to bep. On a failure, each test prints the TPM TCTI it ran against, the full bep stderr, and the bep log lines that carry store=. cargo clippy -p bep --all-targets and cargo fmt --check are clean.

Tests

line exit tail
cargo nextest run -p bep bep_on_linux_with_no_store_prints_the_refusal 0 warning: unknown fields in task runtime-implement-test-0: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in box runtime-implement-test-0-1... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling client-config v0.0.1 (/workbench/cr

Verify

min task run agent-verify passed ([tasks.verify]).

Deferred

The plan marked these test lines deferred: the executor lacks the lane, so nothing here ran them and they still owe evidence.

line lane run at a40f081e
cargo nextest run -p bep --run-ignored ignored-only bep_keeps_its_tpm_keys_across_restarts tpm passed, 1.182s
cargo nextest run -p bep --run-ignored ignored-only bep_without_a_tpm_or_keyring_refuses_start tpm passed, 0.145s

bep_keeps_its_tpm_keys_across_restarts and bep_without_a_tpm_or_keyring_refuses_start run in the bep-tpm-integration lane through scripts/bep-tpm-integration.sh. That script sets BEP_TPM_TCTI (it starts a swtpm when the variable is unset) and runs cargo nextest run -p bep --run-ignored all -E 'binary(/_tpm_integration$/)'. Since a40f081e a test fails, and does not skip, when BEP_TPM_TCTI is set and the TPM cannot be reached. On a40f081e the lane printed TPM: swtpm:host=localhost,port=2321 and 3 tests run: 3 passed, 0 skipped (job).

Residuals

  • The Secret Service half of the T133 proof has no end-to-end test: on a Linux host with no usable TPM, bep keeps its keys in Secret Service, and min auth status names each software key. Filed as https://github.com/gominimal/inbox/issues/1269.

Closes #3329

Starts the bep binary with no tpm2-tools on PATH and a secret-tool that
reports no session bus, and checks the refusal line and the exit code.
Starts the bep binary twice against the TPM that BEP_TPM_TCTI names, and
checks that the published fingerprints match. With the TPM gone, the next
start refuses and keeps the key files. With no TPM and no keyring, the
start refuses. Both tests are ignored until the tpm lane runs them.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd036974-c6e5-400c-93e4-a1a96e226555

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@minimal-foundry

minimal-foundry Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Approved: every review thread resolved at a40f081e0d60.

@norrietaylor resolved the last thread, which releases the approval this review had withheld.

Nothing to do.

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arch-review: PASS_WITH_CONDITIONS · 1 condition · the full ruling

The tests conform to Gatehouse §6.10 line 837. They prove that bep keeps its keys in the TPM across restarts and that it refuses to start when it has no key store. The refusal strings match crates/bep/src/keys.rs, and every refusal path fails closed. The two TPM legs did not run, so the TPM half of the proof is still open. C1 closes it: run the bep-tpm-integration lane on this head and put the job URL in the Deferred table.

Ruled at 5df6927 against gominimal/arch@327e1b57d16b by claude-opus-5-5.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 2 unresolved threads — minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:220, minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:297. No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Without a resource manager, each tpm2-tools command in the proof flushes
every object in the TPM, and key_store_tpm_integration does the same from
another nextest process. On the shared CI swtpm the two removed each
other's loaded keys. When the named TPM has no resource manager and swtpm
is on PATH, the restart proof now starts an swtpm of its own.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on a failed check suite, pushed as a9c4cf4def12.

line exit tail
cargo nextest run -p bep bep_on_linux_with_no_store_prints_the_refusal 0 warning: unknown fields in task runtime-implement-test-0: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in box runtime-implement-test-0-1... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling client-config v0.0.1 (/workbench/cr

Verify min task run agent-verify passed.

Review threads the coder judged:

  • 👍 valid — crates/bep/tests/linux_custody_tpm_integration.rs:340: The tpm lane ran this leg and it passed. key_store_tpm_integration failed in the same job, because both binaries flushed one shared swtpm. This proof now runs on its own swtpm. A green job URL on the new head is still owed. This box has no TPM to produce one.
  • 👍 valid — crates/bep/tests/linux_custody_tpm_integration.rs:418: This leg passed in the tpm job too. The job failed on the shared-swtpm flush race in key_store_tpm_integration, which this round fixes. A green job URL on the new head is still owed for the Deferred table. Only the tpm lane can produce it.

On a Linux host with a TPM, the bep-tpm-integration lane starts bep twice and shows that it keeps its TPM keys across restarts. It also shows that bep refuses to start and keeps its key files when the TPM is gone. With no TPM and no Secret Service, bep refuses to start and prints why. The no-store refusal is proved on this box. The TPM proofs still need a green run of the tpm lane on this head.

Notes from the agent: Cause of the failed checks: bep-tpm-integration ran all _tpm_integration binaries at the same time against one swtpm. The test wrappers in linux_custody_tpm_integration.rs flush every transient object and session after each tpm2-tools command. TpmStore in key_store_tpm_integration does the same from another nextest process. Its in-process lock does not stop another process. So the two tests removed each other's loaded keys, and a_tpm_key_is_fixed_exempt_from_lockout_and_needs_its_authorization failed. ci-linux-native-success failed only because that job failed. Fix, inside the layers: when BEP_TPM_TCTI names a TPM with no resource manager (not device:/dev/tpmrm or tabrmd) and swtpm is on PATH, bep_keeps_its_tpm_keys_across_restarts starts its own swtpm on two free local ports, waits for tpm2_getcap to answer, and stops it on drop. A real TPM behind /dev/tpmrm0 is still used as named. It prints which TPM it ran against. Alternative fix, out of scope: a nextest test-group with max-threads = 1 for binary(/_tpm_integration$/) in .config/nextest.toml. Deferred (lane: tpm): cargo nextest run -p bep --run-ignored ignored-only bep_keeps_its_tpm_keys_across_restarts, and cargo nextest run -p bep --run-ignored ignored-only bep_without_a_tpm_or_keyring_refuses_start. This box has no swtpm and no tpm2-tools. Locally both TPM tests compile and return early with 'Skipped.'. I did not run the private-swtpm path, so the tpm lane must prove it. cargo clippy -p bep --all-targets is clean.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 2 unresolved threads — minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:340, minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:418. No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arch-review: PASS_WITH_CONDITIONS · 1 condition · the full ruling

The two new test files conform to gatehouse §6.10 line 837. They prove that bep keeps its keys in the TPM across restarts, and that it refuses to start when it has no key store. The change is test-only, in the bep crate, and pins the refusal text that keys.rs prints. The two TPM proofs are deferred, and the executor did not run them. A deferred leg is not a pass. C1 asks you to record the bep-tpm-integration CI result for this head in the PR body.

Ruled at a9c4cf4 against gominimal/arch@327e1b57d16b by claude-opus-5-5.

@norrietaylor

Copy link
Copy Markdown
Member

/revise Meet the arch review's three C1 conditions on this PR (threads at crates/bep/tests/linux_custody_tpm_integration.rs lines 220, 297 and 340). Each one asks the PR record to show that the TPM legs really ran, rather than returning early with Skipped..

Evidence at head a9c4cf4d: the bep-tpm-integration job (https://github.com/gominimal/minimal/actions/runs/43978497012/job/133688636098) prints TPM: swtpm:host=localhost,port=2321, then Starting 3 tests across 2 binaries, and all three pass:

  • bep_without_a_tpm_or_keyring_refuses_start 0.148s
  • bep_keeps_its_tpm_keys_across_restarts 1.193s
  • a_tpm_key_is_fixed_exempt_from_lockout_and_needs_its_authorization 2.370s

Summary: 3 tests run: 3 passed, 0 skipped.

The gap: nextest hides a passing test's stderr. So the log has no line in which each test names the TPM it used (for the restart proof, its own swtpm), and nothing in the log rules out an early return. Do both of these:

  1. Make the lane show that line for each TPM test. For example, have the recipe the lane runs pass --success-output immediate, and have each test eprintln! the TCTI it uses. Alternatively, make a TPM test fail instead of returning early when the lane asks for a TPM (for example, an env var the lane sets).
  2. In the PR body's Deferred table, record the bep-tpm-integration run on the new head: the run URL, the pass of each test, and the stderr line that names its TPM.

With BEP_TPM_TCTI set, a missing tpm2-tools now fails the test, so a
pass in the bep-tpm-integration lane shows the test ran. Each test also
prints the TPM it runs against.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 2 of 10 on a /revise note, pushed as a40f081e0d60.

line exit tail
cargo nextest run -p bep bep_on_linux_with_no_store_prints_the_refusal 0 warning: unknown fields in task runtime-implement-test-0: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in box runtime-implement-test-0-1... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling client-config v0.0.1 (/workbench/cr

Verify min task run agent-verify passed.

Review threads the coder judged:

  • 👍 valid — crates/bep/tests/linux_custody_tpm_integration.rs:345: With BEP_TPM_TCTI set, which the lane always sets, a TPM test now fails and does not return early. Each test prints the TPM it ran against. The run URL for the new head goes in the PR body after the lane runs. This session cannot edit the PR body.

On a Linux host with a TPM, bep starts and keeps its keys in the TPM across restarts, and a host with neither a TPM nor a keyring refuses to start and says why. The bep-tpm-integration lane sets BEP_TPM_TCTI, so with this change a TPM test there fails and does not return early, and each test prints the TPM it ran against. A pass in that lane is now a run.

Notes from the agent: Revise round 2. I took the directive's second option. With BEP_TPM_TCTI set, tpm_lane() now panics when tpm2-tools is missing, and does not print Skipped. scripts/bep-tpm-integration.sh always exports BEP_TPM_TCTI before it calls nextest, so in the lane no TPM test can pass by an early return. Each test also eprintln!s its TPM: the restart proof names the TCTI it uses after tpm_for_restarts (its own swtpm when it starts one), and the refusal proof names the lane TPM and the NO_TPM TCTI it uses. I did not add --success-output immediate. The justfile and scripts/bep-tpm-integration.sh are outside this task's layers, so the stderr lines still show only on a failure, unless someone adds that flag. Item 2 of the directive (record the bep-tpm-integration run of the new head in the PR body's Deferred table) is not mine to do. I cannot edit the PR body, and the lane has not run on the new head yet. The runner or a person must add the run URL, each test's pass, and the TPM line after CI runs. Deferred (lane tpm): bep_keeps_its_tpm_keys_across_restarts and bep_without_a_tpm_or_keyring_refuses_start. I also ran the second one locally with no BEP_TPM_TCTI. It returned early as designed (exit 0, 1 passed), so that run is not evidence for the tpm lane.

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arch-review: PASS_WITH_CONDITIONS · 1 condition · the full ruling

The TPM proofs conform to Gatehouse §6.10 line 837. The keys stay in the TPM across restarts and do not move to another store. With no usable store, bep refuses to start. The TPM lane now fails, not skips, when a TPM is asked for and the tools are missing. The Secret Service half of the T133 proof has no end-to-end test and no issue. File that issue and link it in the PR body as C1 says.

Ruled at a40f081 against gominimal/arch@327e1b57d16b by claude-opus-5-5.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 4 unresolved threads — minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:345, minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:424, minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:345, minimal-arch[bot] crates/bep/tests/linux_custody_tpm_integration.rs:1. No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@norrietaylor

Copy link
Copy Markdown
Member

/revise Meet arch ruling 1341's one remaining condition at a40f081e (C1, thread at crates/bep/tests/linux_custody_tpm_integration.rs:1). Make no code change.

The Secret Service half of T133's proof has no end-to-end test here: on a Linux host with no usable TPM, bep keeps its keys in Secret Service, and min auth status names each software key. The residual is filed as https://github.com/gominimal/inbox/issues/1269.

Add a ## Residuals heading to this PR's body, with a line that names that half of the proof and links https://github.com/gominimal/inbox/issues/1269.

While you edit the body, update its Deferred notes as well. The ruling found that scripts/bep-tpm-integration.sh runs both TPM proofs in the bep-tpm-integration lane, and since a40f081e they fail instead of skipping when BEP_TPM_TCTI is set. Say that they ran and passed in that lane, and give the run URL of the lane on the new head.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 3 of 10 on a /revise note: the coder changed nothing. This round makes no code change, as the /revise note asks. The note asks for two pull request body edits. I have no credential to edit the body, so I give the text here for the runner or a person to add.

Add to the body:

Residuals

  • The Secret Service half of the T133 proof has no end-to-end test: on a Linux host with no usable TPM, bep keeps its keys in Secret Service, and min auth status names each software key. Filed as https://github.com/gominimal/inbox/issues/1269.

Deferred notes, replace with: bep_keeps_its_tpm_keys_across_restarts and bep_without_a_tpm_or_keyring_refuses_start run in the bep-tpm-integration lane through scripts/bep-tpm-integration.sh. That script sets BEP_TPM_TCTI (it starts a swtpm when the variable is unset) and runs cargo nextest run -p bep --run-ignored all -E 'binary(/_tpm_integration$/)'. Since a40f081 a test fails, and does not skip, when BEP_TPM_TCTI is set and the TPM cannot be reached.

I cannot give the run URL of…[truncated]

@bryan-minimal bryan-minimal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the tests against keys.rs. They can fail for the right reasons: a restart that makes new keys changes the fingerprints, a key outside the TPM is caught, and losing the TPM must neither delete key files nor rewrite the published identity. The strings they look for are the real ones. They also ran: the TPM job in the Linux native lane passed both, none skipped.

Before merge:

  • The arch thread is not answered yet. It asks for an issue covering the Secret Service half of the proof, linked under ## Residuals. The body has no such section and links no issue.
  • The body is out of date: it says the TPM tests were "written but not run". They ran in the TPM job.

Two small notes, neither blocking: the tests reach the TPM through wrapper scripts, so how bep itself picks the device is not exercised; and the helper that finds two free ports releases them before the software TPM binds them, which leaves a small window for a flake.

@norrietaylor

Copy link
Copy Markdown
Member

/review

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — every review thread is resolved; @norrietaylor closed the last one. The review of a40f081e0d60 withheld this approval on the threads open then. Posted as a comment: the App cannot approve its own pull request; the check and the label carry it.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 17, 2026

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Babysitter review of a40f081e against T133's plan block and test lines. Approve.

  • start: bep_on_linux_with_no_store_prints_the_refusal runs the real bep binary with a cleared environment. PATH holds only a secret-tool that reports no session bus, and no tpm2-tools. The test asserts the exact BEP-088 refusal line, a non-zero exit, and that no identity file is published.

  • e2e: bep_keeps_its_tpm_keys_across_restarts asserts:

    • store tpm for each role, and .key plus .auth files for each role;
    • the same fingerprints and the same files on the second start, and no "chose the key store" line, so no key is generated twice;
    • with the TPM removed, a kept-key refusal that names no --replace-key, unchanged key files, and a byte-identical identity file.

    bep_without_a_tpm_or_keyring_refuses_start asserts the refusal with tpm2-tools installed and no TPM behind them. Both print the TPM they use. Since a40f081e both fail instead of skipping when BEP_TPM_TCTI is set. Both ran and passed in bep-tpm-integration on this head (run 43981178293: 3 passed, 0 skipped).

  • Round 1: gives the restart proof its own swtpm when the lane's TCTI has no resource manager. That fixes the TPM_RC_OBJECT_MEMORY (0x902) failure in key_store_tpm_integration, which the two binaries' whole-TPM flushes caused when they ran at the same time.

  • Proof: the Secret Service half is not proven end to end here. It is deferred to gominimal/inbox#1269, as arch ruling 1341 asked, and linked under ## Residuals.

Non-blocking notes:

  • free_port_pair releases both ports before swtpm binds them, so another process can take one in between. The 30 s readiness loop would then report that swtpm exited. This is a test-only race.
  • Without swtpm on PATH, tpm_for_restarts falls back to the shared TPM and says so. The arch ruling notes that CI always has swtpm.

@norrietaylor
norrietaylor added this pull request to the merge queue Nov 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 17, 2026
@norrietaylor
norrietaylor added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 1b031ef Nov 17, 2026
41 checks passed
@norrietaylor
norrietaylor deleted the agent/3329-linux-hosts-hold-the-proxy-s-keys-end-to-end branch November 17, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T133 — Linux hosts hold the proxy's keys, end to end

2 participants