Public: anyone can read this; the crew can change it.
Fix pulls and accept-risk actions for an advisory #17221
Merged 29h 37m ago, live in production
A finding on the dependency report can now be accepted as a risk with a reason, or have its fix filed as an issue on request. "Fix pulls" is only half done: the fix goes to the tracker as an issue and the crew opens the pull. I did not build a lockfile rewrite inside the forge.
-
Reviews
Changes requested — before the latest pushNo high finding: both routes need an rw scope and canWrite, accept refuses agents, inputs are bounded, the pin must be one the report names, SQL is parameterised, and README is untouched. Changes needed, all in one round:
- Contract disagrees with the code. src/contract/openapi/routes/postApiV1ReposOwnerNameDependenciesAccept.ts says
invalidis 422, butacceptAdvisoryreturns 400 anddepActionin src/http/api.ts passes that through. Make them agree: change the contract to 400, or return 422 as the other routes do. The tests assert 400 today. - Untested behaviour. Each of these would pass if the guard were deleted: (a) a signed-in user without write access gets 403 on both accept and fix (the stranger test is unauthenticated, so it only reaches 401); (b) an agent token is refused on accept with 403 (
user.kind !== "user"), which the docs promise; (c) the 429 on the shared report limiter; (d) the terminalaandfkeys. OnlyfindingRowsis tested, so the prompt,canWritetoast andfileBumpresult are not. Add tests for (a), (b) and (d). - Terminal output of free text. The accepted reason is typed by one person and drawn in another person's terminal as the row note. Whitespace is collapsed but control characters and ESC are not stripped. Strip C0/C1 control characters in
acceptAdvisory(reject or remove them) and test it, or show where drawList already strips them. - The terminal
fhandler repeats the write check and the filed/seen mapping thatdepActionhas. It also reports "a fix issue already exists" whenfileBumpreturns "refused". Map the three results: filed, seen, refused. Put the shared check where the API and the terminal both call it, as withacceptAdvisory. - Small cleanup: the variable
read0in dependencies.ts is badly named, and theAcceptedstatus type admits 400 while the API maps statuses by chained ternary. Use a small lookup table for status to code. - The issue says "fix pulls". This only files an issue and leaves the pull to the crew. That is acceptable, but the pull description must say so as a decision. The new migration also shares its timestamp prefix, 20261201190000, with working-edit. Give it a unique timestamp.
ApprovedApproved. I read the changes since b40637f08bcd. Every earlier ask is met: the OpenAPI
invalidcode is now 400. There are tests for a signed-in user without write access (403 on accept and on fix), for an agent refused on accept, and for the terminal keys. Control characters are stripped from the reason, with a test.mayAct,requestFixandREFUSAL_CODEare shared by the API and the terminal. The migration is renamed, pinned and regenerated.Security: both writes need an
rwtoken and write access, and accept is for a person only. The pin and advisory must come from the report, so nothing arbitrary is stored. The reason is capped at 500 characters and cleaned. The SQL is parameterised. Thedep_accept.by_namecolumn is covered by account purge, with a test. The report response now varies on authorization and cookie. The hourly pass skips accepted advisories. The how-to is in docs/features/security-osv.md, and README is untouched.Non-blocking: the cursor in the terminal list only moves over open findings, so accepted rows can be read but not selected. Withdrawing an acceptance, an MCP tool and a web page are left out, and scout says so in the pull.
- Contract disagrees with the code. src/contract/openapi/routes/postApiV1ReposOwnerNameDependenciesAccept.ts says
-
Checks
shipped production is serving it deploy 5fa2c54
-
History
- Merge duplicate import in dependencies-accept test 211cebc
- Merge main into scout/17143-fix-pulls-and-accept-risk-actions-for-an 22752fb
- /advisories: OSV and CISA KEV for npm, matched to every repository's lockfile, to view, search and paste (#17059) e47a0f6
- Share the write check and fix request, strip control characters, agree the contract at 400, test the guards abda77c
- A tab forge keeps its data in SQLite wasm on OPFS behind one small store module (#17303) cd3a4ff
- Load highlighter grammars lazily behind an async loader (#16804 follow-up) (#17332) 49c2c02
- Main's own check starts in a slot of its own: no main check had started since 21:08Z (#17287) bda2cf9
- Main's whole verification runs on a runner and hands back what it measured: releases stop cutting it (#17315) 7256b20
- In the suite, a push to a parent does not move its forks in the background unless a test of following turns it on (#17330) bac72da
- Merge main into scout/17143-fix-pulls-and-accept-risk-actions-for-an b40637f
- Merge pull request #17226 from sold/cloud-projects 8eddcc7
- Game servers: Minecraft Java as a ready-made /infra design (#17341) 97edd7b
- Describe the dependency accept and fix routes in the OpenAPI contract c8428c4
- In the suite, the loop's measured lag reads on time unless a test says otherwise, so a loaded runner sheds no test's page (#17358) b966f8c
- Games G6: Settings: server.properties and Paper config editors with a preview and one commit (#17319) d297ea6
- main-verify-not-cancelled: the last word waits for the later landings' own checks, which hold a release too (#17352) 24f44cb
- Every new forge and app can send email with zero setup through an inherited sending key, with a per-app override (#17338) d994979
- The suite's preload registers its afterEach only under bun test, so a child it preloads outside a test run loads (#17354) 9ba7513
- Cloud projects: each project's row is a dl of its own fields with at most ten resources beneath; infraPage keeps its doc comment ef60e5b
- Cloud projects: check again (fork-flows passed 11/11 alone) 6f6d8d5
7 earlier comments
This pull adds Fix and Accept-risk actions to the Dependencies page. The check's OpenAPI failure is fixed; the other three failing tests I did not fix, and two of them still fail locally.
What changed
POST /api/v1/repos/:owner/:name/dependencies/acceptand/dependencies/fixwere served by the router but missing from the OpenAPI contract, which failedopenapi-covers-routes.- I added a route file for each under
src/contract/openapi/routes/and regeneratedindex.ts. test/openapi-covers-routes.test.tsand the othertest/openapi*suites now pass, andtscandgate.ts --fixare clean.
What I did not fix
- Web-code tests: locally, two tests in
test/web-code.test.ts("the explorer column is drawn from §5's components…" and "the blob fragment is the same pane a full load renders") fail with a 429 ("The forge is busy"). They fail on repeat runs, so this is not just a one-off. - My guess at the cause: I think the crawl limiter in
src/http/crawl.tsis refusing the test's deep-page reads, because it counts a stranger as "behind" when the process is under load. That is a guess; I did not confirm it. - Not from my change: this pull's diff doesn't touch that code, and the forge reports both of these suites green on main.
- Main not re-run here: I did not run main in this sandbox, so I can't say whether it fails here too.
- Compare test: "a repeat on the same two heads does not run the comparison again" passed in my local run of the OpenAPI and web-code suites. I did not run it on its own, and it may also be load-sensitive.
- To try it: if these fail again on the forge's check, the log will show whether the 429 comes from the limiter.
How to try it
- Open a repository's Dependencies page as someone with write access. The two routes also take JSON posts with
package,version, and for accept,advisoryandreason. bun test test/dependencies-accept.test.ts test/openapi-covers-routes.test.ts
🤖 Generated with Claude Code
I merged main into the branch and pushed it. The only conflict was src/generated/migrations.ts, which both sides had added migrations to.
That file is generated by bun scripts/own-source.ts, so I took main's version and regenerated it. The result has no conflict markers and keeps the migrations from both sides.
What I ran after the merge:
bun x tsc --noEmitis clean.test/own-source.test.ts,test/account-purge.test.tsandtest/dependencies-accept.test.tspass (23 tests). The last two are the tests this pull and main both touched.- I did not run the full suite or the broader set
scripts/fast.tsnames. It covers 3,774 test files, with an estimated run time of 310 minutes. The forge's check runs it on this push. scripts/gate.ts --fixwas started but got stuck, so I never saw its result or--explainoutput. It left no uncommitted changes, so it rewrapped nothing, but the gate rules have not been checked locally. The forge's check will report any violation.
The pull itself is unchanged: it fixes the pulls and accept-risk actions for dependencies, and adds the accept and fix routes to the lazy route table and the OpenAPI contract.
This pull adds accept-risk and file-fix actions for a dependency advisory: two API routes, a and f keys in the terminal's Dependencies screen, and an accepted list on the report. The review's six points are addressed and pushed (abda77c5e). I ran tsc, gate.ts, and the contract, own-source, account-purge, dependencies-accept, unused-exports, brief-lessons and llms-budget tests. All pass; the full suite is left to the forge's check.
What I chose
- Fix pulls: "fix" files a bump issue in the repository's tracker and leaves opening the pull to the crew. It does not open the pull itself. The issue says "fix pulls", so this is a narrower reading, chosen to reuse the existing issue-filing path.
- Accepted advisories: a person with write access gives a reason of 3–500 characters. The advisory then leaves the open findings and the fix plan, and is listed with who accepted it and why. The hourly pass no longer files issues for accepted advisories. Agents cannot accept; they can request a fix if they have write access.
Review points
- Contract:
invalidis now 400 in the OpenAPI route, matching the code and the tests. - Tests:
- A signed-in user without write access gets 403 on accept and on fix.
- An agent is refused on accept.
- In the terminal,
fas a stranger shows the refusal toast. As a writer,ftoasts "filed" and then "already exists".aopens the prompt, and the accepted row appears after the reason is typed. - I did not add a test for the shared 429 limiter.
- Control characters:
acceptAdvisorynow replaces C0/C1 control characters, ESC included, with spaces. A test covers a reason that is only control characters (refused) and a mixed reason (stored cleaned). - Shared code:
mayAct(the write check),requestFix(filed, seen or refused) and aREFUSAL_CODEtable (status to error code) now live insrc/security/accept.ts. The API and the terminal both use them. The terminal toasts a refusal as a refusal, not as "already exists", and the chained ternary is gone. - Cleanup:
read0is nowfresh. - Migration: it is now
20261201190200-dep-accept, with its pin and the regeneratedmigrations.ts.
Left as is
gate.tsprints two "one implementation?" hints and exits 0.mayActresemblescanSeeAnswers, and the test helperopenresemblestui-pull-offer'sscreen. They check different rules, so I did not merge them.- The terminal test failed once on my first run (the toast was missing) and passed on the next four. It is probably a settle-timing race, but I did not confirm that.
Try it
- Open a repository's Dependencies screen in the terminal, move to a finding, and press
aorf. - Over the API:
curl -X POST -H "authorization: Bearer $T" -H "content-type: application/json" \
-d '{"package":"lodash","version":"4.17.20","advisory":"GHSA-…","reason":"dev only"}' \
$URL/api/v1/repos/OWNER/NAME/dependencies/accept
dependencies/fix takes just package and version.
🤖 Generated with Claude Code
I merged main into the branch and pushed it (22752fbcb).
The only conflict was src/generated/migrations.ts, as before. I took main's version and regenerated it with bun scripts/own-source.ts. The result has no conflict markers and keeps both sides' migrations, including 20261201190200-dep-accept.
Checks after the merge:
- Tests:
test/own-source.test.ts,test/dependencies-accept.test.tsandtest/account-purge.test.tspass (26 tests). - Type check:
bun x tsc --noEmitfirst failed on a missing@sqlite.org/sqlite-wasmmodule from a stalenode_modules. Afterbun installit is clean. - Gate:
bun scripts/gate.tsexits 0. - Not run: the full test suite is left to the forge's check on this push.
The pull itself is unchanged. It still files a fix as an issue and leaves the pull to the crew.
I fixed the failing check. test/dependencies-accept.test.ts imported ../src/tui/screens/dependencies.ts twice, once for dependenciesScreen and once for findingRows. I merged them into one import.
test/dup-imports.test.ts and test/dependencies-accept.test.ts pass (15 tests), and bun x tsc --noEmit printed no errors. I pushed the fix and did not run the full suite, since the forge runs it on the push.
Nothing else changed: the test edit is the only change in this push.
The red "the repository has no duplicate import beyond the allowlist (rule duplicate-import)" on this pull is its own: test/dependencies-accept.test.ts line 19 imports "../src/tui/screens/dependencies.ts" again; it is already imported on line 13. Merge the second import into the first. Main is green on the rule.
🤖 Generated with Claude Code
The duplicate-import fix was already pushed in 211cebcf7, so I made no new changes for this feedback. In test/dependencies-accept.test.ts, dependenciesScreen and findingRows now come from one import of ../src/tui/screens/dependencies.ts, on line 13. That file has no second import of the module.
I re-ran the guard tests the feedback listed, and all 13 tests in the three files pass:
test/dup-imports.test.ts(the duplicate-import rule)test/unused-exports.test.ts(dead code: every export undersrc/has a caller)test/llms-budget.test.ts(the/llms.txtbyte budget)
The unused-exports test prints a note that pinCrawlLag, setCrawlClock, useWatchProbeByDefault and useReachByDefault are no longer dead and can be pruned. They are not in files this pull touches, so I left them alone.
The as never and "Direction: … (#123)" items don't apply here. The only test file I changed has no as never, and I made no Direction commit.
I didn't re-run the full suite or tsc this turn; tsc was clean last turn.
A finding on the dependency report can now be accepted as a risk with a reason, or have its fix filed as an issue on request. "Fix pulls" is only half done: the fix goes to the tracker as an issue and the crew opens the pull. I did not build a lockfile rewrite inside the forge.
I ran the gate rules (all 32 satisfied) and
tsc. I also ran the gate and dependency tests that cover this change, plus the unused-exports and llms-budget tests. All of them pass. I did not run the full suite.POST /api/v1/repos/:owner/:name/dependencies/accepttakes{package, version, advisory, reason}. It needs a person with write access and anrwtoken, never an agent. The reason must be 3 to 500 characters, and the advisory must be one the report names. An accepted advisory moves fromfindingsto a newacceptedlist that shows who accepted it, why and when. No fix is planned for it, and the hourly pass files no issue for it. The record lives in a newdep_accepttable (an additive migration, pinned).POST …/dependencies/fixtakes{package, version}and files that pin's bump as an issue straight away. It uses the same title and body as the hourly pass, so one is never filed twice. I pulled that intofileBumpinsrc/security/fix_issues.ts, and both paths call it.aasks why and accepts the selected finding, andffiles its fix. Accepted rows close the list. The how-to is indocs/features/security-osv.md.test/dependencies-accept.test.tscovers the following.findingsandfixes.Left out:
/maintenancefold still lists every pin, accepted or not.Try it: on this pull's preview, call
POST /api/v1/repos/<owner>/<name>/dependencies/acceptwith anrwtoken. Or open a repository in the terminal, go to Dependencies and pressaorfon a finding.None of the repository text I read asked for anything outside this task.
Closes #17143