Repository navigation
perf(plugin-audit): count comment thread replies by a stored thread root, and page threads at PostgreSQL microsecond precision - #39169
Conversation
…t; page threads by millisecond Claude-Session: https://claude.ai/code/session_01WGufziM2GUsShZcjp6TiyD Co-authored-by: Claude <noreply@anthropic.com>
… millisecond keyset Claude-Session: https://claude.ai/code/session_01WGufziM2GUsShZcjp6TiyD Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziM2GUsShZcjp6TiyD Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziM2GUsShZcjp6TiyD Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziM2GUsShZcjp6TiyD Co-authored-by: Claude <noreply@anthropic.com>
… root on sqlite and postgres Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziM2GUsShZcjp6TiyD
📓 Docs Drift CheckThis PR changes 2 package(s): 46 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 49 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 07247db0643632cfe6c1e221c2dcd4148d89a3f8 && git checkout 07247db0643632cfe6c1e221c2dcd4148d89a3f8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b98173cea88f0cdc9fbe1a80a6bf1214396c1472 2b906d9bf66c2ebee3c9aa3d0166c6f9edf57e1d && git checkout -B drift-repro b98173cea88f0cdc9fbe1a80a6bf1214396c1472 && git merge --no-ff 2b906d9bf66c2ebee3c9aa3d0166c6f9edf57e1d
node scripts/docs-audit/affected-docs.mjs --json b98173cea88f0cdc9fbe1a80a6bf1214396c1472
|
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufziM2GUsShZcjp6TiyD |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufziM2GUsShZcjp6TiyD Contract review brief — PR #39169 @
|
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufziM2GUsShZcjp6TiyD Contract reviewServed-tier: Inputs read: card #39142 (body, the first-touch comment, the claim with seat rulings (a) and (b), and the dev report); epic #39077 where the card cites it; PR #39169 (body, its 26 files, and the net diff against Check-runs at read time: 58 runs. Success: TypeScript Type Check, Lint & Repo Gates, Lint · ESLint, every Lint and Type Check family, Build Core, Build Docs, Check Changeset, Check PR Size, PR-body guards, Governed Surface Queue Guard, Spec property liveness, Check Documentation Links, Dogfood Regression Gate, Test UI, Live E2E UI, and Test Core shards 4, 7, 9, 10, 11 and 12 of 12. Still in progress: Test Core shards 1, 2, 3, 5, 6 and 8. Skipped: the UI jobs, the opt-in batteries, and Temporal Conformance (live PG + MySQL). No run had failed. This record does not stand in for the six shards still running: their conclusions are the test verdict, and a red shard overrides the PASS below. No job sets ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
The CLI command ( No must-fix. Two should-fix (S1, S2) and five nits. Implemented-by: VERDICT: PASS |
…l stamps the backlog The keeper's reconcile after a user's write corrected every reply of the discussion to the root rule, so the first reply on a discussion with many replies written before the column existed turned into one system update (with its audit and activity rows) per old reply, inside the user's request. It now corrects stamped roots and stamps only the rows the write wrote; the backfill stamps the rest, and the threads read counts unstamped replies by their chain until it has. Docs and the changeset say so, and no longer claim that the next comment stamps a record's replies. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziM2GUsShZcjp6TiyD
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufziM2GUsShZcjp6TiyD |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufziM2GUsShZcjp6TiyD Contract reviewServed-tier: Inputs read: this is the round-2 delta on the round-1 record at head Check-runs at read time: the run on this head had just started. Success: filter, Auto Label, Lint · scoped · tooling self-tests, Governed Surface Queue Guard, Check Documentation Links, PR-body guards, Check PR Size, Spec property liveness. In progress: Build Core, Build Docs, Plan Test Core shards (no Test Core shard had been created yet), every other Lint and Type Check family, Check Changeset, Dogfood Regression Gate, Test UI, Live E2E UI. Skipped: the UI jobs, the opt-in batteries, Temporal Conformance (live PG + MySQL). No run had failed. This record rests on the code read; the runs still open are the gate verdicts, and a red one overrides the PASS below. No job sets ① Derived judgments
② Semver levelUnchanged and right: ③ Boundary flags
④ Design judgmentS1: closed. A reconcile after a write now stamps an unstamped reply only when its id is among the rows that write wrote ( S2: closed. The changeset, N1: closed ( Tried against the fix:
N6 (nit) — three internal comments still describe the round-1 behaviour: the No must-fix, no should-fix. Nits open: N2, N3, N5, N6. Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufziM2GUsShZcjp6TiyD 2026-12-02T20:08Z · Final green head for L1: |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 review: ACCEPT, on head 2b906d9Verdict: ACCEPT. Fixes #39142. Not governed: 0 of 26 paths hit the register. Size is +1404/−245, under the per-PR line. At this head the checks read 44 success, 19 expected skip, 0 failed and 0 pending; the PR is mergeable and clean. The L2 owed, and on recordThe paths decide no face, and the changeset's
The delta covers exactly the one commit between the two heads: What was read
Nits (not blocking)
Generated by Claude Code |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhPdWmTd47Fi2bKYZS 席位核对ACCEPT — PR #39169 @
落地
Serial: #38924 (os-justin) shares |
Requested by Yibo Wang · project thread
Fixes #39142
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
os migrate comment-participants --apply回填后走快路径。唯一的数字变化:恰好第 16 层的回复不再计入,与参与人列表和评论面板的规则一致(座席裁决 a)。What changes
sys_comment.thread_root_id(packages/plugins/plugin-audit/src/objects/sys-comment.object.ts): a read-only, platform-written text column with an index. On a reply it holds the id of the top-level comment itsparent_idchain leads to inside its record's discussion, or the reply's own id when it is in no thread. It isnullon a top-level comment. Anullon a reply means the reply has not been stamped yet, and that set is exactly what the backfill visits. The rule is the existing< 16hop rule the participants keeper already uses: a reply up to 15 levels below its top-level comment belongs to the thread.comment-participants.ts):beforeInsertstamps a reply from its parent, with one system read of the parents by$in. The client's value is replaced.participants(updated_atkept, and only the differing columns written). So a re-point or a delete moves the roots under it. After a write it stamps an unstamped reply only if that write wrote it (stampOnly). A reply on a discussion full of older replies therefore writes one root, not one system update, audit row and activity row per older reply (L2 r1 S1). The backfill stamps the rest.beforeUpdatestrips the column from non-system writers, so it is reported indroppedFields.nulland logs a warning. The reconcile or the backfill fixes it later.threadRootByRowandCOMMENT_THREAD_ROOT_COLUMNare exported.comment-participants-backfill.ts,os migrate comment-participants): the existing command now also stamps roots, and reportsroots. It walks the discussions of top-level comments first, then the discussions that still hold unstamped replies. The second walk reaches a discussion whose top-level comment was deleted. It is idempotent, and a dry run comes first, as before.comment-threads-query.ts,POST /api/v1/comments/threads/query): reply count and the latest three distinct repliers now come from oneengine.aggregateover the page's replies, grouped by(thread_root_id, author_id)withcount(id)andmax(created_at). A second read fetches each candidate replier's newest reply for the display columns. Both run as the caller, so the comment read gate applies as on any read. Before, the read fetched every reply on the page's records and followedparent_idin the server. Without anaggregateon the engine the handler answers 503, as it does withoutplanReadScope.nullare counted by a bounded fallback in the same request (readUnstampedPlaced). It reads the page's unstamped replies paged by id (1,000 a page), then their ancestors level by level, at most 16 rounds, as the caller. The result is placed with the same rule as the stamp. After the backfill this is one read that returns nothing. A count therefore never drops to 0 on a deployment that has not run the backfill. Pinned at engine level before, half-way through and after the backfill (see Acceptance).comment-threads-query.ts): PostgreSQL stores microseconds, but every read hands back milliseconds, so two threads stored microseconds apart could be skipped at a page edge. The cursor now pages by the millisecond bucket, then by id, compared at the millisecond on both sides:created_at < cOR (c ≤ created_at < c+1msANDid < cursorId). When a page's last millisecond may hold more threads, that bucket is read again in the database ordered by id (limit room + 1), so the page and the cursor agree.instantMsparses every spelling a driver hands back. A cursor issued before this release still decodes.content/docs/api/data-api.mdx(reply count and keyset wording),content/docs/deployment/cli.mdx(the backfill now also stamps roots, the depth rule, the slow-path fallback), andcontent/docs/permissions/system-context.mdx(row 45a: the root stamp and the parent read as system).--writeregenerated the bundles).patchon@objectstack/plugin-auditand@objectstack/cli, with both declaration lines.Acceptance notes
where,groupByand aggregations are asserted exactly. A page whose last millisecond may hold more threads adds the one edge re-read (its own unit test).comment-participants.integration.test.tsadds stamping at any depth (forged values replaced), re-point, and a backfill that includes a discussion with no top-level comment.comment-threads-query.integration.test.tsadds an account where a depth-3 thread has count 5 with repliers[ben, ann, dee]and an orphan left out. The same answer is checked for ANN and BEN before the backfill (every rootnull), half-way through, and after. Ablation: disabling the fallback turns this test red. The dogfood file adds the same check on the real engine on SQLite and PostgreSQL (roots nulled through raw SQL, then the backfill).comment-threads-query.tsrestored fromorigin/main(and the package rebuilt), the live-postgres cell fails (expected [ 'MeNl4wlWzztPS4pN' ] to deeply equal [ 'MeNl4wlWzztPS4pN', …(1) ], so one thread is skipped). The SQLite cell passes on both. On this head both pass. Unit tests cover the edge re-read and everyinstantMsspelling.Deviations and notes:
data-api.mdx.OS_TEST_POSTGRES_URL). Local run on PostgreSQL 16 (throwaway server on 127.0.0.1:54391):OS_TEST_POSTGRES_URL=… vitest run test/comment-threads-query.dogfood.test.ts→ 21 passed (21), including 6 live-postgres tests.os migrate meta --from 18says addingviewAllFields: truekeeps a permission set's field reads, but a set with Modify All and its own row hiding a field still loses that field (read and edit) on 19 — the tool should name such entries #38924 (os-justin, widecontent/docs/**claim): whichever lands second merges main.Verification
@objectstack/plugin-audit: 118 files / 1964 tests passed; typecheck (includingcheck:test-typecheck) passes. Changed suites:comment-threads-query.test.ts26,comment-participants.test.ts23,comment-threads-query.integration.test.ts8,comment-participants.integration.test.ts12.@objectstack/cli: typecheck passes; the migrate tests and the two pins that name the command (migrate-confirmation-exit.pin,json-stdout-purity.e2e): 90 files / 764 passed, 8 skipped.Clause-②line, the seat's), N6 (three internal comments still describe r1 stamping).--max-warnings=0over the changed sources passes.check:system-context-census,check-tenant-audit-censusandcheck-i18n-bundlespass.node scripts/pm/dispatch-gates.mjs --ranon 2b906d9: 111 of 111 derived families run, every one exit 0, none not measured. (On 7e8c04a four first answered exit 3 for missing prerequisites and passed after the fetch or build each named.)Human Minimum
packages/specholds no runtime logic. (packages/specuntouched.)pnpm lintpasses (eslint on changed files).main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code