Skip to content

fix(app-shell): count the record discussion reaction read's batches against the row budget as one read - #39342

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-39313-reaction-budget-scope
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-39313-reaction-budget-scope

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #39313
Clause-②: no
Metadata-protocol: none

维护者速读

  • 设了单次读取行数上限的部署上,超过 100 条评论的记录,列表页评论栏和手机评论页对表情回应的判断改为与记录页一致:整串评论的表情回应合计超上限时都不显示,合计没超时都显示。
  • 属于记录评论专题,替这类部署上的用户解决「同一条记录的表情回应在记录页被拒、在列表页却显示」的不一致。
  • 只影响这类部署上评论超过 100 条且表情回应接近上限的记录;最坏情况是多发一次只取一行的读取,或表情回应不显示而评论照常显示,改动可直接撤回。
  • 无

What changes

On a deployment with OS_DATA_QUERY_ROW_BUDGET, the record page payload (readReactions in packages/rest/src/record-page-routes.ts) counts every id chunk's reaction rows against the budget, so the thread's reactions together past the budget refuse the reactions part. The client's direct read (readCommentReactionRows in ui/packages/app-shell/src/views/useRecordDiscussion.ts, used by the list-page comments column, the phone comments page and every comment read the payload does not serve) reads the thread in batches of REACTION_READ_COMMENT_IDS (100) comment ids, in parallel, each batch its own query, so the door judged each batch alone. A thread over 100 comments whose reactions together were past the budget, with no batch past it, showed its reactions there and none on the record page.

Premise re-read on main at 6b2e596 (includes #39308 and #39309): holds as the card states.

The fix keeps the batches parallel and adds the one thing the door could not see: when more than one batch answered rows, the client asks the door its own budget rule of the whole walk, with one read of the last answering batch at $skip = (rows read together) minus 1 and $top = 1. The door judges $skip plus $top against the budget before it runs anything (planQueryReadWindow), so it refuses exactly when the rows together are past the budget, the same rule budgetRefusalOfWalk applies server side. The client never learns or infers the budget number; the door's QUERY_ROW_BUDGET_EXCEEDED rejects the read, as a page past the budget already does, and the caller shows the comments without reactions, as the payload's refused part does. A 400 that is not the budget's leaves the rows standing (as a later page's does in readEveryPage); a failure or a refusal rejects. Cost: one extra one-row GET, only for a thread whose reactions span more than one 100-comment batch. No new client or server surface, and the data door's budget means the same for every other consumer. record-page-routes.ts is unchanged: the payload already applies the rule; its test file gains the twin table.

Files edited:

  • ui/packages/app-shell/src/views/useRecordDiscussion.ts
  • ui/packages/app-shell/src/views/useRecordDiscussion.test.tsx
  • packages/rest/src/record-page-routes.test.ts
  • .changeset/39313-reaction-read-budget-one-walk.md (@object-ui/app-shell patch)

Read first:

  1. readCommentReactionRows in useRecordDiscussion.ts: the walk read and its catch (which verdicts reject, which leave rows standing). Highest risk: the $skip arithmetic (rows read together minus 1, $top 1).
  2. The new #39313 describe in useRecordDiscussion.test.tsx: the door double filters by comment_id $in and applies the page/budget rule per query.
  3. The [#39313] describe in record-page-routes.test.ts: the same case table against the payload.

Tests

Both doors are pinned with one case table (150 comments, so two client batches; reactions on comment 1 and comment 101; budget 10): rows together past the budget with no batch past it (6 + 6), with and without a page size of 4, are declined on both; rows that fit exactly (5 + 5, and 6 + 4 paged) are shown on both; one batch past the budget (11 + 0, 0 + 11 paged) is declined on both. One more client test pins the walk read's window ([11, 1] for 6 + 6) and that a thread whose reactions sit in one batch sends none.

Local runs at fb3b009
  • pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/useRecordDiscussion.test.tsx packages/app-shell/src/views/ObjectView.phoneCommentsPage-39086.test.tsx: 2 files, 40 passed.
  • The seven RecordDetailView.* suites that read sys_comment_reaction: 7 files, 71 passed.
  • pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/record-page-routes.test.ts: 60 passed (the 6 new [#39313] cases confirmed by -t 39313 --reporter=verbose: 6 passed, 54 skipped).
  • @object-ui/app-shell type-check (src + tsconfig.test.json): exit 0, after building its dependency closure. @objectstack/rest typecheck (tsc + check:test-typecheck): exit 0.
  • Ablation (committed first, scripts/ablation-replace.mjs, anchor if (answering.length > 1) { replaced by if (answering.length > 1 && false) {, landed x1 to x0, blob 6a0a0938 to b8619467): 3 failed, 21 passed; the two "rows together past the budget, no batch past it" cases and the walk-window test went red. Restored: blob equals HEAD, git diff HEAD empty.

Acceptance notes

  • Observation C (read, not measured): the reaction read gate's candidate pre-scan (computeReactionVisibilityFilter in packages/plugins/plugin-audit/src/comment-access-hooks.ts, READ_SCAN_LIMIT = 2,000) reads at most 2,000 reaction rows of the read's where in the caller's order, under system context, and narrows the read to comment_id in the comments those rows name. A comment none of whose reactions falls in those first 2,000 rows is filtered out, fail closed, with one warn line. Its own comment says a comment feed "never hits this", but one 100-comment client batch or one 500-id payload chunk with more than 2,000 reaction rows does, and the two doors hit it at different sizes. It bites only with no budget or a budget over 2,000. Not changed here (outside this card's file surface); reported to the seat.
  • The walk read returns at most one row, which is not used.

Verification

Two-minute check: pnpm --dir ui exec vitest run packages/app-shell/src/views/useRecordDiscussion.test.tsx -t 'past one reaction batch', expect 7 passed. Gates: node scripts/pm/dispatch-gates.mjs --ran over the 68 derived commands at fb3b009: 66 run with exit 0, 2 NOT MEASURED (exit 3, prerequisite not met: check-plugin-teardown-shape.mjs --self-test needs an unshallowed clone; check:dual-build-cjs-loads needs every package's dist). overlap-check.mjs: clean against origin/main 170f9f8, 0 PR heads. Every other family is CI's.


Generated by Claude Code

…gainst the row budget as one read

Claude-Session: https://claude.ai/code/session_01Utp6Ca2yTZZiHWkyVgD2oK
Co-authored-by: Claude <noreply@anthropic.com>
… client's 100-comment batch; changeset

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

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 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 170f9f829711e77c0be05f42bd52a9d0f45d314c → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

L1: ACCEPT · PR #39342 at head fb3b009e2b.

Head read back through gh api .../pulls/39342 at 2026-12-03T13:57Z; the branch tip is the same sha.

Reads: card #39313 body and its comments (triage 7376938471 and 7377848037, claim 7378573816, os-dev-report 7380601301), the PR body, the net diff against main (4 files: useRecordDiscussion.ts +36/-2, its test +121, record-page-routes.test.ts +49, one changeset), and check-runs at the head at 2026-12-03T13:58Z and again at 2026-12-03T14:06Z. l1-face.mjs --pr 39342 ran at 2026-12-03T13:57Z. It reads ok on shape, first-line, relation, keywords, releases-path, empty-changeset, nul, declarations, skills-docs and dogfood, and flag on changeset (judged below). Floor checks and all-checks were not measured then and are measured below.

Equivalence (read and measured). The door's list plan (planQueryReadWindow, protocol-data-crud.ts listPlan) runs before engine.find. With an explicit limit, it refuses QUERY_ROW_BUDGET_EXCEEDED when offset + limit > rowBudget, and $top 1 never trips MAX_RECORDS_EXCEEDED. The walk read's window is therefore N−1+1 = N, the rows read together. It is refused exactly when N > B: answered at an exact fit (N = B), refused one past (N = B+1). answering.length > 1 means N ≥ 2, so $skip ≥ 1 and the N = 0 and N = 1 cases never send a walk. With no budget, the walk is answered and its row discarded. On the server side, readReactions passes walked = records.length into readWholeStream. Its rule (budgetRefusalOfWalk(walked, first page), then room = B − walked − read, refusing at room ≤ 0 while hasMore) also comes down to refusing when Σ rows > B. So both doors apply the same rule. The refusal depends only on the window, never on the rows, so which batch's where the walk carries does not affect the count. I checked this with a mutant that used the first answering batch instead of the last: 24/24 green, as expected. Paging does not change N. readEveryPage either returns a batch whole or rejects it (#39308's cut), so N is the sum of the batch totals, the same count the payload walks. A page size above B refuses the first page on both doors. Only the pre-existing edges (the DISCUSSION_READ_MAX_PAGES stop, a later non-budget 400) can leave N short. This PR does not touch them.

Ordering. The walk runs after await Promise.all(...), so it runs only once every batch has fulfilled. If any batch rejects, the whole read rejects first and no walk is sent. "Last answering batch" is the highest batch index with more than 0 rows, which is deterministic, and the choice doesn't matter for the count (see above).

Failure mapping. In the catch, feedReadVerdictOf(err) !== 'answered' throws. declined, refused and failed all reject, and the caller (catch { records = null }) shows the comments without reactions. That matches what a batch's own rejection does and what the payload's refused reactions part does (#39287 mapping). A non-budget 400 (or 404) leaves the rows standing, matching readEveryPage's later-page rule. I judge that right: a $top 1 read cannot meet MAX_RECORDS_EXCEEDED, every row was already judged by its own batch read, and the walk is only a consistency check, so standing rows fall back to the pre-fix per-batch answer and hide nothing the reader may not see.

Cost. One extra one-row GET, only when 2 or more batches answered rows, i.e. threads over 100 comments with reactions in more than one batch. A single answering batch sends none; this is pinned by the second test, which expects 0 $top: 1 reads. The client cannot see the budget, so the GET goes out on every deployment, not only budget ones. The PR body's Cost paragraph and the changeset say this correctly. The 维护者速读 bullet 3 ("只影响这类部署") is loose about the request, though not about the behaviour. Non-blocking.

Tests, ablation and positive controls (my runs, in a scratch worktree at fb3b009e). pnpm --dir ui exec vitest run packages/app-shell/src/views/useRecordDiscussion.test.tsx: 24 passed. pnpm --filter @objectstack/rest exec vitest run src/record-page-routes.test.ts: 60 passed.

  • Dev's ablation reproduced. The anchor if (answering.length > 1) { was changed to ... && false) { (blob 6a0a0938 → b8619467, the same ids the report gives). Result: 3 failed | 21 passed, namely the two "rows together past the budget, no batch past it" cases and the walk-window test.
  • $skip: rows.length (one late): 3 red (both exact-fit cases and the window test).
  • $skip: rows.length - 2 (one early): red only on the literal [11, 1] window assertion. The table has no one-past row (N = B+1 with no batch past it, e.g. 6 + 5), so the lower edge is pinned by the window literal and not by behaviour. Non-blocking.
  • Catch swallowing every error: 2 red. Catch arms are not pinned: throw err unconditionally, and throwing only on declined, both stay 24/24 green. So the "non-budget 400 leaves rows standing" and "403/5xx rejects" claims in the TSDoc and PR body have no test. Non-blocking, but worth a pin in a later touch.
  • Server twin table, controls (record-page-routes.ts itself is unchanged, so no ablation is owed). At REACTION_READ_CHUNK_SIZE = 500, the 150-id thread is ONE payload chunk, so the table pins the payload's answers and does not exercise the cross-chunk walked path. Control 1: chunk 100 with walked kept, -t 39313 6/6 green, so the server's cross-chunk rule gives the same answers at the client's batch size. Control 2: chunk 100 with walked forced to 0 (per-chunk semantics), the two "rows together past the budget" cases go red. So the table tells the two rules apart. It is a real twin: the same 6 rows (label, page, budget 10, rows on comment 1 / comment 101, answer) give the same answers on both doors, and the refusal arm asserts code and status (ADR-0112 envelope).

Scope and changeset. The files are inside the claim's file surface. @objectstack/rest files[] = dist, README.md, CHANGELOG.md, and tsup's entry is src/index.ts, so the touched src/record-page-routes.test.ts ships nothing. The face's flag is a package-level over-approximation, and no @objectstack/rest entry is owed. Precedent on main: #39158 (a50269ae, test(rest) only), #39139 (1536c07a) and #39120 (b706ec6e) each touched packages/rest/src/*.test.ts with changesets naming other packages only, and no rest entry. ⛔ No skip-changeset either: the diff publishes an app-shell fix (AGENTS.md Post-Task step 3). Check Changeset is success at the head. The dev adds nothing.

Changeset .changeset/39313-reaction-read-budget-one-walk.md ('@object-ui/app-shell': patch, a private package versioned under privatePackages.version: true, as precedent app-shell changesets are), checked sentence by sentence:

  1. Title "a record discussion's reaction read counts the row budget over the whole thread, as the record page does": true per the equivalence above.
  2. Clause-②: no, Metadata-protocol: none: true (no spec or authorable surface touched).
  3. "the record page payload refuses a discussion's reactions when the thread's reaction rows together are past the budget": true (readReactions walked).
  4. "the list page's comments and the phone comments page read ... in batches of 100 comment ids and let the budget judge each batch alone": true. objectViewCommentsShared.tsx (column and phone page) calls readComments(null), which reads directly through readCommentReactionRows.
  5. "So a thread whose reactions together were past the budget, with no batch past it, showed its reactions on those surfaces and none on the record page": true before this PR (ablation case 6 + 6).
  6. "Those surfaces now read the batches as one read: when more than one batch has reactions, the server is asked its own budget rule of the whole read (one extra one-row read), and rows together past the budget show the comments without reactions, as the record page does; reactions that fit are all shown, as before": true (the code, plus the exact-fit cases 5 + 5 and paged 6 + 4).

Fixes vs Part of. Fixes #39313 stands. The acceptance (both doors give the same answer, pinned, red without the fix) is met. The card's "the reverse also holds" (client declines, payload answers) cannot happen: a batch's rows are at most the thread's total, so a batch past B means the total is past B. Nothing is left undelivered. pm:dispatched comes off with the auto-close.

Gates at fb3b009e (2026-12-03T14:06Z): TypeScript Type Check success, Lint & Repo Gates success. 32 success, 12 skipped, 19 in progress (Test UI 1–9/16, Test Core 1–8/12, Lint UI, Type Check UI), 0 failed. Queue entry still waits for every check to be green. Dogfood battery is not owed (no !, no (narrowing)). The report has no git-answerable API reads.

Out of scope, Observation C (dev's out_of_scope_findings): confirmed by reading computeReactionVisibilityFilter on main. Filed as #39344 (sub-issue of #39077, now claimed and building). Not a blocker for this PR.

Seat at landing (2026-12-03T14:26Z): every check at fb3b009e completed with 0 failed; landing-k K = 3 < 15. Not governed (no spec or governed path, Clause-② no, 214 lines). Landing.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 3, 2026 14:26
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit ac14a74 Dec 3, 2026
66 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-39313-reaction-budget-scope branch December 3, 2026 14:54
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

2 participants