Repository navigation
feat(mcp): aggregate_records returns select groups in declared option order and names a fixed amount's currency - #35186
Conversation
… and names a fixed amount's currency (wip) Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 5 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 062e521fc96c9983e8ecedeea27284420c527bfe && git checkout 062e521fc96c9983e8ecedeea27284420c527bfe
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4b1eb0eab7ac41708a6775d1e6116ac4c038a5a3 4582c20e076360cfe76027bb27a266063e2a61da && git checkout -B drift-repro 4b1eb0eab7ac41708a6775d1e6116ac4c038a5a3 && git merge --no-ff 4582c20e076360cfe76027bb27a266063e2a61da
node scripts/docs-audit/affected-docs.mjs --json 4b1eb0eab7ac41708a6775d1e6116ac4c038a5a3
|
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Contract review brief handed to the isolated reviewer (TIER_DEFAULT, declaration face), posted beside its record: Contract review brief — PR #35186 @
|
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Contract reviewServed-tier: Inputs: brief 6976909080; card #35138 (body and all 10 comments, among them the claim 6975089907, the W0 decisions in amendment 6975318215, os-dev report 6976835443 and area note 6976885282); card #35144 (claim 6974958437 and every comment after it); PR #35186 (body and comments); the full diff against merge-base Face: the committed file list is ① Derived judgments
Findings:
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Contract review delta on head
|
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Final head for L1 · 2026-11-18T11:33ZHead-sha: |
|
repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9 L1 review (#35138, PR 2) · 2026-11-18T11:37ZL1: ACCEPT Fixes vs Part of. This is PR 2 of the W0 plan, so it does not close the card. The body says Claim file surface. Amendment 1 gives PR 2 Each changeset sentence against the diff. The changeset is new, and
Tests. There are ten new cases in
Clause-②: yes (widening). TIER_DEFAULT record 6977026565 is PASS on this same head, and delta 6977058863 closes S1 through 6977042103 on #35144. N1 and N2 of that record stay nits. Governance. CI at this head, from check-runs: 37 success and 16 skipped, with none failed or in progress (all ten Must-fixNone. Should-fixNone. Notes
|
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Landing · 2026-11-18T12:05Z
Open findings: record nits N1, N2; L1 notes N1 ( State: ready + auto-merge armed by area o1-B (lease Dev-effort: medium · Rounds: 1 |
…ate order and cut Resolves the two conflicts in packages/mcp (mcp-http-tools.ts and the aggregation-entry test) and carries the agreed items as the second PR to merge main: - A limit with no orderBy hands the database the declared option order of the leading select/radio group keys, each as an order key's rank, derived by the uncut path's own declaredOptionRank (the leading-key reading is now one helper, declaredOptionOrderKeys, used by both paths). - The cut result carries currencies (fixedAmountCurrencies) like the uncut one, and keeps groups on the uncut path. - Seat ruling: the result keeps totalGroups and adds no groupCount; on the cut path totalGroups is the statement's count of the groups before the cut. The engine outcome, the bridge member and the driver directive spell it totalGroups too. - Pins: the limit-only push-down (tool and stdio engine), the explicit-order CONTROL, currencies on the cut result, and no groupCount in a served result. Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8 Co-authored-by: Claude <noreply@anthropic.com>
Requested by Warren · project thread
Refs #35138 (items select order, currency)
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
aggregate_records工具在调用方未指定排序时,按 select/radio 字段声明的选项顺序返回分组(未声明的值排最后),排序发生在 50 行截断之前;对sum/avg/min/max这类金额列,若字段是固定币种(currencyConfig.currencyMode: 'fixed'),结果多出currencies成员,按列别名给出 ISO 4217 币种代码。HTTP 和 stdio 两个入口走同一个处理函数。servedObjectDefinitionOf),看不到的字段不排序也不报币种;读不到定义时返回与之前完全相同。已有成员rows/totalGroups/truncated不变,currencies只在有固定币种金额时出现。回滚即 revert 本 PR。packages/mcp/src/mcp-http-tools.ts的inDeclaredOptionOrder:多个分组键时只按前导的 select 键排序,遇到第一个非 select 键即停;② 同文件aggregate_records处理函数里排序在截断之前;③fixedAmountCurrencies只认fixed模式。pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/mcp-http-tools.aggregation-entry.test.ts,预期 19 个测试全绿,其中 10 个是本 PR 新增的 mcp: the result members the hosted ask tools add over the framework tools are either moved into the framework or stated as hosted-only, one by one #35138 用例。What changes
aggregate_records(packages/mcp/src/mcp-http-tools.ts, one handler serving both the HTTP and the stdio door) now reads two facts off the object as the caller is served it, through the existing optional bridge memberservedObjectDefinitionOf(both bridges implement it, each answering the caller-masked definition):selectorradiofield come back in the order the field declares its options. A value no option declares, such as a null, sorts last. The group keys are read ingroupByorder while each is such a field: the first key that is not one ends the reading, and the groups under it keep the driver's order. The sort is stable and runs over every group before the tool's cap, so the cap keeps the first declared groups. A group key'saliasis honoured.multiselectis not ordered, because its group value is a combination.currenciesmaps an amount column's alias to its ISO 4217 code, when the column issum/avg/min/maxover a field whosecurrencyConfigiscurrencyMode: 'fixed'.countandcount_distinctcarry none.The bridge read is skipped when the call has no group key and no amount column. If the bridge does not have the member, finds no object or throws, the tool answers exactly as before, and the aggregate itself is never failed by it. A field the caller's served schema does not show is never ordered or named.
currenciesis typed locally inpackages/mcp. Theaggregate_recordsresult has no type inpackages/spec:git grep aggregate_records -- packages/spec/srcfinds two comments indata/query.zod.tsabout the input entry, and no result schema. No guidance text enters the spec (ADR-0149 M1).Record mode, re-measured and unchanged: the engine already refuses
sum/avg/min/maxover arecord-mode amount unless it is grouped by the amount's code field (packages/objectql/src/record-currency-aggregate-door.ts, ADR-0144 D6), so each group's code is in its row.packages/objectql/src/record-currency-guards.test.ts-t "raw aggregate over a record-mode amount" on this branch readsTests 4 passed | 70 skipped (74): ungrouped is refusedINVALID_FIELD, grouped by another field is refused, and grouped by the code it answers{ USD: 100, EUR: 100 }.Tests
New pins: top-level describe in packages/mcp/src/mcp-http-tools.aggregation-entry.test.ts (the shared aggregate_records harness)
o00..o49,truncated: true,totalGroups: 60sumandavgname{ total: 'USD', mean: 'USD' }count,count_distinctover the fixed amount, a non-currencynumbermeasure, and arecord-mode and adynamic-mode amount carry nocurrenciesAblations (one per pin, through scripts/ablation-replace.mjs; each restored to the HEAD blob)
Each mutation landed (anchor count 1 then 0) and the test file went red. Every restore was confirmed by blob
0ed787fe6949against HEAD:const groups = rows;in place of the option-order call. Red: 3 failed, 16 passed (the three order pins).void defaultCurrency;. Red: 1 failed (the fixed-currency pin).if (!rank) break;changed tocontinue. Red: 1 failed (the CONTROL for a non-select leading key).Acceptance notes
origin/mainhas no ordering argument onaggregate_records. Without one,strictToolInputrefuses anorderBykey as unknown. mcp: aggregate_records can order and cut its groups and says how many groups there were #35144 addsorderBy/limiton its branch (claude/issue-35144-aggregate-order-cut, no PR yet). That path returns before the default path, so option order never reaches an explicit order. The control pin is owed when the second of the two PRs mergesmain.git merge-treeof this head with that branch conflicts in one place, therows:line of the default path's result; the resolution keepsgroupsand addsgroupCount. On that branch, a call withlimitbut noorderBytakes the database path with an empty order, so option order does not apply there.currenciesis added on the default path only. mcp: aggregate_records can order and cut its groups and says how many groups there were #35144's order-and-cut path builds its own result, so whoever merges second should addcurrenciesthere as well.dynamicmode carries no currency. The served schema does not hold the tenant'slocalization.currency, so this PR does not invent a value.Verification
All readings below are at head
4582c20e07, the final commit.Local subset
pnpm --filter @objectstack/mcp typecheck, thenvitest run --maxWorkers=2over the whole package, run under the shared verify lock. Lock line:VERDICT command-exit 0. Result:Test Files 71 passed (71),Tests 1280 passed (1280). The typecheck rantsc --noEmitandcheck:test-typecheck.src/mcp-http-tools.aggregation-entry.test.ts:Tests 19 passed (19).packages/objectql/src/record-currency-guards.test.ts -t "raw aggregate over a record-mode amount"givesTests 4 passed | 70 skipped (74).dispatch-gates --commands: 68 derived families, run with each exit code captured before any pipe.--ranreconciliation:68 derived, 67 run, 1 NOT-MEASURED, 0 UNRUN.check:dual-build-cjs-loads, exit 3,PREREQUISITE NOT MET(it reads every package'sdist, and only the mcp closure was built). CI runs it.node scripts/check-nul-bytes.mjs: OK.overlap-check.mjs:VERDICT clean exit 0, against origin/main7d8dcf693aand 0 open PR heads.The families CI runs (
Lint & Repo Gates,Test Core,Build Core, the type-check lanes) are left to this PR's check-runs.Generated by Claude Code