Skip to content

Commit abb40ae

Browse files
docs(skills): the ask skill teaches withheldFields, the database top-N cut and totalGroups (#35268)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg1XdbbGasMNVx41tq3hZKV4)_ Fixes #35191 Fixes #35203 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:问数技能 `objectstack-ask` 多教三件事:字段被字段级权限隐藏(`withheldFields`)时说「你看不到」而不是「为空」;排名(前 N / 后 N)让数据库用 `orderBy` + `limit` 排好再截;结果被截断时引用 `totalGroups` 作为截断前一共多少组;`query_dataset` 没有 `totalGroups` 时说总数未知(`query_records` 分页自带 `total`,不受影响)。 - 为什么改:服务端已经返回 `withheldFields`、`totalGroups` 和数据库排名截断,但技能还没教,模型可能把隐藏字段说成空值,或把返回的行数当成总数。 - 风险与回滚:只改技能文字和由它生成的 `GET /mcp/skill` 页面,不改任何代码路径;回滚即 revert 本 PR。技能 token 天花板 1779 → 1877(+98),按常设裁决先删重复、余额按实测提高。 - 先看:`skills/objectstack-ask/SKILL.md`(第 4 步两条新句、第 6 步合并后的 `truncated` 句);`scripts/check-skills-token-ratchet.mjs` 的 ask 行注释;`skills/objectstack-ask/evals/metric-selection-fallback.json` 新增的 12、13 两例。 - 两分钟验证:`node scripts/check-skills-token-ratchet.mjs && node scripts/gen-mcp-ask-skill.mjs --check`,预期 ask 行 `1877 / 1877` 且生成模块 current。 - 需要你做的:本 PR 含 ratchet 行与 `packages/mcp` 生成模块,属 Tier H:需授权账号 APPROVED 审核,之后由席位落地。 ## What changes `skills/objectstack-ask/SKILL.md`, and `packages/mcp/src/ask-skill.generated.ts` regenerated from it: - **Step 4, `withheldFields` (#35191, line 1, card wording verbatim):** "`withheldFields` on a `query_records` or `get_record` answer names fields that exist but are hidden from you: say they are not visible to you, never that they are empty." It stays inside #35137's ruling A (comment 6977609191): the bullet speaks only of a field the answer names, and the server names only a field the caller's own served schema shows. - **Step 4, top or bottom N (#35191, line 2):** "For a top or bottom N, pass `orderBy` (an aggregation alias or a group key) and `limit: N`, so the database ranks and cuts the groups." The card's closing clause ("cite `totalGroups` as how many groups existed before the cut") moved, in those words, into the shared sentence below, as #35203 asks ("use one shared sentence for both"). - **Step 6, one shared `truncated` bullet (#35203):** "`truncated: true`: more rows or groups existed than came back; say the result is partial, and cite `totalGroups` as how many groups existed before the cut. Without it, say a `query_dataset` total is unknown, not `rowCount`." Source text: scope note 6982266158 and the `totalGroups` describe in `packages/spec/src/ai/dataset-tools.zod.ts` (present on both the pushed-down and the in-memory window, absent only where the count is not provable). It covers `query_dataset` and `aggregate_records` in one place, because step 6 is read on both the governed path (step 3) and the fallback (step 4). "Unknown" is scoped to `query_dataset`: `aggregate_records` always answers `totalGroups`, and a capped `query_records` page or `get_record` related list states its own `total` (contract review 6997032414, M1). - **Cut, the restatements the shared bullet replaces:** step 3's "`truncated: true`: more rows existed than came back. Say the result is partial." and step 4's "`truncated: true` on its answer means groups were cut off: say so." Step 3 keeps its `warning` sentence. - **Evals:** four cases in `skills/objectstack-ask/evals/metric-selection-fallback.json`: #12 (a `query_records` answer with `withheldFields: ['probability']` → "not visible", never "is empty" or "is blank"), #13 (a top-5 `query_dataset` answer with `truncated: true` and no `totalGroups` → "partial", total "unknown", never 5), #14 (an `aggregate_records` top-3 with `totalGroups: 41` → cites 41, never "unknown") and #15 (a capped `query_records` page with `total: 240` → says 240, never "unknown"). Evals are unpriced by the ratchet (ruling record 6513306068, part 1). - **Ratchet:** the `skills/objectstack-ask/SKILL.md` row moves 1779 → 1873 → 1877, each measurement written into its note. The raise path is the standing maintainer ruling 「A:先削重复,余额按实测提高」 (2026-10-27), which ruling record 6513306068 (letter B) made the gate-recognised path: the restatements above are cut in the same file first (-151 bytes), and the row moves by the measured remainder only. Text net +377 bytes: 7135 → 7512, less the 20-byte stamp line, `ceil(7492 / 4)` = 1873 (+94); the M1 fix then took the step-6 bullet from 215 to 230 bytes: 7512 → 7527, `ceil(7507 / 4)` = 1877 (+4). Pinned AT the measurement with zero headroom. No other row moves. - **Changeset:** `.changeset/35191-ask-skill-withheld-totalgroups.md`, `patch` on `@objectstack/skills` and `@objectstack/mcp` (the generated module ships in `@objectstack/mcp`). `content/docs/ai/skills-reference.mdx` and `skills/README.md` were regenerated (`gen:skill-docs`) and came out byte-identical: they render the frontmatter only, which is unchanged. ### Skills size readings (`skills/**` touched) | Reading | Before (`origin/main` e8a78c4) | After (this head) | |:--|--:|--:| | `skills/objectstack-ask/SKILL.md` lines | 120 | 125 (+5) | | `skills/objectstack-ask/SKILL.md` ratchet tokens | 1779 | 1877 (+98) | | Bundle, all 13 `skills/*/SKILL.md`, lines | 4830 | 4835 (+5) | | Bundle, all 13 `skills/*/SKILL.md`, bytes | 253765 | 254157 (+392) | No re-wrap is counted as payment: the one re-flowed line (step 3's `warning` sentence, now on one line) moves 2 bytes and is inside the net figure. ## Tests <details><summary>Ask-skill single source and the mcp package</summary> - `pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/skill-single-source-34686.test.ts` → `Tests 3 passed (3)` (the generated module and the served `/mcp/skill` section equal the skill's data loop). - `pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2` → `Test Files 77 passed (77)`, `Tests 1400 passed (1400)`. - `pnpm --filter @objectstack/mcp typecheck` → exit 0; `check:test-typecheck: OK`. - Built first: `pnpm --workspace-concurrency=2 --filter '@objectstack/mcp...' build` → lock `VERDICT command-exit 0`. - All of the above re-run on head `f7e199c4` with the same results (one lock run, `VERDICT command-exit 0`). </details> No ablation: the diff changes served text and a ratchet row, no tested behaviour. ## Acceptance notes - The dispatch asked the lines to pay for themselves in the file. Cutting restatement covered 151 of 528 added bytes; the rest of the file outside step 1/2 (held by #35158) carries no further restatement, so the row moves by the measured remainder under ruling 6513306068 letter B, quoted above. The seat's contract review checks the deletion and the quote. - The shared sentence's "say the result is partial" half is general to `truncated: true` and true on all four answers that carry it. Its count half reaches only the analytics answers: it cites `totalGroups` where the answer has one, and says the total is unknown only for a `query_dataset` answer without it. A capped `query_records` page and a `get_record` related list carry no `totalGroups` and state their own `total`, which the bullet leaves alone (eval #15 pins it). ## Verification <details><summary>Local gate subset (dispatch-gates --commands, narrowed to this diff)</summary> Derived by `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at ef142a1 and again at f7e199c (the same 88 commands); the readings below are from f7e199c. 85 exit 0, including `node scripts/check-skills-token-ratchet.mjs` (`skills/objectstack-ask/SKILL.md is 1877 tokens (ceiling 1877; headroom 0)`), `pnpm --filter @objectstack/spec run check:skill-docs`, `pnpm check:nul-bytes`, `pnpm check:doc-authoring`, `node scripts/check-adr-0087-registration.mjs --base origin/main`, `node scripts/check-empty-changeset.mjs --base origin/main`. `node scripts/gen-mcp-ask-skill.mjs --check` → current. NOT MEASURED locally (exit 3, PREREQUISITE NOT MET, CI runs them): `node scripts/check-plugin-teardown-shape.mjs --self-test` (shallow clone cannot reach its pinned fixture commit) and `pnpm check:dual-build-cjs-loads` (needs every package's `dist/`; only the mcp closure was built). `pnpm check:pm-dispatch-gates` (run outside the 88 above, in the background with a foreground wait): `✓ dispatch-gates self-test (fast tier): 2249 cases pass`, exit 0. Reconciliation: `node scripts/pm/dispatch-gates.mjs --ran` with exit codes recorded → `88 derived famil(ies) accounted for — 86 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)`. The gate union ran on head `f7e199c4`. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7 <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f848e37 commit abb40ae

5 files changed

Lines changed: 100 additions & 11 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/skills': patch
3+
'@objectstack/mcp': patch
4+
---
5+
6+
docs(skills): the `objectstack-ask` skill reads `withheldFields`, asks `aggregate_records` for a top or bottom N, and answers "how many" from `totalGroups`
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The `objectstack-ask` skill, and the page at `GET /mcp/skill` that is generated from it, now tell a connected client three things. In step 4: a `query_records` or `get_record` answer whose `withheldFields` names a field means the field exists but is hidden from the caller, so the client says it is not visible, never that it is empty; and a top or bottom N is asked of `aggregate_records` with `orderBy` (an aggregation alias or a group key) and `limit: N`, so the database ranks and cuts the groups. In step 6, one bullet covers `truncated: true`: more rows or groups existed than came back, so the client says the result is partial, and cites `totalGroups` (answered by `query_dataset` and `aggregate_records`) as how many groups existed before the cut; a `query_dataset` answer without `totalGroups` has an unknown total, never `rowCount`. A capped `query_records` page keeps stating its own `total`, which the bullet leaves alone.
12+
13+
The two per-tool `truncated` sentences that bullet replaces are removed from steps 3 and 4. `packages/mcp/src/ask-skill.generated.ts` is regenerated from the skill; no code path changes.

‎packages/mcp/src/ask-skill.generated.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ export const ASK_SKILL_DATA_LOOP: string = [
6868
' `provenance` (the dataset\'s label and each measure\'s label, as in',
6969
' 「指标:营收(数据集:销售分析)」), not from memory.',
7070
'- Use the measure\'s `description` to say what the number includes and excludes.',
71-
'- `truncated: true`: more rows existed than came back. Say the result is',
72-
' partial. A `warning` on the answer narrows what you were allowed to read:',
73-
' repeat it.',
71+
'- A `warning` on the answer narrows what you were allowed to read: repeat it.',
7472
'',
7573
'## 4. Fallback: object queries',
7674
'',
@@ -82,8 +80,12 @@ export const ASK_SKILL_DATA_LOOP: string = [
8280
' read. Read its fields before you filter: a field with `options` is filtered',
8381
' by the option\'s `value`, never its label.',
8482
'- Use `aggregate_records` for a count, sum, average or breakdown. Never page',
85-
' through `query_records` to add numbers up yourself. `truncated: true` on its',
86-
' answer means groups were cut off: say so.',
83+
' through `query_records` to add numbers up yourself. For a top or bottom N,',
84+
' pass `orderBy` (an aggregation alias or a group key) and `limit: N`, so the',
85+
' database ranks and cuts the groups.',
86+
'- `withheldFields` on a `query_records` or `get_record` answer names fields',
87+
' that exist but are hidden from you: say they are not visible to you, never',
88+
' that they are empty.',
8789
'- Open the answer with one line saying it is not from a governed metric',
8890
' (非指标口径), and name the object and fields you computed it from.',
8991
'- When that object is a listed dataset\'s `object`, add one line naming the',
@@ -102,5 +104,8 @@ export const ASK_SKILL_DATA_LOOP: string = [
102104
'- Answer in the user\'s language.',
103105
'- Show labels, not machine names or raw option values.',
104106
'- Every figure comes from a tool answer in this conversation.',
107+
'- `truncated: true`: more rows or groups existed than came back; say the',
108+
' result is partial, and cite `totalGroups` as how many groups existed before',
109+
' the cut. Without it, say a `query_dataset` total is unknown, not `rowCount`.',
105110
'- State the filter and the time window you used, in words.',
106111
].join('\n');

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,33 @@ export const CEILINGS = new Map([
19231923
// ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(7115 / 4)
19241924
// = 1779 (+29), the measured remainder only. Pinned AT the measurement, zero
19251925
// headroom; no other row moves.
1926-
['skills/objectstack-ask/SKILL.md', 1779],
1926+
// 1779 -> 1873, the cards that teach the object tools' new members: step 4
1927+
// says `withheldFields` names fields that exist but are hidden (never empty),
1928+
// and how to ask `aggregate_records` for a top or bottom N; one shared
1929+
// `truncated` bullet in step 6 answers "how many" from `totalGroups` for
1930+
// `query_dataset` and `aggregate_records` alike, and says the total is
1931+
// unknown without it. Same raise path (ruling record 6513306068, letter B).
1932+
// PAID DOWN FIRST — the per-tool `truncated` restatements cut, the shared
1933+
// bullet keeping their one home: step 3's "`truncated: true`: more rows
1934+
// existed than came back. Say the result is partial." and step 4's
1935+
// "`truncated: true` on its answer means groups were cut off: say so."
1936+
// Cuts -151 bytes, net +377: 7135 -> 7512 bytes, less the 20-byte stamp line:
1937+
// ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(7492 / 4)
1938+
// = 1873 (+94), the measured remainder only. Pinned AT the measurement, zero
1939+
// headroom; no other row moves.
1940+
// 1873 -> 1877, re-measured on the same PR before it landed, after its
1941+
// contract review (record 6997032414, M1) found the shared bullet telling the
1942+
// agent a total is unknown on a capped `query_records` page, which states
1943+
// its own `total`. The bullet now cites `totalGroups` as the pre-cut count and
1944+
// scopes "unknown" to a `query_dataset` answer without it (`aggregate_records`
1945+
// always answers it). Same raise path (ruling record 6513306068, letter B);
1946+
// the restatements were cut on the row's previous measurement and nothing
1947+
// else in the file restates it. Bullet 215 -> 230 bytes: 7512 -> 7527 bytes,
1948+
// less the 20-byte stamp line:
1949+
// ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(7507 / 4)
1950+
// = 1877 (+4), the measured remainder only. Pinned AT the measurement, zero
1951+
// headroom; no other row moves.
1952+
['skills/objectstack-ask/SKILL.md', 1877],
19271953

19281954
// ── the objectstack-project skill joins the catalog ──
19291955
// A new published process skill: how a change moves through a metadata-app

‎skills/objectstack-ask/SKILL.md‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ be incomplete; `warning` says why, and you repeat it when you fall back.
8383
`provenance` (the dataset's label and each measure's label, as in
8484
「指标:营收(数据集:销售分析)」), not from memory.
8585
- Use the measure's `description` to say what the number includes and excludes.
86-
- `truncated: true`: more rows existed than came back. Say the result is
87-
partial. A `warning` on the answer narrows what you were allowed to read:
88-
repeat it.
86+
- A `warning` on the answer narrows what you were allowed to read: repeat it.
8987

9088
## 4. Fallback: object queries
9189

@@ -97,8 +95,12 @@ be incomplete; `warning` says why, and you repeat it when you fall back.
9795
read. Read its fields before you filter: a field with `options` is filtered
9896
by the option's `value`, never its label.
9997
- Use `aggregate_records` for a count, sum, average or breakdown. Never page
100-
through `query_records` to add numbers up yourself. `truncated: true` on its
101-
answer means groups were cut off: say so.
98+
through `query_records` to add numbers up yourself. For a top or bottom N,
99+
pass `orderBy` (an aggregation alias or a group key) and `limit: N`, so the
100+
database ranks and cuts the groups.
101+
- `withheldFields` on a `query_records` or `get_record` answer names fields
102+
that exist but are hidden from you: say they are not visible to you, never
103+
that they are empty.
102104
- Open the answer with one line saying it is not from a governed metric
103105
(非指标口径), and name the object and fields you computed it from.
104106
- When that object is a listed dataset's `object`, add one line naming the
@@ -117,4 +119,7 @@ be incomplete; `warning` says why, and you repeat it when you fall back.
117119
- Answer in the user's language.
118120
- Show labels, not machine names or raw option values.
119121
- Every figure comes from a tool answer in this conversation.
122+
- `truncated: true`: more rows or groups existed than came back; say the
123+
result is partial, and cite `totalGroups` as how many groups existed before
124+
the cut. Without it, say a `query_dataset` total is unknown, not `rowCount`.
120125
- State the filter and the time window you used, in words.

‎skills/objectstack-ask/evals/metric-selection-fallback.json‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,46 @@
110110
"must_contain": ["trip request"],
111111
"must_not_contain": ["aggregate_records", "query_records", "query_dataset", "非指标口径"]
112112
}
113+
},
114+
{
115+
"id": 12,
116+
"prompt": "The user asks: \"List the open opportunities with their probability.\" No dataset matches, so you fell back: `describe_object({ objectName: 'opportunity' })` lists the fields `name`, `stage` and `probability`, and `query_records` answered three open opportunities (Acme Renewal, Globex Expansion, Initech Pilot), each with `name` and `stage` but no `probability`, plus `withheldFields: ['probability']`. How do you write the answer?",
117+
"expected_output": "Opens with one line saying the list is not from a governed metric and names the Opportunity object and its fields. Lists the three opportunities by name and stage, and says the probability field exists but is not visible to it, because `withheldFields` names it. It never says the probability is empty, blank or zero, and gives no probability value.",
118+
"files": [],
119+
"assertions": {
120+
"must_contain": ["not visible", "Acme Renewal"],
121+
"must_not_contain": ["is empty", "is blank", "are empty", "are blank"]
122+
}
123+
},
124+
{
125+
"id": 13,
126+
"prompt": "The user asks: \"Which 5 industries bring in the most revenue, and how many industries are there?\" `revenue` and `industry` match one measure and one dimension of `sales_analysis` (label Sales Analysis). `query_dataset` with `order` on revenue descending and `limit: 5` answered five rows (Software, Retail, Banking, Energy, Health), `rowCount: 5`, `truncated: true`, and no `totalGroups`. How do you write the answer?",
127+
"expected_output": "Cites the answer's source, then lists the five industries by revenue and says the result is partial: more industries exist than came back. Because the answer carries no `totalGroups`, it says the total number of industries is unknown. It never gives 5 (`rowCount`) as how many industries there are.",
128+
"files": [],
129+
"assertions": {
130+
"must_contain": ["Software", "Health", "partial", "unknown"],
131+
"must_not_contain": ["there are 5", "there are five"]
132+
}
133+
},
134+
{
135+
"id": 14,
136+
"prompt": "The user asks: \"Which 3 accounts have the most open opportunities, and how many accounts have any?\" No dataset matches, so you fell back on `opportunity`. `aggregate_records` with a count grouped by `account`, `orderBy` on the count descending and `limit: 3` answered three groups (Acme 12, Globex 9, Initech 7), `truncated: true` and `totalGroups: 41`. How do you write the answer?",
137+
"expected_output": "Opens with one line saying it is not from a governed metric, naming the Opportunity object and its account field. Lists the three accounts with their counts, says the result is partial, and cites 41 as how many accounts have open opportunities (the groups before the cut). It does not give 3 as that number.",
138+
"files": [],
139+
"assertions": {
140+
"must_contain": ["Acme", "41", "partial"],
141+
"must_not_contain": ["unknown"]
142+
}
143+
},
144+
{
145+
"id": 15,
146+
"prompt": "The user asks: \"List the open support tickets and how many there are.\" No dataset matches, so you fell back: `query_records` on `support_ticket` answered a page of 50 records with `total: 240` and `truncated: true`, and no `totalGroups`. How do you write the answer?",
147+
"expected_output": "Opens with one line saying it is not from a governed metric, naming the Support Ticket object. Says there are 240 open tickets, from the answer's `total`, shows the 50 that came back and says the list is partial. It never says the total is unknown, and never gives 50 as the total.",
148+
"files": [],
149+
"assertions": {
150+
"must_contain": ["240", "partial"],
151+
"must_not_contain": ["unknown"]
152+
}
113153
}
114154
]
115155
}

0 commit comments

Comments
 (0)