You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
objectql: the relation semi-join keeps the 1,000-id cap for a single-valued hop across tenancy classes under an organization wall #34157
Filing gate: seat ruling on PR #33652, contract finding S3, option B for the tenancy-class case (the federated case keeps the cap by ruling A). ⛔ Not a claim.
维护者速读
#33652 把单值关系条件编译为库内子查询(无 id 上限),但在有组织墙的租户姿态下,若外层对象与关联对象的租户类别不同(一个按组织隔离、另一个为平台全局),该跳仍回退到 id 读取并保留 1000 个 id 的上限。子查询本可以带上关联读取自身的驱动选项,从而在这种情况下也去掉上限。
What exists
packages/objectql/src/relation-semi-join.tsrelationSemiJoinServes keeps the id read, before planning, when a posture that walls organizations is in force and the read's object and the related object are of different tenancy classes (isDriverTenantScopedSchema, packages/objectql/src/engine-driver-options.ts). The driver compiles a ReadableIds subquery with the OUTER read's driver options (ADR-0139 D3), so those options would scope the related table wrongly.
Let the composed leaf carry the related read's own driver options (its tenant scope) so the SQL drivers compile the subquery under the related read's wall, and serve the hop as one statement with no id cap. Pin it on SQLite and PostgreSQL in both tenancy directions, with the two-step route's rows as the oracle.
Dedupe words: relation semi-join tenancy class, ReadableIds driver options, 1000 id cap tenant wall, cross tenancy subquery
Triage: lands in domain:server · pm:queue; rationale: area:data · Bug · Impeded (a single-valued hop across tenancy classes under an organization wall keeps the 1,000-id cap) · rare (mixed tenancy classes on one relation) → p3 as set; it goes to p2 if a measured run shows rows silently dropped past the cap.
Triage: lands in area:data · domain:server · Bug · p3 · pm:queue · size M; rationale: past 1,000 matches the cross-tenancy-class hop is refused loudly (INVALID_FILTER / 400), never truncated. The card removes a limit on a narrow posture (an organization wall, and objects of different tenancy classes), so it is not silently wrong data. p3 stands (audit restatement, tier 3). Recorded 2026-11-27T06:30Z.
Picked by card-pick.mjs --order area:data --seat repo:objectstack#8 at 2026-11-28T05:05Z: p3 close-out (ranks above it are this seat's claims, held for triage, off the intake, or a security-boundary fork: #33681 adds a public route that distinguishes an accepted invitation from an unknown one, which is a human-floor decision, not taken). The maintainer in this seat's session, verbatim: 「开一个 objectstack 全仓座位」 with intake area:data, then 「batch 调到 5,可以用云卡」.
Claim: PM loop round 1
Session: session_017xRBcSAaBEfQpU2yJexSJ8
Account: sunhaolin
Branch: claude/issue-34157-semi-join-tenancy-cap
Worktree: objectstack-issue-34157
Domain: domain:server
Seat: repo:objectstack#8
File surface: packages/objectql/src/relation-semi-join.ts, packages/objectql/src/engine-driver-options.ts (read; edit only if the leaf's options are composed there), the ReadableIds subquery compile in packages/drivers/driver-sql/src/** (and the memory/sqlite drivers only if they compile the same leaf), co-located tests and a conformance pin on SQLite (PostgreSQL where CI's live-PG lane runs it), one changeset per moved package; ⛔ no packages/spec/src/**, no change to the federated case (ruling A keeps its cap) (stop on breach; explain in the report)
Container & model: M, mode:subagent, model: opus (dispatch-gates --tier: no path-derived mandate; default tier), effort: high
Clause-②: no
Metadata-protocol: none
Responsibility: objectstack — relationSemiJoinServes keeps the id read (1,000-id cap) when the read's object and the related object are of different tenancy classes under an organization wall, because the driver compiles ReadableIds with the OUTER read's options | the id read, refused past 1,000 matches with INVALID_FILTER / 400 (loud, never truncated) | queries over a relation between an org-scoped and a platform-global object under an organization wall, past 1,000 related matches
Thread-read: 7211589159
Premise: holds per the card (seat ruling on PR #33652, contract finding S3, option B); the dev measures the cap on current main first.
Serial constraints cleared: no in-flight claim names these files (check-handover.mjs --inflight); seat 3's packages/** claims #37856 / #36495. Textual overlap re-checked with overlap-check.mjs before every push.
Scope this dispatch: the whole card. Fixes #34157. Tenant-wall path ⇒ the seat adds an isolated adversarial review of the diff before landing.
{
"issue": 34157,
"status": "needs_decision",
"branch": "claude/issue-34157-semi-join-tenancy-cap",
"pr": null,
"session": "session_017xRBcSAaBEfQpU2yJexSJ8",
"premise_still_valid": true,
"summary": "Premise measured on BASE 33a0d4fa (origin/main at worktree creation): under an `isolated` posture a single-valued hop across tenancy classes is the id read in BOTH directions and is refused past 1,000 related matches with INVALID_FILTER / 400; the same-class CONTROL composes the leaf with no related read. No code was written: the card's mechanism ('the composed leaf carries the related read's own driver options') has no carrier inside the dispatched file surface. `ComposedReadableIds` is built and frozen by `ReadableIds.compose` in `packages/spec/src/data/readable-ids.ts` as exactly `{ object, scope }` plus its brand, and `DriverOptions` reaches a driver cut to the keys `DriverOptionsSchema` declares (`pickDeclaredDriverOptions`), so any route that puts the related read's tenant scope in front of `readableIdsSubquery` either changes a spec shape (forbidden here) or adds an engine-to-driver channel outside the spec in `@objectstack/core` (a new published export, outside the surface). Both are contract-shape changes with different architectures, and both contradict the accepted text of ADR-0139 D2 step 3 / D3 ('with the outer read's options'), which needs a Tier H amendment. Per os-dev 'when to stop', returned as needs_decision rather than speculative code on a tenant-wall path.",
"tests": "Premise, one throwaway file (deleted, never committed) on the BASE tree after `turbo run build --filter=@objectstack/objectql^...`: `os-verify-lock.sh -c 'pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/premise-34157.tmp.test.ts'` -> `VERDICT command-exit 0`, `Test Files 1 passed (1)`, `Tests 3 passed (3)`. Readings: `PREMISE outer org-scoped / related global {code: INVALID_FILTER, status: 400, reads: [[owner, limit 1001, tenantId null]]}`; `PREMISE outer global / related org-scoped {code: INVALID_FILTER, status: 400, reads: [[owner, limit 1001, tenantId org_b]]}`; `CONTROL same class under the wall {ownerReads: 0, composed: true}`. Recording driver declaring `readableIdsLeaf: true`, 1,001 related rows, posture provider `isolated`, caller tenant org_b. Corroboration: every `Test Core (N/10)` shard and `TypeScript Type Check` are `success` on 33a0d4fa, and that suite carries `engine-nested-relation-lowering.test.ts`'s two 'another tenancy class under a walled posture ... id read' pins. Three earlier lock attempts were `VERDICT queue-timeout (exit 99)` behind a dogfood holder (pid 7654, held up to 2209s): NOT MEASURED, then measured on the fourth.",
"gates": "None owed: no diff (files_changed is empty). No `check:*`, `dispatch-gates --commands` or `--ran` reconciliation was run, and no PR check-runs exist to cite.",
"dogfood_battery": "n/a — no PR, no `!` in any title and no (narrowing) arm",
"mcp_calls": "0",
"api_writes": "1 — this report comment, POST /repos/objectstack-ai/objectstack/issues/34157/comments via scripts/pm/post-stamped.mjs. Not a REST write but recorded: `git push -u origin claude/issue-34157-semi-join-tenancy-cap` (the empty-branch probe, dev-worktree.sh --probe, branch tip = BASE, no commits of its own).",
"files_changed": [],
"line_budget": "n/a — no diff",
"deviations": "Stopped before any edit (os-dev 'when to stop': a contract shape and two architectures). The decision framework's axes (pm-dispatch SKILL.md, escalation and decision) were not pasted in the dispatch, so the options below carry facts and costs only, with no self-made axis grid; the per-axis analysis is owed once the PM supplies the axes. Worktree /home/user/objectstack-issue-34157 removed after this report; the empty probe branch stays on the remote for a resume.",
"open_questions": [
{
"question": "Q1. Which carrier takes the related read's tenant scope from the engine's planned relation leaf to the drivers' subquery wall? Facts every option shares: three compile sites read the wall with the OUTER read's options today and would each need it: driver-sql `readableIdsSubquery` (sql-driver-internal-helpers.ts, `applyTenantScope(sub, parent, options)` and the nested `applyFilters(sub, leaf.scope, options)`), the Turso remote face `toRemoteWhere` (turso-driver.ts, `remoteTenantScope(leaf.object, options)` for every nested leaf), and the analytics relation-group derived table (sql-driver-aggregation.ts, 'the related object's tenant wall from THIS read's options'), because `relationSemiJoinServes` is shared by `engine-query-lowering.ts` and `relation-group-join.ts`. Direction 2 (outer platform-global, related org-scoped) is the dangerous one: the outer read's options carry no `tenantId`, so a compile site that ignores the carried scope reads the related table across every organization. Direction 1 (outer org-scoped, related platform-global) is already the related read's own statement on the SQL family, because `computeTenantField` answers null for a tenancy-disabled table and `applyTenantScope` is then a no-op.",
"options": [
"A — spec carries it: `ReadableIds.compose(leaf, scope, readScope)` gives `ComposedReadableIds` an optional field holding the related read's tenant scope (`tenantId` / `tenantIds`), and the three compile sites wall the subquery with it when present, the outer options otherwise. Cost: a `packages/spec/src/data/readable-ids.ts` shape change (api-surface regen, its own tests), the objectql compose site in `engine-readable-ids-permission-formula.ts` plus `relation-semi-join.ts` (lift the tenancy-class gate, let `plannedRelationLeafVerdict` compose with the carried scope where only the tenancy class differs), driver-sql, driver-turso, and pins on objectql (recording driver), driver-sql (SQLite plus the live-PG lane, which runs `@objectstack/driver-sql test`) and rest (SQLite). Fail-closed needs a further spec choice: a driver that declares `readableIdsLeaf` but predates the field (third-party, or a skewed install) compiles direction 2 unwalled, so either the leaf with a carried scope is a distinct brand an unaware driver refuses (INTERNAL_ERROR / 500 per D3), or the bit's documented obligation changes. Effort: L, over objectql, driver-sql, driver-turso and spec.",
"B — out-of-spec side table in `@objectstack/core` (beside `replaceComposedReadableIds`): a WeakMap keyed by the composed leaf's identity, written by the engine and read by the three compile sites. Cost: no spec edit, but a new core export and an engine-to-driver fact that no spec type names, against `packages/spec` being the one producer/consumer contract; a duplicated core copy or an unaware driver silently falls back to the outer options, which in direction 2 is the cross-organization read, and gating that needs a driver declaration that again lives in spec (`DriverCapabilities`). Effort: M, over objectql, core, driver-sql and driver-turso.",
"C — direction 1 only, no carrier: serve the org-scoped-outer / platform-global-related hop as a semi-join (the SQL family's wall is already inert on a tenancy-disabled table) and keep the id read with its cap for direction 2. Cost: objectql only (`relationSemiJoinServes` and the boundary comparison), but the equality rests on a driver fact the engine does not own, and half the card stays open. Effort: S-M.",
"D — keep the cap in both directions (main's behaviour). Contradicts the seat ruling (option B on PR #33652), listed for completeness only."
],
"recommendation": "A, because it is the only route where the fact travels in the type every driver already reads for this leaf (ADR-0139's composed leaf), so an unaware driver can be made to refuse rather than read across organizations, and the change stays one contract instead of a second dialect beside the spec. Per-axis reasoning is owed once the PM supplies the decision axes (see deviations)."
},
{
"question": "Q2. Who lands the ADR-0139 amendment? Every option but D contradicts the accepted text of D2 step 3 ('the driver applies its own tenant scope to the subquery's table with the outer read's options (D3)') and D3's driver-sql bullet, and the spec jsdoc on `ComposedReadableIds` repeats it ('The tenant wall is not in `scope` ... with the outer read's options'). `docs/adr/**` is Tier H and was outside this dispatch's surface.",
"options": [
"A — the seat drafts the amendment note as its own Tier H PR before the code PR merges",
"B — the code PR carries it (the whole PR becomes Tier H)"
],
"recommendation": "A, because it keeps the code PR's landing tier independent of the maintainer's ADR approval while Prime Directive 13 is still met before the behaviour ships."
},
{
"question": "Q3. Is the analytics relation-group dimension across tenancy classes in this card's scope? `relationSemiJoinServes` decides both the where lowering and `relation-group-join.ts`; lifting its tenancy-class gate also lifts the refusal 'is not plannable as one statement' for a cross-class analytics dimension, whose derived table is walled with the outer read's options.",
"options": [
"A — in scope: the group-join derived table takes the same carried scope (one more compile site, one more pin pair)",
"B — out of scope: the group join keeps its own tenancy-class refusal via a separate predicate, and a card carries it"
],
"recommendation": "A, because one predicate keeping one meaning for both consumers is what `relationSemiJoinServes`' docblock promises, and splitting it is a second spelling of the same registry fact."
}
],
"security_findings": "none",
"out_of_scope_findings": [
"none"
]
}
One-sentence problem. Under an organization wall, a filter or a report dimension that crosses from an organization's own table to a table shared by the whole platform (or back) does not get the uncapped one-statement read that same-kind tables got on 2026-11-16: the filter is refused past 1,000 related matches, and the report dimension is refused at any size.
Background. PR #33652 (merged 2026-11-16) serves a single-valued relation condition as one in-database subquery, "where it is provably the same read as the id read". Its contract review (record 6900638852, finding S3, should-fix) said: "Name a carrier, or ask for a ruling that the cap stays there." The seat domain:server#5 chose to name a carrier and filed this card.
Standing of the premise.⚠️ This card rests on a seat ruling (option B on PR #33652, contract finding S3), not a maintainer ruling. The maintainer-directed parent is #33626 (filing gate ③, 「首先保sql,应该用最高性能的方案」), whose item 2 reads "each hop carries that object's read scope and tenant wall". No maintainer record names this tenancy-class case. The accepted ADR text below conflicts with every option except D, so A, B and C are protocol changes, not a Bug fix (SKILL 〈升级与决策〉: 「改协议、新增公开面另立卡,⛔ 不作 Bug 选项」). The tenant wall is a security boundary, so this sits on the human floor whatever the letter.
Governing text: ADR-0139 D2 step 3, verbatim: "The composed leaf carries { object: P, scope }. The tenant wall is not composed here: the driver applies its own tenant scope to the subquery's table with the outer read's options (D3). The engine never re-derives it." D3, driver-sql bullet, verbatim: "compiles the composed leaf in its filter compiler … to field IN (SELECT id FROM P_TABLE WHERE SCOPE AND TENANT), the subquery scoped by packages/drivers/driver-sql/src/sql-driver.ts#applyTenantScope with the outer read's options." The spec docblock on ComposedReadableIds repeats it. Re-check: git show origin/main:docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md | sed -n 191,206p.
Protocol change? A: yes, the spec leaf shape, ADR-0139 D2/D3 and probably one driver-facing brand or declaration. B: yes, ADR-0139 D2/D3 plus a new @objectstack/core export that no spec type names. C: yes, ADR text only (direction 1 no longer "outer read's options" by proof, direction 2 unchanged). D: none.
Premises (read on origin/main = 7605e0c9cc; the dev measured on 33a0d4fa):
#
Premise
Status
Re-check
P1
Both directions take the id read and are refused past 1,000 with INVALID_FILTER / 400; the same-class control composes
dev-measured (3/3 on a throwaway file, not re-run here); the two direction pins are on main, read here
git grep -n "another tenancy class under a walled posture" origin/main -- packages/objectql/src (1 parametrised pin, 2 directions); git grep -n "RELATION_FILTER_ID_CAP = 1000" origin/main -- packages/objectql/src
P2
relationSemiJoinServes answers false when the posture walls and the two objects differ in tenancy class
measured
git show origin/main:packages/objectql/src/relation-semi-join.ts | sed -n 168,180p
P3
ReadableIds.compose(leaf, scope) builds and freezes exactly { object, scope } plus the brand
measured
git show origin/main:packages/spec/src/data/readable-ids.ts | sed -n 293,320p
P4
pickDeclaredDriverOptions cuts the bag to the keys of DriverOptionsSchema.shape, so an undeclared key never reaches a driver
measured
git show origin/main:packages/objectql/src/engine-driver-options.ts | sed -n 144,173p
P5
Three compile sites wall the related table with the outer read's options: readableIdsSubquery (sql-driver-internal-helpers.ts:160-166), Turso toRemoteWhere (turso-driver.ts:3576-3581), the relation-group derived table (sql-driver-aggregation.ts:340)
relationSemiJoinServes has two consumers: the where lowering (engine-query-lowering.ts:252) and the analytics group join (relation-group-join.ts:378). The second has no id-read fallback: it answers "is not plannable as one statement"
Direction 2: the outer read's options carry no organization (pin table: { object: OBJECT, tenantId: undefined }), and applyTenantScope returns the builder unwalled when options.tenantId is absent
measured
git show origin/main:packages/drivers/driver-sql/src/sql-driver-internal-helpers.ts | sed -n 126,130p
P8
Direction 1 is already the related read's own statement on the SQL family (no tenant column resolves for a tenancy-disabled table)
inferred from sql-driver-rotation.ts:311; no statement was captured
git show origin/main:packages/drivers/driver-sql/src/sql-driver-rotation.ts | sed -n 305,326p
P9
A driver that declares the leaf capability but predates a new field would compile direction 2 unwalled
inferred (follows from P5 and P7; no such driver exists in the repo)
same as P5, P7
Measured pull (script over git show origin/main:; 97 object declarations and 94 relation fields in examples/** and packages/platform-objects/**):
Platform-global, non-federated objects: 2 (sys_api_key, sys_sso_provider), both in platform-objects. examples/**: 0 (its two tenancy-disabled objects are federated, which is the separate ruling-A case).
Relations from an organization-scoped object to a platform-global one (direction 1): 0. Repo-wide lookups to either global object: 0.
Relations from a platform-global object to one the predicate classes as tenant-scoped (direction 2): 3 (sys_api_key.user_id and sys_sso_provider.user_id to sys_user, sys_api_key.active_organization_id to sys_organization). Both targets are managedBy: 'better-auth' and declare no organization column, so the wall is inert on them (inferred from the declarations, not from a running schema).
Reaching 1,000: only by filtering API keys or SSO providers on a user attribute that matches more than 1,000 users. No first-party view or filter spells such a path (git grep -n -E "['\"](user_id|active_organization_id)\.[a-z_]+['\"]" origin/main -- packages/platform-objects/src examples → 0). No example sets a walled posture. Reading: zero measured pull today; reachable only in a large walled deployment through an author-written filter.
Questions. Q1: which carrier, if any, takes the related table's own organization scope to the database subquery (A–D). Q2: who lands the ADR-0139 amendment (A/B). Q3: is the analytics dimension across tenancy classes in scope (A/B).
Option
What it does
What the customer sees
Workload
Q1 A, spec carries it
The composed leaf gains an optional related-read organization scope; three compile sites wall with it; an unaware driver must refuse
Cross-kind filters uncapped; report dimension served; a driver that lags answers a loud 500
domain:server · ADR PR + 1–2 code PRs over spec, objectql, driver-sql, driver-turso. Nearest precedents: #34565 (a spec-declared driver fact with its engine readers and the ADR note, +726/−100, 36 files) and #33652 (the semi-join with SQLite and PG pins, +1623/−223, 27 files). No precedent for changing this leaf's shape
Q1 B, side table in core
An identity-keyed side table written by the engine, read by the drivers
Same when everything is current; on a duplicated core copy or an unaware driver, direction 2 reads the related table across every organization, silently
domain:server · ADR PR + 1 code PR over objectql, core, driver-sql, driver-turso. No precedent for an engine-to-driver fact outside spec
Q1 C, direction 1 only
Lift the gate where the related table is platform-global; keep the cap the other way
Shared-catalog filters uncapped; global-to-organization stays capped; the card stays half open
domain:server · 1 PR, objectql only. No precedent for a one-direction serve; the equality rests on a driver fact the engine does not own (P8, inferred)
Q1 D, keep the cap
Nothing changes
Past 1,000 a loud 400 that names the two-step route; never truncated
0 PRs; the card closes as not planned. A to D differ by far more than 3×
Q2 A / B
A: a docs-only amendment PR first. B: the code PR carries it
None
A precedent: #33992 (+43/−0, 2 files, "This amendment declares; #33696's change lands only after it merges"). B precedent: #34565 (27 ADR lines inside a 36-file code PR)
Q3 A / B
A: the group-join derived table takes the same carrier. B: a separate predicate keeps its refusal; a new card carries it
A: the cross-kind report dimension is served. B: it stays refused at any size
A: one more compile site and pin pair inside Q1's PR, no separate precedent. B: no precedent (a second predicate over the same registry fact)
Business meaning. A: every table checks its own organization badge at its own door, and that rule is written into the contract. B: the badge travels on a sticky note beside the contract, and if the note falls off, the door stays open. C: we open the shared-catalog door and leave the other one as it is. D: the reception desk keeps saying "too many matches, ask in two steps".
Four axes, argued from the business side.
① Long-term soundness. Two years on, a customer running many organizations on one database expects a shared catalog and per-organization data to filter and group together with no size limit, each table walled by its own organization. This is how PostgreSQL row-level security behaves (a policy belongs to the table and applies wherever that table is read, a subquery included). A reaches that state inside the one contract every driver already reads, and removes a special case (one hop class behaves differently) at the cost of one optional field. B reaches it with a second dialect beside the contract. C leaves a half. D keeps the special case and adds nothing. Reading: A.
③ AI-mistake resistance. Direction 2 is where a mistake is expensive. If a driver ignores the carried scope there, the related table is read with no organization filter, so a user of organization B gets rows selected by related records that belong to organization A: a cross-organization read, with a normal 200 and no error. Under A with a distinct brand, a driver that does not know the new leaf refuses (INTERNAL_ERROR / 500, the ADR-0139 D3 envelope): loud, an operator sees it, nobody sees foreign data. Under B the fallback to the outer options is silent by construction. C avoids direction 2 entirely. D is loud today (400). Reading: A with the refusing brand, or D; never B.
④ Start-up focus. A adds a permanent spec field and an obligation on every third-party driver that declares the leaf. D adds nothing and no gate. Reading: D.
os-decision-facets
① Long-term: A shrinks a behavioural special case and keeps one contract; B adds a second dialect; C is a half; D keeps the special case. No SQL slowdown for memory/Mongo parity in any option.
② Pull: zero first-party pull (0 / 3 / 0 as counted above; 90 of 94 relations already served); default defer or remove.
③ AI mistakes: A with a refusing brand fails loud (500); B fails silent into a cross-organization read; D is loud (400).
④ No proliferation: A is one more declared key held forever; D declares nothing.
Prior rulings read: "tenancy class" ReadableIds → 3 hits (#34157, #33626, #33619); ADR-0139 D2 step 3 / D3; thread: 4 (this card), plus PR #33652 records 6900638852 and 6902361654
Recommendation. Q1 A, with its sub-choice ruled in the same stroke: the leaf that carries a scope is a distinct brand that an unaware driver refuses (not a change to what the existing capability bit promises). Not B: it is the only option whose failure mode is a silent cross-organization read. Not C: a half delivery whose proof rests on an unpinned driver fact. Not D by axis ①, but D is the honest reading of ② and ④, and the workload gap is far above 3×, so it is named here: ruling D is fully defensible, costs nothing, and only the maintainer can take it. ②, ③ and ④ adjust timing only: p3 stands, no urgency, the amendment lands first and the code follows. Q2 A: ADR-0139 says of itself "This record declares; it implements nothing", and #33992 is the landed shape. Q3 A: one predicate keeps one meaning, and the report dimension is the larger visible symptom (refused at any size, P6).
Confidence gaps: downstream apps (cloud, hotcrm, the blackcat CRM) were not searched, so the pull is first-party only. The dev's premise run was not repeated here (its file was deleted); P1 rests on the report and the pins on main. P8 and P9 are inferred. The Turso remote face and PostgreSQL were read, not run. Local history is shallow, so the precedent sizes come from the pulls API. The exact field and brand names are not proposed here.
Q1 A: the seat repo:objectstack#8 retypes the card from Bug to a protocol change, then re-dispatches with the surface widened to the spec leaf, objectql, driver-sql and driver-turso (Clause-②: yes (widening), Metadata-protocol: added). Pins: both directions on SQLite and PostgreSQL with the two-step rows as oracle, an ablation pin that an unaware driver refuses with 500, and an isolated adversarial review of the diff before landing.
Q2 A: the seat repo:objectstack#8 drafts the ADR-0139 amendment (D2 step 3, the D3 driver-sql and Turso bullets, the spec docblock wording) as its own Tier H docs PR; the maintainer approves it; the code PR is cut only after it merges. Q2 B: the dev writes the amendment inside the code PR and the whole PR lands as Tier H.
Q3 A: the analytics group-join is in scope: its derived table takes the same carrier, with one more pin pair in the same code PR. Q3 B: it is out of scope: the group join gets its own predicate and keeps its refusal, and the seat files one card for it.
No answer: the card stays in the decision box and main stays in state D.
Related.#34157 (this card, p3) · #33626 (closed, the maintainer-directed parent) · #33619 (closed, the hop-count decision) · PR #33652 (merged 2026-11-16, the source of S3) · #33876 / PR #34565 (the capability bit and the ruled 400) · PR #33992 (amendment-only precedent) · PR #22707 (ADR-0139 itself, +287/−1) · #34155 (closed, the sibling carrier filed with this one).
Activity
objectstack-fleet commentedon Nov 19, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
Triage: lands in
domain:server·pm:queue; rationale: area:data · Bug · Impeded (a single-valued hop across tenancy classes under an organization wall keeps the 1,000-id cap) · rare (mixed tenancy classes on one relation) → p3 as set; it goes to p2 if a measured run shows rows silently dropped past the cap.objectstack-fleet commentedon Nov 27, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
Triage: lands in area:data · domain:server · Bug · p3 · pm:queue · size M; rationale: past 1,000 matches the cross-tenancy-class hop is refused loudly (
INVALID_FILTER/ 400), never truncated. The card removes a limit on a narrow posture (an organization wall, and objects of different tenancy classes), so it is not silently wrong data. p3 stands (audit restatement, tier 3). Recorded 2026-11-27T06:30Z.objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8
Picked by
card-pick.mjs --order area:data --seat repo:objectstack#8at 2026-11-28T05:05Z: p3 close-out (ranks above it are this seat's claims, held for triage, off the intake, or a security-boundary fork: #33681 adds a public route that distinguishes an accepted invitation from an unknown one, which is a human-floor decision, not taken). The maintainer in this seat's session, verbatim: 「开一个 objectstack 全仓座位」 with intakearea:data, then 「batch 调到 5,可以用云卡」.Claim: PM loop round 1
Session:
session_017xRBcSAaBEfQpU2yJexSJ8Account:
sunhaolinBranch:
claude/issue-34157-semi-join-tenancy-capWorktree:
objectstack-issue-34157Domain:
domain:serverSeat:
repo:objectstack#8File surface:
packages/objectql/src/relation-semi-join.ts,packages/objectql/src/engine-driver-options.ts(read; edit only if the leaf's options are composed there), theReadableIdssubquery compile inpackages/drivers/driver-sql/src/**(and the memory/sqlite drivers only if they compile the same leaf), co-located tests and a conformance pin on SQLite (PostgreSQL where CI's live-PG lane runs it), one changeset per moved package; ⛔ nopackages/spec/src/**, no change to the federated case (ruling A keeps its cap) (stop on breach; explain in the report)Container & model:
M,mode:subagent,model: opus (dispatch-gates --tier: no path-derived mandate; default tier),effort: highClause-②: no
Metadata-protocol: none
Responsibility:
objectstack — relationSemiJoinServes keeps the id read (1,000-id cap) when the read's object and the related object are of different tenancy classes under an organization wall, because the driver compiles ReadableIds with the OUTER read's options|the id read, refused past 1,000 matches with INVALID_FILTER / 400 (loud, never truncated)|queries over a relation between an org-scoped and a platform-global object under an organization wall, past 1,000 related matchesThread-read: 7211589159
Premise: holds per the card (seat ruling on PR #33652, contract finding S3, option B); the dev measures the cap on current main first.
Serial constraints cleared: no in-flight claim names these files (
check-handover.mjs --inflight); seat 3'spackages/**claims #37856 / #36495. Textual overlap re-checked withoverlap-check.mjsbefore every push.Scope this dispatch: the whole card.
Fixes #34157. Tenant-wall path ⇒ the seat adds an isolated adversarial review of the diff before landing.objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8
os-dev-report
{ "issue": 34157, "status": "needs_decision", "branch": "claude/issue-34157-semi-join-tenancy-cap", "pr": null, "session": "session_017xRBcSAaBEfQpU2yJexSJ8", "premise_still_valid": true, "summary": "Premise measured on BASE 33a0d4fa (origin/main at worktree creation): under an `isolated` posture a single-valued hop across tenancy classes is the id read in BOTH directions and is refused past 1,000 related matches with INVALID_FILTER / 400; the same-class CONTROL composes the leaf with no related read. No code was written: the card's mechanism ('the composed leaf carries the related read's own driver options') has no carrier inside the dispatched file surface. `ComposedReadableIds` is built and frozen by `ReadableIds.compose` in `packages/spec/src/data/readable-ids.ts` as exactly `{ object, scope }` plus its brand, and `DriverOptions` reaches a driver cut to the keys `DriverOptionsSchema` declares (`pickDeclaredDriverOptions`), so any route that puts the related read's tenant scope in front of `readableIdsSubquery` either changes a spec shape (forbidden here) or adds an engine-to-driver channel outside the spec in `@objectstack/core` (a new published export, outside the surface). Both are contract-shape changes with different architectures, and both contradict the accepted text of ADR-0139 D2 step 3 / D3 ('with the outer read's options'), which needs a Tier H amendment. Per os-dev 'when to stop', returned as needs_decision rather than speculative code on a tenant-wall path.", "tests": "Premise, one throwaway file (deleted, never committed) on the BASE tree after `turbo run build --filter=@objectstack/objectql^...`: `os-verify-lock.sh -c 'pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/premise-34157.tmp.test.ts'` -> `VERDICT command-exit 0`, `Test Files 1 passed (1)`, `Tests 3 passed (3)`. Readings: `PREMISE outer org-scoped / related global {code: INVALID_FILTER, status: 400, reads: [[owner, limit 1001, tenantId null]]}`; `PREMISE outer global / related org-scoped {code: INVALID_FILTER, status: 400, reads: [[owner, limit 1001, tenantId org_b]]}`; `CONTROL same class under the wall {ownerReads: 0, composed: true}`. Recording driver declaring `readableIdsLeaf: true`, 1,001 related rows, posture provider `isolated`, caller tenant org_b. Corroboration: every `Test Core (N/10)` shard and `TypeScript Type Check` are `success` on 33a0d4fa, and that suite carries `engine-nested-relation-lowering.test.ts`'s two 'another tenancy class under a walled posture ... id read' pins. Three earlier lock attempts were `VERDICT queue-timeout (exit 99)` behind a dogfood holder (pid 7654, held up to 2209s): NOT MEASURED, then measured on the fourth.", "gates": "None owed: no diff (files_changed is empty). No `check:*`, `dispatch-gates --commands` or `--ran` reconciliation was run, and no PR check-runs exist to cite.", "dogfood_battery": "n/a — no PR, no `!` in any title and no (narrowing) arm", "mcp_calls": "0", "api_writes": "1 — this report comment, POST /repos/objectstack-ai/objectstack/issues/34157/comments via scripts/pm/post-stamped.mjs. Not a REST write but recorded: `git push -u origin claude/issue-34157-semi-join-tenancy-cap` (the empty-branch probe, dev-worktree.sh --probe, branch tip = BASE, no commits of its own).", "files_changed": [], "line_budget": "n/a — no diff", "deviations": "Stopped before any edit (os-dev 'when to stop': a contract shape and two architectures). The decision framework's axes (pm-dispatch SKILL.md, escalation and decision) were not pasted in the dispatch, so the options below carry facts and costs only, with no self-made axis grid; the per-axis analysis is owed once the PM supplies the axes. Worktree /home/user/objectstack-issue-34157 removed after this report; the empty probe branch stays on the remote for a resume.", "open_questions": [ { "question": "Q1. Which carrier takes the related read's tenant scope from the engine's planned relation leaf to the drivers' subquery wall? Facts every option shares: three compile sites read the wall with the OUTER read's options today and would each need it: driver-sql `readableIdsSubquery` (sql-driver-internal-helpers.ts, `applyTenantScope(sub, parent, options)` and the nested `applyFilters(sub, leaf.scope, options)`), the Turso remote face `toRemoteWhere` (turso-driver.ts, `remoteTenantScope(leaf.object, options)` for every nested leaf), and the analytics relation-group derived table (sql-driver-aggregation.ts, 'the related object's tenant wall from THIS read's options'), because `relationSemiJoinServes` is shared by `engine-query-lowering.ts` and `relation-group-join.ts`. Direction 2 (outer platform-global, related org-scoped) is the dangerous one: the outer read's options carry no `tenantId`, so a compile site that ignores the carried scope reads the related table across every organization. Direction 1 (outer org-scoped, related platform-global) is already the related read's own statement on the SQL family, because `computeTenantField` answers null for a tenancy-disabled table and `applyTenantScope` is then a no-op.", "options": [ "A — spec carries it: `ReadableIds.compose(leaf, scope, readScope)` gives `ComposedReadableIds` an optional field holding the related read's tenant scope (`tenantId` / `tenantIds`), and the three compile sites wall the subquery with it when present, the outer options otherwise. Cost: a `packages/spec/src/data/readable-ids.ts` shape change (api-surface regen, its own tests), the objectql compose site in `engine-readable-ids-permission-formula.ts` plus `relation-semi-join.ts` (lift the tenancy-class gate, let `plannedRelationLeafVerdict` compose with the carried scope where only the tenancy class differs), driver-sql, driver-turso, and pins on objectql (recording driver), driver-sql (SQLite plus the live-PG lane, which runs `@objectstack/driver-sql test`) and rest (SQLite). Fail-closed needs a further spec choice: a driver that declares `readableIdsLeaf` but predates the field (third-party, or a skewed install) compiles direction 2 unwalled, so either the leaf with a carried scope is a distinct brand an unaware driver refuses (INTERNAL_ERROR / 500 per D3), or the bit's documented obligation changes. Effort: L, over objectql, driver-sql, driver-turso and spec.", "B — out-of-spec side table in `@objectstack/core` (beside `replaceComposedReadableIds`): a WeakMap keyed by the composed leaf's identity, written by the engine and read by the three compile sites. Cost: no spec edit, but a new core export and an engine-to-driver fact that no spec type names, against `packages/spec` being the one producer/consumer contract; a duplicated core copy or an unaware driver silently falls back to the outer options, which in direction 2 is the cross-organization read, and gating that needs a driver declaration that again lives in spec (`DriverCapabilities`). Effort: M, over objectql, core, driver-sql and driver-turso.", "C — direction 1 only, no carrier: serve the org-scoped-outer / platform-global-related hop as a semi-join (the SQL family's wall is already inert on a tenancy-disabled table) and keep the id read with its cap for direction 2. Cost: objectql only (`relationSemiJoinServes` and the boundary comparison), but the equality rests on a driver fact the engine does not own, and half the card stays open. Effort: S-M.", "D — keep the cap in both directions (main's behaviour). Contradicts the seat ruling (option B on PR #33652), listed for completeness only." ], "recommendation": "A, because it is the only route where the fact travels in the type every driver already reads for this leaf (ADR-0139's composed leaf), so an unaware driver can be made to refuse rather than read across organizations, and the change stays one contract instead of a second dialect beside the spec. Per-axis reasoning is owed once the PM supplies the decision axes (see deviations)." }, { "question": "Q2. Who lands the ADR-0139 amendment? Every option but D contradicts the accepted text of D2 step 3 ('the driver applies its own tenant scope to the subquery's table with the outer read's options (D3)') and D3's driver-sql bullet, and the spec jsdoc on `ComposedReadableIds` repeats it ('The tenant wall is not in `scope` ... with the outer read's options'). `docs/adr/**` is Tier H and was outside this dispatch's surface.", "options": [ "A — the seat drafts the amendment note as its own Tier H PR before the code PR merges", "B — the code PR carries it (the whole PR becomes Tier H)" ], "recommendation": "A, because it keeps the code PR's landing tier independent of the maintainer's ADR approval while Prime Directive 13 is still met before the behaviour ships." }, { "question": "Q3. Is the analytics relation-group dimension across tenancy classes in this card's scope? `relationSemiJoinServes` decides both the where lowering and `relation-group-join.ts`; lifting its tenancy-class gate also lifts the refusal 'is not plannable as one statement' for a cross-class analytics dimension, whose derived table is walled with the outer read's options.", "options": [ "A — in scope: the group-join derived table takes the same carried scope (one more compile site, one more pin pair)", "B — out of scope: the group join keeps its own tenancy-class refusal via a separate predicate, and a card carries it" ], "recommendation": "A, because one predicate keeping one meaning for both consumers is what `relationSemiJoinServes`' docblock promises, and splitting it is a second spelling of the same registry fact." } ], "security_findings": "none", "out_of_scope_findings": [ "none" ] }objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8
Release: claim 7234456160 (
session_017xRBcSAaBEfQpU2yJexSJ8,repo:objectstack#8) · 2026-11-28T05:51Z · cause: devneeds_decision(report 7234854982), no code written. The card enters the decision box (needs-user-decision), assignee cleared; this seat re-dispatches on the maintainer's ruling.Resume-from:
claude/issue-34157-semi-join-tenancy-cap@33a0d4fa(empty probe branch)维护者速读
Analysis
One-sentence problem. Under an organization wall, a filter or a report dimension that crosses from an organization's own table to a table shared by the whole platform (or back) does not get the uncapped one-statement read that same-kind tables got on 2026-11-16: the filter is refused past 1,000 related matches, and the report dimension is refused at any size.
Background. PR #33652 (merged 2026-11-16) serves a single-valued relation condition as one in-database subquery, "where it is provably the same read as the id read". Its contract review (record 6900638852, finding S3, should-fix) said: "Name a carrier, or ask for a ruling that the cap stays there." The seat
domain:server#5chose to name a carrier and filed this card.Standing of the premise.⚠️ This card rests on a seat ruling (option B on PR #33652, contract finding S3), not a maintainer ruling. The maintainer-directed parent is #33626 (filing gate ③, 「首先保sql,应该用最高性能的方案」), whose item 2 reads "each hop carries that object's read scope and tenant wall". No maintainer record names this tenancy-class case. The accepted ADR text below conflicts with every option except D, so A, B and C are protocol changes, not a
Bugfix (SKILL 〈升级与决策〉: 「改协议、新增公开面另立卡,⛔ 不作 Bug 选项」). The tenant wall is a security boundary, so this sits on the human floor whatever the letter.Governing text: ADR-0139 D2 step 3, verbatim: "The composed leaf carries
{ object: P, scope }. The tenant wall is not composed here: the driver applies its own tenant scope to the subquery's table with the outer read's options (D3). The engine never re-derives it." D3,driver-sqlbullet, verbatim: "compiles the composed leaf in its filter compiler … tofield IN (SELECT id FROM P_TABLE WHERE SCOPE AND TENANT), the subquery scoped bypackages/drivers/driver-sql/src/sql-driver.ts#applyTenantScopewith the outer read's options." The spec docblock onComposedReadableIdsrepeats it. Re-check:git show origin/main:docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md | sed -n 191,206p.Protocol change? A: yes, the spec leaf shape, ADR-0139 D2/D3 and probably one driver-facing brand or declaration. B: yes, ADR-0139 D2/D3 plus a new
@objectstack/coreexport that no spec type names. C: yes, ADR text only (direction 1 no longer "outer read's options" by proof, direction 2 unchanged). D: none.Premises (read on
origin/main=7605e0c9cc; the dev measured on33a0d4fa):INVALID_FILTER/ 400; the same-class control composesgit grep -n "another tenancy class under a walled posture" origin/main -- packages/objectql/src(1 parametrised pin, 2 directions);git grep -n "RELATION_FILTER_ID_CAP = 1000" origin/main -- packages/objectql/srcrelationSemiJoinServesanswersfalsewhen the posture walls and the two objects differ in tenancy classgit show origin/main:packages/objectql/src/relation-semi-join.ts | sed -n 168,180pReadableIds.compose(leaf, scope)builds and freezes exactly{ object, scope }plus the brandgit show origin/main:packages/spec/src/data/readable-ids.ts | sed -n 293,320ppickDeclaredDriverOptionscuts the bag to the keys ofDriverOptionsSchema.shape, so an undeclared key never reaches a drivergit show origin/main:packages/objectql/src/engine-driver-options.ts | sed -n 144,173preadableIdsSubquery(sql-driver-internal-helpers.ts:160-166), TursotoRemoteWhere(turso-driver.ts:3576-3581), the relation-group derived table (sql-driver-aggregation.ts:340)git grep -n "applyTenantScope(sub, |remoteTenantScope(leaf.object" origin/main -- packages/driversrelationSemiJoinServeshas two consumers: the where lowering (engine-query-lowering.ts:252) and the analytics group join (relation-group-join.ts:378). The second has no id-read fallback: it answers "is not plannable as one statement"git grep -n "relationSemiJoinServes(object" origin/main -- packages/objectql/src ':!*.test.ts'{ object: OBJECT, tenantId: undefined }), andapplyTenantScopereturns the builder unwalled whenoptions.tenantIdis absentgit show origin/main:packages/drivers/driver-sql/src/sql-driver-internal-helpers.ts | sed -n 126,130psql-driver-rotation.ts:311; no statement was capturedgit show origin/main:packages/drivers/driver-sql/src/sql-driver-rotation.ts | sed -n 305,326pMeasured pull (script over
git show origin/main:; 97 object declarations and 94 relation fields inexamples/**andpackages/platform-objects/**):sys_api_key,sys_sso_provider), both inplatform-objects.examples/**: 0 (its two tenancy-disabled objects are federated, which is the separate ruling-A case).sys_api_key.user_idandsys_sso_provider.user_idtosys_user,sys_api_key.active_organization_idtosys_organization). Both targets aremanagedBy: 'better-auth'and declare no organization column, so the wall is inert on them (inferred from the declarations, not from a running schema).git grep -n -E "['\"](user_id|active_organization_id)\.[a-z_]+['\"]" origin/main -- packages/platform-objects/src examples→ 0). No example sets a walled posture. Reading: zero measured pull today; reachable only in a large walled deployment through an author-written filter.Questions. Q1: which carrier, if any, takes the related table's own organization scope to the database subquery (A–D). Q2: who lands the ADR-0139 amendment (A/B). Q3: is the analytics dimension across tenancy classes in scope (A/B).
domain:server· ADR PR + 1–2 code PRs over spec, objectql, driver-sql, driver-turso. Nearest precedents: #34565 (a spec-declared driver fact with its engine readers and the ADR note, +726/−100, 36 files) and #33652 (the semi-join with SQLite and PG pins, +1623/−223, 27 files). No precedent for changing this leaf's shapedomain:server· ADR PR + 1 code PR over objectql, core, driver-sql, driver-turso. No precedent for an engine-to-driver fact outside specdomain:server· 1 PR, objectql only. No precedent for a one-direction serve; the equality rests on a driver fact the engine does not own (P8, inferred)Business meaning. A: every table checks its own organization badge at its own door, and that rule is written into the contract. B: the badge travels on a sticky note beside the contract, and if the note falls off, the door stays open. C: we open the shared-catalog door and leave the other one as it is. D: the reception desk keeps saying "too many matches, ask in two steps".
Four axes, argued from the business side.
INTERNAL_ERROR/ 500, the ADR-0139 D3 envelope): loud, an operator sees it, nobody sees foreign data. Under B the fallback to the outer options is silent by construction. C avoids direction 2 entirely. D is loud today (400). Reading: A with the refusing brand, or D; never B.os-decision-facets
① Long-term: A shrinks a behavioural special case and keeps one contract; B adds a second dialect; C is a half; D keeps the special case. No SQL slowdown for memory/Mongo parity in any option.
② Pull: zero first-party pull (0 / 3 / 0 as counted above; 90 of 94 relations already served); default defer or remove.
③ AI mistakes: A with a refusing brand fails loud (500); B fails silent into a cross-organization read; D is loud (400).
④ No proliferation: A is one more declared key held forever; D declares nothing.
Prior rulings read: "tenancy class" ReadableIds → 3 hits (#34157, #33626, #33619); ADR-0139 D2 step 3 / D3; thread: 4 (this card), plus PR #33652 records 6900638852 and 6902361654
Recommendation. Q1 A, with its sub-choice ruled in the same stroke: the leaf that carries a scope is a distinct brand that an unaware driver refuses (not a change to what the existing capability bit promises). Not B: it is the only option whose failure mode is a silent cross-organization read. Not C: a half delivery whose proof rests on an unpinned driver fact. Not D by axis ①, but D is the honest reading of ② and ④, and the workload gap is far above 3×, so it is named here: ruling D is fully defensible, costs nothing, and only the maintainer can take it. ②, ③ and ④ adjust timing only: p3 stands, no urgency, the amendment lands first and the code follows. Q2 A: ADR-0139 says of itself "This record declares; it implements nothing", and #33992 is the landed shape. Q3 A: one predicate keeps one meaning, and the report dimension is the larger visible symptom (refused at any size, P6).
Confidence gaps: downstream apps (cloud, hotcrm, the blackcat CRM) were not searched, so the pull is first-party only. The dev's premise run was not repeated here (its file was deleted); P1 rests on the report and the pins on main. P8 and P9 are inferred. The Turso remote face and PostgreSQL were read, not run. Local history is shallow, so the precedent sizes come from the pulls API. The exact field and brand names are not proposed here.
Self-check: 只看①选 A;②③④ 是否翻转:是(②零拉动与④不扩散指向 D;字母不改,只调时序;翻 D 只凭维护者本卡另裁)。Q2 只看①选 A,不翻转。Q3 只看①选 A,不翻转。
After the ruling.
repo:objectstack#8retypes the card fromBugto a protocol change, then re-dispatches with the surface widened to the spec leaf, objectql, driver-sql and driver-turso (Clause-②: yes (widening),Metadata-protocol: added). Pins: both directions on SQLite and PostgreSQL with the two-step rows as oracle, an ablation pin that an unaware driver refuses with 500, and an isolated adversarial review of the diff before landing.@objectstack/corein place of spec. Q1 C: one objectql PR; the seat files a carrier for direction 2. Q1 D: the seat closes this card as not planned and records on PR feat(objectql): a nested-relation condition on a read verb is one read-scoped in-database subquery per relationship, up to three, where it is provably the same read as the id read #33652's S3 that the cap stays by maintainer ruling; the docs already list the case; no ADR edit.repo:objectstack#8drafts the ADR-0139 amendment (D2 step 3, the D3driver-sqland Turso bullets, the spec docblock wording) as its own Tier H docs PR; the maintainer approves it; the code PR is cut only after it merges. Q2 B: the dev writes the amendment inside the code PR and the whole PR lands as Tier H.Related. #34157 (this card, p3) · #33626 (closed, the maintainer-directed parent) · #33619 (closed, the hop-count decision) · PR #33652 (merged 2026-11-16, the source of S3) · #33876 / PR #34565 (the capability bit and the ruled 400) · PR #33992 (amendment-only precedent) · PR #22707 (ADR-0139 itself, +287/−1) · #34155 (closed, the sibling carrier filed with this one).