Skip to content

fix(runtime): an un-walled boot seed's person references resolve to the first admin once that admin exists - #34516

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-34458-unwalled-seed-person-refs
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-34458-unwalled-seed-person-refs

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #34458
Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:单租户(未开组织隔离墙)首次启动时,种子数据里指向首个管理员的人员字段(负责人、审核人等)在管理员账号创建后会被自动补上,不再永久留空。
  • 为什么改:种子先于首个管理员落库,人员引用解析不到就写成空;此前只有 owner_id 会被交接,示例记录的负责人、审核人一直显示为"未分配",后续启动也不会修复。
  • 风险与回滚:只回填种子自己写入、且该列仍为空的行;访客写的行和期间被人手动改过的值都不动。回滚即 revert 本 PR,已回填的值保留,不影响其它数据。
  • 先看:packages/runtime/src/app-plugin.ts 的 registerSeedPersonReferenceHandoff(sys_user 插入后触发);packages/metadata-protocol/src/seed-loader.ts 的 resolveHeldPersonReferences(按行 id 加列为空条件写入);packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/organizations exec vitest run src/default-organization-seed-owner.wall.test.ts,预期 5 个用例全绿,未开墙用例里 assignee、reviewer、owner_id 都等于管理员 id。
  • 需要你做的:无,席位落地。

What changes

On an un-walled (single-tenant) first boot the inline boot seed loads before the first admin's sys_user row exists, so a Field.user() / Field.lookup('sys_user') value naming that admin landed NULL. The first-admin handoff (claimSeedOwnership) writes owner_id only, and a later boot's replay of a create-only dataset leaves an existing row as it is, so assignee / reviewer style columns stayed NULL for good.

  • packages/metadata-protocol/src/seed-loader.ts: pass 2 now holds each person reference it left NULL (target sys_user, row id known) as a HeldPersonReference. New SeedLoaderService#resolveHeldPersonReferences() retries them with the loader's own resolveReferenceItem (same organization), and writes a resolved value with a compare-and-set update by row id and FIELD = null. So a row the seed did not write is never reached (ADR-0138 D1), and a value set since is kept. Retries are serialized. A reference that still misses stays held. heldPersonReferenceCount() reports how many are held. The held list resets per load.
  • packages/runtime/src/app-plugin.ts: after the inline boot seed, AppPlugin keeps the loader while it holds references. A new ObjectQL middleware (registerSeedPersonReferenceHandoff) runs the retry after every sys_user create/insert and releases the loader once it holds none. Failure is best-effort and logged at warn, like the tenancy handoff beside it. The user insert always stands.
  • The walled boot is unchanged: it writes no inline seed, and its per-organization replay already waits for the owner's membership (fix(organizations): the walled Default Organization's seed resolves its bound owner #34457).
  • No change under packages/spec/src/**; no contract change. The new loader methods are on the concrete SeedLoaderService class and are not part of ISeedLoaderService.
  • Changeset .changeset/34458-unwalled-seed-person-refs.md: patch on @objectstack/metadata-protocol and @objectstack/runtime.

Tests

packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts. This is the forced test change the card names:

  • The CONTROL describe is flipped as the card's Done-when requires. It was titled control: the same seed on an un-walled boot reads as it did before the fix and asserted assignee: null, reviewer: null, owner_id: adminId. It is now titled the same seed on an un-walled boot resolves the first admin once that admin exists and asserts assignee, reviewer and owner_id all equal the admin id.
  • New describe un-walled: a held seed person reference fills only the seed's own rows, and only while still NULL. Its PREMISE leg shows the reference is NULL before the named person signs up, and that the admin's insert did not fill it. Its main leg covers three rows. The seed's row resolves to the late person once they exist. A seeded row assigned by hand in the meantime keeps that assignment. A guest-written row with a NULL person stays NULL (the ADR-0138 D1 negative leg).

Ablation (one-shot, not kept). The handoff's loader read in app-plugin.ts was replaced with an always-undefined read through scripts/ablation-replace.mjs. The marker was proved in packages/runtime/dist with ablation-dist-preflight.mjs (exit 0) after a rebuild. The organizations suite then went red on exactly the two new/flipped legs: Tests 2 failed | 3 passed (5). Restore leg: blob hash equal to HEAD, rebuild, preflight --absent exit 0, then Tests 5 passed (5).

Suite readings (locked runs, on e2ab3fd; the later merge of origin/main 6c7d730 touches none of these packages)
  • pnpm --filter @objectstack/metadata-protocol test: exit 0, Test Files 346 passed | 9 skipped (355), Tests 22968 passed | 45 skipped (23013)
  • pnpm --filter @objectstack/organizations test: exit 0, Test Files 20 passed (20), Tests 264 passed (264)
  • pnpm --filter @objectstack/runtime test: exit 0, Test Files 609 passed (609), Tests 11271 passed | 19 skipped (11290)
  • pnpm --filter @objectstack/metadata-protocol --filter @objectstack/runtime --filter @objectstack/organizations typecheck: VERDICT command-exit 0, all three Done
  • Focused re-run after the last code commit (build metadata-protocol + runtime, wall test, three seed-loader suites): VERDICT command-exit 0; wall test Tests 5 passed (5); seed-loader suites Tests 58 passed (58)
Ablation readings
  • Mutation leg: anchor hit (injected marker count 1, original line count 0), pnpm --filter @objectstack/runtime build exit 0, ablation-dist-preflight.mjs @objectstack/runtime '__ABLATION_34458__' exit 0. Wall test: × the wall is down, the seed landed once before the admin existed, and every person reference naming the admin resolves to the admin, × the seed's NULL reference resolves to the person once they exist; the guest row and the hand assignment stand, Tests 2 failed | 3 passed (5).
  • Restore leg: restored blob equals the HEAD blob, rebuild exit 0, preflight --absent: marker absent from all 12 built files, then Test Files 1 passed (1), Tests 5 passed (5).

Acceptance notes

Verification

Gate sweep: node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 72 families for this diff. Each was run with stdin closed and its exit code captured before any pipe. Reconciliation with --ran reports 72 derived, 72 run, 0 NOT-MEASURED, 0 UNRUN. Two families first answered exit 3 (PREREQUISITE NOT MET) and were re-run once the prerequisite was met. check-plugin-teardown-shape --self-test needed its pinned fixture commit fetched, then exited 0 with 48 cases. check:dual-build-cjs-loads needed every package built, then exited 0 with 124 entry points across 72 packages.

Head and gate provenance
  • Lines 1 to 67 of the sweep ran on e2ab3fd. The run was interrupted by a container restart and resumed. The last 5 families and the two re-runs ran on 0916d33, which is e2ab3fd plus a merge of origin/main 6c7d730. That merge touches none of the 4 files of this diff, and the re-derivation on 0916d33 lists the same 72 commands.
  • check:type-check-debt: exit 0, 0 ledger entries re-measured, 0 raw tsc errors.
  • CI has not been awaited; its check-runs are the record for the families CI runs.

… the person exists

The inline boot seed runs before the first admin's sys_user row exists, so a
person reference naming that admin lands NULL after pass 2. The seed loader now
holds such references (on the rows it landed on) and AppPlugin retries them
after each sys_user insert, writing each one that resolves only while the
column is still NULL.

Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz
Co-authored-by: Claude <noreply@anthropic.com>
…ed's own NULL columns (ADR-0138 D1)

Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/metadata-protocol, @objectstack/runtime, touching 17 documentable anchor(s).

52 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 0c7869c03c9c6ff3a38bd6b09206edeee0184769.

⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 cross-cutting symbol(s) contributed no route anchor: recordId (4 routes)
  • 2 anchor(s) matched too much of the corpus to be a work list: objectName (symbol, 58 pages), sys_user (literal, 55 pages)
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 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 — 35 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 0c7869c03c9c6ff3a38bd6b09206edeee0184769 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from fb02f7a29115e6eda2dfc28e5305fedf395a9c37 — the merge of head 0916d339e426a32f029081870c5764bc546b81ce into base 0c7869c03c9c6ff3a38bd6b09206edeee0184769, 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 fb02f7a29115e6eda2dfc28e5305fedf395a9c37 && git checkout fb02f7a29115e6eda2dfc28e5305fedf395a9c37
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0c7869c03c9c6ff3a38bd6b09206edeee0184769 0916d339e426a32f029081870c5764bc546b81ce && git checkout -B drift-repro 0c7869c03c9c6ff3a38bd6b09206edeee0184769 && git merge --no-ff 0916d339e426a32f029081870c5764bc546b81ce

node scripts/docs-audit/affected-docs.mjs --json 0c7869c03c9c6ff3a38bd6b09206edeee0184769

⚠️ 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 0c7869c03c9c6ff3a38bd6b09206edeee0184769 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

Final head for review: 0916d339e426a32f029081870c5764bc546b81ce (card #34458, branch claude/issue-34458-unwalled-seed-person-refs). CI on this head: 35 success, 16 skipped, 0 failed. Owed: L1 first review. Clause-②: no, Metadata-protocol: none, no contract surface, so no contract-tier review is owed. packages/metadata-protocol/src/seed-loader.ts is shared with open PR #34429; git merge-tree against its head is clean. A push after this comment restarts the review on the new head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W

席位核对

L1 first review · ACCEPT · head 0916d339e426a32f029081870c5764bc546b81ce · card #34458 · read 2026-11-17T00:20Z

Checklist (read on GitHub at this head, not from the report)

  • Shape: draft, base main, body opens Fixes #34458. Closing-keyword scan of the whole body: one hit, #34458; the #34457 and #34429 mentions carry no keyword. Fixes is right: the card's done-when (the un-walled CONTROL leg flips to the admin id) is the flipped describe.
  • File surface: 4 files from get_files, all named in claim 6931025801: packages/metadata-protocol/src/seed-loader.ts (listed "only if the person-reference resolution must move there", and it did), packages/runtime/src/app-plugin.ts, the wall test, the changeset. The claim's plugin-security files are untouched. Merges e2ab3fd2 and 0916d339 bring main in; the three-dot diff holds only these 4.
  • Serial constraint: seed-loader.ts is shared with open PR fix(cloud-connection): install-local keeps and honours the landed-key record, so a seed row a tenant deleted stays deleted #34429; the body records git merge-tree --write-tree against refs/pull/34429/head exiting 0. Whichever of the two lands second re-reads that intersection on its landing head.
  • Changeset: .changeset/34458-unwalled-seed-person-refs.md, patch on @objectstack/metadata-protocol and @objectstack/runtime, both published (no private); @objectstack/organizations is touched by a test only. Sentences checked against the diff: "holds each person reference its second pass left NULL, together with the row it landed on" (the push guarded by stillUnresolved && deferred.targetObject === SystemObjectName.USER && heldRowId); "writes it to that row only while the column is still NULL" (where: { id: held.recordId, [held.field]: null }); "A row the seed did not write keeps its value" (only held row ids are ever written); "A reference that still names nobody stays held until the next user insert of the process" (stillHeld, and the middleware fires on sys_user create / insert only); "The walled boot is unchanged" (the loader is kept only on the inline boot seed path).
  • Mechanism read: retries are serialized through heldPersonRetry; the held list resets per load; the middleware runs after next(), returns at once when no loader is held, and releases the loader when held === 0; a failed retry is caught and logged at warn, so the user insert stands. A failed back-fill write is kept held and logged at error with the row, field and cause.
  • Tests: the CONTROL describe flipped as the card requires (assignee, reviewer, owner_id all equal the admin id). The new describe has a PREMISE leg (NULL before the named person signs up, not filled by the admin's insert) and three outcome rows. The hand-assigned row keeping adminId pins the [field]: null compare-and-set; the guest row staying NULL pins ADR-0138 D1. No refusal path is added, so no code/status assertion is owed.
  • Positive control: ablation of the handoff's loader read, proved in packages/runtime/dist by ablation-dist-preflight.mjs (the organizations suite imports built runtime), turns exactly the two new or flipped legs red (2 failed | 3 passed); restore leg proves the marker absent and 5/5 green.
  • Gates at this head: check-runs on 0916d339…: 51 runs, 35 success, 16 skipped, 0 failed; Lint & Repo Gates, TypeScript Type Check and Dogfood Regression Gate success. Derived-gate round 72/72 (--ran: 0 NOT-MEASURED, 0 UNRUN).
  • Accepted deviation: the derived-gate sweep spans two heads (e2ab3fd2 for 67 families, 0916d339 for the rest) after a container restart; the merge between them touches none of the 4 files, and CI on the final head is the record.

Out of scope, for the area to place (one line each: filed #N or dropped — reason)

  • Acceptance note 1: the held references live in process memory, so a restart between the boot seed and the first admin's sign-up loses them. Not measured; a durable retry is a spec change (seed-settlement contract).
  • Acceptance note 3: the pass-2 UNRESOLVED log still reads "No further seed pass retries this" while a held retry now follows for sys_user targets. Literally true, but an operator reading it may conclude the NULL is final.

Body, no push

  • The body has no attribution header; the project's two lines (the claude-projects-attribution comment and the "Requested by" line) open every PR body. A body edit.

Owed after this

  • L2: not owed. Clause-②: no, Metadata-protocol: none, no (narrowing), no packages/spec/src/**, no governed path.
  • Landing tier: node scripts/pm/check-governed-merges.mjs --pr 34516: 0 of 4 paths governed, 306 changed lines (+297 / −9) ≤ 3000 ⇒ ordinary queue landing by the area, on this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

Landing 0916d339e426a32f029081870c5764bc546b81ce (card #34458) on L1 ACCEPT 6933601260 at this head. No L2 owed (Clause-②: no, no contract path).

probe reading
check-governed-merges.mjs --pr 34516 NOT governed, 0 of 4 paths; 306 changed lines ≤ 3000
git merge-tree --write-tree of this head against open PR #34429 2a00228cf (shared seed-loader.ts) and origin/main ec6b5fd34 both exit 0; main is 4 first-parent commits past the merge base

Body: attribution header added; the two Acceptance notes now read "Filed: #34542" (held references in process memory) and "Dropped" (the pass-2 log text, still literally true). State: ready, auto-merge armed.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 00:25
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit d0348cf Nov 17, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34458-unwalled-seed-person-refs branch November 17, 2026 00:53
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/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

organizations: on an un-walled first boot, seed person references to the first admin land NULL, and only owner_id is handed over

2 participants