Repository navigation
Commit 2fbe1fd
refactor(plugin-security): move the organization-scope helpers and the seed write-refusal accumulator out of per-organization-catalog.ts (#22696)
Part of #15204
Clause-②: no
Stage **6c-prep** of the cutover stage plan (claim amendment 6098235618
on the card, adding this stage to the epic lane's claim 6095611212). The
surviving per-organization helpers leave `per-organization-catalog.ts`,
so stage 6c (deleting that module) no longer waits on stage 7. This is a
move with no behavior change. #15204 remains open: this PR is one stage
of its cutover.
## What moved, and where
`sec/` = `packages/plugins/plugin-security/src/`.
| Export | New home | Kept consumers past 6c's landing slot |
|:--|:--|:--|
| `seedCtx`, `catalogIsPerOrganization`, `listSeedOrganizationIds`,
`rowOrganizationId`, `resolveOwnOrganizationRow`,
`SEED_ORGANIZATION_SCAN_LIMIT`, `warnOrganizationLessRows`,
`OrganizationLessRowOrigin` | `sec/organization-scope.ts` |
delegated-admin-gate, grant-permission-set-name-backfill,
auto-org-admin-grant, security-plugin, bootstrap-declared-permissions
(6b-2), seed-name-lookup and permission-set-projection (7a) |
| `SeedLogger`, `logSeedDurabilityFailure`, `createSeedWriteRefusals`,
`reportSeedWriteRefusals`, `SeedWriteRefusals`,
`SeedWriteRefusalReport`, `SeedWriteRefusalClass` |
`sec/write-refusals.ts` | bootstrap-platform-admin,
cleanup-package-permissions, suggested-audience-bindings,
bootstrap-declared-permissions and permission-set-drift (6b-2),
permission-set-overlay-discard (7-pre), permission-set-projection (7a) |
- **What stays in `per-organization-catalog.ts`:**
`rowMatchesDeclaration` and nothing else. Its one importer is
`bootstrap-builtin-positions.ts`, which retires in 6a. The module
changes by deletion only: `git diff` shows 0 added lines and 666
deleted.
- **Bodies are byte-identical.** Each new module is built from line
ranges of the old file. Each gets a new header of at most seven lines,
plus one new `import type { SeedLogger } from './write-refusals.js'` in
`organization-scope.ts`. No export is renamed, and no signature or body
changes.
- **The doctrine docblock moved with the helpers it explains.** Its
three sections (why the catalog is per organization, the doctrine, and
what replaces a reap) now head `organization-scope.ts`, beside
`resolveOwnOrganizationRow` and `warnOrganizationLessRows`.
- **The `SeedLogger` choice.** Both modules use `SeedLogger`. It lives
in `write-refusals.ts` because its own doc is the durability-channel
contract, and `organization-scope.ts` imports the type from there. Its
pin in `seed-write-refusal.test.ts` reads the declaration from source,
so that test's path literal follows it.
- **No re-export shim, and no public surface.** None of these names is
in `plugin-security`'s `src/index.ts`, and none is imported from any
other package (`git grep` over the tree). The package's public exports
are unchanged.
## Importers repointed
There are 17 importers in `sec/` plus `seed-write-refusal.test.ts`. The
only edits are their import specifiers: names, aliases (`seedCtx as
organizationScopedCtx`, `seedCtx as lookupCtx`) and `type` modifiers are
all kept. `walled-platform-bucket-diagnostic.test.ts` names the module
only in comments, which point at `per-organization-catalog.test.ts`, so
it is unchanged.
For retired modules, batch #310 item 4 applies as the seat reads it in
6098235618: an import specifier repoint is the mechanical consequence of
the move, and no other line changes. That covers the 6a, 6b-1, 6b-2,
7-pre and 7a modules. `permission-set-projection.ts`'s import is the
only line changed there.
## Comment pointers
- **Repointed in surviving modules:**
- `security-plugin.ts`, the seeding comment: now
`organization-scope.ts`, plus `rowMatchesDeclaration` for the O(changed
declarations) half.
- `delegated-admin-gate.ts`: now `organization-scope.ts`.
- `bootstrap-platform-admin.ts`, the `tryInsert` comment: now
`write-refusals.ts`.
- `plugin-auth/src/ensure-default-organization.ts`, the
`logSeedDurabilityFailure` provenance: now `write-refusals.ts`. Comment
only.
- **Left as they are in retired modules (item 4):**
`bootstrap-builtin-positions.ts`, `bootstrap-declared-positions.ts`,
`bootstrap-declared-permissions.ts`, `permission-set-projection.ts`, and
`plugin-sharing/src/bootstrap-declared-sharing-rules.ts`. ADR-0131 D2
lists `bootstrapDeclaredSharingRules` among the retirements.
## Behavior-free pin
The full `@objectstack/plugin-security` suite was run before (base
`0fea05fe3`) and after (`539010f0`). Both runs: 196 files, 4,150 tests,
4,105 passed, 45 skipped, 0 failed. Compared by (file, full test name),
the two runs have the same set of keys and no status differs.
## Size
1,422 changed lines (+725 / −697) over 22 files, measured by
`dispatch-gates`. That is under the 3,000 line of batch #310 item 7.
## Local gates (on `539010f0`)
- **Build:** `pnpm --filter '@objectstack/plugin-security...' --filter
'@objectstack/plugin-auth...' build` exited 0.
- **Typecheck:** `pnpm --filter @objectstack/plugin-security --filter
@objectstack/plugin-auth typecheck` exited 0. That covers `tsc
--noEmit`, the scripts program and `check:test-typecheck` for both
packages.
- **Tests:** the `plugin-security` suite results are under
"Behavior-free pin" above.
- **`dispatch-gates --ran`:** 69 families derived, 66 run with exit 0, 3
NOT MEASURED, 0 unrun. The five roster gates whose roster sits under a
changed path also ran, and exited 0: `check-changeset-fixed`,
`check:auth-mount-ledger`, `check:authz-resolver`,
`check:error-code-casing` and `check:filter-alias-parity`.
- **The three NOT MEASURED (each exited 3, prerequisite refused):**
- `check:dual-build-cjs-loads` and `check:i18n` read every package's
`dist/`, and only this diff's closure was built.
- `check-plugin-teardown-shape --self-test` needs an unshallowed clone.
It is checker-health only.
- **Left to CI:** the repo-wide `pnpm lint` and the workspace type-check
lanes.
## Acceptance notes
- `scripts/check-logger-receiver-detach.mjs:503` carries a
control-fixture provenance comment naming `per-organization-catalog.ts`.
It is a gate script, which this stage does not touch. It goes stale when
6c deletes the module. Carrier: stage 6c.
- `scripts/engine-double-contract.pinned.json` pins
`per-organization-catalog.test.ts`. That test is not moved here: it
exercises the retired seeders and goes with them.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FNnkhcT29ev69L6LVnt5yt)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 87cd458 commit 2fbe1fd
22 files changed
Lines changed: 725 additions & 697 deletions
File tree
- .changeset
- packages/plugins
- plugin-auth/src
- plugin-security/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
48 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
| 399 | + | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
0 commit comments