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 dac99c2
Browse filesBrowse the repository at this point in the historyBrowse files
refactor(plugin-security)!: delete the permission-set projection, the seed-name lookup and the refusal sink (C3 stage 7a) (#23368)
Refs #22975
Clause-②: no (narrowing)
C3 (#15204) stage 7a. It deletes the permission-set projection, the
seed-name lookup and the seed refusal sink, with the suites that pin
only them. Stage 8 left all three without a live caller, and #23308 (PR
#23334) moved the one live behaviour the projection still carried, the
environment kernel's security-catalog echo, into its own module. It is
the first half of the stage-7 pair; 7b (#23302) has landed, and 8-post
follows. #22975 stays open.
## 维护者速读(草稿)
### 改了什么
删除权限集「投影器」及其两个配套模块(种子名称查找、种子拒绝汇报),以及只测试它们的旧测试,共约 6,500 行(30 个文件,+350 /
−6,539)。新增一个集成测试,证明「发布权限集不会再写出任何 `sys_permission_set` 行」。同时撤下 liveness
登记里指向已删文件的那一条,并为仍在使用的「权限集锁」补回一个被旧测试顺带覆盖的用例。
### 为什么改
投影器原本把每个权限集定义复制成一行 `sys_permission_set` 记录。阶段 8
已经下线了这张表,投影器从此没有调用方,只是死代码。它身上唯一还在用的功能(环境内核上让安全目录找到元数据门写入的权限集和岗位)已由
#23308 搬到独立模块。所以现在可以干净地删掉。
### 风险与代价(含回滚)
- 对运行中的部署:没有行为变化。被删的代码在阶段 8
之后已不被调用。新测试在全新数据库上实测:包发布、可写基础包直接发布、重启后的启动流程,都留下零行。
- 对外部代码:`@objectstack/plugin-security` 去掉了 11
个导出(函数与类型)。如有人直接导入它们,升级时会编译失败。changeset 逐个写明了替代方案(大多是「直接删掉调用」)。
- 回滚:整体 revert 本 PR 即可,没有数据迁移。
### 席位意见
### 你要做的
用 `os-zhuang` 或 `hotlong` 批准本 PR(Tier H,按行数超过 3,000)。批准同时确认:本 PR 改写了
#23258 尚未发布的更新说明
`.changeset/23233-permission-echo-names-runtime-package.md` 里的一句(「仍是
`managed_by: 'admin'` 的 `sys_permission_set` 行」改为「不再写任何
`sys_permission_set` 行」),因此 `Check Changeset` 按设计保持红(它不在合并队列的五个必查项里)。
## What this changes
- **Deleted modules:** `permission-set-projection.ts` (the ADR-0094
projector, its data-door write-through and its boot reconcile),
`seed-name-lookup.ts` and `seed-refusal-sink.ts`, with their exports
from the package entry and the projection's ADR-anchor JSON.
- **Deleted suites**, each pinning only deleted code:
- `permission-set-projection.test.ts`
- `permission-set-projection-heal-by-id.test.ts`
- `packaged-permission-set-restore-leg.test.ts`
- `permission-set-duplicate-name-refusal.test.ts`
- `seed-name-lookup-degradation-audible.test.ts`
The #21789 echo-stamp cases of the old projection suite are not kept
here: they already live in `security-catalog-echo.test.ts` (#23308),
which pins the echo where it now lives.
- **Re-pinned:** `packaged-permission-set-lock.test.ts` moves onto the
metadata door's lock gate. That includes the classifier's refusal of a
SchemaRegistry that answers with a non-list
(`packaged-permission-set-lock.ts`, the `Array.isArray` branch). The old
pin 5 was its only direct pin; it now sits beside the throwing-registry
case, and it measured red with the branch ablated.
- **Re-homed:** `tryFind` becomes a private helper of
`packaged-permission-set-overlay-detection.ts`, its one live caller, and
that reading's logger option asks only for `warn`.
- **The security middleware** loses the `writesExecutedByDataDoor`
stand-down, which only the retired data door could arm.
- **The epic's zero-row acceptance** (6129253247):
`packages/cli/test/permission-set-zero-row.integration.test.ts`. On a
fresh SQLite file, on both the host kernel and an environment kernel, it
runs:
- a package-door publish (a draft, then `publishPackageDrafts`);
- a writable base's direct publish;
- a second boot over the stored definitions.
The rows are counted from the file through the test's own connection, so
a table that does not exist counts as zero. A control writes one row and
reads it back as one.
- **Liveness (Q3 → B):** the `permission-set-projection`
`HIGH_RISK_CLASSES` entry in
`packages/spec/scripts/liveness/proof-registry.mts` is removed, together
with its README mirror row. Its `proofRef` pointed at a dogfood file
that no longer exists, and no `@proof` tag carries it. The
`permission.tabPermissions` entry no longer cites the deleted file.
- **A pending changeset this PR makes false:**
`.changeset/23233-permission-echo-names-runtime-package.md` no longer
says the set keeps a `managed_by: 'admin'` row. No row is written once
the projector is gone.
- **D's transitional text:** the header of
`package-uninstall-revokes-named-grants.dogfood.test.ts` no longer
describes a projector row. The `authorization.mdx` sentences were
already removed on `main` by #23322, so nothing is left to change there.
- **Generated, regenerated with the repo's own tools:**
- the tenant-audit census page and counts (`node
scripts/tenant-audit-census.mjs --write`; `main` 226 → 223 sites), with
the prose figures the gate holds to the census updated;
- `scripts/engine-double-contract.pinned.json` (`--write`);
- the entries of the deleted suites removed from
`engine-double-contract.baseline.json` and
`objectql-double-limit.baseline.json`. Both gates name that removal;
neither has a write flag.
- **Changeset:** `@objectstack/plugin-security` minor (a narrowing on
the v18 prerelease line). The ADR-0087 marker is `not-required
(runtime-export-retired …)` for the 11 retired exports, each with its
FROM → TO. `@objectstack/spec` patch.
## Acceptance notes
- **The zero-row result already held on `main` after S8.** On S8's
parent `99e944daf2`, measured with this same test file, every leg goes
red on both kernels:
- after the two publishes, `expected 2 to be +0` (the projector's
`admin` rows);
- with those rows deleted, the boot over the stored definitions
re-creates both (`expected 2 to be +0` after the boot).
That tree is the writer put back.
- **Not here:**
- ADR-0094 still names the projector. That is governed text, and the
seat files the card at this PR's landing.
- The ADR anchor sweep is green (`check:adr-symbol-anchors` exit 0), so
no ADR line anchors into a deleted file and no anchor fix was needed.
- **For 8-post's comment sweep:** the prose that still names the deleted
modules:
- the spec docblocks `permission.zod.ts:824`,
`metadata-plugin.zod.ts:1166` and `error-code-ledger.zod.ts:1270`;
- `scripts/check-durability-degradation-log-level.mjs:156`;
- the `source` of
`docs/qa/platform-checklist/areas/access-security.json:2649`;
- the surviving code comments in `plugin-security`.
- **For the seat's governed ADR card at landing:** ADR-0094 (it names
the projector throughout); ADR-0126 "Three real mechanisms"; ADR-0131
lines 59 and 993.
- **A deliberate correction of a pending release note, for
confirmation:**
`.changeset/23233-permission-echo-names-runtime-package.md` (added by
#23258, not by this PR). Its "Unchanged" item said the set keeps a
`sys_permission_set` row (`managed_by: 'admin'`, no `package_id`). After
this PR no row is written, so that sentence would publish a false
statement. The seat's patch round (6160244399, item 3) asks for the
correction. `check-empty-changeset` stays red on it by design, and this
note is the human path that gate names.
## Verification
**Full battery, on `accde78fe6`** (`main` `18cd410dc4` merged in). Since
then the code has changed only by `main` merges and this round's patch,
which touches no runtime code path.
- Full build: 75/75.
- `plugin-security` typecheck: exit 0.
- `plugin-security` suite: 185/185 files, 3,772 passed.
- CLI integration tier: 125/125 files, 1,093 passed. This includes the
zero-row test.
- Dogfood: 257 files passed, 2,176 passed.
- The derived sweep: 120 derived, 119 run, all exit 0. `--ran`
reconciles with 0 UNRUN and 1 NOT-MEASURED: `check:platform-checklist`,
exit 1 with the same 8 reds as `main`.
- `check:pm-dispatch-gates`: exit 0.
**The patch round, scoped**, on `ddcdb46bd4` (`main` `6eb6f7d65b` merged
in once, just before the push):
- The spec liveness and proof-registry tests: 81/81.
- `check:liveness`: exit 0.
- The `plugin-security` lock suites
(`packaged-permission-set-lock*.test.ts`): 2 files, 15 passed. The new
non-list pin measured red with the branch ablated.
- `plugin-security` and spec typecheck: exit 0.
- The gates derived for the three changed paths, the three anchor sweeps
among them: 72 derived and run. `--ran` reconciles with 0 NOT-MEASURED
and 0 UNRUN. 71 exit 0. `check-empty-changeset` exits 1, deliberately:
see the next point.
**The ablation:** see Acceptance notes (S8's parent `99e944daf2`, red on
both kernels).
**objectui pinned sibling: NOT MEASURED.** It is not checked out here,
and the Console Pin Gate runs only in the full battery (#22998), so it
is skipped on a PR. Nothing the console imports should move: the entry
loses only the 11 projector names (`permissionSetRowFields`,
`permissionSetBodyFromRow`, `upsertEnvPermissionSet`,
`projectPermissionMutation`, `registerPermissionSetProjection`,
`createPermissionSetWriteThrough`, `reconcilePermissionSetProjection`,
and the types `PermissionSeedOutcome`, `ProjectionDeps`,
`ProjectionReconcileOutcome`, `WriteThroughDeps`), and no package in
this repository imports any of them.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01287UbjvrigpWwNfGDmdwpS)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(plugin-security)!: the permission-set projection, its seed-name lookup and refusal sink are deleted (ADR-0131 D3, C3 stage 7a)
7
+
8
+
Clause-②: no (narrowing)
9
+
10
+
<!-- adr-0087: not-required (runtime-export-retired @objectstack/plugin-security#permissionSetRowFields, @objectstack/plugin-security#permissionSetBodyFromRow, @objectstack/plugin-security#upsertEnvPermissionSet, @objectstack/plugin-security#projectPermissionMutation, @objectstack/plugin-security#registerPermissionSetProjection, @objectstack/plugin-security#createPermissionSetWriteThrough, @objectstack/plugin-security#reconcilePermissionSetProjection, @objectstack/plugin-security#PermissionSeedOutcome, @objectstack/plugin-security#ProjectionDeps, @objectstack/plugin-security#ProjectionReconcileOutcome, @objectstack/plugin-security#WriteThroughDeps) The retired names are runtime functions and types of the projector that mirrored a permission-set definition into a sys_permission_set row. No metadata moves: no spec key, authorable spelling or stored shape changes, and no stored row is rewritten. Stage 8 already stopped registering the projector and the data-door write-through, so nothing in a running deployment called them. -->
11
+
12
+
**BREAKING** (retired exports of `@objectstack/plugin-security`), graded `minor` on the v18 prerelease line.
13
+
14
+
Stage 8 stopped registering the `sys_permission_set` row object, the `permission` mutation projector and the data-door write-through. This change deletes the modules behind them: `permission-set-projection`, `seed-name-lookup` and `seed-refusal-sink`. A permission set is written through the metadata door alone (`PUT /api/v1/meta/permission/:name`), and the security catalog serves it by name.
15
+
16
+
What a consumer sees:
17
+
18
+
- FROM `createPermissionSetWriteThrough(deps)` TO nothing: no `sys_permission_set` data-door write exists to redirect. Write the set through the metadata door. Delete the call.
19
+
- FROM `registerPermissionSetProjection(protocol, deps)` TO nothing: no row mirrors a definition. Delete the call.
20
+
- FROM `reconcilePermissionSetProjection(...)` TO nothing: there is no projection to reconcile at boot. Delete the call.
21
+
- FROM `projectPermissionMutation(...)` TO nothing. Delete the call.
22
+
- FROM `upsertEnvPermissionSet(...)` TO `PUT /api/v1/meta/permission/:name`, or the metadata protocol's `saveMetaItem({ type: 'permission', name, item })`.
23
+
- FROM `permissionSetBodyFromRow(row)` TO `permissionSetDefinitionFromRow(row)` from `@objectstack/core`: the same mapping, for converting a stored `sys_permission_set` row into its definition.
24
+
- FROM `permissionSetRowFields(definition)` TO nothing: no row is written. Delete the call.
25
+
- FROM the types `PermissionSeedOutcome`, `ProjectionDeps`, `ProjectionReconcileOutcome` and `WriteThroughDeps` TO nothing. Delete the import.
26
+
27
+
Unchanged: the security catalog's echo of a metadata-door permission set or position on an environment kernel, which lives in its own module since #23308. The packaged-permission-set lock still refuses a metadata-door save of a set a code package ships (`403 NOT_OVERRIDABLE`), and the boot still reports environment overlays that shadow such a set. `OverlayDetectionOptions.logger` now asks only for `warn`, the one channel the reading reports on.
28
+
29
+
**`@objectstack/spec`** (patch): the `permission.tabPermissions` liveness entry no longer cites the deleted projection, and the liveness README's registered-but-unbound `permission-set-projection` proof row is retired with the invariant it described (no `@proof` tag carries it any more).
Copy file name to clipboardExpand all lines: .changeset/23233-permission-echo-names-runtime-package.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,5 +9,5 @@ Clause-②: no
9
9
-**What was wrong.** A writable runtime package's permission set marked `isDefault: true`, published through the package door with no `packageId` in its body, recorded no audience-binding suggestion on an environment kernel, so ADR-0090 D5's "packages suggest, admins confirm" never happened for it. On that kernel the protocol hydrates no stored row into the engine registry, so the security catalog finds the set in the metadata service. The only body there is the permission-set projection's in-memory copy, and that copy carried no `_packageId`. The catalog served the set as unowned while `GET /api/v1/meta/permission/NAME` named the package, and the suggestion collector skipped it.
10
10
-**What changed.** The projection's copy of a tenant-authored set now names the package its stored row is bound to. It reads that binding from the protocol's by-name read (the `_packageId` that read serves) and derives none of its own. The catalog, the by-name read and the layered read (`?layers=true`, whose `packageId` comes from the same copy) now name the same owner. `GET /api/v1/security/suggested-bindings` lists one pending suggestion under that package. A `manage_metadata` holder still has to accept it: the publish grants nothing.
11
11
-**When the body's `packageId` disagrees.** A set whose body declares a `packageId` other than the package it is published into is now owned, for the catalog and the suggestions, by the package it is published into, which is what the by-name read already served. On an environment kernel, a suggestion recorded under the body's package is pruned at the next sync while pending, and withheld from `everyone` with its reason logged if it was accepted. A pending suggestion under the publishing package replaces it.
12
-
-**Unchanged.** The `sys_permission_set` row (still `managed_by: 'admin'`, with no `package_id`), the packaged-permission-set lock and every edit door. A code package's set, whose owner the catalog reads from its artifact. A set saved into no package, which stays unowned and records no suggestion. A copy of a code-shipped set's legacy overlay, which carries no owner, as before.
12
+
-**Unchanged.** The packaged-permission-set lock and every edit door. (No `sys_permission_set` row is written for the set: C3 stage 7a retires the last writer.) A code package's set, whose owner the catalog reads from its artifact. A set saved into no package, which stays unowned and records no suggestion. A copy of a code-shipped set's legacy overlay, which carries no owner, as before.
13
13
-**If the binding cannot be read**, the copy is registered without an owner, as before, and one warning says so. It still enforces the new body, and the next save, publish or boot reads the binding again.
Copy file name to clipboardExpand all lines: content/docs/permissions/system-context.mdx
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,6 @@ that silently does not happen.
108
108
| 9 |`explain()` may target a principal other than the caller | plugin-security | Get: no `manage_users` / delegated-admin check |`packages/plugins/plugin-security/src/security-plugin.ts#explainAccessForCaller`|
109
109
| 9b | The master-detail write check the `security` service serves (`checkControlledByParentWrite`, ADR-0055) answers `allow`| plugin-security | Get: `allow` for any record, with no master judged — the write path's own first exit, so a gate composing it admits exactly what the record's own system-context update would. Lose: nothing a caller reaches today: its two consumers, the `sys_attachment` and `sys_comment` parent gates, return before they ask for a system session |`packages/plugins/plugin-security/src/security-plugin.ts#checkControlledByParentWrite`|
110
110
| 10 | Anonymous-deny treats the caller as authenticated | core | Get: passes the 401 seam with no `userId`|`packages/core/src/security/anonymous-deny.ts#shouldDenyAnonymous`|
111
-
| 11 | Permission-set projection middleware skipped | plugin-security | Lose: nothing on a stock composition — the security plugin no longer registers this middleware, because the `sys_permission_set` object it projected into is retired (ADR-0131 D3); the module is still exported. Where a host registers it, the skip is of the projection of permission-set-derived columns |`packages/plugins/plugin-security/src/permission-set-projection.ts#createPermissionSetWriteThrough`|
Copy file name to clipboardExpand all lines: content/docs/permissions/tenant-audit-census.mdx
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ what moved this page's population from 225 to 227; nothing about the two sites
83
83
changed, only whether this instrument could see them.
84
84
85
85
**The expensive failure direction is a keyword.** Sites whose receiver the author
86
-
typed `any` have no type to read, and there are 41 of them — just under a fifth
86
+
typed `any` have no type to read, and there are 38 of them — just under a fifth
87
87
of the population, concentrated in exactly the seed and bootstrap paths this
88
88
control exists for. Scoring an unreadable receiver as "not an engine" would have
89
89
dropped every one of them silently, with a clean exit and a smaller number that
@@ -122,7 +122,7 @@ are reported as `undecidable` rather than assumed either way.
122
122
123
123
The same holds twice over for the context. An options argument spelled as a
124
124
literal can be read; one spelled `options`, `{ ...opts }`, or handed through a
125
-
forwarding shim cannot, and **53 of the 228 sites are spelled that way**. A
125
+
forwarding shim cannot, and **53 of the 225 sites are spelled that way**. A
126
126
context resolved from an inline literal or a local `const` can be tested for
127
127
`isSystem`; one arriving from a helper call cannot.
128
128
@@ -187,10 +187,10 @@ reproduce them. Where it disagrees, it disagrees on the page:
187
187
188
188
| carried figure | where it survives | this census |
189
189
| :--- | :--- | ---: |
190
-
| 175 write call sites | quoted in the merged changeset |**228**|
190
+
| 175 write call sites | quoted in the merged changeset |**225**|
191
191
| 24 carrying no tenant context | quoted in the merged changeset |**2** provable and tenancy-enabled; **32** more whose options argument is unreadable |
192
-
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card |**155 of 228** decidable, **73** undecidable |
193
-
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration**|**not reproduced**: 121 decidably elevated, 0 decidably not, 99 undecidable |
192
+
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card |**154 of 225** decidable, **71** undecidable |
193
+
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration**|**not reproduced**: 120 decidably elevated, 0 decidably not, 97 undecidable |
194
194
| 141 and 132, two independent re-derivations | the card that filed this work | — |
195
195
196
196
**The differences are not reconciled, and deliberately so.** The old census's
@@ -200,18 +200,18 @@ be stated is what this instrument counts, which is written above and re-runnable
200
200
at any commit.
201
201
202
202
Two structural facts do plausibly widen this reading against any hand or regex
203
-
one, and both are counted in the generated tables below: the 41 sites reached
203
+
one, and both are counted in the generated tables below: the 38 sites reached
204
204
through an erased (`any`) receiver, and the 50 that name their object through a
205
205
`const` rather than inline. An instrument that read either the way a person does
206
206
would report a smaller number and would not say so.
207
207
208
208
The fourth row is the one worth flagging to anyone citing it. **The 135 / 77%
209
209
figure has no surviving corroboration anywhere in the tree.** This census reads
210
-
121 of 228 (53%) as decidably elevated, with 99 more whose elevation is a
210
+
120 of 225 (53%) as decidably elevated, with 97 more whose elevation is a
211
211
run-time fact — so the claim is neither confirmed nor refuted, and the honest
212
212
answer is that a static reading cannot settle it.
213
213
214
-
⇒ **Cite `2 / 228`, and say what it is**: the sites whose options argument was
214
+
⇒ **Cite `2 / 225`, and say what it is**: the sites whose options argument was
215
215
READ and holds no tenant context, against a decidably tenancy-enabled object.
216
216
That is the control's provable yield surface. ⛔ Do not cite it as "the sites
217
217
without tenant context" — **32 further sites** have an options argument this
@@ -223,30 +223,30 @@ cannot read, and they are neither in nor out.
223
223
224
224
| what | count |
225
225
| :--- | ---: |
226
-
| write call sites on the application surface |**228**|
227
-
| …whose object name is statically decidable |155|
228
-
| …whose object name is chosen at run time |73|
226
+
| write call sites on the application surface |**225**|
227
+
| …whose object name is statically decidable |154|
228
+
| …whose object name is chosen at run time |71|
229
229
| …against an object with tenancy ENABLED | 153 |
230
230
| …against an object that declares tenancy off | 1 |
231
-
| threading a tenant context |167|
231
+
| threading a tenant context |164|
232
232
| PROVABLY carrying none (options read, no context key) |**8**|
233
233
| …of those, against a decidably tenancy-enabled object |**2**|
234
234
| options argument UNREADABLE — may or may not carry one | 53 |
235
235
| …of those, against a decidably tenancy-enabled object | 32 |
236
-
| threading a decidably ELEVATED (`isSystem`) context |121|
236
+
| threading a decidably ELEVATED (`isSystem`) context |120|
237
237
| threading a context that is decidably NOT elevated | 0 |
238
-
| threading a context whose elevation is a run-time fact |99|
238
+
| threading a context whose elevation is a run-time fact |97|
239
239
240
240
| how the instrument reached the site | count |
241
241
| :--- | ---: |
242
242
| receiver carried a readable engine type | 187 |
243
243
| receiver erased, placed by the object NAME | 28 |
244
-
| receiver erased, placed by an `object: string` PARAMETER |7|
245
-
| receiver erased, placed by an `UNTYPED_RECEIVERS` row |6|
244
+
| receiver erased, placed by an `object: string` PARAMETER |5|
245
+
| receiver erased, placed by an `UNTYPED_RECEIVERS` row |5|
246
246
247
-
| object name spelled inline |105|
247
+
| object name spelled inline |104|
248
248
| object name spelled through a `const`| 50 |
249
-
| object name is an `object: string` parameter |9|
249
+
| object name is an `object: string` parameter |7|
250
250
| object name is some other run-time expression | 64 |
251
251
252
252
### Subtractions the census could NOT defend — enforced
@@ -297,13 +297,13 @@ holds still. They are required to be HERE and to say WHEN they were true;
297
297
their values are not compared. The reasoning, and the measurement behind it,
0 commit comments