Skip to content

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

In review

Description

@objectstack-fleet

repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

Filing gate: ③ maintainer-ruled. Split of placeholder #37144 per ruling 7177410380 (the maintainer, decision card, 2026-11-25T23:18Z: Q1 A · Q2 A · Q3 A; analysis 7177223845).
Grading: area:ai · Feature · p2 (topic child; blocks 10b and cloud 10c) · reach: n/a (new capability) · evidence: read (split analysis on main a182fbe).

维护者速读

  • 做什么:在 spec 里定义"引用"的形状(哪条记录、哪个资料包、正文哪一节、原文摘句),同时交付核对器:以提问人的权限重读这条记录,确认摘句确实逐字出现在资料里。
  • 谁受益:所有展示 AI 引用的界面(控制台、cloud 应用内问答),它们只显示核对通过的引用。
  • 不做会怎样:AI 给出的引用无法核对,可能引用不存在的原文。
  • 需要你做的:无(三条裁决已定)。

What

  1. packages/spec/src/ai/record-citation.zod.ts (new):
    • RecordCitationSchema, strict: object, id, context? (the pack face, spelt as get_record_context's input context takes it; ruling Q2), anchor? (min 1), quote (min 1).
    • RecordCitationsSchema: an array with a cap.
    • RECORD_CITATIONS_PART_TYPE = 'data-record-citations': the answer member is a UI-message data part (precedent BUILD_PROGRESS_FRAME_TYPE). Export from ai/index.ts.
  2. packages/spec/src/ai/record-body-anchor.ts (new): move headingsOf/slugOf here unchanged from body-outline.ts, so the server and the console derive one anchor. body-outline.ts re-imports them; body-outline.test.ts passes untouched.
  3. packages/services/service-record-context/src/verify-citations.ts (new): verifyRecordCitations(citations, door).
    • One executeGetRecordContext per distinct (object, id, context, anchor), as the door's caller (ruling Q1: the platform verifies as the asking user).
    • object/id are the pack's root record (ruling Q3). Verified ⇔ quote is a substring of a data-member string of that answer: a field or related-list cell value/display, or body.text. Notes, framing and labels never count. Whitespace runs collapse. An html/richtext body is also matched tag-stripped.
    • A citation without context on an object with several packs is not verified (the tool's refusal stands); with one pack it verifies.
    • Any refusal ⇒ not verified. The function returns the verified subset and never throws per citation.
  4. Export from src/index.ts. Tests in __tests__/verify-citations.test.ts, reusing fake-door.ts.

Acceptance

  • The spec schema refuses an unknown key, an empty quote and null, and admits context.
  • The verifier:
    • verifies a quote in a section by its anchor, and refuses a stale anchor;
    • verifies a quote found in a related-list cell, cited on the root record (Q3);
    • refuses a quote that appears only in a note;
    • refuses a quote from a field the caller has withheld or hidden;
    • for a body that came back as an outline, refuses a quote cited without an anchor;
    • refuses a citation without context on an object with two packs, and verifies it on an object with one (Q2).
  • A caller with no read access gets "not verified", and nothing that reveals existence.
  • Metadata-protocol: added (new exported schema → authorable-surface/ai.json rows; ADR-0160 expects added) with its Skills-docs: line. Clause-②: yes.

Out of scope: an MCP verify tool; rendering (10b); producing and persisting citations (cloud 10c).

Governing text: ADR-0160 D9 as amended by #37363, D3, D4; ADR-0049 (the schema lands with its first reader); ruling 7177410380.
Blocked-by: #37363
Parent: #36996 (row 10a; replaces placeholder #37144)
Size: M
Dedupe (objectstack, is:issue): citation in:title → #37144 (this placeholder, closed in favour of these cards); no other citation-shape card.

Activity

  1. added
    priority:p2
    pm:blocked
    area:ai
    on Nov 25, 2026
  2. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    First touch, 2026-11-25T23:34Z.

  3. added
    pm:queue
    and removed
    pm:blocked
    on Nov 26, 2026
  4. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

    Unblocked: Blocked-by: #37363 is closed. PR #37370 merged as db77cc4, so ADR-0160's third amendment (D9 context, when a citation is verified, root record for quotes from related rows) is in force. pm:blocked → pm:queue. Dispatch waits on PR #37354, which is in the merge queue and touches the same service-record-context and spec ai.json baselines. Also: pm:dispatched removed from closed #37363.

  5. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

    Claim: PM loop round 4 · area ai-36996 (topic #36996 non-cloud rows; the maintainer, verbatim, 2026-11-25T12:57Z project thread: 「开一个 36996 专题,接手剩余任务」) · 2026-11-26T01:21Z
    Session: session_01Utp6CbeF2saT6wUBV4E9uc
    Account: os-bill
    Area: ai-36996
    Branch: claude/issue-37364-record-citation-verifier
    Worktree: objectstack-issue-37364
    Domain: domain:spec
    Seat: repo:objectstack#5
    File surface: packages/spec/src/ai/record-citation.zod.ts (new) and record-body-anchor.ts (new), packages/spec/src/ai/index.ts, the headingsOf/slugOf move out of packages/services/service-record-context/src/body-outline.ts (re-import only), packages/services/service-record-context/src/verify-citations.ts (new), src/index.ts, tests, liveness rows, generated spec baselines, root .changeset/. Stop on breach and report.
    Container & model: M, mode:subagent, model: default — dispatch-gates --tier: "no path-derived mandate", effort: high
    Clause-②: yes
    Metadata-protocol: added
    Responsibility: n/a — not a defect card
    Thread-read: 7179552779
    Premise: holds — on origin/main 9ffe37153: #37363 closed (PR #37370 merged, ADR-0160 third amendment in force); PR #37354 merged
    Serial constraints cleared: PR #37354 merged (service-record-context, spec ai baselines). #37233 also touches body-outline.ts and is held until this lands. Sibling #37361 (this area, in flight) owns record-context-tools.ts, the doors and the runtime harness; this card only reads fake-door.ts.
    Pre-claim deps: #37363 closed
    Prior rulings read: ruling 7177410380 (Q1 A · Q2 A · Q3 A) on #37144; ADR-0160 D9 as amended by PR #37370

  6. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 26, 2026
  7. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc
    os-dev-report

    {
     "issue": 37364,
     "status": "done",
     "branch": "claude/issue-37364-record-citation-verifier",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/37396",
     "head": "8471b77d7",
     "session": "session_01Utp6CbeF2saT6wUBV4E9uc",
     "premise_still_valid": true,
     "summary": "Spec gains RecordCitationSchema {object,id,context?,anchor?,quote} (strictObject, all strings min 1), RecordCitationsSchema (max RECORD_CITATIONS_MAX = 20), RECORD_CITATIONS_PART_TYPE = 'data-record-citations', and record-body-anchor.ts, where headingsOf and its private readers (slugOf included, still private) moved unchanged out of service-record-context body-outline.ts; the tag reader is exported as stripBodyTags. service-record-context gains verifyRecordCitations(citations, door): one executeGetRecordContext per distinct (object,id,context,anchor) through the caller's door; any refusal drops the citation; a quote survives only as a whitespace-collapsed, trimmed, case-sensitive substring of a field/cell value (strings only) or display, or body.text (html/richtext also tag-stripped). Notes, framing, labels, pack/record header and outline headings are never matched. It reads at most 20 entries, drops unparsable ones and never throws. body-outline.ts re-imports and re-exports headingsOf and BodyHeading; body-outline.test.ts is untouched and green. A1 measured: spec's package.json has no workspace dependency (pg-connection-string and zod only), so moving headingsOf creates no cycle. A2 holds: the verifier is the schema's only reader.",
     "per_acceptance_bullet": {
      "schema refuses unknown key / empty quote / null, admits context": "record-citation.test.ts: unrecognized_keys keys [field]; too_small path [quote]; invalid_type path []; context+anchor parse equal",
      "verifies quote by anchor, refuses stale anchor": "verify-citations.test.ts 'verifies a quote in a section by its anchor...' (also: anchor scopes the match)",
      "related-list cell on root (Q3)": "'verifies a quote found in a related-list cell...' (control: other policy's row dropped)",
      "refuses note-only quote": "'refuses a quote that appears only in a note, the framing, or a label' (control: the answer carries each string); this test is the ablation target",
      "refuses withheld or hidden field": "'refuses a quote from a field the caller has withheld or hidden' (control: same quote verified unhidden)",
      "outline body without anchor refused": "'for a body that came back as an outline...' (control: same quote with anchor verified; outline anchors [scope, claims])",
      "two packs without context refused, one pack verified (Q2)": "'refuses a citation without context on an object with two packs...' plus named-pack verified, unknown-pack refused",
      "no read access: not verified, nothing reveals existence": "unreadable row / missing id / unserved / guarded / unexposed object all resolve to []",
      "Metadata-protocol added + Skills-docs, Clause-2 yes": "PR body and changeset carry Clause-②: yes, Metadata-protocol: added, Skills-docs: follow-up #37177; authorable-surface/ai.json gains 5 ai/RecordCitation rows; Check Changeset success"
     },
     "matching_rule_stated_in_pr": "Yes, in PR What changes: value (string only) or display of root fields and related cells, plus body.text (html/richtext also tag-stripped); whitespace runs collapse; never notes, framing, labels, header, outline headings or non-string values.",
     "tests": "Final head 8471b77d7: pnpm --filter @objectstack/spec test, SPEC_EXIT=0, Test Files 897 passed (897), Tests 28448 passed, 1 todo. pnpm --filter @objectstack/service-record-context test, SVC_EXIT=0, Test Files 3 passed (3), Tests 115 passed (115). service-record-context typecheck SVCTC_EXIT=0. spec typecheck exit 0 (36ec0cf68; the later commit touched only llms.txt). The first spec run on c46e26d72 had 1 failure: alias-integrity, recordId and record_id collapse onto probe recordid. Fixed in 36ec0cf68 by dropping record_id. Ablation (one behaviour, the data-member restriction) via scripts/ablation-replace.mjs: haystackOf also collected answer.framing, note texts and pack.label. Anchor 1 to 0, blob c35fc729 to dcec1804; 'refuses a quote that appears only in a note, the framing, or a label' went RED (1 failed / 15 passed). Restored: blob == HEAD, git diff HEAD empty. A first attempt was a no-op the tool refused before running (its replacement contained the anchor). The verifier test imports src directly (no dist hop for the mutated file), so no rebuild leg was needed.",
     "gates": "Local: dispatch-gates --commands derived 111 families; --ran with exit codes reconciled 111 derived, 106 run, 5 NOT-MEASURED, 0 UNRUN. All 106 run families exit 0 (the 11 that first exited 3 on a stale spec dist or an unbuilt lint closure were re-run after building @objectstack/lint... and all exited 0, check:generated, check:api-surface and check:llms-txt included). NOT MEASURED locally, prerequisite exit 3: check-plugin-teardown-shape --self-test (shallow clone; fixture needs an unshallowed main), spec check:skill-examples (client-react dist absent), check:dual-build-cjs-loads, check:lean-entry-closure, check:type-check-debt (whole-workspace dist absent). This is a declared narrowing; CI runs them. Local-only families: check:skill-frame-freshness exit 0; check:dev-prereqs exit 1, workspace not fully built (103/110 packages without dist), a prerequisite not about this diff, NOT MEASURED. Generated by check:generated --fix: api-surface, export-origins, declaration-map, content/docs/references, strictness-ledger counts; authorable-surface and json-schema.manifest written by the spec build. CI on final head 8471b77d7, 70 check-runs, 60 success, 10 skipped, 0 failure: Lint & Repo Gates=success; TypeScript Type Check=success; Type Check · source gates=success; Test Core=success; Build Core=success; Governed Surface Queue Guard=success; Type Check UI=success; Test UI=success; Build & E2E UI=success; Live E2E UI=success; Dogfood Regression Gate=success; Lint UI=skipped; Check Changeset=success; Spec property liveness=success. The previous head 36ec0cf68 was red only on Type Check · source gates, check:llms-txt (ai count 16 vs 17); CI log saved to scratch and grepped; fixed in 8471b77d7.",
     "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
     "line_budget": "1030 changed lines (+853 / -177) over 20 files, under the 3000 human-merge threshold; skills/** untouched",
     "files_changed": [
      ".changeset/37364-record-citation-verifier.md",
      "content/docs/references/ai/index.mdx",
      "content/docs/references/ai/meta.json",
      "content/docs/references/ai/record-citation.mdx",
      "content/docs/references/index.mdx",
      "docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md",
      "packages/spec/api-surface/ai.json",
      "packages/spec/authorable-surface/ai.json",
      "packages/spec/declaration-map/ai.json",
      "packages/spec/export-origins/ai.json",
      "packages/spec/json-schema.manifest/ai.json",
      "packages/spec/llms.txt",
      "packages/spec/src/ai/index.ts",
      "packages/spec/src/ai/record-body-anchor.ts",
      "packages/spec/src/ai/record-citation.zod.ts",
      "packages/spec/src/ai/record-citation.test.ts",
      "packages/services/service-record-context/src/body-outline.ts",
      "packages/services/service-record-context/src/index.ts",
      "packages/services/service-record-context/src/verify-citations.ts",
      "packages/services/service-record-context/src/__tests__/verify-citations.test.ts"
     ],
     "readings": "Tree objectstack-ai/objectstack. Base 9ffe37153, head 8471b77d7. Shallow clone (is-shallow true); no ancestry verdict depended on it. overlap-check before each push: the first push was clean; the later pushes reported VERDICT overlap exit 1, a conflict with #37366 only in the generated packages/spec/export-origins/ai.json, which whichever PR lands second regenerates (stated in the PR body); origin/main merged cleanly each time.",
     "deviations": [
      "File surface: packages/spec/llms.txt (hand-kept inventory, ai count 16 to 17 and total 230 to 231, Record Citation added to the ai row) and docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md (generated count) are not named in the claim. Both were forced by the new spec module: check:llms-txt and check:strictness-ledger red without them.",
      "Exported stripBodyTags from spec (the old private stripTags, renamed), beyond the card's headingsOf/slugOf move, so that the verifier and the anchor derivation share one tag reader. slugOf stays module-private as before.",
      "The PR body's Readings block was written at head 36ec0cf68. Final-head readings (full spec suite 897/897, CI all green on 8471b77d7) are only in this report: os-dev.md forbids a dev PATCH of the PR body, while the dispatch allows issue_patch; I followed os-dev.md (standard text wins). The seat may patch the readings in.",
      "Pushed after overlap-check exit 1 twice. Both times the only conflict was the generated export-origins/ai.json with #37366: the generated-file rule, regenerated by the second lander.",
      "Wrote a scratch file at /home/user/pr-body-37364.md by mistake (outside any repo) and deleted it at once."
     ],
     "mcp_calls": "0",
     "api_writes": "4 REST writes via the fleet-write relay, as objectstack-fleet[bot]: pr_create stroke = POST /repos/objectstack-ai/objectstack/pulls (draft #37396) + POST /repos/objectstack-ai/objectstack/issues/37396/assignees (os-bill); post-stamped comment = POST /repos/objectstack-ai/objectstack/issues/37364/comments (this os-dev-report); plus the repository_dispatch POST that carries each relay stroke. git push is not counted.",
     "open_questions": [],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: none · noted, not filed: tag-stripping removes a tag with nothing in its place (as headingsOf does), so a quote spanning two html block elements does not verify, and html entities in the body are not decoded. This follows the card's rule as written and is stricter only; noted in the PR's Acceptance notes."
     ]
    }
  8. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc

    ACCEPT → PR #37396 comment 7181455245

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

Metadata

Metadata

Assignees

Labels

area:aipm:dispatchedpriority:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions