Skip to content

feat(cipher): cipher-token-provision — mint and bind a per-agent token, never printed - #3540

Open
POWERFULMOVES wants to merge 1 commit into
mainfrom
feat/cipher-token-provision-2026-11-28
Open

POWERFULMOVES wants to merge 1 commit into
mainfrom
feat/cipher-token-provision-2026-11-28

Conversation

@POWERFULMOVES

Copy link
Copy Markdown
Owner

Why

The launchers bind CIPHER_TOKEN_<AGENT> from pmoves/.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 leak mint_cipher_token.py --emit warns about. .env*.local is zero-access to agents with no Known Road, and nothing in secrets-funnel carries CIPHER_TOKEN_*. Each node's per-agent identity therefore stayed on bootstrap. Measured on the 4090: cipher-identity reports cipher mode bootstrap.

What

make -C pmoves cipher-token-provision AGENT=<card id> [REPLACE=1], run by the operator once per identity:

  • with-env.sh loads the service key into the child process only.
  • scripts/cipher_token_provision.py runs the real minter in process, so its card gate, scopes and insert are the ones that run. The mint uses --emit fd into an os.pipe, then upserts one line of .env.local.
  • The token never reaches stdout, stderr, argv or a temp path. stdout carries names only.
  • It touches exactly one line. CRLF is preserved (a test caught read_text() folding CRLF to LF), the replace is atomic, and a new file is created 0600.
  • An existing key is refused unless REPLACE=1, because a second mint would leave two live rows. With REPLACE=1 it prints that the old row stays valid until cipher-revoke-token.
  • Registry spellings (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 fd contract, so no Supabase is involved and no real credential is held. ruff check is clean.
  • Neighbouring ratchets (cipher / secrets / make): 194 passed, 7 failed. All 7 are in test_cipher_service_key_check.py and fail identically with this change stashed, so they are pre-existing on the Windows 4090 node.
  • Not run live: no mint was performed. Supabase on the 4090 currently refuses its own service key (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-CLAUDE feat/cipher-token-provision-2026-11-28, 48h, included in this branch.

🤖 Generated with Claude Code

…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>
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1

  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

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

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized keys: "branches", "excluded_branches" at "reviews"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T15:37:41.347600Z d446a62 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added docs Documentation governance AGNOTE register / agent definitions / damage-control hooks labels Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment on lines +94 to +98
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +141 to +144
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation governance AGNOTE register / agent definitions / damage-control hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant