Repository navigation
feat(record-context): citation verifier reports failures apart from refusals - #37438
Conversation
…efusals A verifying call refused with an ADR-0112 coded 4xx still drops its citations silently; any other throw drops them too (fail-closed) and is handed to an optional onError, once per call. Doc nits: list cap, adjacent-text join, stripBodyTags is not a sanitizer. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZnFSe9yjMwBFr33Rk
📓 Docs Drift CheckThis PR changes 2 package(s): 8 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 0fec3d0dbcfdc77e4c9971be65626b11c6863f70 && git checkout 0fec3d0dbcfdc77e4c9971be65626b11c6863f70
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a46efa8c625f2b43d4aa1aa1044eb702667ba07d 3ec523a9bcf1097a7b9649f526657ab509652228 && git checkout -B drift-repro a46efa8c625f2b43d4aa1aa1044eb702667ba07d && git merge --no-ff 3ec523a9bcf1097a7b9649f526657ab509652228
node scripts/docs-audit/affected-docs.mjs --json a46efa8c625f2b43d4aa1aa1044eb702667ba07d
|
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZnFSe9yjMwBFr33Rk
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 414d568 · 2026-11-26T06:16Z The seat runs the at-tier contract review of this head through an isolated sub-agent; L1 is the seat's own. |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: PR #37438 for card #37418. Read: the card body and all six comments (triage 7181858112, unblock 7182915332, claim 7182951217, re-claim 7182973002, os-dev report 7183739162, claim amendment 7183761008), the PR body, the net diff against Check-runs on this head, a repeated name governed by its newer run: 0 failure. ① Derived judgments
② Semver levelClause-②: yes (widening)
③ Boundary flags
④ Design judgment
S1 (should-fix) — S2 (should-fix) — "A callback that throws is ignored" holds for a synchronous throw only. N1 (nit) — the tests and the one ablation cover the card's acceptance, and the ablation named (refusal reduced to "has a string code") is the right one for the driver-errno case. Half of the conjunction is unpinned: no test throws a 4xx with no code, so N2 (nit) — N3 (nit) — the rule's sentence "so the host can log or retry it instead of losing the citations silently" is true at this function's boundary only. A failed child read or published-definition read arrives as N4 (nit) — the refusal band is the whole of 4xx. A door that ever declares a coded 408 or 429 would have a transient condition dropped silently and for good, which is the card's own failure mode. No such producer exists on the read path today; no change asked, recorded so the next door author reads it. No must-fix. S1 and S2 are open on this head and each earns a delta review of its fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
… async onError A refusal declared with statusCode only is a refusal. A rejected promise from onError is caught. Doc: the bodyIsHtml report site, the executor's 403 conversion (#37463), the 4xx band. Pins for each. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZnFSe9yjMwBFr33Rk
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 3ec523a · 2026-11-26T07:01Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Delta review of PR #37438 (card #37418) after record 7184346569 on Check-runs on this head: 60 success, 13 skipped, 0 failure, 0 cancelled. Four names ran twice ( ① Derived judgments
② Semver levelClause-②: yes (widening)
③ Boundary flags
④ Design judgmentS1: closed S2: closed N1, N2, N3 and N4 of record 7184346569 are all taken up at this head:
Is the mirror faithful? On the two spelling limbs, exactly. It is not the whole reader: N5 (nit) — N6 (nit) — the PR body's Verification line still says "21 tests pass"; the file holds 25 at this head, as the body's own ablation counts (1 failed, 24 passed) show. Prose face, fixable without moving the head. No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Landing: ACCEPT 7185121718 (delta contract record 7185088829, PASS) at head
Status: ready + auto-merge (merge queue). On MERGED, #37418 closes by |
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Dequeued (CI_FAILURE) from merge group |
Requested by Bill · project thread
Fixes #37418
Clause-②: yes (widening) — new optional third argument of the exported verifyRecordCitations and two new exported types; existing calls unchanged
Metadata-protocol: none
维护者速读
What changes
verifyRecordCitations(citations, door, options?)inpackages/services/service-record-context/src/verify-citations.ts:codewith a declared 4xx status is a refusal. The status is read as ADR-0112's reader (resolveThrownHttpError'sdeclaredStatus) reads it,.statusthen.statusCode, mirrored locally because the package does not depend on@objectstack/types. A refusal is the only shapeget_record_contextrefuses with: its citations are dropped and nothing is reported, as before. Any other throw (no code, a driver code with no status, a 5xx) is a failure: its citations are dropped too, so the result stays fail-closed, and the failure goes to the new optionaloptions.onError(error, call), once per verifying call. A callback that throws, or returns a promise that rejects, is ignored, so the verifier still never throws for a citation and leaves no unhandled rejection. The served-definition read behind the HTML-body check reports too; there the call answered and only the tag-removed reading is lost, which the option's JSDoc says.ECONNRESET,SQLITE_ERROR) also arrives on.code, so the string alone cannot tell.RecordCitationParsed[], existing two-argument callers see nothing, and the result carries nothing that could tell a caller a hidden record from a missing one. A{ verified, unverifiable }result would put the failure next to data the caller may see, and would change the signature every caller reads.VerifyRecordCitationsOptionsandVerifyingCall(src/index.ts).RECORD_CITATIONS_MAX) and drops the rest, whereRecordCitationsSchemarefuses a list of 21.<p>Fire</p><p>cover</p>readsFirecover). A test pins it.stripBodyTags(packages/spec/src/ai/record-body-anchor.ts) says it is not a sanitizer. JSDoc only.Tests
src/__tests__/verify-citations.test.ts, new block "a refusal and a failure":Error: citations dropped, failure reported once per distinct call (two calls, three citations → two reports). Control: the same citations verify through a door that answers.unreadableRows) and a missing record (p404) give the host the identical{ quotes: [], reported: [] }, with a control leg that verifies the readable record.statusCodeonly is not reported (control: coded 503statusCodeis); a 4xx with no code, a thrown string and a thrownundefinedare reported; a failing definition read behind an HTML body is reported once while the field quote and the as-stored quote still verify; an async callback that rejects leaves no unhandled rejection.Ablation (one, on the coded-vs-uncoded split):
isRefusalreduced to "has a string code" → "reports a driver code with no status, and a coded 5xx, as failures" goes red (1 failed, 20 passed); restored → green. Rework ablations: dropping the.statusCodelimb → the statusCode-only test red (1 failed | 24 passed); dropping the returned-promise handler → the async-callback test red (1 failed | 24 passed); both restored → green.Acceptance notes
record-context-tools.ts(fenced, sibling 37203 跟进:get_record_context 无权的关联子对象改为省略、真实通道交出可查询字段,并补筛选排序的双通道比对 #37361) turns some door failures into coded refusals before they reach the verifier: a failing related-object definition read or published-definition read becomesPERMISSION_DENIED403 so the refusal names nothing. Those failures are therefore not reported, and the module doc now says so. The follow-up card is 37418 跟进:资料包读取把关联对象的故障当作「无权」拒绝,故障应如实报出且不泄露 #37463.Clause-②: yes (widening)(seat ruling, same as the fix(service-record-context): get_record_context leaves out an unserved related child; both MCP doors supply queryableFieldsOf and their page cap #37412 precedent): the new parameter is optional and the return type is unchanged, so no existing caller changes; there is no caller outside this package today. Bump stays patch.Verification
Two-minute check:
pnpm --filter @objectstack/service-record-context exec vitest run src/__tests__/verify-citations.test.ts— 25 tests pass.Read first:
verify-citations.tsisRefusal,declaredStatusOfandreport(the split and the async guard), then thehaystackOfcatch.Generated by Claude Code