Skip to content

Commit 2fbe1fd

Browse files
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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
---
4+
5+
Internal move with no behavior change: the organization-scoping helpers and the seed write-refusal accumulator leave `per-organization-catalog.ts` for two new internal modules, `organization-scope.ts` and `write-refusals.ts`
6+
7+
Clause-②: no

‎packages/plugins/plugin-auth/src/ensure-default-organization.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ interface BootstrapLogger {
118118
* injected a sink with no `error`.
119119
*
120120
* The spelling is `logSeedDurabilityFailure` in `plugin-security`'s
121-
* `per-organization-catalog.ts`, re-derived here rather than imported: that
121+
* `write-refusals.ts`, re-derived here rather than imported: that
122122
* helper is deliberately absent from `plugin-security`'s `index.ts` (an
123123
* intra-package helper, not public API), and `plugin-auth` does not depend on
124124
* `plugin-security` at runtime. Its two prohibitions are the measured part and

‎packages/plugins/plugin-security/src/auto-org-admin-grant.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {
5454
resolveOwnOrganizationRow,
5555
seedCtx,
5656
SEED_ORGANIZATION_SCAN_LIMIT,
57-
} from './per-organization-catalog.js';
57+
} from './organization-scope.js';
5858
import { GRANT_SET_ID_FIELD, GRANT_SET_NAME_FIELD, grantSetNameOf } from './grant-permission-set-name.js';
5959

6060
const SYSTEM_CTX = { isSystem: true } as const;

‎packages/plugins/plugin-security/src/bootstrap-builtin-positions.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@
4545
import { securityBuiltinPositions } from './builtin-positions.js';
4646
import {
4747
createSeedWriteRefusals,
48-
resolveOwnOrganizationRow,
49-
rowMatchesDeclaration,
50-
seedCtx,
51-
warnOrganizationLessRows,
5248
reportSeedWriteRefusals,
5349
type SeedLogger,
5450
type SeedWriteRefusals,
51+
} from './write-refusals.js';
52+
import {
53+
resolveOwnOrganizationRow,
54+
seedCtx,
55+
warnOrganizationLessRows,
56+
} from './organization-scope.js';
57+
import {
58+
rowMatchesDeclaration,
5559
} from './per-organization-catalog.js';
5660

5761
function genId(prefix: string): string {

‎packages/plugins/plugin-security/src/bootstrap-declared-capabilities.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ import {
8383
createSeedWriteRefusals,
8484
reportSeedWriteRefusals,
8585
type SeedWriteRefusals,
86-
} from './per-organization-catalog.js';
86+
} from './write-refusals.js';
8787
import { buildExistingByName, type ExistingByNameIndex } from './seed-name-lookup.js';
8888
import { readDeclared } from './bootstrap-declared-permissions.js';
8989
// [#18023] THE owner-comparison predicate, REUSED rather than re-derived. It

‎packages/plugins/plugin-security/src/bootstrap-declared-permissions.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ import {
6262
import { defaultPermissionSets } from './objects/default-permission-sets.js';
6363
import {
6464
createSeedWriteRefusals,
65+
reportSeedWriteRefusals,
66+
type SeedWriteRefusals,
67+
} from './write-refusals.js';
68+
import {
6569
resolveOwnOrganizationRow,
6670
seedCtx,
6771
warnOrganizationLessRows,
68-
reportSeedWriteRefusals,
69-
type SeedWriteRefusals,
70-
} from './per-organization-catalog.js';
72+
} from './organization-scope.js';
7173
import {
7274
permissionSetNameCollisionDiagnostic,
7375
permissionSetNameIsForeign,

‎packages/plugins/plugin-security/src/bootstrap-declared-positions.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ import { buildExistingByName } from './seed-name-lookup.js';
4040
import { isBuiltinPositionName } from './builtin-positions.js';
4141
import {
4242
createSeedWriteRefusals,
43-
seedCtx,
44-
warnOrganizationLessRows,
4543
reportSeedWriteRefusals,
4644
type SeedLogger,
4745
type SeedWriteRefusals,
48-
} from './per-organization-catalog.js';
46+
} from './write-refusals.js';
47+
import {
48+
seedCtx,
49+
warnOrganizationLessRows,
50+
} from './organization-scope.js';
4951

5052
function genId(prefix: string): string {
5153
const rand = Math.random().toString(36).slice(2, 10);

‎packages/plugins/plugin-security/src/bootstrap-platform-admin.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import {
8989
createSeedWriteRefusals,
9090
reportSeedWriteRefusals,
9191
type SeedWriteRefusals,
92-
} from './per-organization-catalog.js';
92+
} from './write-refusals.js';
9393
import { reportThroughSink } from './seed-refusal-sink.js';
9494
import {
9595
resolvePlatformAdminStanding,
@@ -396,7 +396,7 @@ async function tryFind(
396396
// write indistinguishable from "nothing to do": `seeded` never grows, the pass
397397
// returns normally, and the boot reports a successful seed of zero rows. Still
398398
// no rethrow — this pass reports, it does not decide whether the deployment
399-
// boots. See `reportSeedWriteRefusals` in `per-organization-catalog.ts`.
399+
// boots. See `reportSeedWriteRefusals` in `write-refusals.ts`.
400400
async function tryInsert(
401401
ql: any, object: string, data: any, refusals?: SeedWriteRefusals,
402402
// Symmetric with {@link tryFind}'s observer, and for the same reason: a

‎packages/plugins/plugin-security/src/bootstrap-system-capabilities.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ import {
217217
logSeedDurabilityFailure,
218218
type SeedLogger,
219219
type SeedWriteRefusals,
220-
} from './per-organization-catalog.js';
220+
} from './write-refusals.js';
221221

222222
const SYSTEM_CTX = { isSystem: true };
223223

‎packages/plugins/plugin-security/src/cleanup-package-permissions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import {
3131
createSeedWriteRefusals,
3232
type SeedWriteRefusals,
33-
} from './per-organization-catalog.js';
33+
} from './write-refusals.js';
3434

3535
const SYSTEM_CTX = { isSystem: true };
3636

0 commit comments

Comments
 (0)