Repository navigation
feat(data): host-configured default and maximum page size for list, report and analytics reads, and a per-query row budget, refused with a code naming the limit - #29796
Conversation
📓 Docs Drift CheckThis PR changes 4 package(s): 14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 8 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 171 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 012cd7e535f9291023fc6a48538bbf6f3d066662 && git checkout 012cd7e535f9291023fc6a48538bbf6f3d066662
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 99c069652e82e4417fd4cd2f46ee83176f9bab98 cbe0f85dd699d3116ea791b8b671fae1da81c294 && git checkout -B drift-repro 99c069652e82e4417fd4cd2f46ee83176f9bab98 && git merge --no-ff cbe0f85dd699d3116ea791b8b671fae1da81c294
node scripts/docs-audit/affected-docs.mjs --json 99c069652e82e4417fd4cd2f46ee83176f9bab98
|
Claude-Session: https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk Co-authored-by: Claude <noreply@anthropic.com>
…BUDGET_EXCEEDED Claude-Session: https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk Co-authored-by: Claude <noreply@anthropic.com>
…ate reads a producer check:error-status-conformance reads a class declaring both its code and its status; the shared class took its code as a constructor argument, so the catalog's 400 for QUERY_PAGE_SIZE_EXCEEDED and QUERY_ROW_BUDGET_EXCEEDED had no producer it could pin. QueryPageSizeExceededError and QueryRowBudgetExceededError each declare their own pair under the abstract QueryReadLimitError. Claude-Session: https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk Co-authored-by: Claude <noreply@anthropic.com>
|
repo:cloud#2 · os-zhuang · session_0123kRqqdpAJWYMgsgdAJX4G Contract-review record · 2026-11-03T07:12Z · CONTRACT_REVIEW_TIER (fable, by an at-tier reviewer) on Blocking.
Holds as is.
Non-blocking. You can carry these in the same push:
The seat re-reads on the next head. When it lands, the seat closes #29783 (the body says "Part of"). |
…_RECORDS_EXCEEDED The contract review found QUERY_PAGE_SIZE_EXCEEDED a synonym of the standard MAX_RECORDS_EXCEEDED (400, a caller-side limit: the request asked for more than a request may carry). The page-size refusals now answer that code, which gains its first producer, and QUERY_PAGE_SIZE_EXCEEDED is gone from the ledger, so the widening is QUERY_ROW_BUDGET_EXCEEDED alone. Its ledger row says why it is not MAX_RECORDS_EXCEEDED. The catalog folds the page-size cause into the MAX_RECORDS_EXCEEDED entry, the wire count is 57, the unpinned baseline drops MAX_RECORDS_EXCEEDED, and data-api.mdx no longer says a budget probe's read never runs. Claude-Session: https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk Co-authored-by: Claude <noreply@anthropic.com>
|
repo:cloud#2 · os-zhuang · session_0123kRqqdpAJWYMgsgdAJX4G Contract re-read · 2026-11-03T07:47Z · head
The merge state is |
Resolves the one conflict in metadata-protocol findData: main now hands the engine typed bags (aggregateQuery, findQuery). The read-limit plan runs before findQuery is built, so the bag carries the planned limit, and the grouped branch plans before aggregateQuery as before. Reference docs regenerated. Claude-Session: https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk Co-authored-by: Claude <noreply@anthropic.com>
Requested by Sam · project thread
Part of #29783
This PR is the whole of that card. It says
Part ofrather than a closing keyword because the card's claim names noclaude/issue-*branch and this PR's head branch cannot take that shape, socheck:closing-target-claimcould never pass with a closing keyword. The seat closes the card when this lands.What changes
A deployment can now bound how many rows one data API read returns and walks, through three host variables. Each is a positive integer; all three unset is today's behaviour exactly.
OS_DATA_DEFAULT_PAGE_SIZElimitOS_DATA_MAX_PAGE_SIZElimita read may nameOS_DATA_QUERY_ROW_BUDGEToffsetplus the rows it returnsThe documented rule for a request over a limit is refuse, never clamp. A clamp answers a different page from the one asked for: a caller paging by its own
limitwould skip the rows in between, and an analytics answer has nohasMoreto say a chart was cut. So:limitover the maximum →400 MAX_RECORDS_EXCEEDED, the existing standard code for a caller-side limit (the request asked for more rows than a request may carry), naming the spelling the caller wrote ($top/top/limit) and the maximum;offset + limitover the budget →400 QUERY_ROW_BUDGET_EXCEEDED, naming the budget. This is a new code because the budget bounds how deep a query walks, not how big a page is: a page well within the maximum is refused at a deep enough offset.Both are refused before the driver is asked (a budget probe, below, runs first and refuses on its answer). Each refusal writes one
warnline:[data] read refused: code=… surface=list|analytics object=… rows=… limit=…. The line carries the object and counts, never a row value.A read that names no limit:
GET /data/:object,POST /data/:object/query, grouped or flat, throughfindData) run with the default page size as theirlimit. The answer already says when more rows exist (hasMore,total), so this is an ordinary first page.AnalyticsService.query()behind/analytics/query, andqueryDataset(), the dataset door reports and dashboards read through) run with one row more than the default page. An answer with more rows than the default is refused withMAX_RECORDS_EXCEEDED, telling the caller to name alimitand page withoffset. The analytics doors judge the caller's own window; the dataset executor's internal passes (totals, measure-scoped queries) are not judged separately.offset. An answer over the budget is refused, and one that fits is served whole (the probe limit is taken back off, sohasMore/totalread as an unpaged answer).Where it lives:
@objectstack/typesquery-read-limits.tsholds the rule:resolveQueryReadLimits(strict: a value that is not a positive integer, or a default above the maximum, throws naming the variable),planQueryReadWindow,assertQueryReadRows, and the abstractQueryReadLimitError(limit) with one subclass per code,QueryPageSizeExceededError(MAX_RECORDS_EXCEEDED) andQueryRowBudgetExceededError(QUERY_ROW_BUDGET_EXCEEDED), each declaring its owncodeandstatus 400socheck:error-status-conformancepins the catalog's status.MAX_RECORDS_EXCEEDEDgains its first producer, so it leavesscripts/error-status-unpinned-baseline.json(the shrink-only direction).metadata-protocolfindDataplans every list read after the shape gates and before the engine.service-analyticsquery()andqueryDataset()plan the caller's window at the public doors.QUERY_ROW_BUDGET_EXCEEDEDis registered in the error-code ledger under@objectstack/types, with a line on why it is notMAX_RECORDS_EXCEEDED; the references pages are regenerated;content/docs/api/data-api.mdxdocuments the three variables and the refusal rule;content/docs/api/error-catalog.mdxgains aQUERY_ROW_BUDGET_EXCEEDEDentry, names the page-size cause underMAX_RECORDS_EXCEEDED, and counts 57 wire codes.What the budget does not count: rows a database scans inside an aggregate or behind an unindexed filter. The data API cannot see those, so the budget counts the rows a query walks through its window. The expand sub-reads, the export route and internal engine reads (backfills, sweeps) are not data API list reads and are untouched.
Why
The maintainer's 2026-11-03 04:26Z instruction on the cloud plan decision, verbatim: 「同意:在代码里补两个保护再谈放宽:查询扫描行预算和强制分页;每周看板加「每个 Team 组织的数据库大小与行读量」。第 3 个月闸门前有这两组数,再决定存储包价格和数据边界的数字。」
The hosted data plane runs this data API, and on
mainthere was no general page-size cap in it or in the SQL / libSQL drivers (re-checked at946a173f:driver-odata'spageSizeis only for its own upstream, and MCP'smaxQueryLimitonly for its own tool). Cloud sets the numbers in its own card (cloud#3510) once a pin carries this.Verification
packages/types/src/query-read-limits.test.ts(18): configuration (unset, all three, strict refusal of0/-5/1.5/abc/10k/1e3, default above maximum), no limits leave every read untouched, refusal shape (status, code,limit, message, the one log line with no row value), the default page, the analytics probe, the budget (including the default page counting against it, and the budget-only probe), and both codes resolving verbatim at 400 throughresolveThrownHttpError.packages/rest/src/data-query-read-limits.test.ts(6, realSqlDriverover SQLite, both list doors): defaults unchanged with nothing set (every row, a 100,000 limit, a grouped read), the default page withhasMore: true/total: 5, a limit within the maximum,MAX_RECORDS_EXCEEDEDon$top,top,limitand a grouped read with the driver never called,QUERY_ROW_BUDGET_EXCEEDEDwith the driver never called, and a budget-only read refused when it overruns and served whole (hasMore: false,total: 5) when it fits.packages/services/service-analytics/src/__tests__/query-read-limits.test.ts(8): both analytics doors unchanged with nothing set (noLIMIT, 500 rows served), the probe reaching the query (limit: 4) and the SQL (LIMIT 4), an answer past the default refused with the log line, a caller's own limit run as asked, over-maximum and over-budget refused with nothing run, and the budget-only probe.data-page-window-door.test.ts(the existing window pins) still passes. Full local suites:types860 tests,metadata-protocol310 files,service-analytics4,958 tests,rest7,139 tests, all passing.pnpm typecheckfortypes,metadata-protocol,service-analyticsandrest(with its test layer); eslint on every touched file;node scripts/check-error-status-conformance.mjsgreen; specerror-code-ledger.test.tsgreen;pnpm --filter @objectstack/spec check:generatednamedcontent/docs/references/**stale, regenerated withgen:docs;check-doc-anchorsresolves the new catalog links;check-error-status-conformance(and its self-test) green.node scripts/pm/dispatch-gates.mjs --tier: no path-derived tier mandate. Its Clause ② hint fires onpackages/spec/src/api/error-code-ledger.zod.ts: the new code widens the publishedErrorCodevocabulary, so a contract-tier review is owed before the queue.Clause-②: yes (widening)
Metadata-protocol: none
What Clause-② widens: the published error-code vocabulary.
ErrorCode(the unionApiErrorSchema.codeparses against) gains one registered member,QUERY_ROW_BUDGET_EXCEEDED. A page size over the maximum answers the existing standardMAX_RECORDS_EXCEEDED(400), which gains its first producer. No metadata an author writes changes, and no existing code, status or response shape moves.Keep one value on each of the two lines above, each line starting with its key.
Human Minimum
item 5 says what they mean.
Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01QUs3BtTosRanM94rtudkMk
Generated by Claude Code