Repository navigation
feat(spec,service-record-context): the record citation shape, and the verifier that checks a quote as the asking user (ADR-0160 D9) - #37396
Conversation
…verifier (ADR-0160 D9) Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
…e, and add the changeset Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
📓 Docs Drift CheckThis PR changes 2 package(s): 6 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 3d99d201fafbeece3646399bd8ab6c5c1ff2a981 && git checkout 3d99d201fafbeece3646399bd8ab6c5c1ff2a981
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5bf724223cabc05aecbc0f2130c0dafcdf467e1c 8471b77d705d386251204a83ee11281712e47074 && git checkout -B drift-repro 5bf724223cabc05aecbc0f2130c0dafcdf467e1c && git merge --no-ff 8471b77d705d386251204a83ee11281712e47074
node scripts/docs-audit/affected-docs.mjs --json 5bf724223cabc05aecbc0f2130c0dafcdf467e1c
|
…entory Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 8471b77 · 2026-11-26T03:00Z 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: Inputs read: card #37364 (body, 4 comments, os-dev report 7181284963), PR #37396 body, the net diff ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Findings: S1 (should-fix) — A failure that is not a refusal is dropped the same way as a refusal, with no signal. S2 (should-fix) — Two kinds of record material inside the data member are never matched, and neither the card nor D9 rules on them: a non-string N1 (nit) — N2 (nit) — The PR body says tag-stripping "only makes verification stricter, never looser". That is not exact: removing tags with nothing in their place joins adjacent elements, so N3 (nit) — N4 (nit) — A citation with an N5 (nit) — A one-character quote parses ( N6 (nit) — All distinct tuples are read at once: up to 20 concurrent No must-fix. Both should-fix findings are questions for the seat to settle before cloud 10c reads the verifier; neither makes the code disagree with the card or with D9. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Seat ruling on the record's two should-fix findings (record 7181386892)The seat settles both by card scope. Neither needs a code change on this head.
The same reviewer re-reads this head with these two rulings in hand. |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: This record replaces the earlier one on the same head (7181386892); the head is unchanged. Inputs read: card #37364 (body, 4 comments, os-dev report 7181284963), PR #37396 body, the seat's ruling 7181397348 on the PR, follow-up card #37418, the net diff ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Findings: S1: closed — settled by the seat's ruling (PR comment 7181397348) on card scope. The card orders "Any refusal ⇒ not verified … never throws per citation", and this head fails closed, which is what it asks. Telling an outage from a refusal is filed as follow-up #37418 (open, S2: closed — settled by the same ruling. ADR-0160 D9 on N1 (nit) — N2 (nit) — The PR body says tag-stripping "only makes verification stricter, never looser". That is not exact: removing tags with nothing in their place joins adjacent elements, so N3 (nit) — N4 (nit) — A citation with an N5 (nit) — A one-character quote parses ( N6 (nit) — All distinct tuples are read at once: up to 20 concurrent No must-fix. S1 and S2 are closed by the seat's ruling 7181397348, and S1's substance is carried by #37418. Six nits remain; none affects correctness or the contract, and N1 to N3 ride #37418. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Landing: ACCEPT 7181455245 (L2 PASS re-record 7181443752) at head
Status: ready + auto-merge (merge queue). On MERGED, #37364 closes by |
|
repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc Dequeued (CI_FAILURE) from merge group |
Fixes #37364
Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #37177
维护者速读
What changes
Governing text: ADR-0160 D9 as amended by #37370 (third amendment), ruling 7177410380 on #37144 (Q1 A, Q2 A, Q3 A), ADR point 23.
Spec (
@objectstack/spec/ai)record-citation.zod.ts(new):RecordCitationSchema={ object, id, context?, anchor?, quote }, closed withstrictObject(unknown key refused, near-miss aliases such asobjectName/recordId/pack/section/text), every stringmin(1).RecordCitationsSchema= an array of at mostRECORD_CITATIONS_MAX(20).RECORD_CITATIONS_PART_TYPE = 'data-record-citations': the UI-message data part that carries the verified list (the precedent isBUILD_PROGRESS_FRAME_TYPE).record-body-anchor.ts(new):headingsOfandslugOfmoved here unchanged fromservice-record-context/src/body-outline.ts, together with the private readers they need. This way the server and the console derive the same anchor.slugOfstays module-private, as before. The tag readerheadingsOfalready used is exported asstripBodyTags, because the verifier matches an html body with the same notion of a tag.authorable-surface/ai.json(5RecordCitationrows),json-schema.manifest,api-surface,export-origins,declaration-map,content/docs/references/ai/*, and the strictness-ledger count (ai/113 to 114), all written bycheck:generated --fix.Service (
@objectstack/service-record-context)body-outline.tsre-importsheadingsOfandBodyHeadingfrom spec and re-exports them.body-outline.test.tspasses untouched.verify-citations.ts(new),verifyRecordCitations(citations, door), exported fromsrc/index.ts. It never persists or renders.The matching rule, which ADR-0160 D9 leaves to row 10 and which the card's What 3 settles. A citation survives only when its trimmed
quoteis a substring of one of these data-member strings ofget_record_context's answer for its(object, id, context, anchor), read through the door bound to the asking user:valuewhen it is a string, and itsdisplay, at the root and in every related-list cell (Q3: a related-row quote is cited on the root record);body.text(the whole body, or the sectionanchornamed). Anhtml/richtextbody (judged by the type the caller is served) is also matched with its tags removed.Whitespace runs collapse to one space on both sides. Case and every other character must agree. These are never matched: notes, the framing sentence, any label, the pack/record header (
pack.*,record.*, a row'sdisplayName), outline headings, and a value that is not a string (a number, boolean, list or object; itsdisplayis matched where present). A quote that is empty once trimmed verifies nothing.What the verifier does with the list. It makes one
executeGetRecordContextcall per distinct tuple. Any refused call drops its citations (point 23): acontextno pack has, several packs and nocontext(Q2), an anchor that does not resolve, a record the caller cannot read or that does not exist, an object not served, guarded or unexposed. No retry without the offending argument. An entry that does not parse is dropped, and only the first 20 entries are read. The result is the verified subset in input order, with no reason attached, so a hidden record and a missing one look alike.Read first (by risk)
packages/services/service-record-context/src/verify-citations.ts:haystackOfholds the matching rule above. The risky part is which strings it collects.packages/spec/src/ai/record-citation.zod.ts: the public shape, the aliases and the cap of 20.packages/services/service-record-context/src/body-outline.ts: the move. Byte-identical logic now lives inpackages/spec/src/ai/record-body-anchor.ts(onlystripTagswas renamed to the exportedstripBodyTags).Tests
packages/spec/src/ai/record-citation.test.ts(6): the shape refuses an unknown key (unrecognized_keys), an emptyquote(too_small), a missingquoteandnull(invalid_type), an emptycontext/anchor. It admitscontextandanchor. The list is capped at 20 (too_big). The part type is pinned.packages/services/service-record-context/src/__tests__/verify-citations.test.ts(16), one per acceptance bullet plus the rule. Each "dropped" case has a control leg:contextrefused, one pack verified, named packs verified, unknown pack refused;[];listCalls= 2 for 5 citations), unparsable entries dropped, cap of 20, html/richtext tag-stripped and markdown not, whitespace collapse, non-string value not matched.Readings (head 36ec0cf)
pnpm --filter @objectstack/service-record-context test: Test Files 3 passed (3), Tests 115 passed (115).typecheck: exit 0.pnpm --filter @objectstack/spec test: first run on c46e26d had 1 failure,alias-integrity.test.ts(aliasesrecordIdandrecord_idcollapse onto one probe). Fixed in 36ec0cf by droppingrecord_id. Re-run of that file plusrecord-citation.test.ts: 26/26. The final full-suite reading is in the report.pnpm --filter @objectstack/spec typecheck: exit 0.scripts/ablation-replace.mjsmadehaystackOfalso collectanswer.framing, the note texts andpack.label. Result: anchor 1 to 0, blob c35fc729 to dcec1804, andrefuses a quote that appears only in a note, the framing, or a labelwent red (1 failed / 15 passed). Restored: blob equals HEAD,git diff HEADempty. A first attempt was a no-op that the tool refused before running: its replacement contained the anchor. The test runssrcdirectly, so no dist rebuild was needed for the mutated file.Acceptance notes
headingsOfreads heading text. So a quote that spans two paragraph elements, written with a space where the two paragraphs meet, is not verified. HTML entities in the body are not decoded either: an ampersand entity has to be quoted as the entity. Both follow the card's rule as written. They only make verification stricter, never looser.packages/spec/export-origins/ai.json. Whichever PR lands second regenerates it.Verification
Two minutes:
pnpm --filter @objectstack/service-record-context exec vitest run --maxWorkers=2 src/__tests__/verify-citations.test.ts. Expect 16 passed. Thecontext (Q2)block shows a two-pack object dropping a citation that has nocontext.Generated by Claude Code