Repository navigation
fix(objectql): aggregate refuses a groupBy path through relations (INVALID_FIELD 400) before any driver runs - #35479
Conversation
…ge (red on main) Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
…ore any driver Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
…a dotted path Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
… type Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
…ep-groupby-refusal
📓 Docs Drift CheckThis PR changes 1 package(s): 30 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 21 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 40f28c7de5f4ecb229016570fec4996541a1737c && git checkout 40f28c7de5f4ecb229016570fec4996541a1737c
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b65488a8a9db73ddbede8a05605137419da28a8e 13a5b397db366d5a394458464d61b97c80babb08 && git checkout -B drift-repro b65488a8a9db73ddbede8a05605137419da28a8e && git merge --no-ff 13a5b397db366d5a394458464d61b97c80babb08
node scripts/docs-audit/affected-docs.mjs --json b65488a8a9db73ddbede8a05605137419da28a8e
|
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对L1-a: ACCEPT with two required items before landing · head Readings: K=12; Code: sound for the case it targets. In R1 (required): the declaration is a narrowing. As data-1 asked: an engine that aggregates in memory answered a dotted
R2 (required, measure before landing): the analytics own-qualifier path.
Routing. L2 is owed for the narrowing declaration after R1, TIER_DEFAULT by seat 5. data-1 lands after the L2. A push that only applies R1 and records R2's reading needs no fresh L1. |
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ Contract reviewServed-tier: Net diff read against merge-base ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe narrowing against the published spec on
Attempts to break it.
S1 (should-fix) — the arm refuses a class the PR neither declares, measures nor pins: a dotted name whose head is not a relation.
Nits.
Implemented-by: VERDICT: PASS |
…relation arm Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
The refusal covers a relation path, a JSON sub-path and the object's own name as a qualifier; the BREAKING paragraph now names all three and what each answered before, without a null-group claim for the last two. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对Correction to L1-a record 7008122771 (#35479), Routing only · 2026-11-19T14:11Z The routing named the seat's L2 at |
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ Contract reviewServed-tier: Delta review of record 7010069867 (head S1: closed N1, N2 and N3 are taken as well; one new nit, N4, is in ④. ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe narrowing itself is the one judged in round 1 and holds: S1, item by item, in the tree at this head.
The nits.
New on this head.
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb Landing · area data-1 · 2026-11-19T16:10Z
State: draft → ready + auto-merge (merge queue). #34886 closes on merge via |
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
Fixes #34886
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill or docs page teaches a dotted engine or MCP
groupByentry:skills/objectstack-queryteaches bare column names only, and therelationship.fielddimensions incontent/docs/data-modeling/analytics.mdxare the analytics cube surface, which this PR leaves as it was (R2 below). The refusal itself names the path and the fix.维护者速读
席位核对
packages/objectql/src/aggregate-query-shape-door.ts. Its risk is that it only stops dotted names this object does not declare, and that it picks the wording by the head's declared type. Thenpackages/runtime/src/mcp-aggregate-relation-path-group-by.test.ts.pnpm --filter @objectstack/runtime exec vitest run --project local src/mcp-aggregate-relation-path-group-by.test.ts. Expect 8 green: the 4-hop path, a JSON sub-path and the object's own name as a qualifier each answer 400 INVALID_FIELD atgroupBy.0, and grouping by the relation field itself still returns numbers.What changes
Ruling zone of the dispatch (card Expected, verbatim): "either the grouping works, or the door refuses the path with a 4xx that names the hop limit or the unsupported path, so an MCP agent can change its approach." This PR takes the refusal arm.
packages/objectql/src/aggregate-query-shape-door.ts:assertGroupByTargetsAreStored, whichengine.aggregatealready calls for every caller before any driver, gains a first arm. AgroupByentry naming a dotted path the object does not declare (a name or{ field }, a date bucket included) is refusedINVALID_FIELD/ 400 atgroupBy.NorgroupBy.N.field, withfield= the path,fields,object,param: 'groupBy'. The message names the path and the depthgroupByserves (0 hops, the object's own columns by their bare names). The wording follows the head's declared type. For a reference head (REFERENCE_VALUE_TYPES), it counts the relation hops and says to group by that field itself, one group per related record, or to aggregate the related object. For a multi-value reference head (isMultiValueField), it says to aggregate the related object. For any other head, including a JSON field (address.city) or a name that is not a field (the object's own name as a qualifier), it mentions no relation hops: name the field without a qualifier, or store the part in a field of its own.groupByat ingress (assertGroupByFieldsExist, "a related record's column cannot be a grouping target"). The MCP bridge reachesengine.aggregatethroughcallData, past that door. The code is the same as that door's (INVALID_FIELD), so one condition carries one code on both layers.engine-delete-and-aggregate.ts(held by fix(objectql): insert and delete open their after-abort unit inside the middleware chain, as update does #35386) is untouched; the door it already calls carries the arm.@objectstack/objectqlpatch, declaredClause-②: no (narrowing)withMetadata-protocol: none.groupByentry that reachesengine.aggregatepast the REST query door (the MCPaggregate_recordstool, a flow, a hook) is now refusedINVALID_FIELD/ 400 before any statement runs. The refused set has three shapes:500 DATABASE_ERRORat 3–4. An engine that aggregates in memory: one null group under 200.address.city). Before, on SQLite: the driver's ownINVALID_FIELD/ 400 withoutpath, after the statement ran. In memory: grouped by the nested value (code-read).po_line.amount). Before, on SQLite: answered 200, grouped by the bare column.A caller that relied on the last two now gets a 400 and must drop the qualifier or store the part in a field of its own. It ships
patchbecause no metadata an author writes changes: the refused input is a runtime query that the REST query door already refused in all three shapes (assertGroupByFieldsExistchecks the exact name against the declared fields). AGENTS.md Post-Task Checklist step 3: a non-protocol breaking change shipspatchand keeps its BREAKING banner and ADR-0087 disposition.node scripts/check-adr-0087-registration.mjs --base origin/mainate8b311e4c0reports: "1 declared-breaking changeset(s), each carrying an ADR-0087 disposition" ([BREAKING+clause-②-narrowing] not-required (no-migration-prescription)).Tests
New file
packages/runtime/src/mcp-aggregate-relation-path-group-by.test.ts. It runs the HTTP MCP bridge (buildMcpBridge), the realObjectQLand a realSqlDriveron SQLite, over a five-object chain: line, purchase order, requisition, requester, department.{ code: 'INVALID_FIELD', status: 400, field: PATH, path: 'groupBy.0' }, and no GROUP BY statement reaches the database. The object form is refused atgroupBy.1.field. The ordered-and-cut member (aggregateGroups, used byaggregate_recordswithorderBy/limit) is refused the same way,path: 'groupBy.0'included.address.city, a sub-path into a declared JSON field, andLINE.amount, the object's own name as a qualifier (an undeclared head). Each answers the same envelope atgroupBy.0with no statement run, and the message does not match/relation hop/.groupBy: ['purchase_order'], the relation field itself (the supported depth), is answered by one database statement with the right totals.origin/mainb3247ddbdc(before the fix), 5 failed and 1 passed. The 4-hop and 3-hop paths and the object form answeredDATABASE_ERROR/ 500. The 1-hop path answered the driver's backstopINVALID_FIELD/ 400, with nopath, after the statement ran. The CONTROL passed.ce0a9509e5:ablation-replace.mjsswapped the arm's guard forfield === 'ABLATION_34886_R2', which never matches. The anchor went from 1 to 0, and the blob went from196c1d38tode7fae20. objectql was rebuilt, andablation-dist-preflightfound the marker in 4 dist files. Result: 7 failed, 1 passed (the CONTROL). Both new pins went red:address.cityanswered the driver backstop'sINVALID_FIELDwithoutpath, andLINE.amountwas answered ("expected the aggregate to be refused, but it answered"). Restore: the blob equals HEAD and the tree is clean. After the rebuild,--absentfound the marker in none of the 14 dist files, and the file passed 8/8.338e378846:ablation-replace.mjsswapped the arm's guard for one that never matches. The anchor went from 1 to 0, and the blob went from003067detofe264256. objectql was rebuilt, andablation-dist-preflightfound the marker in 4 dist files. Result: 5 failed, 1 passed (the CONTROL). Restore: the blob equals HEAD andgit diff HEADis empty. After the rebuild,--absentfound the marker in none of the 14 dist files and the tree was clean. The file then passed 6/6.Final head
e8b311e4c0. Its code and tests are byte-identical toce0a9509e5; the only later commit is the changeset. All readings below are one8b311e4c0, in one locked run:pnpm --filter @objectstack/objectql exec vitest run --project local --maxWorkers=2: Test Files 615 passed (615), Tests 13888 passed (13888).pnpm --filter @objectstack/objectql typecheck: exit 0, test layer OK.pnpm --filter @objectstack/runtime typecheck: exit 0, test layer OK. The runtime filessrc/mcp-aggregate-relation-path-group-by.test.tsandsrc/mcp-aggregate-order-cut.test.tspassed 17/17 atce0a9509e5(lockVERDICT command-exit 0).pnpm --filter @objectstack/scenarios test: Test Files 40 passed (40), Tests 1182 passed (1182). See Acceptance notes for the CI red on this package.12e7094169failedfederated-injected-column-readers.test.ts, because the first cut of the door read the head throughreferenceTargetOf, a ledgered seam. The door now reads the head's declared type againstREFERENCE_VALUE_TYPES, which reads no reference carrier, so the ledger is unchanged.@objectstack/runtimesuite (only the two aggregate-bridge files above), andtest:repo. Both are declared to CI (Test Core).Acceptance notes
R2, the analytics own-qualifier path, measured (L1-a comment 7008122771). Setup: a temporary probe over real
ObjectQL,SqlDriveron SQLite,AnalyticsServicePluginand the dispatcher'sPOST /api/v1/analytics/query, countingengine.aggregatecalls on the object. The probe was deleted and is not in the diff. Same reading onorigin/maina1b14cdff8and on this head:dimensions: ['CUBE.region']and['OBJECT.region'], whereregionis a field the cube does not declare: answered400 INVALID_FIELDby the analytics door ("Dimension 'CUBE.region' on cube 'CUBE' walks relationship 'CUBE' (path 'CUBE')", then the object's name) before any strategy runs.engine.aggregatewas called 0 times. The same holds with a monthtimeDimensionsentry that routes to the ObjectQL strategy.declaredCubeMemberKey),engine.aggregatereceivesgroupBy: ['stage', { field: 'closed_on', dateGranularity: 'month' }], and the answer is 200 with the right counts on this head.A0 (re-measure): the 500 reproduced on
origin/mainb3247ddbdc, at two layers.SqlDriveron SQLite:nosuch, 1 hop and 2 hops answeredINVALID_FIELD/ 400 (the missing-column backstop). 3 hops and 4 hops answeredDATABASE_ERROR/ 500.A1: no hop limit is declared anywhere for the public
groupBy; its depth is 0 by the REST door's rule. The dotted name reacheddriver-sqlas a qualified identifier. SQLite's "no such column" parse attributes 1–2 hops; deeper qualifiers fail as a statement the driver cannot attribute, which falls to the terminalDATABASE_ERROR.A2: the related cards' mechanism (
RELATION_GROUP_BY,relation-group-join.ts) is an engine-internal, symbol-keyed request for ONE hop, used by the analytics strategy. It is not a publicgroupBykey. Widening it to N hops would be a public-vocabulary change, so this PR does not do it.A3:
driver-sql's fault mapping is untouched. A genuine driver error still answersDATABASE_ERROR/ 500. Only the path is refused, and it is refused before the driver runs.An in-memory engine's aggregate reads a dotted name with
getValueByPathover stored rows (code-read). For a relation path, that gives one null group under 200. For a JSON sub-path, it groups by the nested value. The door now refuses both before any driver runs.CI on
ce0a9509e5,Test Core (7/10),@objectstack/scenarios#test: not caused by this change. It is the timeout of one case:test/export/refresh.test.ts > galleryRefresh — the quiet skip > does not skip when one listed app is on an older version, or when the index lists no app,Test timed out in 5000ms. It took 5493 ms in run 44531427092 (job 135586800061) and 5065 ms in run 44540499020 (job 135618491647).pnpm --filter @objectstack/scenarios testpassed 40/40 files and 1182/1182 tests ate8b311e4c0, and again with the door file restored to the merge-basea1b14cdff8(blob99b3bf59, objectql rebuilt,ablation-dist-preflight --absent0 of 14). Run alone with the verbose reporter, the case took 510 ms at the head and 532 ms at the base. The base leg was restored by blob equality and an emptygit diff HEAD.src/score/scenario-tags.tsimportsstandaloneActionOwnerKey), but its app harness is a stub, andaggregatenever runs in it.The claim's file surface names
packages/plugins/driver-sql/src/**; the driver lives atpackages/drivers/driver-sql, and this PR does not touch it.Verification
e8b311e4c0:pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood testunder the verify lock, with noOS_TEST_SHARDand no path. The lock answeredVERDICT command-exit 0: Test Files 482 passed and 3 skipped (485), Tests 4092 passed and 68 skipped (4160), no failures.e8b311e4c0:check-adr-0087-registration --base origin/main("✓ check-adr-0087-registration: 1 declared-breaking changeset(s), each carrying an ADR-0087 disposition."),check-changeset-no-major,check-empty-changeset,check-issue-citationsandcheck:nul-bytesall exited 0.overlap-check --branch=HEADansweredVERDICT clean exit 0.dispatch-gates at e8b311e: 66 derived, 65 run with exit 0, 1 NOT MEASURED
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 66 commands for the 3 changed paths. All were run ate8b311e4c0; 65 exited 0.--ranreconciliation: "66 derived famil(ies) accounted for — 65 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)".check:dual-build-cjs-loads, exit 3, PREREQUISITE NOT MET. Six packages outside this change's build closure have nodist/here (studio, client-react, embedder-openai, knowledge-memory, knowledge-ragflow, service-knowledge). It exited 0 at1af59bd01f. CI builds everything and runs it.pnpm lint),Test Core/test:repo,Build Core, the type-check lanes, and the Dogfood Regression Gate (merge queue).Generated by Claude Code