Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/39152-qualified-phrase-no-second-reading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@objectstack/service-analytics': patch
---

fix(analytics): `list_datasets` no longer reads a qualified phrase by its last word

Clause-②: no
Metadata-protocol: none

A phrase sent to `list_datasets` in `terms` that is near no member by itself is read a second time, and that second reading now only takes off the words that do not say which number is meant: total words (`total`, `sum`, `overall`, `合计`), short joining words (`of`, `the`, `our`, `so far`) and what follows `by`, `per`, `for`, `to` and similar words. What remains is tested whole. A phrase that keeps another word beside its noun is no longer read by that noun alone, so it has no entry in `candidates`; sent alone or beside a grouping word, the answer's `nextStep.note` sends it to the object tools, and the assistant gives the figure, says no governed metric was used, and asks nothing.

Asked "how many sales orders are in each status?" or "what is the overdue balance by owner?", an assistant that sends `sales orders` or `overdue balance` used to get `candidates_only` with an order-count measure or two balance measures, and asked the user which measure was meant instead of giving a figure. Neither measure is the number asked for.

- This corrects the earlier note for the second reading in this release. A phrase is not read by a "head word", its last word that names what is measured: `sales orders` is not read as `orders`, and `booking count` is not read as a count. Both keep both words and are offered nothing. The same holds for `paid claims`, `hotel spend`, `confirmed orders` and `total booking amount`.
- A phrase that carries only total, joining or `by` words beside its noun is read as before: `booking total`, `total booking`, `booking total by status`, `claimed so far` and `成交合计` are offered the same measure, and the assistant asks about it.
- A bare noun is unchanged: `balance` is still offered both balance measures and `orders` the order count, and the assistant asks. To have a phrase such as `sales orders` select a measure, declare it as one of the measure's `synonyms`.
- What remains after the total word is tested whole in every script: `open invoice total` is read as `open invoice`, as `未结发票合计` is read as `未结发票`.
- What counts as a match is unchanged: only equality after normalization.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ Why the platform computes `matches` instead of leaving the whole rule to the mod
> - **What this note narrows, and the sentences read with it.** It narrows the point ruled on #34691, fork F1, option B, as the note of 2026-11-19 left it: "a measure candidate is still asked about and never selected". For a measure this note takes out, the first half no longer holds: it is not asked about. "Never selected" stands for it. Every sentence above that speaks of a measure candidate, or of a term with a measure among its candidates, stands as written and is read with this scope, the measures it counts being the ones this note leaves: the headline of the note of 2026-11-17 ("offered for a question and never selected") and its third point; the headline and the second point of the note of 2026-11-19, and its "A measure candidate, and every candidate of a term with a measure among its candidates, stays as ruled"; and "a word with a measure among its candidates" in the note of 2026-11-24. The note of 2026-11-17 also says that which members are near enough to offer "is the executor's rule": this note adds one exclusion to it, and that exclusion is the record's, not the executor's.
> - **State on `main`.** PR [#38848](https://github.com/objectstack-ai/objectstack/pull/38848) changes the record and nothing else. The executor (`packages/services/service-analytics/src/dataset-term-matcher.ts#findDatasetTermCandidates`, `packages/services/service-analytics/src/dataset-next-step.ts#composeDatasetNextStep`), the two texts that carry the rule to a model (`packages/services/service-analytics/src/dataset-tools.ts#LIST_DATASETS_DESCRIPTION`, `packages/mcp/src/mcp-server-runtime.ts#DATASET_SELECTION_RULE`) and the spec's account of what a candidate is offered for (`packages/spec/src/ai/dataset-tools.zod.ts#ListDatasetsOutputSchema`, `packages/spec/src/ai/dataset-tools.zod.ts#DatasetTermCandidateSchema`) follow in the second PR of #38551. A third text restates the rule: step 2 of the published ask skill (`skills/objectstack-ask/SKILL.md`), the text the note of 2026-11-19 brought to the rule. That step follows on a skills card of its own, which was not filed when this note was written. One more fact stands at this head: `nextStep.note` is declared as "composed by the tool from this answer" (`packages/spec/src/ai/dataset-tools.zod.ts#DatasetNextStepSchema`), and the catalogue lists no `field` for a measure (`packages/spec/src/ai/dataset-tools.zod.ts#DatasetToolCatalogMeasureSchema`), so the field that sentence will name is in no entry of the answer. Until the second PR lands, such a measure is still offered and asked about. In [D6](#d6--enforce-or-remove-every-key-names-its-reader-in-its-first-implementation-card)'s terms what is pending is named here and not hidden: the executor's half by its card, the skill's by the file that owes it until its card exists.

> **Amendment note (2026-12-03, [#39152](https://github.com/objectstack-ai/objectstack/issues/39152) — this PR): the second reading of a phrase takes off only the words that do not say which number is meant; a phrase that keeps another word beside its noun is not read a second time by that noun.**
> Ruled by the maintainer on [#39152](https://github.com/objectstack-ai/objectstack/issues/39152), on the question 「定 #39152:清楚的数字题被反问,问数怎么改?」, option text verbatim 「P 两步都做」 (ruling record [`7363768737`](https://github.com/objectstack-ai/objectstack/issues/39152#issuecomment-7363768737)). This note records the first of the two steps. The second, about a measure candidate whose dataset cannot give the grouping the question asks for, owes a note of its own and is not stated here. Which members are near enough to offer stays the executor's rule (the note of 2026-11-17); this note states the principle that rule follows, and changes no shape.
>
> - **The principle.** A candidate is put in a question, and the question is worth asking only when its answer can lead to the governed figure for what was asked. A measure near one word of a phrase, while the phrase says more than that word, is a wider number than the one asked for: neither "Outstanding balance" nor "Open balance" is the overdue balance. So the second reading offers such a phrase nothing.
> - **This note governs the second reading only.** The first reading, containment either way between the whole phrase and a member's own name, label or synonym, is the executor's rule of the note of 2026-11-17 and is unchanged: it is not ruled on here. A measure one of whose own targets is wholly inside the phrase is still offered and asked about: a measure with the synonym "orders" is still offered for "sales orders", and one labelled "Balance" for "overdue balance". Whether the first reading should follow the same principle is not ruled.
> - **What the executor takes off a phrase, and nothing else.** A phrase near no member by itself is read a second time without its total words ("total", "sum", 合计), its joining words ("of", "our", "so far") and what follows "by", "per" and the like. Those words do not say which number is meant. What remains is tested whole, by the same containment, against measures only. "booking total" is read as "booking" and "claimed so far" as "claimed", and each is offered the measure whose synonym or label carries that word.
> - **Any other word stays, and the phrase is tested with it.** A word that says which records ("overdue", "paid", "sales") or what kind of number ("count", "amount") is part of what was asked. "overdue balance", "sales orders", "paid claims" and "hotel spend" lose nothing, so they have no second reading: where the first reading found no member near them, they have no candidate. A spaced phrase is read as an unspaced one already was: 逾期余额 was never read as 余额.
> - **With no candidate, rule 4 governs, as the notes above say.** The figure comes from the records, labelled 「非指标口径」, and nothing is asked. The example of the note of 2026-11-24, `["sales orders", "status"]`, stands beside an "Order count" measure as it stood without one.
> - **A bare noun is still asked about.** "balance" alone is near both balance measures and "orders" alone is near "Order count": each is offered and asked about, never selected (the note of 2026-11-17). A plain record noun is not read as its count measure by inference; an app that wants "sales orders" to select a measure declares it as a `synonym` ([D1](#d1--business-vocabulary-on-measures-and-dimensions-synonyms-and-description)).
> - **What does not change.** What counts as a hit (rule 1), `matches`, the `candidates` shape, its order and its cap, and the four `nextStep.decision` values. The notes of 2026-11-19, 2026-11-24 and 2026-12-01 stand as written, the cases each lists under "Not covered" included.
> - **State on `main`.** The second reading first landed reading a phrase by its last word that is not a total word, in PR [#39017](https://github.com/objectstack-ai/objectstack/pull/39017), with no note here; no release carried that form. This PR brings the executor (`packages/services/service-analytics/src/dataset-term-matcher.ts#readDatasetTerms`) to the principle above and pins the ruled phrases both ways.

### D4 — Permissions: the tools add no gate and bypass none

Measured in [Context](#the-executor-and-its-gate-chain-measured-on-originmain). The binding statements:
Expand Down
Loading
Loading