Repository navigation
feat(cipher): cipher-token-provision — mint and bind a per-agent token, never printed - #3540
POWERFULMOVES wants to merge 1 commit into
Conversation
…n, never printed The launchers read CIPHER_TOKEN_<AGENT> from pmoves/.env.local (#3143, #3449); getting it there was left out of band, i.e. a human copying a bearer through a terminal. The new target runs the real card-gated minter in-process with --emit fd into an os.pipe and upserts exactly one line of .env.local (CRLF kept, atomic replace, 0600). Refuses an existing key unless REPLACE=1, and then says the old row is live until revoked. Includes the register CLAIM row for this lane. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ORGSIM-MIRROR drift check (advisory, fail-soft)vv3 / 8 files / VERIFIED 124 / DRIFTED 10 / UNDECIDED 29 / digest 659887324f50 Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d446a62975
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tmp = path.with_name(f".{path.name}.provision.tmp") | ||
| fd = os.open(str(tmp), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600) | ||
| try: | ||
| with os.fdopen(fd, "w", encoding="utf-8", newline="") as fh: | ||
| fh.write("".join(lines)) |
There was a problem hiding this comment.
Keep the temporary credential under the zero-access glob
During every successful provision, this writes the bearer to the predictable path pmoves/..env.local.provision.tmp; because its basename begins with two dots, it does not match the damage-control patterns .env.* or .env*.local. A concurrent agent running under the operator's OS account can therefore poll/read this unprotected path while it contains the token, despite .env.local itself being zero-access. Use a unique temporary name such as .env.local.tmp-* that remains covered by the zero-access patterns.
AGENTS.md reference: AGENTS.md:L38-L38
Useful? React with 👍 / 👎.
| if not AGENT_RE.match(args.agent): | ||
| print(f"error: agent id {args.agent!r} is not a card spelling " | ||
| "(lowercase, digits, '-'): pass the signing-card agent_id", file=sys.stderr) | ||
| return 2 |
There was a problem hiding this comment.
Accept every valid signing-card identifier
When provisioning the active coder_claw card declared in pmoves/config/signing_identity_cards.yaml, this regex rejects the identifier before the real minter can apply its card gate. The target advertises AGENT=<card id>, so this valid identity can never receive a token and remains on bootstrap authentication; validate against the card roster or permit the underscore already used by card identifiers.
Useful? React with 👍 / 👎.
| f"({len(token)} chars); {env_file} was not touched", file=sys.stderr) | ||
| return 1 | ||
|
|
||
| action = upsert(env_file, key, token) |
There was a problem hiding this comment.
Revoke a minted token when the local bind fails
If .env.local cannot be created or replaced—for example because of permissions, a full filesystem, or an os.replace failure—the Supabase insert has already succeeded, but this uncaught upsert exception leaves a live credential with no local binding. Because has_key remains false, retrying provisions another live token, defeating the duplicate-token protection; catch binding failures and revoke the newly minted UUID before returning an error.
Useful? React with 👍 / 👎.
Why
The launchers bind
CIPHER_TOKEN_<AGENT>frompmoves/.env.local(#3143, #3449). Getting the value into that file was left "out of band", so a human had to copy a bearer through a terminal. That is the transcript leakmint_cipher_token.py --emitwarns about..env*.localis zero-access to agents with no Known Road, and nothing in secrets-funnel carriesCIPHER_TOKEN_*. Each node's per-agent identity therefore stayed onbootstrap. Measured on the 4090:cipher-identityreportscipher mode bootstrap.What
make -C pmoves cipher-token-provision AGENT=<card id> [REPLACE=1], run by the operator once per identity:with-env.shloads the service key into the child process only.scripts/cipher_token_provision.pyruns the real minter in process, so its card gate, scopes and insert are the ones that run. The mint uses--emit fdinto anos.pipe, then upserts one line of.env.local.read_text()folding CRLF to LF), the replace is atomic, and a new file is created 0600.REPLACE=1, because a second mint would leave two live rows. WithREPLACE=1it prints that the old row stays valid untilcipher-revoke-token.claude_4090) are refused before minting.Tests
pmoves/tests/tools/test_cipher_token_provision.py: 9 passed, 1 skipped (the POSIX 0600 test skips on Windows). A fake minter speaks the real--emit fdcontract, so no Supabase is involved and no real credential is held.ruff checkis clean.test_cipher_service_key_check.pyand fail identically with this change stashed, so they are pre-existing on the Windows 4090 node.cipher-auth-check PROBE=1: expired, Kong stale). The first real run waits on that repair, which needs a fresh 4090 CHIT bundle.Register: CLAIM
4090-CLAUDEfeat/cipher-token-provision-2026-11-28, 48h, included in this branch.🤖 Generated with Claude Code