Skip to content

feat(spec,service-record-context): the record citation shape, and the verifier that checks a quote as the asking user (ADR-0160 D9) - #37396

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-37364-record-citation-verifier
Nov 26, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-37364-record-citation-verifier

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #37364

Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #37177

维护者速读

  • 用户能看到什么变化:用户无感。本次只交付"引用"的格式定义和核对器;AI 回答里的引用还没有产生方,也没有界面展示。
  • 为什么做:记录范围 AI 问询专题的第 10 行前半(引用格式与核对器),按维护者已定的三条裁决实现;界面展示和云端产生引用两张后续卡依赖它。
  • 出错会怎样:最坏是核对器把一条真实的引用判为"未核对通过"而丢掉,回答少一条引用;它以提问人本人的权限读记录,不会让提问人看到无权看的内容;撤回此 PR 即可,没有数据需要迁移。
  • 要你做什么:无。

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 with strictObject (unknown key refused, near-miss aliases such as objectName/recordId/pack/section/text), every string min(1). RecordCitationsSchema = an array of at most RECORD_CITATIONS_MAX (20). RECORD_CITATIONS_PART_TYPE = 'data-record-citations': the UI-message data part that carries the verified list (the precedent is BUILD_PROGRESS_FRAME_TYPE).
  • record-body-anchor.ts (new): headingsOf and slugOf moved here unchanged from service-record-context/src/body-outline.ts, together with the private readers they need. This way the server and the console derive the same anchor. slugOf stays module-private, as before. The tag reader headingsOf already used is exported as stripBodyTags, because the verifier matches an html body with the same notion of a tag.
  • Generated: authorable-surface/ai.json (5 RecordCitation rows), json-schema.manifest, api-surface, export-origins, declaration-map, content/docs/references/ai/*, and the strictness-ledger count (ai/ 113 to 114), all written by check:generated --fix.

Service (@objectstack/service-record-context)

  • body-outline.ts re-imports headingsOf and BodyHeading from spec and re-exports them. body-outline.test.ts passes untouched.
  • verify-citations.ts (new), verifyRecordCitations(citations, door), exported from src/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 quote is a substring of one of these data-member strings of get_record_context's answer for its (object, id, context, anchor), read through the door bound to the asking user:

  • a field entry's value when it is a string, and its display, 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 section anchor named). An html/richtext body (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's displayName), outline headings, and a value that is not a string (a number, boolean, list or object; its display is matched where present). A quote that is empty once trimmed verifies nothing.

What the verifier does with the list. It makes one executeGetRecordContext call per distinct tuple. Any refused call drops its citations (point 23): a context no pack has, several packs and no context (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)
  1. packages/services/service-record-context/src/verify-citations.ts: haystackOf holds the matching rule above. The risky part is which strings it collects.
  2. packages/spec/src/ai/record-citation.zod.ts: the public shape, the aliases and the cap of 20.
  3. packages/services/service-record-context/src/body-outline.ts: the move. Byte-identical logic now lives in packages/spec/src/ai/record-body-anchor.ts (only stripTags was renamed to the exported stripBodyTags).

Tests

  • packages/spec/src/ai/record-citation.test.ts (6): the shape refuses an unknown key (unrecognized_keys), an empty quote (too_small), a missing quote and null (invalid_type), an empty context/anchor. It admits context and anchor. 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:
    • section by anchor verified, stale anchor refused, anchor scopes the match;
    • related-list cell verified on the root, while another policy's row is not;
    • note, framing and labels refused (the control shows the answer carries each);
    • withheld and hidden field refused (the control verifies the same quote unhidden);
    • outline body without anchor refused, the same quote with its anchor verified;
    • two packs without context refused, one pack verified, named packs verified, unknown pack refused;
    • no read access (unreadable row, missing id, unserved, guarded, unexposed object) all answer [];
    • one call per distinct tuple (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 (aliases recordId and record_id collapse onto one probe). Fixed in 36ec0cf by dropping record_id. Re-run of that file plus record-citation.test.ts: 26/26. The final full-suite reading is in the report.
  • pnpm --filter @objectstack/spec typecheck: exit 0.
  • Ablation, one behaviour (the data-member restriction): scripts/ablation-replace.mjs made haystackOf also collect answer.framing, the note texts and pack.label. Result: anchor 1 to 0, blob c35fc729 to dcec1804, and refuses a quote that appears only in a note, the framing, or a label went red (1 failed / 15 passed). Restored: blob equals HEAD, git diff HEAD empty. A first attempt was a no-op that the tool refused before running: its replacement contained the anchor. The test runs src directly, so no dist rebuild was needed for the mutated file.

Acceptance notes

  • The cap of 20 is the card's "an array with a cap" turned into a number. It bounds both how many calls a model's list can trigger and the persisted list. Easy to change before 10b/10c read it.
  • Tag-stripping removes a tag with nothing in its place, as headingsOf reads 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.
  • Overlap: refactor(spec)!: rename the Studio helper defineForm to defineMetadataForm and its modules to *.metadata-form.ts #37366 also writes the generated packages/spec/export-origins/ai.json. Whichever PR lands second regenerates it.
  • Out of scope, as the card says: an MCP verify tool, rendering (10b), producing and persisting citations (cloud 10c).

Verification

Two minutes: pnpm --filter @objectstack/service-record-context exec vitest run --maxWorkers=2 src/__tests__/verify-citations.test.ts. Expect 16 passed. The context (Q2) block shows a two-pack object dropping a citation that has no context.


Generated by Claude Code

@github-actions github-actions Bot added size/xl 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 26 documentable anchor(s). ⚠️ 8 changed file(s) yielded no anchor (packages/services/service-record-context/src/index.ts, packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/automation/flows.mdx (via isBlank (symbol, a top-level const))
  • content/docs/data-modeling/formulas.mdx (via isBlank (symbol, a top-level const))
  • content/docs/data-modeling/object-extensions.mdx (via isBlank (symbol, a top-level const))
  • content/docs/data-modeling/seed-data.mdx (via isBlank (symbol, a top-level const))
  • content/docs/data-modeling/validation.mdx (via isBlank (symbol, a top-level const))
  • content/docs/protocol/objectql/schema.mdx (via isBlank (symbol, a top-level const))
What this run could not see
  • 8 changed file(s) yielded no anchor (packages/services/service-record-context/src/index.ts, packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, …) — pages documenting those are invisible to this run
  • 4 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 5bf724223cabc05aecbc0f2130c0dafcdf467e1c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 3d99d201fafbeece3646399bd8ab6c5c1ff2a981 — the merge of head 8471b77d705d386251204a83ee11281712e47074 into base 5bf724223cabc05aecbc0f2130c0dafcdf467e1c, 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 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

⚠️ 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 5bf724223cabc05aecbc0f2130c0dafcdf467e1c → 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 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.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8471b77d705d386251204a83ee11281712e47074
Local-runs: none
Scope: packages/spec/src/ai/index.ts, packages/spec/src/ai/record-body-anchor.ts, packages/spec/src/ai/record-citation.zod.ts + packages/services/service-record-context/src/verify-citations.ts, packages/services/service-record-context/src/body-outline.ts, packages/services/service-record-context/src/index.ts, packages/services/service-record-context/src/tests/verify-citations.test.ts, packages/spec/src/ai/record-citation.test.ts
Security-touching: yes
Rule-change-verified: none

Inputs read: card #37364 (body, 4 comments, os-dev report 7181284963), PR #37396 body, the net diff origin/main...pr-37396 (20 files, +853/−177), ADR-0160 on origin/main (third amendment, merged as db77cc4: D9, point 23), and the 70 check-runs on the head (60 success, 10 skipped, 0 failed). Code outside the diff (record-context-tools.ts, door.ts, record-context-tools.zod.ts, strict-object.ts) was read, not reviewed.

① Derived judgments

  • Accept-set, RecordCitationSchema: right. { object, id, context?, anchor?, quote }, every string min(1), closed by strictObject. It is D9's shape as amended (context optional, anchor optional). min(1) on context and anchor mirrors GetRecordContextInputSchema, which the verifying call would refuse an empty string on anyway. The aliases only feed the "did you mean" message; they admit nothing.
  • Accept-set, RecordCitationsSchema (max 20): right, a card-ordered number. D9 names no cap; the card orders "an array with a cap". The PR states the number in its Acceptance notes.
  • Public surface, @objectstack/spec/ai: 11 new exports, right. Eight for the citation (RecordCitation*, RECORD_CITATIONS_MAX, RECORD_CITATIONS_PART_TYPE) and three for the anchor (headingsOf, BodyHeading, stripBodyTags). api-surface, export-origins, declaration-map, json-schema.manifest (2 rows) and authorable-surface (5 rows) agree with the source.
  • Public surface, @objectstack/service-record-context: one new export, verifyRecordCitations. Right.
  • The headingsOf move is behaviour-preserving. A text diff of the removed block against record-body-anchor.ts shows three differences only: stripTags renamed to the exported stripBodyTags, its one call site, and two jsdoc lines. slugOf, decodeEntities, htmlHeadingsOf, markdownHeadingOf and isFence are byte-identical. body-outline.ts re-exports headingsOf and BodyHeading, so its own importers are unchanged.
  • Generated counts: right. llms.txt (ai 16 to 17, total 230 to 231), the docs reference (17 pages, 102 schemas, total 1735) and the strictness ledger (ai/ 113 to 114) each follow from one new *.zod.ts module with two schemas and one strictObject site.

② Semver level

  • @objectstack/spec minor and @objectstack/service-record-context minor: right. Both are additive; nothing is removed or narrowed.
  • Clause-②: yes: correct. A new published schema and new public exports enter spec.
  • Metadata-protocol: added: correct. authorable-surface/ai.json gains the five ai/RecordCitation:* rows, and ADR-0160's execution table says added for row 10 "when the shape enters spec".
  • Skills-docs: follow-up #37177: the card is open. It is about teaching authors to write context packs; a citation is written by a model, not an author, so nothing more is owed here.

③ Boundary flags

  • Dev deviation, llms.txt and the strictness-ledger count outside the claimed surface: accepted. Both are forced by the new module (check:llms-txt, check:strictness-ledger), and both are counts that follow from the diff.
  • Dev deviation, stripBodyTags exported: accepted, see N3. The verifier and the anchor derivation share one notion of a tag, which is the reason the card moved headingsOf in the first place.
  • Dev deviation, PR body Readings written at 36ec0cf: accepted. The final-head readings are in the report, and the check-runs on 8471b77 are the gate verdicts. The seat may patch the PR body.
  • Dev deviation, pushed after overlap-check exit 1: accepted. The only overlap with refactor(spec)!: rename the Studio helper defineForm to defineMetadataForm and its modules to *.metadata-form.ts #37366 is the generated export-origins/ai.json; the second lander regenerates it.
  • open_questions: none. security_findings: none; this review agrees (④, security).
  • Out-of-scope note (tag-stripping joins adjacent elements, entities not decoded): answered in N2.
  • SQL push-down: no finding. The verifier adds no read of its own. It calls executeGetRecordContext, and the substring match has to run on the answer as projected for the caller, which SQL cannot see. No id is materialised and nothing is joined in the app.

④ Design judgment

record-citation.zod.ts against ADR-0160 D9 and its first consumer. The shape holds. ADR-0049 is met for RecordCitationSchema: verifyRecordCitations parses every entry with it in this same PR.

verify-citations.ts against D9 and point 23.

  • As the asking user, through the tool's own path: holds. The verifier builds no door and no context. It hands the door it was given to executeGetRecordContext, the one executor every transport uses, so the read guard, API exposure, the served definition, pack selection, the field projection and the anchor resolution all run as they do for a tool call. Its one other read, servedObjectDefinitionOf for the body's type, also goes through the door. door.ts states the door is bound by its host to one caller with no system context. The verifier cannot check which caller that is: binding the asking user's door is the producer's duty (cloud 10c), and that card should say so.
  • Refusals drop (point 23): holds. Every throw of the executor becomes undefined, and its citations are dropped. No call is retried without an argument. The tests cover an unknown pack, several packs without context, a stale anchor, and five no-access shapes.
  • The haystack is the data member's record strings: holds, and excluding notes, framing and labels is right. notes and framing are siblings of data in GetRecordContextOutputSchema, so D9's "the data member" excludes them by structure. Labels sit inside data but are metadata the caller's locale picks; a quote found in a label says nothing about the record, and the card's What 3 rules "labels never count". The ablation in the report (reading notes, framing and the pack label turns one test red) pins the rule.
  • Security: no finding. The verifier answers no more than the tool the same user can call: it returns the citations the model wrote, never text from the answer, and every drop looks alike, so it tells less than a direct call (which separates not-found from refused). Time to answer varies with the same early refusals the tool already has. A masked, withheld or hidden field has no value in the answer, so nothing matches in it (tested for withheld and hidden).

Findings:

S1 (should-fix) — A failure that is not a refusal is dropped the same way as a refusal, with no signal. haystackOf catches every throw, so a database outage or a bug in a door drops every citation of the answer, and because D9 verifies once and never again, the loss is permanent. This fails closed and matches the card ("never throws per citation"), so it does not block. Before 10c wires the producer, the verifier should let the host tell the two apart (for example, treat only an error carrying an ADR-0112 code as a refusal and report the rest through a callback or a log), or the card should record that the loss is accepted.

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 value (a number or boolean, so premium: 1200 cannot be cited as "1200"), and the names record.displayName and a related row's displayName. D9 says the quote is matched "across the whole data member"; the card narrows that to value/display/body.text and to strings. The PR follows the card and says so, and the effect is stricter only (a true citation dropped, never a false one kept), so it does not block. Amounts and row names are among the facts a model is most likely to cite; the seat should confirm or widen the rule before 10c produces citations, and record the answer on the ADR or the card.

N1 (nit) — RecordCitationsSchema and RECORD_CITATIONS_PART_TYPE have no reader in this PR: the verifier takes unknown, slices to RECORD_CITATIONS_MAX and never parses the list schema. The card orders both, and their readers are 10b and 10c, so ADR-0049 is met for row 10 as a whole. The two treat an over-long list differently (the schema refuses 21 entries, the verifier reads the first 20); 10c should know which one it gets.

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 <td>100</td><td>200</td> also verifies the quote "100200", and the as-stored match verifies a quote taken from an attribute value. Both strings are text the tool returned, so D9 holds; the sentence should be corrected.

N3 (nit) — stripBodyTags is now public API of @objectstack/spec/ai. It is not a sanitizer (script content stays, an unclosed < stays); one jsdoc line saying so would stop a later reader using it as one.

N4 (nit) — A citation with an anchor verifies when its quote sits in a field or a related cell and not in the cited section, because the answer for that call carries all three. This is D9 as written ("the data member of the answer"). The surface in 10b will then open the record at a section that does not hold the quote.

N5 (nit) — A one-character quote parses (min(1)) and verifies against almost any record. D9 sets no minimum; noted for 10b/10c.

N6 (nit) — All distinct tuples are read at once: up to 20 concurrent get_record_context executions, each with its own pack listing and child queries. The bound is fixed and the reads run as the user; a sequential or small-pool loop would be kinder to the database.

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: claude/issue-37364-record-citation-verifier
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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.

  • S1 (an outage drops citations exactly like a refusal does): the card asks for "Any refusal ⇒ not verified … never throws per citation", and failing closed is what this head does. Telling an outage apart from a refusal before the answer is shown is a host concern for row 10c, where the verifier is bound to the asking user's door. The area files it as a follow-up card under 专题:记录范围 AI 问询(在一条记录上问 AI:对话钉在这条记录上、平台按配置交给模型这条记录的资料、外部 AI 经 MCP 拿到同一份) #36996, and 10c depends on that card.
  • S2 (non-string values and displayName are never matched): ADR-0160 D9 (third amendment) leaves "which strings of the data member the quote is matched against and how a value that is not text is compared" to row 10. This card is row 10a, and it decides exactly that: a field or related-list cell value/display, or body.text. The PR follows the card and does not go past D9. A wider matcher would be a new decision for a later row.

The same reviewer re-reads this head with these two rulings in hand.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8471b77d705d386251204a83ee11281712e47074
Local-runs: none
Scope: packages/spec/src/ai/index.ts, packages/spec/src/ai/record-body-anchor.ts, packages/spec/src/ai/record-citation.zod.ts + packages/services/service-record-context/src/verify-citations.ts, packages/services/service-record-context/src/body-outline.ts, packages/services/service-record-context/src/index.ts, packages/services/service-record-context/src/tests/verify-citations.test.ts, packages/spec/src/ai/record-citation.test.ts
Security-touching: yes
Rule-change-verified: none

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 origin/main...pr-37396 (20 files, +853/−177), ADR-0160 on origin/main (third amendment, merged as db77cc4: D9, point 23), and the 70 check-runs on the head (60 success, 10 skipped, 0 failed). Code outside the diff (record-context-tools.ts, door.ts, record-context-tools.zod.ts, strict-object.ts) was read, not reviewed.

① Derived judgments

  • Accept-set, RecordCitationSchema: right. { object, id, context?, anchor?, quote }, every string min(1), closed by strictObject. It is D9's shape as amended (context optional, anchor optional). min(1) on context and anchor mirrors GetRecordContextInputSchema, which the verifying call would refuse an empty string on anyway. The aliases only feed the "did you mean" message; they admit nothing.
  • Accept-set, RecordCitationsSchema (max 20): right, a card-ordered number. D9 names no cap; the card orders "an array with a cap". The PR states the number in its Acceptance notes.
  • Public surface, @objectstack/spec/ai: 11 new exports, right. Eight for the citation (RecordCitation*, RECORD_CITATIONS_MAX, RECORD_CITATIONS_PART_TYPE) and three for the anchor (headingsOf, BodyHeading, stripBodyTags). api-surface, export-origins, declaration-map, json-schema.manifest (2 rows) and authorable-surface (5 rows) agree with the source.
  • Public surface, @objectstack/service-record-context: one new export, verifyRecordCitations. Right.
  • The headingsOf move is behaviour-preserving. A text diff of the removed block against record-body-anchor.ts shows three differences only: stripTags renamed to the exported stripBodyTags, its one call site, and two jsdoc lines. slugOf, decodeEntities, htmlHeadingsOf, markdownHeadingOf and isFence are byte-identical. body-outline.ts re-exports headingsOf and BodyHeading, so its own importers are unchanged.
  • Generated counts: right. llms.txt (ai 16 to 17, total 230 to 231), the docs reference (17 pages, 102 schemas, total 1735) and the strictness ledger (ai/ 113 to 114) each follow from one new *.zod.ts module with two schemas and one strictObject site.

② Semver level

  • @objectstack/spec minor and @objectstack/service-record-context minor: right. Both are additive; nothing is removed or narrowed.
  • Clause-②: yes: correct. A new published schema and new public exports enter spec.
  • Metadata-protocol: added: correct. authorable-surface/ai.json gains the five ai/RecordCitation:* rows, and ADR-0160's execution table says added for row 10 "when the shape enters spec".
  • Skills-docs: follow-up #37177: the card is open. It is about teaching authors to write context packs; a citation is written by a model, not an author, so nothing more is owed here.

③ Boundary flags

  • Dev deviation, llms.txt and the strictness-ledger count outside the claimed surface: accepted. Both are forced by the new module (check:llms-txt, check:strictness-ledger), and both are counts that follow from the diff.
  • Dev deviation, stripBodyTags exported: accepted, see N3. The verifier and the anchor derivation share one notion of a tag, which is the reason the card moved headingsOf in the first place.
  • Dev deviation, PR body Readings written at 36ec0cf: accepted. The final-head readings are in the report, and the check-runs on 8471b77 are the gate verdicts. The seat may patch the PR body.
  • Dev deviation, pushed after overlap-check exit 1: accepted. The only overlap with refactor(spec)!: rename the Studio helper defineForm to defineMetadataForm and its modules to *.metadata-form.ts #37366 is the generated export-origins/ai.json; the second lander regenerates it.
  • open_questions: none. security_findings: none; this review agrees (④, security).
  • Out-of-scope note (tag-stripping joins adjacent elements, entities not decoded): answered in N2.
  • SQL push-down: no finding. The verifier adds no read of its own. It calls executeGetRecordContext, and the substring match has to run on the answer as projected for the caller, which SQL cannot see. No id is materialised and nothing is joined in the app.

④ Design judgment

record-citation.zod.ts against ADR-0160 D9 and its first consumer. The shape holds. ADR-0049 is met for RecordCitationSchema: verifyRecordCitations parses every entry with it in this same PR.

verify-citations.ts against D9 and point 23.

  • As the asking user, through the tool's own path: holds. The verifier builds no door and no context. It hands the door it was given to executeGetRecordContext, the one executor every transport uses, so the read guard, API exposure, the served definition, pack selection, the field projection and the anchor resolution all run as they do for a tool call. Its one other read, servedObjectDefinitionOf for the body's type, also goes through the door. door.ts states the door is bound by its host to one caller with no system context. The verifier cannot check which caller that is: binding the asking user's door is the producer's duty (cloud 10c), and that card should say so.
  • Refusals drop (point 23): holds. Every throw of the executor becomes undefined, and its citations are dropped. No call is retried without an argument. The tests cover an unknown pack, several packs without context, a stale anchor, and five no-access shapes.
  • The haystack is the data member's record strings: holds, and excluding notes, framing and labels is right. notes and framing are siblings of data in GetRecordContextOutputSchema, so D9's "the data member" excludes them by structure. Labels sit inside data but are metadata the caller's locale picks; a quote found in a label says nothing about the record, and the card's What 3 rules "labels never count". The ablation in the report (reading notes, framing and the pack label turns one test red) pins the rule.
  • Security: no finding. The verifier answers no more than the tool the same user can call: it returns the citations the model wrote, never text from the answer, and every drop looks alike, so it tells less than a direct call (which separates not-found from refused). Time to answer varies with the same early refusals the tool already has. A masked, withheld or hidden field has no value in the answer, so nothing matches in it (tested for withheld and hidden).

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, priority:p2, pm:blocked on this PR, parent #36996). I read that card: it asks that only an ADR-0112 coded refusal count as "not verified" and any other failure be reported to the host, keeps the result fail-closed, and keeps a refused record and a missing one alike. It says what the finding asked for.

S2: closed — settled by the same ruling. ADR-0160 D9 on main (line 342) leaves to row 10 "which strings of the data member the quote is matched against and how a value that is not text is compared". Card #37364 is row 10a and decides it: a field or related-list cell value/display that is a string, or body.text. The PR implements that rule and states it, so it is inside D9. A wider matcher (numbers, displayName) would be a new decision for a later row, not a defect of this head.

N1 (nit) — RecordCitationsSchema and RECORD_CITATIONS_PART_TYPE have no reader in this PR: the verifier takes unknown, slices to RECORD_CITATIONS_MAX and never parses the list schema. The card orders both, and their readers are 10b and 10c, so ADR-0049 is met for row 10 as a whole. The two treat an over-long list differently (the schema refuses 21 entries, the verifier reads the first 20); 10c should know which one it gets; #37418 item 3 carries this.

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 <td>100</td><td>200</td> also verifies the quote "100200", and the as-stored match verifies a quote taken from an attribute value. Both strings are text the tool returned, so D9 holds; the sentence should be corrected; #37418 item 3 carries this.

N3 (nit) — stripBodyTags is now public API of @objectstack/spec/ai. It is not a sanitizer (script content stays, an unclosed < stays); one jsdoc line saying so would stop a later reader using it as one; #37418 item 3 carries this.

N4 (nit) — A citation with an anchor verifies when its quote sits in a field or a related cell and not in the cited section, because the answer for that call carries all three. This is D9 as written ("the data member of the answer"). The surface in 10b will then open the record at a section that does not hold the quote.

N5 (nit) — A one-character quote parses (min(1)) and verifies against almost any record. D9 sets no minimum; noted for 10b/10c.

N6 (nit) — All distinct tuples are read at once: up to 20 concurrent get_record_context executions, each with its own pack listing and child queries. The bound is fixed and the reads run as the user; a sequential or small-pool loop would be kinder to the database.

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: claude/issue-37364-record-citation-verifier
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 8471b77d705d386251204a83ee11281712e47074
ACCEPT — L1, seat repo:objectstack#5

  1. Shape: open draft against main. 20 files (+853/−177). Fixes #37364 (row 10a of 专题:记录范围 AI 问询(在一条记录上问 AI:对话钉在这条记录上、平台按配置交给模型这条记录的资料、外部 AI 经 MCP 拿到同一份) #36996). l1-face CLEAN.
  2. Premise and change: per contract record 7181443752:
    • RecordCitationSchema matches ADR-0160 D9 as amended: context and anchor optional, all strings min(1), strict.
    • The verifier hands the asking user's door to executeGetRecordContext, so every gate runs and every refusal drops the citation.
    • The haystack is exactly the data member: field and related cell value/display, and body.text. Notes, framing and labels are out.
    • headingsOf moved into spec byte-identical apart from the stripBodyTags rename.
    • Ablation: reading notes, framing or labels reds the note-only test.
    • No security finding.
  3. Gates: check-runs at 8471b77d70: 60 success, 10 expected skip, 0 failed, 0 pending. Mergeable clean.
  4. Accepted deviations:
    • (a) packages/spec/llms.txt and the strictness-ledger counts sit outside the claimed surface; the new module forces them.
    • (b) stripBodyTags is exported, so the anchor reader and the verifier share one tag reader.
    • (c) The PR body's Readings were taken at 36ec0cf68; the final-head readings are in report 7181284963.
    • (d) Contract nits N1–N6.
  5. Out of scope and where it went:
  6. Landing terms: ungoverned, default tier, Clause-②: yes, Metadata-protocol: added, Security-touching: yes. L2 at CONTRACT_REVIEW_TIER: PASS, comment 7181443752, same head, no open must-fix or should-fix. The area lands it via landing-operations §B.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

Landing: ACCEPT 7181455245 (L2 PASS re-record 7181443752) at head 8471b77d705d386251204a83ee11281712e47074.

Probe Reading
Check-runs on head 60 success, 10 skipped, 0 failed, 0 pending
Governed / size check-governed-merges --pr 37396: NOT governed, 1030 changed lines ≤ 3000; mergeable_state clean

Status: ready + auto-merge (merge queue). On MERGED, #37364 closes by Fixes; #37365 moves to pm:queue, and #37418 unblocks.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 26, 2026 03:14
@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-37396-ee11fce9: Lint & Type Check run 45749208954, jobs Type Check · workspace and TypeScript Type Check. Cause read from the job log: The runner has received a shutdown signal, Turborepo tasks force-killed mid-typecheck; no error TS line. Not this PR's. The earlier group pr-37396-ec5ef77a was green on every workflow. Head unchanged (8471b77d); auto-merge re-armed (relay run 45751345362).

Merged via the queue into main with commit db46566 Nov 26, 2026
71 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-37364-record-citation-verifier branch November 26, 2026 04:45
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/xl 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.

记录 AI 问询 10a:引用格式进入 spec,并交付以提问人身份核对摘句的核对器

2 participants