Skip to content

fix(rest): read the record page reactions in comment-id chunks, under the Oracle and SQL Server IN-list limits - #39309

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-39297-reaction-read-chunks
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-39297-reaction-read-chunks

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #39297

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在 Oracle 或 SQL Server 上,评论上千条的记录页现在也能显示评论的表情回应;评论不多的记录与之前完全一样。
  • 为什么做:记录页讨论区专题的收尾之一,替使用这两种数据库的部署补上长讨论串的表情回应。
  • 出错会怎样:最坏是长讨论串的表情回应显示失败或顺序不对,评论本身照常显示,直接撤回这次合并即可。
  • 要你做什么:无。

What changes

answerDiscussion (packages/rest/src/record-page-routes.ts) read the reactions of a thread with ONE comment_id $in [every comment id of the thread]. Verified on main f808641: the plain $in arm of packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts compiles to a single knex whereIn with the whole list, and nothing in driver-sql/src chunks it, so past 1,000 ids Oracle refuses the IN list (ORA-01795) and past 2,100 parameters SQL Server refuses the request. The reactions part then answers that refusal; the comments are still answered.

Where the fix lives: in the route, as the card's claim scoped it. driver-sql is read, not changed.

  • REACTION_READ_CHUNK_SIZE = 500 (exported, documented): the most ids one reaction read binds. Half Oracle's 1,000 cap, which leaves SQL Server over 1,500 parameters for the rest of the statement (tenant scope, RLS and sharing predicates, the page window).
  • readReactions(ids) reads the ids chunk after chunk, each chunk paged whole by readWholeStream exactly as PR fix(rest): serve the record page discussion whole past the data page size #39294 pages it, then merges the chunks into the spec's one oldest-first order (created_at as an instant, then id) with a stable sort. A thread of up to 500 comments is one chunk and keeps the database's own order, untouched.
  • Row budget kept across chunks: readWholeStream takes walked, the reaction rows earlier chunks already read. Each chunk is its own query, which the door counts from its own offset 0, so a walk past OS_DATA_QUERY_ROW_BUDGET across chunks is refused in the route by the door's own rule, planQueryReadWindow from @objectstack/types, asked of the whole walk. The reactions arm answers the same QUERY_ROW_BUDGET_EXCEEDED / 400 refusal (the door's own message text), and the comments are still answered. With walked = 0 (the comments, and the first chunk) the code path is the one PR fix(rest): serve the record page discussion whole past the data page size #39294 shipped, byte for byte.
  • setReactionReadChunkSizeForTests(n) is a test seam returning a restore function, in the shape of the existing setCelPushdownLimitsModeForTests / setPreferencePageSizeForTests. It is not re-exported from the package entry (packages/rest/src/index.ts does not export this module), so no published type carries it. No env var.

Files to read first, by risk:

  1. packages/rest/src/record-page-routes.ts, the readWholeStream hunk: the two walked > 0 branches (the check after a chunk's first read, and the room check inside the paging loop) carry the cross-chunk budget.
  2. packages/rest/src/record-page-routes.ts, readReactions and compareDiscussionOrder: the merge order.
  3. packages/rest/src/record-page-routes.test.ts, the new [#39297] describe nested in the [#39271] one (it reuses that block's pagingDoor double).

Two-minute verification: pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/record-page-routes.test.ts → Tests 54 passed (54).

Tests

New, in record-page-routes.test.ts, chunk size forced to 3 or 4 through the seam, over the existing pagingDoor double (the door's own windowing and budget refusal):

  • every reaction is answered once, in order, across chunk boundaries, with no page size and with a page of 2: a reaction of chunk 1 ties a reaction of chunk 2 on created_at and sorts after it by id, so chunk-by-chunk concatenation is the wrong order; every read binds at most 3 ids, and the chunks are exactly the thread's ids;
  • reactions past the row budget across chunks (budget 7, eight reaction rows, no chunk alone past it) are the QUERY_ROW_BUDGET_EXCEEDED refusal of the reactions arm, with the whole thread still answered, for three shapes: the refusal after a later chunk's first read (chunks of 3, no page size; chunks of 3, page 2) and the refusal inside a later chunk's paging loop (chunks of 4, page 2);
  • reactions that fit the budget exactly (8) across chunks are answered whole;
  • the constant is below 1,000.

Ablations (fix committed first; each mutation through scripts/ablation-replace.mjs, which proved the anchor hit once, the blob changed, and the restore to HEAD blob 8a599e84f830 with an empty git diff HEAD). The test imports the route by relative source path, so no build sits between mutation and run.

Ablation Result
A1 the seam's assignment removed (no chunking: one $in) 2 failed / 52 passed: both in-order tests (a read bound more than 3 ids)
A2 the merge removed (chunk-by-chunk concatenation) 3 failed / 51 passed: both in-order tests and the exact-fit test
A3 walked passed as 0 (no cross-chunk budget) 3 failed / 51 passed: all three past-budget shapes

A2's first attempt was refused by the tool before any run (its replacement text records already occurred in the file); it was re-run with a distinct replacement. Recorded here because it was a no-op.

Code run at a7c52aa; the head 98a4ad0 adds only the changeset, so src/ is the same blobs.

Local test and typecheck output
pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/record-page-routes.test.ts
 Test Files  1 passed (1)
      Tests  54 passed (54)
os-verify-lock: VERDICT command-exit 0

pnpm --filter @objectstack/rest typecheck   (tsc --noEmit && check:test-typecheck)
check:test-typecheck: OK — @objectstack/rest's test layer compiles under packages/rest/tsconfig.test.json; 0 file(s) / 0 error(s)
os-verify-lock: VERDICT command-exit 0
Derived gate families at 98a4ad0

node scripts/pm/dispatch-gates.mjs --commands derived 70 commands for the three changed paths; all were run, each exit code captured before any pipe, then reconciled:

Run reconciliation — 70 derived, 68 run, 2 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 70 derived famil(ies) accounted for — 68 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).

NOT MEASURED, both PREREQUISITE NOT MET (exit 3): check-plugin-teardown-shape.mjs --self-test (its fixture commit is unreachable on this shallow clone) and check:dual-build-cjs-loads (it reads every package's dist/; only @objectstack/rest's dependency closure was built). CI runs both.

check:query-options-erasure and check-comment-mask-corpus.mjs first hit a 240 s per-command wrapper on a shared box (exit 124); each was re-run alone to its verdict: exit 0 (388 s and 236 s).

overlap-check.mjs --branch=HEAD: origin/main (dc4a2cd) merges cleanly, VERDICT clean.

Acceptance notes

  • Not filed. The driver's $in arm has no IN-list bound for any caller. Any other read that binds an unbounded id list hits the same Oracle and SQL Server ceilings. I inferred this from reading the code and measured it nowhere else. Carrier: none.
  • In-memory merge order: created_at is compared as an instant (a Date, a number, or a parseable string), and id by plain code-unit order, numbers by value. This order is only used when there is more than one chunk. If a database collation orders two ids at the same instant differently (for example a case-insensitive collation), the merged order of that tie can differ from what one statement would answer.
  • The cross-chunk budget refusal is built in the route, so it does not write the door's [data] read refused warn line. The refusal on the first chunk and on the comments is still the door's own and still logs.
  • Chunks are read one after another, not in parallel, because the budget counts rows across chunks. A thread of N comments costs about N/500 sequential reaction reads, plus paging.
  • test:repo was not run locally: the diff edits no test in that project, and no derived family named it. CI's Test Core runs it.

Generated by Claude Code

…ged oldest first

The discussion's reaction read bound every comment id of the thread in one
comment_id $in; past about 1,000 ids Oracle refuses the IN list and past
2,100 parameters SQL Server refuses the request. The ids now go in chunks of
REACTION_READ_CHUNK_SIZE (500), each chunk paged whole as before, the row
budget counting every chunk's rows, and the chunks merged by created_at, id.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca2yTZZiHWkyVgD2oK
@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

7 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
  • 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 dc4a2cdbd6ad880ebcca9a6ff33f3b30bb5ed537 → packageMentionDocs.

Which tree this was computed on

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

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

⚠️ 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 #39309 (card #39297), head 98a4ad0965004d39cd200b6fe62575eb50eff80c. ACCEPT (code). Before ready or queue, CI at this head must be green: both floor checks and every check (see Gates).

Seat, 2026-12-03T12:06Z: conditions met. CI at 98a4ad09: 39 success · 18 expected skip · 0 failed · 0 pending; mergeable_state clean; l1-face CLEAN. K: behind main by 3 (compare API), so K < 15.

Inputs read

  • PR head: gh api …/pulls/39309 --jq .head.sha at 2026-12-03T11:26Z, and again at 2026-12-03T11:31Z. Both reads gave 98a4ad09…. The PR is a draft against main and the merge-base is f8086415.
  • node scripts/pm/l1-face.mjs --pr 39309 at 2026-12-03T11:26Z came back INCOMPLETE. Every row is ok except floor-checks and all-checks, which are NOT MEASURED because CI was still pending.
  • 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 #39297: body, triage audit 7375030135, claim 7375113634, os-dev-report 7376678770. The bot triage line 7374952597 was also read.
  • PR body. Net diff origin/main...origin/claude/issue-39297-reaction-read-chunks: 3 files, +209/−5.
  • Code read beside the diff:
  • Check-runs at the head, read at 2026-12-03T11:29Z and 2026-12-03T11:31Z. The last read: 20 success, 18 skipped, 16 in progress (Test Core 1–12/12, Build Core, Type Check · workspace/consumer/debt, Lint · scoped/docs/CI), 0 failed.

Face footer, item by item

  • Fixes vs Part of. Fixes #39297 is right. The card asks for chunked reads merged by created_at, id, plus a REST test with a forced-small chunk that goes red without the fix. Both are delivered. The card left the choice between route and driver to the builder, and the PR names the route. The body has no negated, bookkeeping or quoted closing keyword, and no other card number sits next to a keyword.
  • Scope. All 3 files are inside the claim's file surface (route, its test, one changeset). driver-sql is read, not changed.
  • Skills-docs. Not owed (kind none).
  • Published surface.
    • @objectstack/rest is not private. files[] is dist + README + CHANGELOG, and tsup has the single entry src/index.ts with splitting: false.
    • src/index.ts exports nothing from record-page-routes.ts. So REACTION_READ_CHUNK_SIZE and setReactionReadChunkSizeForTests reach neither dist/index.d.ts nor the entry's exports.
    • No published type changes. Clause-②: no and Metadata-protocol: none hold.
  • skip-changeset. Not used. A changeset is present and not empty.
  • Write after response. No send or write moves after the response, so no dogfood grep is owed.
  • Other checks. No adjacent fix inside the change, no one-shot codegen, no move or split. The route file is 729 lines, under the 2,000-line rule.

Chunk bound 500: worst-case binds

What a reaction read actually binds, counted on origin/main code:

  1. Route. comment_id $in, at most 500 ids per chunk.
  2. Reaction read gate (computeReactionVisibilityFilter, ADR-0139 D5.2 keeps the probe). It ANDs a second comment_id $in kept, where kept is a subset of the chunk, so at most 500 more. The PR's bind accounting does not list this. The real reaction statement carries two lists, not one. On main that means SQL Server broke at about 1,050 comments with reactions, not at the 2,100 the card's reach line gave.
  3. Sharing. sys_comment_reaction declares no sharingModel and is sys_, so effectiveSharingModel resolves to public. No owner $in and no approval-id list.
  4. Other binds. The org wall (1–2), any authored RLS (a handful) and the MSSQL OFFSET/FETCH window (2).

Worst case for the reaction find statement: about 1,000 + ~10, which is under 2,100. The count statement is a separate statement and carries the same bound.

Oracle: ORA-01795 is per list, and each list is at most 500, so the limit holds.

Two statements next to the chunk, not bounded by it:

  • The gate's candidate pre-scan (SYSTEM context, the route's where only): at most 510 binds.
  • The parent-readability read (resolveReadableParentIds → one caller-scoped sys_comment read). It binds at most 500 ids plus the comment thread gate. That gate is "one branch per registered parent object", each a ReadableIds subquery with that parent's own scope binds; call that G. G is not measured. The thread's own comments read already pays G, so the chunk adds at most 500 to a cost that read already carries.

Verdict: 500 is safe for the statements the chunk controls. The constant's doc comment names "the tenant scope, row-level security and sharing predicates, the page window" but not the gate's second list. That is a nit; the arithmetic still holds. The pin test asserts < 1000, and that still covers SQL Server only because 2 × 999 + ~10 < 2,100.

Merge order and duplicates

  • More than one chunk. The stable sort is instantOf(created_at) (a Date, a number, or a parseable string), then id by code unit (numbers by value).
    • Rows from different chunks never belong to the same comment, so each comment's emoji order is its own chunk's order, which is database order. The client groups by comment anyway (groupReactionRows).
    • The only difference from what one statement would answer is a tie at the same instant under a non-binary collation (case-insensitive, or ICU ignoring - and _). The PR body discloses this.
    • Mixed formats inside one column (SQLite epoch INTEGER next to ISO TEXT) would compare as ms against ms only if the driver normalises on read. That is edge-only, and the comparator falls back to text order.
  • One chunk (500 or fewer comment ids). walked = 0 and no sort, so the database order is DISCUSSION_ORDER = created_at asc, id asc, the order fix(rest): serve the record page discussion whole past the data page size #39294 promised. The path is behaviourally identical to fix(rest): serve the record page discussion whole past the data page size #39294: room subtracts 0 and the new branches are guarded by walked > 0.
  • Duplicates.
    • The chunks are slices of one list, and a reaction has one comment_id, so it lands in exactly one chunk. Within a chunk, paging is fix(rest): serve the record page discussion whole past the data page size #39294's stable-order paging.
    • Residual (nit): ids is not de-duplicated. A comment id that appeared twice in the comments read (an offset-paging race: a row inserted before the cursor, unlikely with created_at defaulting to NOW() and read-only) and fell on both sides of a chunk boundary would duplicate its reactions. The old single $in absorbed that. [...new Set(ids)] would close it.

Budget across chunks (walked)

The door's rule is offset + limit > rowBudget → QUERY_ROW_BUDGET_EXCEEDED.

  • After a later chunk's first read: budgetRefusalOfWalk(name, walked, rows) refuses exactly when walked + rows > budget.
    • A deployment with only a budget gets the door's own probe: one chunk alone past the budget is still the door's refusal.
    • A first page cannot exceed maxPageSize, because the door caps it at defaultPageSize ≤ maxPageSize. So this check cannot raise a false MAX_RECORDS_EXCEEDED.
  • In the paging loop: room = min(pageSize, budget − walked − rows).
    • When room > 0, the door sees rows + room ≤ budget − walked.
    • When room ≤ 0 with hasMore (a count-based hasMore, so rows really remain), it refuses with offset walked + rows and limit pageSize, which is always over the budget.
  • Exact fit is answered. Budget 8 with 8 rows passes (test).
  • One past is refused. Budget 7 with 8 rows is refused, for three shapes. I traced all three:
    • chunk 3, no page: refused at chunk 3's post-check, 7 + 1 > 7
    • chunk 3, page 2: the same
    • chunk 4, page 2: chunk 2 walked 5, first page 2, then room = 0 in the loop
  • Refusal shape. refusalOf(QueryRowBudgetExceededError) is the same mapper the door's thrown error goes through, so the result is { code: QUERY_ROW_BUDGET_EXCEEDED, status: 400, message }. Tests assert code and status (ADR-0112). Comments are still answered (asserted).
  • Differences from the door, both disclosed. The message's "offset N" is the cross-chunk walk. The route-built refusal writes no [data] read refused warn line. Neither blocks.

Test seam

setReactionReadChunkSizeForTests(n) validates a positive integer and returns a restore function, which afterEach calls.

  • It lives in the same file as the route, inside the claim's file surface.
  • Precedent: setCelPushdownLimitsModeForTests (formula) has the same shape and IS re-exported from its package entry. This seam is stricter: module-only, absent from dist.
  • There is no env var and no production caller.

Ablations and evidence pinned to the head

  • Code was run at a7c52aaf. The head 98a4ad09 adds only the changeset: git diff --stat a7c52aaf 98a4ad09 is .changeset/… only. The route blob at the head is 8a599e84f830…, which is the restore blob the PR names. The test blob is 9135b412.

  • The baseline is 54/54 under os-verify-lock. Typecheck exits 0.

  • I derived each ablation's expected outcome from the tests and the pagingDoor double (which enforces the per-query budget through planQueryReadWindow/assertQueryReadRows):

    Ablation Expected failures Reported
    A1, no chunking the 2 in-order tests (≤3 ids). Past-budget tests stay green: one statement of 8 rows over 7 is the door's own refusal 2 failed / 52 passed
    A2, no merge 2 in-order + exact-fit 3 failed / 51 passed
    A3, walked = 0 the 3 past-budget shapes 3 failed / 51 passed

    Every reported count matches. Positive controls hold: the exact-fit test is the control for A3, and the no-budget in-order tests are the controls for the budget arms.

  • I did not re-run vitest. The checkout has no built dist for the dependency closure, and a read-only seat does not build in the shared tree. The runs are recorded as reported plus traced, not re-measured. CI Test Core at this head is the measurement of record and is still in progress.

  • Process deviation (ablation vitest runs outside os-verify-lock). The lock serialises heavy work on a shared box. Running outside it risks a false red from contention or timeouts, not a false green.

    • Each ablation's red names the specific assertions that the mutation predicts (for example "a read bound more than 3 ids"), with counts that match the trace above. The green baseline ran under the lock.
    • So evidence validity is unaffected. The deviation is procedural, and it is recorded in deviations verbatim.
  • Git-answerable API reads. None: the report shows mcp_calls: 0 and only 2 relay writes.

Changeset, sentence by sentence (.changeset/39297-reaction-read-chunks.md)

  1. "the record page reads a thread's reactions in comment-id chunks, so a long thread keeps its reactions on Oracle and SQL Server". True for the chunking, which is in the diff. "Keeps" is inferred from code and not measured on either driver; that is acceptable for a patch line.
  2. "POST /data/:object/:id/page with discussion: true read the reactions … with one comment_id $in naming every comment". True: route ${dataPath}/:object/:id/page, POST, and the - line of the diff.
  3. "Oracle refuses an IN list of more than 1,000 items and SQL Server a statement of more than 2,100 parameters, so … answered its comments with the reactions part refused". True: the refusal lands in the reactions arm and the comments are answered. The sentence names no threshold, so the about-1,050 correction above does not make it false.
  4. "read in chunks of at most 500 comment ids, one chunk after another, each paged whole as before, and merged into the one oldest-first order (created_at, then id)". True: sequential for, readWholeStream per chunk, then compareDiscussionOrder.
  5. "The deployment's row budget … counts the reaction rows of every chunk together: reactions past it are still the QUERY_ROW_BUDGET_EXCEEDED refusal of the reactions part, and the comments are still answered". True, traced and tested.
  6. "A thread of up to 500 comments is read exactly as before". True: one chunk, walked = 0, no sort, and the same reads.

Gates

  • Lint & Repo Gates and TypeScript Type Check: absent at 98a4ad09 as of 2026-12-03T11:31Z. NOT MEASURED.
  • The full check set: 16 still in progress, 0 failed.
  • The dev's local subset (70 derived: 68 run, 2 NOT MEASURED, exit 3) is pinned to 98a4ad09. It proves the local subset only and does not stand in for CI.
  • Landing pre-condition: before ready or queue, the seat re-reads the floor checks plus every check at this head. A turn red during convergence goes to a patch round with the original dev, not to REWORK.

Nits (not blocking; may ride a later touch of the file)

  1. The doc comment on REACTION_READ_CHUNK_SIZE should name the reaction read gate's second comment_id $in (≤ chunk) in its bind accounting.
  2. De-duplicate ids before chunking.
  3. The cross-chunk refusal writes no [data] read refused warn line, unlike the door's (already disclosed).

Out-of-scope findings: cards to file

A. The dev's finding: should be a card. Proposed:

Title: driver-sql: a plain $in compiles to one unbounded whereIn, so a read binding more than 1,000 ids fails on Oracle (ORA-01795) and past 2,100 parameters on SQL Server

Body: packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts (the case '$in' / '$nin' arms) hands a literal list straight to knex whereIn. Nothing in driver-sql/src splits it, although the package declares oracledb and tedious peers. Oracle refuses an IN list of more than 1,000 expressions, and SQL Server a request of more than 2,100 parameters. Several callers chunk for themselves: RECORD_SCOPED_DELETE_CHUNK = 200, SharingRuleService 200, closed-state-lock IN_CHUNK = 500, SUMMARY_GROUPED_AGGREGATE_CHUNK = 500, and the record-page reactions after #39309. Callers that do not chunk meet the ceiling, for example:

  • the comment reaction read gate (computeReactionVisibilityFilter, comment-access-hooks.ts), whose comment_id $in kept can carry up to READ_SCAN_LIMIT = 2,000 ids on a broad reaction read;
  • sharing's owner_id $in ownerIds under unit / unit_and_below scopes;
  • the sys_comment thread gate, one ReadableIds branch per registered parent object, whose total parameter count G is unmeasured.

Direction is the builder's call. One option is driver-side splitting into OR-ed groups below 1,000 for Oracle, with a parameter ceiling (or a typed refusal) for MSSQL. The other is a documented per-caller contract plus a gate. Either way, measure G on MSSQL.

Grade: area:data · domain:server · Bug · p3 (Oracle or SQL Server deployments only; graceful or loud refusals; evidence read from code, not measured on those drivers) · size M · Part of #39077 is not right; file it standalone under the driver-sql area.

Dedupe words: driver-sql whereIn IN list limit, ORA-01795, bind parameters 2100, $in chunking driver. On 2026-12-03T11:28Z these searches found only #39297 (open) and closed, unrelated hits.

B. Coordinator item (from the #39308 reviewer): a real disagreement, filed as a follow-up and not a blocker. Proposed:

Title: Record discussion reactions: the row budget counts the whole thread in the record page payload but each 100-comment batch in the client's direct read, so one thread's reactions can be declined on one surface and shown on another

Body: On a deployment with OS_DATA_QUERY_ROW_BUDGET, the record page payload (answerDiscussion → readReactions, packages/rest/src/record-page-routes.ts) refuses the reactions part when the thread's reaction rows together exceed the budget. That is #39309's cross-chunk walked, and it keeps the single-$in semantics main already had. The client's direct read (readCommentReactionRows in ui/packages/app-shell/src/views/useRecordDiscussion.ts) reads REACTION_READ_COMMENT_IDS = 100 ids per batch, in parallel. Each batch is its own query against its own budget (#39308 cuts each batch's last page at the budget and rejects past it), and any batch rejection drops all reactions (records = null). So for a thread of more than 100 comments whose total reactions exceed the budget while no 100-comment batch does, the record page shows the comments without reactions, while a surface that mounts the discussion without the payload (for example the list-page comments entry of #39077, or the phone comments page) shows them all. The reverse also holds: a thread with one heavy 100-batch is declined on the client while the payload can still answer it if the total fits. User-visible, but rare: it needs a configured budget, a thread over 100 comments, and reactions near the budget. It exists on main today (single $in against 100-batches); #39309 preserves it and does not introduce it. Fix: one rule for what the budget bounds on a chunked discussion read, either the logical stream (the server's choice) or each query, applied on both sides with matching or irrelevant batch sizes. If the rule changes what the budget means for the data door's consumers, it is a maintainer ruling.

Grade: area:data · domain:ui (+server) · Bug · p3 (configured budget only; evidence read from code) · size S–M · Part of #39077.

Dedupe words: reaction batch row budget, REACTION_READ_COMMENT_IDS budget, record page payload vs direct read reactions declined. Adjacent but distinct: #39296, which is the per-read last-page cut, not the batch budget scope.

C. Observation for the seat (lower confidence; file only if confirmed)

The reaction read gate's candidate pre-scan reads at most READ_SCAN_LIMIT = 2,000 rows per read, offset-less. Comments whose reactions all fall past row 2,000 in created_at order are excluded fail-closed, with a warn line only. The gate's comment says "a comment feed reads … by comment_id, and never hits this". Since #39294 reads the whole thread, that assumption fails for threads with more than 2,000 reactions on main. After #39309 it fails per chunk, for 500 comments with more than 2,000 reactions, which narrows the gap but does not close it. A dedupe search for "pre-scan" + reaction on 2026-12-03T11:30Z found no open card.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 3, 2026 12:07
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 2417d66 Dec 3, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-39297-reaction-read-chunks branch December 3, 2026 12:33
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 discussion: the reaction read binds every comment id in one $in, past Oracle's 1000-item IN list and SQL Server's 2100 parameters

2 participants