Commit 8664a2c
refactor(rest): extract the ADR-0112 error/fault-classification prologue out of rest-server.ts (#8887)
* refactor(rest): extract the ADR-0112 error/fault-classification prologue out of rest-server.ts
The module-level code ahead of `RestServer` is ADR-0112's concern — how a
thrown thing becomes an HTTP answer — not the REST server's. It reads no class
state and lived in that file for historical rather than structural reasons.
Moved verbatim to `packages/rest/src/error-response.ts`: mapDataError,
resolveErrorResponse, DATA_STORE_FAULT, UNCLASSIFIED_FAULT, isScriptFaultMessage,
declaredHttpStatus, truncateClientMessage, sendError, sendFieldVisibilityFault,
logWithheldServerFault, isExpectedDataStatus, isExpectedQueryRejection,
isExpectedRouteError, logUnexpectedRouteError, handleRouteError,
droppedFieldsHeaderValue, applyDroppedFieldsHeader, missingRelationIsObject,
plus their module constants. The console shim both files need moved to
`packages/rest/src/log.ts` rather than being copied.
No behaviour change: every moved line is byte-identical, the only edits being
six `export` prefixes and mapDataError's docblock reattached to the function it
describes (it had drifted above an unrelated import). `mapDataError` and
`zodIssuesToFields` are still exported from `./rest-server.js` unchanged.
Not the ADR-0076 D11 decomposition, which the 2026-08-15 ruling on #5949 closed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaS1PAHJcPfAA2acnV53Tn
* chore(gates): keep route-envelope and durability visibility whole across the prologue extraction
Two declarations, both made necessary by the file move in the previous commit and
neither changing what any gate ENFORCES.
check-route-envelope.mjs: `error-response.ts` emits REST bodies (the sendError /
handleRouteError doors) but sits outside the `*-routes.ts` discovery convention,
so it would have been audited by nothing. Named in OFF_CONVENTION_MODULES with a
`{ responses: 2, ok: 0, err: 0 }` entry measured at extraction. rest-server.ts's
own ratchet is untouched and still reads stringError 44 / siblingCode 69.
check-durability-degradation-log-level.mjs: the two saveMetaItem route catches
qualified on main as `loud (error@120 via handleRouteError())` — the gate followed
handleRouteError as a SAME-FILE helper down to logError. Moving that function to
its own module made the inference unavailable (helper resolution is file-scoped by
construction), so the gate lost visibility while the behaviour did not move a line.
Declared handleRouteError in FAILURE_PROPAGATION_CALLEES as `via: 'effect'`: it
answers the caller unconditionally, which is a STRICTER claim than the loudness it
replaces, since it logs only for unexpected errors. Seam count is 25 before and
after — nothing left the gate's view.
No baseline touched, no ratchet raised, no threshold moved.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaS1PAHJcPfAA2acnV53Tn
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 15283cf commit 8664a2c
5 files changed
Lines changed: 1450 additions & 1296 deletions
File tree
- packages/rest/src
- scripts
0 commit comments