Repository navigation
fix(record-context): a related object's read that fails is a failure, not a refusal - #37550
Conversation
… 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>
📓 Docs Drift CheckThis PR changes 1 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 0 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 1b5162a9cf2d320c2424ff7b79307e70b47646c5 && git checkout 1b5162a9cf2d320c2424ff7b79307e70b47646c5
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 58570d8002dd213f7f65525d881ac935583f4050 007615908a5a15466ef2ae3724885d009e8fb213 && git checkout -B drift-repro 58570d8002dd213f7f65525d881ac935583f4050 && git merge --no-ff 007615908a5a15466ef2ae3724885d009e8fb213
node scripts/docs-audit/affected-docs.mjs --json 58570d8002dd213f7f65525d881ac935583f4050
|
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 32aba54 · 2026-11-26T13:12Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: 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
M1 (must-fix) — at both MCP doors the outage is logged once, at S1 (should-fix) — the S2 (should-fix) — at the child list query, a refusal the door recognises without code-plus-status is now answered as an outage. On N1 (nit) — the changeset says all four reads were refused N2 (nit) — every uncoded throw is ② Semver level
③ Boundary flags
Implemented-by: VERDICT: FAIL |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
…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>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Delta review of PR #37550 (card #37463) against my record on ① Derived judgmentsPrior findings:
Check 1, the
Check 2, what
S3 (should-fix) — at the child list query, a fault the door answered with its own code is now N3 (nit) — the predicate asks Unchanged from the first record and still right: the accept set, the classifier at the object-level sites, no leak in the 5xx answer ( ② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对 (delta)Head-sha:
|
…d list query A throw the door answers with a code or sentence of its own (ERR_DATASOURCE_UNAVAILABLE 503, DATABASE_ERROR, a driver's NOT_IMPLEMENTED 501, a declared 5xx with its sentence) is rethrown as the door reads it, asked of the same classifier (doorAnswersItself). Only the door's anonymous 500 fails the call INTERNAL_ERROR. Pinned in the unit suite and on both MCP doors; the changeset says 500 applies to an uncoded failure. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Second delta review of PR #37550 (card #37463) against my record on ① Derived judgments
The check asked for, whether "the door's anonymous answer" is detected robustly: yes.
No new finding. ② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对 (delta 2)Head-sha:
|
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Landing: ACCEPT 7197085445 (second delta contract record 7197072679, PASS; L2 at contract-review tier, fable) at head
Status: ready + auto-merge (merge queue). On MERGED, #37463 closes by |
Fixes #37463
Clause-②: no
Metadata-protocol: none
维护者速读
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 misanswered. At three of them it came back asPERMISSION_DENIED403, so the citation verifier (verifyRecordCitations) read it as a refusal and dropped every citation without a report:assertApiExposedfailure that is not a coded refusalINTERNAL_ERRORservedObjectDefinitionOf(child)throwingINTERNAL_ERRORpublishedOf, published-definition read throwingINTERNAL_ERROR/datadoor answers it500 Internal server errorand nothing else)INTERNAL_ERRORINTERNAL_ERROR, the original at the foot of the stackERR_DATASOURCE_UNAVAILABLE503,DATABASE_ERROR,NOT_IMPLEMENTED501, a declared 5xx with its sentence)refusedOrFaileddecides refusal vs failure at all four sites. At the three object-level sites it asksisCodedRefusal(inrecord-context-tools.ts, not on the package entry): the ADR-0112 line, a non-empty stringcodeplus a declared 4xx status (.status, then.statusCode). The verifier imports the same function in place of its private copy. At the child list query it asksdoorAnswersItself, which reads the/datadoor's own classifier,mapDataErrorfrom@objectstack/types(new as a dependency of this package). Before this change the doors classified that read's throw themselves, so the executor asks them rather than keeping a second reader (seat ruling, REWORK 7193191377 S2). The door answers a throw itself unless its answer is the anonymous fault: status 500,Internal server error, codedINTERNAL_ERRORor not coded, and nothing else (REWORK 7195238190 S3).PERMISSION_DENIED403 within the naming bound; a disabled package'sOBJECT_PACKAGE_DISABLED(404, coded) is such a refusal. At the child list query, a throw the door answers itself is rethrown untouched, exactly as onmain, with its own code and sentence. A sandboxedbeforeFindhook's plain throw stays400 HOOK_ABORTEDin the hook's words, and aPERMISSION_DENIEDwith no status stays the door'sPERMISSION_DENIED. A fault the door codes stays the door's answer too: an unavailable datasource staysERR_DATASOURCE_UNAVAILABLE503 with its sentence (the caller keeps the retry signal), a driver error the door recognises staysDATABASE_ERROR, a driver's declaredNOT_IMPLEMENTEDstays 501, and a declared 5xx keeps its code and the sentence oruserMessageits producer declared.INTERNAL_ERROR500 applies there to an uncoded failure only.INTERNAL_ERROR500, notSERVICE_UNAVAILABLE503. With a 5xx,SERVICE_UNAVAILABLEis onCAPABILITY_ABSENCE_CODES(packages/types/src/server-fault-log.ts), and the doors' fault line logs that code once per route per process, atwarn, without the error (record 7193179486, M1). WithINTERNAL_ERROR, each door logs the failure aterroron every call. The fault line prints an error's message and stack and never itscause(both the console sink andObjectLogger), so the failure's stack ends inCaused by:plus the original's stack. The original is also oncausefor an in-process host; the verifier hands it toonError. A stack never reaches the wire.{ code: 'INTERNAL_ERROR', status: 500 }with the messageInternal server error. The doors withhold a 5xx's own sentence, so the executor'sreadFailedsentence (en and zh-Hans; it names the pack and the root only) is read in-process only. Measured onmapDataError: the answer is500 INTERNAL_ERRORInternal server errorwhatevercauseholds. 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 this change made false is rewritten (claim amendment 7192997436).ADR-0160 (card item 3)
No ADR-0160 sentence fixes 403 for a failed read. The two sentences closest are about refusals only:
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.tshas a newdescribe, "a read of a related object that fails is a failure, not a refusal". It has one uncoded-throw case per site: 500, the exactreadFailedsentence, none of the outage's names, the original oncause, andCaused by:plus the original's stack in the failure's stack. It has a refusal control per object-level site (OBJECT_PACKAGE_DISABLED404 staysPERMISSION_DENIED403, unnamed) and for the child query (a coded refusal is rethrown unchanged). For S2: a sandboxed hook's plain throw (innerMessage) and a status-lessPERMISSION_DENIEDat the child query are rethrown untouched, while the same throws at an object-level read fail the call. A sandboxed body that crashed (a native error name) is a fault at the door, so it fails the call. At an object-level read, a driver errno with no status, a coded 5xx, a status with no code, and a thrown string are failures too. For S3, at the child query: an unavailable datasource (503), a driver error the door answersDATABASE_ERROR, a declaredNOT_IMPLEMENTED501, and a declared 5xx with its sentence or auserMessageare rethrown as the same object; each case first asserts the door's own answer for it (mapDataError). The controls there (a status-less 500, a codedINTERNAL_ERROR500, an errno the door does not recognise, a thrown string), which the door answers with nothing of its own, fail the call. The sentence follows the caller's locale.verify-citations.test.ts: an uncoded throw at the child's served-definition read drops the citation and is reported once throughonError(500, cause is the outage). A coded refusal there drops it and reports nothing. A control verifies the same citation.packages/runtime/src/mcp-record-context-tools-bridge.test.tsis the real-kernel harness, run on both doors. Outage: the related-list read ofrc_revisionthrows an uncoded error inengine.find. Asked twice, there are four[5xx] 500error lines (two doors times two calls), each carryingINTERNAL_ERRORandCaused by: Error: OUTAGE_TEXT(the thrown outage) in its stack, and no capability-absence warning. Both doors answer the same bytes,INTERNAL_ERROR500, with no object name and no outage text. S2, at the same read: a sandboxed hook's plain throw answersHOOK_ABORTED400 in the hook's words, and a status-lessPERMISSION_DENIEDanswersPERMISSION_DENIEDand never a 5xx. S3, at the same read: anERR_DATASOURCE_UNAVAILABLEthrow answersERR_DATASOURCE_UNAVAILABLE503 with its sentence on both doors, each door logs one[5xx] 503line, and no line carriesINTERNAL_ERROR. Each case has a control that reads once the spy is removed.Acceptance notes
main, so the citation verifier still reports a status-less one (PERMISSION_DENIEDwith no status, or a hook abort with no code) throughonError, as it did onmain. The verifier's rule (a stringcodeplus a declared 4xx) is unchanged.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.INTERNAL_ERROR500, a bug included (N2 is accepted by the seat).Verification
Read first, by risk:
record-context-tools.ts:refusedOrFailed, the fourcatchsites that call it, anddoorAnswersItself, the child list query's predicate.record-context-tools.tsisCodedRefusal, andverify-citations.tsimporting it.packages/services/service-record-context/package.jsonandpnpm-lock.yaml: one workspace dependency,@objectstack/types.Two-minute check:
pnpm --filter @objectstack/service-record-context exec vitest run --maxWorkers=2 src/__tests__/record-context-tools.test.ts. Expect the newdescribeto pass, every case.Readings at head
007615908a(this container, shared box):Package suites, ablations, local gates, CI
pnpm --filter @objectstack/service-record-context test+typecheck: Test Files 4 passed (4), Tests 174 passed (174); tsc clean; check:test-typecheck OK.pnpm --filter @objectstack/runtime test(whole suite): Test Files 649 passed (649), Tests 12065 passed, 25 skipped. Lock VERDICT command-exit 0.scripts/ablation-replace.mjs: the child list query's predicate reverted to the round-2 line, "the door answers below 500" (blob 756d30378a88 to cb3d0801619c), rebuilt, marker present in dist (preflight exit 0). Service 5 failed / 145 passed (the five coded-fault cases), harness 1 failed / 27 passed (theERR_DATASOURCE_UNAVAILABLEcase: the answer wasINTERNAL_ERROR). Restore leg: blob back to 756d30378a88, equal to HEAD;git diff HEADempty; rebuilt; marker absent (preflight--absentexit 0); 150/150 and 28/28 pass.bd03a37ed8and not rerun at this head; this commit changes only the child query's predicate. There, M1 failed the harness at the fault-line pin and S2 failed all four S2 cases.dispatch-gates --ran: 83 derived, 82 run with exit 0, 1 NOT MEASURED:check:dual-build-cjs-loads, exit 3, PREREQUISITE NOT MET (it needs every package's dist). The derivation warned the tree is 23 commits behindorigin/mainwith 7 gate files changed there; CI runs the current gates.origin/main, feat(core): requires knowledge mounts the knowledge service and one vector store #37442 onpnpm-lock.yaml, chore: version packages (next) #35129 onpackage.json).007615908a: 69 check-runs, 60 success, 9 skipped, 0 failure. Every required context is green, the UI ones and Check Changeset included.Generated by Claude Code