Skip to content

fix(driver-sql): on Oracle, a composed ReadableIds scope primes its RAW(16) parent's uuid columns - #36084

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-35960-oracle-raw-prime-composed-scope
Nov 21, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-35960-oracle-raw-prime-composed-scope

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #35960

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在 Oracle 外部表上,主键为十六字节二进制 uuid 的父对象,其子记录按父记录可见性读取时,现在第一次读就返回应有的记录,取反也只返回其余记录。
  • 为什么做:数据权限里“按父记录控制可见性”的子对象在 Oracle 上静默读空,替用 Oracle 外部表的部署解决这个问题。
  • 出错会怎样:只影响 Oracle 驱动在读子对象前多读一次父表的列类型;若读取失败则按原来的方式绑定,可直接撤回本次改动。
  • 要你做什么:无。

What changes

On Oracle, a door primes a federated table's RAW(16) uuid columns from the catalog before it binds a comparand (primeOracleRawUuidColumns). It primed only the door's own object, so a composed ReadableIds scope naming a RAW(16)-keyed parent bound the parent's ids as text: the child read answered no row and its negation every row, until something read the parent on that driver.

  • sql-driver-field-mapping.ts: primeOracleRawUuidColumns(object, where?) now primes the door's object and every object a composed ReadableIds leaf in where names, at any depth. It reuses the existing walk collectTextMatchObjects (the SQL Server GUID prime's), ignoring its text-operator answer, so there is still one walk.
  • Every Oracle door that primes with a filter in hand passes it: find/findOne (findRows), count, distinct, updateMany, deleteMany, aggregate (its where plus measure filters, folded once into primedWhere for all three primes, and each joined parent's scope), findWithWindowFunctions, analyzeQuery.
  • sql-driver.ts: the stub takes and forwards where; its docblock says what it now primes.
  • Doors with no filter (create, bulkCreate, update, delete, bulkDelete) are unchanged. Every other dialect is unchanged (the body returns on !isOracle first).

Read first, by risk: sql-driver-field-mapping.ts (the prime body, the loop over objects), sql-driver-aggregation.ts (the primedWhere hoist feeds the SQL Server and PostgreSQL primes too), sql-driver-fixed-read-leaf-conformance.test.ts (the new describe).

Tests

New live pin in sql-driver-fixed-read-leaf-conformance.test.ts, on the Oracle testkit cell (ORACLE_CELL, gvenzl/oracle-free 23-slim-faststart): a composed scope's RAW(16) parent is primed by the child's own door: a fresh driver, the child read first. Each case builds a fresh SqlDriver, and the child read is its first statement. Two forms: the LIST form { id: { $in: [U1 upper-case, U2] } } inside the composed scope, and the share-grant leaf. Ten cases each: find [c1, c2], the negation [c4], count 2, the negation's count 1, distinct, aggregate (where and measure filter), findWithWindowFunctions, analyzeQuery (statement carries HEXTORAW(), updateMany, deleteMany.

The existing nested pin no longer reads the parent first; its comment said the child's door primes the child alone, which is no longer true.

Measured on main 8145424 before the fix: 20 of 20 red
Tests  20 failed | 80 skipped (100)
AssertionError: expected [] to deeply equal [ 'c1', 'c2' ]
AssertionError: expected [ 'c1', 'c2', 'c4' ] to deeply equal [ 'c4' ]
AssertionError: expected +0 to be 2
AssertionError: expected 3 to be 1
AssertionError: expected 'select * from "SRIDO_CHILD" where "PA…' to contain 'HEXTORAW('
With the fix, at head 1924389: both Oracle live files green
src/sql-driver-fixed-read-leaf-conformance.test.ts + src/sql-driver-oracle-federation-conformance.test.ts
Test Files  2 passed (2)
Tests  365 passed | 2 skipped (367)      (20 of 20 pin cases pass)
os-verify-lock: VERDICT command-exit 0
Ablation: the walk call removed, pin red, restored to HEAD

node scripts/ablation-replace.mjs replaced the line collectTextMatchObjects(where, objects); in the Oracle prime with a marker (anchor 1 to 0, blob bb3b7d936b29 to 73e309341315), ran the pin: Tests 20 failed | 80 skipped (100). Restored: blob equals HEAD (bb3b7d936b29), git diff HEAD empty. The test imports the driver from src/, so no rebuild is involved. A first attempt was refused by the tool before any test ran (its replacement text already appeared in the anchor, so the count did not rise); it measured nothing.

Package suite and typecheck
  • pnpm --filter @objectstack/driver-sql test (Oracle cell on), at 0c200dd: Test Files 268 passed | 13 skipped (281), Tests 4686 passed | 258 skipped (4944), VERDICT command-exit 0. The later head 1924389 only removes two as any casts in the pin.
  • pnpm --filter @objectstack/driver-sql typecheck: exit 0, and tsc --noEmit again at 1924389: exit 0. --listFiles includes the conformance test file (1 hit).

Acceptance notes

  • findWithWindowFunctions on a federated Oracle object: a window spec's orderBy/partitionBy field is not mapped through external.columnMap (ORDER BY "id" gives ORA-00904 on a table whose column is ID), and Oracle refuses ROW_NUMBER() OVER () without an ORDER BY (ORA-30485). The pin orders by the stored column ID and says so. Not filed: the door has no producer outside the driver packages (the request surface tombstones windowFunctions; git grep findWithWindowFunctions outside the drivers hits only CHANGELOG files).
  • Aggregate's joined parent now primes the objects its own scope composes, too (same walk). That deeper path is not pinned live here: the fixture has no grandparent.

Verification

Two-minute check: with an Oracle Free container running and OS_TEST_ORACLE_URL=oracle://USER:PASSWORD@127.0.0.1:PORT/FREEPDB1, run
pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-fixed-read-leaf-conformance.test.ts -t 'fresh driver, the child read first'
and expect Tests 20 passed. On main the same command answers 20 failed.

Local gates (derived by dispatch-gates --commands)

node scripts/pm/dispatch-gates.mjs --ran on the exit-coded record: 72 derived famil(ies) accounted for — 70 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3). The 70 ran at 0c200dd with exit 0 (check:query-options-erasure went red there, +1 test-surface site from two casts in the pin; the casts were removed and it is green at 1924389). Re-run at 1924389, all exit 0: check:test-source-alias, check:cross-package-test-inputs, check:nul-bytes, check:issue-citations, check:doc-authoring, check:driver-conformance, check-empty-changeset, check-changeset-no-major, check-adr-0087-registration.

NOT MEASURED: check:dual-build-cjs-loads and check:lean-entry-closure, reason: PREREQUISITE NOT MET (exit 3). They read the whole repo's built output and only driver-sql's dependency closure was built. CI runs them.


Generated by Claude Code

…ds scope's parent

Each Oracle door that compiles a filter now primes the RAW(16) uuid columns of
every object a composed ReadableIds leaf in that filter names, through the same
walk the SQL Server GUID prime uses, so the parent's comparands bind through
HEXTORAW on a driver that has not read the parent yet.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7
…s Oracle requires

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

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/driver-sql, touching 23 documentable anchor(s).

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

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

What this run could not see
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 15 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 fddb9cbb284830d40d2d663f9d1409f9b3b43c15 → packageMentionDocs.

Which tree this was computed on

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

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

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1 · PR #36084 · head 19243893f3 · ACCEPT (CI not concluded) · 2026-11-21T12:48Z

Card #35960. Claim 7062025264, report 7062798455. Clause-② no and Metadata-protocol none. There is no spec, governed or narrowing face, so this PR owes no L2. I read the whole diff against 8145424b53, 10 files, +171/−55. That base already holds #36001 (907b3783), so the changeset's "for the share-grant subquery alike" is true at this head.

What holds

  • One walk. primeOracleRawUuidColumns(object, where?) seeds {object} and adds the objects returned by collectTextMatchObjects(where, …). That is the same walker the SQL Server GUID prime uses: it adds node.object for each composed ReadableIds and recurses into its scope, so nested scopes are covered at any depth. It reads plain objects and arrays only.
  • Each target primed once. Each target is primed once per object (oracleRawUuidFieldsByObject.has(target) → skip). Only federated objects are read. A failed catalog read records nothing, and the loop continues to the next target instead of returning, which is right: one parent's failure no longer skips its siblings.
  • List and leaf read the same map. The leaf's $in arm from feat(driver-sql): the share-grant subquery converts a RAW(16) uuid key on Oracle as the list binds it (ADR-0155 O2) #36001 reads oracleRawUuidFieldsByObject.get(table), where table is the scope's own object (coercionKey on the subquery's builder). The list's coerceFilterValue reads the same map, so both forms bind through HEXTORAW once the parent is primed.
  • Every Oracle door with a filter passes it. That covers findRows (and with it find / findOne), count, distinct, updateMany, deleteMany, analyzeQuery, findWithWindowFunctions, and aggregate. aggregate passes primedWhere, so measure filters are folded in once and shared by the three primes; this is a refactor that changes no behaviour for SQL Server or PostgreSQL. Its joined parents pass join.parent.scope. The remaining Oracle-only call sites (bulkCreate, findOne by id, sequence-semantics) carry no where with a leaf, as I found on feat(driver-sql): compare the share-grant subquery by the key's type on PostgreSQL (ADR-0155 O2, ruling A) #35967.
  • Live pins. Each door's first statement runs on a fresh driver, so nothing has read the parent yet. There are 2 forms × 10 cases:
    • find and its negation ([c4], never every row);
    • count and the count of its negation;
    • distinct;
    • aggregate, in both where and a measure filter;
    • window functions;
    • analyzeQuery, whose SQL carries HEXTORAW(;
    • updateMany, which touches [c1, c2];
    • deleteMany, which leaves [c4].
  • Red/green. 20 red on main, 20 green on the fix, and the ablation turns the same 20 red.
  • Changeset. I checked it sentence by sentence. It also discloses the silent arm on main: no rows, and every row under negation.

Nits (no re-review needed)

  • N1. Unpinned door. The aggregate's joined parent passes its own composed scope, which is correct by reading, but no live pin covers it. On feat(driver-sql): compare the share-grant subquery by the key's type on PostgreSQL (ADR-0155 O2, ruling A) #35967 the joined-parent pin (RelationGroupJoin over a character(4) FK) was the template; an Oracle twin would close this here or in a follow-up.
  • N2. Claim surface. findWithWindowFunctions fits the claim's clause ("the Oracle doors that call it with a filter in hand"), so I accept it. sql-driver.ts, however, is not named: its stub signature and docblock changed (+5/−3, line count steady). Post a one-line claim amendment record naming both.

Owed

  • CI at 19243893f3: 12 success, 16 skipped and 22 in progress at the stamp, including Test Core 1–10, Build Core, every Type Check, and the lints (query-options erasure among them, after the two as any casts were removed). It is not concluded yet. This ACCEPT holds on this head once CI is green.
  • Oracle has no CI witness. No CI job provisions Oracle, so the dev's local live runs are the only Oracle evidence for these 20 pins.
  • Out of scope: window orderBy is not mapped through columnMap (ORA-00904). File it as its own card if it isn't one already.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7

Landing: PR #36084 (#35960) at 19243893f378eaa973cf0a5277915418b75452a0, 2026-11-21T13:20Z

  • Review: L1 ACCEPT 7062827204 at this head. No L2 is owed: Clause-②: no, no narrowing, and no spec or governed path (files read: packages/drivers/driver-sql/src/** and one changeset). N2 is closed by the claim amendment on driver-sql (Oracle): a read scoped by a parent with a RAW(16) uuid key misses every row until something has read the parent #35960; N1 (a live pin for the aggregate joined-parent prime) is carried as a nit.
  • Checks: 37 success and 16 skipped on this head, with no failure and none pending. mergeable_state is clean. K = 14 since the merge base, and main has not touched packages/drivers/driver-sql/** since then; merge-tree with origin/main is clean.
  • Oracle evidence: no CI job provisions Oracle, so the dev's local live runs on Oracle Free 23ai are the record: 20 red on main, 20 green on the fix, and the ablation turns 20 red (report 7062798455).
  • Not governed and not narrowing, so it lands under the seat's standing go-ahead.

Marking ready and arming auto-merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 21, 2026 13:21
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 521b4f6 Nov 21, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35960-oracle-raw-prime-composed-scope branch November 21, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

driver-sql (Oracle): a read scoped by a parent with a RAW(16) uuid key misses every row until something has read the parent

2 participants