Repository navigation
fix(metadata-protocol): seed reference probe filters on the target's resolved tenant column - #33409
Conversation
…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
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
|
Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head ae21eae · 2026-11-14T19:22Z review#2 (server area pilot, A4). |
Review: PASSHead: Checked:
No findings. Generated by Claude Code |
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC ACCEPT · area A4 · head ae21eae · 2026-11-14T19:47Z
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 43635769742 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC Re-queue once · head ae21eae · 2026-11-14T20:37Z
|
…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>
…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>
…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>
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.probeScopeOfnow returns a scope object; theorganizationscope carries the target's resolved tenant column (resolveTenantFieldName(definition), falling back toorganization_id, i.e.DEFAULT_TENANT_FIELD). The reference probe filterswhere[tenantColumn] = organizationIdinstead of alwayswhere.organization_id. A target walled by a declaredtenancy.tenantFieldwith the injected column switched off was classifiedorganization(its tenant field resolves, so it is notglobal) and then probed on a column it does not have, so the driver refused the filter and the reference was reported unresolved. Thesys_membermembership probe still filterssys_member.organization_id(its own column) and is unchanged; theown-organizationandglobalscopes are unchanged.Tests
packages/runtime/src/seed-org-scoped-references.integration.test.ts(realAppPluginreplayer, realSeedLoaderService, realObjectQL+SqlDriverover better-sqlite3): a target declaringtenancy: { enabled: true, tenantField: 'workspace_id' }withsystemFields: { tenant: false }; two rows namedGold, South's inserted first. A North replay resolvestagto North's row, a South replay to South's, both with no errors and no refusal logged for the tag table.main(7e2eadd) before the fix: the pin is red withcrm_deal.tag = 'Gold' -> crm_workspace_tag.name not found; the probe was refused (INVALID_FILTER), and the driver logsno such column: organization_idoncrm_workspace_tag.scripts/ablation-replace.mjs,dist/proved byscripts/ablation-dist-preflight.mjs): reverting the filter toorganization_idturns the pin red (1 failed / 17 passed); restore proved by blob == HEAD and an emptygit 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
loadExistingRecordsfilters a per-organization replay of a dataset byorganization_idtoo. A seed dataset OF aworkspace_id-walled object (injected column off) makes the per-organization replay throwINVALID_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.tstimed 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 typecheckandpnpm --filter @objectstack/runtime typecheck: exit 0.src/*seed*.test.ts): 202 tests, 201 passed, 1 timeout (passed alone, see above).node scripts/pm/dispatch-gates.mjs --commands: 64 families; 63 exit 0;pnpm check:dual-build-cjs-loadsexit 3 (PREREQUISITE NOT MET: needs a fullpnpm build), NOT MEASURED locally and left to CI.--ranreconciliation: 64 accounted, 63 run, 1 NOT-MEASURED, 0 UNRUN.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC