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

Fix pulls and accept-risk actions for an advisory #17221

opened this

Merged 30h 32m 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.

Notes

opened this

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.

  • Accept risk: POST /api/v1/repos/:owner/:name/dependencies/accept takes {package, version, advisory, reason}. It needs a person with write access and an rw token, never an agent. The reason must be 3 to 500 characters, and the advisory must be one the report names. An accepted advisory moves from findings to a new accepted list 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 new dep_accept table (an additive migration, pinned).
  • Fix now: POST …/dependencies/fix takes {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 into fileBump in src/security/fix_issues.ts, and both paths call it.
  • Terminal: on the Dependencies screen, a asks why and accepts the selected finding, and f files its fix. Accepted rows close the list. The how-to is in docs/features/security-osv.md.
  • Tests: test/dependencies-accept.test.ts covers the following.
    • Fix files an issue once.
    • Accept validates its input.
    • An accepted advisory leaves findings and fixes.
    • A caller without write access is refused.
    • The hourly pass skips an accepted advisory.
    • The terminal rows list accepted advisories.

Left out:

  • An MCP tool for either action.
  • A web page for either action. The forge's own /maintenance fold still lists every pin, accepted or not.
  • Withdrawing an acceptance.
  • A lockfile rewrite, as above.

Try it: on this pull's preview, call POST /api/v1/repos/<owner>/<name>/dependencies/accept with an rw token. Or open a repository in the terminal, go to Dependencies and press a or f on a finding.

None of the repository text I read asked for anything outside this task.

Closes #17143

17 earlier comments
commented

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.

  • Accept risk: POST /api/v1/repos/:owner/:name/dependencies/accept takes {package, version, advisory, reason}. It needs a person with write access and an rw token, never an agent. The reason must be 3 to 500 characters, and the advisory must be one the report names. An accepted advisory moves from findings to a new accepted list 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 new dep_accept table (an additive migration, pinned).
  • Fix now: POST …/dependencies/fix takes {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 into fileBump in src/security/fix_issues.ts, and both paths call it.
  • Terminal: on the Dependencies screen, a asks why and accepts the selected finding, and f files its fix. Accepted rows close the list. The how-to is in docs/features/security-osv.md.
  • Tests: test/dependencies-accept.test.ts covers the following.
    • Fix files an issue once.
    • Accept validates its input.
    • An accepted advisory leaves findings and fixes.
    • A caller without write access is refused.
    • The hourly pass skips an accepted advisory.
    • The terminal rows list accepted advisories.

Left out:

  • An MCP tool for either action.
  • A web page for either action. The forge's own /maintenance fold still lists every pin, accepted or not.
  • Withdrawing an acceptance.
  • A lockfile rewrite, as above.

Try it: on this pull's preview, call POST /api/v1/repos/<owner>/<name>/dependencies/accept with an rw token. Or open a repository in the terminal, go to Dependencies and press a or f on a finding.

None of the repository text I read asked for anything outside this task.

commented

I merged main into this branch and pushed it, so the pull should merge cleanly again.

The only conflict was src/generated/migrations.ts, a generated file. I took main's version and regenerated it with bun scripts/own-source.ts, so it now lists main's new migrations alongside this branch's. No source files conflicted.

bun x tsc --noEmit is clean and test/own-source.test.ts passes (3 tests). I did not run the wider tests. scripts/fast.ts named 3,728 test files (about 5 hours expected), so I stopped that run and left the full check to the forge on this push.

commented

I merged main into the branch and pushed it. The one conflict, in docs/features/security-osv.md, is resolved.

main added a paragraph on the GHSA, NVD and CVE.org feeds (#17141), and this pull added one on fix and accept-risk (#17143). Both paragraphs are kept. Both sides also had a "Terminal" paragraph, so I merged them into this pull's version: g reads again, a accepts the risk, f files the fix.

  • Type check: bun x tsc --noEmit is clean.
  • Tests: I ran four dependency and OSV test files (47 pass, 0 fail). I did not run the full suite: scripts/fast.ts found the change too broad to name tests, and the forge's check runs everything on the push.

The pull description is unchanged from before the merge.

commented

This fixes the failing check, "every column that names a user is covered by its cascade or by a row of COVERED". The new dep_accept table's by_name column held a username that no cascade or COVERED row accounted for.

  • Fix: dep_accept.by_name is now a COVERED row in src/core/account_purge.ts, marked as a username rather than an id. purgeAccount now rewrites a purged person's name on their accepted advisories to "a former member", the same way it already handles degraded_span.touched_by.
  • Test: test/account-purge.test.ts has a new test for that rewrite. It checks that the purged person's rows are renamed and that a row naming someone with a similar name (danae) is left alone.
  • Checks: test/account-purge.test.ts passes (14 tests), test/dependencies-accept.test.ts passed earlier with the first fix, and bun x tsc --noEmit is clean. bun scripts/gate.ts --explain listed every rule as ok. I ran bun scripts/gate.ts --fix and it rewrapped one comment, which is in the commit.
  • Not run: test/dependencies-accept.test.ts was not re-run after the test-only follow-up. The forge's full check on this push is the remaining run.
  • Intermediate push: the first push (6882f9d7e) had a failing new test. The test used a reserved username, owner. The follow-up commit 1c882012e switches it to hollis.

I did not change the advisory accept or fix-pull behaviour itself.

commented

I merged main into the branch and fixed the conflict, but the push is rejected, so nothing has landed. Each push (git push, git push origin HEAD) failed with "fetch first": the forge says the remote branch has commits I don't have. When I look, the branch isn't on the remote at all, so I can't fetch what it's pointing at. I tried the push three times and stopped there.

  • Conflict: src/generated/migrations.ts clashed because main added 20261201150000-dns-record.ts and this branch added 20261201190000-dep-accept.ts. That file is generated, so I took main's version and regenerated it with bun scripts/own-source.ts. It now lists both migrations in name order, with dep-accept as m454.
  • Checks: bun x tsc --noEmit is clean and test/own-source.test.ts passes. I didn't run the rest of the suite; the forge runs the full check on push.
  • Remote state: I committed the merge locally and then merged main again after it moved. The branch is 5 commits ahead of the stale remote-tracking ref, and it's the only thing on my side.

I'd guess the forge is mid-update on this branch's ref, so retrying the push later may work. If it keeps failing, a person needs to look at the forge's ref for this branch.

commented

I merged main into the branch and pushed it (1c882012e..32124acd1). Pull #17221 now merges cleanly.

  • Conflict: the only one was src/generated/migrations.ts. I took main's version and regenerated it with bun scripts/own-source.ts, so it lists main's migrations plus this branch's 20261201190000-dep-accept.ts in name order. The regenerated file has no conflict markers left.
  • Checks: bun x tsc --noEmit is clean and test/own-source.test.ts passes (3 pass, 0 fail). The test/dep-accept*.test.ts glob I passed matched no files, so the accept-risk tests were not run in this session. I did not run the rest of the suite. The forge runs the full check on this push.
  • Last time's push failure: it was not a ref problem on the forge's side. The earlier clone I worked in had gone stale, so the retries were rejected. In this clone the push went through first time.
commented

I merged main into the branch again and pushed it (32124acd1..3cc913f4c), so pull #17221 should merge cleanly. I haven't confirmed that on the forge.

  • Conflict: again only src/generated/migrations.ts, because main added another migration. I took main's version and regenerated it with bun scripts/own-source.ts. It has no conflict markers and lists this branch's 20261201190000-dep-accept.ts as m454.
  • Checks: bun x tsc --noEmit is clean. test/own-source.test.ts and test/account-purge.test.ts pass (17 pass, 0 fail). test/account-purge.test.ts auto-merged with main's changes. I did not run the rest of the suite, so the forge's check on this push is the full run.
commented

I merged main into the branch and pushed it. The two conflicts were in src/tui/screens/dependencies.ts and docs/features/security-osv.md.

  • Conflict: main had moved the "read again" key from g to keyOf("reread"), which is R. This pull had added a (accept the risk) and f (file the fix) on the same screen.
  • Resolution: I kept a and f and switched read-again to keyOf("reread"). The hint line and the key handler both use it now. The doc line says R reads again and still describes a and f.
  • Checks run: bun x tsc --noEmit printed nothing. The four test files covering dependencies and OSV pass, 47 tests (dependencies-accept, dependencies, security-osv, osv-findings).
  • Checks not completed: scripts/fast.ts named 3742 test files, an estimated 314 minutes. I ran those four instead of the named set. bun scripts/gate.ts hit the 120 s timeout and moved to the background, so I never saw its result.

The forge's own check will run the full suite on this push.

commented

I merged main into the branch and pushed it. The only conflict was in docs/features/security-osv.md.

  • Resolution: I kept this pull's "Fix and accept the risk (#17143)" paragraph. After it I took main's updated "More feeds (#17141)" paragraph, which now includes EPSS.
  • No other conflict: src/tui/screens/dependencies.ts merged without one.
  • Checks run: bun x tsc --noEmit printed nothing. The four test files covering dependencies and OSV pass, 48 tests (dependencies-accept, dependencies, security-osv, osv-findings).
  • Not run: I skipped the full suite and bun scripts/gate.ts this time. Last time scripts/fast.ts named over 3,700 test files and the gate run hit the timeout. The forge's own check will run both on this push.
commented

I merged main into the branch, resolved the two conflicts, and pushed.

  • src/security/fix_issues.ts: I kept main's exploited-advisory issues, which are filed before any bump. The bump loop still reads report.fixes, which already leaves out accepted risks. So an accepted advisory gets no exploited issue and no bump issue.
  • docs/features/security-osv.md: I kept the #17143 paragraph and main's version of the feeds paragraph, which adds the exploited-advisory text (#17144).
  • Extra fix: main now loads API routes lazily from a table in src/http/lazy_lists.ts. After the merge, POST …/dependencies/accept and …/dependencies/fix returned 404, so I added both to that table.

bun x tsc --noEmit is clean. The dependency, accept, OSV and lazy-route tests pass (54 pass, 0 fail). I did not run the full suite; the forge runs it on the push. scripts/gate.ts printed nothing on its plain run and on --fix.

commented

Still red on current main: every JSON route the router serves has an OpenAPI row or is listed as not yet described. Fix it and push.

commented

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/accept and /dependencies/fix were served by the router but missing from the OpenAPI contract, which failed openapi-covers-routes.
  • I added a route file for each under src/contract/openapi/routes/ and regenerated index.ts.
  • test/openapi-covers-routes.test.ts and the other test/openapi* suites now pass, and tsc and gate.ts --fix are 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.ts is 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, advisory and reason.
  • bun test test/dependencies-accept.test.ts test/openapi-covers-routes.test.ts

🤖 Generated with Claude Code

commented

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 --noEmit is clean.
  • test/own-source.test.ts, test/account-purge.test.ts and test/dependencies-accept.test.ts pass (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.ts names. 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 --fix was started but got stuck, so I never saw its result or --explain output. 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.

commented

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

  1. Contract: invalid is now 400 in the OpenAPI route, matching the code and the tests.
  2. Tests:
    • A signed-in user without write access gets 403 on accept and on fix.
    • An agent is refused on accept.
    • In the terminal, f as a stranger shows the refusal toast. As a writer, f toasts "filed" and then "already exists". a opens the prompt, and the accepted row appears after the reason is typed.
    • I did not add a test for the shared 429 limiter.
  3. Control characters: acceptAdvisory now 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).
  4. Shared code: mayAct (the write check), requestFix (filed, seen or refused) and a REFUSAL_CODE table (status to error code) now live in src/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.
  5. Cleanup: read0 is now fresh.
  6. Migration: it is now 20261201190200-dep-accept, with its pin and the regenerated migrations.ts.

Left as is

  • gate.ts prints two "one implementation?" hints and exits 0. mayAct resembles canSeeAnswers, and the test helper open resembles tui-pull-offer's screen. 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 a or f.
  • 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

commented

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.ts and test/account-purge.test.ts pass (26 tests).
  • Type check: bun x tsc --noEmit first failed on a missing @sqlite.org/sqlite-wasm module from a stale node_modules. After bun install it is clean.
  • Gate: bun scripts/gate.ts exits 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.

commented

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.

commented

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

commented

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 under src/ has a caller)
  • test/llms-budget.test.ts (the /llms.txt byte 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.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs