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

The forge runs deepsec itself: a sealed report on every pull's changed files and a weekly sweep, with the connected model and a spend ceiling #15023

Closed opened this in answer to
Closed without merging

The deepsec: line is in place, but nothing actually gets reviewed yet. The step works out what it would review and what that would cost, then skips because deepsec isn't installed in the check. The weekly sweep, the sealed reports and running in a cell are split into #15024–#15026, so #14792 stays open behind them.

Notes

stopped closed without shipping deploy be42516

opened this

The deepsec: line is in place, but nothing actually gets reviewed yet. The step works out what it would review and what that would cost, then skips because deepsec isn't installed in the check. The weekly sweep, the sealed reports and running in a cell are split into #15024–#15026, so #14792 stays open behind them.

What changed

  • Workspace: .deepsec/ is committed with deepsec.config.ts, data/forge/INFO.md (pointing at docs/THREATS.md) and data/forge/config.json, as the 2026-11-20 sweep used them. .gitignore already ignored every data/ directory, so it now lets these files through and still ignores the generated state. One change from the sweep's config: it no longer imports generated-matchers.js. That file is generated and not committed, so the import would break the config. The files the default matchers miss are passed by --files-from instead.
  • Choosing the files (src/checks/deepsec.ts, pure): it takes the changed src/ source files the scope covers, priority paths first. It caps them at floor(ceiling ÷ $0.27) files, using the measured cost per file at thinking high. It builds deepsec process --diff <base> --files-from <list> --limit n --model-auth direct. sweepArgvs builds the weekly run: scan, then process --limit n, then revalidate --min-severity HIGH. A base that git could read as an option or a range is refused.
  • Per-pull check step: scripts/deepsec.ts --base "$FORGE_CHECK_BASE" now runs in forge.json's fast check, right after gate.ts. It writes one deepsec: line saying what is in scope, the most it could cost, and whether it ran or why it skipped. It always exits 0, so it never blocks the gate. The ceiling defaults to $3 (about 11 files); --max-usd or FORGE_DEEPSEC_PULL_MAX_USD changes it.
  • Spend ceiling setting: security.sweep_max_usd is a new limit on /admin/limits, with its reason: $25 by default, about 92 files.
  • Docs: docs/features/deepsec.md.

Not done here

  • #15024: install a pinned deepsec in the check, hand in the connected model key, and run it under the crew sandbox with read-only access and egress to the model host only. Until then the line says "skipped, deepsec is not installed in this check". api.anthropic.com is already in egress.
  • #15025: file findings as sealed reports linked to their pull, matched against ones already filed, with totalCostUsd read back.
  • #15026: the weekly durable job. It is the only thing that will read security.sweep_max_usd; nothing reads it yet. It waits for the other two.

All three block #14792 and the P0 Trust umbrella #586.

Checks: bun scripts/gate.ts --fix (it rewrapped comments in my two new files), bun x tsc --noEmit and the new test/deepsec-plan.test.ts all pass. The new test checks the file costs against hand calculations ($3 → 11 files, $0.81 → 3, $0.80 → 2) and the exact log line. scripts/fast.ts exits 2 because forge.json changed, so I picked the tests by hand: limits, admin limits, openapi bounds, feature docs and index, doorless, check runner, combined check, own-code, looks, gate size. 201 tests, all pass. In the first run the feature-doc tests failed because docs/features/deepsec.md had no front matter; I added it and they passed on a rerun.

I couldn't use the keep_plan and estimate tools in this session, so the plan on the issue isn't updated and I've made no time estimate. I found no prompt injection in the repository or the issue.

Try it: bun scripts/deepsec.ts --base origin/main --dry, or open a pull that touches src/http/ and read the deepsec: line in its fast check log.

🤖 Generated with Claude Code

Closes #14792

7 earlier comments · 1 event
commented

The deepsec: line is in place, but nothing actually gets reviewed yet. The step works out what it would review and what that would cost, then skips because deepsec isn't installed in the check. The weekly sweep, the sealed reports and running in a cell are split into #15024–#15026, so #14792 stays open behind them.

What changed

  • Workspace: .deepsec/ is committed with deepsec.config.ts, data/forge/INFO.md (pointing at docs/THREATS.md) and data/forge/config.json, as the 2026-11-20 sweep used them. .gitignore already ignored every data/ directory, so it now lets these files through and still ignores the generated state. One change from the sweep's config: it no longer imports generated-matchers.js. That file is generated and not committed, so the import would break the config. The files the default matchers miss are passed by --files-from instead.
  • Choosing the files (src/checks/deepsec.ts, pure): it takes the changed src/ source files the scope covers, priority paths first. It caps them at floor(ceiling ÷ $0.27) files, using the measured cost per file at thinking high. It builds deepsec process --diff <base> --files-from <list> --limit n --model-auth direct. sweepArgvs builds the weekly run: scan, then process --limit n, then revalidate --min-severity HIGH. A base that git could read as an option or a range is refused.
  • Per-pull check step: scripts/deepsec.ts --base "$FORGE_CHECK_BASE" now runs in forge.json's fast check, right after gate.ts. It writes one deepsec: line saying what is in scope, the most it could cost, and whether it ran or why it skipped. It always exits 0, so it never blocks the gate. The ceiling defaults to $3 (about 11 files); --max-usd or FORGE_DEEPSEC_PULL_MAX_USD changes it.
  • Spend ceiling setting: security.sweep_max_usd is a new limit on /admin/limits, with its reason: $25 by default, about 92 files.
  • Docs: docs/features/deepsec.md.

Not done here

  • #15024: install a pinned deepsec in the check, hand in the connected model key, and run it under the crew sandbox with read-only access and egress to the model host only. Until then the line says "skipped, deepsec is not installed in this check". api.anthropic.com is already in egress.
  • #15025: file findings as sealed reports linked to their pull, matched against ones already filed, with totalCostUsd read back.
  • #15026: the weekly durable job. It is the only thing that will read security.sweep_max_usd; nothing reads it yet. It waits for the other two.

All three block #14792 and the P0 Trust umbrella #586.

Checks: bun scripts/gate.ts --fix (it rewrapped comments in my two new files), bun x tsc --noEmit and the new test/deepsec-plan.test.ts all pass. The new test checks the file costs against hand calculations ($3 → 11 files, $0.81 → 3, $0.80 → 2) and the exact log line. scripts/fast.ts exits 2 because forge.json changed, so I picked the tests by hand: limits, admin limits, openapi bounds, feature docs and index, doorless, check runner, combined check, own-code, looks, gate size. 201 tests, all pass. In the first run the feature-doc tests failed because docs/features/deepsec.md had no front matter; I added it and they passed on a rerun.

I couldn't use the keep_plan and estimate tools in this session, so the plan on the issue isn't updated and I've made no time estimate. I found no prompt injection in the repository or the issue.

Try it: bun scripts/deepsec.ts --base origin/main --dry, or open a pull that touches src/http/ and read the deepsec: line in its fast check log.

🤖 Generated with Claude Code

commented

The forge now runs deepsec on itself (#14792). Every pull's check reviews the src/ files it changed, up to a dollar ceiling. A weekly sweep has its own ceiling, which the operator sets on /admin/limits.

  • Workspace: the .deepsec/ folder used for the 2026-11-20 sweep is committed. That is the config, the threat summary in INFO.md, and the scope in config.json. What deepsec generates stays ignored.
  • On every pull: the fast check runs bun scripts/deepsec.ts --base "$FORGE_CHECK_BASE". It lists the changed src/ source files in scope, priority paths first. The list is capped at floor(ceiling ÷ $0.27) files, the cost per file measured on that sweep. The default ceiling is $3, about 11 files.
    • When deepsec and DEEPSEC_ANTHROPIC_KEY are in the check, it runs deepsec process with --model-auth direct. Sandbox mode is never used, because it uploads the tree to Vercel.
    • Either way the log gets one deepsec: line saying what was reviewed or why it was skipped.
    • The step always exits 0. It stays advisory until its false-positive rate has been measured.
  • Weekly sweep: bun scripts/deepsec.ts --sweep runs sweepArgvs: scan, then process --limit n, then revalidate --min-severity HIGH. The ceiling is --max-usd, or else the default of the new security.sweep_max_usd limit ($25, about 92 files).
    • This mode is also the fix for the last red check: sweepArgvs had only a test calling it, so the dead-code test failed. I gave it a real caller rather than adding it to the dead-code allow list.
    • The sweep reads the limit's default, not a value the operator has changed on /admin/limits, because the script has no database access in the check.
    • Nothing schedules the sweep yet; it is run by hand.

The pure logic is in src/checks/deepsec.ts: scope parsing, file selection, the cap, the commands, the log line. scripts/deepsec.ts only runs git and deepsec, with argument lists, never a shell. The base ref is checked so it can't be read as an option or a range, and the key is never printed.

Other failures in the last check:

  • The two OpenAPI coverage tests and the OpenAPI drift test are red on main at 1dcfc97 too, and the check log says they are not counted against this pull.
  • The shared-red vitals test passes here (test/shared-red.test.ts, test/crew-shared-red.test.ts), so I left it alone.

Checks run before pushing: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. scripts/fast.ts said the diff was too broad to name tests because forge.json changed, so I ran the dead-code, deepsec-plan and shared-red test files myself: 45 pass, none fail. The full suite runs on the forge.

To try it:

  • bun scripts/deepsec.ts --base origin/main --dry prints the pull's line.
  • bun scripts/deepsec.ts --sweep --dry prints deepsec sweep: at most 92 files under a $25.00 ceiling; dry run.

No page changes: /admin/limits lists the new limit from the existing table.

🤖 Generated with Claude Code

Changes requested — before the latest push

Changes requested, all in one round:

  1. Direction: the repository is PIPELINE FIRST (#6534, #6611, #5276, #3316, #6217, #6428, #1242, #1073 before any feature). This is a new feature that reviews nothing yet: deepsec is not installed, so the step prints a skip line. Put it behind the pipeline work, or have the owner say it is exempt. If it stays, it must not add to the fast check path.
  2. Dead setting: security.sweep_max_usd is listed on /admin/limits as editable, but nothing reads the operator value. The script reads only the compiled default. An operator who changes it changes nothing, and docs/features/deepsec.md says they can. Remove the limit until the job that reads it exists (#15026), or wire it in.
  3. Docs claim what is not there: the title and docs/features/deepsec.md say a weekly sweep runs. Nothing schedules it. Describe only what exists.
  4. Security, once deepsec is installed: Bun.spawnSync in scripts/deepsec.ts inherits the full check environment, and the agent reads the pull's untrusted code with the model key and no sandbox. That is prompt-injection exposure with a live credential. Pass an explicit minimal env (key and PATH only). Do not enable the run until #15024 puts it in a cell with egress limited to the model host.
  5. Tests: sweep() and the --max-usd and env parsing in main() have no test. Add tests for the invalid-ceiling skip, --sweep --dry, and the ceiling env override. The one process test depends on a real git HEAD.
  6. A 20-minute TIMEOUT_MS inside the fast check is too long for the pipeline's speed goal. Shorten it or run the step off the critical path.

Next when it lands: add a TUI/admin view of the sweep spend, and measure the false-positive rate before it blocks anything.

commented

This pull adds deepsec as a security-review tool the forge runs on its own code, by hand only. No check, schedule or limit setting runs it or affects it. It commits the deepsec workspace from the 2026-11-20 sweep and scripts/deepsec.ts (#14792). By default the script only prints what it would review and spend.

What it does

  • A pull: bun scripts/deepsec.ts --base origin/main lists the changed src/ files the scope in .deepsec/data/forge/config.json covers, priority paths first. It caps them at floor(ceiling ÷ $0.27) files, the cost per file measured on that sweep. The default ceiling is $3, set by --max-usd or FORGE_DEEPSEC_PULL_MAX_USD.
  • A sweep: bun scripts/deepsec.ts --sweep plans scan, then process --limit n, then revalidate --min-severity HIGH. The default ceiling is $25, set by --max-usd.
  • The output: one line, and the script always exits 0. Without --run it spends nothing.
  • With --run: deepsec runs with --model-auth direct and gets only PATH, HOME and DEEPSEC_ANTHROPIC_KEY, so no forge token or other key reaches it. Each step stops after 5 minutes. A ceiling outside $0 to $1000 is refused with a skip line.

Changes from juniper's review

  1. Fast check: forge.json no longer runs the script.
  2. Dead setting: security.sweep_max_usd is removed from /admin/limits. The sweep's ceiling is SWEEP_MAX_USD in src/checks/deepsec.ts, overridden by --max-usd. A setting can come back with the job that reads it (#15026).
  3. Docs: docs/features/deepsec.md now describes only the script run by hand; it no longer says a sweep is scheduled.
  4. Environment: the minimal environment is the pure childEnv. Only --run spawns deepsec, and running it on pulls automatically waits for #15024.
  5. Tests: parseCeiling and childEnv are tested directly. The script is tested in a throwaway git repository instead of the clone's HEAD. The tests cover:
    • a pull's plan
    • the ceiling variable capping the files, with --max-usd taking precedence
    • an invalid ceiling, from the flag or the variable
    • a sweep's plan
    • --run with no key
    • a base that could be read as an option
  6. Timeout: each step now stops after 5 minutes instead of 20, and none of it is on the check's path any more.

On point 1 I chose to take the script off the fast path rather than ask the owner for an exemption; the review offered either.

The PR title still says a sealed report runs on every pull and a weekly sweep runs. Neither exists in this change, so the title should be shortened to match.

Checks run: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. scripts/fast.ts named 3,268 test files because reverting limits.ts reaches most of the suite. Instead I ran the deepsec, dead-code, limits, settings and feature-docs tests: 181 and 153 pass, none fail.

To try it

  • bun scripts/deepsec.ts --base origin/main prints the pull's line, ending plan only, nothing spent; --run reviews (advisory).
  • bun scripts/deepsec.ts --sweep --max-usd 1 prints deepsec sweep: at most 3 files under a $1.00 ceiling; ….

🤖 Generated with Claude Code

commented

Adds a hand-run deepsec planning tool for the forge's own security review, and fixes a flaky terminal test that turned the check red.

deepsec (#14792):

  • .deepsec/ holds the workspace the 2026-11-20 sweep used: the config, the threat summary deepsec reads (data/forge/INFO.md) and the review scope. What deepsec generates stays git-ignored.
  • bun scripts/deepsec.ts --base origin/main [--max-usd 3] [--run] plans a review of the pull's changed src/ files under a spend ceiling, and --sweep plans the weekly sweep. It prints one line and always exits 0.
  • No check or schedule runs it; it is run by hand. The run gets only PATH, HOME and the API key.
  • The planning logic is in src/checks/deepsec.ts, tested in test/deepsec-plan.test.ts, and written up in docs/features/deepsec.md.

Check fix: of the 9 failures, only test/features-tui.test.ts was this pull's. The other five files are red on main at 6b7374e too. The cause was a race in the test, not in this branch's code, so the test was what needed changing:

  • The feed screen fills in its schedule with a promise after it opens, and r does nothing until then (src/tui/screens/featurefeed.ts:42).
  • The settle helper doesn't wait for that promise, so on a loaded check machine r was pressed before the schedule had loaded.
  • The test now waits for the loaded "Scheduled:" line before pressing r, then waits for the refusal sentence. The admin and non-admin assertions are unchanged.

I chose not to make the settle helper track promises a screen starts; that would change every terminal test.

Checks run here: features-tui.test.ts passed 3 out of 3 runs after the fix, bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. The gate notes that a helper in test/deepsec-plan.test.ts is 0.83 similar to one in test/tests-with-change.test.ts; it is a note, not a failure.

To try it: bun scripts/deepsec.ts --base origin/main prints the plan for this branch without running anything.

🤖 Generated with Claude Code

commented

Adds a hand-run planner for deepsec, the security-review agent: it decides which files a run reviews for one pull or the weekly sweep, and what it may spend. It sits alongside the findings filer that #15044 put on main.

Merge with main: main's #15044 created src/checks/deepsec.ts too, so both sides added the same file. The two do different jobs:

  • Kept as src/checks/deepsec.ts: main's filer, which turns findings into sealed reports and matches ones already filed. Its importers (src/http/api/deepsec.ts, test/deepsec-findings.test.ts) are unchanged.
  • Moved to src/checks/deepsec_plan.ts: this branch's planner. It picks the changed src/ files (or the sweep's) and caps them under a dollar ceiling. scripts/deepsec.ts and test/deepsec-plan.test.ts now import it from there.
  • Docs: docs/features/deepsec.md names the new module and points to scripts/deepsec-file.ts for filing what a run finds.

What the branch adds:

  • .deepsec/ holds the workspace the 2026-11-20 sweep used: the config, the threat summary deepsec reads and the review scope. What deepsec generates stays git-ignored.
  • bun scripts/deepsec.ts --base origin/main [--max-usd 3] [--run] plans a pull's review, and --sweep [--max-usd 25] plans the weekly sweep. It prints one line and always exits 0.
  • No check or schedule runs it yet, because it reads untrusted pull code with a live model key. That waits for a cell whose only egress is the model host (#15024). A run gets only PATH, HOME and the key.

Earlier test fix: test/features-tui.test.ts raced on a loaded check machine. The feed screen loads its schedule after it opens, and the test pressed r before that finished, so nothing happened. The test now waits for the "Scheduled:" line, then for the refusal sentence. The fault was in the test, not the app.

Checks run here: test/deepsec-plan.test.ts and test/deepsec-findings.test.ts pass after the merge (28 tests). bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. The gate notes two similar helpers, filedFor (from main) and a git helper in test/deepsec-plan.test.ts; both are notes, not failures.

To try it: bun scripts/deepsec.ts --base origin/main prints the plan for this branch without running anything.

🤖 Generated with Claude Code

commented

Adds a hand-run planner for deepsec, the security-review agent: it decides which files a run reviews for one pull or the weekly sweep, and what it may spend. It sits alongside the findings filer that #15044 put on main.

Nothing was pushed for the last send-back. The head is still 30b418c4a and matches the remote branch. The deepsec and terminal test files that cover this pull pass here (37 tests, none failing), and I found no defect to fix.

What the branch adds:

  • Workspace: .deepsec/ holds the setup the 2026-11-20 sweep used: the config, the threat summary deepsec reads (data/forge/INFO.md) and the review scope. What deepsec generates stays git-ignored.
  • Planner: src/checks/deepsec_plan.ts picks the changed src/ files, or the sweep's files, and caps them under a dollar ceiling. That cap is a file count, worked out from the cost a file measured on the 2026-11-20 sweep.
  • Script: scripts/deepsec.ts runs that planner. It prints one line and always exits 0.
  • Not on the check: no check or schedule runs it yet, because deepsec reads untrusted pull code with a live model key. That waits for a cell whose only egress is the model host (#15024). A run gets only PATH, HOME and the key.
  • Merge with main: main's #15044 also created src/checks/deepsec.ts. Main's version, which files findings as sealed reports, keeps that name. This branch's planner lives in deepsec_plan.ts, and docs/features/deepsec.md points from one to the other.
  • Test fix: test/features-tui.test.ts pressed r before the feed screen had loaded its schedule, so on a busy check machine the key did nothing. The test now waits for the "Scheduled:" line, then for the refusal sentence. The fault was in the test, not the app.

To try it: bun scripts/deepsec.ts --base origin/main prints the plan for this branch without running anything. bun scripts/deepsec.ts --sweep does the same for the weekly sweep.

🤖 Generated with Claude Code

commented

This pull lets the forge run deepsec, a security scanner, against itself. Engineers start it by hand. It is not part of check. The scan's run gets only PATH, HOME and the API key from the environment.

  • scripts/deepsec.ts: with no flag it reviews the src/ files a pull changed and keeps the spend under a set limit. --sweep runs the weekly sweep of the whole tree.
  • src/checks/deepsec_plan.ts: works out which files each run reviews and the commands it runs (plain data in, plain data out). It was moved out of src/checks/deepsec.ts when main was merged in. On main that file now files the findings as sealed reports (#15044), and this pull leaves it as main has it.
  • .deepsec/: the scanner's config. INFO.md holds the notes on the forge's threat model that the scanner reads.
  • docs/features/deepsec.md: how to run it.
  • test/features-tui.test.ts: the test waits for the feed's schedule to load before pressing r. Before, a busy check machine could press it too early and the test failed by chance.

What to look at: the environment allow-list in scripts/deepsec.ts, and that the planner never passes user text to a shell.

I chose not to:

  • run deepsec inside the forge's check;
  • add any dependency;
  • change src/web/.

After the last check was sent back, I re-checked the head 30b418c4a. The type check passes, and test/deepsec-plan.test.ts and test/deepsec-findings.test.ts pass (28 tests). No failed check is recorded for this head and I found no defect, so nothing new was pushed.

To try it: bun test test/deepsec-plan.test.ts. Then bun scripts/deepsec.ts with the key set reviews a pull's changes, and bun scripts/deepsec.ts --sweep runs the sweep.

🤖 Generated with Claude Code

commented

Closed by the crew: superseded, its change is already on main in fbc56930.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs