Repository navigation
fix(cli): hand over the credential file the launcher minted, or none - #1812
Merged
Merged
Conversation
writeCredentialFile now requires an explicit root. It defaulted to ~/.commonly/credentials, so a caller that forgot the root wrote a live credential into a directory no adapter cleans - measured 2026-09-20: 32 such directories on the fleet host, 24 of them from this repo's own harnesses. The token check stays first, so "no token, nothing written" still holds without a root. withholdRuntimeCredential now removes COMMONLY_TOKEN_FILE when this spawn minted no file. It only ever added one, so a launcher whose own process was spawned by a seat inherited that seat's path and passed it to the runtime and every MCP child below it. The value already followed this rule; the path is the same leak with a smaller blast radius. The claude test plants a foreign path instead of trusting the runner: the pre-fix assertion passed in CI and failed in a seat run, which is where the leak actually happens.
lilyshen0722
force-pushed
the
kai/credential-root-required
branch
from
September 20, 2026 07:48
fe4428d to
789e567
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two halves, both about credential pointers a launcher did not create.
1.
writeCredentialFilerequires an explicitroot. It used to default to~/.commonly/credentials, so any caller that forgot the root wrote a live seat credential into a directory no adapter cleans (adapters put theirs in a per-spawn directory they own and remove). Measured on the fleet host 2026-09-20: 32 such directories, 24 of them written by this repo's own harnesses — mine, from TASK-083's mutation runs. The default is gone; a missing or blank root throws. The token check stays first, so the documented "no token to write ⇒ null" contract still holds without a root, and the ordering is asserted.2.
withholdRuntimeCredentialremovesCOMMONLY_TOKEN_FILEwhen this spawn minted no file. It only ever added one. Since a runtime environment is derived fromprocess.env, a launcher whose own process was spawned inside a seat inherits that seat'sCOMMONLY_TOKEN_FILEand hands it to the runtime and every MCP child below it — a path to a credential file this spawn did not create. The value already followed the opposite rule (delete the inherited key); the path is the same leak with a smaller blast radius. This is the second half of the TASK-078/083 rule applied to the second channel.How the second half was found
Running the suite from the seat that wrote it — every agent's normal condition —
adapters.claude.credential-channel.test.mjsfailed onexpect(calls[0].env.COMMONLY_TOKEN_FILE).toBeUndefined(), and the value it saw was my seat's own credential path, inherited through the runner.mainCOMMONLY_TOKEN_FILE(a seat run)mainSo the pre-fix suite was green in CI and red in a seat: the leak it was written to prevent was invisible exactly where it happens. The test now plants a foreign path in the spawn environment (the same move Vera's
70455rationale required for the value), which turns the assertion from "the runner happened to be clean" into "a path this spawn did not mint is removed".Evidence
Full cli suite, ambient credential env present and scrubbed: 45/45 suites, 732 passed / 10 skipped, both ways.
npx eslint srcclean.Mutation ledger (each run with an ambient
COMMONLY_TOKEN_FILEset):Restored green after each (27/27 and 11/11).
Scope
cli/srcchanged ⇒ version 0.1.65 (only the version line moved). Rows: TASK-085 (the hygiene ruling, wren70709) plus the test-suite half, which the first half forced into the open. Gate: wren structure + Vera stamp, then connector-ops arms.Two things this deliberately does not do: (b) the server-side unlink-after-read is refused (it breaks an MCP respawn inside a spawn and raises no bar — wren
70710), and the real boundary — a per-spawn scoped credential — is TASK-082's design slot, wren's.