Skip to content

[Decision] ADR-0155 O2: the share-grant subquery on PostgreSQL for an object whose id is not text (integer, uuid) #35906

Description

@objectstack-fleet

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Filing gate: ② a maintainer fork a ruled record routes to the maintainer (ADR-0155 D-0) · Source: fleet (os-dev report 7046516194 on #35872, open_questions[0]; PR #35893). Carries the O2 non-text-key item of #35872; #35872 keeps every other item (compile, declaration, update path, N4, O3 and D6 readings), delivered by PR #35893.

维护者速读

  • 问题:在 PostgreSQL 上,主键是数字或 uuid 的外部表,用新的共享子查询读记录会直接报错;今天按名单读能正常返回被共享的记录。最后一步切换前碰不到用户,切换后这类表上被共享的人会读不到。
  • 选项:A 按表的主键类型做比较,结果和今天完全一样,约一个中等 PR;B 用另一种类型转换,个别超长编号会报错而不是查不到,一个小 PR;C 把主键转成文本比较,写法不同的编号会悄悄对不上,还会变慢,一个小 PR;D 这类表继续用今天带五千上限的名单,这里不改,最后一步多一条分支。
  • 推荐 A:只有它让这类表上的共享和今天读出完全相同的记录,又不留下带上限的老路。
  • 不定会怎样:最后一步(切换共享读取方式)不能在 PostgreSQL 外部表上开启,否则那里的共享读取会报错。

Analysis

Background. ADR-0155 lowers the sharing scope's share-grant arm to an engine-internal semi-join leaf (SharedRecordIds) that SQL drivers compile to id IN (SELECT record_id FROM sys_record_share WHERE …). Step 3 (#35872, PR #35893) compiled it on driver-sql and the Turso remote transport. record_id is a text column; on the tables the platform manages id is also text. On PostgreSQL, a federated (external) object keyed by integer or uuid is sharing-scoped (packages/plugins/plugin-sharing/src/federated-phantom-anchors.ts), and there the compiled comparison fails with DATABASE_ERROR 42883 ("operator does not exist: integer = character varying", and the uuid twin), where today's bound id list answers [7, 42] and both uuids (measured live on PostgreSQL 16 by the dev; PR #35893 Acceptance notes, O2). SQLite answers the same rows through column affinity (measured). MySQL and SQL Server convert implicitly by documentation (unmeasured); Oracle RAW(16) keys are expected to differ (unmeasured).

Governing text. ADR-0155 D-0, verbatim: "An outer key of another type answers the same rows. Where an object's id column is not a string, the subquery answers the rows today's list answers (O2). A refusal there would narrow this invariant on that object, so it is no driver card's to choose: a card that cannot keep the same rows stops, and the case goes to the maintainer under ②." O2: "The driver card pins the comparison, type and collation, on every dialect driver-sql ships, and answers an outer key of another type with the same rows (D-0)." Ruling record 6942854600 on #33787: 「三问都按 ADR 推荐」 (② the recommended column: no capped id list kept anywhere).

Protocol. No change to what a metadata author can write under any option (Metadata-protocol: none).

Premise (re-check). Nothing writes the leaf until ADR-0155 step 6 (#33787): git grep -n 'SharedRecordIds\.' origin/main -- packages/plugins packages/services | grep -v '\.test\.' → 0 hits at eb9f8ed (no producer). The failure is loud (a 500 from the database), never a wrong row set.

Question. What should the PostgreSQL compile answer for an object whose id column is not text?

Option What it does What the customer sees Effort
A Type-aware inner read on PG: cast record_id to the outer key's base type, read once per object from the catalog and cached Same rows as today's list for integer and uuid keys; a malformed grant id fails the statement as a list literal does today domain:server · 1 PR, M · no precedent
B jsonb_populate_record-typed inner read on PG external objects Same rows for int and uuid (measured), but an over-long grant id errors ("value too long for type character varying(10)") where the list answers no match 1 PR, S · no precedent
C Cast the outer column to text (id::text IN (…)) Grant 07 no longer matches 7, an uppercase uuid grant does not match; the outer pk index is lost (full scan) 1 PR, S · no precedent
D Leave the compile; step 6's producer keeps today's capped id list for non-text keys on non-SQLite SQL dialects Those tables keep the 5,000 cap #33787 retires; behaviour splits by key type 0 here, cost moves to step 6

Business meaning: A is "compare like with like"; B is a second conversion with its own edge failures; C changes which records a person sees on spelling differences; D keeps the old silent cap for one class of table.

os-decision-facets

  • ① Long-term: A keeps one statement shape and every grant for every key type (shrinks special cases); C and D each add a permanent special case (a lossy cast, or a second capped path).
  • ② Business pull: federated PG tables keyed by integer/uuid are sharing-scoped today; reachable the moment step 6 writes the leaf; no customer hits it before.
  • ③ AI-safety: A and the current loud 500 never return wrong rows; C changes rows silently (worst); B adds a quieter divergence.
  • ④ Startup focus: D keeps a capped second path alive; A adds driver code for a narrow path but retires the list everywhere.
    Prior rulings read: "ADR-0155 D-0 O2", "6942854600" → ADR-0155 D-0, O2, ② ruled the recommended column; thread: none

Recommendation: A (the dev's, report 7046516194; the card thread concurs). Two years out the platform answers sharing on any SQL table with one in-database semi-join whatever the key type, as mainstream platforms type their joins; A is the only option that meets D-0 as written without keeping the capped list (D) or changing rows silently (B, C). Self-check: only ① picks A; ②③④ flip it: no. Confidence gaps: MySQL/SQL Server implicit conversion and Oracle RAW keys unmeasured; A's catalog read needs a pin per type.

After the ruling. A: a domain:server card in packages/drivers/driver-sql (catalog read + cache, a pin per type on live PG), landing before step 6. D: step 6's card carries the producer branch. B/C: a small driver-sql PR.

Related. #33787 (step 6, Blocked-by this card), #35872 / PR #35893 (step 3), #35873 (step 4), #35874 (step 5), ADR-0155.

Activity

  1. added
    priority:p2
    needs-user-decision
    on Nov 20, 2026
  2. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in domain:server · needs-user-decision (kept); rationale: area:data · Task · decision card for ADR-0155 O2: on PostgreSQL, the share-grant subquery errors on an object whose id is not text (integer, uuid); options A (compare by key type, same result as today, a medium PR), B (another cast, a small PR, rare over-long ids refuse), C (cast to text); no user sees it until the switch → p2 as filed · size S–M by the option. Waits on the maintainer's letter.

  3. added
    domain:server
    on Nov 20, 2026
  4. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c

    Seat note · 2026-11-20T19:11Z · scope carried from step 3's contract review

    Step 3 (#35872) landed as PR #35893 (643fe3b). Its CONTRACT_REVIEW_TIER review (7047602668) leaves two readings for this fork, carried here so whichever option is ruled covers them before step 6 (#33787) is cut:

    • O2 is measured on SQLite (same rows) and PostgreSQL 16 (42883) only. MySQL and SQL Server (implicit conversion by documentation) and Oracle RAW(16) keys are unmeasured. The card that implements the ruled option measures each dialect driver-sql ships, or names the ones it leaves.
    • An id = ANY(ARRAY(SELECT …)) form, outside D2's stated SQL, may keep PostgreSQL's owner index for the no-grant caller's total (the D6 reading). Unmeasured; for the maintainer to weigh at step 6, not a fifth option here.
  5. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c

    Ruled: A — type-aware inner read on PostgreSQL · 2026-11-20T22:01Z

    The maintainer (Tesla) picked option A on seat 7's decision card at 2026-11-20T22:01Z. The card's question was 「PG 上主键是数字或 uuid 的外部表,共享子查询怎么比较?(#35906)」 and the option chosen was 「A 按主键类型比较」.

    So driver-sql casts record_id to the outer key's base type on PostgreSQL. The type is read once per object from the catalog and cached. The result is the same rows as today's id list for integer and uuid keys, with a pin per type on live PG. The card also measures, or names as left, the other dialects driver-sql ships (MySQL, SQL Server, Oracle RAW(16)), per the seat note above.

    This card becomes the work card. It is part of the ADR-0155 chain, which the maintainer counted as work in hand (2026-11-20T18:06Z). It lands before step 6 (#33787), which keeps Blocked-by: #35906 until then. needs-user-decision comes off; triage does the first touch for domain and queue.

  6. removed
    needs-user-decision
    on Nov 20, 2026
  7. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

    Claim: PM loop round 1
    Session: session_01L9qibyXo4gSy8DJPNz4ANz
    Account: os-tesla
    Branch: claude/project-thread-thptm0 (platform exception: this card thread can push only its assigned branch. PR #35945 (#35874) holds it now, so the build runs locally on a worktree branch and is pushed to it after #35945 merges, restarted from main)
    Worktree: objectstack-issue-35906
    Domain: domain:server
    Seat: repo:objectstack#7
    Area: card #35906
    File surface: packages/drivers/driver-sql/src/**: the PostgreSQL arm of the fixed-read leaf's inner read (sql-driver-internal-helpers.ts#fixedReadLeafSubquery, fixed-read-leaf-compile.ts), a catalog read of the outer key's base type with its per-object cache, in a sibling module, since sql-driver.ts is at 10067 of its 10071-line ceiling; the fixedReadLeaves comment (step 3 L2 nit N3, "every dialect"); tests beside each (live PG pins per key type); scripts/adr-anchors/ (new anchor files only); one new changeset .changeset/35906-*.md. Stop on breach and explain in the report. ⛔ No producer writes the leaf (step 6). No driver-turso change unless measured necessary (SQLite answers by affinity). No docs/adr/**, skills/** or packages/objectql/src/engine.ts edit.
    Container & model: M, mode:subagent, model: default, effort: high (FRAME: "M/L high")
    Clause-②: yes
    Clause-② basis: the compiled share-grant subquery changes its SQL on PostgreSQL for non-text keys, keeping D-0's same rows (ruled A).
    Metadata-protocol: none
    Responsibility: n/a — not a defect card (a ruled fork of ADR-0155 O2)
    Thread-read: 7051669729
    Premise: holds (origin/main 170ca48: step 3's fixedReadLeafSubquery compares record_id (text) to the outer id with no cast, so PostgreSQL 16 answers 42883 for an integer or uuid key, as measured on PR #35893; no producer writes the leaf: git grep -n 'SharedRecordIds\.' origin/main -- packages/plugins/plugin-sharing | grep -v '\.test\.' → 0)
    Serial constraints cleared: overlap-check (probe commit over sql-driver.ts, sql-driver-internal-helpers.ts, sql-driver-filter-helpers.ts, fixed-read-leaf-compile.ts, origin/main 170ca48): merges cleanly, 0 open PR heads share them; reruns before each push. Push waits for PR #35945 (same branch, disjoint packages).
    Pre-claim lane: repo:objectstack seat 7, card thread card #35906 (the ADR-0155 L program's thread, which landed step 3); domain:server (drivers/*); no skills/**, docs/adr/** or workflow path
    Pre-claim deps: #35872 (step 3) closed, merged as 643fe3b; ruling 7051669729 (A) recorded; no Blocked-by: line on the card
    Scope-review: exempt — a ruled route (maintainer ruling 7051669729, option A)
    Prior rulings read: ruling 7051669729 (「A 按主键类型比较」: cast record_id to the outer key's base type on PostgreSQL, type read once per object from the catalog and cached, pin per type on live PG; measure or name the other dialects); seat note 7048341758 (MySQL / SQL Server / Oracle RAW(16) unmeasured, owed here; id = ANY(ARRAY(SELECT …)) is not a fifth option, step 6's to weigh); ADR-0155 D-0, O2, D2 (the SQL shape: "⛔ No EXISTS, no correlated form, no join"), ruling record 6942854600; step 3's close-out 7048322381 and L2 7047602668 (N3). check-prior-rulings.mjs --card 35906: ADR-0139 D4 among the named; thread: none beyond the above.

  8. added
    pm:dispatched
    on Nov 20, 2026
  9. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

    os-dev-report · #35906 · PR #35967 (draft) · head 0f3e1d4 (code f00b631)

    The dev built locally while PR #35945 held the branch; the card thread replayed both commits onto main 523ada4 (patch-ids identical) and opened #35967. Status: done. Condensed report:

    • Seam for driver-sql: the share-grant subquery on Oracle for a RAW(16) uuid key (ADR-0155 O2, ruling A applied to Oracle) #35952: new packages/drivers/driver-sql/src/fixed-read-leaf-key-type.ts: pg_catalog read of the outer key's base type (pg_attribute + pg_type, domains walked to base, no typmod), cache = WeakMap keyed by knex client → physical [schema, table] → column → cast. Primed at every where-compiling door beside the existing primeMssqlGuidColumns call (findRows, count, updateMany, deleteMany, aggregate + joined parents, distinct, analyzeQuery, window functions: 8 sites in 6 facet files). Compile site: sql-driver-internal-helpers.ts fixedReadLeafSubquery projects CAST(NULLIF(record_id, '') AS <type>) via castFixedReadLeafColumn(knex, column, cast) only on PG when the base type is not text/varchar; other dialects read nothing and keep step 3's SQL. The $in arm in sql-driver-filter-helpers.ts passes table (threaded through $or via tableHint) and field. sql-driver.ts stays 10067/10071 (stub signature + N3 comment changed in place).
    • Live PG 16.15 (private cluster): same rows as today's list for integer, bigint, smallint, numeric(10,2), uuid (upper-case and braced grants), domain over integer, character(4) (was a SILENT MISS under step 3: list [k1,k2], leaf [k2]; bpchar cast fixes). text / varchar COLLATE "C" unchanged, no cast. Malformed grant ('abc' vs int, 'not-a-uuid' vs uuid): DATABASE_ERROR/500 sqlstate 22P02, identical to the list.
    • Pins: sql-driver-fixed-read-leaf-conformance.test.ts PG cell +28 (six key types × find+count, negation and $or, predicate update, compiled statement; nested under ReadableIds; aggregate; malformed id; one catalog read per table; blank grant per typed table). New fixed-read-leaf-key-type.test.ts 9 unit tests. Full driver-sql: 277 files passed / 4 skipped, 5747 tests passed / 133 skipped (sqlite + live PG RAN, MySQL NOT RUN). Turso fixed-read-leaf conformance 54/54. Typecheck + eslint exit 0.
    • Ablation (committed 7c8cf753aa): cast removed → 29 failed / 86 passed / 1 skipped as predicted (malformed pin shows step 3's 42883); restored blob-equal.
    • Gates: dispatch-gates 80 derived, 78 exit 0, 2 NOT MEASURED (check:dual-build-cjs-loads, check:lean-entry-closure: no full build). check:tenant-chokepoint, check:facade-delegation-only, check:adr-anchors, check:driver-conformance exit 0. overlap-check clean.
    • Oracle, by reading (unmeasured here): list binds HEXTORAW over undashed hex (sql-driver-oracle-dialect.ts#oracleUuidRawBinding, columns primed in oracleRawUuidFieldsByObject at every Oracle door), refuses non-uuid with INVALID_FILTER/400; subquery's implicit VARCHAR2→RAW of a dashed uuid expected ORA-01465. Dev's suggested shape: HEXTORAW(REPLACE(record_id,'-','')) when the outer column is a known RAW(16) uuid. NUMBER keys convert like the list's binds.
    • Left: MySQL (CI live cell push-only), SQL Server (no cell): by vendor docs same rows.
    • Noted: cache has no invalidation for external DDL (same contract as Oracle RAW / MSSQL GUID primes).
    • Open questions as routed by seat 7 (2026-11-20T22:56Z): Oracle RAW(16) → driver-sql: the share-grant subquery on Oracle for a RAW(16) uuid key (ADR-0155 O2, ruling A applied to Oracle) #35952 (ruling A applied to Oracle; plugin-sharing: a member with more than 5000 share grants on one object silently loses access to the grants past 5000 (list misses rows, GET answers 404) #33787 Blocked-by it). MySQL / SQL Server non-text keys → left until a PR-time live cell exists (vendor docs).
    • Deviations: the per-door prime touches six facet files beside the two named compile files, all under driver-sql/src/** (the MSSQL-GUID precedent); the character(n) silent-miss fix is in scope (same mechanism), declared under Clause-②; local suite ran live SQLite + PG only; check:dual-build-cjs-loads and check:lean-entry-closure NOT MEASURED locally (CI's).
    • api_writes: dev 0; card thread 1 (pr_create). mcp_calls: 0.
  10. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

    os-dev-report · #35906 · PR #35967 (draft) · amendment, fix round on L1 REWORK and L2 F1 · head c7cc4e2

    New head c7cc4e28ca, fast-forward from 0f3e1d467e in three commits: 707ffb5cc2 (R1, R2, N1 to N3), 7f4974aac8 (F1), c7cc4e28ca (the CI erasure-ratchet fix: the five { transaction } as any bags in the new pins are typed DriverOptions, test surface back to 236).

    R1, done. Each door runs as the first statement of a fresh SqlDriver on the character(4) key. Each pin asserts the list's rows or count, plus the bpchar cast in every statement that reads sys_record_share. Every ablation below removed one door's prime through ablation-replace.mjs after the commit (at 707ffb5cc2), and each restore was blob-equal to HEAD.

    door pin asserts prime removed
    count count 2 + cast 1 failed / 121 passed / 1 skipped: its own pin
    updateMany (write form) 2 rows touched + cast 1 failed: its own pin
    deleteMany 2 deleted, k3 left + cast 1 failed: its own pin
    distinct [k1, k2] + cast 1 failed: its own pin
    aggregate count 2 + cast 1 failed: its own pin (the first attempt was a no-op, because the replacement did not parse; it was redone)
    aggregate joined parent {1: 2, 0: 1} over a character(4) FK + cast 1 failed: its own pin
    analyzeQuery plan Actual Rows 2 + cast 1 failed: its own pin
    findWithWindowFunctions [k1, k2] + cast 1 failed: its own pin
    find (control) per-key pins 15 failed, as predicted (7 non-text keys x 2, plus once-per-table)

    R2, done. New PG_KEY_CASES rows:

    • smallint: grants 07, 42, cast int2.
    • numeric(10,2): grants 7, 07, 42.0, expected [42.00, 7.00], cast numeric with no typmod.

    The changeset sentence now matches the pins: eight key types.

    Nits.

    F1, preferred route, taken. No reading is now distinct from "read: a text key".

    • A failed or empty catalog read caches nothing.
    • On PostgreSQL, a leaf compared with a table that has no reading is refused in step 3's envelope: INTERNAL_ERROR / 500, logged once per knex client. It is never compiled uncast.
    • An unspellable type name is refused the same way.

    Evidence:

    • (a), live PG. Pool max 1, held by the caller's transaction, acquire timeout 1s. find, count and updateMany with { transaction } each answer INTERNAL_ERROR / 500. Zero statements read the grants, nothing was written, and the error was logged once. The next statement re-reads the catalog and answers the list's rows.
    • (b), live PG. A character(4) table created in an uncommitted transaction. The list in that transaction answers [k1]; the leaf is refused 500.
    • Ablation (refusal disabled, after commit 7f4974aac8): 5 failed / 130 passed / 1 skipped, as predicted: 2 unit pins, the compiled-statement refusal, (a) and (b). Unrefused, (a) answered [k2] against the list's [k1, k2] and (b) answered [] against [k1]. That is the silent miss F1 names. The restore was blob-equal.
    • Nothing real breaks. Every applyFilters site primes. No other package compiles the leaf through driver-sql on PG; service-analytics has its own compiler. The full driver-sql suite on live PG at 7f4974aac8 is 277 files passed / 4 skipped, 5767 tests passed / 133 skipped, with TZ=America/New_York.
    • Step-6 precondition, stated in the PR. A sharing-scoped read in a transaction on a saturated pool, or against a table created in that transaction, now answers 500 where step 3 compiled uncast.

    The fallback route was not needed.

    Gates at c7cc4e2.

    • Changed test files on live PG: 135 passed / 1 skipped.
    • typecheck: exit 0. eslint: exit 0.
    • check:query-options-erasure: exit 0 (236, at the ceiling).
    • dispatch-gates --ran: 80 derived, 80 run, 0 NOT-MEASURED.
    • check:dts-closure and check:dual-build-cjs-loads first read 1. The cause was an organizations dist rebuilt mid-run by an overlapping earlier gate run of mine. After rebuilding that package, both exit 0.
    • overlap-check: clean against main 9ed18a50e0.

    The PR body was brought to this head through the relay issue_patch (stored identical). Its false sentences were the six key types, uncast on a failed read, the test counts and the local-gates head.

    api_writes this round: 2 (issue_patch on #35967, this comment). mcp_calls: 0.

  11. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

    os-dev-report · #35906 · PR #35967 (draft) · amendment, S1 from delta L2 · head 99e085e

    New head 99e085ec96, fast-forward from c7cc4e28ca, one commit.

    S1, code route, done. A door in the caller's transaction now reads the catalog on that transaction's own connection. The read runs inside a savepoint: trx.transaction(sp => sp.raw(...)), with the transaction taken from the door's options, passed to the prime at all 9 sites and to the compile-site lookup.

    • No second pooled connection is needed, a table the transaction created is visible, and a failed read rolls back only the savepoint.
    • That reading is cached for that transaction only (a WeakMap keyed by the transaction), because the table it describes may never commit. Outside a transaction the read stays on the pool, cached per knex client.
    • Everything from F1 is kept: a failed or empty read is not cached, unread or unspellable is refused with 500, and the refusal is logged once.

    Live PG pins, turned around:

    • (a) A single-connection pool held by the caller's transaction, with a 1s acquire timeout. find, count and updateMany answer the list's rows ([k1, k2], 2, 2). All 3 grant-reading statements carry the bpchar cast, and nothing is logged.
    • (b) A character(4) table created in the uncommitted transaction. The list returns [k1], the leaf returns [k1], count is 1, and both statements carry the cast.
    • (c), new. A test seam turns the catalog read inside the savepoint into select 1/0, a real PostgreSQL error on the caller's connection. find and count are refused with INTERNAL_ERROR / 500, logged once, and the read was attempted twice. The caller's transaction then still runs select 1 and a list read. With the seam removed, the next leaf statement answers the list's rows.
    • Unit, new. In a transaction the read goes through the savepoint and not the pool, once per transaction. The reading is refused outside that transaction, and a failed savepoint read records nothing.

    Ablation. I moved the read back to the pool, through ablation-replace.mjs after the commit: 4 failed / 133 passed / 1 skipped (138), as predicted. Live (a) and (b) are refused with 500 (no reading), (c) answers rows instead of refusing, and the unit pin fails. The restore was blob-equal to HEAD.

    Text keys. The changeset's "Unchanged" bullet now says exactly what changes: the compiled statement is step 3's, with no cast. The first leaf statement per table (once per driver, or once per transaction) is preceded by the catalog read, and if that read fails or finds no relation, the statement is refused with 500 instead of run. The PR's step-6 line is narrowed: the saturated pool and the in-transaction table are no longer preconditions. What remains is a failing catalog read refusing where step 3 ran uncast.

    Gates at 99e085e.

    • Full driver-sql suite on live PG: 277 files passed / 4 skipped, 5769 tests passed / 133 skipped.
    • The changed test files: 137 passed / 1 skipped.
    • typecheck, eslint and check:query-options-erasure (236, at the ceiling) all exit 0.
    • dispatch-gates --ran: 80 derived, 80 run, 0 NOT-MEASURED, all exit 0 on the first pass.
    • overlap-check: clean against main 9ed18a50e0.

    The PR body was updated through the relay issue_patch (stored identical).

    api_writes this round: 2 (issue_patch on #35967, this comment). mcp_calls: 0.

  12. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

    os-dev-report · #35906 · PR #35967 (draft) · amendment, delta-2 L1 R1 and L2 S2 · head 1e61bf8

    New head 1e61bf84ed, fast-forward from 99e085ec96, one commit.

    R1 / S2, done. I took the second route: the lookup reaches the parent transaction's reading from a derived savepoint.

    • transactionReading walks knex's parentTransaction chain. The prime uses it to skip a read and the compile-site lookup uses it to find one.
    • Why this route over priming inside issue:
      • attemptWithoutPoisoning opens a new savepoint on every presumed write. Priming inside issue would pay one more savepoint and one more catalog read on every such write, because the reading would be cached under a transaction object that is thrown away.
      • It would also fix only this one door.
      • The parent-chain walk is sound for any savepoint derived from the caller's transaction, now and later: a savepoint runs on its parent's connection and sees what the parent sees.
      • It never runs the other way. A reading a savepoint takes may describe a table that rolls back with it, so it never reaches the parent.

    The pin. Pin (d) runs on live PG, on a fresh driver, as the first statement. The object is managed (registerObjectMetadata over a table the driver did not create), so its updated_at is presumed. There is one object with a text key and one with a character(4) key. A predicate updateMany with the write-form leaf, inside a caller transaction, answers the list's rows (2), touches them, settles the presumption, and the character(4) statement carries the cast.

    • Red on the old head. With the pin added and the code at 99e085ec96: 2 failed / 126 passed / 1 skipped. Both are INTERNAL_ERROR / 500 "holds no reading", for the text key and the character(4) key.
    • Unit pin. A savepoint derived from the transaction reaches the transaction's reading without a second read, and a savepoint's reading never reaches its parent.
    • Ablation after the commit. With the parent walk removed (at = undefined): 3 failed / 137 passed / 1 skipped (141), as predicted. The red pins are the unit pin and (d) for both key types. The restore was blob-equal to HEAD.

    Sweep. grep -n 'applyFilters(' over driver-sql/src (non-test) finds 12 call sites.

    • All of them compile under the options their door primed with, except sql-driver-bulk-operations.ts:326, which is updateMany's issue and is now covered.
    • sql-driver-internal-helpers.ts:145, the composed scope, uses the door's options. sql-driver-latest-per.ts:133 is reached only from findRows, with its options.

    I also grepped for derived transaction options: { ...options, transaction: … }, .transaction(async and attemptWithoutPoisoning(. That finds bulkUpdate (:268, which goes to update by id), upsert (sequence-semantics.ts:842 and :853) and the autonumber sequence (autonumber.ts:193). None of them calls applyFilters. So I found no other door, which agrees with L1.

    L2 additions.

    • (1) The changeset's "Read where the statement runs" bullet and the anchor invariant now say that the reading reaches derived savepoints, and name the presumed-updated_at write path. The bullet also states the cost: one savepoint and one catalog read per transaction per table.
    • (2) The prime's docblock now says that, while the savepoint is open, knex runs the caller's concurrent statements on that transaction inside it, so a failed catalog read rolls back a concurrent write made during the read.
    • N1: the "How the type is known" bullet now says "once per driver" holds outside a transaction only.
    • The PR body's step-6 line names the cost and the interleave, and it carries the sweep.

    Gates at 1e61bf8.

    • Full driver-sql suite on live PG: 277 files passed / 4 skipped, 5772 tests passed / 133 skipped.
    • The changed test files: 140 passed / 1 skipped.
    • typecheck and eslint exit 0. check:query-options-erasure exits 0 (236, at the ceiling).
    • dispatch-gates --ran: 80 derived, 80 run, 0 NOT-MEASURED.
    • overlap-check: clean against main 9ed18a50e0.

    The PR body was updated through the relay issue_patch (stored identical).

    api_writes this round: 2 (issue_patch on #35967, this comment). mcp_calls: 0.

  13. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

    Close-out · 2026-11-21T04:59Z · ADR-0155 O2 (PostgreSQL share-grant key type) landed

    Merged as 850bcec018 via PR #35967 (head 1e61bf84ed, 2026-11-21 04:58 UTC). Reviews: L1 REWORK 7055124444, delta ACCEPT 7056216450, delta-2 REWORK 7056796280, delta-3 ACCEPT 7057216047. L2 TIER_DEFAULT (declaration face only): PASS 7055157866 (F1), delta PASS 7056236983 (S1), delta-2 PASS 7056813710 (S2), delta-3 PASS 7057221897 (all closed). Landing 7057235388. Dev amendments on this card: 7056181587, 7056768200, 7057194515.

    What landed (@objectstack/driver-sql, patch):

    • On PostgreSQL the share-grant subquery projects CAST(NULLIF(record_id,'') AS <base type>) when the outer key is not text. The type is read from pg_catalog (domains walked to base, no typmod), cached per knex client outside a transaction, and per transaction inside one. Text keys compile exactly as step 3 did.
    • Inside a caller's transaction the catalog read runs on that transaction's connection under a savepoint; a savepoint derived from it (the presumed-updated_at retry of updateMany) reaches the parent's reading, one way only.
    • No reading (a failed or empty catalog read) or a type name that cannot be spelled as one identifier answers INTERNAL_ERROR/500, logged once per knex client; a failed read is not cached. It is never compiled uncast.
    • Same rows pinned on live PG for int, bigint, smallint, numeric(10,2), uuid, a domain, character(n) and text, at all 8 doors as a fresh driver's first statement, plus pins (a)–(d) for a held pool, an uncommitted DDL table, a failed read inside a savepoint, and a presumed managed object. character(n) was a silent miss under step 3 and now answers the list's rows.

    Carried:

  14. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

    Closed by PR #35967; pm:dispatched removed.

  15. removed
    pm:dispatched
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:datadomain:serverpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions