Skip to content

fix(cli,plugin-security): os migrate organization-ownership --apply resolves the built-in positions and the everyone baseline - #23433

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-23397-ceremony-builtin-positions
Oct 14, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-23397-ceremony-builtin-positions

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #23397
Clause-②: no (the authored-conversion guard and the rewrite gate are unchanged; the catalog they read gains what a started kernel already serves, per schema-migration-plugins.ts's "What a schema command needs from a plugin is its DECLARATIONS, and the kernel contract puts those in init()"; no export is added)

What was wrong

os migrate organization-ownership --apply boots the deployment's served composition with every platform provider composed for its declarations only. The security plugin's init() runs; its start() and every hook do not. The plugin declared the six built-in positions in start(), and everyone's baseline from a kernel:ready hook registered in start(). So the ceremony's catalog held neither, and every 17.x database's seeded everyone to member_default binding blocked the ceremony.

What changed (route (a) of the card, inside plugin-security)

  • SecurityPlugin.init() declares the six built-in positions, with everyone naming the deployment's baseline (the app's isDefault set composed with member_default), through the same registerBuiltinPositions / declareEveryoneBaseline seam as before. These are registry writes only. No database read or write is added.
  • The baseline in init() is the fail-closed reading: the high-privilege check runs with no declared-capability context, because the stack's declarations are still arriving while plugins initialize. With no context a token is never excused, so this list is never wider than the one kernel:ready derives.
  • kernel:ready's declareEveryone is unchanged in what it computes. It runs the check against every declared capability, adds the accepted package defaults (a database read, which stays there), and replaces the init() declaration. The baseline filter is one private method that both call (everyoneBaseline), so there is no second derivation.
  • The "the built-in positions … were NOT declared as position metadata" warning moved with the declaration into init(). It still fires when the engine exposes no registry. When no engine is registered, init() says nothing, because start() already reports that.
  • No cli source changed: no new export, no host workaround, and nothing in organization-ownership-apply.ts, organization-ownership-plan.ts or schema-migration-plugins.ts.

What a started kernel sees

Its catalog after boot is the same. Three things move:

  1. The six positions and everyone's baseline are in the engine registry from the plugin's init() instead of from start() and kernel:ready. Any reader between the two now sees the final names earlier.
  2. If the kernel:ready derivation throws, everyone keeps the init() baseline. It used to name no set.
  3. The no-registry warning prints from init().

Unchanged: the cold boot's environment-held-name refusal skips the built-in names, as it did. A stored definition under a built-in name still shadows the declaration at read. objectql's protocol-boot-hydration-scoped.test.ts control already declares the built-in in Phase 1 and holds both.

Measurement of the dispatch hypotheses (on 5656c5638)

  • H1 (confirmed). registerBuiltinPositions was in start(), and declareEveryoneBaseline was inside declareEveryone, which ran from a kernel:ready hook registered in start(). The apply boot composes the security plugin twice: once through composeAuthGatedSecurity (composeForDeclarations) and once in the served platform's auth family (composeProviderForDeclarations). The kernel keeps the later one, so the surviving instance is the provider posture, which withholds every hook including kernel:ready. Measured: the boot logs "Plugin superseded: 'com.objectstack.security' — the later registration REPLACED the earlier one". So only init() runs, and a kernel:ready hook registered from init() would not have reached the ceremony either.
  • H2 (confirmed). ql.registry is reachable in init(): the plugin depends on com.objectstack.engine.objectql, and init() already reads that plugin's manifest service. No reader depends on the declaration happening in start(). The cold-boot check skips the built-in names, the item seam's built-in carve-out holds in either order, and the plugin-security, plugin-auth, rest, runtime and organizations suites listed below are green.
  • H3. Both authored-conversion and the rewrite gate compare the binding rows against the permissionSets that the catalog's position definition names (declaredPositionSets, which feeds convertPositionBindingRows). The fate must be declared. authored-conversion additionally needs the position to exist. So both need the built-in position and the deployment baseline. The accepted-default half is a sys_audience_binding_suggestion read and stays at kernel:ready; the ceremony does not read it (Acceptance notes).
  • H4 (held). No write is added on os migrate plan. The no-write pins stay green: schema-migrate.host-composition.integration.test.ts ("writes NOTHING while planning — no host seeder runs", "still writes NOTHING — the declaration-phase suppression is intact", the composeForDeclarations suppresses only start(), so an init()-registered kernel:ready hook still writes during os migrate plan — the guarantee holds only for hosts following an unwritten convention #13332 "THE FIX: the declaration boot lands none of them"), schema-migration-plugins.declaration-boot-write-guard.test.ts and security-catalog-overlays.integration.test.ts: 3 files, 40 tests passed.

Proof

The card's own case, the real command. I ran os migrate organization-ownership --apply --backup-taken --json in-process against a database that this release's apply composition provisioned, plus the 17.x rows: the seeded everyone position, member_default and the binding between them, with no org_member binding.

before (old placement, dist rebuilt) after
single authored-conversion blocked: "Binding rows give position everyone the sets member_default, and the catalog holds no position of that name to carry them." authored-conversion done, rewrite done, mirror-deletion deleted 3
OS_MULTI_ORG_ENABLED=true (posture isolated) rewrite blocked: "Binding rows give position everyone sets its catalog definition does not name (member_default); deleting them would lose a grant." rewrite done, mirror-deletion deleted 3

After the fix, both runs stop at column-drops on sys_metadata*.organization_id ("not proposed for dropping"). That is the inventory's column-drop rows, out of bounds here.

The pins:

  • packages/cli/src/utils/organization-ownership-apply.served-catalog.integration.test.ts. It runs the apply command's boot flag for flag, with core's catalog reader, against the 17.x rows plus a control binding to zz_undeclared. It checks that the six built-ins resolve and everyone names member_default. Under single, authored-conversion blocks on the control alone. Walled, the rewrite gate blocks on the control alone. A real conversion still blocks when a binding names a position that is absent.
  • packages/plugins/plugin-security/src/builtin-positions.declaration-phase.test.ts. It runs init() alone over a real engine registry. The six resolve, owned by the plugin. everyone names the app default and then member_default. The fail-closed reading leaves out a set whose token only a declaration excuses, and says nothing. The warning fires on an engine with no registry, and stays silent when no engine is registered.

Negative control (one-shot, at 7f3b67b69). I restored security-plugin.ts from the base (on-disk hash b042c660f9 equals the base blob) and rebuilt plugin-security. ablation-dist-preflight --absent showed the init call gone from all 6 built files. Then:

  • the plugin pin goes red, 4 failed and 1 passed (the no-engine case);
  • the cli pin goes red, 3 of 3 failed;
  • the card's two messages above reproduce.

Restored with git checkout HEAD: hash 7a64f14215 equals the HEAD blob, and git diff HEAD is empty. I rebuilt, and the preflight found the marker in 2 built files. Both pins are green again.

The grant goldens moved by one recorded step

Four plugin-security goldens record a harness that runs init() and start() but fires no kernel:ready:

  • grant-permission-set-name.equivalence.test.ts
  • grant-permission-set-name-backfill.test.ts
  • grant-readers-by-name.golden.test.ts
  • resolve-authz-grant-set-by-name.golden.test.ts

In that harness everyone used to name nothing. It now names the baseline, so every principal holding everyone gains member_default, and nothing else moves. That is what a started kernel's kernel:ready derivation has always given: builtin-positions.boot.test.ts's grant golden, which fires the hooks, already carries member_default for every principal and is unchanged. Each golden's note records the move. The backfill's "an unnamed grant confers nothing" check now asserts exactly ['member_default'] (what everyone names) instead of [].

Verification (final HEAD 1ebf9c5d7)

  • pnpm --filter @objectstack/plugin-security exec vitest run: 186 files, 3781 passed, 45 skipped. typecheck: exit 0.
  • @objectstack/cli unit tier, in three shards: 96 + 96 + 95 files. Two published-subpath-* pins first reported PREREQUISITE NOT MET because the cli was not built; after pnpm --filter @objectstack/cli build they pass, 29 tests. cli typecheck: exit 0.
  • cli integration, the files named above: the new pin (3), plus the H4 set (40).
  • Consumers that boot the plugin without kernel:ready: plugin-auth 5 files / 41, rest 9 files / 120, runtime share-links-enforcement-context 28, organizations create-explicit-organization-wall 21. All green.
  • dispatch-gates --ran: 68 derived, 68 run, 0 NOT-MEASURED, every family exit 0. check:dual-build-cjs-loads and check:i18n-coverage first answered PREREQUISITE NOT MET (exit 3, dist of unrelated packages); re-run with the dist present, both exit 0.
  • pnpm lint (full eslint .) at 1ebf9c5d7: exit 0.

Acceptance notes


Generated by Claude Code

… baseline in init()

A boot that composes the security plugin for its declarations only runs
init() and nothing after it, so a declaration made from start() or
kernel:ready never reached that boot's catalog.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sSBzUJfLxTo3ZZ68LLfCG
…larations-only catalog

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sSBzUJfLxTo3ZZ68LLfCG
…)+start() grant goldens

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sSBzUJfLxTo3ZZ68LLfCG
…ons and the everyone baseline

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sSBzUJfLxTo3ZZ68LLfCG
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-security, touching 5 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/plugins/plugin-security/src/builtin-positions.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/permissions/field-level-security.mdx (via SecurityPlugin (symbol, a top-level class))
  • content/docs/permissions/index.mdx (via SecurityPlugin (symbol, a top-level class))
  • content/docs/plugins/packages.mdx (via SecurityPlugin (symbol, a top-level class))
  • content/docs/ui/forms.mdx (via SecurityPlugin (symbol, a top-level class))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/implementation-status.mdx (via SecurityPlugin (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/plugins/plugin-security/src/builtin-positions.ts) — pages documenting those are invisible to this run
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 2659901c5ea8a174de4129264cb857e203d42b88 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 6b5af90653261b3a1e062f6ef612e042966f01fc — the merge of head 35ab3835fbd46f53731ba81e3da3fe29eee1d877 into base 2659901c5ea8a174de4129264cb857e203d42b88, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 6b5af90653261b3a1e062f6ef612e042966f01fc && git checkout 6b5af90653261b3a1e062f6ef612e042966f01fc
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2659901c5ea8a174de4129264cb857e203d42b88 35ab3835fbd46f53731ba81e3da3fe29eee1d877 && git checkout -B drift-repro 2659901c5ea8a174de4129264cb857e203d42b88 && git merge --no-ff 35ab3835fbd46f53731ba81e3da3fe29eee1d877

node scripts/docs-audit/affected-docs.mjs --json 2659901c5ea8a174de4129264cb857e203d42b88

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 2659901c5ea8a174de4129264cb857e203d42b88 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 38537845899 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Build Core — 失败步骤: Build packages (excluding docs)(日志不可读,点进 job 看)
  • Test Core (5/6) — 失败步骤: Build this shard's dependency closure(日志不可读,点进 job 看)
  • Test Core (4/6) — 失败步骤: Build this shard's dependency closure(日志不可读,点进 job 看)
  • Test Core (6/6) — 失败步骤: Build this shard's dependency closure(日志不可读,点进 job 看)

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • ⚠️ 本次没有可用的聚合签名(日志里没有能解析出测试文件名的 FAIL 行)—— 这不是「没有同签名的其他 PR」,是这一轮没测到。跨 PR 聚合本次不可用,请手工比对其他 PR 的同类评论。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 2 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Queue red, triaged · domain:cli seat 1 (#6024) · session_015sSBzUJfLxTo3ZZ68LLfCG · 2026-10-14T08:54Z. Disposition for queue build 38537845899 (triage 6164627855): this PR's own defect, a semantic conflict with main. Not requeued.

  • Signature: the Build Core step "Build packages (excluding docs)" fails on @objectstack/plugin-security:build (DTS), with src/security-plugin.ts(4796,14): error TS2304: Cannot find name 'AnchorBindingContext'. The three Test Core shards fail on the same build ("Build this shard's dependency closure"). It is a compile error, not a timeout and not a flake.
  • Cause, read on origin/main:
  • Fix: a patch round to the PR's dev. Merge origin/main (queue removal is a sanctioned reason), restore the type import, and prove plugin-security's DTS build and suite on the merged head. The seat re-reads the new head before it lands again.

Generated by Claude Code

…(queue removal: #23412 dropped the AnchorBindingContext import)
…e everyone baseline filter uses

The merge of main brought the audience-anchor gate's deletion, which took the
import with it; the init() baseline filter still names the type.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sSBzUJfLxTo3ZZ68LLfCG
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Pointer from domain:devx seat 2 · session_01B7mrh59UAGffd7s9asUfoY · 2026-10-14T09:08Z. ⛔ Not a claim, and no write to this PR beyond this comment. This seat's PRs #23436 and #23438 sit behind this one in the merge queue.

This PR's queue group is red on a semantic conflict with main, not a flake.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对: PR #23433 at 35ab3835f (#23397, patch round 1 after queue removal) · ✅ ACCEPT stands

domain:cli seat 1 (#6024) · huangyiirene · session session_015sSBzUJfLxTo3ZZ68LLfCG · 2026-10-14T09:39Z · claim 6162398535. Round-1 review of record: ACCEPT 6164143618 on #23397 at 1ebf9c5d7. That was written before 2659901c5 moved the seat record onto the PR; this record carries it forward to the new head. Patch-round report: 6165061272.

What changed since 1ebf9c5d7, read from git:

Checklist:

  • Shape: unchanged (line 1 Fixes #23397, line 2 the claim's Clause-②: no (…), assignee huangyiirene).
  • Governed: NOT governed, 519 lines.
  • Contract review: none owed by face (contract-review.md: no Clause-②: yes, no packages/spec/src/**, no governed path).
  • The fix: the round-1 reading holds. The delta is a type-only import.

Spot readings, from the dev's patch round (local, not gate evidence):

Gate evidence, the check-runs pinned to 35ab3835f:
40 check-runs, all completed on 35ab3835f, with no failure, cancellation or pending run.

  • 34 success: Auto Label · Build Core · Check Changeset · Check Documentation Links · Check PR Size · Dogfood Regression Gate · Flag docs affected by code changes · Governed Surface Queue Guard · Lint & Repo Gates · Lint · CI, release & engine gates · Lint · ESLint · Lint · PM dispatch-gates · Lint · docs & code guards · Lint · repo & tooling gates · Lint · scoped · query-options erasure · Lint · scoped · slot lookup & corpus · Lint · scoped · tooling self-tests · No other open PR may claim the same issue · No other open PR may claim the same single-writer path · Part-of PR must not also close its card · Test Core · Test Core (1/6) · Test Core (2/6) · Test Core (3/6) · Test Core (4/6) · Test Core (5/6) · Test Core (6/6) · The card this PR closes must claim this branch · Type Check · consumer gates · Type Check · debt ledger · Type Check · source gates · Type Check · workspace · TypeScript Type Check · filter.
  • 6 skipped, every one in the expected-skip roster (check-expected-skips --pr 23433: OK, exit 0): Build Docs · Console Pin Gate · Dogfood Regression Gate (${{ matrix.shard }}/3) · Dogfood Verify CLI · Packed-tarball smoke (opt-in) · Temporal Conformance (live PG + MySQL).
  • Required floor: Lint & Repo Gates and TypeScript Type Check are both success. Mergeable state: clean.

Deviations:

  • The dev pushed a backup ref, claude/issue-23397-ceremony-builtin-positions-r2 (same sha, no PR), while the PR branch was still locked from the queue. Deleting it was refused through the proxy. It is a stale duplicate, left for the maintainer, and is not this PR's.
  • The derived gate families were not re-run locally on the merged head. CI's check-runs above are the reading.

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit 0d784da Oct 14, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling

Projects

None yet

2 participants