Skip to content

fix(analytics): list_datasets offers a measure for a phrase whose head word it carries - #39017

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-38953-booking-head-word
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-38953-booking-head-word

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread
Part of #38953
Claim for this branch: #38953 comment 7330351836
Clause-②: no
Metadata-protocol: none
What remains: the eval seat's daily round measures dq_booking_total on both arms (the card's acceptance: two consecutive days, or 4/5 or better at 5 reps on both arms). This PR is route P's executor half only.

维护者速读

  • 用户能看到什么变化:在问数里用"订单合计""booking total"这类带"合计、总额"字样的说法提问时,助手现在会先列出最接近的已治理指标并反问确认,而不是自己算一个非指标口径的数字;行为变化也包括:像"工时合计"这样中心词恰好是某个字段名的说法,过去直接按字段兜底、不提问,现在会先问是不是那个口径更窄的指标(单说"工时"仍按字段回答);其它问法的回答不变。
  • 为什么做:属于"问数"专题(用业务词向数据提问),解决评测里这道"订单合计"题在两组配置下连续多轮都答错的问题。
  • 出错会怎样:规则若偏宽,用户最多被多问一句"是不是指某个指标",答"不是"后照常得到答案;已经精确命中的指标不受影响,改动可以直接整体撤回。
  • 要你做什么:无。

What changes

list_datasets term matching (dataset-term-matcher.ts), executor side of ADR-0149 D3's candidate rule. Rule 1 (equality after normalization is the only hit) is untouched; matches, the candidates shape, its order and its cap are untouched.

A term that is near no member of any listed dataset (today's containment test, either way, two code points) is now read a second time, by its head word, and a measure near the head is offered as a candidate for the phrase. The second reading offers no dimension: the head names the thing measured, so a head near no measure leaves the term with no candidate and rule 4's labelled fallback, as on main (balance due, whose head due is near only the dimension labelled "Days past due", stays no_measure). The first reading keeps both kinds, untouched. The head word is:

  • the phrase cut at the first of by, per, for, in, at, on, from, to, during, over, across, vs, versus;
  • then its last space-separated word that is not a total word (total, totals, subtotal, sum, sums, overall, grand) or a short joining word (of, the, our, so, far, this, ...);
  • with an unspaced total word (合计, 合計, 总计, 總計, 総計, 总额, 總額, 総額) cut once from its end, or else its start;
  • none when that word is under two code points or is the whole term.

Kind words (amount, value, count, number, 金额, 数量) are deliberately not skipped: "deal value" and "deal count" are different numbers.

The second reading never adds to the first: a term near any member by itself keeps exactly today's candidates. The 2026-12-01 take-out (a filtered measure whose field the term names) still tests the whole term, as the amendment note defines "named by the term". isNearDatasetTerm (the host's narrowing of which field labels to read) answers for the term or its head, a superset, so no offered measure goes unread.

Design points answered (claim route P)
  1. Measure first. On docs/qa/scenarios/builds/order_to_cash.json (blob 7cb264d4), order_book.booked_amount is label "Booked amount", synonyms bookings, revenue, 营收, 订单金额, 成交额, field total_amount, no filter. Today "booking total" misses because neither side contains the other for any target: no target contains "booking total", and the phrase contains no whole target (it holds "booking", not "bookings"). The single word "booking" is near only because the target "bookings" contains it.
  2. The rule. Head-word containment, reusing the existing isNear on the head. "booking" reaches "Booked amount" through the synonym "bookings" the fixture already carries: no stem, prefix rule, edit distance or embedding. The file's own sentence ("No edit distance, stem or embedding") stays true.
  3. Head versus any word. The first build used any non-generic word, and the existing pins in dataset-tools.test.ts went red on two real false positives: "sales orders" offered a sales amount (the modifier "sales"), and "deal value" offered a count once "value" was skipped. The head (last word before a cutting word, total words skipped) removes both, and kind words stay heads. Per-term gains over the two committed scenario builds (115 terms: every member name, label and synonym, plus 50 phrases): 12 terms gain candidates, each from zero, all of them measures, at most 3; the other 103 are unchanged.
  4. Interactions. The 2026-12-01 note: dataset-term-names-field-38551.test.ts, green, unedited. The 2026-11-19 note (dimension-only candidates are a possible grouping) and the 2026-11-24 note: the grouping-word, precedence and app-crm blocks of dataset-tools.test.ts, green, unedited. No nextStep sentence became false, so no runtime sentence of dataset-next-step.ts changes; one doc comment there now names the head-word reading of measures (review nit N5, comments only).
  5. CJK. A phrase with no spaces is one token: the first reading (whole term) is unchanged, so 金额 near 合同金额 and back stay as pinned. The second reading cuts one total word: 成交合计 gives 成交, inside 成交额. 订单合计 gives 订单 (two candidates: booked amount, order count). A one-code-point total prefix (总) is not cut; 总营收-style phrases are already near through the whole-term test.
  6. ADR. No ADR-0149 text needs to change: rule 1 says a substring may be offered and never acted on, and the note of 2026-11-17 leaves which members are near enough to the executor.
  7. Red-first. See Tests.
Per-term gains on the scenario builds (12 of 115 terms change, all from 0, measures only)
build term candidates after
order_to_cash booking total order_book.booked_amount
order_to_cash 成交合计 order_book.booked_amount
order_to_cash order total order_book.order_count
order_to_cash invoice total receivables_aging.open_invoice_count
order_to_cash billing total billing.billed_amount
order_to_cash orders by status order_book.order_count
order_to_cash total booking amount billed_amount, open_balance, booked_amount (head "amount")
order_to_cash 订单合计 booked_amount, order_count
order_to_cash 订单总额 booked_amount, order_count
travel_expense claimed so far reimbursement.claimed_amount
travel_expense 报销合计 claimed_amount, claim_count
travel_expense claim total claimed_amount, claim_count

Unchanged and still falling back: balance due (its head is near only a dimension), number of payments, payments, 付款笔数, employees, number of employees (the card's two fallback_labelled questions).

Tests

New pins as one top-level describe('[#38953] …') in the matcher's existing test file packages/services/service-analytics/src/__tests__/dataset-term-matcher.test.ts (9 tests), on the scenario build's three datasets copied member by member: the card's case at the list_datasets door (candidates_only, the one candidate, empty matches, the schema parse), the matcher, head-not-any-word, preservation of the first reading, total-only phrases falling back, CJK, the cap, the measures-only head reading (balance due is no_measure with no candidates; order total keeps order_count, loses only the order_status dimension and stays candidates_only), and the 2026-12-01 cell: a filtered "Billable hours" over field hours is asked about for "hours total" (candidates_only) while "hours" alone is still answered from the field (no_measure, the field named).

Red-first ablation (matcher at the merge base, then restored)

Committed head bf875b3f87 (matcher blob 0ca02122); mutation: git restore --source=571b4947b1 of the matcher, on-disk blob b67074bf = base blob. Run of dataset-term-matcher.test.ts: Tests 6 failed | 13 passed (19). The six red are the card's case at the door (expected 'no_measure' to be 'candidates_only'), the matcher case, head word, CJK, cap, and the "hours total" cell (expected 'no_measure' to be 'candidates_only'); the two preservation pins and the 11 older matcher pins stay green on both trees, as they should. Restored with git checkout HEAD --: blob 0ca02122, git diff HEAD 0 bytes, git status --porcelain empty.

The S1 guard, test first and then ablated. The balance due pin was written first and run against the bf875b3f87 matcher: Tests 1 failed | 19 passed (20) (expected 'candidates_only' to be 'no_measure'), green after the change. At head bd0821d8c2 (matcher blob 4ac6f758), node scripts/ablation-replace.mjs turned the head pass's dimensions flag from false to true; the anchor went from 1 to 0, blob 2c0ac008. Result: Tests 2 failed | 18 passed (20), failing the measures-only pin and the booking count pin. Restored: blob 4ac6f758, git diff HEAD empty.

Package suite and typecheck
  • Second fix round (contract review S1), head bd0821d8c2: the same three files: Tests 131 passed | 10 skipped (141); typecheck exit 0. Diff vs main: 4 files, +375 / -22 (the fourth is a comment-only update to dataset-next-step.ts, review nit N5).
  • Fix round, head bf875b3f87: dataset-term-matcher.test.ts, dataset-term-names-field-38551.test.ts and dataset-tools.test.ts: Tests 130 passed | 10 skipped (140); typecheck exit 0. Diff vs main: 3 files, +348 / -21.
  • pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2: Test Files 230 passed (230), Tests 5942 passed | 345 skipped.
  • pnpm --filter @objectstack/service-analytics typecheck: exit 0; the pin file is in the program.

Acceptance notes

  • Behaviour change, chosen by the seat (option A). A phrase whose head names the field a filtered measure aggregates ("hours total" beside a filtered "Billable hours") is now asked about that measure, because the take-out still tests the whole term ("named by the term" in the 2026-12-01 note); before, it was no_measure with no candidate. "hours" alone is still answered from the field. Both halves are pinned. Testing the head in the take-out (option B) would change that note's definition and is not built.
  • Containment cost, unchanged in kind. The head is tested with today's substring rule against measures, so "count" is inside the measure name open_invoice_count exactly as the single word "count" already is. "balance due" has the head "due", which is near only the dimension labelled "Days past due"; the head reading offers measures only, so the phrase has no candidate and takes rule 4's labelled fallback, as on main (contract review S1).
  • Not run on purpose. Public surface is byte-identical (no export added or removed), so no importer is owed a test; packages/mcp's suites send single-word terms only.

Verification

Read first:

  1. dataset-term-matcher.ts, phraseHead and the three word lists: the risk is a word in the wrong list.
  2. dataset-term-matcher.ts, the second-reading hunk in readDatasetTerms: it must run only when the first near set is empty.
  3. The [#38953] describe in dataset-term-matcher.test.ts, its the head word, not any word and "hours total" tests.

Two-minute check: pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/dataset-term-matcher.test.ts, expect Tests 20 passed (20).

Local gates (head 9132572, after merging origin/main ce0d0da; fix rounds at bf875b3 and bd0821d re-ran the affected test files and typecheck only)

node scripts/pm/dispatch-gates.mjs --commands derived 66 families for this diff; --ran reconciliation: "66 derived, 64 run, 2 NOT-MEASURED, 0 UNRUN", every line carrying its exit code. 64 exited 0, among them pnpm check:nul-bytes, pnpm check:cross-package-test-inputs, pnpm check:test-source-alias, pnpm check:doc-authoring, pnpm check:issue-citations, pnpm check:engine-double-contract and node scripts/check-empty-changeset.mjs --base origin/main.

  • NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test, reason: PREREQUISITE NOT MET (exit 3), the shallow clone cannot reach the pinned positive-control commit. CI runs it.
  • NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: PREREQUISITE NOT MET (exit 3), it reads every package's dist and only the service-analytics closure is built here. CI runs it.
  • The repo-wide farm (Lint & Repo Gates, Test Core and the rest) is CI's.

Generated by Claude Code

A list_datasets term near no member by itself is read a second time,
word by word: a member near one of its non-generic words is a candidate
for the phrase, never a hit. booking total now offers Booked amount
through its synonym bookings; a phrase near any member keeps exactly
its first-reading candidates.

Claude-Session: https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ
Co-authored-by: Claude <noreply@anthropic.com>
Any non-generic word offered Sales amount for "sales orders" and a
count for "deal value". The second reading now takes the phrase's head:
the last word before by/per/... that is not a total word, an unspaced
total word cut off. Kind words (amount, value, count) stay the head.

Claude-Session: https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

6 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/services/service-analytics/src/dataset-next-step.ts), 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
  • 1 changed file(s) yielded no anchor (packages/services/service-analytics/src/dataset-next-step.ts) — pages documenting those are invisible to this run
  • the SDK route bridge reached 71 of 254 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 10 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 2f9a68cfa184eaa7e77616df03654233ddd9f9f9 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 2f9a68cfa184eaa7e77616df03654233ddd9f9f9

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

The pins join dataset-term-matcher.test.ts as one top-level describe,
as AGENTS.md asks of a component that already has a test file, and the
separate file is removed. One pin is added: a filtered measure found
through the head of "hours total" is asked about, while "hours" alone
is still answered from the field it names.

Claude-Session: https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
Fix round on this PR, ordered by the seat. New head: bf875b3f87.

  1. Option A, as the seat chose: the 2026-12-01 field take-out still tests the whole term. A new pin covers the cell: a filtered "Billable hours" over field hours answers candidates_only and asks for "hours total", and "hours" alone is still no_measure, answered from the field. The body's 维护者速读 names this as a behaviour change: a question where the answer used to be no_measure with no candidate.
  2. AGENTS.md's shared-harness rule: every head-word pin moved into packages/services/service-analytics/src/__tests__/dataset-term-matcher.test.ts as one top-level describe named for MCP 问数: list_datasets(["booking total"]) answers no_measure, so the agent states a non-governed figure instead of asking which booking measure — a stable loss on both arms, 4 measured runs in a row (order_to_cash dq_booking_total) #38953. dataset-term-matcher-38953-head-word.test.ts is deleted. The diff is now 3 files, +348 / -21.
  3. Body updated through the relay's issue_patch (read-back: 11793 bytes sent, 11793 stored, identical); it still ends with the signed trailer.

Readings at bf875b3f87:

  • dataset-term-matcher.test.ts, dataset-term-names-field-38551.test.ts, dataset-tools.test.ts: Tests 130 passed | 10 skipped (140).
  • pnpm --filter @objectstack/service-analytics typecheck: exit 0.
  • Ablation: the matcher restored to the merge base (blob b67074bf) turns 6 of the 19 matcher pins red, the "hours total" pin among them (expected 'no_measure' to be 'candidates_only'). Restored to blob 0ca02122, git diff HEAD empty.
  • The pin can go red because it pins this PR's new candidate.
  • Gate families were not re-derived for this round: the only change is the test file move and one pin.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ

Final green head · 2026-12-02T01:53Z · zone osa-ai
Head-sha: bf875b3

  • CI at this head: 41 success, 20 skipped, 0 failure, 0 running; mergeable_state clean.
  • Diff: 3 files, +348 / −21: packages/services/service-analytics/src/dataset-term-matcher.ts, its shared harness __tests__/dataset-term-matcher.test.ts (one describe for MCP 问数: list_datasets(["booking total"]) answers no_measure, so the agent states a non-governed figure instead of asking which booking measure — a stable loss on both arms, 4 measured runs in a row (order_to_cash dq_booking_total) #38953, per AGENTS.md's shared-harness rule), one changeset. Part of #38953.
  • Route P, chosen by the seat as the lane's owner (claim 7330351836): a list_datasets term near no member by itself is read again by its head word, and a member near the head is a CANDIDATE, never a hit. Rule 1 (equality is the only hit) is unchanged, and so is any term already near a member by itself. On the order_to_cash build, booking total now answers candidates_only with order_book.measures.booked_amount, through the synonym bookings the fixture already carries. No stem, prefix or edit-distance rule.
  • Behaviour change named in the 速读 (the seat chose option A): the 2026-12-01 field take-out still tests the whole term, so hours total beside a filtered Billable hours over field hours now asks about that measure; before, it answered no_measure with no candidate. hours alone is still answered from the field. Pinned.
  • Readings (dev): the first "any word" cut gave two false positives in existing dataset-tools.test.ts pins and was narrowed to the head word; those pins are green unedited. Over the two scenario builds' 115 terms, 13 gain candidates (max 3), 102 unchanged; the per-term cap holds (pinned). Matcher restored to the merge base turns 6 of 19 matcher pins red, the door case and the hours total pin among them; restored, git diff HEAD empty. Affected files 130 passed, 10 skipped; full service-analytics 5942 passed at round 1; typecheck exit 0; 64 of 66 derived gates exit 0 at round 1, 2 NOT MEASURED (CI ran them).
  • ADR: none changed. ADR-0149 D3 rule 1 already lets a substring be offered and never acted on, and its amendment note leaves "which members are near enough to offer" to the executor.
  • Governed check (check-governed-merges --pr 39017): NOT governed. Clause-②: no. Owed before landing (seat): L1, and a contract-tier L2 in-house, because the change alters what ADR-0149 D3's candidate list carries.
  • What remains: the eval seat's daily round measures dq_booking_total on both arms (the card's acceptance).
  • Dev reports: MCP 问数: list_datasets(["booking total"]) answers no_measure, so the agent states a non-governed figure instead of asking which booking measure — a stable loss on both arms, 4 measured runs in a row (order_to_cash dq_booking_total) #38953 comment 7331571455; fix round 7331729780.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head bf875b3 · 2026-12-02T01:56Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bf875b3f87ac111a72066a3ea9ba0fbad31e5f23
Local-runs: none
Scope: packages/services/service-analytics/src/dataset-term-matcher.ts + none

PR #39017, card #38953, rendered 2026-12-02T02:02Z. Read: the card and its three comments (triage 7315392885, claim 7330351836, os-dev-report 7331571455), the PR body and file list, the net diff against main (merge base ce0d0da26e; main has since moved to 4203db7e4a with no change under packages/services/service-analytics, packages/spec/src/ai, packages/mcp, skills/objectstack-ask or ADR-0149), and the check-runs on the head. The matcher is not on the governed register; it is read at this tier at the seat's request, as the executor of ADR-0149 D3's candidate rule. The test file and the changeset are the L1's and were read only to judge the matcher.

Check-runs on the head: every run concluded success or skipped, none red and none pending. Among the green ones: Test Core (12 shards), TypeScript Type Check, Lint & Repo Gates, Build Core, Check Changeset, PR-body guards, Governed Surface Queue Guard.

① Derived judgments

  • list_datasets answer shape: unchanged. Right. No hunk touches packages/spec, dataset-tools.ts or dataset-next-step.ts; candidates, matches and nextStep keep their declared shapes, and the new pin parses the answer through ListDatasetsOutputSchema.
  • What a hit is: unchanged. Right. matchedOn and matchDatasetTerms have no hunk, and readDatasetTerms still skips a term with a hit anywhere before any near test runs.
  • Candidate accept-set: widened. Right for measures, wrong for dimensions (S1). A term near no member of any listed dataset is read once more by phraseHead, and members near the head become its candidates. For such a term nextStep.decision moves from no_measure to candidates_only. Order (datasets as listed, measures before dimensions) and the cap are the same loop as before, now over the set either reading returned.
  • A term near any member by itself: unchanged. Right. The second reading runs only when the first set is empty, so every answer that carried candidates on main carries the same ones.
  • The 2026-12-01 take-out: unchanged in its test, wider in what it is put to. Right by the note's letter. namesField still receives the whole normalized term; it is now also put to candidates the head reading found.
  • isNearDatasetTerm: widened to the term or its head. Right. It is a module export read by dataset-tools.ts#candidateMeasure alone; the package entry (src/index.ts) exports matchDatasetTerms and MatchableMember only and has no hunk. The widening is a superset of both readings in readDatasetTerms, so no measure the finder offers reaches it without its field labels. The cost is at most one more readFieldLabel per field per answer, through the existing per-answer memo.
  • Package public surface: unchanged. Right. No export added, removed or renamed.

② Semver level

.changeset/38953-booking-head-word.md takes patch on @objectstack/service-analytics, the one released package the diff moves. That matches what is published: a behaviour fix in a tool answer, with no key, export or accepted value added or removed. Metadata-protocol: none is right, since nothing a metadata author can write changes.

Clause-②: no — right. The line is present and identical in the PR body and the changeset body, with no arm, and none is owed: the answer keeps its shape and nothing an author or a caller could write is refused. Check Changeset is green on the head.

One sentence of the changeset describes behaviour S1 asks to change in part ("A member near the head word is offered in candidates"); it stays true of measures after the fix and needs no edit unless the fix words it more narrowly.

③ Boundary flags

  • Open question 1 (the take-out on a head-found measure): answered, option A, by the seat as lane owner; this review concurs on the contract. The 2026-12-01 note defines "named by the term" as the term equal to, or contained in, the field's label or name. "hours total" is contained in neither "Hours" nor hours, so the note leaves the filtered measure offered and asked about ("a measure candidate it leaves keeps the question … whatever left it there: a field the term does not name"). Testing the head there (option B) would change that definition and needs the record amended first; it is correctly not built. Both halves are pinned ("hours total" asked, "hours" answered from the field). The answer is written on the PR body only; see nit N4.
  • Deviation: the pin file. The report on the card names a new pin file; the head carries the pins as one top-level describe('[#38953] …') in the existing dataset-term-matcher.test.ts, which is the AGENTS.md placement and is inside the claim's file surface. Settled.
  • Deviations on background gate run, attribution and the pre-open merge: process notes with no contract face; nothing to rule here.
  • Claim fence. The diff stays inside the claim's surface: no skills/**, no packages/spec/**, no docs/adr/**.
  • SQL push-down. Not engaged. The change is string comparison over the admitted catalogue already in memory: no query, no id materialisation, no in-app join. The only added I/O is the bounded label read named under ①.

④ Design judgment

dataset-term-matcher.ts, read against ADR-0149 D3 on main and against dataset-next-step.ts#composeDatasetNextStep, the consumer that turns its candidates into the sentence a client follows.

Holds, sentence by sentence:

  • Rule 1. Equality after normalization stays the only hit. The head test reuses isNear, a containment test, so the file's own "no edit distance, stem or embedding" stays true. "booking" reaches Booked amount through the authored synonym bookings.
  • Note of 2026-11-17. A candidate only for a term with no hit, a pointer to a listed member, in listing order, capped, with no score. It also says which members are near enough to offer "is the executor's rule; this record and the spec say what a candidate is, not how it is found". The PR's claim that no ADR text must change is therefore right, and stays right with S1 fixed in code.
  • Note of 2026-12-01. The take-out runs over the uncapped set, on filtered measures only, with the whole term. Unchanged, as ③ records.
  • The card's scenario. On the order_to_cash build read at the head, booking total is near no target by the first reading and its head booking is inside bookings: one candidate, order_book.measures.booked_amount, candidates_only, and the note asks. That is the card's dq_booking_total expectation (asked_back, near_miss, that one measure). 成交合计 gives 成交, inside 成交额: the same. claimed so far on travel_expense gives claimed, the card's dq_claimed_so_far expectation. The two fallback_labelled controls keep no_measure for payments, number of payments, employees and number of employees (no member is near payments or employees).
  • phraseHead mechanics. A cutting word at index 0 gives no head; a phrase of total and joining words gives no head; a head under two code points or equal to the whole term gives no head; one unspaced total word is cut, once. Each is pinned.

Findings:

S1 (should-fix) — the second reading offers DIMENSIONS near the head, and a phrase for a thing measured is then answered as a grouping word.
phraseHead's own doc defines the head as "the last word that names what it measures", yet nearSet runs the head over dataset.dimensions as well. When the head is near a dimension and no measure, the term's candidates are all dimensions, readTerm marks it groupingOnly, and composeDatasetNextStep writes groupingCandidateHit, groupingCandidateTail and, for a call with no other word, groupingTail: "A grouping alone is no answer: ask the user which number they mean." On main the same term is no_measure with unknownHit and fallbackTail: rule 4, labelled, nothing asked.
The PR's own table has the case: balance due on order_to_cash has the head due, near only receivables_aging.dimensions.aging_bucket (label "Days past due"). The phrase names a balance, the build declares Open balance and Outstanding balance, and the door now answers that it may name a grouping and that the client should ask which number is meant. The PR body describes this cell as "a possible grouping, no question"; the tree writes the question. Beside a real grouping word (["balance due", "customer"]) the result is the same question, where the note of 2026-11-24 reads an unknown word beside a grouping word "as the word for the thing measured. That is rule 4 … and nothing is asked". The letter of that note is not broken, because the term now has a candidate; its reading is, and the candidate exists only because this PR manufactured it from a word the PR itself says names a number. The note of 2026-11-19 rests the grouping reading on "the ordinary shape of a grouping or time word"; a head word is by construction not one. Route P in the claim is "yields a measure as a CANDIDATE"; a dimension through the head is outside it, and no pin covers it.
Fix, in this file: the head reading offers measures only (the first reading keeps both kinds, untouched), so a head near no measure leaves the term with no candidate and rule 4 as on main. Pin balance due on the fixture shape (no_measure, no candidates), and correct the PR body's sentence. order total then keeps order_count and loses only the order_status dimension, which changes neither its decision nor its question.

Nits (no effect on the contract; none blocks):

  • N1 — a kind word as head carries no entity. payment count on the fixture is asked about Order count and Open invoices; discount amount would be asked about every amount, first five in listing order. This is deliberate, pinned (booking count equals the candidates of count) and stated in the changeset, and a bare count already behaves so on main. Left as an accepted deviation; the eval seat should watch the two fallback_labelled controls for a client that sends payment count or employee count.
  • N2 — the head reading is gated on the first reading finding no member of either kind. A phrase that contains a dimension target (booking total by account on the fixture) keeps that dimension alone and is never offered the measure. Same as main, so no regression; the changeset's booking total by status example holds on the fixture only because no target there is status. A follow-up card if route P is to cover it.
  • N3 — the last word is not the head of a phrase with a postposed modifier (balance due, invoices paid, whose head paid is inside unpaid invoices). A limit of a lexical rule; with S1 fixed the cost is one clarifying question, never a selection.
  • N4 — two prose gaps on the thread: the seat's option A is recorded on the PR body alone, and the card's os-dev-report predates the fix round (it names the retired pin file and head 91325724b6). A line on the card closes both.
  • N5 — dataset-next-step.ts (outside the diff, read only) still says the finder "offers a member for any word that contains or is contained in one of its names"; true, and now incomplete. It can ride with the S1 commit or be left.

Implemented-by: claude/issue-38953-booking-head-word
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 review · PR #39017 (Part of #38953) · head bf875b3 · 2026-12-02T02:03Z

VERDICT: NOT ACCEPTED on this head, for one should-fix. I adopt the contract-tier record 7332412283. Its verdict is PASS, but S1 (should-fix) is open, and the queue guard reads it as open on this head. A fix head, an L2 delta naming S1: closed, and my L1 delta are owed.

  • Face. l1-face is CLEAN at bf875b3, with 13 items read and none flagged. Checks are 41 success, 20 expected skip and 0 failed, and mergeable_state is clean. It is NOT governed. Part of is right, because the card's acceptance is the eval seat's measured round. Clause-②: no and Metadata-protocol: none are right, because the answer shape, what counts as a hit, and the exports are unchanged. The service-analytics patch changeset is right.
  • Code read. The read follows the PR body's account:
    • Rule 1 (equality is the only hit) is untouched.
    • The second reading runs only when the first finds no member at all, so it never adds to the first.
    • phraseHead cuts at a head-ending word, skips total and joining words, and cuts one unspaced total word from the end or else the start.
    • isNearDatasetTerm answers for the term or its head, a correct superset, so no offered measure goes unread.
    • The 2026-12-01 take-out still tests the whole term.
    • The card's booking total reaches Booked amount through its existing synonym bookings, with no stem or edit distance.
  • S1 (should-fix), as the record grades it. The head reading also offers DIMENSIONS. Take balance due on the order_to_cash build: its head is due, which is near only the dimension "Days past due". The door then answers candidates_only and asks "which number they mean", where main answers no_measure with the labelled fallback. Route P asked for a measure as a candidate. The PR body calls that cell "a possible grouping, no question", and the tree asks the question. The close is to have the head reading offer measures only, pin balance due (no_measure, no candidates), and correct the body sentence.
  • Seat's option A ("hours total"). It is consistent with the letter of the 2026-12-01 note, per the record, and the 速读 names the change. Record nit N4: option A sits on the PR body only. A one-line seat comment on MCP 问数: list_datasets(["booking total"]) answers no_measure, so the agent states a non-governed figure instead of asking which booking measure — a stable loss on both arms, 4 measured runs in a row (order_to_cash dq_booking_total) #38953 would keep it with the card.
  • The claim that no ADR text must change is right per the record, and it stays right with S1 fixed in code.
  • Sentence read (changeset). It is true of this head, apart from what S1 changes. If the fix restricts the head reading to measures, the bullet "A member near the head word is offered" should say "a measure".
  • Nits, accepted (record N1–N5). These are the kind-word head (payment count), the first reading's dimension-only keep, postposed modifiers, the option-A record, and a stale comment in dataset-next-step.ts outside the diff. The eval seat should watch the two fallback_labelled controls (N1).

Next: the fix head, then the L2 delta and the L1 delta.

A head names the thing measured, so a dimension near it is no reading of
the phrase: "balance due", whose head "due" is near only a dimension,
was answered as a grouping word and asked which number is meant. The
second reading now skips dimensions, and a head near no measure leaves
the term with no candidate, the labelled fallback as before. The first
reading keeps both kinds.

Claude-Session: https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
Second fix round, for contract review 7332412283 S1. New head: bd0821d8c2.

  • S1: the head-word (second) reading now offers measures only, and the first reading keeps both kinds, untouched. A head near no measure leaves the term with no candidate, so rule 4 holds as it does on main. On the order_to_cash shape, balance due (head due, near only the dimension "Days past due") answers no_measure with no candidates. order total keeps order_count, loses only the order_status dimension, and stays candidates_only. Both are pinned in the [#38953] describe of dataset-term-matcher.test.ts. The booking count pin now compares against the measures the word count is offered.
  • Red-first: the new pin against the bf875b3f87 matcher gave Tests 1 failed | 19 passed (20) (expected 'candidates_only' to be 'no_measure'). It is green on the fix.
  • Ablation of the guard at bd0821d8c2: ablation-replace.mjs set the head pass's dimensions flag to true (blob 4ac6f758 to 2c0ac008). Result: Tests 2 failed | 18 passed (20), the measures-only pin and the booking count pin. Restored to blob 4ac6f758, git diff HEAD empty.
  • Readings at bd0821d8c2: the matcher, names-field-38551 and dataset-tools suites give Tests 131 passed | 10 skipped (141). pnpm --filter @objectstack/service-analytics typecheck exits 0.
  • N5: one doc comment in dataset-next-step.ts now names the head-word reading of measures. It is a comment only.
  • Changeset: "A measure near the head word is offered…", and a dimension near the head is not.
  • PR body corrected through the relay issue_patch (13378 bytes sent and stored, identical). The corrections: the balance due cell, the measures-only head reading, 12 of 115 scenario terms gaining candidates (measures only), and the diff at 4 files, +375 / -22. The body still ends with the signed trailer.
  • N4 is posted on the card: comment 7332575996.
  • Gate families were not re-derived this round. The change is one condition in the matcher, a pin, a comment and a changeset sentence.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head bd0821d · 2026-12-02T02:14Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bd0821d8c2ad0d12183d4d0d2256c5cf052df5b3
Local-runs: none
Scope: packages/services/service-analytics/src/dataset-term-matcher.ts + packages/services/service-analytics/src/dataset-next-step.ts

Delta record for PR #39017, card #38953, rendered 2026-12-02T02:32Z. It follows this session's record on head bf875b3f87, which left S1 open. Read: the fix commit bd0821d8 (bf875b3f..bd0821d8, 4 files, +36 / -10), the net diff against main (4 files, +375 / -22), the PR body at this head, the card's thread through comment 7332575996, and the check-runs on this head. Everything the earlier record judged and this commit does not touch stands as written there.

Check-runs on the head: all 61 concluded, 41 success and 20 skipped, none red and none pending. The twelve Test Core shards, Build Core, the type checks, the lint families, Check Changeset and the Governed Surface Queue Guard are among the green ones.

S1: closed

① Derived judgments

  • Candidate accept-set: narrowed back for dimensions. Right. nearSet takes a second argument and skips dataset.dimensions when it is false; the first reading passes true, the head reading passes false. A term near no member by itself is now offered only the MEASURES near its head.
  • A head near no measure: no_measure, as on main. Right. Such a term has no entry in candidates, so readTerm reads it as no_measure and the note is the labelled fallback of rule 4. The grouping sentences are no longer reachable through the head reading.
  • The first reading: unchanged. Right. It still returns both kinds, so every answer that carried candidates on main carries the same ones; past due still offers the dimension labelled "Days past due".
  • isNearDatasetTerm: unchanged, still a superset. Right. It is asked about measures only (dataset-tools.ts#candidateMeasure), and the head reading now offers measures only.
  • Shape, hits, exports: unchanged. No hunk in packages/spec, dataset-tools.ts or src/index.ts. The dataset-next-step.ts hunk is three comment lines and changes no sentence the tool writes.

② Semver level

Unchanged: patch on @objectstack/service-analytics, Metadata-protocol: none. The changeset's first paragraph now reads "A measure near the head word is offered … a dimension near the head word is not, so a phrase whose head is near no measure still falls back as before", which is what the tree does.

Clause-②: no — right, present and identical in the PR body and the changeset body. Check Changeset is green on this head.

③ Boundary flags

  • Open question 1: answered, option A, and now recorded on the card as well (comment 7332575996). Unchanged in the tree: the "hours total" and "hours" pins are untouched.
  • Claim fence: dataset-next-step.ts is on the claim's file surface; still no skills/**, packages/spec/** or docs/adr/**.
  • SQL push-down: not engaged. The fix removes a loop over in-memory members and adds no read.

④ Design judgment

dataset-term-matcher.ts at this head, against ADR-0149 D3 and against composeDatasetNextStep.

  • The fix is the one asked for, and no more. One flag, read in one place. The take-out and the cap run over the same near array as before, so the note of 2026-12-01 and the cap are untouched.
  • The code now agrees with its own definition. phraseHead says the head "names what it measures"; the head is put to measures alone, and the doc of readDatasetTerms and the file header say so.
  • Notes of 2026-11-19 and 2026-11-24. A dimension-only candidate set can again arise only from the first reading, the grouping-word shape the 2026-11-19 note describes. An unknown phrase whose head is near a dimension alone has no candidate, so beside a grouping word it is the 2026-11-24 note's word and takes rule 4.
  • Pins. balance due is pinned at the door (no_measure, terms, no candidates) and at the matcher (no candidate). order total keeps order_book.measures.order_count and stays candidates_only. past due guards the first reading. The booking count pin now compares against the measures the bare word count is offered, which is the narrower and correct statement.
  • The card's scenario is unaffected. booking total, 成交合计 and claimed so far each reach a measure through the head, so their answers are those of the earlier head.
  • No ADR text must change. Still right: the fix moves the executor's rule further inside what the note of 2026-11-17 leaves to it.

No must-fix, no should-fix.

Nits from the earlier record:

  • N1 (a kind word as head carries no entity), N2 (the head reading is gated on the first reading finding no member of either kind) and N3 (a postposed modifier as last word) stand as accepted deviations and follow-up material. None blocks. With S1 fixed, N3 costs at most one clarifying question about a measure.
  • N4 is settled by card comment 7332575996.
  • N5 is settled by the comment hunk in dataset-next-step.ts, which now names the head reading and that it offers measures.

Implemented-by: claude/issue-38953-booking-head-word
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 delta · PR #39017 (#38953) · head bd0821d · 2026-12-02T02:33Z

ACCEPT, on head bd0821d8c2ad0d12183d4d0d2256c5cf052df5b3.

  • Contract L2 delta at CONTRACT_REVIEW_TIER on this head: PASS, S1: closed, no new finding (comment 7332960378). No graded finding is open.
  • Fix commit bf875b3f..bd0821d8 (4 files, +36/-10) read in the tree: nearSet takes a dimensions flag; the first reading passes true, the head-word reading false, so the second reading offers measures only and a head near no measure falls to rule 4's labelled fallback. Pins: balance due → no_measure with no candidates; order total keeps order_count and stays candidates_only.
  • Changeset read sentence by sentence: "A measure near the head word is offered … a dimension near the head word is not" matches the tree. patch, Clause-②: no, Metadata-protocol: none unchanged and right.
  • dataset-next-step.ts hunk is jsdoc only (N5). N4 settled on the card (7332575996). N1–N3 stand as accepted deviations.
  • l1-face CLEAN: Part of #38953, no closing keyword; checks 41 success, 20 expected skips, 0 failed, 0 pending; mergeable_state clean.

Landing rule B: Part of card #38953 keeps pm:dispatched after the merge.

Next: zone landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ

落地

reading value
check-governed-merges.mjs --pr 39017 (head fetched) NOT governed — 4 files, 397 changed lines ≤ 3000
reviews on bd0821d8 Contract review delta 7332960378 at CONTRACT_REVIEW_TIER: PASS, S1: closed, no new finding (over record 7332412283). L1 delta ACCEPT 7332969374 (osa-L1-a). No graded finding open.
check-runs on bd0821d8 41 success · 20 expected skip · 0 failed · 0 pending; mergeable_state clean
K landing-k.mjs --pr 39017: K = 0 < 15, no new locale pack, no shared book moved

State change: ready for review + auto-merge, by zone osa-ai (2026-12-02T02:34Z). Part of #38953: the card keeps pm:dispatched after the merge (landing rule B) until the eval seat's daily round measures dq_booking_total on both arms. Accepted nits N1–N3 stand; the eval seat should watch the two fallback_labelled controls (N1).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 2, 2026 02:35
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 7aaced0 Dec 2, 2026
62 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-38953-booking-head-word branch December 2, 2026 03:02
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 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.

2 participants