Skip to content

objectql: a committed trio handle reverts to unattributed instead of closed #35149

Closed

Description

@objectstack-fleet

repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

What

After a ScopedContext trio transaction commits or rolls back, the engine drops the handle's owner record, so the handle reverts to "unattributed" instead of "closed". A late write that still carries that handle to another datasource is handed the dead foreign handle again.

A closed transaction() unit's handle is treated differently: isClosedUnitHandle answers true, the handle is treated as absent, and the late work runs unenrolled (#22855). The two kinds of handle should agree.

Where

Origin

Nit N2 of contract review 6969574094 on PR #35102 (card #35028). It is the pre-PR behaviour for trio handles, unchanged by that PR and outside its card. The ADR-0119 note's "a handle the engine never opened" does not quite cover it.

Suggested direction (unverified)

Mark the trio handle closed on commit/rollback (so isClosedUnitHandle answers true for it) instead of forgetting it, and pin that a late cross-datasource write carrying a committed trio handle runs unenrolled, as a closed transaction() unit's late work does.

Re-check: git grep -n "isClosedUnitHandle" origin/main -- packages/objectql/src and read the trio release path once #35102 has merged.

Activity

  1. added
    finding
    on Nov 18, 2026
  2. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    First touch: p2 · domain:server · pm:queue. Grading principle of 2026-11-18, item 3: an engine consistency edge. A late write carrying a committed trio handle to another datasource is handed the dead handle again, where a closed transaction() unit handle is treated as absent (#22855). No user flow is named and no data loss is shown. It follows PR #35102 (card #35028, p2).

  3. added
    domain:server
    pm:queue
    priority:p2
    on Nov 18, 2026
  4. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Claim: PM loop round 16 · area data-1 (the maintainer, verbatim, 2026-11-19T04:35Z project chat: 「再开 area:data」; standing 「暂时都只派 p1 p2 的卡」) · 2026-11-19T13:43Z
    Area: data-1
    Session: session_01Utp6Ca1jJvsA1dHsPwMiQb
    Account: os-bill
    Branch: claude/issue-35149-trio-handle-closed
    Worktree: objectstack-issue-35149 (os-dev worktree in the data-1 container)
    Domain: domain:server
    Seat: repo:objectstack#5
    File surface: the trio owner record and its commit/rollback release in packages/objectql/src/ (located by the dev: engine-scoped-context.ts, engine-transactions-section.ts, engine-execute-transactions.ts, engine-driver-options.ts, unit-detach.ts), the PR #35102 test that pins "forgets the owner once the trio commits", a new test named for this card, root .changeset/. ⛔ engine.ts must not grow (facade ceiling 6854, ruling 6897467376). ⛔ Not engine-delete-and-aggregate.ts (#35329) or aggregate-query-shape-door.ts (#34886). Stop on breach and report.
    Container & model: M, mode:subagent, model: default — no path-derived mandate, effort: high
    Clause-②: no (an internal handle-lifecycle consistency fix; measure on the diff)
    Metadata-protocol: none
    Responsibility: platform — a late cross-datasource write carrying a committed trio handle is handed the dead foreign handle again, where a closed transaction() unit's handle is treated as absent (#22855); engine callers holding a stale handle.
    Thread-read: 6972365865
    Premise: read from code (contract review 6969574094 N2 on PR #35102); PR #35102 merged. The dev re-reads the trio release path on origin/main first.
    Serial constraints cleared: #35167 / PR #35386 merged (sequenced before this card); no open PR holds the trio path.
    Pre-claim lane: domain:server (packages/objectql/**)
    Pre-claim deps: #35028 / PR #35102 merged.
    Prior rulings read: contract review 6969574094 N2; #22855 closed-unit handle rule; ADR-0119 note; facade ceiling ruling 6897467376; thread: 1

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 19, 2026
  6. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
    os-dev-report

    {
      "issue": 35149,
      "status": "done",
      "branch": "claude/issue-35149-trio-handle-closed",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35541",
      "head": "b548ddfb97",
      "session": "session_01Utp6Ca1jJvsA1dHsPwMiQb",
      "premise_still_valid": true,
      "summary": "The ScopedContext trio now marks a handle it opened as closed on commit and rollback (closeTrioTransactionScope adds it to a module-level closedTrioHandles WeakSet in engine-execute-transactions.ts, besides dropping the owner record), and isClosedUnitHandle (engine-transactions-section.ts) answers isClosedTrioHandle(handle) when openedUnits holds no entry. A late write carrying a committed or rolled-back trio handle now runs unenrolled, as late work carrying a closed transaction() unit handle does (#22855); openTransactionKind answers none for it. A begin that gets the same object back from the driver clears the mark. engine.ts untouched (6852 lines at base and head). The new pins are a top-level describe in the existing harness file engine-transaction-same-origin.test.ts, named for the card; no new test file (AGENTS shared-harness rule).",
      "a0": "REPRODUCED at origin/main 921211960d source (new tests only): a late ledger insert carrying a committed trio handle reached the ledger_db driver with transaction { __trx: 'primary' } (the dead foreign handle), and the same after rollback; observable = the dead handle handed to the wrong driver, no refusal. vitest: Tests 7 failed | 27 passed (34).",
      "a1": "Owner record: trioTransactionScopes WeakMap, engine-execute-transactions.ts:78 at base; record at :81 (recordTrioTransactionScope), release at :88 (forgetTrioTransactionScope), read at :95 (trioTransactionScopeOf). Callers at base: engine-scoped-context.ts:359 (beginTransaction records), :375 (commitTransaction finally forgets), :391 (rollbackTransaction finally forgets). Readers: enforceTransactionOrigin engine-execute-transactions.ts:309, transactionCoversDriverFor engine-middleware-and-context.ts:445.",
      "a2": "isClosedUnitHandle body at engine-transactions-section.ts:186 (facade engine.ts:5449 only delegates): detached handle -> true; primitive -> false; else openedUnits entry with transaction undefined. A trio handle joins it with no engine.ts edit: the facet imports isClosedTrioHandle from engine-execute-transactions.ts and answers it when openedUnits holds no entry; engine.ts byte-identical to base.",
      "a3": "The PR #35102 pins 'forgets the owner once the trio commits / rolls back, too' pinned only that a late ledger insert with the closed handle lands (1 write, not refused); they did not assert the handle it got, which was the dead primary handle. Re-worded to 'treats the handle as closed once the trio commits / rolls back, too — a late cross-datasource write runs unenrolled', intent kept, plus expect(ledgerDb.writes[0].transaction).toBeUndefined().",
      "tests": "b548ddfb97: vitest run engine-transaction-same-origin + engine-scoped-transaction-late-write + open-transaction -> Test Files 3 passed (3), Tests 69 passed (69). objectql typecheck && test under the lock -> VERDICT command-exit 0, Test Files 615 passed (615), Tests 13900 passed (13900), check:test-typecheck OK. Ablation 1 via ablation-replace.mjs (anchor x1->x0, blob abff61612cfc->235b522e2582, close stops marking): Tests 7 failed | 27 passed (34); restored blob == HEAD, git diff HEAD empty. Ablation 2 (record stops clearing the mark, blob ->99010386c306): Tests 1 failed | 33 passed (34), the reused-handle pin; restored, git diff HEAD empty. The tests import ./engine.js from src, so no dist leg.",
      "gates": "Local: dispatch-gates --commands derived 65 families; 59 ran with exit 0 each; check:type-check-debt exit 3 (PREREQUISITE NOT MET, its closure build never got the lock) = NOT MEASURED; check:dts-closure, check:dual-build-cjs-loads, check:lean-entry-closure, check:published-files, check:sourcemap-no-sources-content not run locally (they read objectql dist; the objectql build stayed queued on the lock for more than 45 minutes behind #35329's dogfood and #34886's r4 run) = declared narrowing to CI. --ran with exit codes: 65 derived, 59 run, 1 NOT-MEASURED, 5 UNRUN (exit 1, the 5 above). overlap-check --branch=HEAD: VERDICT clean exit 0. PR check-runs on b548ddfb97, read once: Lint & Repo Gates success, Type Check · debt ledger success, Type Check · source gates success, Governed Surface Queue Guard success, Check Changeset success, Dogfood Regression Gate success, Live E2E UI success, Test UI success, PR-body guards success; Build Core, Test Core (1-10/10), Type Check · workspace, Type Check · consumer gates in_progress.",
      "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
      "line_budget": "+133 / -12 over 5 files; engine.ts 6852 -> 6852 (ceiling 6854)",
      "files_changed": [".changeset/35149-trio-handle-closed.md", "packages/objectql/src/engine-execute-transactions.ts", "packages/objectql/src/engine-scoped-context.ts", "packages/objectql/src/engine-transactions-section.ts", "packages/objectql/src/engine-transaction-same-origin.test.ts"],
      "deviations": ["Six derived gate families not measured locally (lock never granted); CI ran them on the PR, see gates.", "The order's 'a new test named for this card' is a new top-level describe named for the card in the existing harness file, per the AGENTS shared-harness rule."],
      "mcp_calls": "0",
      "api_writes": "3 — git push (branch, twice; not REST); relay pr_create: POST /repos/objectstack-ai/objectstack/pulls + POST /issues/35541/assignees (os-bill); relay comment POST /repos/objectstack-ai/objectstack/issues/35149/comments (this report)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": []
    }
  7. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Close-out 2026-11-19T15:54Z: PR #35541 merged, and Fixes closed this card.

    When the ScopedContext trio commits or rolls back a handle it opened, it now marks that handle closed. A late write carrying that handle runs unenrolled, as a closed transaction() unit handle does (#22855). It is no longer handed the dead foreign handle, and openTransactionKind answers 'none' for it. If a driver reuses the same handle object on a later begin, the mark is cleared. An open trio handle still enrolls, and a cross-datasource write under it is still refused (CONTROL). engine.ts is untouched.

    Both PR #35102 pins now assert that the late write carries no transaction. Two ablations and the full objectql suite back the change.

    L1-a ACCEPT 7013453714, with no L2 owed. pm:dispatched off.

  8. removed
    pm:dispatched
    on Nov 19, 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:serverfindingpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions