Skip to content

fix(record-context): a related object's read that fails is a failure, not a refusal - #37550

Draft
objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-37463-record-context-outage
Draft

objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-37463-record-context-outage

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #37463

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:AI 用资料包读一条记录时,如果关联对象那一步因为故障(比如数据库抖动)读不出来,现在回答「服务暂时不可用」,不再谎称「无权访问」;对有权限的拒绝照旧。用户无感于正常路径。
  • 为什么做:属于「记录级 AI 问答」专题,替核对 AI 回答引用的一方解决分不清「没权限」和「出故障」的问题,故障时引用会被如实上报而不是悄悄丢掉。
  • 出错会怎样:最坏情况是某次故障被报成「暂时不可用」,调用方重试即可;回答里不会多说出任何对象、字段或包的名字,改动可直接撤回。
  • 要你做的:无。

What changes

get_record_context (packages/services/service-record-context) reads each related object of a pack before it answers. At four of those reads, a throw that was not a refusal (an outage, a bug) was answered as PERMISSION_DENIED 403, so the citation verifier (verifyRecordCitations) read it as a refusal and dropped every citation without a report:

Site Before (uncoded throw) After
step 4a, assertApiExposed failure that is not an API-exposure refusal 403 unnamed 503 SERVICE_UNAVAILABLE
step 4a, servedObjectDefinitionOf(child) throwing 403 unnamed 503 SERVICE_UNAVAILABLE
publishedOf, published-definition read throwing 403 unnamed 503 SERVICE_UNAVAILABLE
the child list query throwing the raw error rethrown 503 SERVICE_UNAVAILABLE
  • One classifier, two readers. isCodedRefusal (in record-context-tools.ts, not on the package entry) is the ADR-0112 line: a non-empty string code plus a declared 4xx status (.status, then .statusCode). The executor asks it at all four sites through one helper (refusedOrFailed); the verifier now imports the same function in place of its private copy, so the two can not drift.
  • A coded refusal answers as before. At the three object-level sites it stays PERMISSION_DENIED 403 within the naming bound; a disabled package's OBJECT_PACKAGE_DISABLED (404, coded) is such a refusal. At the child list query the door's own coded refusal is rethrown as the door wrote it, exactly as on main (the child already passed step 4a, so it is served to the caller).
  • A failure names nothing. Its sentence (sentences.ts readFailed, en and zh-Hans) names the pack and the root only. The original error rides on cause for the host (the verifier hands it to onError). Measured: mapDataError (the /data classifier both MCP doors answer with) answers 503 SERVICE_UNAVAILABLE with the error text Internal server error whatever cause holds — tried with no cause, a plain error, a SQLite and a Postgres unique violation, SQLITE_BUSY, and a coded 403.
  • verify-citations.ts: the docblock paragraph that said the executor turns these failures into a 403 was made false by this change and is rewritten.

ADR-0160 (card item 3)

No ADR-0160 sentence fixes 403 for a failed read. The two sentences closest are about refusals only:

Every such refusal carries one code — PERMISSION_DENIED, the code #35145 uses — so the code does not tell a hidden object from a refused one. (D4, "The naming bound")

An object-level refusal names the refused object only when the caller's served schema shows it, and every such refusal carries one code. (point 12)

D3 "Object level" covers refusals by gates and says nothing on reads that fail. So no ADR text has to change for this PR; whether to add a sentence on failures stays with #37490.

Tests

  • record-context-tools.test.ts, new describe "a read of a related object that fails is a failure, not a refusal": one uncoded-throw case per site (503, the exact readFailed sentence, none of the outage's names, the original on cause); a refusal control per object-level site (OBJECT_PACKAGE_DISABLED 404 stays PERMISSION_DENIED 403, unnamed) and for the child query (the door's coded refusal is rethrown unchanged); a driver errno with no status, a coded 5xx, a status with no code, and a thrown string are failures too; the sentence follows the caller's locale. The old case pinning an uncoded served-definition throw as 403 now pins a coded refusal there instead.
  • verify-citations.test.ts: an uncoded throw at the child's served-definition read drops the citation and is reported once through onError (503, cause is the outage); a coded refusal there drops it and reports nothing; a control that verifies the same citation.
  • packages/runtime/src/mcp-record-context-tools-bridge.test.ts, the real-kernel harness: the related list read of rc_revision throws an uncoded error in engine.find; both doors answer the same bytes, SERVICE_UNAVAILABLE 503, with no object name and no outage text in them; the control call reads once the spy is removed.

Acceptance notes

  • What a coded refusal from the child list query does is unchanged (it is rethrown, the door's own text). The card does not ask for that site's refusal path to change, so it is left as it is.
  • The naming-probe read inside the step 4a exposure catch (servedObjectDefinitionOf(...).catch(() => null)) still treats a throw as "not shown". The refusal is a real one, so a throw there only leaves out the object's name.

Verification

Read first, by risk:

  1. record-context-tools.ts refusedOrFailed and the four catch sites that call it.
  2. record-context-tools.ts isCodedRefusal, and verify-citations.ts now importing it.
  3. sentences.ts readFailed.

Two-minute check: pnpm --filter @objectstack/service-record-context exec vitest run --maxWorkers=2 src/__tests__/record-context-tools.test.ts — expect the new describe to pass, all of it.

Readings at head 32aba54598 (this container, shared box):

Package suites, ablation, local gates
  • pnpm --filter @objectstack/service-record-context test + typecheck: Test Files 4 passed (4), Tests 162 passed (162); tsc clean; check:test-typecheck OK. Lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/runtime test (whole suite): Test Files 649 passed (649), Tests 12062 passed, 25 skipped. Lock VERDICT command-exit 0.
  • Ablation on the classifier (isCodedRefusal made to answer "refusal" for every throw, the pre-change reading), via scripts/ablation-replace.mjs (anchor 1 to 0, blob 74d1834cb467 to 496f2990cf29), rebuilt, ablation-dist-preflight marker present in dist index.js and index.cjs: service suites 16 failed / 122 passed (every new outage case, the new verifier pin and the verifier's existing failure cases); runtime harness 1 failed / 24 passed (the new outage case). Restore leg: blob back to 74d1834cb467 equal to HEAD, git diff HEAD empty, tree clean, rebuilt, marker absent from dist: 138/138 and 25/25 pass.
  • dispatch-gates --ran reconciliation: 68 derived, 67 run with exit 0, 1 NOT MEASURED: check:dual-build-cjs-loads exit 3 PREREQUISITE NOT MET (reads every package's dist; this container built only the runtime closure). CI runs it.

Generated by Claude Code

… not a refusal

At the reads of a related object get_record_context judges (step 4a's
exposure check and served definition, a published definition, the child
list query), one helper tells a coded refusal from a failure: a refusal
answers as before, a failure fails the call SERVICE_UNAVAILABLE (503)
naming the pack and the root only, with the original on cause. The
citation verifier reads the same classifier.

Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation 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 1 package(s): @objectstack/service-record-context, touching 14 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/services/service-record-context/package.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/api/client-sdk.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))
  • 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/error-catalog.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))
  • content/docs/automation/hook-bodies.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))
  • content/docs/permissions/system-context.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))
  • content/docs/plugins/development.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))
  • content/docs/protocol/kernel/error-handling.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))
  • content/docs/releases/v18/18-2.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))
  • content/docs/releases/v18/18-3.mdx (via INTERNAL_ERROR (literal, a string literal in executeGetRecordContext))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/services/service-record-context/package.json) — pages documenting those are invisible to this run
  • 1 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 — 0 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 411646562566a1e12b4e0fc3de256192e8302719 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 03d08c1cf2185a12a867e1557c47ee21b6a2e4fc — the merge of head bd03a37ed869418622699397ed127f0dccdceea6 into base 411646562566a1e12b4e0fc3de256192e8302719, 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 03d08c1cf2185a12a867e1557c47ee21b6a2e4fc && git checkout 03d08c1cf2185a12a867e1557c47ee21b6a2e4fc
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 411646562566a1e12b4e0fc3de256192e8302719 bd03a37ed869418622699397ed127f0dccdceea6 && git checkout -B drift-repro 411646562566a1e12b4e0fc3de256192e8302719 && git merge --no-ff bd03a37ed869418622699397ed127f0dccdceea6

node scripts/docs-audit/affected-docs.mjs --json 411646562566a1e12b4e0fc3de256192e8302719

⚠️ 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 411646562566a1e12b4e0fc3de256192e8302719 → 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 32aba54 · 2026-11-26T13:12Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 32aba545983608ea7b5787ffeb82d95c829267e2
Local-runs: none

PR #37550, card #37463. Read: the card and its six comments (os-dev report 7192952275, amendment 7192997436), the PR body, the net diff (7 files), and the head's check-runs (53 completed: 37 success, 16 skipped, 0 failed). Code outside the diff was read, not run.

① Derived judgments

  • Accept set: unchanged. Right. No call that answered before is refused now, and none that was refused answers now. Only the error answer of a failing read moves.
  • One classifier at four sites. Right. isCodedRefusal (non-empty string code and a declared 4xx, .status then .statusCode) is the verifier's old private isRefusal, moved unchanged. refusedOrFailed calls it at the exposure check, the served-definition read, publishedOf and the child list query. It is not on the package entry (src/index.ts), so no export is added.
  • Coded refusals unchanged. Right. The refusals the two real doors throw at these reads all declare a status: OBJECT_API_DISABLED 404, OBJECT_API_METHOD_NOT_ALLOWED 405, OBJECT_PACKAGE_DISABLED 404, PermissionDeniedError 403. The stdio door's FIELD_VISIBILITY_UNRESOLVED 503 moves from 403 to 503, which is correct for a read that could not be evaluated.
  • The 503 leaks nothing. Right. Both MCP doors answer a coded 5xx through mapDataError's declared-5xx arm: code and status kept, sentence replaced by Internal server error. That arm is reached before any arm that reads cause, and the arms before it are keyed on other codes. No stack, path, driver text or child name reaches the wire. The executor's own sentence names the pack and the root only, inside ADR-0160 D4's naming bound.
  • No ADR-0160 amendment owed. Right. D4 "The naming bound" and point 12 fix one code for "every such refusal"; D3 "Object level" covers gates that refuse. No sentence of ADR-0160 speaks of a read that fails. ADR untouched, as the claim fences.
  • Callers. An AI caller on either door reads SERVICE_UNAVAILABLE 503 for an outage and PERMISSION_DENIED 403 for a refusal, so the two are told apart. The verifier drops and reports the first, drops and stays silent on the second. Right, subject to the findings below.
  • Pins. Each of the four sites has its own uncoded-throw case, and its own coded-refusal control. The verifier pin and one real-kernel case on both doors are present. One ablation was run, on the classifier (every throw read as a refusal): 16 service cases and the harness case failed. The opposite direction (a refusal read as a failure) was not ablated; the per-site controls cover it.

M1 (must-fix) — at both MCP doors the outage is logged once, at warn, as a "declared capability absence", and the original error is never logged. dataDoorErrorResult (packages/mcp/src/mcp-http-tools.ts) hands logServerFault the door's code. SERVICE_UNAVAILABLE with a 5xx is on CAPABILITY_ABSENCE_CODES (packages/types/src/server-fault-log.ts), the list for "this deployment did not install that". Such a line is printed once per route per process (the route is tools/call get_record_context plus the root object), at warn, without the error object, so without cause. Every later outage on that root object prints nothing. On main the child list query's raw throw was logged at error on every call with the driver's text; this PR takes that away. The card names the people who debug outages as a beneficiary, and the changeset says the original error is there "for the host". That holds for the verifier's onError only. Fix either by a failure code that is not on the absence list, or by logging the cause at error in the door (that file is outside the claimed surface, so it needs a claim amendment). Pin the log line in the harness case. Read from the three functions; not run.

S1 (should-fix) — the readFailed sentence reaches no MCP caller. The doors withhold a 5xx sentence unless the throw declares it for the caller (refusal: true, or userMessage). The throw declares neither, so the caller reads Internal server error. The en and zh-Hans sentences, the locale test, and the advice "try again later, or read the record with get_record" are in-process only. The changeset reads as if the caller is shown the sentence. Either declare it for the caller and pin it on both doors, or say in the changeset what the doors answer.

S2 (should-fix) — at the child list query, a refusal the door recognises without code-plus-status is now answered as an outage. On main that throw was not caught, so the door classified it. A sandboxed beforeFind hook's plain throw new Error(...) (no code) answered 400 HOOK_ABORTED with the hook's sentence; a code-only PERMISSION_DENIED answered 403. Both now answer 503 Internal server error. The card's wording ("not a coded refusal") and the verifier's rule support the dev's line, so this needs a decision, not a guess: either ask the door's classification at this one site, or rule that a status-less refusal is a failure here and pin it. The query control uses a coded 403 only.

N1 (nit) — the changeset says all four reads were refused PERMISSION_DENIED 403 before. The child list query was not: it answered the door's 500 (the dev's own reading). The PR body's table has it right.

N2 (nit) — every uncoded throw is SERVICE_UNAVAILABLE, a bug included. The error catalog gives that code retry_backoff, so a deterministic bug invites retries. The card allows the code.

② Semver level

  • patch on @objectstack/service-record-context: right. A bug fix, no new entry export, no spec change. SERVICE_UNAVAILABLE 503 is already in the error ledger and the error catalog. The packages/runtime change is a test, so it publishes nothing.
  • Clause-②: no: right, with no arm. Not a widening: nothing new is accepted. Not a narrowing: nothing accepted before is refused now. No published type, protocol doc or skill documents 403 for a failed read; skills/objectstack-ai/references/context-packs.md states 403 for a related object nobody is served, which still holds.
  • Metadata-protocol: none: right. Both lines are line-initial in the PR body and the changeset. Check Changeset passed.

③ Boundary flags

  • open_questions: none filed.
  • Deviation 1 (verify-citations.ts edited): answered by claim amendment 7192997436. Accepted.
  • Deviation 2 (the child query's coded refusal is rethrown as the door wrote it): accepted for coded refusals, as on main. The status-less case is S2, escalated to the area.
  • Deviations 3 and 4 (PR footer, a killed waiter): process only, no contract effect.
  • SQL push-down: no new read, no id materialisation, no in-app join. The diff wraps the one existing child query in a try.
  • No packages/spec/** and no docs/adr/** in the diff, as the claim fences.

Implemented-by: claude/issue-37463-record-context-outage
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: FAIL

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 32aba545983608ea7b5787ffeb82d95c829267e2
REWORK — L1, seat repo:objectstack#5

  1. Shape: open draft against main, Fixes #37463. 7 files, +255/−54. Not governed. Clause-②: no, Metadata-protocol: none, patch; the reviewer confirms this, since no published surface documents the old answer. No review face, so the declaration face applies; the seat ran it on the contract-review tier because it changes an error answer.
  2. Premise: one classifier, isCodedRefusal, now runs at all four sites. Coded refusals are unchanged, and an uncoded throw answers 503 SERVICE_UNAVAILABLE without leaking anything. No ADR-0160 amendment is needed.
  3. Gates: contract record 7193179486 reads FAIL, with one must-fix. CI on this head: 37 success, 16 skipped, 0 failed.
  4. Owed for the delta:
    • M1: the outage now disappears from the server log. SERVICE_UNAVAILABLE with a 5xx is on CAPABILITY_ABSENCE_CODES (packages/types/src/server-fault-log.ts). So dataDoorErrorResult logs it once per root object per process, at warn, as a capability absence, without the error or its cause; on main it was logged at error on every call. Make an outage log at error with its cause on every occurrence. Either answer with a failure code that is not on the capability-absence list, or log the cause in the door. If the fix touches a file outside the claim, amend the claim first. Pin it, with the ablation.
    • S1: the en and zh-Hans readFailed sentences and the "try again later, or use get_record" advice never reach an MCP caller, because both doors replace an undeclared 5xx sentence with Internal server error. Either make the changeset and PR body say what the caller actually sees, or carry the sentence to the caller. The seat prefers the first; it is cheaper and honest.
    • S2: the seat rules here. A child-query throw that main already answered as a refusal stays a refusal. That means a sandboxed beforeFind hook's plain throw keeps 400 HOOK_ABORTED, and a code-only PERMISSION_DENIED keeps 403. Only a truly uncoded failure becomes 503. Pin both cases.
    • N1 (the changeset misstates the child query's old answer): fix it with S1. N2 (a bug also reads as a retryable 503) is accepted.
  5. Out of scope and where it went: none.
  6. Next: push, then knock. The same reviewer reads M1, S1 and S2. After ACCEPT, area ai-36996 lands it.

…lt; door refusals at the list read stay

A failure at a related object's read now answers INTERNAL_ERROR (500):
SERVICE_UNAVAILABLE with a 5xx is a declared capability absence the
doors log once per route at warn without the error. At the child list
query the executor asks the /data door's own classifier (mapDataError),
so a sandboxed hook's plain throw stays 400 HOOK_ABORTED and a
status-less PERMISSION_DENIED stays 403; only a door fault fails.

Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
Co-authored-by: Claude <noreply@anthropic.com>
…he door's refusals at the list read

The doors' fault line prints an error's message and stack, never its
cause, so the failure's stack ends with the original. The harness pins
an error line per call per door with the outage in it, and the two
refusals the /data door answers below 500 at the list read.

Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation 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.

37418 跟进:资料包读取把关联对象的故障当作「无权」拒绝,故障应如实报出且不泄露

2 participants