You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1a298dd
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-audit): a member removes their own comment reaction through an own-row unreact door (#26345)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XQxK8SxQ94Ud3phjAvzrrEE)_Fixes#26161
This is the server half of ruling 6422861164 (letter A). The console
half (the reaction chip calls the new route, and `feedReactionRemove`
stops reading a `delete` grant) is a separate `domain:ui` card that the
seat files with `Blocked-by: #26161`.
Clause-②: yes (widening)
Metadata-protocol: none
## What changed
`AuditPlugin` mounts an own-row unreact door on the kernel's HTTP
server:
| | |
|---|---|
| Method and path | `DELETE /api/v1/comments/reactions/:id` (`:id` is
the `sys_comment_reaction` row id) |
| Body | none read; any query parameter is refused |
| `200` | `{ success: true, data: { id, deleted: true } }` |
| `400 VALIDATION_ERROR` | a query parameter, or an empty id |
| `401 UNAUTHENTICATED` | the request names nobody |
| `403` held-sign-in code | an expired password or MFA not yet enrolled
(the auth policy's own code) |
| `403 PERMISSION_DENIED` | the row is another member's reaction; it
stays |
| `404 RECORD_NOT_FOUND` | no such row, or a row the caller cannot read
(same answer, so nothing leaks) |
| `503 SERVICE_UNAVAILABLE` | the permission store cannot be read, or no
data engine is registered |
How it decides, in order:
1. The caller is resolved by the platform's one request-to-context
composition, `resolveRequestExecutionContext`, with the settings door's
choices: fail-closed for anonymous, the sign-in gate resolved onto the
context, API key and session both admitted, nothing localized, no bearer
carried.
2. Anonymous, held sign-in and query-parameter refusals come next.
3. The row is read **as the caller**, so the object grant, the
organization wall and the reaction read gate (a reaction is readable
exactly when its comment is) all decide. A row the caller cannot read
answers the same `404 RECORD_NOT_FOUND` as an unknown id. That is the
answer the data door gives both.
4. The row's `created_by` must be the caller. This is the column the
platform's own-record floor (`owner_only_deletes`) reads, stamped by the
engine with the reactor. Otherwise the door answers `403
PERMISSION_DENIED`.
5. Only then is the row removed by id, under a system context with
`attributedUserId` set to the caller and the caller's `tenantId`. Step 4
is the only way in to that elevated write. If the driver reports that
nothing matched (a race), the door answers `404`.
What does not move: no permission set gains `delete`, `member_default`
(`default-permission-sets.ts`) is untouched, and
`security-anchor-high-privilege` (ADR-0090 D5) is untouched. The generic
`DELETE /api/v1/data/sys_comment_reaction/:id` answers exactly what it
did before.
Files:
- `packages/plugins/plugin-audit/src/comment-reaction-routes.ts`: the
door, `removeOwnCommentReaction`, and `platformCallerResolver`.
- `packages/plugins/plugin-audit/src/audit-plugin.ts`: `start()` mounts
the door on `http.server` (falling back to the `http-server` alias).
With no HTTP server it warns once and mounts nothing.
- `packages/plugins/plugin-audit/src/comment-reaction-route-ledger.ts`
plus its `.conformance.test.ts`: the package-local route ledger, using
the print-door model. The row is a `gap` because `@objectstack/client`
has no method yet.
-
`packages/plugins/plugin-audit/src/objects/sys-comment-reaction.object.ts`:
the header's Delete section now names the door.
- `scripts/check-single-authz-resolver.mjs`: lists the door as a
delegator of `resolveRequestExecutionContext`, so a later re-inline of
the resolver goes red.
- `content/docs/permissions/tenant-audit-census.mdx` and
`docs/audits/2026-08-tenant-audit-write-call-sites.counts.md`: the
census regenerated for the door's one system-context write (243→244
sites).
- `scripts/check-route-envelope.mjs`: declares the new `*-routes.ts`
module with `{ responses: 0, ok: 0, err: 0 }`. Every body goes through
the shared `sendOk` / `sendError` / `sendServerFault`.
- `.changeset/26161-own-row-unreact-door.md`: `patch` on
`@objectstack/plugin-audit`.
## Tests
-
`packages/plugins/plugin-security/src/comment-reaction-unreact-door.integration.test.ts`
runs on the real kernel, the real `SecurityPlugin` with the shipped
sets, and the real `AuditPlugin` (object, read gate and mounted door).
Caller resolution is real too: the platform resolver runs over seeded
`sys_user` / `sys_member` rows and an auth service whose session read
names the user. The member is a plain organization member with no
position. Their baseline is `member_default` composed with an app
every-member set that grants read and create (never delete) on comments
and reactions. Cases:
- own row: `200`, and the row is gone on read-back;
- foreign row: `403 PERMISSION_DENIED`, and the row stays;
- a reaction on a comment the caller cannot read: `404
RECORD_NOT_FOUND`, the same status and code as an unknown id, and the
row stays;
- unknown id: `404 RECORD_NOT_FOUND`;
- anonymous: `401`; a query parameter: `400`. In both cases the row
stays;
- the generic data-door delete of the member's own row still answers
`403 PERMISSION_DENIED`, via the engine delete under the caller plus
`mapDataError`, the data door's own path. The row stays.
The test lives in plugin-security because plugin-security already has a
devDependency on plugin-audit. The reverse edge would be a workspace
cycle.
- `packages/plugins/plugin-audit/src/comment-reaction-routes.test.ts`:
the door's shell before the engine is asked (permission store outage
`503`, nobody `401`, held sign-in `403`, no engine `503`, engine fault
`500 INTERNAL_ERROR`), plus the `AuditPlugin` mount with and without an
HTTP server.
-
`packages/plugins/plugin-audit/src/comment-reaction-route-ledger.conformance.test.ts`:
checks ledger and registrar in both directions.
Red first, on base `c4968860` with the door not mounted: 6 of 8
integration cases red, each with "no DELETE
/api/v1/comments/reactions/:id is mounted". The fixture case and the
generic-delete `403` case were green, which is the defect itself.
Ablation of the reactor check, on `0f28b47607` (`if (row.created_by !==
callerId) throw …` deleted through `scripts/ablation-replace.mjs`):
plugin-audit was rebuilt and `ablation-dist-preflight.mjs --absent`
reported the marker absent from all 6 dist files. Then 1 failed and 7
passed, and the failure was the foreign-row case alone. Restore: HEAD
blob hash matched, the rebuild had the marker present in `dist/index.js`
and `dist/index.mjs`, the tree was clean, and the run was 8 of 8.
Package runs on `0f28b47607`: `pnpm --filter @objectstack/plugin-audit
test` passed 64 files and 1023 tests. `pnpm --filter
@objectstack/plugin-security test` passed 229 files, with 4942 passing
and 45 skipped. The `--project repo` suites of core, objectql, rest,
runtime, spec and types all passed. `typecheck` exited 0 for both.
eslint `--no-inline-config` on both packages exited 0.
Gates on `0f28b47607`: all 122 commands `dispatch-gates.mjs --commands`
derives for this diff exited 0, and `--ran` reconciled 122 derived, 122
run, 0 NOT-MEASURED, 0 UNRUN.
## Acceptance notes
- The route is a `gap` on the SDK: `@objectstack/client` has no method
for it. The console reaches the server through `ObjectStackClient`
(`ui/packages/data-objectstack`), so the console half will want a client
method or a direct call. That half is the seat's `domain:ui` card.
- The dogfood live-mount parity gate
(`route-ledger-live-mount-parity.dogfood.test.ts`) boots the showcase
without `AuditPlugin`, so this ledger is not in its union, and this
route is neither probed nor flagged there. The package-local conformance
test is this route's guard. Adding `AuditPlugin` to that boot is outside
this card.
- An impersonation session may use the door, as it may use the generic
data door to add a reaction. The removal is attributed to the session's
user.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01TZQBvhyKHoq1oKrgnVx35Y)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(plugin-audit): a member removes their own comment reaction through an own-row unreact door, with no object delete grant
6
+
7
+
A member whose grants are the every-member ones could add a comment reaction and never take it back. The console removes a reaction through the generic data door's `DELETE /api/v1/data/sys_comment_reaction/:id`, which needs an object-level `delete` grant, and no every-member set may carry one: ADR-0090 D5 keeps `delete` off the `everyone` anchor (`security-anchor-high-privilege`), and `member_default` carries none. Measured as a plain member: add a reaction → `201`, delete it → `403`.
8
+
9
+
Clause-②: yes (widening)
10
+
Metadata-protocol: none
11
+
12
+
`AuditPlugin` now mounts `DELETE /api/v1/comments/reactions/:id` on the kernel's HTTP server. It removes the caller's own `sys_comment_reaction` row and nothing else:
13
+
14
+
- The row is read as the caller, so every read gate decides. A reaction on a comment the caller cannot read answers `404 RECORD_NOT_FOUND`, the same answer as an id that names no row, so the door says nothing about a reaction the caller cannot see.
15
+
- The row's reactor (`created_by`, the column the platform's own-record floor reads) must be the caller. Anyone else's reaction is refused with `403 PERMISSION_DENIED` and stays.
16
+
- Only then is the row removed, under a system context attributed to the caller and kept in the caller's organization. Success answers `200` with `{ success: true, data: { id, deleted: true } }`.
17
+
- Before any of that the door answers what every door answers: `401 UNAUTHENTICATED` for a request that names nobody, a held sign-in's own `403`, the permission store's `503` when it cannot be read, and `400 VALIDATION_ERROR` for any query parameter.
18
+
19
+
The grant model does not move. The generic data-door delete answers exactly what it answered before (`403` for a member with no delete grant), no permission set gains `delete`, and `member_default` and the `security-anchor-high-privilege` rule are unchanged. The console's reaction chip moves to the new route in a separate change; until then the route is reachable but nothing in the console calls it.
Copy file name to clipboardExpand all lines: content/docs/permissions/tenant-audit-census.mdx
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -132,7 +132,7 @@ are reported as `undecidable` rather than assumed either way.
132
132
133
133
The same holds twice over for the context. An options argument spelled as a
134
134
literal can be read; one spelled `options`, `{ ...opts }`, or handed through a
135
-
forwarding shim cannot, and **51 of the 243 sites are spelled that way**. A
135
+
forwarding shim cannot, and **51 of the 244 sites are spelled that way**. A
136
136
context resolved from an inline literal or a local `const` can be tested for
137
137
`isSystem`; one arriving from a helper call cannot.
138
138
@@ -197,10 +197,10 @@ reproduce them. Where it disagrees, it disagrees on the page:
197
197
198
198
| carried figure | where it survives | this census |
199
199
| :--- | :--- | ---: |
200
-
| 175 write call sites | quoted in the merged changeset |**243**|
200
+
| 175 write call sites | quoted in the merged changeset |**244**|
201
201
| 24 carrying no tenant context | quoted in the merged changeset |**2** provable and tenancy-enabled; **29** more whose options argument is unreadable |
202
-
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card |**166 of 243** decidable, **77** undecidable |
203
-
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration**|**not reproduced**: 140 decidably elevated, 0 decidably not, 95 undecidable |
202
+
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card |**166 of 244** decidable, **78** undecidable |
203
+
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration**|**not reproduced**: 141 decidably elevated, 0 decidably not, 95 undecidable |
204
204
| 141 and 132, two independent re-derivations | the card that filed this work | — |
205
205
206
206
**The differences are not reconciled, and deliberately so.** The old census's
@@ -217,11 +217,11 @@ would report a smaller number and would not say so.
217
217
218
218
The fourth row is the one worth flagging to anyone citing it. **The 135 / 77%
219
219
figure has no surviving corroboration anywhere in the tree.** This census reads
220
-
140 of 243 (58%) as decidably elevated, with 95 more whose elevation is a
220
+
141 of 244 (58%) as decidably elevated, with 95 more whose elevation is a
221
221
run-time fact — so the claim is neither confirmed nor refuted, and the honest
222
222
answer is that a static reading cannot settle it.
223
223
224
-
⇒ **Cite `2 / 243`, and say what it is**: the sites whose options argument was
224
+
⇒ **Cite `2 / 244`, and say what it is**: the sites whose options argument was
225
225
READ and holds no tenant context, against a decidably tenancy-enabled object.
226
226
That is the control's provable yield surface. ⛔ Do not cite it as "the sites
227
227
without tenant context" — **29 further sites** have an options argument this
@@ -233,31 +233,31 @@ cannot read, and they are neither in nor out.
233
233
234
234
| what | count |
235
235
| :--- | ---: |
236
-
| write call sites on the application surface |**243**|
236
+
| write call sites on the application surface |**244**|
237
237
| …whose object name is statically decidable | 166 |
238
-
| …whose object name is chosen at run time |77|
238
+
| …whose object name is chosen at run time |78|
239
239
| …against an object with tenancy ENABLED | 165 |
240
240
| …against an object that declares tenancy off | 1 |
241
-
| threading a tenant context |184|
241
+
| threading a tenant context |185|
242
242
| PROVABLY carrying none (options read, no context key) |**8**|
243
243
| …of those, against a decidably tenancy-enabled object |**2**|
244
244
| options argument UNREADABLE — may or may not carry one | 51 |
245
245
| …of those, against a decidably tenancy-enabled object | 29 |
246
-
| threading a decidably ELEVATED (`isSystem`) context |140|
246
+
| threading a decidably ELEVATED (`isSystem`) context |141|
247
247
| threading a context that is decidably NOT elevated | 0 |
248
248
| threading a context whose elevation is a run-time fact | 95 |
249
249
250
250
| how the instrument reached the site | count |
251
251
| :--- | ---: |
252
-
| receiver carried a readable engine type |188|
252
+
| receiver carried a readable engine type |189|
253
253
| receiver erased, placed by the object NAME | 45 |
254
254
| receiver erased, placed by an `object: string` PARAMETER | 5 |
255
255
| receiver erased, placed by an `UNTYPED_RECEIVERS` row | 5 |
256
256
257
257
| object name spelled inline | 115 |
258
258
| object name spelled through a `const`| 51 |
259
259
| object name is an `object: string` parameter | 7 |
260
-
| object name is some other run-time expression |70|
260
+
| object name is some other run-time expression |71|
261
261
262
262
### Subtractions the census could NOT defend — enforced
263
263
@@ -307,13 +307,13 @@ holds still. They are required to be HERE and to say WHEN they were true;
307
307
their values are not compared. The reasoning, and the measurement behind it,
note: "remove the caller's own sys_comment_reaction row, needing no object delete grant; the console's reaction chip is the consumer and the SDK has no method yet"},
0 commit comments