Skip to content

fix(rest): serve the record page discussion whole past the data page size - #39294

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-39271-record-page-discussion-whole
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-39271-record-page-discussion-whole

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #39271

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在设了分页上限的部署上,记录页一打开带回的评论区现在是整串评论和全部表情回应,不再只有第一页;没设上限的部署用户无感。
  • 为什么做:属于「评论与讨论」专题,协议写明记录页要带回整串讨论,服务端此前没做到,这次补上。
  • 出错会怎样:读记录页评论的用户可能看到评论区报错而不是评论;这是一处服务端改动,可以直接撤回。
  • 要你做什么:无。

What changes

answerDiscussion in packages/rest/src/record-page-routes.ts read sys_comment, then sys_comment_reaction, through findData with no limit. On a deployment that sets a data page size, the data door answers such a read with its first page and hasMore. The route passed that page on as the whole thread, and the payload had no signal that rows were missing. The spec row discussion in packages/spec/src/api/record-page.zod.ts says "no page size (the whole thread, as the record feed reads it)".

  • New readWholeStream (the same file): the first read still names no page. While an answer says hasMore, it reads the next page, the size the first page was, at offset = rows read so far. Both discussion reads (comments, then reactions) go through it.
  • Order is created_at asc, then id asc (DISCUSSION_ORDER). Without the id tie-break, rows that share a timestamp could repeat or drop across an offset boundary. The spec's created_at asc is kept; id only orders ties. This is the same order as the client's readEveryPage (PR fix(console): page the record discussion reaction read on hasMore #39269).
  • Row budget (OS_DATA_QUERY_ROW_BUDGET): the last page is cut so it ends exactly at the budget (resolveQueryReadLimits, the same env the data door reads). Without the cut, a thread that fits the budget would be refused. A thread with rows past the budget gets the data door's own refusal of the read that would walk there (QUERY_ROW_BUDGET_EXCEEDED, 400). That refusal is carried in the discussion part for comments, or in reactions for reactions, where the spec's union already declares a refusal. The route never passes off the rows read so far as the thread. A deployment with a budget and no page size already answered this way, because its probe read refuses over budget. So both configurations now give the same answer. This needs no contract change.
  • No page-count ceiling, which differs from the client precedent's 100-page bound. The data door computes hasMore as offset plus rows against its count, so the loop always ends once the rows are read. A ceiling could only end in a short list or in an error code invented for it.
  • readStream now returns the door's hasMore beside records / total. Activity, attachments and timeline read the same fields as before.

Tests

record-page-routes.test.ts — 47 passed at 6bc8f6b; new describe [#39271], 4 cases

pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/record-page-routes.test.ts gave Tests 47 passed (47).

The new cases use a paging double that windows reads with the real planQueryReadWindow / assertQueryReadRows from @objectstack/types and the deployment env (vi.stubEnv). The double has 7 comments (two share a timestamp) and 8 reactions, against a page size of 3.

  • page 3: the payload carries all 7 comments in created_at, id order and all 8 reactions; the reads are offsets 0 (no limit), 3, 6 for each object.
  • page 3, budget 8: read whole; the last reaction page is limit 2, offset 6.
  • page 3, budget 6: the discussion is { error: { code: QUERY_ROW_BUDGET_EXCEEDED, status: 400 } }, not 6 comments.
  • page 3, budget 7: all 7 comments answered; reactions refused with QUERY_ROW_BUDGET_EXCEEDED / 400.

The existing all-streams case pins the new two-key orderBy on both discussion reads.

Ablation — two mutations, each red, each restored (blob == HEAD, git diff HEAD empty)

Done with scripts/ablation-replace.mjs on packages/rest/src/record-page-routes.ts. The suite imports the route from src/, so no build is involved.

Package suite and typecheck
  • pnpm --filter @objectstack/rest test at c71cd87 (6bc8f6b changes only the test double's matcher, and that file's 47 cases were re-run on 6bc8f6b): Test Files 451 passed (451), Tests 9356 passed | 351 skipped (9707).
  • pnpm --filter @objectstack/rest typecheck at 6bc8f6b: exit 0. check:test-typecheck: OK, 0 errors.

Acceptance notes

  • The client's own discussion read (readEveryPage in ui/packages/app-shell/src/views/useRecordDiscussion.ts) keeps the pages already read when a later page is refused with a 400 such as the row budget. This route refuses instead, as this card's dispatch asked. On a deployment whose thread exceeds the budget, the two doors now answer differently: the payload gives a refusal, the client's fallback read gives a short list. This is noted here and not filed.
  • The reaction read puts every comment id of the thread in one comment_id $in. Deployments with no page size already did this before this change. A thread of thousands of comments could reach a driver's bind-parameter limit. Not measured; noted only.
  • On a deployment with a page size and no row budget, a very long thread costs one find plus one count per page, run in series, on every record-page open. The deployment's budget is the bound it chose.

Verification

Read first, by risk:

  1. packages/rest/src/record-page-routes.ts, the readWholeStream loop: the room cut and the refusal carry.
  2. packages/rest/src/record-page-routes.test.ts, pagingDoor: it windows reads with the real planner.
  3. .changeset/record-page-discussion-whole-thread.md.

Two-minute check: pnpm --filter @objectstack/rest exec vitest run src/record-page-routes.test.ts -t 39271 should report 4 passed.

Local gates at 6bc8f6b: dispatch-gates --ran gives 70 derived, 68 run with exit 0, 2 NOT MEASURED
  • node scripts/pm/dispatch-gates.mjs --ran prints 70 derived famil(ies) accounted for — 68 run, 2 NOT-MEASURED.
  • NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test. It exits 3 because the shallow clone cannot reach its pinned positive-control commit; it exits 3 on origin/main too. It only checks the checker's own health.
  • NOT MEASURED: pnpm check:dual-build-cjs-loads. PREREQUISITE NOT MET: only the rest dependency closure was built. CI runs it.
  • pnpm check:where-matcher first flagged the test double as a silent matcher. It now refuses combinators and operators it does not implement, and the check passes.
  • node scripts/pm/overlap-check.mjs: VERDICT clean exit 0 (origin/main c7478b3, 0 open PR heads share a file).

Generated by Claude Code

@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 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: created_at (literal, 49 pages)
  • the SDK route bridge reached 71 of 256 client-bound route-ledger rows — the other 185 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 185: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 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 — 19 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 c7478b37b9ddd0dc3b7ceceaaf0c6f8ea9a4608d → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json c7478b37b9ddd0dc3b7ceceaaf0c6f8ea9a4608d

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6Ca2yTZZiHWkyVgD2oK

L1 review — PR #39294 (card #39271) — ACCEPT (landing conditions below)

Head-sha: 6bc8f6b509a38e1e3551f009a6a655b98f90a791 (read via gh api …/pulls/39294 --jq .head.sha at 2026-12-03T09:13Z; equals origin/claude/issue-39271-record-page-discussion-whole). Base merge-base ee2be200. 3 commits, 3 files: packages/rest/src/record-page-routes.ts (+49 net, file now 614 lines), its test, .changeset/record-page-discussion-whole-thread.md.

Inputs read: card #39271 body; comments 7371086694 (triage), 7371261298 (claim), 7373334709 (os-dev-report); the PR body; the net diff vs merge-base; check-runs on the head; PR #39287 body and diff (origin/claude/issue-39272-row-budget-discussion-state, head 376f45c1, still OPEN, not merged at 2026-12-03T09:18Z).

Face (node scripts/pm/l1-face.mjs --pr 39294, read 2026-12-03T09:14Z)

All mechanical rows ok (draft, base main, Fixes #39271, no other closing keyword, changeset present for @objectstack/rest, no empty changeset, no NUL suspect, Clause-②: no · Metadata-protocol: none, Skills-docs not owed, dogfood not owed). INCOMPLETE: floor-checks and all-checks NOT MEASURED (CI running). Footer items, judged:

  • Fixes is right: the card's acceptance ("with a page cap smaller than a record's comments and reactions, the payload carries every comment and reaction; a REST test pins it and goes red without the fix") is delivered whole (case 1 + ablation A).
  • Body read by eye: the only other card number is PR #39269, with no keyword next to it. Clean.
  • Scope: all 3 files are inside the claim's file surface. No adjacent fix, no codegen, no move/split. @objectstack/rest is not private and ships dist (compiled from the touched src), so the changeset is owed and present.
  • No send/write moved after the response, so no dogfood grep is owed. skip-changeset is not involved.
  • No git-answerable API reads in the report.

Check-runs on the head

  • Read at 2026-12-03T09:16Z: 13 success, 18 skipped, 22 in progress, 0 failed.
  • Re-read at 2026-12-03T09:18Z: 18 success, 18 skipped, 18 pending, 0 failed. Still pending: Test Core 1–12/12, Build Core, Type Check · workspace/source/consumer gates, the Lint repo/docs/CI/scoped jobs and Live E2E UI. Lint & Repo Gates and TypeScript Type Check were not yet reported.
  • ⇒ The floor and all-green are NOT MEASURED. This ACCEPT does not clear the queue: re-read before ready or enqueue.
  • My own local rerun: NOT MEASURED. A scratch worktree at the head could not load @objectstack/spec/api (no spec dist in the shared checkout), and I did not build into the shared checkout. Removed and pruned.

readWholeStream

  • Termination: the dev's argument holds for ProtocolDataCrud.findData. The door computes hasMore = pageOffset + records.length < counted (protocol-data-crud.ts ~L875). The route's offset is the rows read so far, and the loop returns on an empty page. So every iteration either ends or moves offset forward by at least 1 against a count that is re-read each page. Even a driver that ignored offset would terminate, because the door's hasMore is computed from the requested offset, not from the driver. Non-termination needs a count that grows faster than the reads, which is not a practical risk. Dropping the 100-page ceiling is acceptable.
  • Count absent or throwing:
    • A findData that answers no hasMore reads once (=== true). That is the old behaviour.
    • If engine.count throws, the door degrades counted to offset + rows, so hasMore is false and the route returns the rows read so far as the thread, silently. This is pre-existing door degradation that the route cannot see. Residual, not this PR's.
    • Rows short with hasMore true: the next page is read at the advanced offset. An empty page ends the loop. Correct.
  • Windows:
    • The first read names no limit, so the door's default page applies.
    • Each later read is limit = min(pageSize, budget − read) at offset = read. pageSize is the first page's length, which is at most the default, which is at most the maximum, so MAX_RECORDS_EXCEEDED is never tripped.
    • These are QueryAST limit/offset, which the door normalizes natively (L233/L746), not $top/$skip.
  • Budget cut:
    • The last page ends exactly at the budget (case 2: [2, 6] under budget 8). A thread of exactly the budget gets hasMore = false and is answered whole.
    • Past the budget, room ≤ 0 deliberately sends limit = pageSize at offset = budget. The real planner refuses that with QueryRowBudgetExceededError, which goes through the route's real refusalOf/mapDataError.
    • Budget-only deployments keep the probe refusal from the first read, as before.
  • Order: created_at asc, then id asc. This is compatible with the spec's "by created_at asc" (id only breaks ties) and is the same order as the client's $orderby: { created_at, id }. Without the tie-break, offset paging over tied timestamps can repeat or skip rows, so it is needed. The all-streams case pins the two-key orderBy on both reads.

Refusal arm, stop condition, Clause-②

  • Shape matches the spec union.
    • Discussion: the part is z.union([RecordPageDiscussionSchema, RecordPageStreamRefusalSchema]). The route returns { error: { code, status, message } } and nothing else, as the .strict() refusal arm requires.
    • Reactions: RecordPageDiscussionReactionsSchema is union([{records}.strict(), RecordPageStreamRefusalSchema]), and the route returns { error } there.
    • The tests parse every answer through RecordPageResponseSchema.parse and assert code and status (ADR-0112). HTTP stays 200.
    • QUERY_ROW_BUDGET_EXCEEDED is already in error-code-ledger.zod.ts (L1415), so no new code is added.
  • The stop condition held. No packages/spec/** file is in the diff, and the claim's "spec change = stop and report" was not triggered.
  • Clause-② no is right, and no contract review is owed.
    • The request accept set is unchanged: the same bodies are accepted with the same HTTP status.
    • What moves is which declared arm of a response union one configuration lands in. That configuration is page size plus budget, with a thread or reaction set past the budget. Before, it got a silent short list that broke the spec's "the whole thread". Now it gets the declared refusal arm.
    • That is pulling the producer back to the declared contract (execution-duties: 「条款②只指已发布契约面,拉回已声明契约不触它」). It is not a narrowing of an accept set.
    • Neither limb hits: no path limb, no yes declaration.
  • What the change does make is a landing-order dependency (condition 2 below).

Reaction read: one comment_id $in. I disagree with "noted, not filed".

  • The PR body says deployments with no page size already did this. That is true but incomplete. On page-size deployments, the $in was bounded by the page before this PR, and now it is bounded only by the budget, or not at all.
  • driver-sql declares oracledb and tedious peers. Oracle caps an IN list at 1000 expressions (ORA-01795), and SQL Server caps bind parameters at 2100. I found no whereIn chunking in driver-sql/src.
  • So a thread of more than about 1000 comments on Oracle now fails the reaction read. Every page re-sends the whole list (find and count).
  • It degrades gracefully: the failure lands in the reactions refusal arm and the comments are still answered. So it does not block this PR, but it should be filed as a p3 card in the topic 专题:列表页右上角的评论入口——看当前视图里各条记录的评论串,可回复、可解决,不能写新评论 #39077 family.
  • Suggested card: "Record page discussion: the reaction read binds every comment id in one $in, past Oracle's 1000-item IN list and SQL Server's 2100 parameters". The fix direction is to read the reactions in id chunks and merge by created_at, id, so the spec's single oldest-first order holds.

The two doors after #39287 (out-of-scope finding 1): they disagree in a way users can see. File a follow-up card.

Test double, assertions, controls, ablation

  • pagingDoor windows reads with the real planQueryReadWindow and assertQueryReadRows over vi.stubEnv limits. Its hasMore/total arm (offset + rows < all.length) matches the door's count arm.
  • Its matcher refuses $-combinators and any operator other than a lone $in. That is the check:where-matcher fix in 6bc8f6b. It cannot answer an unimplemented predicate as a field match.
  • The sort reads the route's {field, order} shape.
  • Fidelity gaps (not blocking):
    • The real ProtocolDataCrud is not exercised.
    • There is no case for budget-only or for OS_DATA_MAX_PAGE_SIZE-only, even though the changeset names both. The real planner covers MAX_PAGE_SIZE as the default.
  • Positive controls are present:
    • Budget 8: a fitting thread is not refused, and its last page is cut.
    • Budget 7: the comments are answered whole while the reactions are refused.
    • The tie pair is seeded c3 before c2, so an order without the tie-break would fail case 1.
  • Ablation A (no paging: 4 red) and ablation B (refusal replaced by the rows read so far: 2 red) go red where they should.
  • Pinning: the restores report the source blob ffd093ac. I verified that equals the head's blob, which is unchanged since 3f2e300. The commit at which the test file was ablated is not stated. 6bc8f6b only adds throws to the matcher and could not flip A or B. I accept it as pinned by blob.
  • The package suite ran at c71cd87, not the head. The head adds only test-double changes, and that file's 47 cases were re-run at 6bc8f6b. CI Test Core is the reading at the head (pending).

Changeset, sentence by sentence

  • Level: '@objectstack/rest': patch is right: a bug fix with kind none. The Clause-②: no and Metadata-protocol: none lines are present.
  • Title line "serves the whole discussion past the data page size": true.
  • "POST /data/{object}/{id}/page with discussion: true now returns every comment … and every reaction … on a deployment that sets a data page size (OS_DATA_DEFAULT_PAGE_SIZE or OS_DATA_MAX_PAGE_SIZE), as the record page contract declares": true. The route is ${dataPath}/:object/:id/page, and the maximum page size acts as the default.
  • "Before, it returned only the deployment's first page of each, with nothing in the answer to say rows were missing.": true for both reads.
  • "The server now reads the next page while the data door answers hasMore, ordered by created_at and then id so rows that share a timestamp are neither repeated nor skipped across pages.": true. Concurrent deletes mid-read can still shift an offset, which is outside the claim's scope.
  • "On a deployment that also sets a query row budget …, the last page is cut to end at the budget.": true.
  • "A thread with more rows than the budget is answered with the data door's own refusal (QUERY_ROW_BUDGET_EXCEEDED, status 400), in the discussion part for the comments or in its reactions for the reactions.": true. The 400 is the part's status, the HTTP status stays 200, and the sentence places it "in the discussion part".
  • "It is never answered with the rows read so far.": true, except the door's own count-failure degradation (see above).
  • "A deployment that sets only a row budget already answered this way.": true (probe refusal).
  • "Deployments that set none of these limits see no change.": true for rows and the reads made. Nit, not blocking: rows that tie on created_at now come back in id order where before the driver's order was unspecified.

Verdict: ACCEPT

Conditions, met by the seat 2026-12-03T09:40Z:

  1. CI at 6bc8f6b5: 39 success · 18 expected skip · 0 failed · 0 pending; Lint & Repo Gates and TypeScript Type Check success; mergeable_state clean; landing-k OK, K = 3.
  2. fix(app-shell): a record discussion the row budget declines is not shown as empty #39287 merged 2026-12-03T09:36Z (1354e3e51d), so main draws the new refusal as the declined "couldn't load" note.
  3. Filed: Record discussion client read keeps a short list at the row budget where the record page payload answers the whole thread or the budget refusal #39296 (client read vs payload at the row budget) and Record page discussion: the reaction read binds every comment id in one $in, past Oracle's 1000-item IN list and SQL Server's 2100 parameters #39297 (reaction $in past Oracle/SQL Server limits), both p3 area:data, sub-issues of 专题:列表页右上角的评论入口——看当前视图里各条记录的评论串,可回复、可解决,不能写新评论 #39077.

Landing: zone marks ready and arms auto-merge.

Reviewer's conditions as written:

Landing conditions (seat):

  1. Re-read the check-runs at the head before ready or enqueue: Lint & Repo Gates and TypeScript Type Check must be success and every check green.
  2. Enqueue only after fix(app-shell): a record discussion the row budget declines is not shown as empty #39287 is on main. Without it, the Console draws the new refusal as "No comments yet".
  3. File the two cards above: the client read alignment, and the reaction $in chunking. Record their numbers in the ACCEPT comment.

pm:dispatched comes off by Fixes on merge. Nothing is owed by hand.

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.

Record page payload: the served discussion is cut at the deployment's default page with no hasMore, though the spec says the whole thread

2 participants