Skip to content

fix(metadata-protocol): seed replay matches a global object's rows unscoped - #33570

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/area-A4-33554
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/area-A4-33554

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread
Fixes #33554
Clause-②: no
Metadata-protocol: none

Stacked on #33550 (not merged when this was opened): this branch is cut from claude/area-A4-33411 and its diff against main carries #33550's two commits until that lands.

维护者速读

  • 改了什么:按组织重放种子数据时,全局对象(无组织列、未声明租户字段,例如 tenancy: { enabled: false })的已有行改为不按组织过滤匹配,所有组织的重放都更新同一条共享行。
  • 为什么改:原先对这类对象按 organization_id 过滤,该列不存在,驱动直接抛 INVALID_FILTER,种子行落不了地。
  • 风险与回滚:只影响全局对象的重放匹配,判定复用引用探针已有的 global 判据(一处读法);回滚即 revert 本 PR。
  • 先看:packages/metadata-protocol/src/seed-loader.ts 的 isGlobalSeedObject 与 loadExistingRecords 里的过滤分支;packages/runtime/src/seed-org-scoped-references.integration.test.ts 末尾新增的 describe。
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run src/seed-org-scoped-references.integration.test.ts,预期 23 个用例全绿。
  • 需要你做的:无,席位落地(须待 fix(metadata-protocol): seed replay matches and stamps an object on its declared tenant column #33550 先合入)。

What changes

  • packages/metadata-protocol/src/seed-loader.ts
    • New module predicate isGlobalSeedObject(objectName, definition): an author's object (no managedBy) with no organization column (declared or injected) that resolves no tenant field, excluding sys_user / sys_organization. This is exactly the predicate probeScopeOf used inline for its global scope; probeScopeOf now calls it, so the reference probe and the replay match share one reading.
    • organizationColumnOf answers null for a global object, and loadExistingRecords then reads existing rows unscoped on a per-organization replay. Every organization's replay upserts the one shared row instead of throwing the driver's INVALID_FILTER on a nonexistent organization_id.
    • Stamp side checked, no code change needed: a global object always gets null from seedRowTenantColumn (no organization column, no tenant field), so its rows are neither stamped nor refused for a column they do not have. The new test pins it.
    • Review nit N1 on fix(metadata-protocol): seed replay matches and stamps an object on its declared tenant column #33550: the organizationColumnOf jsdoc and the loadExistingRecords jsdoc now each sit directly above their own method.
  • packages/runtime/src/seed-org-scoped-references.integration.test.ts: a new top-level describe on the real AppPlugin + SqlDriver (better-sqlite3) harness. In the first case, two organizations replay crm_country (tenancy: { enabled: false }) upsert on name: North inserts 1, South inserts 0, exactly one Japan row exists with no organization, and a second replay by both is idempotent. In the second case, a load with no organization (two organizations, no pin) writes the global row instead of refusing it.
  • Changeset: @objectstack/metadata-protocol patch.

Tests

All runs are at head 5d02c2e281.

  • pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/seed-org-scoped-references.integration.test.ts: Test Files 1 passed (1), Tests 23 passed (23). fix(metadata-protocol): seed replay matches and stamps an object on its declared tenant column #33550's tenantField cases and the organization_id control are green.
  • pnpm --filter @objectstack/metadata-protocol test: Test Files 340 passed | 9 skipped (349), Tests 22866 passed | 43 skipped.
  • pnpm --filter @objectstack/metadata-protocol typecheck exited 0, and so did pnpm --filter @objectstack/runtime typecheck.
  • eslint --no-inline-config on both changed source files exited 0.
  • Ablation via scripts/ablation-replace.mjs, at commit 5d02c2e281, with a metadata-protocol rebuild on each leg (runtime resolves it through dist/).
    • Mutation: the unscoped branch was replaced with the old organization_id fallback filter. ablation-dist-preflight found the marker in 2 built files, and the result was Tests 1 failed | 22 passed. The failing case is "two organizations replay it: exactly one shared row…".
    • Restore: blob equals HEAD and git diff HEAD is empty. After the rebuild, preflight --absent found the marker absent from all 24 built files and the tree clean.
    • The no-organization case stays green under the mutation, as expected: it pins the stamp side, which this diff does not change.

Verification

node scripts/pm/dispatch-gates.mjs --commands derived 64 local families at 5d02c2e281. Their run status and any NOT MEASURED entries are in the os-dev report on #33554. The full runtime package suite and test:repo are left to CI (Test Core).

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC

…ts declared tenant column

A per-organization replay matched the existing rows of every dataset on
organization_id, so a dataset of an object walled by a declared
tenancy.tenantField (and no organization_id column) was refused by the
driver as INVALID_FILTER. The match now runs on the column the object is
walled by (resolveTenantFieldName, organization_id when it resolves none),
and the seed stamp, the unowned-row refusal and the row-organization reads
use the same column.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
…scoped

A per-organization replay filtered the existing rows of every dataset by
organization, so a dataset of an object with no organization column and no
tenant field (tenancy disabled) was refused by the driver as INVALID_FILTER.
The match now reads such an object unscoped, keyed on the same predicate the
reference probe's global scope uses, so every organization's replay upserts
the one shared row.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
@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 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/metadata-protocol, touching 5 documentable anchor(s).

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

  • content/docs/data-modeling/validation.mdx (via SeedLoaderService (symbol, a top-level class))
  • content/docs/protocol/objectql/state-machine.mdx (via SeedLoaderService (symbol, a top-level class))

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

  • content/docs/releases/v17/17-1.mdx (via SeedLoaderService (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
  • 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 — 10 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 b95d915688b384bb9ae770c163fa425eb87cf0e4 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json b95d915688b384bb9ae770c163fa425eb87cf0e4

⚠️ 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 b95d915688b384bb9ae770c163fa425eb87cf0e4 → 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

Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head 875ddcc · 2026-11-15T01:43:49Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Review: PASS

review#2 (server area pilot) · area A4 · Fixes #33554 (p2) · head 875ddcc4156a1c8741bfeab0d4fdbe84165586c8 · Clause-② no. CI on this head: 35 success, 16 skipped, none failing.

Stacked on #33550. Against that branch's head a66e100b (my PASS at fe338b46, carried over by the main-merge delta note 6887473363), this PR is 3 commits and 3 files. Only those were reviewed. Once #33550 lands, merge main in; any change to these 3 files from that merge is a delta.

What was checked:

  • One predicate, extracted exactly. isGlobalSeedObject(objectName, definition) is probeScopeOf's inline global arm, and probeScopeOf now calls it. The guards that arm sat behind come along:

    • a describable definition;
    • not sys_user or sys_organization;
    • no organization column, declared or injected;
    • no managedBy;
    • resolveTenantFieldName(...) === null.

    The probe's answer is therefore unchanged for every target.

  • The replay match follows it. organizationColumnOf answers null for a global object, and loadExistingRecords then sets no where, so the match is unscoped. That fixes the card: a per-organization replay of a tenancy: { enabled: false } dataset filtered on an organization_id the object does not have, and the driver refused it INVALID_FILTER. A definition the registry cannot describe is not global and keeps the organization_id filter, the pre-PR fallback.

  • The stamp side is untouched and pinned. seedRowTenantColumn already answers null for such an object, so a row is neither stamped nor refused for a column it lacks. The new no-organization case pins that.

  • The behaviour is the right one for a global object. No organization walls its rows, so the one shared row is what every organization's replay reads, and the write side already treats it that way. The two-organization case pins exactly one shared row, unstamped, with an idempotent second replay (the no-op replay comparison, so no rewrite churn). Before this PR the same replay refused instead, so nothing that used to succeed now writes differently.

  • N1 from fix(metadata-protocol): seed replay matches and stamps an object on its declared tenant column #33550 is folded in: each jsdoc block now sits above its own method.

  • 23/23 in the integration file, including fix(metadata-protocol): seed replay matches and stamps an object on its declared tenant column #33550's cases and the organization_id control. The ablation (old fallback filter) reds the two-organization case.

Semver: Clause-②: no and Metadata-protocol: none are right. A replay that was refused now succeeds on the object's own wall semantics, and nothing an author writes is read differently. @objectstack/metadata-protocol at patch.

Not run locally (declared): 17 gate families were skipped; CI on this head is green.

Nits: none. Final round. Land after #33550 merges and main is merged in.


Generated by Claude Code

The stacked base merged to main as a squash; both conflicted files on
main are byte-identical to the base head already merged here, so each
conflict resolves to this branch's side. The branch delta against main
is byte-identical to the reviewed delta.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cxkE5YceM1ZSSAeofZ
Brings in the bounded seed membership probe, which edits the same
seed loader and runtime seed test; both files auto-merge cleanly and
the branch delta against main keeps the reviewed hunks unchanged, at
shifted line offsets.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cxkE5YceM1ZSSAeofZ
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract-review-claim: session_016WV4cztXwcRKcZdDqJmbSn · head 4223d30 · 2026-11-15T08:43:40Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Review: PASS

review#2 (server area pilot) · area A4 · Fixes #33554 · head 4223d301c596380a30c84ca02c6ace743454bde2 · delta of 6887493134

This is a delta on the PASS at 875ddcc4. The new head is two merges of main with no source edits. CI on this head: 35 success, 16 skipped, none failing or pending.

What was checked:

Items:

  1. N (not blocking, not caused by this PR). A global seed object with a sys_user lookup now reaches the per-organization reference probe on every organization's replay. Before this PR the replay was refused. The person is resolved through membership in each organization. With fix(metadata-protocol)!: the seed membership probe is bounded by the organization's members, and an id-shaped person is judged by membership #33611, that also applies to an id-shaped value. So one shared row could be re-pointed by each organization's replay, or refused by an organization the person does not belong to. Nothing in the current fixtures declares such a field, and no behaviour that used to succeed changes. File it as a follow-up if a global catalog with a person reference ever appears. It does not block this PR.

Semver: unchanged from the review of record: Clause-②: no, @objectstack/metadata-protocol at patch.

Not run locally (declared): the other gate families. CI on this head is green.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-elon-musk · session_016WV4cxkE5YceM1ZSSAeofZ

ACCEPT · area A4 · 2026-11-15T08:51Z

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.

Seed replay: a dataset of a global object (tenancy disabled) throws INVALID_FILTER on a per-organization replay

2 participants