Repository navigation
Commit 2478f8e
test(plugin-security): pin the authored-policy outcome and the skipped sharing relief on a controlled_by_parent predicate write (#38338)
Fixes #36367
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:用户无感;只补测试,产品行为不变。
-
为什么做:为「共享授权与字段权限改造」专题补上上一单(批量与逐条一致)留下的两处测试空白:明细上应用自写的修改/删除规则,以及批量改删时不再去问共享服务。
- 出错会怎样:只动一个测试文件,不影响任何用户;有问题可以直接撤回。
- 要你做什么:无。
## What changes
Test-only. One file:
`packages/plugins/plugin-security/src/predicate-write-floor-deferral.test.ts`,
on its own real-engine rig (real `SecurityPlugin`, `ObjectQL`, SQL
driver over better-sqlite3, `SharingService` and its middleware). It
carries nit N3 of contract record 7076369115 on PR #36282.
The rig gains one detail, `pwf_line_staged`: the `controlled_by_parent`
detail of `pwf_order`, with a `stage` column. Two permission sets carry
REP_SET's grants and one app-authored policy each: `update` with `using:
"stage == 'open'"`, and the same for `delete`. `seedLines` takes per-row
overrides. On the staged matrix the order's owner ALICE created r1 and
r3, which are closed. CAROL created r2 and r4, which are open.
**The authored-policy outcome** (new describe inside the
`controlled_by_parent` block, real engine, row for row against the by-id
oracle):
- `update`: under the update policy, the predicate update writes exactly
r2 and r4, which is what a by-id update of each writes. It skips r1 and
r3, which ALICE created and the policy does not admit.
- `delete`: the same under the delete policy.
- CONTROL, each verb: a policy on the other verb binds nothing, so every
row is written, the closed rows ALICE created included. So it is the
policy that keeps r1 and r3 out, not the master gate.
**The skipped sharing relief** (second new describe):
- End to end, each verb: a vouched predicate write by the master's owner
asks the sharing service no write verdict about the detail, per row or
set form. It writes beyond the floor, with no authored policy (all four
rows) and with one (r2 and r4). A control: a by-id write of one row of
the same detail does ask, so the recorder sees verdicts on that object.
- Why it can't be seen, measured on this rig: the skip on its own moves
no row and asks nothing here. One case pins each of three facts that
make that true:
1. With no authored policy, the vouched Layer 1 is empty, so the relief
has no Layer 1 to work on.
2. With an authored `using`, the vouched Layer 1 is the policy alone (`{
stage: 'open' }`). Replacing only the floor (the relief's own test)
keeps the authored term, so the relief returns before it asks anything.
3. Record sharing answers `abstain` for every row of both details, for
both verbs. So a verdict, even if one were asked, would replace no
floor.
No product code is touched. Every pin measures the outcome PR #36282
declares. No product defect was measured.
## Tests
Head `198443d7b0`. The suite, typecheck and gate runs below were taken
at this head, after its last commit.
<details><summary>The file, the plugin-security suite and
typecheck</summary>
- `pnpm --filter @objectstack/plugin-security exec vitest run
--maxWorkers=2 src/predicate-write-floor-deferral.test.ts`, under the
verify lock: `Tests 116 passed (116)` (109 before, plus 7 new), `VERDICT
command-exit 0`.
- `pnpm --filter @objectstack/plugin-security exec vitest run
--maxWorkers=2`, under the verify lock: `Test Files 290 passed (290)`,
`Tests 7337 passed | 45 skipped (7382)`, `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/plugin-security typecheck` (tsc, scripts
project, `check:test-typecheck`), under the verify lock: `VERDICT
command-exit 0`. The file is in the `tsconfig.test.json` program
(`--listFiles`: 1 hit).
</details>
<details><summary>Ablations, through scripts/ablation-replace.mjs, each
restored and proved by blob hash</summary>
The test imports plugin-security's source, so there is no dist hop. On
every leg the anchor went from 1 to 0 and the blob changed. After each
restore the blob equals HEAD and `git diff HEAD` is empty. The whole
file is run each time; the counts below are the 7 new cases.
1. **A1, the vouch taken off step 3's Layer 1**
(`security-plugin-authz-middleware.ts`, `predicateMasterGateRowIds ? {
masterGateCoversThisWrite: true } : undefined` becomes `undefined`): 22
failed / 94 passed. 6 of the 7 new cases are red. The authored-policy
update and delete wrote r1 to r4 by predicate (floor OR policy, the
outcome before PR #36282) against r2 and r4 by id. The other-verb
controls wrote only r1 and r3. The end-to-end relief case wrote only r1
and r3. The "why" case stays green, as expected: it calls the
composition directly with the vouch option.
2. **A2, the relief's skip removed** (`&& !predicateMasterGateRowIds`
dropped from the relief's guard): 116 passed. This is the outcome the
"why" case pins: on its own, the skip is not visible here.
3. **A3, the floor's yield to the master gate removed**
(`security-plugin-rls-filter.ts`, the `collected.filter(...
!isPlatformOwnershipFloorPolicy ...)` under
`platformFloorYieldsToObjectWriteModel` becomes a no-op): 26 failed / 90
passed, all 7 new cases red. The "why" case read the vouched Layer 1 as
`{ created_by: 'usr_alice' }` instead of null.
4. **A4, A2 and A3 together** (A2 held with `--hold`, A3 wrapped, then
A2 restored): 26 failed / 90 passed, all 7 new cases red. The verdict
assertion itself now fails, on both verbs: `pwf_line: verdicts the
predicate write asked: expected [ { verb: 'edit', … }, … ] to deeply
equal []` (and `'delete'` for the delete). So the recorder catches a
relief verdict on a vouched write once the relief can reach one.
</details>
## Acceptance notes
- The card allows "or show why none is observable" for the sharing
relief. A2 shows that removing the skip alone changes nothing on these
fixtures, so the relief case pins the three reasons and is ablated red
through A3 and A4. PR #36282 named this gap ("on these fixtures the
relief would answer nothing either way").
- `scripts/pm/overlap-check.mjs` before each push: `VERDICT clean`.
- The test file's own run: about 5.3 s of tests inside about 20 s of
wall time, most of it module import, as before.
## Verification
Read first:
1. The `[#36367]` describe "why the skip moves no row" in the test file:
it holds the three facts above.
2. The `[#36367]` describe on the authored policy: the four cases and
the staged seed.
Two-minute check: `pnpm --filter @objectstack/plugin-security exec
vitest run --maxWorkers=2 src/predicate-write-floor-deferral.test.ts -t
36367`. Expect 7 passed.
<details><summary>Gates</summary>
Derived with `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `198443d7b0`: 1 path against merge base
`c279520a0c`, 54 families. Each was run once at this head, with its exit
code captured before any pipe. `dispatch-gates --ran`: "54 derived
famil(ies) accounted for — 52 run, 2 NOT-MEASURED (2 DERIVED from a
recorded exit 3)", exit 0.
- 52 exit 0. One of them took a second run: `node
scripts/check-plugin-teardown-shape.mjs --self-test` first exited 3
because its pinned positive-control commit was missing from the shallow
clone. Once that one commit was fetched it exited 0 (48 cases pass).
- NOT MEASURED, PREREQUISITE NOT MET (exit 3), left to CI's `Lint & Repo
Gates`: `pnpm check:dual-build-cjs-loads` and `pnpm check:i18n` read the
`dist/` of packages outside the plugin-security closure built here (59
packages, and the CLI).
- Not run locally, by rule: the repo-wide lint and `test:repo`
(CI-owned; the diff touches no test in that project).
`check-platform-checklist` is not owed: no exported symbol is renamed or
removed.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_017xRBcSCSJLNEQQeWJhKnd1)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 191235b commit 2478f8e
1 file changed
Lines changed: 121 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
192 | 209 | | |
193 | 210 | | |
194 | 211 | | |
| 212 | + | |
195 | 213 | | |
196 | 214 | | |
197 | 215 | | |
| |||
312 | 330 | | |
313 | 331 | | |
314 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
315 | 337 | | |
316 | 338 | | |
317 | 339 | | |
| |||
1254 | 1276 | | |
1255 | 1277 | | |
1256 | 1278 | | |
| 1279 | + | |
| 1280 | + | |
1257 | 1281 | | |
1258 | 1282 | | |
1259 | 1283 | | |
| |||
1284 | 1308 | | |
1285 | 1309 | | |
1286 | 1310 | | |
| 1311 | + | |
1287 | 1312 | | |
1288 | 1313 | | |
1289 | 1314 | | |
| |||
1381 | 1406 | | |
1382 | 1407 | | |
1383 | 1408 | | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
1384 | 1504 | | |
1385 | 1505 | | |
1386 | 1506 | | |
| |||
0 commit comments