Skip to content

fix(metadata-protocol): seed reference probe filters on the target's resolved tenant column - #33409

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/area-A4-33393
Nov 14, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/area-A4-33393

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

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

维护者速读

  • 改了什么:按组织回放种子数据时,引用目标若用声明的 tenancy.tenantField(如 workspace_id)隔离,探针改为按该租户列过滤,不再一律按 organization_id。
  • 为什么改:此类目标没有 organization_id 列,原探针被驱动拒绝(INVALID_FILTER),本组织明明有同名行,引用却报"未解析"。
  • 风险与回滚:只影响按组织加载时对"组织"类目标的引用探针;普通租户对象解析出的列仍是 organization_id,行为不变。回滚即还原本 PR。
  • 先看:packages/metadata-protocol/src/seed-loader.ts 的 probeScopeOf 与 resolveFromDatabase 中 where[scope.tenantColumn] 一行;packages/runtime/src/seed-org-scoped-references.integration.test.ts 新用例。
  • 两分钟验证:pnpm --filter @objectstack/metadata-protocol build && pnpm --filter @objectstack/runtime exec vitest run src/seed-org-scoped-references.integration.test.ts,预期 18/18 通过。
  • 需要你做的:无,席位落地。

What changes

SeedLoaderService.probeScopeOf now returns a scope object; the organization scope carries the target's resolved tenant column (resolveTenantFieldName(definition), falling back to organization_id, i.e. DEFAULT_TENANT_FIELD). The reference probe filters where[tenantColumn] = organizationId instead of always where.organization_id. A target walled by a declared tenancy.tenantField with the injected column switched off was classified organization (its tenant field resolves, so it is not global) and then probed on a column it does not have, so the driver refused the filter and the reference was reported unresolved. The sys_member membership probe still filters sys_member.organization_id (its own column) and is unchanged; the own-organization and global scopes are unchanged.

Tests

  • New pin in packages/runtime/src/seed-org-scoped-references.integration.test.ts (real AppPlugin replayer, real SeedLoaderService, real ObjectQL + SqlDriver over better-sqlite3): a target declaring tenancy: { enabled: true, tenantField: 'workspace_id' } with systemFields: { tenant: false }; two rows named Gold, South's inserted first. A North replay resolves tag to North's row, a South replay to South's, both with no errors and no refusal logged for the tag table.
  • Premise measured on main (7e2eadd) before the fix: the pin is red with crm_deal.tag = 'Gold' -> crm_workspace_tag.name not found; the probe was refused (INVALID_FILTER), and the driver logs no such column: organization_id on crm_workspace_tag.
  • Ablation (fix committed first; mutation via scripts/ablation-replace.mjs, dist/ proved by scripts/ablation-dist-preflight.mjs): reverting the filter to organization_id turns the pin red (1 failed / 17 passed); restore proved by blob == HEAD and an empty git status --porcelain, marker absent from all 24 built files, pin green again (18/18). A first attempt used a comment marker that the build strips; the preflight refused it before any verdict was read, so it was not counted.

Acceptance notes

  • Source side of the same column assumption, not changed here: loadExistingRecords filters a per-organization replay of a dataset by organization_id too. A seed dataset OF a workspace_id-walled object (injected column off) makes the per-organization replay throw INVALID_FILTER (measured with a temporary case on this branch, then removed). Reported to the seat for filing; it touches the stamp and ledger semantics, so it is not a mechanical in-place fix.
  • src/seed-tenancy-autonumber-split.integration.test.ts timed out once (5000 ms) in a 21-file run on a shared box and passed 15/15 when re-run alone; unrelated to this diff.

Verification

Local runs at head ae21eae
  • pnpm --filter @objectstack/metadata-protocol test: Test Files 339 passed, 9 skipped (348); Tests 22848 passed, 43 skipped.
  • pnpm --filter @objectstack/metadata-protocol typecheck and pnpm --filter @objectstack/runtime typecheck: exit 0.
  • Runtime seed suites (21 files, src/*seed*.test.ts): 202 tests, 201 passed, 1 timeout (passed alone, see above).
  • eslint on the two changed source files: exit 0.
  • node scripts/pm/dispatch-gates.mjs --commands: 64 families; 63 exit 0; pnpm check:dual-build-cjs-loads exit 3 (PREREQUISITE NOT MET: needs a full pnpm build), NOT MEASURED locally and left to CI. --ran reconciliation: 64 accounted, 63 run, 1 NOT-MEASURED, 0 UNRUN.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC

…resolved tenant column

An organization-scoped seed load probed every tenant-walled reference
target with organization_id = load organization. A target walled by a
declared tenancy.tenantField with the injected organization_id column
switched off has no such column, so the driver refused the filter and the
reference was reported unresolved although a row of that organization
existed. The organization probe now filters on the column the target is
walled by (resolveTenantFieldName, falling back to organization_id).

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

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 df9fe9463020a58b29a61f98605b91e7fbb307c1 → packageMentionDocs.

Which tree this was computed on

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

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

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

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

Request: review · area A4 · head ae21eae

Fixes #33393 · metadata-protocol seed-loader + runtime integration pin, 3 files, +71/−18 · Clause-② no · NOT governed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head ae21eae · 2026-11-14T19:22Z

review#2 (server area pilot, A4).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Review: PASS

Head: ae21eae6fe4e48b9d195ed9d5da12661810df5ec · reviewer review#2 (session_016WV4cxDxAYxdtDhtR1kQQe) · area A4 · Fixes #33393

Checked:

  • Filters on the column the wall uses. probeScopeOf now carries tenantColumn = resolveTenantFieldName(definition) ?? DEFAULT_TENANT_FIELD in the organization scope, and the probe writes where[tenantColumn] = organizationId. resolveTenantFieldName (core/security/tenant-field.ts) is the platform's one reading of the tenant column: the declared tenancy.tenantField when the object has that field, else organization_id when present, else null. So:
    • A declared workspace_id with the injected column off is probed on workspace_id, which is the card's case.
    • A target whose definition names no tenant field in fields (the injected-column case, or a registry that could not describe it) falls back to organization_id, exactly as before.
    • tenancy.enabled: false with an organization_id column also resolves null, so it falls back to organization_id, as before.
  • No cross-organization borrow. The pin seeds South's Gold first. North and South each resolve to their own row, and no refusal is logged for the tag table. The members, own-organization, global and unscoped branches are unchanged: the union type only renames them, and global still requires no managedBy and no tenant column.
  • Clause-②: no is accepted. This is a seed-loader probe fix with no export or published answer moving, and @objectstack/metadata-protocol patch is right.
  • CI on this head was still running at review time (15 success, 17 in progress, none failed). Landing needs all green.

No findings.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

ACCEPT · area A4 · head ae21eae · 2026-11-14T19:47Z

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 14, 2026 19:48
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

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

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

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

  • Dogfood Regression Gate (3/3) — 失败步骤: Boot example apps and exercise real user flows

    @objectstack/dogfood:test:  FAIL   isolated  test/audit-log-admin-search.dogfood.test.ts > [#21154] the stock admin searches the ledger and the activity stream with no parent named > the activity stre
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: expected 0 to be greater than 0
    

↳ 失败原因 是判读的关键:超时(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,按失败测试文件聚合):

历史信号:

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

分诊清单:

  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

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

Re-queue once · head ae21eae · 2026-11-14T20:37Z

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 14, 2026
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 14, 2026
Merged via the queue into main with commit c92ae14 Nov 14, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/area-A4-33393 branch November 14, 2026 21:40
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…is served (objectstack-ai#33449)

<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DXuamRUC67fx2TTYrFfyuSH)_

Fixes objectstack-ai#33429

Clause-②: no — a test-only change in the private `@objectstack/dogfood`
package; nothing publishes.
Metadata-protocol: none

## Maintainer quick read

- What changes: one dogfood test now picks its search words from rows
the admin can actually see, so it stops failing at random in the merge
queue.
- Why: it ejected objectstack-ai#33364 and objectstack-ai#33409 from the queue. It is not a product
bug. Sometimes the word it picked came from an activity row about an
internal object (`sys_oauth_resource`) that no one is allowed to read
through the data API, so the admin's search correctly found nothing.
- Risk and rollback: test only. Rollback is a revert.
- Needed from you: nothing.

## Cause (measured locally on the stock showcase boot)

- The test took its term from `ql.find(table, { limit: 1 })` under the
system context, with no sort. That row varied between boots: four boots
gave `showcase_invoice_line`, `showcase_expense_line`, `showcase_task`
and `sys_oauth_resource`.
- The boot writes one `sys_activity` row about `sys_oauth_resource` (the
MCP resource registration, no actor). `GET /data/sys_oauth_resource`
answers 404 `OBJECT_API_DISABLED`, and the activity read gate serves a
row only to a reader who can read its parent, so the stock admin is
served none of that object's activity rows.
- A probe over every `object_name` the boot wrote: the admin's `$search`
and its `$filter` on the name both answer more than 0 rows for every
name except `sys_oauth_resource`, where both answer 0. When that row
came first, line 96 saw 0. Both victims failed on that assertion, not on
a timeout.

No wait or retry is added.

## What changes

- `packages/qa/dogfood/test/audit-log-admin-search.dogfood.test.ts`:
each term is the `object_name` of the newest row the stock admin reads
through the same data door (`$orderby=created_at desc` on
`sys_audit_log`, `timestamp desc` on `sys_activity`, `$top=1`). The
armed control and the comment say so.

## Verification

- The changed file, run 3 times on a built tree: 3/3 passed each run.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset. (Nothing
publishes here.)
- [x] 6. `packages/spec` is not touched.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…ts declared tenant column (objectstack-ai#33550)

<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D4Jsmd91BqTVB7dSii9uJMV)_
Fixes objectstack-ai#33411
Clause-②: no
Metadata-protocol: none

## 维护者速读

- **改了什么**:按组织回放种子数据时,对用 `tenancy.tenantField` 声明了自定义租户列(且没有
`organization_id`)的对象,改为在该租户列上匹配已有行并打上组织标记;此前这类数据集直接抛
`INVALID_FILTER`,该组织一行都种不进去。
- **为什么改**:租户墙(`resolveTenantFieldName`)把声明的租户列当作组织键,种子加载器却写死了
`organization_id`。引用目标那一侧已在 objectstack-ai#33409 修过,这次修的是数据集自身这一侧,复用同一个读法。
- **风险与回滚**:低。普通 `organization_id` 对象的行为不变(对照用例钉住)。唯一的行为变化:同时声明自定义租户列又带
`organization_id` 的对象,加载器改为只在声明列上打标记(引擎与驱动本来就只按声明列筑墙)。回滚即 revert 本 PR。
- **先看**:`packages/metadata-protocol/src/seed-loader.ts` 的
`seedRowTenantColumn` 与 `organizationColumnOf`(风险最高的两处),再看数据集循环里
`organizationColumn` 替换的打标记/拒绝分支,最后看集成测试新增的 describe。
- **两分钟验证**:`pnpm --filter @objectstack/runtime exec vitest run
src/seed-org-scoped-references.integration.test.ts`,预期 21 个用例全绿。
- **需要你做的**:无,席位落地。

## What changes

A per-organization seed replay (AppPlugin's `seed-replayer` on a walled
boot, or a load pinned to `config.organizationId`) read a dataset's
existing rows with a filter on `organization_id`. An object walled by a
declared `tenancy.tenantField` with `systemFields.tenant: false` has no
such column, so the driver refused the filter (`INVALID_FILTER`) and the
replay threw for every organization.

`packages/metadata-protocol/src/seed-loader.ts`:

- **(a) Existing-row match.** `loadExistingRecords` filters on
`organizationColumnOf(objectName)`, which is
`resolveTenantFieldName(definition) ?? DEFAULT_TENANT_FIELD`. objectstack-ai#33409
introduced this reading for the reference-target probe, and this PR
reuses it.
- **(b) Stamp.** `seedRowNeedsOrganization` now delegates to
`seedRowTenantColumn`. That function returns the column a seeded row
carries its organization in: a declared tenant field the object really
has, else `organization_id` (authored or injected). Both halves are the
existing shared readings (`resolveTenantFieldName`,
`resolveInjectedSystemColumns`). The dataset loop stamps the load's
organization in that column, and it uses the same column for the
unowned-row refusal (its `field` and message), the reference-pass skip
of the stamped value, the seed-file owner and the row's own write
organization (`writeOptionsFor`, now passed into `writeRecord`). The
wall reads the column the same way: the SQL driver scopes reads and
stamps inserts on `resolveTenantField` (`applyTenantScope`,
`injectTenantOnInsert`), so the generalised stamp needs no refusal path.

Behaviour for an ordinary `organization_id` object is unchanged.

## Tests

`packages/runtime/src/seed-org-scoped-references.integration.test.ts`
gets a new top-level `describe`. It runs a real AppPlugin,
SeedLoaderService, ObjectQL and SqlDriver over better-sqlite3, the same
harness objectstack-ai#33409 used.

1. Two organizations replay a `crm_workspace_tag` dataset. South already
holds a `Silver` of its own. North gets a new row stamped `workspace_id
= North`. South's replay matches its existing row and inserts nothing. A
second replay of both inserts nothing, and the stored rows are
unchanged.
2. A load with no organization, pinned or derivable (two organizations
exist), refuses the row with the loader's named refusal on
`workspace_id`, and no row lands.
3. CONTROL: an ordinary `organization_id` dataset (`crm_account`)
replays per organization, is stamped, and is idempotent.

## Acceptance notes

- **Ablation (b) shows what the stamp itself buys.** With the stamp
reverted to `organization_id`-only, case 1 stays green. The driver's
`injectTenantOnInsert` already stamps the declared column from the
write's `tenantId` (objectstack-ai#33206), so the stored rows do not change. Only case
2 turns red: the row is refused by the engine's write refusal (`field:
"(write)"`) instead of by the loader's named one. So the observable gain
of (b) is the named refusal, plus row-organization reads (seed files,
per-row write organization) for a record that authors its own tenant
column.
- An object that declares a `tenancy.tenantField` and also carries
`organization_id` is now stamped on the declared column only. The engine
and the driver already wall it by that column. No object in this
repository declares a non-default `tenantField` (`git grep
"tenantField:"` outside tests).

## Verification

Readings from head `fe338b4650`.

<details><summary>Premise at origin/main (e40cd1e), new cases before
the fix</summary>

```
× each organization gets its own row, stamped on the tenant column; ...
Error: A filter on object 'crm_workspace_tag' names a column the database could not resolve, ...
[sql-driver] INVALID_FILTER — a WHERE column could not be resolved on 'crm_workspace_tag' ('organization_id')
× a load with no organization, pinned or derivable, refuses the row by name on the tenant column
-   "field": "workspace_id",
+   "field": "(write)",
Tests  2 failed | 19 passed (21)
```
</details>

<details><summary>After the fix</summary>

```
seed-org-scoped-references.integration.test.ts   Tests  21 passed (21)
@objectstack/metadata-protocol vitest run        Test Files  340 passed | 9 skipped (349) · Tests  22866 passed | 43 skipped
@objectstack/metadata-protocol typecheck         exit 0
@objectstack/runtime typecheck (+ check:test-typecheck)   exit 0
eslint --no-inline-config (both files)           exit 0
```
</details>

<details><summary>Ablations (scripts/ablation-replace.mjs +
ablation-dist-preflight.mjs, metadata-protocol rebuilt each
leg)</summary>

```
LEG A  filter back to organization_id: mutation landed (blob 5ff5e8c -> b40cbc9a0619);
       dist marker "[await this.organizationColumnOf(objectName)]" absent;
       Tests 1 failed | 20 passed — case 1 red with INVALID_FILTER on crm_workspace_tag
       (the leg's build exits 1 at the DTS step: TS6133, organizationColumnOf unused under the mutation;
        the JS the suite consumes was emitted, as the preflight reading shows)
LEG B  stamp column back to organization_id only: mutation landed (blob 5ff5e8c -> ba19869c5932);
       dist marker "const resolved = resolveTenantFieldName(definition);" absent;
       Tests 1 failed | 20 passed — case 2 red
RESTORE  blob == HEAD, git diff HEAD empty; rebuild exit 0; both markers present in dist; tree clean;
         Tests 21 passed (21)
```
</details>

<details><summary>Gate families (dispatch-gates --commands, reconciled
with --ran)</summary>

```
Run reconciliation — 64 derived, 63 run, 1 NOT-MEASURED, 0 UNRUN (dispatch-gates --ran, exit codes recorded)
63 families exit 0, including check:nul-bytes, check:cross-package-test-inputs, check:test-source-alias,
  check:durability-log-level, check:engine-double-contract, check:issue-citations, check:doc-authoring
NOT MEASURED: pnpm check:dual-build-cjs-loads :: exit 3 — PREREQUISITE NOT MET (reads every package's dist/; this
  worktree built only the runtime dependency closure). Declared narrowing: CI's Lint & Repo Gates runs it.
```
</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC

---------

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…s to the load organization's row (objectstack-ai#34100)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9WLWfdqSAaFLKQRS27UZeAT)_

Fixes objectstack-ai#33794
Clause-②: no
Metadata-protocol: none

## 维护者速读

- 改了什么:`seed-data.mdx` 里“按组织加载种子时引用解析到哪一行”表格中的一行。以 `tenancy.tenantField`
隔离、没有 `organization_id`
列的对象,现在写的是“只解析到本次加载所属组织的那一行,按该租户列匹配,绝不借用别的组织同名行”。
- 为什么改:该行还停在 objectstack-ai#33393 修复之前,写的是“查询被拒并报告”。修复后种子探针按目标对象解析出的租户列过滤,QA
实测也是各组织各自解析到自己的行。文档与行为不符,会误导写种子的人。
- 风险与回滚:纯文档一行,不改代码,不发包(skip-changeset)。回滚就是 revert 这一个提交。
- 先看:`content/docs/data-modeling/seed-data.mdx` 第 476 行附近的表格行。
- 两分钟验证:`grep -n "tenancy.tenantField"
content/docs/data-modeling/seed-data.mdx`,应看到新句子,且全仓 `content/docs` 与
`skills/` 再搜不到 “refused and reported” 描述这个场景。
- 需要你做的:无,席位落地。

## What changes

One row of the "References on an organization's own load" table in
`content/docs/data-modeling/seed-data.mdx`.

- Before: an object walled by another tenant column
(`tenancy.tenantField`) with no `organization_id` column resolves
"nothing on such a load: the lookup is refused and reported, never
answered from another organization".
- After: "a row of the load's organization only, matched on that tenant
column (the column a seeded row of such an object is stamped with);
another organization's row with the same key is never used".

The row was written for the first org-scoped reference change and went
stale with the seed-probe tenant-column fix (PRs objectstack-ai#33409 / objectstack-ai#33550).
Main's probe, `packages/metadata-protocol/src/seed-loader.ts` at
`63db7240`:

```ts
// probeScopeOf(targetObject)
const tenantColumn = resolveTenantFieldName(definition) ?? DEFAULT_TENANT_FIELD;
let scope: ProbeScope = { kind: 'organization', tenantColumn };
// ...
// the probe itself
if (scope.kind === 'organization') where[scope.tenantColumn] = organizationId;
```

An object that declares a `tenantField` and no `organization_id` is
neither `sys_user`, `sys_organization` nor a global object
(`isGlobalSeedObject` needs no tenant field at all), so it keeps the
`organization` scope and is probed on its declared column. The
integration test
`packages/runtime/src/seed-org-scoped-references.integration.test.ts`
pins it: "an object walled by another tenant column resolves within the
load organization, on that column" (North gets `tag_gold_n`, South gets
`tag_gold_s`, no refusal logged) and "is not taken for a global one:
another organization's row is not borrowed". The stamp half ("the column
a seeded row of such an object is stamped with") is the shipped 18.5.0
note `1e889b1` in `packages/metadata-protocol/CHANGELOG.md` and the test
block "a dataset OF an object walled by a declared tenant column replays
per organization on that column".

## Tests

No code changed; no test edits.

## Acceptance notes

- Changesets: `.changeset/33207-seed-org-scoped-references.md` and
`.changeset/33393-seed-probe-tenant-column.md` were both consumed by the
Version Packages commit `b914e724` (objectstack-ai#33097, 18.5.0). Per the order,
nothing is touched. The published
`packages/metadata-protocol/CHANGELOG.md` 18.5.0 section still carries
the 33207 bullet saying a `tenancy.tenantField`-walled target "keep[s]
the old lookup, and its refusal is now reported" (line 527), which the
33393 note in the same section (line 568) supersedes. AGENTS.md routes a
factual error in a released entry to a dedicated docs-only PR amending
that entry; that is for the seat to decide (`carrier: seat`). The
curated release page `content/docs/releases/v18/18-5.mdx` does not
mention this case, so it has nothing to correct.
- Sweep: `grep -rn -i "refused and reported"` over `content/docs` and
`skills` at `63db7240` hit only this row; `grep -rn tenantField` over
both trees found no other sentence on the seed-reference case. No
`skills/**` hit.

## Verification

Gates at head `0a569a31`: `dispatch-gates --commands` derived 43
commands; all 43 exit 0. `--ran` with exit codes: "43 derived famil(ies)
accounted for — 43 run, 0 NOT-MEASURED (a DERIVED zero)".

<details><summary>Notes on the run</summary>

`check:skill-examples` first exited 3 (refused before measuring:
`packages/client-react/dist` was not built). After `pnpm --filter
'@objectstack/client-react...' build` under the verify lock (VERDICT
command-exit 0) it exited 0: "346 prose examples type-check across 3
surface(s)". The spec and lint closures were built first under the lock
(VERDICT command-exit 0).

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmPBERWks32kU5eiYwm)_

Co-authored-by: Claude <noreply@anthropic.com>
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/s 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 loader: an org-scoped reference probe filters on organization_id even when the target declares another tenantField

2 participants