Found while implementing #15362 (docs: the 409 unique-constraint refusal is UNIQUE_VIOLATION on the wire). It blocks that card.
Repro
On a branch whose only change is renaming #### DUPLICATE_RECORD to #### UNIQUE_VIOLATION (keeping **HTTP Status:** 409) in content/docs/protocol/kernel/error-handling.mdx:
pnpm check:error-status-conformance # exit 1
scope: 52 code(s) reconciled = 50 StandardErrorCode member(s) + 2 ledger code(s) a doc page
publishes a status for (INVALID_REQUEST, UNIQUE_VIOLATION)
unpinned: 33 documented code(s) with no derivable producer (baselined: 32).
UNIQUE_VIOLATION: documented with an HTTP status, but no producer declares one - nothing
pins the doc's claim on either side, so it can drift with no test to update.
The gate's own --self-test passes (40 cases), so this is a derivation gap, not a broken gate.
Why the deriver misses it — two independent blind spots
R5b (scripts/check-error-status-conformance.mjs, the { status, body } mapper terminal) matches with a body group that forbids nested braces — the pattern is status, colon, three digits, comma, body, colon, then a brace group whose contents are spelled as a negated character class excluding both brace characters.
The real terminal — packages/rest/src/error-response.ts:992, structuredCodeAnswer's DuplicateRecordError arm — builds its body with conditional spreads, so nested braces sit between status: 409 and code: 'UNIQUE_VIOLATION':
return {
status: 409,
body: {
error: field
? `A record with this ${field} already exists`
: 'A record with this value already exists',
code: 'UNIQUE_VIOLATION',
...(typeof error?.message === 'string' && error.message.length > 0
? { developerMessage: error.message }
: {}),
...(field ? { field } : {}),
...(refused ? { object: refused } : {}),
},
};
R5b skips it. The second real producer is missed for a different reason — driver-memory declares the pair by ASSIGNMENT, which no rule matches:
// packages/drivers/driver-memory/src/memory-unique-constraint.ts:504-505
err.code = UNIQUE_VIOLATION_CODE; // = 'UNIQUE_VIOLATION'
err.status = UNIQUE_VIOLATION_STATUS; // = 409
The 409 UNIQUE_VIOLATION answer itself is pinned by tests — packages/rest/src/rest-duplicate-record-arm.test.ts section 1 asserts status 409 and body.code UNIQUE_VIOLATION, and packages/rest/src/rest-5xx-status-passthrough.test.ts:379 asserts the same through another door. So the code IS emitted; only the deriver is blind.
Why neither remedy the gate offers is right as it stands
Its failure text names two: wire a producer that declares status/statusCode, or admit the code to scripts/error-status-unpinned-baseline.json. The first describes a producer that already exists. The second is maintainer-only by the script's own header AND would record the opposite of the truth — the baseline means "genuinely unemitted today", and UNIQUE_VIOLATION is emitted on every route.
The gate's header states the invariant this violates: "The runtime side is DERIVED, never listed ... Where an identifier cannot be resolved the declaration is REPORTED as unresolved, never silently dropped — a deriver that goes quietly blind is the same failure one layer down." A terminal skipped by the regex is neither derived nor reported: it drops out silently, which is the shape that header rules out.
Suggested disposition
Extend the deriver so both shapes are seen, with a --self-test case per shape (the script's header requires the self-test case in the same edit):
- R5b: allow one level of nesting inside the
body group, or locate code within a brace-balanced span rather than a brace-free one.
- A new rule for the assignment form (
err.code = X; followed by err.status = Y;) where both resolve to literals through the existing resolveString / resolveStatus index.
Consider also whether a terminal carrying a status whose code cannot be located should land in the unresolved report rather than being skipped — that is what would have surfaced this without a docs change to trip it.
Until this lands, the #15362 docs fix cannot go green.
Found while implementing #15362 (docs: the 409 unique-constraint refusal is
UNIQUE_VIOLATIONon the wire). It blocks that card.Repro
On a branch whose only change is renaming
#### DUPLICATE_RECORDto#### UNIQUE_VIOLATION(keeping**HTTP Status:** 409) incontent/docs/protocol/kernel/error-handling.mdx:The gate's own
--self-testpasses (40 cases), so this is a derivation gap, not a broken gate.Why the deriver misses it — two independent blind spots
R5b (
scripts/check-error-status-conformance.mjs, the{ status, body }mapper terminal) matches with a body group that forbids nested braces — the pattern isstatus, colon, three digits, comma,body, colon, then a brace group whose contents are spelled as a negated character class excluding both brace characters.The real terminal —
packages/rest/src/error-response.ts:992,structuredCodeAnswer'sDuplicateRecordErrorarm — builds its body with conditional spreads, so nested braces sit betweenstatus: 409andcode: 'UNIQUE_VIOLATION':R5b skips it. The second real producer is missed for a different reason —
driver-memorydeclares the pair by ASSIGNMENT, which no rule matches:The
409 UNIQUE_VIOLATIONanswer itself is pinned by tests —packages/rest/src/rest-duplicate-record-arm.test.tssection 1 assertsstatus409 andbody.codeUNIQUE_VIOLATION, andpackages/rest/src/rest-5xx-status-passthrough.test.ts:379asserts the same through another door. So the code IS emitted; only the deriver is blind.Why neither remedy the gate offers is right as it stands
Its failure text names two: wire a producer that declares
status/statusCode, or admit the code toscripts/error-status-unpinned-baseline.json. The first describes a producer that already exists. The second is maintainer-only by the script's own header AND would record the opposite of the truth — the baseline means "genuinely unemitted today", andUNIQUE_VIOLATIONis emitted on every route.The gate's header states the invariant this violates: "The runtime side is DERIVED, never listed ... Where an identifier cannot be resolved the declaration is REPORTED as unresolved, never silently dropped — a deriver that goes quietly blind is the same failure one layer down." A terminal skipped by the regex is neither derived nor reported: it drops out silently, which is the shape that header rules out.
Suggested disposition
Extend the deriver so both shapes are seen, with a
--self-testcase per shape (the script's header requires the self-test case in the same edit):bodygroup, or locatecodewithin a brace-balanced span rather than a brace-free one.err.code = X;followed byerr.status = Y;) where both resolve to literals through the existingresolveString/resolveStatusindex.Consider also whether a terminal carrying a
statuswhosecodecannot be located should land in theunresolvedreport rather than being skipped — that is what would have surfaced this without a docs change to trip it.Until this lands, the #15362 docs fix cannot go green.