Repository navigation
Commit b633afe
feat(spec): the list_datasets output declares candidates for a term that matched nothing (ADR-0149 D3) (#34828)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_
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 只声明形状,不改执行器。
- 为什么改:#34691 F1 的裁决(选 B,记录
6943126855):零命中时由服务器返回候选,任何客户端都读得到,不靠技能或工具描述的措辞。「什么算命中」不变,平台永不替用户选。
- 风险与回滚:只加一个可选输出字段,不带该字段的返回解析结果与之前相同。服务器填充在 #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 #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.
<details><summary>What the new cases pin</summary>
- 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`.
</details>
<details><summary>Ablations (three, each restored)</summary>
Each mutation went through `scripts/ablation-replace.mjs` on
`dataset-tools.zod.ts`, and each restore ended with "ok restored: blob
== HEAD (bbb4dce) 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.
</details>
## Acceptance notes
- **The key is declared and nothing fills it yet.** Until #34763 lands
no answer carries `candidates`. The tool's `outputSchema` lists the
optional member from this PR on. The ADR note says so in its last
bullet.
- **File surface.** Three files are beyond the list in the claim.
`content/docs/references/index.mdx` and
`docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md` are
generator output (`gen:docs`, `gen:strictness-ledger`).
`packages/spec/src/type-alias-convention.pin.test.ts` is a hand edit
that `check:spec-parsed-alias` demands for any new bare input alias.
- **Overlap with open PR #34719.** `node scripts/pm/overlap-check.mjs`
exits 1: both PRs move the totals in `content/docs/references/index.mdx`
and the pinned count in `type-alias-convention.pin.test.ts`.
`origin/main` merges cleanly. Whichever lands second merges `main`,
re-runs `gen:docs` and sets the count to the sum.
- **Pending: the #34720 qualifier.** As the seat relayed it to this dev,
#34720 is ruled (record `6946563869`; not read here) and rule 1 of D3
will need a qualifier for it. Card #34761 does not carry that amendment
(body and both comments re-read after the last commit; the card was last
updated 2026-11-17T10:53:47Z), so this note does not write it. The note
is one self-contained block and changes no existing D3 sentence, so a
later sentence can be added to it.
- **The ruling record's "note that several readings may exist".** Record
`6943126855` describes candidates as "near matches, with a note that
several readings may exist". This PR carries that as the member's
description ("possible readings of a term ... for a clarifying
question"), not as a text field in the result. A result field for it
would be a second, per-answer copy of guidance text, which M1 A keeps
out of the spec. Raised in the dev report as an open question.
- **No second pointer under D2.** D2's "Output" sentence is unchanged
(the note is add-only), and the D3 note names D2.
- **The entry is a plain `z.object`.** The strictness count for `ai/`
moves 96 to 97 object sites; `ai/` is an untriaged directory in that
ledger.
- **The skill file in the `Skills-docs:` line** arrives with PR #34792
and is not on `main` yet.
- **Shallow clone.** This checkout is shallow. No claim here rests on
history dates or ancestry.
## 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`.
<details><summary>Selected verdict lines</summary>
| 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" |
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; the repo-wide `pnpm lint` is left to CI (the
three changed TypeScript files lint clean).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English (the 维护者速读 block is
Chinese by the dev agent's rule).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done, with the
repo-wide runs left to CI as stated above.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzfR33NbV51QQU6R6bm -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6320abb commit b633afe
13 files changed
Lines changed: 227 additions & 15 deletions
File tree
- .changeset
- content/docs/references
- ai
- docs
- adr
- audits/2026-07-unknown-key-strictness-ledger.counts
- packages/spec
- api-surface
- authorable-surface
- declaration-map
- export-origins
- json-schema.manifest
- src
- ai
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
45 | | - | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
88 | 103 | | |
89 | 104 | | |
90 | 105 | | |
| |||
211 | 226 | | |
212 | 227 | | |
213 | 228 | | |
| 229 | + | |
214 | 230 | | |
215 | 231 | | |
216 | 232 | | |
| |||
225 | 241 | | |
226 | 242 | | |
227 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
228 | 252 | | |
229 | 253 | | |
230 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
159 | 170 | | |
160 | 171 | | |
161 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
| |||
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| 248 | + | |
245 | 249 | | |
246 | 250 | | |
247 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
0 commit comments