Public: anyone can read this; the crew can change it.

A run gets exactly the secrets it declares, for exactly that run, and never in a transcript #369

Closed opened this in answer to
Closed without merging

A run now receives only the secrets its brief or issue declares, for that run alone, and a granted value is kept out of the log, events and commits. bun test is not fully green here: 10 tests fail, and I did not check them against main.

Notes

stopped closed without shipping

opened this

A run now receives only the secrets its brief or issue declares, for that run alone, and a granted value is kept out of the log, events and commits. bun test is not fully green here: 10 tests fail, and I did not check them against main. They are mirror/origin, Instagram and sign-in-throttle tests, and only the off-host redirect failure was read (unreachable instead of invalid_response, which looks like the sandbox's restricted network). The new test/run-secrets.test.ts and the crew, sandbox, secret-store and run-lease tests pass, and tsc is clean.

What changed

  • Declaring: put front-matter at the top of an agent's brief, or of an issue body whose author can write to the repo:
    ---
    secrets: [email protected], TF_BUCKET_KEY
    ---

    Only declared names are resolved (narrowest scope wins). A malformed name or host, or a name that would shadow the run's environment (FORGE_*, GIT_*, PATH, …), is refused and said in the run log. Names that exist at no scope are logged as "not set". src/crew/grant.ts does this.

  • Injection and egress: granted values go into the run's env beside FORGE_TOKEN. An @host is added to the sandbox allowlist for that run only, but only if its secret was actually granted, and it is logged by host name.
  • Redaction: values are held from the moment they are opened and redacted in plain, base64 and URL-encoded form from the run log, the agent's final message and every event payload. This is in kernel/log.ts, with hooks in runs/log.ts and core/events.ts.
  • Committed files: before the forge commits for an agent it scrubs held values out of the working tree (src/crew/leak.ts). If commits the agent already made contain a value, the branch is not pushed and the run says so.
  • Grant record: new run_secret table (migration 35) stores names and scope, never values. The grant is released in the runner's finally, so a crash is covered, and a 30-second sweep in main.ts closes any left open. The classic run page shows "Secrets held: NAMES (released)".
  • Docs: a short section in docs/APPS.md.

Tests: test/run-secrets.test.ts plants a value and shows it never reaches the log (plain or encoded) or an event. It also covers a value written into a file and into a commit, the egress widening, and the crash sweep.

Left out

  • The studio run page does not show the secret names yet.
  • A model that transforms a value beyond those three encodings, or pushes it itself in a form the commit search misses, is not caught.
  • Hosts come from the declaration, not from a per-secret host stored with the secret.

To try: set a forge secret under Settings → Secrets, assign an agent an issue whose body starts with the front-matter above, and open the run page to see the names held.

🤖 Generated with Claude Code

Closes #336

2 earlier comments
commented

I merged main into the branch and pushed it; the two conflicts are resolved and the merge result typechecks. I did not rerun the full bun test suite after the merge. I ran only test/run-secrets.test.ts, test/kernel.test.ts, test/secret-store.test.ts and test/crew.test.ts, and all 44 tests in them pass.

  • src/core/schema.ts: main also added a migration 35, the feed's interaction table. I kept that one as 35 and renumbered the run_secret table to migration 36, so it runs after it.
  • src/kernel/log.ts: I kept the error ring that main added to createLog. The log line is still redacted with redactHeld, so granted secret values stay out of it.

Everything else in the pull is unchanged: a run gets only the secrets it declares, for that run only. Granted values are redacted from the log, events and commits, and the run page shows the names held.

commented

I merged main into the branch and pushed; the only conflict was the import block in src/main.ts, and it is resolved.

  • Imports in src/main.ts: main now imports resolveDestination from ./snapshot/destination.ts in place of the old snapshot store imports (dirStore, s3FromEnv, s3Store). I kept that and dropped the old store imports, which nothing else in the file uses. I also kept my releaseOrphans import.
  • Checks run: tsc is clean, and 35 tests pass across test/run-secrets.test.ts, test/kernel.test.ts and test/crew.test.ts. I did not rerun the full suite after this merge. It had 10 failures on the earlier run (mirror/origin, Instagram and sign-in-throttle tests, plus an off-host redirect test that returned unreachable), and I didn't check those against main.

Nothing else in the pull changed: a run still gets only the secrets it declares, for that run only, with values redacted from the log, events and commits.

commented

Parked by the crew: main moved under it 2 times and the branch could not be brought up to date (src/core/schema.ts)

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs