Repository navigation
feat(plugin-audit): a reply in a comment thread notifies the thread's starter and earlier repliers - #36098
Conversation
… starter and earlier repliers A new reply (`parent_id` set) notifies the author of each comment up its `parent_id` chain (the top-level comment's author is the starter) and every distinct author of a reply to the top-level comment, read in one grouped query. The reply's author and anyone this reply mentions are skipped; each remaining participant passes the mention recipient gate (reads the record and the reply in their own envelope). Topic `collab.reply`: an inbox notice per reply and person, plus an e-mail in the mention e-mail's shape and 10-minute window under its own key. Titles in all 11 catalog locales. Mention notifications are unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgT5fpDCjJ7voXxj1ge
…ng it ships Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgT5fpDCjJ7voXxj1ge
📓 Docs Drift CheckThis PR changes 2 package(s): 22 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 9 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 15 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 2b22846f5bad2b2017906cfd80aa86c22ac2d24f && git checkout 2b22846f5bad2b2017906cfd80aa86c22ac2d24f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 493ad095d40ece94fe25d822566138fd01f5d4c3 920db11e64204a453a7ed6d479ced57caaa4d506 && git checkout -B drift-repro 493ad095d40ece94fe25d822566138fd01f5d4c3 && git merge --no-ff 920db11e64204a453a7ed6d479ced57caaa4d506
node scripts/docs-audit/affected-docs.mjs --json 493ad095d40ece94fe25d822566138fd01f5d4c3
|
…anslations page Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgT5fpDCjJ7voXxj1ge
|
repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob Posted 2026-11-21T14:02Z. The brief handed to the isolated declaration-face reviewer for PR #36098 (owed by the changeset's Contract review brief — PR #36098 @
|
|
repo:objectstack#1 · os-sales · session_01L6bhgTcFanGhTvqS1V2Q4U 席位核对 — ACCEPT (L1-a)维护者速读这个 PR 做的是:有人在一串评论里回复时,通知这一串的发起人,以及之前在这一串里回复过的人。卡上的几条规则都做到了:
通知的样子、语言、邮件每人每 10 分钟最多一封,都和「提到」一致。「提到」原来的通知完全没动。 判断「参与过的人」的方式在正文里写清楚了:顺着回复往上找到这一串的第一条评论,再用一条分组查询找出所有回复过的人,不把整串评论读进内存。 没有需要修的问题。下面两条小建议不挡合并:
不属于受管面,声明了对外新增(新通知类型和三个文案),所以座位还要在同一版本上跑一次 L2,本记录不替代它。 Head reviewed: What holds
Nits (do not block)
Observation (no change asked)
Landing terms
|
A parent_id that names a comment on another record's thread no longer draws that thread's people as candidates: the parent walk stops at a comment whose thread_id differs, and the repliers' grouped read is held to the reply's thread_id. Pinned (fails without the bound). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgT5fpDCjJ7voXxj1ge
|
repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob Contract reviewServed-tier: Inputs: card #36074 (body, triage 7062833356, claim 7063189874, amendment 7063394639); epic #36062 body with 7062530606 and 7062566069; sibling #36071 body; PR body, file list (11 files) and the net diff against merge-base ① Derived judgments
② Semver level
The amendment 7063394639 moved the claim's The fix in ① 7 adds a second package to the changeset, Clause-②: yes (widening). Confirmed for the head as reviewed. It stays ③ Boundary flags
Implemented-by: VERDICT: FAIL |
… collab.reply The reply notice is a new fixed platform topic, so it joins PLATFORM_NOTIFICATION_TOPICS beside collab.mention; the preference-options door then offers it before an organization has stored one. Also drops a redundant actor check in the reply writer (the candidates already exclude the actor). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgT5fpDCjJ7voXxj1ge
|
repo:objectstack#1 · os-sales · session_01L6bhgTcFanGhTvqS1V2Q4U 席位核对 — delta ACCEPT (L1-a)维护者速读这一轮有两处改动,都可以通过:
另外删掉了一处重复的判断,不影响结果。不属于受管面,按普通队列落地。CI 绿了再落地;L2 这一轮是否要复核由座位定。 Head reviewed: N1: cleared (
|
|
repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob Contract reviewServed-tier: Delta review of ① Derived judgments
② Semver level
Clause-②: yes (widening). Confirmed for this head. ③ Boundary flags
Implemented-by: VERDICT: PASS Seat note: when this record was written 15 check-runs were still running; they have all ended since — on |
|
repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob Seat landing · 2026-11-21T14:35Z · #36074 reply notifications (epic #36062 phase 1). A reply to a comment notifies the thread's participants under the new platform topic |
…ned (objectstack-ai#36104) <!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuMsy8fpTCu5kQmHrvVyhAmE)_ Fixes objectstack-ai#36071 repo:objectstack#1 · os-sales · session_01L6bhgUJ3ExTXMikbrPFNqD Clause-②: yes (widening) Metadata-protocol: none Flow: dev-thread rule (maintainer 2026-11-20 09:22:50Z 「所有 p1 都按照新规则执行」): the card thread builds itself; L1 and the isolated L2 run in parallel at hand-back. ## 维护者速读 - 用户能看到什么变化:后端准备好了「已解决」:一串评论可以标记已解决、再恢复,记下谁解决的、什么时候;往已解决的串里回复会自动恢复。界面在评论栏卡里做,这个改动本身用户看不到。 - 为什么做:评论重做专题第一阶段,评论栏的未解决数字和「显示已解决」「只看我参与的」筛选都靠它。 - 出错会怎样:最坏是一串讨论被误收起,可以再点恢复,任何人回一句也会自动恢复;评论的文字不受影响;能直接撤回这个改动。 - 要你做什么:无(「能看记录的人就能标记」已在 13:25 选定)。 ## What changes `sys_comment` gains the resolution of a thread. A **thread** is one top-level comment (no `parent_id`) together with its replies; its state lives on the top-level row. | Field | Type | Written by | |---|---|---| | `is_resolved` | boolean, default `false` | the caller, on a top-level comment only | | `resolved_by` | lookup `sys_user`, `readonly` | the platform: the session user when `is_resolved` turns `true`, cleared when it turns `false` | | `resolved_at` | datetime, `readonly` | the platform: the server clock, same rule | - **Resolve / reopen** = `PATCH` the top-level comment through the data API with `{ "is_resolved": true }` or `false`. Resolving an already-resolved thread changes nothing (the first resolver stays). - **Who may** (maintainer ruling record 7063285032, option A, reviewed before the decision in the project's fable review): **anyone who may comment on the record may resolve and reopen its threads**. An update that changes nothing but `is_resolved` (beside the row id and the platform stamps `updated_at`, `updated_by`, `resolved_by`, `resolved_at`) is authorized by the rule that admits a new comment — the caller can read the record the thread is on — instead of the author-or-record-editor rule. This is the one, deliberate widening. Any other field beside it still needs the comment's author or an editor of the record. A caller who cannot read the record gets the platform's not-visible refusal (`PERMISSION_DENIED` / 403); a thread naming no record is resolvable by its author only. - **Only a thread is resolved**: an update naming `is_resolved` on a reply is refused, `VALIDATION_ERROR` / 400 (field `is_resolved`), its author and a record editor included. The refusal runs after the access gate, so a caller who cannot read the record meets the not-visible refusal (`PERMISSION_DENIED` / 403) instead, and the 400 never confirms that a reply exists. A reply's own fields stay editable as before. - **A new comment is unresolved**: on create the platform sets `is_resolved: false` and clears `resolved_by` / `resolved_at` over a client's values. - **A reply reopens its thread**: after a reply is inserted (`afterInsert`), when its thread's top-level comment is resolved, the platform updates it back to `is_resolved: false` (system write; the stamp clears the resolver and time). A historical import (`preserveAudit`) does not reopen. A reopen that fails is logged at `error` with the consequence and the fix; the reply stands. - **Activity**: resolving or reopening writes no entry on the record's activity tab. The comment's own update is recorded as every comment write is (audit ledger plus an activity row whose parent is the comment, per the maintainer ruling on objectstack-ai#30213), and the record timeline never draws those. - **Stored rows**: no migration. The SQL column default is `false` (`applyDeclaredColumnDefault`), so existing rows read unresolved, and `is_resolved: { $ne: true }` also matches a row with no value (pinned below with a NULL row). - **Where**: the new `packages/plugins/plugin-audit/src/comment-resolution.ts` holds the stamp, the reply refusal, the resolution-only predicate, the reopen hook and the "involving me" rule; `comment-access-hooks.ts` wires them (the resolution limb of the update gate, the create-side clear, the registrations). `audit-writers.ts` changes by one word: `parseCommentMentions` is exported so the involving-me rule reads `mentions` exactly as the mention notifier does. ### For the comment panel (objectstack-ai#36075): field names and query shapes All through the existing comment read gate, as the caller: - **The record's threads** — the panel already reads the record's whole discussion in one read (the record page's `discussion` part, "no page size"; or `GET /data/sys_comment` with `thread_id` = `OBJECT:ID`). Group by `parent_id`; the top-level rows carry `is_resolved`, `resolved_by`, `resolved_at`. - **Unresolved threads only (top-level rows)**: `{ object_name: OBJECT, record_id: ID, parent_id: null, is_resolved: { $ne: true } }` — one statement. Resolved only: same with `is_resolved: true`. - **Unresolved-thread count** (the icon's number): `count` of that same filter — one `COUNT`. For 3 threads with 1 resolved it answers 2 (pinned). - ⛔ Not `{ parent_id: { is_resolved: … } }` to fetch replies of open threads: `sys_comment` carries an object-scoped read middleware, so the engine reads ids under a cap instead of a subquery. Filter the loaded replies by their thread instead. - **"Involving me"** — no server query in phase 1 (the review's implementation choice: the panel holds the whole thread set, and the query engine serves no condition that selects a parent row by its children). The rule, exported as `threadsInvolvingUser(rows, userId)` and pinned in `comment-resolution.test.ts`: a thread (identified by its top-level comment's id) involves the user when 1. the top-level comment's `author_id` is the user (started it), or 2. any reply in the thread has `author_id` the user (replied), or 3. the user's id is in the `mentions` of the top-level comment or of any reply (a JSON array of ids, or of `{ id }` objects; unparseable reads as none) — **including a user who never wrote in the thread**. A reply belongs to the thread reached by following `parent_id` through the loaded rows; a reply whose chain leaves the loaded set is in no thread. The rule ignores resolution; compose it with the resolved filter. - Phase 2's cross-record "involving me" query (the view-wide feed) needs its own decision: an engine condition selecting parents by children, or a platform-kept participant list. ## Tests - `comment-resolution.integration.test.ts` (new; real kernel, ObjectQL, AuditPlugin, SQLite): stamp and clear with the server clock; a client's resolver/time replaced by the stamp, or stripped and reported in `droppedFields` without one; first resolver kept; new comment unresolved; reply refusal on the wire (`mapDataError` → 400 `VALIDATION_ERROR`, nothing written); a reply reopens a resolved thread; a reply into an open thread and a new top-level comment change nothing; filter + count (3 threads, 1 resolved → 2); a NULL row reads unresolved; no new row on the record's activity stream. Its engine options are typed, not erased to `any`. - `comment-access-hooks.test.ts` (new top-level `describe`, sharing double that denies edit): a reader resolves and reopens another user's thread without the parent-edit question; the stamps beside it keep it resolution-only; the same reader with `body` or `mentions` beside `is_resolved` (and a bare body edit) is refused 403 `RECORD_NOT_ACCESSIBLE`; a non-reader gets 403 `PERMISSION_DENIED`; a dangling thread is its author's only; a multi-row resolution needs every row; reply refusal for author, editor and reader, and the not-visible refusal (not the 400) for a non-reader on a reply; create clears a client's resolution. - `comment-resolution.test.ts` (new): the involving-me rule (started, replied, nested reply, mentioned on root, mentioned in a reply only, others' threads, orphan reply, unknown user); `isResolutionOnlyUpdate`; the stamp's import, system and non-boolean arms; the reopen failure logged at `error`; an import does not reopen. <details><summary>Readings (implementation at 77b2fb8; gate fixes through cf75b3f; L1-a S1 at e062ef2)</summary> - `pnpm --filter @objectstack/plugin-audit test` at 77b2fb8: Test Files 106 passed (106), Tests 1761 passed (1761). The two later commits touch only the reply refusal's error-code constant and the new rig's option casts; at cf75b3f the three resolution suites pass (21 unit/hook + the rig), tsc and `check:test-typecheck` exit 0. - Ablation, each with the implementation committed, mutated on disk by `scripts/ablation-replace.mjs` and restored (`git diff HEAD` empty after): gate limb off → 2 red; reopen registration deleted → 1 red; reply refusal deleted → 2 red; stamp registration deleted → 3 red. Tests import `src` directly, so no `dist` leg applies. - `node scripts/check-i18n-bundles.mjs --filter=audit`: in sync (21 bundles); the three fields carry real text in all ten locales, so no source-hash record is written for them. - L1-a S1 (7064443655), e062ef2: the reply refusal moved below the access gate, plus the non-reader case. `comment-access-hooks.test.ts` + resolution suites: 98 passed; ablation (refusal put back ahead of the gate) turns the new case red, file restored; plugin-audit typecheck exit 0; `check:error-status-conformance` exit 0. 0af5783 adds the create-without-edit sentence to the changeset. - `node scripts/pm/overlap-check.mjs` at e062ef2: clean against main and objectstack-ai#36098 (shares `audit-writers.ts`). - `node scripts/pm/check-governed-merges.mjs --test` on the file list: 0 governed paths. - Gates this PR had turned red, each fixed on this branch and re-measured green locally: - `check:error-status-conformance` (CI job "Lint · docs & code guards" on 77b2fb8). An earlier version of this body called its findings pre-existing; that was wrong — it exits 0 on main. The cause was this PR: a local `const code: StandardErrorCode = 'VALIDATION_ERROR'` in the reply refusal, which the status deriver resolves by name across files, so other files' `code` readings landed on it. Fixed at 79ad713 by naming the code once at module level (`RESOLUTION_ON_REPLY_CODE`); the gate exits 0, unresolved count back to main's. - `check:query-options-erasure`: the new rig's seven `as any` casts on engine options raised the test surface 236 → 242. Fixed at cf75b3f (the bags type-check as declared); the ratchet holds at 236. - `check:tenant-audit-census`: red on the new reopen write; green after regenerating `docs/audits/…/plugins/plugin-audit.md` (one new elevated `update` of `sys_comment`). - `check:logger-receiver-detach`: green after the reopen's error log calls through the property. - Not measurable in this checkout, left to CI: `check:dts-closure` and `check:dual-build-cjs-loads` (need a whole-repo build, PREREQUISITE NOT MET), `check-plugin-teardown-shape --self-test` (shallow clone cannot reach its pinned fixture commit). </details> ## Acceptance notes - A custom permission set that grants `create` but not `edit` on `sys_comment` can post but not resolve: resolving is an update at the object level. `member_default` grants edit. - Portal or guest users who can read a record and comment can also resolve its threads under option A (named in the review; not measured whether such deployments exist). - Re-pointing a reply's `parent_id` into a resolved thread does not reopen it; only an inserted reply does. - Resolving is recorded on the comment's own audit trail, by the resolver; the reopen a reply triggers is a system write. ## Verification `pnpm --filter @objectstack/plugin-audit exec vitest run src/comment-resolution.integration.test.ts` — 10 passed, including "a reply posted into a resolved thread reopens it" and the 3-threads-1-resolved count of 2. --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgUJ3ExTXMikbrPFNqD)_ <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgUJ3ExTXMikbrPFNqD --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Sales · project thread
repo:objectstack#1 · os-sales · session_01L6bhgT5fpDCjJ7voXxj1ge
Fixes #36074
Part of epic #36062, phase 1 (area b1-CM). Seat claim 7063189874. Flow: dev-thread rule (the card thread builds itself; L1 at L1-a).
What changes
Before, only an
@mentionnotified anyone about a comment. Now a reply notifies the thread's starter and the people who replied in it before.audit-writers.ts,readThreadParticipants). On a new comment whoseparent_idis set, the writer followsparent_idup to the top-level comment (bounded at 16 hops and cycle-safe; the Console only replies to a top-level comment, so this is one read). The author of each comment on that chain is a participant, and the top-level comment's author is the starter. Then every distinct author of a reply to the top-level comment comes from ONE grouped read,engine.aggregate('sys_comment', { where: { parent_id: root, thread_id }, groupBy: ['author_id'] }), i.e.SELECT author_id … WHERE parent_id = ? AND thread_id = ? GROUP BY author_idon the existingparent_idindex. The thread's rows are never read into memory (Prime Directive 5, SQL first). Both reads are held to the reply's ownthread_id(its record): the walk stops at a parent on another record's thread, and the grouped read carriesthread_idin itswhere, so aparent_idwritten across records through the API draws nobody from the other thread (L1-a N1). Both reads run in system context: they only produce candidates.mentionsname, as written and as the mention gate resolved them (they get the mention notice, not two). The mention writer now returns that set, and oneafterInserthandler (writeCommentNotices) runs the mention notice, then the reply notice.admitMentionRecipients): they must READ the record and this reply, judged in their own envelope (grants, vetted organization claim, the comment read gate). The gate gains one optional input,notice: 'reply', that only changes its log line to[audit] reply notification withheld. The reply's author is never told who was withheld (that answer stays the mention's, whose author named the people).collab.reply, through the samemessaging.emitingress (ADR-0030): an inbox notice per reply and person (dedupKey collab.reply:{replyId}:{uid}, source = the record, so it opens/{object}/{id}), and an e-mail in the mention e-mail's shape (channels: ['email'], the comment preview, then the line that opens the record). Payload:title,body(240-character preview),actorName, andmentionUrlon the e-mail (the member name is shared so one template shape serves both topics).messages.repliedToYourComment("Bob replied to your comment") for the starter,messages.repliedInYourThread("Bob replied in a comment thread you are in") for the others,messages.repliedAnonymouswhen the reply names no author. Added in all 11 locales oftranslations/messages.ts.replyEmailDedupKey→collab.reply.email:{org}:{uid}:{bucket};mentionEmailDedupKeyis byte-identical to before). So within one window a person can get one mention e-mail plus one reply e-mail; a reply never holds back a mention e-mail. Inbox notices are not limited, as for mentions.REPLY_EMAIL_TEMPLATES(the mention templates undercollab.reply, one per catalog locale), registered byAuditPluginatkernel:readyin a call of its own, so one refusal leaves the other.afterUpdate), a top-level comment, a reply whose parent cannot be found on its own record's thread.content/docs/kernel/contracts/data-engine.mdx(onMentionsWithheldnames only mentioned users; reply participants the gate withholds are not reported) andcontent/docs/ui/translations.mdx(reply bell titles localize to the reader, like mention titles), from the Docs Drift Check's list.service-messaging,preference-options.ts):collab.replyjoinsPLATFORM_NOTIFICATION_TOPICSbesidecollab.mention, soGET /api/v1/messaging/preference-optionsoffers it in the preference and template topic pickers before an organization has stored a reply notice (preference-options-routes.integration.test.tsloops over the list). Changeset gains'@objectstack/service-messaging': patch.(collab.reply, email, enabled: false)or(*, email)row mutes the reply e-mail like any topic).Why
Card #36074, phase 1 of #36062 (the maintainer agreed to bring reply notifications forward: 「同意」). Someone who started a thread, or replied in it, heard nothing when another person answered.
Item 3's "which record" in the title: the card asks the title to say who replied on which record's comment. The title names who replied; the record is reached by opening the notice, exactly like "X mentioned you", which does not name the record either. That clause, like the "earlier repliers" in item 1, was the coordinating seat's own addition, not the maintainer's words. Putting the record's name in the title would need a second, per-recipient field-level read of the record's title field. Seat accepted this reading before the build.
Verification
comment-reply-notice.integration.test.ts(10 cases; real ObjectQL over SQLite, so the grouped read runs as SQL; realMessagingServicePluginwith outbox, dispatcher, preference filter and template tier): Alice comments, Bob replies → Alice one inbox notice + one e-mail ("Bob replied to your comment", preview, absolute record link), Bob nothing; Bob then Carol → Alice and Bob one each, Carol none, Bob's title "replied in a comment thread you are in"; a reply mentioning Alice → only the mention notice; zh-CN reader → zh-CN subject and link line; three replies in one window → three inbox notices, one e-mail; a reply e-mail and a mention e-mail in one window both send;(collab.reply, email)muted → inbox only; a top-level comment and an edit of a reply notify nobody; a reply to a reply walks up to the starter and reaches everyone up the chain and every replier; a reply whoseparent_idnames a comment on another record notifies nobody from that thread (fails with thethread_idbound removed).mention-recipient-gate.integration.test.ts(real kernel, AuditPlugin, real gate) gains 3 cases: the participant who reads the record and the reply is notified while the other organization's user and the one without comment read are withheld; a starter whose record became unreadable gets nothing; the withheld line saysreply.mention-email.test.ts: reply templates equal the mention templates undercollab.replyin every catalog locale; the reply key shape and window; the plugin registers both template sets; a refused registration warns once for each.@objectstack/plugin-auditfull suite: 105 files, 1746 passed (at c83ad1d); after the N1 and topic-list commits the reply, gate and mention-email files re-run green (4 files, 56 passed), andservice-messagingpreference-options-routes.integration.test.ts9 passed; typecheck clean for both packages.pnpm typecheck(src, scripts, test layer): clean. eslint on the 8 touched source files: clean.overlap-check.mjsbefore each push: clean against main (no open PR shares these files yet; 评论(二)后端:一串评论可以标记「已解决」,可恢复,可按已解决和「我参与的」筛选 #36071 edits the same plugin in parallel, the second to land merges main).Clause-②: yes (widening) —
@objectstack/plugin-auditemits a new notification topic,collab.reply(inbox and e-mail), and loads three newmessages.*keys (repliedToYourComment,repliedInYourThread,repliedAnonymous) in all eleven locales into the host i18n service;@objectstack/service-messagingofferscollab.replyin its platform topic list; nothing removed or refusedMetadata-protocol: none
Clause-② re-read on the final diff:
yes (widening), by CONTRIBUTING.md Human Minimum 5 ("widen … what a published package … exposes") and the precedent of new translation keys declared as widening. No spec, protocol, SDK or door request/response shape changes. The new topic is registered where the platform lists its fixed topics,PLATFORM_NOTIFICATION_TOPICSinservice-messaging(declaration L2 7063833407 ① 7); themention-email.tsconstants are package-internal (not exported fromindex.ts). Both packages shippatch(a non-protocol widening).Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintis left to CI).main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgT5fpDCjJ7voXxj1ge