Skip to content

feat(record-context): citation verifier reports failures apart from refusals - #37438

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-maip9m
Nov 26, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-maip9m

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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

维护者速读

  • 用户能看到什么变化:用户无感;AI 回答里的引用核对时,数据库故障不再被当成「无权查看」悄悄丢掉,而是报给后台。
  • 为什么做:AI 回答引用专题的后续,替云端产生引用的那一步和运维排障的人解决「一次故障让引用永久消失且无人知晓」。
  • 出错会怎样:故障时引用照样不显示(宁缺勿错),只是多报一条错误;无权查看和记录不存在对后台仍是同一个结果,不泄露记录是否存在;可直接撤回本改动。
  • 要你做什么:无。

What changes

verifyRecordCitations(citations, door, options?) in packages/services/service-record-context/src/verify-citations.ts:

  • Refusal vs failure. A throw carrying an ADR-0112 code with a declared 4xx status is a refusal. The status is read as ADR-0112's reader (resolveThrownHttpError's declaredStatus) reads it, .status then .statusCode, mirrored locally because the package does not depend on @objectstack/types. A refusal is the only shape get_record_context refuses 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 optional options.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.
  • Why status, not the code string. ADR-0112's 2026-08-27 amendment names the status channel as the one structural signal between a refusal and a fault: a driver errno (ECONNRESET, SQLITE_ERROR) also arrives on .code, so the string alone cannot tell.
  • Design choice: a callback, not a new result shape. It is the smaller change. The return type stays 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.
  • New exported types VerifyRecordCitationsOptions and VerifyingCall (src/index.ts).
  • Nits from the PR feat(spec,service-record-context): the record citation shape, and the verifier that checks a quote as the asking user (ADR-0160 D9) #37396 review:
    • The module doc says which list cap a producer gets: the verifier reads the first 20 (RECORD_CITATIONS_MAX) and drops the rest, where RecordCitationsSchema refuses a list of 21.
    • The module doc corrects the "tag-stripping only makes verification stricter" note: the tag-removed reading is a second string, and removing a tag joins adjacent text (<p>Fire</p><p>cover</p> reads Firecover). 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":

  • A door whose root read throws an uncoded 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.
  • A driver code with no status and a coded 500: dropped and reported.
  • Control: coded 403, 404 and 400 refusals: dropped, not reported.
  • A refused read (unreadableRows) and a missing record (p404) give the host the identical { quotes: [], reported: [] }, with a control leg that verifies the readable record.
  • A throwing callback is ignored; no callback still drops the failed call.
  • Rework (contract review 7184346569, seat REWORK 7184355118): a coded refusal declared with statusCode only is not reported (control: coded 503 statusCode is); a 4xx with no code, a thrown string and a thrown undefined are 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.
  • The adjacent-text join of the tag-removed reading.

Ablation (one, on the coded-vs-uncoded split): isRefusal reduced 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 .statusCode limb → 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

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.ts isRefusal, declaredStatusOf and report (the split and the async guard), then the haystackOf catch.


Generated by Claude Code

…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
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:ai tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/service-record-context, @objectstack/spec, touching 15 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/services/service-record-context/src/index.ts, packages/spec/src/ai/record-body-anchor.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

8 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/data-api.mdx (via /:object/:id/change-owner (route, bridged from symbol isRefusal — its route source's handler names it), /:object/change-owner (route, bridged from symbol isRefusal — its route source's handler names it))
  • content/docs/api/data-flow.mdx (via onError (symbol, a field of interface VerifyRecordCitationsOptions), onError (literal, a string literal in bodyIsHtml; a string literal in haystackOf; a string literal in report))
  • content/docs/api/error-handling-server.mdx (via onError (symbol, a field of interface VerifyRecordCitationsOptions), onError (literal, a string literal in bodyIsHtml; a string literal in haystackOf; a string literal in report))
  • content/docs/automation/hook-bodies.mdx (via onError (symbol, a field of interface VerifyRecordCitationsOptions), onError (literal, a string literal in bodyIsHtml; a string literal in haystackOf; a string literal in report))
  • content/docs/automation/hooks.mdx (via onError (symbol, a field of interface VerifyRecordCitationsOptions), onError (literal, a string literal in bodyIsHtml; a string literal in haystackOf; a string literal in report))
  • content/docs/frontend/plugins/plugin-chatbot.mdx (via onError (symbol, a field of interface VerifyRecordCitationsOptions), onError (literal, a string literal in bodyIsHtml; a string literal in haystackOf; a string literal in report))
  • content/docs/frontend/schema-rendering.mdx (via onError (symbol, a field of interface VerifyRecordCitationsOptions), onError (literal, a string literal in bodyIsHtml; a string literal in haystackOf; a string literal in report))
  • content/docs/kernel/events.mdx (via onError (symbol, a field of interface VerifyRecordCitationsOptions), onError (literal, a string literal in bodyIsHtml; a string literal in haystackOf; a string literal in report))
What this run could not see
  • 2 changed file(s) yielded no anchor (packages/services/service-record-context/src/index.ts, packages/spec/src/ai/record-body-anchor.ts) — pages documenting those are invisible to this run
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a46efa8c625f2b43d4aa1aa1044eb702667ba07d → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 0fec3d0dbcfdc77e4c9971be65626b11c6863f70 — the merge of head 3ec523a9bcf1097a7b9649f526657ab509652228 into base a46efa8c625f2b43d4aa1aa1044eb702667ba07d, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs a46efa8c625f2b43d4aa1aa1044eb702667ba07d → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 414d568e8b3239f1135c1b154c7894ff6257e8c0
Local-runs: none
Scope: packages/spec/src/ai/record-body-anchor.ts + packages/services/service-record-context/src/verify-citations.ts, packages/services/service-record-context/src/index.ts

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 main (5 files, +187 / -14), and the 73 check-runs on this head. The rest of the diff (the test file, the changeset) is the lane seat's ACCEPT at TIER_DEFAULT; what is said about the tests below is said because the brief asked, not as a review of them.

Check-runs on this head, a repeated name governed by its newer run: 0 failure. PR-body guards cancelled at 05:44:59Z is superseded by its success at 05:45:23Z; Check PR Size and Auto Label each ran twice, the newer runs are skipped and success. Check Changeset, Governed Surface Queue Guard, Spec property liveness, Lint & Repo Gates, every Lint lane, Type Check · workspace, Test Core 10/10 and Test UI 16/16 are success. The dev report's gates were read on 88f220f0; the one later commit is the changeset's Clause-② line, and the runs above are on the head reviewed.

① Derived judgments

  • verifyRecordCitations(citations, door, options = {}): one new optional third parameter with a default. Every existing two-argument call type-checks and behaves as before. Right.
  • Return type unchanged, a list of RecordCitationParsed. The verified subset is computed exactly as on main: every throw of the verifying call still yields no haystack, so no citation of that call survives. No accept-set of the result changes. Right.
  • Two new exported types, VerifyRecordCitationsOptions and VerifyingCall, from src/index.ts. Additive public surface of @objectstack/service-record-context. Right, and it is the only widening in the diff.
  • packages/spec/src/ai/record-body-anchor.ts: four JSDoc lines on stripBodyTags, no code. No schema, no accept-set, no export, no api-surface or export-origins entry moves. It is NOT part of the widening. Right.
  • Does dropping a failure from the result, with no onError passed, narrow anything for an existing caller? No. On main the catch is bare (catch {} with the comment "Every refusal is one outcome"): a caller never saw a failure, in the result or as a throw. Nothing a two-argument caller could observe before is taken away, so no narrowing arm is owed. main has no caller outside the package (read: the only other mentions are the spec's prose and the index.ts export).
  • Metadata-protocol: none. Right: nothing a metadata author can write changes.

② Semver level

Clause-②: yes (widening)

  • The line is right, and it is the claim as amended (7183761008), not the card's no: the card's condition "unless the exported signature changes in a way an existing caller sees" is narrower than the rule, an exported function gaining a parameter and a package gaining two exported types widens the public surface whether or not a caller exists. PR body and changeset carry the same line, word for word.
  • Level patch on @objectstack/service-record-context: right. AGENTS.md, changeset rule: "a non-protocol change, widening or breaking, ships patch"; the level follows the Metadata-protocol kind alone, and the kind is none.
  • Level patch on @objectstack/spec: right. The JSDoc ships in the published declarations, so the package moves; with kind none it takes patch. The spec change rides the changeset but is outside the widening; the Clause line's own account names only the verifier's argument and types, which is accurate.

③ Boundary flags

  • Dev deviation 1, the signature uses the thread session per re-claim 7182973002: accepted, the re-claim names that session.
  • Dev deviation 2, reviewer request left to the seat: accepted, nothing for this record.
  • Dev deviation 3, the spec suite not run locally for a JSDoc-only change: accepted, Test Core 10/10 is green on this head.
  • open_questions: empty. Nothing to answer.
  • security_findings: none reported. This review adds none at must-fix grade; see ④ for the two directions of leak tried.
  • out_of_scope_findings, "record-context-tools.ts turns some door failures into PERMISSION_DENIED 403, so they reach the verifier as refusals and are not reported — noted, not filed": confirmed in the live tree. On main the executor still refuses unnamed for a failed child read ("A read that failed is no answer about this caller: it refuses, unnamed"), and a published-definition read that throws does the same. The fence is right, the file is the sibling's. ESCALATED to the seat: "noted, not filed" leaves the card's own goal (an outage must not lose citations silently) unmet for every pack with a related entry, so it needs a card under 专题:记录范围 AI 问询(在一条记录上问 AI:对话钉在这条记录上、平台按配置交给模型这条记录的资料、外部 AI 经 MCP 拿到同一份) #36996. Until then N3 below stands as an accepted deviation.
  • File surface of the claim: held. index.ts moved only for the two exported types; the spec file is prose only.
  • SQL push-down (Prime Directive 5): clean. The diff adds no read, no id materialisation and no in-app join. The verifying calls, one per distinct tuple and at most 20, and the in-app substring match are main's (PR feat(spec,service-record-context): the record citation shape, and the verifier that checks a quote as the asking user (ADR-0160 D9) #37396) and must go through the caller's executor to keep its gates; the new code only classifies what those calls throw.

④ Design judgment

packages/spec/src/ai/record-body-anchor.ts (hits). The three added sentences hold against the function below them. "Not a sanitizer": the loop only removes spans from a less-than sign to the next greater-than sign and escapes nothing. "Entities are left encoded": true, the heading reader decodes them itself, after the strip (decodeEntities(stripBodyTags(h.inner))), and the verifier does not. "Joined with nothing between": true, out += text.slice(i, open) with no separator. It agrees with the verifier's new paragraph and with the test that pins Firecover. It closes nit N1 of record 7181386892 as the card asked. No finding.

packages/services/service-record-context/src/verify-citations.ts (implementing). The design holds: a callback rather than a second result member keeps anything failure-shaped away from data a caller is shown, and the result is byte-for-byte what main returns. Tried to break it, per the brief's questions:

  • 5xx carrying a string code: failure, dropped and reported. Agrees with ADR-0112 (declaresServerFault, 5xx with a code, is a declared fault, not a refusal). Pinned by the coded-500 test.
  • 4xx with no code, or a code that is not a non-empty string: failure, reported. Conservative and safe, it over-reports to the host and changes nothing in the result. Not pinned by any test (N1).
  • A thrown non-Error (a string, null, undefined, or the bridge's own bare object with statusCode: 503 and a message): isRefusal answers false at its first line or at the code check, so it is a failure, reported with the thrown value as given. Correct.
  • AbortError: a DOMException's code is the number 20 and a Node abort's code is ABORT_ERR with no status, so both are failures, reported. Correct.
  • A failure miscounted as a refusal, inside this file: only an error that itself declares a string code and a 4xx status. No in-tree producer on the read path declares 408 or 429 with a code today (N4). Upstream of this file the executor does it by design, see ③.
  • A refusal miscounted as a failure: S1.
  • Does either miscount reach the user? Not through the result: a refusal, a failure and a missing record all yield the same absent citation, so the model and the user are told nothing in any of the three cases, and no "you cannot see this" can be produced from it. The only channel that differs is onError, which is the host's. The read path's real refusals (PermissionDeniedError, recordNotFoundError, objectNotFoundError, the exposure and credential refusals of both bridges, every refusal() of the executor) all carry code and a 4xx status, so a hidden record and a missing one are equally silent to the host today. No leak found.

S1 (should-fix) — isRefusal reads .status alone, which is not ADR-0112's reader. The ADR's discriminator is ThrownHttpError.declaredStatus, and resolveThrownHttpError computes it as .status, then .statusCode (packages/types/src/thrown-http-error.ts; the same order is restated in data-error-classification.ts and external-driver-floor.ts, and #7525 is the record of the 500 a status-only read produced for a deliberate 409). A refusal that declares a code and statusCode: 403 or 404 is therefore reported to the host as a failure, which breaks the module's own sentence "it is called for a failure only, never for a refusal" and, for such a producer, gives the host different answers for a refused read and a missing record (card acceptance 2). Not live in the tree: every refusal read above carries both spellings. But RecordContextDoor is an open contract whose members throw "the door's own coded refusal", and row 9 and 10c build new doors. Fix: read the declared status as the shared reader does, or call resolveThrownHttpError(err).declaredStatus, and pin one statusCode-only refusal as not reported. If .status-only is meant, say so in the rule and drop the claim that this is ADR-0112's channel.

S2 (should-fix) — "A callback that throws is ignored" holds for a synchronous throw only. onError is typed as returning void, which accepts an async function, and a logger or a retry enqueue is the natural async callback. Its rejection is not caught by the try in report, so it becomes an unhandled rejection, which ends a Node process by default. That is the opposite of "a callback that throws changes nothing". Fix: when the callback returns a thenable, attach a no-op rejection handler, and pin it with a callback that returns a rejected promise; or state in the option's JSDoc that the callback must be synchronous and must not return a promise.

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 isRefusal reduced to "status in the 4xx band" passes all 21 tests. Also unpinned: the second report site (bodyIsHtml's catch), a thrown non-Error, and the band edges. The head moves for S1 and S2 anyway, so add them there: a bare status: 404 with no code reported, a served-definition read that throws on an HTML body reported once, a thrown string reported. The test file is the lane seat's to accept.

N2 (nit) — VerifyRecordCitationsOptions.onError says "Its citations are dropped whether or not it is given". For the second report site that is not so: the call answered, only the tag-removed reading is lost, and a quote found in a field or in the body as stored still verifies. A host that retries on every report would re-verify citations that survived. Say that a report can also mean "the HTML reading was unavailable". Fix with S1 and S2, or leave as an accepted deviation.

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 PERMISSION_DENIED 403 from the executor and is lost silently, as the PR body's acceptance note says and the module doc does not. Accepted deviation on this PR; the follow-up card is the escalation in ③.

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: claude/project-thread-maip9m
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 414d568e8b3239f1135c1b154c7894ff6257e8c0
REWORK — L1, seat repo:objectstack#5: contract record 7184346569 (schema face, CONTRACT_REVIEW_TIER) reads PASS with two should-fix findings. Both are small and are fixed in this PR before ACCEPT.

  1. Shape: open draft against main, 5 files (+187/−14), Fixes #37418, Clause-②: yes (widening), Metadata-protocol: none, patch. Check-runs: 59 success, 13 expected skip. The one cancelled run is a PR-body guards run that the 05:45:23Z success supersedes.
  2. Premise: an optional onError leaves the return type unchanged. The result still gives a refusal, a failure and a missing record the same absent citation, so there is no leak in either direction. Existing two-argument callers see no change, since main swallowed every failure. The spec change is four accurate JSDoc lines.
  3. Owed in this PR:
    • S1. isRefusal reads .status alone, but ADR-0112's reader (resolveThrownHttpError().declaredStatus) reads .status and then .statusCode. Use that reader, or mirror it, so a coded refusal declared with statusCode only is a refusal. Pin it.
    • S2. "A callback that throws is ignored" holds only for a synchronous throw. An async onError that rejects escapes report's try as an unhandled rejection. Catch a returned promise's rejection (Promise.resolve(r).catch(() => {})) and pin it.
      The same reviewer reads the delta.
  4. Accepted deviations: the following nits are fixed in the same push if cheap.
    • N1: pin a 4xx without a code, the bodyIsHtml report site and a thrown non-Error.
    • N2: the onError JSDoc overclaims at the bodyIsHtml site.
    • N3: the module doc's "instead of losing the citations silently" overclaims; see 5.
    • N4: a coded 408/429 counts as a refusal. No producer exists today.
  5. Out of scope and where it went: the executor still turns failed child and published-definition reads into PERMISSION_DENIED 403, so those failures are still lost silently, and the card's goal stays unmet for packs with related entries. File a card under 专题:记录范围 AI 问询(在一条记录上问 AI:对话钉在这条记录上、平台按配置交给模型这条记录的资料、外部 AI 经 MCP 拿到同一份) #36996 for it and name it in the acceptance notes. It is owed before ACCEPT.
  6. Landing terms: ungoverned, schema face at CONTRACT_REVIEW_TIER. A same-head at-tier PASS with S1 and S2 closed, the card from 5, and an ACCEPT are owed. The area lands it.

… 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
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 3ec523a · 2026-11-26T07:01Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 3ec523a9bcf1097a7b9649f526657ab509652228
Local-runs: none
Scope: packages/spec/src/ai/record-body-anchor.ts + packages/services/service-record-context/src/verify-citations.ts, packages/services/service-record-context/src/index.ts

Delta review of PR #37438 (card #37418) after record 7184346569 on 414d568e and the seat's REWORK 7184355118. Read: the one rework commit 3ec523a9 as git diff 414d568e..3ec523a9 (3 files, +127 / -18: the verifier, its test file, the changeset), the PR body at this head, the PR's comments (no new dev report was posted; the PR body is the dev's account, and it is judged against the tree), and the check-runs on this head. record-body-anchor.ts and index.ts did not move in the delta; their judgment in 7184346569 stands.

Check-runs on this head: 60 success, 13 skipped, 0 failure, 0 cancelled. Four names ran twice (Auto Label, Check Changeset, Check PR Size, PR-body guards); no run of any of them is a failure.

① Derived judgments

  • No public-surface change in the delta. onError keeps its type (a function returning void), the two exported types are unchanged, the return type is unchanged. Right.
  • The refusal set widens by one limb: a coded throw that declares its 4xx through statusCode only is now a refusal, not a failure. This changes only what is reported to the host, never the result. Right, and it is what S1 asked.
  • The result's accept-set is as on 414d568e, and so as on main: every throw of the verifying call still yields no haystack. Right.

② Semver level

Clause-②: yes (widening)

  • Unchanged and still right: the delta adds no export and no parameter. patch on both packages stands, Metadata-protocol: none stands. The changeset's two edited bullets agree with the code at this head (the .status then .statusCode read, the report behind an HTML body, the rejected promise).

③ Boundary flags

  • The deviation put to this review: @objectstack/service-record-context depends on @objectstack/core and @objectstack/spec only, so the declared-status read is mirrored locally (declaredStatusOf) with a comment naming resolveThrownHttpError, in place of a new dependency on @objectstack/types. ACCEPTED. A new runtime dependency on a published package for a four-line read is the heavier change, and the tree already carries the same local mirror with the same comment twice (packages/objectql/src/external-driver-floor.ts, plugin-driver-conformance.ts). Fidelity is judged in ④.
  • The escalation of record 7184346569 (the executor turns failed related-object and published-definition reads into PERMISSION_DENIED 403): answered. The PR body and the module doc name the follow-up card 37418 跟进:资料包读取把关联对象的故障当作「无权」拒绝,故障应如实报出且不泄露 #37463. The card itself is outside this review's inputs and was not read; its existence is the seat's to confirm before ACCEPT.
  • No new dev flag and no open_questions entry at this head.
  • SQL push-down (Prime Directive 5): clean. The delta adds no read, no id materialisation and no in-app join.

④ Design judgment

S1: closed
isRefusal now takes its status from declaredStatusOf: .status when it is a number, else .statusCode when it is a number, else none. That is the order and the type test of resolveThrownHttpError's declaredStatus (packages/types/src/thrown-http-error.ts), including the detail that a non-numeric .status falls through to .statusCode instead of blocking it. Pinned both ways: a coded statusCode: 403 is dropped and not reported, a coded statusCode: 503 is reported; the PR body records the ablation (the .statusCode limb removed, that test red).

S2: closed
report keeps the callback's return value and, when it has a callable then, attaches a rejection handler with a no-op. A synchronous throw, a rejected promise, and a then getter that itself throws all end inside the existing try. The callback is not awaited, so a slow host callback cannot stall verification. The type stays a function returning void, which is right: widening it would be a second surface change for nothing. Pinned by a test that listens for unhandledRejection across an async callback that rejects; ablation recorded.

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: resolveThrownHttpError also takes a declared 400 from two shapes that carry no status at all, a validation failure and an unevaluable hook condition. The mirror reads neither, so such a throw is a failure here and is reported. That is the safe direction (the host is told more, the result is unchanged), both shapes are raised on writes and not on the reads this function makes, and the module doc claims only ".status, then .statusCode", which is what the code does. Recorded as N5.

N5 (nit) — declaredStatusOf mirrors two of the four limbs of resolveThrownHttpError's declaredStatus; the validation-shape and hook-condition limbs are left out. No effect on the result and none reachable on the read path. Accepted deviation; if a door ever raises either shape on a read, take the dependency then.

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: claude/project-thread-maip9m
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 3ec523a9bcf1097a7b9649f526657ab509652228
ACCEPT — L1, seat repo:objectstack#5

  1. Shape: open draft against main, Fixes #37418, Clause-②: yes (widening), Metadata-protocol: none, patch. The rework since 414d568e adds the S1/S2 fixes, the N1 pins and the doc fixes. No main merge.
  2. Rework closed (delta contract record 7185088829, schema face, CONTRACT_REVIEW_TIER, same head):
    • S1: closed. isRefusal reads .status and then .statusCode, in the same order and with the same numeric test as resolveThrownHttpError. statusCode 403 is pinned as a refusal and 503 as reported.
    • S2: closed. A thenable returned by onError gets a rejection handler, and an async rejection is pinned. The => void type stays.
    • N1 to N4: closed.
  3. Gates: check-runs at 3ec523a9: 60 success, 13 skipped, 0 failed.
  4. Accepted deviations:
    • The reader is mirrored locally rather than adding @objectstack/types. The package depends only on core and spec, and packages/objectql already carries the same mirror.
    • N5 (nit): the mirror implements two of the reader's four limbs. The two missing limbs are write-side shapes, and reporting them as failures is the safe direction.
    • N6 (nit): the PR body's Verification line says 21 tests; the file holds 25. This is body prose, and the area may correct it without moving the head.
  5. Out of scope and where it went: the executor's failed related reads, still turned into 403, went to 37418 跟进:资料包读取把关联对象的故障当作「无权」拒绝,故障应如实报出且不泄露 #37463 (open, area:ai, p2), and the module doc names it.
  6. Landing terms: ungoverned. A same-head at-tier PASS with S1 and S2 closed is in place. The area marks it ready and lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

Landing: ACCEPT 7185121718 (delta contract record 7185088829, PASS) at head 3ec523a9bcf1097a7b9649f526657ab509652228. N6 closed in the body only (Verification line 21 → 25); head unchanged.

Probe Reading
Check-runs on head 62 success, 15 skipped, 0 failed, 0 pending (incl. the body-edit reruns of Check Changeset and PR-body guards)
Governed / size check-governed-merges --pr 37438: NOT governed; mergeable_state clean

Status: ready + auto-merge (merge queue). On MERGED, #37418 closes by Fixes; #37463 unblocks.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 26, 2026 07:13
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 26, 2026
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 26, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

Dequeued (CI_FAILURE) from merge group pr-37438-4925039a: CI run 45773724951, job "Dogfood Regression Gate (3/3)" cancelled after running 07:21Z–07:44Z (the job's time limit; the log ends in "Terminate orphan process" with no failed assertion), so the aggregate "Dogfood Regression Gate" reads failure. Every other workflow of the group was green. The diff touches only verify-citations.ts, its test, index.ts exports and one spec JSDoc; no dogfood path imports the verifier. Not this PR's. Head unchanged (3ec523a9); ungoverned, so auto-merge re-armed once.

Merged via the queue into main with commit 2776e88 Nov 26, 2026
78 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-maip9m branch November 26, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:ai size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

37364 跟进:引用核对器区分「拒绝」和「故障」,故障不再静默丢失引用

2 participants