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

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

opened this

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.

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

Show 10 earlier items

7 earlier comments
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