Skip to content

feat(spec): the list_datasets output declares candidates for a term that matched nothing (ADR-0149 D3) - #34828

Merged
os-zhuang merged 6 commits into
mainfrom
claude/issue-34761-list-datasets-candidates
Nov 17, 2026
Merged

os-zhuang merged 6 commits into
mainfrom
claude/issue-34761-list-datasets-candidates

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

repo:objectstack#3 · os-support-ai · session_01WGufzfR33NbV51QQU6R6bm

Fixes #34761

Clause-②: yes (widening — an optional output field on a published schema)
Metadata-protocol: added
Skills-docs: follow-up owed — skills/objectstack-ask/SKILL.md (zero-match row reads candidates once #34763 lands)
Served-tier: CONTRACT_REVIEW_TIER

维护者速读

  • 改了什么:list_datasets 的返回结构新增可选成员 candidates。用户的词在所有列出的数据集里一个成员都没精确命中时,平台列出可供反问的候选成员,每项指向同一份返回里的「数据集 + 成员」,每个词最多 5 个。ADR-0149 D3 末尾加一段只增不改的修订说明。本 PR 只声明形状,不改执行器。
  • 为什么改:[Decision] The published skills: who reviews a change, how they are verified, one catalog or two for code-first and MCP, and the E2 premise reading #34691 F1 的裁决(选 B,记录 6943126855):零命中时由服务器返回候选,任何客户端都读得到,不靠技能或工具描述的措辞。「什么算命中」不变,平台永不替用户选。
  • 风险与回滚:只加一个可选输出字段,不带该字段的返回解析结果与之前相同。服务器填充在 service-analytics: list_datasets fills candidates with near members (name, label, synonym) on a zero-match, only from what the caller may read #34763,它落地前没有返回会带这个字段,但 MCP 客户端读到的 outputSchema 现在就多出这一项。回滚即 revert 本 PR。
  • 先看:① packages/spec/src/ai/dataset-tools.zod.ts 里 candidates 的 .describe() 文字,它是对外契约,也是 MCP 客户端读到的说明;② docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md D3 末尾的修订说明,看它是否如实转述裁决;③ 同一文件里 DatasetTermCandidateSchema 不带 matchedOn,与卡片提案不同,理由在下面 Schema decisions。
  • 两分钟验证:pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/ai/dataset-tools.test.ts,预期 Tests 33 passed (33)。
  • 需要你做的:席位 L2 复核后,亲手合并本 PR(Tier H:docs/adr/** 与 packages/spec/**)。

What changes

  • packages/spec/src/ai/dataset-tools.zod.ts (62 lines added, 2 removed; the two removed lines are module doc block lines, rewritten to name candidates):
    • ListDatasetsOutputSchema gains one optional member, candidates: a list of DatasetTermCandidateSchema with at least one entry.
    • DatasetTermCandidateSchema (type DatasetTermCandidate): { term, dataset, member }, all three required. member is DatasetTermMatchSchema's member by reference, under its own description, so the member-reference format (measures.NAME or dimensions.NAME) is declared once.
    • LIST_DATASETS_MAX_CANDIDATES_PER_TERM = 5, exported.
    • matches, DatasetTermMatchSchema, DatasetTermMatchedOn and every other declaration in the file are untouched.
  • packages/spec/src/ai/dataset-tools.test.ts: seven new cases (33 run in the file now). Six in a new list_datasets candidates block, one in the JSON Schema projection block.
  • packages/spec/src/type-alias-convention.pin.test.ts: one pin row for the new alias and the pinned count 857 to 858. check:spec-parsed-alias (ADR-0122) refuses a new bare input alias with no pin. See File surface below.
  • Generated, by the generators only: packages/spec/{api-surface,authorable-surface,declaration-map,export-origins,json-schema.manifest}/ai.json, content/docs/references/ai/dataset-tools.mdx, content/docs/references/index.mdx (schema totals 1669 to 1670, AI 81 to 82), docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md (96 to 97 object sites).
  • docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md: an amendment note at the end of D3, in ADR-0011's > **Amendment note** form. 11 lines added, 0 removed or changed.
  • .changeset/34761-list-datasets-candidates.md: @objectstack/spec at minor.
  • Nothing under packages/services/service-analytics/**, packages/mcp/** or skills/**.

Why

Ruled by the maintainer on #34691, fork F1, option B, option text verbatim 「B 零命中返回候选」 — 「现在就改服务器,list_datasets 零命中时返回候选数据集。专题席的新推荐。」 (ruling record 6943126855, relayed to #34659 as 6943149235). It re-rules point E2 of #34659's record 6940528935 to that point's option A.

With terms, list_datasets answers the whole admitted catalogue, and a term with no match gets no pointer to the near members (the card's reading of packages/services/service-analytics/src/dataset-tools.ts), so what to do next is left to each client. A tool result is read by every client that made the call; a tool description is read only after the client picked the tool, and a skill only when it is installed and triggered.

This PR is the spec half: the shape, and the record. The executor that fills the list and the tool descriptions are #34763.

Schema decisions

The card's proposal was a starting point ("the PR settles it and says why if it differs"). One point differs.

Point Card's proposal Settled here Why
Entry shape { term, dataset, member, matchedOn } { term, dataset, member } Differs. matchedOn says which of the member's words the term equals after normalization. A candidate has no such equality, so the key would state something false. There is no "near which word" key either: D3 rule 1 names an embedding neighbour among the non-hits that may be offered, and an embedding neighbour is near no single word. Such a key would presume a substring or stem rule, and the rule is the executor's.
What the question lists not stated read from datasets D3 rule 3 lists label, dataset label and description. Each candidate points at a member listed in the same answer, so the client reads those from that datasets entry. The entry repeats none of them.
Presence only when terms were sent and a term matched no member of any listed dataset as proposed, as .min(1).optional() "No candidates" has one spelling, the key's absence. An empty list does not parse. An answer without the key parses to the same value as before.
Order terms as sent, datasets as listed, measures before dimensions, no score as proposed Stated in the member's description. It is a listing order and the description says it is not a ranking. A schema cannot enforce an order; holding it is the executor's (#34763).
Cap an exported per-term constant, proposed 5 LIST_DATASETS_MAX_CANDIDATES_PER_TERM = 5 The description states the cap from the constant. The list is flat (one list for all terms), so the schema carries no per-term maxItems: nothing in this PR refuses a sixth entry for one term.
Description text not a match, for a clarifying question, never selected, only members this caller may read as proposed, as facts ADR-0149 M1 A keeps AI guidance out of the spec. The description says what a candidate is. How to ask stays in the tool description (#34763).
Near-match rule the server sibling's not in the spec The spec and the ADR note say what a candidate is, not how one is found.

The new type alias is a bare input alias with a pin, not an alias paired with a Parsed twin: the schema has no default and no transform, so input and output types are the same (ADR-0122).

Prior rulings read

The claim names four. None is crossed.

  • ADR-0078, the hit labelled "Decision §8": the text is its section 5, "Ratchet, not retrofit", where "candidates" means audit findings. It rules nothing about a tool output.
  • ADR-0110 D2: handler-key candidates derived from an action declaration. Unrelated.
  • ADR-0149 D2 (two tools, one definition, one executor, two transports): this PR adds one optional member to the one definition. No second definition, no executor and no transport changes. The output members D2 lists stand as written, and the D3 note names the added one.
  • ADR-0149 D6 (every key names its reader in its first implementation card): the note's "State on main" bullet names service-analytics: list_datasets fills candidates with near members (name, label, synonym) on a zero-match, only from what the caller may read #34763 as the card that fills the list and carries the branch to the model. The spec liveness ledger classifies authorable metadata keys and has no row for the dataset-tool output schemas; check:liveness exits 0 and asked for no row.

Tests

Readings are on head 666309be with a clean working tree, unless a row says otherwise.

Command Result
pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/ai/dataset-tools.test.ts src/type-alias-convention.pin.test.ts (verify lock) Test Files 2 passed (2), Tests 36 passed (36); lock line VERDICT command-exit 0
pnpm --filter @objectstack/spec typecheck then test (verify lock), on a23b07c9 check:test-typecheck: OK; Test Files 847 passed | 1 skipped (848); Tests 27175 passed | 1 skipped | 1 todo (27177); VERDICT command-exit 0. The one later commit, 666309be, changes one sentence of the ADR note.
pnpm --filter @objectstack/service-analytics test and pnpm --filter @objectstack/mcp test (verify lock) service-analytics Test Files 218 passed (218), Tests 5548 passed | 335 skipped (5883); mcp Test Files 66 passed (66), Tests 1226 passed (1226); VERDICT command-exit 0
pnpm exec eslint --no-inline-config on the three changed TypeScript files exit 0, no finding

The two downstream packages are the ones outside spec that import the dataset-tool schemas (direction: consumers of spec). They ran against a spec dist/ that carries the new export.

What the new cases pin
  • An answer with candidates parses, and the parsed value keeps the list.
  • An answer without the key parses to the same value as before.
  • An empty candidates list is refused, at path candidates.
  • An entry's keys are exactly dataset, member, term, each required, and there is no matchedOn.
  • member takes what a match's member takes and refuses what it refuses.
  • The cap constant is 5.
  • The projected list_datasets outputSchema has candidates as an array with minItems 1 whose items require term, dataset and member, and candidates is not in the output's required list.

The built dist/ answers the same: required is ["datasets"]; candidates is type: array, minItems: 1; its items are type: object, required: ["term","dataset","member"], additionalProperties: false.

Ablations (three, each restored)

Each mutation went through scripts/ablation-replace.mjs on dataset-tools.zod.ts, and each restore ended with "ok restored: blob == HEAD (bbb4dce7b5b8) and git diff HEAD is empty". The suite imports the schema by relative path from src/, so there is no dist/ leg.

Mutation Reading
.min(1) to .min(0) on candidates Tests 2 failed | 31 passed (33): the empty-list case and the projection case
the key candidates renamed Tests 3 failed | 30 passed (33): the keep-the-list case, the empty-list case, the projection case
member to a plain string Tests 1 failed | 32 passed (33): the member-format case

The first attempt at the first ablation did not run. The tool refused it (the replacement text was a substring of the anchor, so the count moved 18 to 18) and restored the file. The row above is the second attempt with a narrower anchor.

Acceptance notes

Verification

  • Derived gates. node scripts/pm/dispatch-gates.mjs --commands at 666309be derives 109 commands. --ran answers: "109 derived famil(ies) accounted for — 109 run, 0 NOT-MEASURED", exit 0.
  • First pass. 96 exited 0. 11 exited 3 (PREREQUISITE NOT MET) and check:generated exited 1, all twelve for one cause: dist/ older than the sources after the pin edit, or a package not built. check:type-check-debt hit my runner's 300 s cap. After pnpm --workspace-concurrency=2 --filter '@objectstack/lint...' build, and after pnpm check:type-check-debt run to its end (exit 0, "0 ledger entr(ies) re-measured"; that run does a turbo run build over the packages under the verify lock), all thirteen exited 0 on a re-run.
  • Changeset level. node scripts/check-changeset-no-major.mjs --base origin/main with a pull_request event carrying this title and body: exit 0, "LEVEL AXIS: this PR declares clause-② yes (widening) and metadata-protocol added, and no package whose published source ... it moves is graded patch". Control: the same event with Metadata-protocol: none exits 1, "metadata-protocol declares none while an authorable-surface or authorable-defaults baseline moved" (packages/spec/authorable-surface/ai.json). That is why the claim's provisional none is added here, with minor.
  • Local-state gates. pnpm check:skill-frame-freshness exit 0. pnpm check:dev-prereqs exit 1: "34 of 107 workspace packages declare an entry point under dist/ that is not on disk" in this worktree (the three it names are under ui/; the gates above needed none of them). That is this machine's state, not a reading of the diff.
  • Not run locally, CI's. test:repo, the repo-wide pnpm lint and the rest of the farm. No full dogfood run: the title has no ! and the declaration has no (narrowing) arm.
  • The branch merged origin/main at 3bbda33b through scripts/pm/os-regen-merge.sh.
Selected verdict lines
Gate Line
check:generated "All 14 generated artifacts are up to date"
check:spec-parsed-alias "1592 bare z.input aliases, 858 pinned isomorphic, 734 paired with an XParsed. OK"
check:api-surface "public API surface + factory signatures unchanged" (against the regenerated baseline)
check:export-origins "6223 exports across 19 entry points resolve exactly as recorded"
check:docs "248 generated files in sync with packages/spec"
check:adr-symbol-anchors "3734 anchors across 158 records resolve"
check-adr-links "1150 relative link destination(s) under docs/adr/ resolve"
check:adr-index "docs/adr/README.md is current, every record parsed"
check-empty-changeset "No empty-frontmatter changeset introduced by this diff (1 declaring changeset(s) added)"
check:nul-bytes "no raw ASCII control bytes"

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; the repo-wide pnpm lint is left to CI (the three changed TypeScript files lint clean).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 block is Chinese by the dev agent's rule).
  • The Before Submitting list in CONTRIBUTING.md is done, with the repo-wide runs left to CI as stated above.

Generated by Claude Code

…t matched nothing

`ListDatasetsOutputSchema` gains the optional `candidates`: pointers
`{ term, dataset, member }` to listed members the platform offers for a
clarifying question when a term matched no member of any listed dataset
(ADR-0149 D3). A candidate is not a match and is never selected; no
candidates is the key's absence, never an empty list. The per-term cap is
the exported `LIST_DATASETS_MAX_CANDIDATES_PER_TERM`.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
Generator output only, nothing hand-edited: `gen:schema` (authorable-surface,
json-schema.manifest), `gen:api-surface`, `gen:export-origins`,
`gen:declaration-map`, `gen:docs` (the dataset-tools reference page and the
reference index counts) and `gen:strictness-ledger` (the `ai/` site count).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…eset

An add-only note under D3 records the ruling: a term with no hit is
answered with `candidates`, offered for a clarifying question and never
selected; what counts as a hit, and rule 4's fallback, stand as written.
The changeset declares the widening at `minor` for `@objectstack/spec`.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…st-datasets-candidates

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
`check:spec-parsed-alias` refuses a bare `z.input` alias that is neither
pinned nor paired with an `XParsed`. The candidate entry is a plain object
of strings with no default and no transform, so it takes a pin: 857 -> 858.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
"This note changes no word of rule 1" states what the candidates note
does and leaves room for a later, separate note on rule 1's match targets.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
@github-actions github-actions Bot added size/m 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 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

4 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 5 changed file(s) yielded no anchor (packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, packages/spec/declaration-map/ai.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 5 changed file(s) yielded no anchor (packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, packages/spec/declaration-map/ai.json, …) — pages documenting those are invisible to this run
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 173 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 c513d62acdd342745bbfe29786ba4b644cd934fc → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json c513d62acdd342745bbfe29786ba4b644cd934fc

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg

L1: ACCEPT · 2026-11-17T12:51Z

Head-sha: 666309b
Reviewer: seat 3 L1-c, for card #34761 (claim 6945989234, seat amendment 6947893386).

席位核对

PR shape. Draft, base main, Fixes #34761. The card is the spec half only. The executor and tool descriptions are #34763, and the ADR note's last bullet names that card as the pending half (the D6 reader). No other issue sits next to a closing verb.

Scope vs claim. 13 paths, all inside the claim as amended by 6947893386. The amendment adds three paths:

  • type-alias-convention.pin.test.ts, the hand pin that check:spec-parsed-alias demands;
  • content/docs/references/index.mdx (generator output);
  • the strictness-ledger counts (generator output).

Nothing under packages/services/**, packages/mcp/** or skills/**.

Declaration.

  • Clause-②: yes (widening — an optional output field on a published schema) and Metadata-protocol: added appear in the body and the changeset, and they agree.
  • The changeset releases @objectstack/spec at minor, the level added takes. The authorable-surface/ai.json baseline moved (ai/ListDatasetsOutput:candidates plus three ai/DatasetTermCandidate:*), so none would have been refused (the body's control run shows exit 1).
  • Served-tier: CONTRACT_REVIEW_TIER is right for a published-schema widening.

Governed / size. check-governed-merges --pr 34828: GOVERNED, landing tier H, on 1 of 13 paths (docs/adr/**). 242 lines. The low-risk skills arm does not apply (spec paths, an ADR note under Decision, a minor). So the route is seat L2 at CONTRACT_REVIEW_TIER, then os-zhuang's hand.

Check-runs at 666309b. 70 runs, every one success or skipped: Lint & Repo Gates, TypeScript Type Check, Test Core and all 10 shards, Test UI and all 16 shards, Build Docs, Spec property liveness, Check Changeset, PR-body guards, Governed Surface Queue Guard, Check Documentation Links, Live E2E UI.

Contract shape (as relayed for checking).

  • candidates: z.array(DatasetTermCandidateSchema).min(1).optional(): yes. An empty list is refused at path candidates, and an answer without the key parses to the same value with no key added.
  • The entry is { term, dataset, member }, all required, and has no matchedOn. member is DatasetTermMatchSchema.shape.member by reference, so there is one member-reference format. A test asserts candidate and match accept and refuse the same strings.
  • LIST_DATASETS_MAX_CANDIDATES_PER_TERM = 5 is exported and declared above the factory (an OS_EAGER_SCHEMAS=1 ordering hazard, handled). The description interpolates it rather than restating 5.
  • "Never selected" and "not a ranking" are stated as facts in .describe(). No how-to-ask guidance enters the spec (M1 A), and there is no result text field, per the amendment's ruling on question A.
  • The projected outputSchema keeps required: ["datasets"] and lists candidates as array, minItems: 1, items requiring three keys. Pinned.

ADR-0149 D3 note.

Generated artifacts. api-surface, authorable-surface, declaration-map, export-origins, json-schema.manifest, the reference page and index totals (1669→1670, AI 81→82) and ledger counts (96→97) each move by exactly the one new schema and three members. CI's generated and docs gates are green.

Tests and ablations. Seven new cases. There are three ablations, each restored to the HEAD blob:

  • .min(1) changed to .min(0): 2 tests red.
  • The key renamed: 3 red.
  • member made a plain string: 1 red.

The body reports runs of the downstream consumers (service-analytics, mcp) against a spec dist/ that carries the export.

Docs made false? None. The reference page is regenerated and the module doc block names candidates. connect-mcp.mdx and the MCP README do not enumerate list_datasets output members.

Must-fix

None.

Should-fix

None.

Notes

Next: seat L2 at CONTRACT_REVIEW_TIER (fable), then os-zhuang (Tier H, docs/adr/**). A later push owes an L1-c delta read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 666309be7ec4379477340524ece0e735a22bd57b
Local-runs: none
Scope: packages/spec/src/ai/dataset-tools.zod.ts, docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md + none
Security-touching: yes

Read for this record: card #34761 (body and all four comments, claim amendment 6947893386 included), ruling 6943126855 on #34691, PR #34828 (body, the 13-file list, the net diff from merge-base 3bbda33b78 to the head), and the 70 check-runs on the head: 60 success, 10 skipped, none failed, none pending. Nothing was built or run. Read but not reviewed, outside the diff: packages/services/service-analytics/src/dataset-tools.ts and docs/design/mcp-local-first-door.md on origin/main 4771d66a2b, docs/adr/0011 lines 232-242, packages/spec/src/shared/lazy-schema.ts. + none: no file in the diff implements or enforces the two hits files apart from tests and generator output, which are the lane seat's remainder; the executor is #34763 and is not in this diff. Not read, because they are outside the brief's inputs: #34659 record 6940528935 and the body of #34691. Two clauses of the ADR note rest on them and are marked below.

① Derived judgments

  • Accept-set of ListDatasetsOutputSchema: widened by one optional key. Right. An answer without candidates parses to the same value as before (the new test pins it; Test Core is green). An answer with a non-empty list of { term, dataset, member } is now kept, where before the unknown key was dropped by the plain z.object.
  • One narrow refusal is new, and it is right. { datasets, candidates: [] } and a malformed candidates parsed before (the key was dropped) and are refused now. No producer on main emits the key (the executor at dataset-tools.ts:390-451 returns datasets, partial, warning only), so no existing answer changes. The widening declaration stands.
  • Public surface: three new exports from @objectstack/spec/ai. Right. DatasetTermCandidateSchema, the type DatasetTermCandidate, and LIST_DATASETS_MAX_CANDIDATES_PER_TERM. The generated baselines move by exactly these: api-surface +3, export-origins +3, declaration-map +2, json-schema.manifest +1, authorable-surface +4 (the candidates key and the entry's three members), the strictness count 96 to 97, the pin count 857 to 858, the reference totals 1669 to 1670. Nothing is removed or renamed.
  • MCP outputSchema of list_datasets gains the optional property from this PR on, before anything fills it. Right, and stated. The ADR note's last bullet and the changeset both say so.
  • matches, DatasetTermMatchSchema, DatasetTermMatchedOn, normalization, the input schema: untouched. Confirmed in the diff. member is taken from DatasetTermMatchSchema.shape.member with its own description; the generated reference page shows the match's member description unchanged and the candidate's own text on the new entry, so the re-describe did not overwrite the original.
  • Gate verdicts, read off the check-runs: Check Changeset, Spec property liveness, Lint · repo & tooling gates, Lint · docs & code guards, Type Check · source gates, Type Check · workspace, Test Core (10 shards), Governed Surface Queue Guard, PR-body guards: all success.

② Semver level

@objectstack/spec at minor, one changeset, no other package. That matches what the diff publishes: three additive exports and one optional output member, nothing removed. Check Changeset is success on the head.

Clause-②: yes (widening — an optional output field on a published schema). The line is the same in the PR body and in the changeset, and it is correct. Metadata-protocol: added replaces the claim's provisional none; the claim amendment (point 2) records it and the level gate agrees.

③ Boundary flags

  • Deviation: no matchedOn on a candidate, no near-word key. Accepted by the seat (amendment point 3). I agree: matchedOn is described as "which of the member's words the term equals", and a candidate has no such equality, so the key would publish a false statement. A near-word key would presume a substring rule, and D3 rule 1 also allows an embedding neighbour.
  • Open question (the ruling's "note that several readings may exist"): answered A by the seat (amendment point 4). I agree. The member's description carries the fact ("possible readings of a term ... for a clarifying question"), and a per-answer text field would be guidance text in a spec shape, which M1 A keeps out. Not escalated.
  • reading first: does list_datasets match a member's translated label from a translation bundle, or only an inline label map #34720 qualifier for D3 rule 1: not in this PR (amendment point 5). The note is one self-contained block and changes no D3 sentence, so a later add-only edit can carry it. Not a defect of this head.
  • Overlap with open draft feat(spec, runtime, lint): an action body refuses in the caller's language through a declared refusal catalogue #34719 (head 0169fc10): both PRs move content/docs/references/index.mdx and the pin count in type-alias-convention.pin.test.ts. A merge-order matter: whichever lands second merges main, regenerates and re-sums the pin. main has not touched either file since this PR's merge-base.
  • Skills-docs: follow-up owed still carries no card number at this head (amendment point 7 says the body names it once it has one). The PR-body guard is green; the seat owes the number before landing.
  • Extra files beyond the claim (the pin test, two generator outputs): recorded in amendment point 1.
  • SQL push-down: not applicable. The diff holds a schema, prose, tests and generator output; it adds no query, no id materialisation and no in-app join.
  • Security-touching is yes on purpose. Two changed hunks state permission behaviour: the candidates description ("Every candidate is a member this caller may read") and the ADR note ("only a member this caller may read is ever offered"). The PR is Tier H in any case (docs/adr/** and packages/spec/**), so the low-risk arm does not apply.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/ai/dataset-tools.zod.ts, against the ruling, ADR-0149 and its first consumer.

  • The shape holds against D3. A hit on main is always a member: matchDatasetTerms(terms, { dimensions, measures }) at dataset-tools.ts:439 compares only members, and matches[].member is the regex dimensions.NAME or measures.NAME. A candidate is at the same grain and reuses that one regex by reference, so the two cannot drift apart.
  • The pointer form holds against the first consumer. With terms the executor still returns every admitted dataset with its admitted members, so each pointer resolves inside the same answer and the entry repeats no label or description. Rule 3's question (label, dataset label, description) can be built from the answer alone.
  • .min(1).optional() gives "no candidates" one spelling. The test and the projected JSON Schema (minItems: 1, not in required) agree.
  • The jsdoc claim that the constant is declared ahead of the schema because of OS_EAGER_SCHEMAS=1 matches packages/spec/src/shared/lazy-schema.ts:31-35.
  • The description states facts and no instruction to the model, which is what M1 A asks.
  • I tried to break it on five cases and none did: a term whose only equal member is withheld from this caller (it has no match in the answer, so it may get candidates among readable members, and nothing withheld is named); a degraded answer with partial (the wording "no member of any listed dataset" stays true); a dimension hit with a zero-match measure word (rule 5 still needs a measure, and the measure word can carry candidates); a client on an older spec (a plain z.object drops the unknown key, no failure); an answer carrying both matches for one term and candidates for another (allowed by the shape and by the wording, which is per term).

N1, the point the seat asked about: the ruling says 「返回候选数据集」 and the shape returns { term, dataset, member }. This is within the ruling. The quoted sentence is the label of the option the maintainer picked; the ruling record itself then states the content as "a candidates list (near matches ...) for the client to ask back with", and ties it to ADR-0149 D3, where the thing a word matches is always a measure or a dimension of a dataset, never a dataset alone. Each candidate names its dataset, so "the candidate datasets" are exactly the dataset values in the list, and the shape gives the ruling's words plus one more fact: which number or grouping inside that dataset is offered. That extra fact is needed, because a person cannot answer "which did you mean" from a dataset name alone, and query_dataset needs a measure to run. The door record already on main (PR #34813, docs/design/mcp-local-first-door.md:110) says the same: "Which members are candidates, the entry shape, order and cap are the contract of #34761". One thing the shape cannot say, stated so that nobody has to infer it: a dataset that is near the word only by its own label or description, with no near member, cannot be listed, because member is required. Under D3 that dataset would not be an answer either (rule 5: no measure, no number), so nothing the ruling asked for is lost. 一句话:裁决选项的字面是「候选数据集」,实际返回的是「数据集 + 其中的指标或维度」;每条候选都带数据集名,所以不少于裁决所说,只是更细一层,仍在裁决范围内。唯一表达不了的是「只有数据集名字相近、没有任何相近成员」的情况,按 D3 这种情况本来也不能直接作答。

N2 (nit) — the cap cuts by catalogue order and the answer does not say when it cut. The description reads "at most 5 per term, the first in that order", and the order is terms as sent, datasets as listed, measures before dimensions. So for a common word (the near-miss words that motivated the ruling are generic: 金额, 销售额, revenue) the five shown are the first five the catalogue happens to list, not the nearest five, and the sixth is dropped with no marker. A client can tell only indirectly: a term with exactly five candidates may have more. This is the card's own proposal (order, no score, cap 5) and no declared sentence is wrong, so it does not block this head. It should be decided before #34763 fills the list: either the near rule is kept tight enough that five is rarely reached, or a later additive key states the cut. Whether the hotcrm catalogue reaches the cap on those words was not measured here. Carrier: #34763.

N3 (nit) — the permission sentence is a duty of the executor, and no schema holds it. "Every candidate is a member this caller may read, listed in datasets" cannot be enforced by a flat list of strings: nothing in the spec refuses a pointer to a dataset or member that the answer does not list. The dev report names the cap and the order as unenforced, but not this one, and this is the one with a security consequence: an executor that searched the unfiltered catalogue would publish the names of withheld or internal members. #34763 must draw candidates from the admitted entries only (after admitDatasetCatalogEntry), and must carry a test that every pointer resolves in the same answer. Carrier: #34763.

N4 (nit) — the module doc block credits the candidate rule to card #31589. The rewritten sentence lists "the rule that finds a zero-match term's candidates" among the things that "belong to @objectstack/service-analytics (card #31589)". The package is right; the card for that rule is #34763.

docs/adr/0149-...md, against its first consumer and its execution plan.

N5 (nit) — the note says "this PR" where ADR-0011's form gives the PR number. The card asked for ADR-0011:238's form, which reads "PR #33725, 1e65a389". This note's heading says "#34761 — this PR", and its last bullet starts "This PR declares the shape". Once merged, "this PR" names nothing in a record on main; it should read PR #34828. A fix moves the head, so it is left as an accepted deviation or folded into the later add-only edit that carries the #34720 qualifier.

Nits only: N2 and N3 go to #34763, N4 and N5 are left as accepted deviations or folded into a later edit. No delta review is owed.

Implemented-by: claude/issue-34761-list-datasets-candidates
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

席位记录 · 2026-11-17T13:01Z

Head-sha: 666309be7ec4379477340524ece0e735a22bd57b

维护者速读(终稿)

席位意见:建议批准。请留意一点:裁决选项的字面是「候选数据集」,实际返回的是「数据集 + 其中的指标或维度」。每条候选都带数据集名,所以不少于裁决所说,只是更细一层;而只靠数据集名,用户回答不了「你指的是哪个」,query_dataset 也需要具体指标。唯一表达不了的情况是「只有数据集名相近、没有任何相近成员」,而按 D3 这种情况本来也不能直接作答(L2 ④ N1)。

席位核对

@objectstack-fleet objectstack-fleet Bot added pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue security labels Nov 17, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 17, 2026 13:05
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit b633afe Nov 17, 2026
80 of 81 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-34761-list-datasets-candidates branch November 17, 2026 13:47
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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue protocol:ai security 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.

spec: list_datasets answers a term with no match with a candidates list, never selected; ADR-0149 D3 gains the amendment note

3 participants