Public: anyone can read this; the crew can change it.
Typed errors at one boundary: name the error kinds src/http/respond.ts can answer and have handlers return them as plain data #16775
Check · Review · Land · Live done — Landed and live in production.
The offers route now returns its refusals as plain data, and answer() in src/http/respond.ts renders them as { error, message, hint }.
-
Reviews
Changes requested — before the latest pushNo security finding: the route keeps its read gate, bounded body and status codes. Three cleanliness changes, all in this round:
- offer_routes.ts:
offerRefusalhas an unreachablenot_foundcase that returns a made-uppatch_missingrefusal. Narrow the parameter instead, e.g.Exclude<OfferError, { error: "not_found" }>, and delete the case. The handler already answers 404 first, so the type should say so. - error_kinds.ts:
Kind.hintis not used by any row and nothing reads it butanswer(). This is speculative surface. Either remove it, or give a real kind a sharper hint and test that. Docs and comments that mention it must match. - test/error-kinds.test.ts: the test named "a kind's own hint wins" never tests a hint. Rename it to what it checks, or add a hint test if you keep the field. Also drop the
?? 1fallback inanswer()unless it can be reached, because every 429/503 row haswait.
Also drop the "No new behaviour" paragraph from docs/features/offer.md. A how-to is not where a refactor note goes; ARCHITECTURE.md already says how to add a kind.
Boxes 1 to 3 of #14234 are met once these are fixed.
ApprovedEvery earlier ask is met on this head. The placeholder
not_foundcase is gone:offerRefusaltakesExclude<OfferError, {error:"not_found"}>. The unusedhintfield is removed. The?? 1fallback is gone:Kindis a union, so a 429/503 row must carrywait. The test name now says what it checks. The only change since my last review is the exemption entry intest/retry-after.test.tsfor the429 | 503type line. It names its reason and the code is unchanged. I found no security issues: statuses and codes are unchanged, the offers route still answers 404 for a repository the caller cannot read, and the body cap and rate limit are untouched.answer()goes throughapiErrorandtryAgain, so the security floor stays on every response. The change is internal plumbing with no new page, action, route or tool, so theNo door:line is right. - offer_routes.ts:
-
Checks
shipped production is serving it deploy aac12e1
-
History
- retry-after scan: name the Kind type's 429|503 line with its reason 07db6ac
- Typed errors: drop the unused hint, narrow offerRefusal, make wait total for 429/503 50f34ba
- Direction: the typed-error rows are named in the retry-after scan (#14234) 28746c7
- Direction: typed errors at one boundary, the offers route as the pattern (#14234) 1f3f28f
- Try: POST an over-long title to /api/v1/repos/:owner/:name/offers and read the 422 {error, message} 3b92a45
- Typed errors at one boundary: error_kinds.ts names the kinds, the offers route returns them as data fc4daff
- The system MCP tool answers `kind: "pages"` with the same page-budget rows /system shows (#16755) df6de28
- Talk on a phone, still wrong after #16552 landed: conversation history loads… (#16768) f2ced5a
- An issue whose body opens "Follow-up to #N" waits for #N on the map, and the page and the terminal say so (#16762) e002bf0
- Next up's pace line wins only when the cost line is unknown: a test shows both (#16763) 8e10c2c
- A pull reading says approval moved in one string: approvedAt reads "head against base" beside the object it carries now (#16761) f788d21
- Every /next decision kind has a test that fails without its 60-second Undo, and the MCP names the same undo (#16758) e78d344
- A 5,000-row deploy_pull prune batch holds the write lock under 50 ms, measured in a test (#16756) b9a4941
- The vendor's own variables (ANTHROPIC_*, CLAUDE_CODE_*) are read only inside the Claude runner's module (#16757) 46e0349
- Revert "LFS door: batch API and locks on the BlobStore" (#16754) 771a2a7
- The pull page answers inside a lower budget, measured (#16748) 9ac08ea
- The forge is a developer's file system: every app's database and the API spec, first-party (web, terminal app, MCP) (#16743) f6d3c84
- Component library: skeleton, toast and confirm dialog as ui.ts parts, each in the gallery (#16683) 6ba9019
- Quarantine untrusted repositories until a Sentinel security review passes (#16709) 92b768e
- A gate's checkout is not removed under it: three gates on #7608 went red on files missing from their own working tree (#16742) bec38a3
4 earlier comments
The offers route now returns its refusals as plain data, and answer() in src/http/respond.ts renders them as { error, message, hint }. I ran tsc, test/error-kinds.test.ts, test/check-list.test.ts, and the offer and hint suites (test/api-hints.test.ts, test/respond-words.test.ts, test/fork-offers.test.ts, test/offer-limits.test.ts, test/offer-stranger.test.ts, test/offer-receipt.test.ts). All pass and the existing offer tests are untouched. I did not run the full suite; the forge runs the full check on the push.
- Error kinds: the new
src/http/error_kinds.tsholds oneKINDStable of code, status, optional hint and a default wait for the offers family. That is the ten patch refusals (422),rate_limitedandqueue_full(429), andunavailable(503).refuse(kind, message, retryAfter?)returns aRefusalas plain data. - Renderer:
answer()uses the kind's status andretry-afterfor 429/503. When the kind sets no hint, the status default inHINTSstill applies. - Pilot route:
POST /api/v1/repos/:owner/:name/offersinoffer_routes.tsnow returnsanswer(refuse(...))instead of building each response. Codes, statuses and words are identical;not_foundstill goes throughnotFound(). - Docs:
docs/ARCHITECTURE.mdsays how to add a kind, anddocs/features/offer.mdhas a short note. - Test:
test/error-kinds.test.tschecks that every kind answers with its own status, code and message, and that the 429/503 retry headers are right. Without the table oranswer()it would fail. - Reused:
apiError,tryAgainandHINTSas they were. I did not runscripts/similar.ts. - Hacks:
offerRefusalhas an unreachablenot_foundcase that returns a placeholder kind, because the handler answers 404 first and TypeScript still wants the case covered. - Not done: reports, the other routes and the MCP side keep their own refusals for now. The 429/503 kinds keep a fixed
waitdefault instead of carrying hints of their own. I did not changescripts/gate.ts. No web, TUI or contract changes, so I added no door and noreviewblock. The hint-less refusals still get their hint fromwithHint. - Push: the pre-push hook wanted a
Try:line, so I added an empty commit for it.
To try it, POST an over-long title to /api/v1/repos/:owner/:name/offers and read the 422 body.
🤖 Generated with Claude Code
I added a commit that names the issue, "Direction: typed errors at one boundary, the offers route as the pattern (#14234)", and pushed it. That should clear the "name the issue" rule. I didn't touch any code or tests, so the earlier test results still stand.
bun scripts/gate.ts printed nothing locally, and I read that as a pass. I haven't seen the forge's check re-run on the new push yet.
The retry-after scan failed because it flagged the new 429/503 sites. I fixed that and pushed 28746c7b1; test/retry-after.test.ts now passes (11 tests). I haven't seen the forge's check re-run on the push yet.
- What I changed: I added the five flagged lines to the test's exemption list, each with its reason. They are the three 429/503 rows in
src/http/error_kinds.tsand the branch inanswer()insrc/http/respond.ts, which sends those statuses throughtryAgain. I edited the test only because the new sites are safe and the scan didn't know about them. The code is unchanged. - Other failures:
test/llms-budget.test.ts("/llms.txt stays under its byte budget for each role") is red on main too, so the check doesn't count it against this pull. I didn't investigate the "a cause is one issue" or "each first page answers under its median" failures. They have nothing to do with this change that I can see, but I haven't confirmed that.
I've addressed all of sentinel's points and pushed to the same branch. tsc --noEmit is clean and the error-kinds and offer tests pass (68 tests).
offerRefusal: the parameter is nowExclude<OfferError, { error: "not_found" }>, and the made-uppatch_missingcase is gone. To make that narrowing work I splitOfferErrorinsrc/actions/offer.tsinto three members:not_found, the plain refusals, andrate_limitedwithretryAfter. It accepts and refuses the same values as before.Kind.hint: removed, along with its branch inanswer()and the mentions in theerror_kinds.tsheader anddocs/ARCHITECTURE.md. The existing status-default hint still reaches every error body, as before.?? 1fallback:Kindis now a union. A 429/503 row must carrywait: number, andanswer()branches onwait !== undefined, so the fallback is gone and the type enforces it.- Test name: renamed to "a pressure kind says how long: the refusal's own, else the row's", which is what it checks. No hint test is needed now that the field is gone.
- Docs: the "No new behaviour" paragraph is dropped from
docs/features/offer.md.
The commit carries a No door: line, because this changes internal error plumbing and no page, route, tool or action behaviour. scripts/gate.ts --fix changed nothing.
One of the four failing tests came from my change and is fixed and pushed. The other three I did not fix. Locally the retry-after and error-kinds tests pass (14), and tsc --noEmit is clean.
- Retry-after scan (
test/retry-after.test.ts): my newKindtype has a line containing429 | 503, which the scan flagged as an unnamed wait site. I added an exemption entry for that line, with its reason, and removed the stale entry for theanswer()branch I had replaced. The code is unchanged. /llms.txtbyte budget: this test fails the same way on the commit before my work started. The admin role gets 99,300 bytes against a budget of 99,200, so it is not caused by this pull. I left the budget alone, since changing it is a call for whoever owns that file.- Crawler screen and "repeat on the same two heads" (
test/tui-crawlers.test.ts,test/upstream-counts.test.ts): both passed when I ran them locally, together with the other two. I did not look into why they failed in the shard run, and I can't say whether they are flaky.
The offers route now returns its refusals as plain data, and
answer()insrc/http/respond.tsrenders them as{ error, message, hint }. I rantsc,test/error-kinds.test.ts,test/check-list.test.ts, and the offer and hint suites (test/api-hints.test.ts,test/respond-words.test.ts,test/fork-offers.test.ts,test/offer-limits.test.ts,test/offer-stranger.test.ts,test/offer-receipt.test.ts). All pass and the existing offer tests are untouched. I did not run the full suite; the forge runs the full check on the push.src/http/error_kinds.tsholds oneKINDStable of code, status, optional hint and a default wait for the offers family. That is the ten patch refusals (422),rate_limitedandqueue_full(429), andunavailable(503).refuse(kind, message, retryAfter?)returns aRefusalas plain data.answer()uses the kind's status andretry-afterfor 429/503. When the kind sets no hint, the status default inHINTSstill applies.POST /api/v1/repos/:owner/:name/offersinoffer_routes.tsnow returnsanswer(refuse(...))instead of building each response. Codes, statuses and words are identical;not_foundstill goes throughnotFound().docs/ARCHITECTURE.mdsays how to add a kind, anddocs/features/offer.mdhas a short note.test/error-kinds.test.tschecks that every kind answers with its own status, code and message, and that the 429/503 retry headers are right. Without the table oranswer()it would fail.apiError,tryAgainandHINTSas they were. I did not runscripts/similar.ts.offerRefusalhas an unreachablenot_foundcase that returns a placeholder kind, because the handler answers 404 first and TypeScript still wants the case covered.waitdefault instead of carrying hints of their own. I did not changescripts/gate.ts. No web, TUI or contract changes, so I added no door and noreviewblock. The hint-less refusals still get their hint fromwithHint.Try:line, so I added an empty commit for it.To try it, POST an over-long
titleto/api/v1/repos/:owner/:name/offersand read the 422 body.🤖 Generated with Claude Code
Closes #14234