Repository navigation
fix(objectql,service-analytics): query_dataset's ObjectQL face cuts its top-N in the database - #35728
Conversation
…its top-N in the database The engine's order-and-cut request gains an opt-in declinable flag: where the cut cannot be served it reads nothing and records a declined outcome instead of refusing. The analytics plugin bridges it as executeOrderCutAggregate, and ObjectQLStrategy sends order + (offset + limit) through it, taking the group count from the statement; on a decline it reads every group and cuts in memory as before. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
…face's database top-N Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
…'s type is unchanged Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1k1GRsQbF3vCPKxhz
📓 Docs Drift CheckThis PR changes 2 package(s): 29 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 27 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 7241a6f1bbac601810e54aee8065e2be1e9a4534 && git checkout 7241a6f1bbac601810e54aee8065e2be1e9a4534
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5ecf9374701d3fcb9de439c0bc09f7008992c80a d726cc761765087c4ba038ed8690c4872255a845 && git checkout -B drift-repro 5ecf9374701d3fcb9de439c0bc09f7008992c80a && git merge --no-ff d726cc761765087c4ba038ed8690c4872255a845
node scripts/docs-audit/affected-docs.mjs --json 5ecf9374701d3fcb9de439c0bc09f7008992c80a
|
|
repo:objectstack#4 · os-elon-musk · session_016WV4d1k1GRsQbF3vCPKxhz Final green head: |
|
repo:objectstack#4 · os-elon-musk · session_016WV4cxk4f4T7at3YeFruhZ L1 verdict (L1-a): ACCEPT at head Gates on this head: 53 check-runs: 37 success, 16 skipped, 0 failed, 0 pending. What I checked (holds):
On the seat's question (is Notes (non-blocking):
Not governed (no Generated by Claude Code |
Requested by Elon · project thread
Fixes #35287
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
Arm A of the maintainer's ruling on this card (「A 交给数据库排序(推荐)」, ruling record 7023449707), with the riders in 7023599246 as acceptance.
@objectstack/objectql(aggregate-order-cut.ts,engine-delete-and-aggregate.ts): anAGGREGATE_ORDER_CUTrequest may setdeclinable: true. Where the cut cannot be served (aggregateOrderCutRefusal: a driver that compiles none, an aggregate computed in memory, ahaving, a relation group join) the engine then reads nothing, answers[], leavesoutcomeunset and records the reason on a newdeclinedslot. Without the flag nothing changes:aggregate_recordskeeps its 400. The "Refused, never approximated" docblock is amended to say who declines and who is refused. The decline is a separate optional slot rather than a new arm ofAggregateOrderCutOutcome, so the published outcome type is unchanged and the three existing callers (runtimeaction-execution.ts, runtimedomains/mcp.ts, mcpstdio-data-bridge.ts) were reviewed and need no edit: none opts in, all still narrow onoutcome.kind === 'served'.@objectstack/service-analytics: a newexecuteOrderCutAggregatemember onDatasetScopedStrategyContext(mirroringexecuteRelationGroupAggregate), passed throughAnalyticsServiceConfigand wired byAnalyticsServicePluginonly when it auto-bridgesexecuteAggregate.ObjectQLStrategy.execute(base path) sends the query'sorderas the engine'sorderBy(a measure by its alias, a dimension by its group column) andlimit = offset + limit; served, it skips theoffsetover the database's rows and answerstotalGroupsfrom the statement's count; declined (or no seam, nolimit, an order key it cannot map), it reads every group and runs today'sapplyWindow(applyOrdering(...)).canPushDownWindow), so such a selection reaches the face with nolimitand is ordered and cut in memory by label. Pinned below. The optionalrankroute for select keys was not taken.The win is narrower than the card body says: memory, MongoDB, OData, Turso's remote face, uncompiled date buckets (a reference timezone, a granularity the driver does not compile), measure filters the driver does not evaluate and any
havingstill decline and are cut in memory. The cross-object path (executeCrossObject) is untouched.Visible behaviour (Clause-② yes, ruled): a text-ordered top-N on a compiling driver returns the database's choice of groups, its collation and NULL last in both directions, instead of
applyOrdering's (localeCompare,''as empty). The executor's post-pass still re-sorts the rows it was handed withapplyOrdering, as it does for the native face.Verification
Two-minute check:
pnpm --filter @objectstack/service-analytics exec vitest run src/__tests__/objectql-order-cut-face.test.ts, expect 7 passed.Read first:
packages/services/service-analytics/src/strategies/objectql-strategy.ts(readOrderCut,windowServedCut: the order-key mapping and the offset arithmetic),packages/objectql/src/engine-delete-and-aggregate.ts(the decline branch),packages/services/service-analytics/src/plugin.ts(the bridge readsoutcomeanddeclined).objectql-order-cut-face.test.ts(realObjectQL+SqliteWasmDriverthrough the plugin's own composition): top two by a measure reads 2 rows in one statement andtotalGroupsis 5;limit 2 offset 1sends a cut of 3 and answers groups 2 and 3; text order picksEmeaoveramer(binary collation) and never keeps the NULL group ascending or descending; the analytics query door uses the same face; a reference-zone date bucket and a driver that compiles no cut fall back with no refusal and an exacttotalGroups; a lookup dimension ordered by name is cut in memory (by nameAmy,Bob, where an id cut would have keptZed,Cat).aggregate-order-cut.test.tsgains a top-leveldescribe: declinable requests on memory, MongoDB and OData drivers, with ahaving, and with a zone bucketed in memory answer[]with the reason ondeclined, driver never asked; served unchanged on a compiling driver; a malformed order key still refusedINVALID_SORT.readOrderCutforced toundefinedviascripts/ablation-replace.mjs, anchor 1 to 0, blobc581598cto5983467d): 4 of 7 face pins red (the four that assert the database cut), the 3 fallback pins green; restored, blob equals HEAD,git diff HEADempty.Local runs (head d726cc7 for ratchets and typecheck)
pnpm --filter @objectstack/objectql test: 617/618 files, 13956/13960 tests; the 4 failures were the new describe, read mid-edit (its file and its source were rewritten while the suite ran); the file re-run alone: 20/20.pnpm --filter @objectstack/service-analytics test: 220/220 files, 5616 passed, 345 skipped.pnpm --filter @objectstack/objectql typecheck,pnpm --filter @objectstack/service-analytics typecheck: exit 0.node scripts/pm/dispatch-gates.mjs --commands: 76 families derived, 74 exit 0, 2 exit 3 PREREQUISITE NOT MET (check-plugin-teardown-shape --self-test: positive control unreachable in this clone;check:dual-build-cjs-loads: needs every package'sdist/), so NOT MEASURED here, CI runs both. Ratchets re-run on d726cc7:type-check-coverage,type-check-debt,issue-citations,nul-bytes,doc-authoring,dts-closureexit 0.node scripts/pm/overlap-check.mjs --branch=claude/area-a4C-35287: clean (origin/main 5d2ce34, fix(audit): a search the server widens never names a column the caller may not query #34817 merges cleanly).Acceptance notes
AggregateOrderCutOutcome/AggregateOrderCutRequestsee only an added optional field; CI'sTypeScript Type Checkcovers them.havingreaches the analytics face, so its decline is pinned at the engine only.🤖 Generated with Claude Code