Public: anyone can read this; the crew can change it.
A hunter finding files itself: one issue per key, a comment only when its evidence changes #15279
Merged 12d 16h ago, live in production
bun scripts/hunt.ts --file now files what the hunter finds as forge issues: one issue per finding key, and a comment on that issue only when the evidence has changed. The new tests pass and bun x tsc --noEmit is clean.
-
Reviews
Changes requested — before the latest pushThe filing logic matches the forge's real list routes (author/state/cursor on issues, after/next on comments), the tests cover the issue's three behaviours, and docs/HUNT.md is updated. One thing must change before this lands.
FIRST: the issue body embeds target-controlled text (paths, Location headers, link text) from
evidenceOf(f)unescaped, before the<!-- hunt-key -->marker.KEY_REtakes the first match, so a page that serves a link or redirect containing<!-- hunt-key: other%3Akey -->can make the hunter's issue answer to a different key, which suppresses or misdirects later filing. Fix: neutralise<!--and-->in the evidence before it goes into any body (for example replace<!--with<!--), and read the key from the last marker, not the first. Add a test where a finding's evidence contains a fake marker and the real key still wins.Also, smaller: (a)
filedLineprints the constant FILE_CAP, not thecapactually used; (b) if one API call throws mid-run, the report of what was already written is lost. Catch per finding, record it as failed, and still printfiledLine, so a rerun is not surprised. No page changed, so no review steps are needed.ApprovedClean. Evidence is neutralised by quiet() and the key is read from the last marker, with a spoof test. Only the hunter account's own issues are matched. Closed issues are never reopened and the new issue names the old one. Writes are capped at 5 a run, per-finding failures are reported, and the how-to is in docs/HUNT.md, not the README. No page changed, so there is nothing to see in the preview. Not blocking: the 50-page listing bound silently stops at 5000 issues, and evidence could carry an @mention into a comment.
-
Checks
shipped production is serving it deploy 4513adb
-
History
- Hunt filing: evidence cannot spoof the key marker; one failed call fails its finding alone; the log names the cap used (#15259) d4021cd
- The hunter files its findings: one issue per key, a comment only when the evidence changes (#15259) 1f687ac
- Flaky test: 500 entries: GET /changelog answers in under 50 ms (median of 3 warm runs) (#15250) 8b57058
- Full suite red: 3 files in check run 01m7ys3y4hj03keaxqsq3vkemy (#15249) 42bd748
- Saving one repository setting never reverts another setting changed at the same time (#15245) b2d5e11
- Each flow lane shows how long its cards wait: now and typical, and the slowest lane is named (#14886) bc747ab
- The nightly release was held: tests failed on 894353657 (#15243) f59fe6d
- A board's sampler caps the rows it keeps per source and says on the board when it dropped some (#15181) e3b8d6c
- Weekly deepsec sweep as a durable forge job, bounded by security.sweep_max_usd (#15223) 14fc5fe
- A tell longer than the limit is refused at the boundary with the limit named (#15116) c407bfb
- A lapse notice says the date the grace period ends and what happens then, in one plain sentence (#15173) fc37ec0
- A fork or pull opened while a repository is being deleted is refused, and a crash never leaves the delete mark behind (#15228) b315064
- A full-suite file "red alone" on the runner says how it was run, and one red only under the runner's load is held, not handed to a builder (#15241) ffb82ff
- A stuck-flow alarm names the one action that unblocks it, as a link the owner taps (#15179) 75bba3e
- A cell child cannot steer its adoption: cell records live outside the child's directory and adoption checks pid start time and the supervisor's port (#15237) e92b8be
- A client invite link says in one plain line when it expires (#15125) 3ef9a3c
- Full suite red: 9 files in check run 01m7yfmq924q03359h4smt7t1n (#15219) 9634e62
- small: the restore drill card and the other cards that show a duration read it in words, not milliseconds (#15217) 8943536
- The search warm-up is bounded and reports how long it took, so a slow warm-up shows as a number (#15172) af62c42
- A cell child never receives the edge token or x-plat-* headers: forward and forwardSocket strip them (#15236) 4b3eb63
bun scripts/hunt.ts <origin> --file now files what the hunter finds as forge issues: one issue per finding key, and a comment on that issue only when the evidence has changed. The new tests pass and bun x tsc --noEmit is clean. I didn't run the full suite: scripts/fast.ts said the diff is too broad to name tests for (because scripts/hunt.ts changed), and no other test mentions the hunt script or docs/HUNT.md.
- How it finds its own issues (
src/hunt/file.ts): the forge's issue list has no text search. So the filer asks who the token belongs to (GET /api/v1/user), lists that account's issues in every state, and reads a hidden marker in each body:<!-- hunt-key: … -->plus<!-- hunt-evidence: <fingerprint> -->. Nothing is stored locally. Someone else's issue that happens to carry the marker is ignored. - When it comments: the fingerprint covers the repro text, the URL and the status, but not the time, bytes or milliseconds, which change on every run. A rerun with the same fingerprint writes nothing. A different one adds a comment with the new evidence and the new marker.
- Closed issues: these are never reopened. A new issue is opened that says "The same finding was filed before in #N, since closed."
- Flood cap: at most 5 writes per run, counting new issues and comments together. The rest are listed as held back, counted in a line on stderr, and filed on a later run.
- Running it:
--fileneedsFORGE_URLandFORGE_TOKEN;FORGE_REPOdefaults totrevato/forge. The JSON output and exit codes are unchanged. - Tests (
test/hunt-file.test.ts): these run against an in-memory stub forge. They file the same finding again with only the timing changed and get one issue and no writes, then change the status and get exactly one comment, then rerun and get nothing new. They also check that a closed issue is linked and not reopened, that a stranger's marker is ignored, and that 7 findings become 5 issues now and 2 on the next run. They fail withoutsrc/hunt/file.ts. - Docs:
docs/HUNT.mdno longer lists filing as not built, and describes how it works.
Left out:
- Filed issues get no labels. The labels for each kind of finding (bug, high, polish) are only added by the in-process filers. Doing it here would mean extra label-creation calls through the API.
- "Links" means naming the closed issue in the new issue's text, not a dependency link.
- There is no schedule yet; it is still one pass per run.
- I didn't keep the plan on the issue: the
keep_planandestimatetools weren't available in this run.
No page changed, so there are no review steps.
To try it: FORGE_URL=… FORGE_TOKEN=… bun scripts/hunt.ts https://lab--forge-trevato-apps.open-platform.sh --file twice. The second run should report opened 0 and comment only where evidence changed.
🤖 Generated with Claude Code
scripts/hunt.ts --file now files hunt findings through the forge API: one issue per finding key, and a comment only when the evidence fingerprint changes. An issue closed for a key is never reopened; a new issue is opened that names the old one. A run makes at most 5 writes. Findings over that cap are counted as held back and filed on the next run.
This push fixes the issues from review, in src/hunt/file.ts:
- Key spoofing: evidence comes from the target (paths,
Locationheaders, link text), so a page could plant a fake<!-- hunt-key -->marker in it. A newquiet()now turns<!--into<!--and-->into-->in the evidence before it goes into the issue body (issueBody) or a comment (changedBody). Separately,keyInnow reads the last key marker in a body, the one the filer writes after the evidence, instead of the first. This also covers bodies written before evidence was escaped. - A failed API call: each finding is now filed in its own
try. If a call throws, that finding is recorded inFiled.failedwith its error and the run carries on, sofiledLinestill reports what was already written. Listing the hunter's existing issues still stops the run if it fails, since nothing has been written at that point. - The cap in the log:
Filednow records thecapthe run actually used, andfiledLineprints that instead of theFILE_CAPconstant. It also prints failures, with each key and its error.
Two tests were added in test/hunt-file.test.ts:
- A finding whose evidence carries a fake key marker and a fake evidence marker. The body shows the markers escaped,
keyInreturns the real key, and a rerun leaves the issue unchanged. - A forge stub that fails the second of three issue creations, with a cap of 2. The first is opened, the second is recorded as failed, the third is held back, and the log line reads
opened 1,failed 1andcap 2 a run.
bun scripts/gate.ts --fix and bun x tsc --noEmit pass. scripts/fast.ts said the diff was too broad to pick tests (exit 2), so I ran test/hunt-file.test.ts and test/hunt.test.ts: 20 pass. The gate prints two "one implementation?" notes about stubForge in the test file; they were already there before this change and do not fail it. No page changed, so there are no review steps.
To try it: bun test test/hunt-file.test.ts.
🤖 Generated with Claude Code
bun scripts/hunt.ts <origin> --filenow files what the hunter finds as forge issues: one issue per finding key, and a comment on that issue only when the evidence has changed. The new tests pass andbun x tsc --noEmitis clean. I didn't run the full suite:scripts/fast.tssaid the diff is too broad to name tests for (becausescripts/hunt.tschanged), and no other test mentions the hunt script ordocs/HUNT.md.src/hunt/file.ts): the forge's issue list has no text search. So the filer asks who the token belongs to (GET /api/v1/user), lists that account's issues in every state, and reads a hidden marker in each body:<!-- hunt-key: … -->plus<!-- hunt-evidence: <fingerprint> -->. Nothing is stored locally. Someone else's issue that happens to carry the marker is ignored.--fileneedsFORGE_URLandFORGE_TOKEN;FORGE_REPOdefaults totrevato/forge. The JSON output and exit codes are unchanged.test/hunt-file.test.ts): these run against an in-memory stub forge. They file the same finding again with only the timing changed and get one issue and no writes, then change the status and get exactly one comment, then rerun and get nothing new. They also check that a closed issue is linked and not reopened, that a stranger's marker is ignored, and that 7 findings become 5 issues now and 2 on the next run. They fail withoutsrc/hunt/file.ts.docs/HUNT.mdno longer lists filing as not built, and describes how it works.Left out:
keep_planandestimatetools weren't available in this run.No page changed, so there are no
reviewsteps.To try it:
FORGE_URL=… FORGE_TOKEN=… bun scripts/hunt.ts https://lab--forge-trevato-apps.open-platform.sh --filetwice. The second run should report opened 0 and comment only where evidence changed.🤖 Generated with Claude Code
Closes #15259