Repository navigation
Commit d12ac84
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuQDMVvYbduXkDz6CEaA8Q1G)_
repo:objectstack#1 · os-sales · session_01L6bhgUH1jEKbDzYRc4nghq
Fixes #36186
Fixes #36191
Clause-②: yes (widening) — `@objectstack/plugin-audit`'s `AuditPlugin`
mounts two new HTTP routes, `PUT /api/v1/comments/:id/resolution` and
`DELETE /api/v1/comments/:id`, and the resolution stamp reads a system
write's `provenance.attributedUserId`. `@objectstack/core`'s
`OwnRowDeleteDoor` adds the optional `refuseRemoval(row, engine,
context)` (step 7, after the owner check). `@object-ui/react`'s
`DiscussionContextValue` adds the optional `ownCommentDeletesOnly`;
`@object-ui/plugin-detail`'s `RecordCommentsData` adds the optional
`ownDeletesOnly`, which `RecordCommentThreadProps['comments']` may
carry; `@object-ui/core`'s affordance-to-grant map adds the row
`feedCommentDeleteOwn`. Nothing existing is removed or re-typed.
Metadata-protocol: none
## 维护者速读
-
普通成员现在能给**任何**自己看得到、也能在上面发评论的评论串点对勾(标成已解决),也能恢复。以前只能点自己发起的串,别人发起的只有管理员能点。点了以后「已由
某某 解决」写的是点的人。这就是你 13:25Z 的裁定 A(能看记录就能解决,门槛和发评论一样)真正生效。
- 普通成员现在能**删自己的评论**。以前成员的「更多」里只有编辑。删别人的评论还是不行,能编辑记录也不行;管理员照旧。
-
**自己的评论下面已经有回复(不管是谁回的,自己回的也算),就不能删**(可以改文字)。原因:平台删一条顶层评论时会把下面的回复各自变成独立的串,等于改动了别人的评论,这不符合你
21:59Z 的裁定(别人的评论删不了)。座位核过,认为这是裁定本身的结论,不再单独问你。管理员有删除权限,删法和以前一样。
-
评论的文字照旧只有作者能改。平台的底线规则、删除权限一行没动:两个新的服务端入口各只做一件事(一个只改「已解决」,一个只删自己的那一行)。走原来的数据接口,成员改别人评论、改别人的「已解决」、删任何评论,仍然是
403。
- 只能看评论、不能发评论的人(比如只给了只读权限的外部成员),**点不了对勾**,控制台也不显示对勾。审核指出裁定 A
里同时写了「能看记录的人」和「和发评论同一道门槛」,座位定了按后者,较窄。普通成员都能发评论,所以对他们没有区别;能发评论的外部成员照样能点。
-
已知限制:删评论时「下面有没有回复」的检查和真正删除是两步。如果恰好在这一瞬间有人发了回复,这条回复会变成独立的串,和今天管理员用数据接口删评论时一样。平台的数据引擎没有「条件删除」可以把两步并成一步,套一层事务在默认隔离级别下也挡不住别的请求插进来的回复,所以先写明,不在这次改。
## What changes
**The resolution door** (`plugin-audit` `comment-routes.ts`, #36186)
- `PUT /api/v1/comments/:id/resolution`, body exactly `{ "resolved":
boolean }`. Order: caller (the own-row doors' one composition,
`ownRowDeleteCallerResolver`), anonymous `401`, held sign-in `403`, any
query parameter or other body `400 VALIDATION_ERROR`, the comment read
AS THE CALLER (object grant + organization wall + the comment read gate;
unreadable and unknown both `404 RECORD_NOT_FOUND`), the posting gate
(the security service's `canWriteObject('sys_comment', 'insert',
caller)`: a caller who reads comments but may not post one is `403
PERMISSION_DENIED`, a check that throws refuses, and a deployment with
no security service has no posting gate either; ruling 7063285032 names
"the same gate as posting a comment", contract review F1), a reply `400`
(`refuseResolutionOnReply`, the data door's sentence), then a system
write of `{ is_resolved }` alone by id, `attributedUserId` = caller, the
caller's organization kept. Answers `200 { id, is_resolved, resolved_by,
resolved_at }` read back as stored.
- `stampCommentResolution` (`comment-resolution.ts`): on a system write
the resolver is `provenance.attributedUserId` (the audit writer's own
read of the attribution), so `resolved_by` names the door's caller. A
non-system write still stamps its session user; a system write with no
attribution still stamps `null`.
- Untouched: `owner_only_writes`, `sys_comment_moderation`,
`member_default`, the data door's resolve limb (#36104). No
`sys_comment` update twin: a row policy cannot scope a column, so one
would also admit a member's edit of a colleague's words, which ruling
7069889899 keeps author-only.
**The own-comment delete door** (same file, #36191)
- `DELETE /api/v1/comments/:id` on `@objectstack/core`'s shared own-row
delete door; owner column `author_id`. Another member's comment `403
PERMISSION_DENIED`, even for a record editor (the moderator's delete
stays the data door's, behind the delete grant).
- Step 7, new in the kit: `OwnRowDeleteDoor.refuseRemoval`, asked after
the owner check. The comment door's refuses a comment with any reply
under it (a system read of `parent_id = id`), `409 DELETE_RESTRICTED`:
`parent_id` is a lookup that clears on delete, so the removal would turn
each reply into a thread of its own, a rewrite of other members' rows.
The other three doors on the kit declare none and are unchanged. Known
limit (contract review F2): the reply check and the removal are two
engine calls and the data engine offers no conditional delete to join
them (wrapping both in a transaction would not close it either: at the
stores' default isolation another request's reply insert still lands
between the probe and the delete), so a reply posted within that one
request is promoted to a thread of its own, the same result as an
administrator's data-door delete today; stated in the module doc.
- Both doors mount beside the unreact door (`mountCommentDoors`, renamed
from `mountUnreactDoor`); one `warn` names all three routes when no HTTP
server is registered. Ledger rows in `comment-route-ledger.ts` (`gap`:
the console is the consumer, the SDK has no method), with their
conformance test; `scripts/check-route-envelope.mjs` declares the
module.
**Console** (`RecordDetailView`, `plugin-detail`, `react`, `core`)
- ✓ calls the resolution door and is offered on every thread, the
viewer's and anyone else's, under the `sys_comment` create grant (the
door's posting gate), wherever the rows store resolution; it no longer
depends on `updatesOthersComments`. The explain probe of a foreign
`sys_comment` update stays, and gates Edit on someone else's comment
alone.
- Delete: with the `sys_comment` delete grant, the data door as before
(others' comments included where the viewer moderates). Without it, the
new affordance row `feedCommentDeleteOwn` (`grant: 'create'`, as
`feedReactionRemove`) hands Delete over, it calls the own-comment door,
and the host sets `ownCommentDeletesOnly`: `CommentThread` and the
legacy `CommentBody` then offer Delete on the viewer's own comments with
no reply and on nobody else's, whatever `moderatesComments` says. So the
panel offers exactly what the doors admit.
- `handleResolveComment`'s jsdoc says what the write is now (L2 S-D1 on
#36178). `affordanceGrantMap-12082`: `handleResolveComment` is no longer
a data-source write site (its row is gone); `feedCommentDeleteOwn` is in
the grant table.
**Prose**: `plugin-detail.mdx` (Delete wording; ✓ on every thread; the
own-comment door). The two unreleased notes of #36104
(`36071-comment-threads-resolved.md`) and #36178
(`36075-comments-resolved.md`) stay as written; the new changeset
`36186-36191-comment-doors.md` ends with one sentence for each, naming
the line it replaces.
## Why
Ruling 7063285032 (any reader may resolve) never reached a rank-and-file
member: the row floor runs before the comment hook (L1-c HOLD
7068026256, readings in #36178). Ruling 7069889899 kept comment text
author-only, which rules out loosening the floor for `update`, and added
the own-comment delete (`member_default` may carry no delete bit,
ADR-0090 D5). Shape agreed in the premise read and the seat's claims
7069978538 / 7069989751.
## Verification
- `plugin-security` `comment-doors.integration.test.ts` (16 cases, real
kernel + `SecurityPlugin` with the shipped sets + `AuditPlugin` + the
real caller resolution, SQLite, two plain `org_member` principals, an
`org_admin` and two `org_external` principals with explicit grants):
member resolves and reopens a colleague's thread (200, `resolved_by` =
member, cleared on reopen); data door unchanged (member's `body`,
`is_resolved`, `{ is_resolved, body }` on a colleague's comment all
403); reply 400; unreadable = unknown 404; anonymous 401, query and
every malformed body 400; own delete 200; colleague's 403 and stays; own
comment with a reply 409, root and reply unchanged; own reply 200; own
comment on an unreadable record 404; an external who reads the thread
but may not post is 403 on resolve and still reads the comment, an
external who may post resolves (200); member's data-door delete of their
own still 403; admin resolves through the data door (floor does not
bind) and the comment rule still decides edits.
- `plugin-audit`: `comment-routes.test.ts` (mount, pre-engine answers,
the write's exact shape and context; +4 for the posting gate: refused
403 with no write, a throwing check refuses, an unreadable comment still
404 before the gate, a poster resolves), `comment-resolution.test.ts`
(+2: attribution stamps a system write; never outranks a session user),
`comment-route-ledger.conformance.test.ts`; unreact ledger unchanged.
`core`: `own-row-delete-routes.test.ts` (+3: step 7 refuses before any
removal, runs only after the owner check, resolving admits).
- UI: `RecordDetailView.commentsResolved-36075` also pins no ✓ for a
viewer without the `sys_comment` create grant.
`CommentsPanel.resolved-36075` (✓ on others' threads without the floor
verdict; own-door Delete matrix),
`RecordDetailView.commentsResolved-36075` (✓ → door URL and body, no
data-source update; refused ✓; member without delete grant deletes
through the door, none on others', none on own-with-reply; refused door
delete), `RecordDetailView.feedCommentEditDelete-12268` (the
no-delete-grant pin now asserts the door, plus own-with-reply). Local:
app-shell comment/feed/discussion/reaction/explain RecordDetailView
files + all of `plugin-detail` + `react` context: 437 files, 4067
passed.
- Typecheck: `plugin-audit`, `core`, `plugin-security` clean.
`check-route-envelope`, `check-single-authz-resolver` green.
`check-governed-merges --test` on the file list: not governed.
- Rig readings, CRM dev server (`objectstack dev --fresh`). Before: the
#36178 hold readings at `a2dc85896` (reader and a record editor, both
plain org members). After: this branch at `dd9f5571`; a fresh rig is
`invite_only` now, so the admin creates both members through `POST
/api/v1/auth/admin/create-user`, the reader with `viewer_readonly` and
the record editor with `crm_sales_user`.
| Reading | Before | After |
|---|---|---|
| Member resolves the admin's thread | data API `403 PERMISSION_DENIED`
| door `200`, `resolved_by` = the member |
| Member resolves a colleague's thread / reopens it | data API `403` |
door `200` / `200`, `resolved_by` and `resolved_at` cleared |
| Member resolves a reply | n/a | door `400 VALIDATION_ERROR` |
| Member's data-API `is_resolved` on the admin's thread | `403` | `403`
(unchanged) |
| Record editor edits a member's comment (data API) | `403` | `403`
(unchanged) |
| Member edits the admin's comment | `403` | `403` (unchanged) |
| Member deletes own comment, data API | `403` | `403` (unchanged) |
| Member deletes own comment, door | n/a | `200 { deleted: true }` |
| Member deletes a colleague's comment, door | n/a | `403
PERMISSION_DENIED` |
| Member deletes own comment with a reply, door | n/a | `409
DELETE_RESTRICTED`, root and reply kept |
| Colleague deletes that reply, door; member then deletes the root | n/a
| `200`, then `200` |
| Admin edits / resolves / deletes a member's comment (data API) | `200`
| `200` / `200` / `200` (unchanged) |
Rows left on the record afterwards: the admin's thread (resolved by the
member), the record editor's thread (reopened); nothing else. Script and
report: `build-seat1/36186-36191/rig/doors.cjs`, `doors-report.json` in
the project files.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No `packages/spec` change.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the touched
files: 0 errors.)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request. (Two folded cards, one `Fixes` line each.)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. (The 维护者速读 section is
the maintainer's Chinese summary, as on this seat's other PRs.)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
## Follow-ups
- None filed. A "comment deleted" placeholder that would let an author
remove a comment that has replies is a product question of its own
(needs a stored marker), not in scope. Contract review F3 (the console
asks the create grant for own-comment Delete while the door asks none)
is left as is, consistent with `feedReactionRemove`.
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgUH1jEKbDzYRc4nghq
<!-- signed: repo:objectstack#1 · os-sales ·
session_01L6bhgUH1jEKbDzYRc4nghq -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5e8e243 commit d12ac84
25 files changed
Lines changed: 1733 additions & 122 deletions
File tree
- .changeset
- content/docs/frontend/plugins
- docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins
- packages
- core/src/security
- plugins
- plugin-audit/src
- plugin-security/src
- scripts
- ui/packages
- app-shell/src/views
- core/src/utils
- plugin-detail/src
- comments
- plugin-form/src
- react/src/context
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | | - | |
219 | | - | |
220 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | 227 | | |
223 | 228 | | |
| |||
392 | 397 | | |
393 | 398 | | |
394 | 399 | | |
395 | | - | |
396 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
397 | 407 | | |
398 | 408 | | |
399 | 409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
65 | | - | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
| |||
197 | 209 | | |
198 | 210 | | |
199 | 211 | | |
200 | | - | |
| 212 | + | |
201 | 213 | | |
202 | | - | |
203 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
204 | 217 | | |
205 | 218 | | |
206 | 219 | | |
| |||
221 | 234 | | |
222 | 235 | | |
223 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
224 | 240 | | |
225 | 241 | | |
226 | 242 | | |
| |||
292 | 308 | | |
293 | 309 | | |
294 | 310 | | |
295 | | - | |
| 311 | + | |
296 | 312 | | |
297 | 313 | | |
298 | 314 | | |
| |||
0 commit comments