Repository navigation
fix(objectql)!: an action body's write inside ctx.api.transaction keeps its audit rows beside a telemetry datasource - #35102
Conversation
…iver at the same-origin gate The discrete beginTransaction trio never publishes into txStore, so both same-origin gates stepped aside for its handle: a ledger row routed to the telemetry datasource ran on the primary's connection and was lost, and a cross-datasource business write ran on the wrong connection. The trio now records the owner it knows at begin, and the gates read that record. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
… action door Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
…0119 note narrows the gate's limit Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
… handle Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
…e body opened a transaction Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
…body's transaction Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
…urce body write is refused Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
…R's import edit Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
…dit-write-in-action-tx
…ption Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
…ata at collection Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin d40a3fc74777a8aad60d6686c1ad58ede9aea12c && git checkout d40a3fc74777a8aad60d6686c1ad58ede9aea12c
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e81ecccd2b897a7e2a3a68cf489f30cfe6821736 d7aba9673223d5740a3755ff68f95b691eeb1a8b && git checkout -B drift-repro e81ecccd2b897a7e2a3a68cf489f30cfe6821736 && git merge --no-ff d7aba9673223d5740a3755ff68f95b691eeb1a8b
node scripts/docs-audit/affected-docs.mjs --json e81ecccd2b897a7e2a3a68cf489f30cfe6821736
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa Hand-off (area o3-H → next PM) · 2026-11-18T03:24ZSeat 3 is handing over on the maintainer's order (2026-11-18 03:19Z). This PR is WIP pushed: route A is implemented and pinned, but the narrowing obligations are not finished. It is not ready for review. Card: #35028 (p1). Reading 6964984927. Seat ruled route A at 2026-11-18 00:20Z. Claim 6964496798 plus its route-A amendment (Clause-②: yes (narrowing), Tier H). Done
Left (next step first)
Related, not in this PR#35052 (platform Lease |
|
repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9 L1 review (#35028, route A, Tier H, narrowing) · 2026-11-18T04:56ZL1: REWORK (PR body only; nothing in the code) This is the first L1 on this PR. I read the full diff against the merge-base Must-fix
Should-fixNone. What I checked, and found sound (this stands for the re-ACCEPT): Route A against the code.
Scope.
Changeset.
I checked its sentences against the diff and the pins:
ADR-0119 note. It is add-only and dated, and the paragraph above it is not rewritten. The symbol it cites, Pins and ablations. All four ruled pins are present: the split-layout ledger rows, single-datasource parity, the cross-datasource refusal on insert, update and delete, and the #34998 roll-up child stall bound.
Battery and gates at this head (report 6969444494).
CI at this head, read from check-runs (59): no failure and nothing in progress. Lint & Repo Gates, TypeScript Type Check, Build Core, all 10 Test Core shards and their aggregate, every Lint · and Type Check · lane, Live E2E UI, Check Changeset (re-run after the body edit), PR-body guards, Governed Surface Queue Guard and Spec property liveness are green. The UI lanes are skipped by path filter. Notes
|
|
repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9 L1 review, M1 re-read (#35028) · 2026-11-18T04:58ZL1: ACCEPT The head is unchanged since my REWORK 6969498926, so I re-read only the body line that M1 named. M1, closed. The body now reads Everything in 6969498926 stands for this head: route A in the code, scope and the re-claim surface, the changeset sentences, the add-only ADR-0119 note, the four ruled pins with their ablations, the full dogfood battery pinned to this head, CI, and no freeze flag. Must-fixNone. Should-fixNone. Notes
|
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Contract reviewServed-tier: Inputs read: card #35028 (body and all 8 comments), PR #35102 (body, 12-file list, 3 comments, net diff against ① Derived judgmentsEvery accept-set and public-surface change the diff implies, read off the tree:
② Semver level
③ Boundary flags
④ Design judgmentThe narrowing against the published spec on Attempts to break it, and what the tree answers:
Findings: S1 (should-fix) — the gate judges a handle the current run was DETACHED from. N1 (nit) — the ADR note says a trio handle's owner "is known at that moment" without the one exception the code's own comment records: a primitive handle cannot key the map and stays unattributed ( N2 (nit) — a CLOSED trio handle reverts to "unattributed" rather than to "closed". After commit or rollback the record is dropped, so a late write that still carries the handle to another datasource is handed the dead foreign handle again, and the new case "forgets the owner once the trio commits" pins exactly that delivery. A closed No must-fix. One should-fix (S1), which earns a delta review of its fix; N1 and N2 need no round. Implemented-by: VERDICT: PASS |
…run was detached from An `async: true` `afterFind` run starts outside every open unit and its `ctx.api` still carries the trio handle; `buildDriverOptions` already treats that handle as absent (`isClosedUnitHandle`). `enforceTransactionOrigin` now reads it the same way before consulting the trio record, so such a run's cross-datasource business write lands on its own connection instead of being refused. Pinned beside the trio cases. Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
Add-only paragraph under the 2026-11-18 note: a handle an async hook's run was detached from is read as closed by the gate, and a primitive handle stays unattributed. The changeset says the same for the detached run. Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Contract-review-claim: session_01JQwxbXGvw43spR79ztEvWt · head Delta contract review |
|
repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9 L1 review, delta for contract-review S1 (#35028) · 2026-11-18T07:38ZL1: ACCEPT S1 of contract review 6969574094, closed in code. The pin targets the right case. A write event's async run under the trio waits for the trio to settle ( The changeset and ADR delta match the code. The added changeset sentence describes the detached run as unjudged, with writes outside any transaction "as under CI at this head. 39 success, 18 skipped, and Must-fixNone. Should-fixNone. Notes
|
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Contract reviewServed-tier: This is a DELTA record: Inputs read: card #35028 (body and all 10 comments, among them the route A reading 6964984927, the claim amendment 6965031920 and the os-dev reports 6969444494 and 6972198231), PR #35102 (body, 12-file list, all 8 comments, among them record 6969574094 and the L1-a ACCEPTs 6969533256 and 6972259586; no review and no inline comment exists), and the 58 check-runs on the head, read at 07:42Z: 39 ① Derived judgmentsThe accept-set changes the delta implies, read off the tree:
② Semver levelUnchanged and still right. ③ Boundary flags
④ Design judgmentS1 as graded: the gate read the trio record for the raw Attempts to break the guard, and what the tree answers:
The pin ( ADR-0119, the added paragraph (Tier H governed text): add-only, placed under the dated 2026-11-18 note, nothing above it rewritten. Its first bound agrees with the code: an S1: closed. No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbabAdcWyApSTGBYJNY Seat record · 2026-11-18T07:45Z · Head-sha: 91960c4 维护者速读
席位意见:同意合并。修的是真实的数据丢失(审计行静默丢失),收窄只影响「一个事务里写两个数据源」这种本来就写错连接的用法,并有明确报错。 席位核对
|
Requested by Yibo Wang · project thread
Fixes #35028
Clause-②: yes (narrowing) — inside a transaction opened by
ScopedContext's discrete begin/commit/rollback trio (the sandbox'sctx.api.transaction), a business write to an object on another datasource is now refused withCrossDatasourceTransactionWriteError(ERR_CROSS_DATASOURCE_TRANSACTION_WRITE, 400 at the action door). Before, it ran on the transaction's connection, the wrong one.Metadata-protocol: none
Skills-docs: follow-up #35117 (the
api.transactionrow: one datasource per body transaction; a write to an object on another datasource is refused)维护者速读
ctx.api.transaction打开的事务句柄,现在在开启时记下归属的驱动;同源闸门据此判断,审计/动态行写到 telemetry 库自己的连接,跨库业务写被拒。os dev、带OS_TELEMETRY_DB的os serve),动作体事务里的写入丢失审计行和动态行,接口仍回 200。packages/objectql/src/engine-scoped-context.ts(beginTransaction 记录、commit/rollback 清除)、packages/objectql/src/engine-execute-transactions.ts(记录表与 enforceTransactionOrigin)、packages/objectql/src/engine-middleware-and-context.ts(transactionCoversDriverFor)。pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-transaction-same-origin.test.ts,预期 29 个用例全绿。docs/adr/**),需 os-zhuang 在当前 head 上 APPROVED 审核。What changes
ScopedContext.beginTransactionrecords the opened handle's owner (the sameTransactionScopethattransaction(cb)publishes), keyed by handle in a WeakMap.commitTransactionandrollbackTransactiondrop it, also when the driver call throws.txStoreholds no scope for the handle,transactionCoversDriverForandenforceTransactionOriginread that record. So ledger rows (sys_audit_log,sys_activity) take the existing ambient 事务句柄跨数据源泄漏:凡在事务中执行的被审计写入,合规审计行全部静默丢失(#5226 的真实根因) #5351 carve-out: written ontelemetry, outside the body transaction, on their own connection. A cross-datasource business write is refused before any hook runs.enforceTransactionOrigintakes the write's explicit handle (options.context.transaction) as a fourth argument. That puts four one-line call-site edits outside the claim's file surface:engine.ts(the private wrapper),engine-insert.ts,engine-update.tsandengine-delete-and-aggregate.ts. Route A needs them, because the gate cannot otherwise see the handle.IDataDriverorpackages/specchange. The sudo()'action'elevation-mark defect (plugin-security: platform sudo() keeps the action body's action mark, so the platform's own audit and activity inserts are judged as app inserts and would be refused once the announced system-identity write refusal ships #35052) is not touched.enforceTransactionOriginnow discards an explicit handle the current run was detached from before it reads the trio record, with the same predicate the structural half uses (isClosedUnitHandle,engine-driver-options.ts). Anasync: trueafterFindrun starts outside every open unit while itsctx.apistill carries the trio handle; before this, its cross-datasource business write was refused althoughbuildDriverOptionsran it outside any transaction. It now lands on its own connection, as it does undertransaction(cb). The ADR-0119 note gains an add-only paragraph bounding "exactly the 2026-08-06 answers" (the detached run, and review nit N1: a primitive handle stays unattributed); the changeset gains one sentence. Nit N2 (a closed trio handle reverts to unattributed rather than closed) is unchanged here; the seat files its follow-up.Why
Reading 6964984927 measured this on
origin/main. The trio never publishes intotxStore, so both same-origin gates stepped aside. plugin-audit'sapi.sudo()insert carried the body's primary handle to the telemetry driver, and the statement ran on the primary connection, which has nosys_audit_log. On a Postgres primary, the refused statement turned COMMIT into a rollback.Tests
Pins (seat ruling) and their ablations, each run through
scripts/ablation-replace.mjs. Every ablation landed (anchor 1 to 0, blob changed) and was restored (blob equals HEAD,git diff HEADempty). The dist legs were proved withablation-dist-preflight.mjs(--absenton mutate, present after the restore rebuild).engine-transaction-same-origin.test.ts, new describe "a handle the ScopedContext trio opened is attributed to its owner (#35028)"recordTrioTransactionScopecallpackages/qa/dogfood/test/action-body-transaction-audit-split.dogfood.test.ts(bootStack + real AuditPlugin +telemetryDriverPlugin, real/actionsdoor)packages/runtime/src/sandbox/action-body-transaction-rollup-child.integration.test.ts, split case400 ERR_CROSS_DATASOURCE_TRANSACTION_WRITE, message names the object)transactionCoversDriverForreturns false (business writes leave the handle and wait on SQLite's one connection)asyncafterFindrun: its cross-datasource business write under an open trio handle lands, with no handle!this.isClosedUnitHandle(explicitTransaction)withtrueCrossDatasourceTransactionWriteErrorreceived instead ofstoreddescribe.skipIf(!OS_TEST_POSTGRES_URL), pg primary + SQLite telemetryS1 was measured before it was fixed: the new pin, run on
1ea3deab98with no code change, failed 1 of 29 withFAILED CrossDatasourceTransactionWriteError: insert of 'ledger' inside transaction() resolves to datasource 'ledger_db', but the transaction is open on 'primary'. With the guard (fe13609b7b) the file passes 29 of 29. Ablation E ran throughablation-replace.mjs(anchor 1 to 0, blob9ed8195b6c32toc224861e208a), went red as above, and was restored (blob equals HEAD,git diff HEADempty). A first attempt with a replacement that was a substring of the anchor was refused by the tool before any test ran. The objectql tests import the source, so no dist leg applies.Fix-round suites on head
91960c4f5a:test: 610 files / 13733 tests passed (VERDICT command-exit 0).typecheck: exit 0.Package suites on head
1ea3deab98(previous round), all run in one locked chain:test: 610 files / 13732 tests passed (exit 0).typecheck: exit 0.typecheck: exit 0.Live probe (re-run of the reader's probe,
os dev --freshon a probe app)"Before" is origin/main's objectql source (
1282a464e9) rebuilt. "After" is this branch.Audit write FAILEDlinesOS_TELEMETRY_DB=0OS_TELEMETRY_DB=0Acceptance notes
as any.Verification
Fix-round readings, all taken on head
91960c4f5a(the final head). Verified by repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt. No merge frommain:overlap-checkbefore each push merged cleanly againstorigin/mainand the four PRs sharing files (#35124, #34978, #34817, #34709), andmainis not red.Full build:
pnpm build --concurrency=2underos-verify-lock, 120 of 120 tasks successful,VERDICT command-exit 0.Full dogfood battery (owed:
!title +(narrowing)arm), no shard, no path filter:pnpm --filter @objectstack/dogfood test · exit 0 · 480 files / 4075 tests passed
pnpm --filter @objectstack/dogfood typecheck · exit 0
Derived gate families (
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, run after the full build):82 derived · 82 run · 82 exit 0 · 0 NOT MEASURED
The derivation warned that the local
origin/mainref was 17 commits ahead of the merge base and thatscripts/check-skills-token-ratchet.mjschanged in that range; that script is not one of this diff's families.check-governed-merges --pr 35102 · exit 3 (GOVERNED, the expected answer)
CI on head
91960c4f5a:Lint & Repo Gates,TypeScript Type Check,Build Core,Governed Surface Queue Guard,Live E2E UI,Test UI,Dogfood Regression GateandCheck Changesetconcludedsuccess;Test Core9 of 10 shardssuccess.Test Core (7/10)failed on one test this diff does not reach:plugin-securitysrc/org-admin-assignment-boundary.posture.test.ts:1153(orgAdminAuditorDelegate, posture 'isolated'), "Test timed out in 5000ms", the known flake signature tracked on #35111; no plugin-security path is in this diff. TheLint & Repo GatesandTypeScript Type Checkreds onfe13609b7bwere cancellation aggregates: that run was cancelled at 06:20Z when91960c4f5awas pushed, and every sub-lane readscancelled.Still owed (seat)
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa