Repository navigation
Commit ba8af87
feat(plugin-security)!: under single, Setup positions are written through to the environment ledger, and row-only positions are backfilled once (ADR-0131 D3, C2 stage S7) (#22388)
Part of #15196
Clause-②: no (narrowing)
ADR-0131 D3, C2 stage S7. Built on the seat's re-rule of the card
(comment 6070208925: Q1 = A, Q2 = A, Q3 = A) after the measurement round
(os-dev-report 6070148106), and on the seat note that keeps the Q2
stand-down while #22360 changes the declared-position seeder.
Not touched: every position reader (the read switch is S8),
`packages/core`, `packages/spec`, the row `active` flag, S2's built-in
declarations, the permission-set write-through, and
`bootstrap-declared-positions.ts`. Walled postures behave exactly as
before; the walled gap is #22361.
## What changes, under `single`
| Setup write on `sys_position` | Before | After |
|:--|:--|:--|
| create | row only; the catalog read does not resolve it | row first,
then the definition `{ name, label, description, delegatable }` saved
through the metadata door at environment scope; the catalog read
resolves it at once |
| edit (label, description, delegatable) | row only | row, then the
definition saved again from the row |
| `active` / `is_default` only | row only | unchanged: row only |
| rename | row only | row, then the new name's definition saved and the
old name's deleted |
| delete | row only | row, then the definition; a failed definition
delete is logged at `error` with its remedy |
| create, or rename into, a name the metadata door refuses | `201` /
`200` | the door's own refusal (`400 INVALID_REQUEST` at the item-name
grammar, `422 INVALID_METADATA` at `PositionSchema.name`); the row write
is undone, nothing is kept (Q1 = A) |
| edit of a row already carrying such a name | `200` | unchanged: a row
write, no definition (Q1 = A's control) |
| a name a package or a built-in holds | row only | unchanged: the
write-through stands down and writes nothing to metadata, read from the
engine registry's artifact provenance (Q2 = A) |
| system write, walled posture, kernel without a metadata door | row
only | unchanged |
A metadata refusal of a legal name also undoes the row write (create) or
restores the patched columns (edit), and the refusal is the answer. No
reader changes, so a user holding a position is granted exactly what
they were granted before (pinned below against a kernel with no metadata
door).
**The package door (Q3 = A, within Q4 = A).** Once a Setup position is
defined in the environment ledger, a package registering a position of
the same name is refused `422 NAMESPACE_CONFLICT`, naming both holders.
Before this change the same registration was accepted. The changeset
says so.
**The one-time backfill.** `runOneTimePositionEnvironmentBackfill`, at
`kernel:bootstrapped` beside the S4b grant-name backfill, under `single`
only. Every position name the security catalog read does not resolve
gets a definition from its row through the metadata door, verified
through the catalog read afterwards. A name the environment ledger, a
package or a built-in declares is left alone. A name the door refuses is
a final class, reported at `warn` and never written. Rows of one name
that disagree are reported at `error` and not written. The verdict row
(`sys_migration`, id `adr-0131-position-environment-backfill`) is
written only when every name is decided; a failure leaves it unrecorded
and the next boot retries. Its writer `persistPositionBackfillRecord`
joins the durability gate's critical list. The hook is
`kernel:bootstrapped` because an environment definition minted ahead of
a package's declaration of the same name would refuse that package
(measured at the registry item seam).
## Measured before the build (objectstack `1cb0edb82d`, showcase,
`single`)
- A Setup create answered `201` and wrote a row and nothing else: no
`sys_metadata` row, and the catalog read did not resolve it. Edit,
rename, deactivate and delete likewise touched only the row. The data
door accepted names in seven classes (uppercase, a space, a hyphen, a
leading digit, a leading underscore, one character, a dot) that the
metadata door refuses.
- No position projector exists: a metadata-door save of a position gets
its row only at the next boot, from the declared-position seeder.
- A fresh showcase has no row-only position after S2; one Setup create
adds exactly that one.
## Pins and ablations
`packages/plugins/plugin-security/src/position-write-through.test.ts`,
30 tests. They use a real ObjectQL engine over the SQL driver, the real
`SecurityPlugin`, and the real `ObjectStackProtocolImplementation`
(aliased to source) writing real `sys_metadata` rows.
- **Red on main.** `security-plugin.ts` restored to the base
(`3f80f17167`), so nothing is registered: 18 red, 12 green. The 12 green
are the controls (walled posture, system write, no door, a built-in
refused at the admin door, the permission-set write-through unchanged,
the Q1 edit control, the door's own `NOT_OVERRIDABLE`) and the
backfill's module-level cases. The restore was proven: blob equals HEAD,
and `git diff HEAD` is empty.
- **Ablations.** Each was run through `scripts/ablation-replace.mjs`,
with the anchor hit once, the blob changed and the restore proven. Each
turned exactly its own pins red:
- backfill wiring removed: the census pin and the rerun pin;
- the stand-down removed: the Q2 stand-down pin;
- insert undo removed: the six refused-name creates and the refused
legal create;
- Q1 control removed: the illegal-name edit control;
- the definition delete removed: the delete pin and the delete-failure
pin;
- the rename's old-name delete removed: the rename pin;
- the row-state carve-out removed: the edit/deactivate pin;
- update undo removed: the refused rename pin and the edit-refusal
restore pin;
- the refused-name class removed: the census, rerun and retry pins;
- the conflict check removed: the conflict pin.
- **The Q2 stand-down is pinned at the write-through's own level.** It
calls the middleware with a package-held edit, a built-in create and a
package-held delete; all three are passed on, and nothing reaches
metadata. A control holds that a Setup-only name is written. The data
door's answer for a declared-position edit is not pinned, because #22360
flips it.
- **Dogfood.**
`packages/qa/dogfood/test/position-environment-write-through.dogfood.test.ts`,
6 tests on the real showcase. It covers a create that resolves, rename
and delete, the Q1 door refusals (`400 INVALID_REQUEST`, `422
INVALID_METADATA`), the Q3 `NAMESPACE_CONFLICT`, and the backfill across
three boots of one database.
- Ablation, the backfill skipped: wiring replaced, `plugin-security`
rebuilt, the marker proven present in `dist/` by
`ablation-dist-preflight`. The backfill pin goes red. The restore was
rebuilt, and the marker was proven absent with the tree clean.
- Red on main (`security-plugin.ts` at base, rebuilt, write-through
proven absent from `dist/`): every behaviour pin is red. The
precondition stays green, as does a Q2 data-door case that has since
been removed.
- **Goldens.** S5b's `grant-readers-by-name.golden.test.ts` is green in
`plugin-security` (also at `42f9c68085`) and in `plugin-auth`.
## Verification at HEAD `dbef39ca41`
This head merges `origin/main` after #22364 landed. It runs `pnpm
install --frozen-lockfile`, then rebuilds the dogfood closure (63
tasks).
- `pnpm --filter @objectstack/plugin-security run typecheck`: exit 0
(`check:test-typecheck: OK`).
- `plugin-security`, full suite: 188 files, 3925 passed, 45 skipped.
This includes the pin file, the S4b backfill file and S5b's
`grant-readers-by-name.golden.test.ts`.
- `plugin-auth`, full suite: 132 files, 2672 passed, 10 skipped. This
includes its `grant-readers-by-name.golden.test.ts`.
- The 22 dogfood files that write or read positions: 214 passed.
- `pnpm check:durability-log-level`: 44 critical seams, all loud. With
the verdict writer's `error` downgraded, it goes red, naming
`persistPositionBackfillRecord`.
- `node scripts/check-adr-0087-registration.mjs --base origin/main`: one
declared-breaking changeset, `not-required (no-migration-prescription)`.
- `check-changeset-no-major`, with this body as the event: `✓ LEVEL
AXIS: this PR declares clause-② no (narrowing), and no package whose
packages/**/src/** it moves is graded patch.`
- `check-tenant-audit-census` and `check-system-context-census`: OK at
this head.
- Lint, narrowed: `eslint --no-inline-config` over the 8 changed TS/MJS
files gives 0 errors and 0 warnings.
- The 4 Markdown changes are outside eslint's globs.
- `eslint.config.mjs` enables no type-aware linting, so this diff cannot
move a verdict on an untouched file.
- Derived gates: 117 (`dispatch-gates --commands`). All 117 exited 0 at
`42f9c68085`, and `--ran` reconciled to 117 run, 0 unrun. They are
re-running at this head; the card report carries the verdict lines.
## Acceptance notes
- `content/docs/permissions/system-context.mdx` gains row 11b for the
write-through's `isSystem` read, and its counts were regenerated (`pnpm
gen:system-context-census`).
- The tenant-audit census was regenerated (`node
scripts/tenant-audit-census.mjs --write`). The page's hand-written prose
figures were updated to the census, as the census gate demands.
- `measure-durability-swallow-family.mjs` carries the vocabulary copy
for the new critical seam.
- S4b's boot-wiring pin now counts two `kernel:bootstrapped` handlers:
the grant-name backfill, then this one.
- Under `single` with several organizations, two Setup rows of one name
share one environment definition. The backfill refuses to guess when
they disagree. The write-through saves the definition from the row being
written.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WkL6Eijt432S1Y7ekb6ovQ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 9af0005 commit ba8af87
12 files changed
Lines changed: 1810 additions & 41 deletions
File tree
- .changeset
- content/docs/permissions
- docs/audits
- packages
- plugins/plugin-security/src
- qa/dogfood/test
- scripts
| 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 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
144 | | - | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
287 | | - | |
| 288 | + | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
| |||
358 | 359 | | |
359 | 360 | | |
360 | 361 | | |
361 | | - | |
| 362 | + | |
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
365 | | - | |
366 | | - | |
| 366 | + | |
| 367 | + | |
367 | 368 | | |
368 | 369 | | |
369 | | - | |
370 | | - | |
| 370 | + | |
| 371 | + | |
371 | 372 | | |
372 | 373 | | |
373 | 374 | | |
| |||
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
434 | | - | |
| 435 | + | |
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | | - | |
193 | | - | |
| 192 | + | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
| 203 | + | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
| 236 | + | |
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
243 | | - | |
| 242 | + | |
| 243 | + | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | | - | |
| 304 | + | |
| 305 | + | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| |||
Lines changed: 12 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
| 97 | + | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
| |||
0 commit comments