Skip to content

docs(skills): data-hooks api.transaction row says when it joins an outer unit and that it is one datasource; teach hook texts + ctx.text - #35309

Merged
os-zhuang merged 2 commits into
mainfrom
claude/issue-34967-transaction-row
Nov 19, 2026
Merged

os-zhuang merged 2 commits into
mainfrom
claude/issue-34967-transaction-row

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread
Fixes #34967
Fixes #35117
Part of #34546

Clause-②: no
Metadata-protocol: none

The declaration half of #34546 only: hook texts + ctx.text taught once in objectstack-data. The translation-bundle half is in PR #35302, which owns the bundle shape; #34546 stays open until both PRs merge, and the area then closes that card by hand.

维护者速读

  • 改了什么:数据技能 data-hooks.md 的 api.transaction 一行写明:回调是一个数据源上的一个事务,写到其他数据源的对象会在执行前被拒(400 ERR_CROSS_DATASOURCE_TRANSACTION_WRITE);在已打开的单元里(钩子所在写入的单元,或调用方的)它并入该单元,返回不提交、抛错不回滚。另在 refusals 旁新增 texts + ctx.text 的教学块,附两条 eval。
  • 为什么改:原文无条件写「返回即提交、抛错即回滚」,AI 照写会以为内层已回滚或已提交;跨数据源的拒绝和钩子组织语言文本也没教。
  • 风险与回滚:仅技能文本与 eval,无代码改动;token 棚 10011 → 10122(先删同文件十处重复,余额按实测提高)。回滚即 revert 本 PR。
  • 先看:skills/objectstack-data/references/data-hooks.md 的 api.transaction 行与新的 Declared texts 块;scripts/check-skills-token-ratchet.mjs 的 data-hooks 行注。
  • 两分钟验证:node scripts/check-skills-token-ratchet.mjs | grep data-hooks,预期见 10122 tokens (ceiling 10122; headroom 0)。
  • 需要你做的:席位合同审核通过后批准落地(受管面 skills/**)。

What changes

skills/objectstack-data/references/data-hooks.md:

  • api.transaction row (Capabilities table). Was: "runs the callback's ctx.api ops in one driver transaction (commit on return, rollback on throw)", with no condition. Now: one transaction on the default datasource, commit on return, rollback on throw; a write in it to an object on any other datasource is refused before it runs (400 ERR_CROSS_DATASOURCE_TRANSACTION_WRITE); inside a unit already open (the one the hook's write runs in, or a caller's) it joins that unit: its return is no commit and its throw no rollback, the outer unit commits or rolls back all of it, so a throw the body catches keeps the callback's writes. Worded from content/docs/automation/hooks.mdx ("A nested transaction() joins the outer unit, so its return is no commit") and from PR fix(objectql)!: an action body's write inside ctx.api.transaction keeps its audit rows beside a telemetry datasource #35102's CrossDatasourceTransactionWriteError and its ADR-0119 note (2026-11-18), which says the trio the sandbox uses gets the same refusal as transaction(cb). Runtime read: packages/runtime/src/sandbox/quickjs-runner.ts __txCommit / __txRollback abstain on a joined handle and the rollback leaf re-throws; ScopedContext.beginTransaction joins the ambient transaction (owned: false).
  • New "Declared texts (texts)" block right after "Declared refusals", in its compact form: declare on the hook, ask with ctx.text(key, params?) (no capability; a js body or a handler, never an expression body); the organization's language (Setup → Localization, else i18n.defaultLocale), never the saver's; translated first, then filled from params; a missing translation never fails the hook; an unreadable Localization setting rejects; only declared keys. Worded from hooks.mdx § "Writing a sentence people read — texts" and the texts TSDoc in packages/spec/src/data/hook.zod.ts. The block names the translation key inline, hooks.HOOK.texts.KEY.message, and points to objectstack-i18n for the bundle; the bundle shape is not restated (PR docs(skills): teach the mappings group, action and hook texts, and drop the stale label-serving caveat #35302 owns it).
  • ctx.text row in the sandbox ctx table: one cell, a pointer to the block.

skills/objectstack-data/evals/hooks-security-seeds-datasources.json: two cases, ids 28 and 29 (25 and 26 are taken by open draft PR #34964), inserted after id 17 so they do not touch that PR's hunk at the end of the array:

  • 28: a blocking afterUpdate body whose ctx.api.transaction throws after an insert and catches it, plus an insert to a business object on a non-default datasource (join, ERR_CROSS_DATASOURCE_TRANSACTION_WRITE).
  • 29: an afterInsert hook writing a task subject in the organization's language (texts, ctx.text, params); it links the task by ctx.result.id and pins related_to_lead: ctx.input.id as must_not_contain.

scripts/check-skills-token-ratchet.mjs: the data-hooks row 10011 → 10122 with its note. .changeset/34967-data-hooks-transaction-texts.md: @objectstack/skills patch.

Paid down first, remainder by measurement

Raise path: the standing ruling 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). Ten restatements cut in the same file, each keeping its other home:

  1. Hook Context API, "Sandbox vs in-process" blockquote (now a two-line pointer). Other home: the body vs handler table under Sandboxed Hook Bodies.
  2. "Reading the current organization": the column / RLS / seed-row sentence. Other home: the HookContext listing comment on organizationId and the code line's own comment.
  3. body — Implementation: the example block. Other home: "The body shape" block and the before* bullet under it (ctx.input.x = …).
  4. Pattern 4: the five-line session.roles comment (now one line). Other home: the ctx.session row ("session.roles was retired in 17.0.0") and the field-level callout above the pattern.
  5. Copy-paste example: the "ctx.result is the PARTIAL patch" comment. Other home: Gotcha 1 right above it, and the example's intro sentence.
  6. Copy-paste example: the "needs the acting user to be able to edit" comment. Other home: Gotcha 2 right above it.
  7. Body shape block: the // the FUNCTION BODY only — not a module comment. Other home: the bullet under the block (source is the function body the runtime wraps) and Sandbox restrictions (import/require rejected).
  8. Sandbox ctx table, ctx.email row: "; not in a hook body". Other home: the email.send capability row ("Not in a hook body (refused at parse and at bind)").
  9. api.read capability row: the ctx.title clauses. Other home: the ctx.title row.
  10. HookContext listing: the notice? comment. Other home: the ctx.notice row, which links rules/lifecycle.md § Save Notice.

Restored in the fix round (review 6999973886): the "Why so few?" per-row sentence, byte-identical to main (PR #34964 cites it as a home). Items are numbered 2-11; ten cuts remain.

Arithmetic (bytes, ceil(bytes / 4) tokens): main 40004 (10001 of 10011, headroom 10). The text adds 1805, the ten cuts remove 1323, landed 40486 → 10122. The ceiling moves +111, the measured remainder only, pinned at the measurement.

skills/** readings

Reading Before (c809deb67) After
data-hooks.md lines 890 893
data-hooks.md tokens 10001 10122
All skills/**/SKILL.md lines 4835 4835
Whole skills/** tree lines 22082 22105
Bundle tokens (ratchet's "bundle total") 270968 271730

The bundle token delta is +121 in authored text and +641 in eval fixtures (unpriced, population 1b).

Tests

No package code changes, so there are no package tests to run. The one edited script is scripts/check-skills-token-ratchet.mjs (a row note and the measured ceiling): its own --self-test passes (104 cases). No *.test.* file names it. No ablation: text, config and a ratchet row only.

Acceptance notes

  • Observation, not filed (no repro run): the sandbox refuses a ctx.api.transaction nested inside another one in the same body (nested ctx.api.transaction is not supported, quickjs-runner.ts __txBegin). The row does not say so. That is a different case from joining a unit the host opened.
  • Observation, not filed: the Hook Context API input section shows a delete's ctx.input as { id: '123' }, while pattern 1 says a delete's ctx.input is empty (ctx.previous is the row). Read only, not measured, and the two may describe different doors (handler vs body).
  • Footer: the dispatch order asks for the body to end with the "Generated with" line and the session URL. AGENTS.md asks for the rule-plus-session-URL footer block on a PR body. This body carries both, the block last.

Verification

Premise readings on origin/main c809deb
  • A1 holds: skills/objectstack-data/references/data-hooks.md:334, the api.transaction row: "runs the callback's ctx.api ops in one driver transaction (commit on return, rollback on throw)", no condition, nothing on datasources.
  • A2 holds: grep -n "texts\|ctx.text" gives 0 hits in the file; the refusals block is at :830-879 (### Declared refusals :830), plus uses at :609 and :742.
  • A3 holds: hooks-security-seeds-datasources.json has 25 cases (ids 1-24 and 27).
Ratchet
✓ check-skills-token-ratchet: skills/objectstack-data/references/data-hooks.md is 10122 tokens (ceiling 10122; headroom 0).
✓ check-skills-token-ratchet: 59 authored bundle file(s) within their ceilings; 10 generator-owned file(s) and 38 eval fixture(s) measured, not ratcheted.
✓ check-skills-token-ratchet self-test: 104 cases pass.
Local gate subset (head f7fa386; fix round 84b73e2 re-ran the ratchet, skills, changeset gates and overlap-check, all exit 0)

node scripts/pm/dispatch-gates.mjs --commands derived 65 commands. 60 exited 0 on the first run, check:pm-dispatch-gates among them (fast tier, 2249 cases). check:doc-formula-expressions exited 3 (PREREQUISITE NOT MET, @objectstack/lint not built); it exited 0 after turbo run build --filter=@objectstack/lint under the verify lock. Four Build Core families exited 3 for unbuilt dist and were not measured locally: check:dts-closure, check:dual-build-cjs-loads, check:lean-entry-closure, check:sourcemap-no-sources-content. CI's Build Core runs them. Exit codes were captured before any pipe and reconciled with --ran.

✓ check-skill-links: 269 relative link(s) in 73 published skill file(s) resolve; 139 fragment(s) name a real heading under GitHub's slug rule.
✓ check-skill-id-lint: 120 file(s) clean (pattern /#[0-9]{3,}/g).
✓ check:doc-formula-expressions: 26 record-scoped formula example(s) across 580 files / 1854 TS blocks judged clean by @objectstack/formula.
✓ dispatch-gates --ran: 65 derived famil(ies) accounted for — 61 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3).
overlap-check: ✓ #34964 (shares the eval json and data-hooks.md): merges cleanly · VERDICT clean exit 0
overlap-check at 84b73e214: ✓ #34964, #35312: merges cleanly · VERDICT clean exit 0

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7


Generated by Claude Code

…ter unit and that it is one datasource; teach hook texts + ctx.text

The api.transaction capability row now states one transaction on one
datasource (a write to another datasource is refused with 400
ERR_CROSS_DATASOURCE_TRANSACTION_WRITE) and that inside an open unit it
joins that unit: its return is no commit, its throw no rollback. A
Declared texts block beside Declared refusals teaches a hook's texts and
ctx.text. Paid by seven same-file restatement cuts; the remainder raises
the data-hooks.md ratchet row by measurement (10011 -> 10123). Two eval
cases added.

Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f7fa38653f2b5e451d4870369afd8dab5884ef18
Local-runs: none
Scope: skills/objectstack-data/evals/hooks-security-seeds-datasources.json, skills/objectstack-data/references/data-hooks.md + scripts/check-skills-token-ratchet.mjs
Security-touching: yes

PR #35309 (draft, author objectstack-fleet[bot]), Fixes #34967, Fixes #35117, Part of #34546. Read: the three cards with every comment, the dev report 6999096112, ruling record 6513306068, the net diff against merge-base c809deb67b, and the cited code at the head. All paths below are at the head; data-hooks.md:N is the head file.

Why Security-touching: yes: three changed hunks shorten text that teaches permission and sharing behaviour. Pattern 4 (never gate a mask exemption on a session claim; a per-set exemption belongs in field-level permissions), the copy-paste example (a cross-object write needs the acting user's edit right on the target), and "Reading the current organization" (the value RLS and sharing predicates read). The rule taught is unchanged in each case and keeps its other home. No platform protection bypass was found.

① Derived judgments

No accept-set or published-surface change: served skill text, two eval cases, one ratchet row. Each claim the diff makes, judged:

  1. api.transaction row, own transaction ("commit on return, rollback on throw"): right. The sandbox sugar begins, commits on return, rolls back and re-throws on a throw (packages/runtime/src/sandbox/quickjs-runner.ts:1224-1234, leaves :806-856); the trio opens on the default driver (packages/objectql/src/engine-scoped-context.ts:328-362) and closes there (:366-392).
  2. Row, "one datasource": right but under-specified, see S1. The transaction always opens on the DEFAULT driver (engine-scoped-context.ts:228, :315-326; ADR-0119 D1: "covers only the default driver"); EngineTransactionOptions has no datasource selector (packages/spec/src/contracts/objectql-engine.ts:144-163).
  3. Row, the refusal: right. enforceTransactionOrigin runs at the top of insert, update and delete, before hooks and validation (packages/objectql/src/engine-execute-transactions.ts:253, :293-320); the code is ERR_CROSS_DATASOURCE_TRANSACTION_WRITE (packages/objectql/src/transaction-errors.ts:124, :149-173); the trio handle is judged since PR fix(objectql)!: an action body's write inside ctx.api.transaction keeps its audit rows beside a telemetry datasource #35102 (engine-scoped-context.ts:350-360); 400 with that code is pinned at the action door (packages/qa/dogfood/test/action-body-transaction-audit-split.dogfood.test.ts:163-170).
  4. Row, the join: right for every unit the host opens. The callback face joins the ambient unit and neither commits nor rolls back (engine-scoped-context.ts:215-224); the trio joins with owned: false (:335-342) and its commit and rollback abstain (:367, :382); the runner abstains too and the sugar re-throws (quickjs-runner.ts:827-856). The write door opens that unit for an aborting after* hook or a metadata before* hook, on the default datasource only (packages/objectql/src/engine-hooks-and-functions.ts:537-553). Pinned on a real engine and real QuickJS: packages/runtime/src/sandbox/transaction-ambient-join.integration.test.ts:152, :169, :188, :209, :242. Two bounds are not stated, see N2.
  5. content/docs/automation/hooks.mdx:373-374 ("A nested transaction() joins the outer unit, so its return is no commit") holds against the three faces above and packages/objectql/src/engine-transactions-section.ts:72-78. It says nothing about a throw; the "throw no rollback" half of the row is from code, not from those two lines, and the code supports it. The same two bounds apply to the docs sentence (N2).
  6. ctx.text row and the "Declared texts" prose: right, sentence by sentence.
    • No capability: quickjs-runner.ts:1067-1104 installs it with no capability check.
    • A js body or a handler, never an expression body: packages/spec/src/data/hook.zod.ts:343-357; served on both doors (packages/runtime/src/sandbox/body-runner.ts:557, :390-399).
    • Organization's language, Localization setting else i18n.defaultLocale, never the saver's: packages/runtime/src/sandbox/hook-text.ts:147, :189; packages/core/src/organization-locale.ts:84-116, :185-198.
    • Translated first, then filled; a missing translation writes the declared message: hook-text.ts:148-162.
    • An unreadable setting rejects: organization-locale.ts:143-157 (only an unregistered setting reads as unset); pinned at packages/runtime/src/sandbox/hook-text.integration.test.ts:213-229.
    • Only declared keys, at save when literal, else at run: hook.zod.ts:358-365, hook-text.ts:143-146. The 500 matches hooks.mdx:500-501 and the fault rule in packages/runtime/src/sandbox/hook-refusal-catalogue.ts:27-32; the status itself was not traced further.
    • "Holes as in refusals": same rules (hook.zod.ts:382-399), and data-hooks.md:852-853 states them.
  7. The example in that block: WRONG on its second statement, see M1.
  8. Seven cuts: each is a true restatement and none removes the only statement of a rule. Byte deltas per hunk from the diff: 137, 137, 161, 85, 241, 223, 275 = 1259 removed.
    • Cut 1 ("Why so few?", per-row context detail): kept at data-hooks.md:173-179 (before*), :186-190 (after*), :246 (ctx.input row).
    • Cut 2 ("Sandbox vs in-process"): kept in the table at :211-216; the new anchor names the heading at :239.
    • Cut 3 (organization sentence): kept at :459-460 and :490.
    • Cut 4 (body example): the rule is at :233-235, the shape at :220-228, a worked before* body at references/examples-objects.md:124.
    • Cut 5 (session.roles comment): kept at :250, :462-463, and the callout at :669-673.
    • Cut 6 (partial patch comment): Gotcha 1 :358-369 and the intro :389-390.
    • Cut 7 (edit right comment): Gotcha 2 :371-385.
    • Eval check, because the runner installs only the case's own bundle without evals/ (packages/qa/scenarios/src/skill-evals/arms.ts:86-100) and grades literal substrings (grade.ts:27-31): all 187 must_contain tokens of the 48 graded cases in skills/objectstack-data/evals/*.json (27 + 21; triggers.json carries no assertions) are present in the head bundle. No token left the bundle. Five lost one occurrence in this file and all remain: afterUpdate 16 to 15, language: 'js' 9 to 8, ctx.previous.id 7 to 6, lookup 5 to 4, organization_id 4 to 3. No case's prompt asks for a statement a cut removed.
  9. Evals 28 and 29: the tokens are taught by the new text and by nothing else in the bundle on main (ERR_CROSS_DATASOURCE_TRANSACTION_WRITE, texts, ctx.text had no hit outside evals/), the prompts do not leak them, ids are unique. Two soft spots in case 28's expected_output, see N1.
  10. Ratchet: the numbers hold. Base 40004 bytes (10001 of 10011), head 40492 bytes, ceil(40492 / 4) = 10123; adds 144 + 390 + 1213 = 1747, cuts 1259, net 488. Ruling B's four conditions are met: same-file restatement deletions are in the diff, the PR body quotes the 2026-10-27 words and record 6513306068, the row moves by the measured remainder (+112), and it is pinned at the measurement (headroom 0). Net growth of 122 tokens for three cards is within the 10402 principle. The row comment agrees with the diff.
  11. Other skills: nothing contradicts the new text. skills/objectstack-automation/** says nothing on texts or api.transaction and routes hooks to objectstack-data (SKILL.md:9); skills/objectstack-i18n/SKILL.md has no texts key on this head (S2); the other transaction statements in this file (:62-63, :331, :797, :806) agree with the row.

② Semver level

Right. .changeset/34967-data-hooks-transaction-texts.md is @objectstack/skills patch with Clause-②: no and Metadata-protocol: none, both line-initial there and in the PR body. Text-only served skill text changes nothing an author can write, so the kind is none and none takes patch (AGENTS.md, Post-Task Checklist step 3). No !, no arm, no BREAKING banner owed. Check Changeset is green on the head.

③ Boundary flags

④ Design judgment

skills/objectstack-data/references/data-hooks.md

M1 (must-fix) — the "Declared texts" example writes undefined into the task's link. data-hooks.md:869-871 labels the fragment an afterInsert body and inserts related_to_lead: ctx.input.id. On an insert ctx.input.id is always undefined, on both doors:

  • the hook input of an insert is { data, options } with no id (packages/objectql/src/engine-insert.ts:644), and the id is minted later in the driver on a copy (packages/drivers/driver-sql/src/sql-driver-crud.ts:329-334);
  • the reserved name id never reads through to the payload (packages/objectql/src/hook-wrappers.ts:742-751), pinned at packages/objectql/src/hook-input-envelope-precedence.test.ts:163-187, a spread included;
  • a body's ctx.input is the payload snapshot (body-runner.ts:1481, :1553);
  • the governing docs say so: hooks.mdx:216 ("or undefined on insert").
    The source example (hooks.mdx:465-477) is an afterUpdate handler, where ctx.input.id is the target row; the skill changed the event and the door and kept the read. The same file teaches the opposite at :246, :248, :564 and pattern 2 :628, and eval 12 forbids this class (account_id: ctx.input.id). The fragment is unmarked, so check:skill-examples does not read it. Copied as written, which eval 29's prompt invites, every follow-up task is created with no lead. Fix: ctx.result.id. That is one byte more: 40493 bytes is 10124 tokens, over the 10123 pin, so trim a byte or re-measure the row.

S1 (should-fix) — "one transaction on one datasource" does not say which. It is the default datasource (① item 2). A callback whose writes are ALL on one non-default datasource is refused too, and a reader of the row, and of eval 28's "keep the objects one transaction writes on one datasource", concludes the opposite. hooks.mdx:343-344 names the default datasource. Fix: "the default datasource" in the row and in the eval's expected answer.

S2 (should-fix) — the translation key is nowhere in the skills on this head. data-hooks.md:881 points to objectstack-i18n for it, and that skill has no texts key until PR #35302 lands (hooks.{hook}.texts.{key}.message, read in that PR's diff at 14899df1c2). The refusals block in the same file states its own key inline (:854-855). Close either way: land #35302 first and have the delta record confirm the target, or state the key in one clause here.

N1 (nit) — eval 28's expected_output, which is neither sent nor graded (packages/qa/scenarios/src/skill-evals/cases.ts:91-93). (a) "or write the ledger outside it": inside the save's unit a plain ctx.api write to another datasource is refused the same way (engine-execute-transactions.ts:309-319 reads the ambient scope; hooks.mdx:338-340); what works is a write outside the unit, such as an async: true hook (hooks.mdx:382-383). (b) The refused object is named ledger_entry, while the one class the engine carves out of this refusal is the append-only ledger (lifecycle.class audit, telemetry, event; engine-execute-transactions.ts:318, transaction-errors.ts:144-147). A neutral object name avoids the collision. Fix with the M1 delta, since the head moves anyway.

N2 (nit) — two bounds on "joins" that neither the row nor hooks.mdx:373-374 states. (a) A second ctx.api.transaction inside the first, in one body, is refused (quickjs-runner.ts:806-807). (b) A unit a sandboxed body opened itself is never ambient: the trio does not publish into the store (packages/objectql/src/engine.ts:6681-6693; the one publisher is engine-transactions-section.ts:177), and the write door opens none under a threaded handle (engine-hooks-and-functions.ts:538-539). So a hook body's ctx.api.transaction fired by a write inside an action body's transaction opens a second driver transaction instead of joining, which makes "or a caller's" too wide for that caller. (b) is read in code, not measured. Follow-up card.

N3 (nit) — not stated by the row, each for the follow-up card: the ledger carve-out (a lifecycle-classed ledger on another datasource is written outside the transaction, not refused); on PostgreSQL a throw that is a failed statement aborts the whole unit even when the body catches it (hooks.mdx:347-354), so "a throw the body catches keeps the callback's writes" holds for a throw the body raises itself; and the silent degrade on a driver with no transactions, which the old row did not state either.

skills/objectstack-data/evals/hooks-security-seeds-datasources.json

Cases 28 and 29 test what the text teaches (① item 9). Case 29 exercises the M1 line without asserting on it; when M1 is fixed, a must_not_contain of ctx.input.id would pin it, as case 12 does for its own. Findings: N1, and S1's wording in case 28.

scripts/check-skills-token-ratchet.mjs (implementing file)

Agrees with the contract it enforces (① item 10): the ceiling equals the measured count, the comment's arithmetic matches the diff, and the raise path is the one the header recognises. It must move again with the M1, S1 and S2 fixes, by measurement.

Implemented-by: claude/issue-34967-transaction-row
Reviewed-by: session_01Utp6CbUb7TcZK1XUAddUmQ

VERDICT: FAIL

…ransaction is on the default datasource; texts block names its key

Review fix round. The Declared texts example is an afterInsert body, so
it links the task by ctx.result.id (ctx.input.id is undefined on
insert). The api.transaction row says the transaction is on the default
datasource and a write to any other is refused. The texts block names
its translation key inline and keeps the objectstack-i18n pointer. The
"Why so few?" per-row sentence is restored, since another open PR cites
it as a home. Paid by four more same-file restatement cuts; the ratchet
row re-pinned at the measurement (10122). Eval 28 says default
datasource and uses a neutral object name; eval 29 pins the link.

Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 84b73e214610ea6179b01f0411b3488806aef1dd
Local-runs: none
Scope: skills/objectstack-data/evals/hooks-security-seeds-datasources.json, skills/objectstack-data/references/data-hooks.md + scripts/check-skills-token-ratchet.mjs
Security-touching: yes

Delta review of PR #35309. Round 1 is record 6999973886 on head f7fa38653f; it stands for everything this record does not name. Read here: the one commit since that head (84b73e2146, 4 files, +33 −31), the cited code at the new head, the updated PR body, card #35324, and the check-runs on the new head. data-hooks.md:N is the new head's file.

Security-touching stays yes for the round-1 reason: the PR still shortens three passages that teach permission and sharing behaviour. The delta adds no security teaching and removes none. No protection bypass was found.

① Derived judgments

Each claim of the fix round, judged against the tree:

  1. Texts example (data-hooks.md:870-872): right. The afterInsert body now links by ctx.result.id. The stored row, id included, is the after-hook's result (packages/objectql/src/engine-insert.ts:1617) and reaches the body as ctx.result (packages/runtime/src/sandbox/body-runner.ts:1573, packages/runtime/src/sandbox/quickjs-runner.ts:717). It agrees with the file's own ctx.result row (:249) and pattern 2 (:629).
  2. api.transaction row (:328): right. "One transaction on the default datasource" and "a write in it to an object on any other datasource is refused before it runs" match packages/objectql/src/engine-scoped-context.ts:228, :315-326 and packages/objectql/src/engine-execute-transactions.ts:293-320. The join sentences are unchanged from round 1.
  3. Translation key (:882): right. The bullet names the key inline, hooks.{hook}.texts.{key}.message, in the placeholder form the refusals bullet uses (:855); it is the key the runtime reads (packages/spec/src/system/i18n-resolver.ts:4651-4653). The pointer to objectstack-i18n now covers the bundle only.
  4. "Why so few?" sentence: restored. Lines 42-54 of the note are byte-identical to merge-base c809deb67b, and the file no longer differs from main there.
  5. Four new cuts: each is a true restatement and none removes the only statement of a rule.
    • Body-shape comment ("the FUNCTION BODY only, not a module"), 44 bytes: kept at :231-233 (the function body the runtime wraps) and :349 (imports rejected).
    • ctx.email row ("not in a hook body"), 20 bytes: kept at :331, with the refusal at parse and at bind.
    • api.read row (the two ctx.title clauses), 87 bytes: kept at :261 (plain form "no extra read", lookup form "needs api.read").
    • notice? comment in the HookContext listing, 50 bytes: kept at :259, which carries the link to Save Notice.
    • No gate or test pins a removed string (the files that name data-hooks.md were read: scripts/check-corpus-claim-drift.mjs, scripts/check-skill-identifier-liveness.mjs, packages/spec/src/contracts/scoped-context.test.ts, packages/runtime/src/sandbox/overlap-hook-template.integration.test.ts).
  6. Eval sources: no must_contain token lost its source. Over the 48 graded cases (187 tokens), the set of tokens with no literal hit in the bundle is the same 21 on main, on the round-1 head, on this head and on this head merged with main; against main only three tokens changed, all newly present (ERR_CROSS_DATASOURCE_TRANSACTION_WRITE, texts, ctx.text). No case's prompt or expected answer turns on a statement one of the four new cuts removed.
    • Correction to record 6999973886, ① item 8: it said all 187 tokens are present in the bundle. That was wrong. The reading was a base-against-head comparison; 21 of the 187 are compositions of a case's own names (for example CREDIT_LIMIT: {) and are in no bundle file on main either. The conclusion there is unchanged: no cut removed a token's source.
  7. Eval 28: right. The object is bank_transfer, named a business object; the expected answer says the default datasource only, that a plain ctx.api write inside the save's unit is refused the same way (engine-execute-transactions.ts:309-319; content/docs/automation/hooks.mdx:338-340), and that the write belongs outside the unit, in an async: true hook (hooks.mdx:382-383). The prompt still leaks neither asserted token.
  8. Eval 29: right. The expected answer links by ctx.result.id, and must_not_contain carries related_to_lead: ctx.input.id, which no bundle file contains any longer.
  9. Ratchet: the numbers hold. Head file 40486 bytes, ceil(40486 / 4) = 10122, equal to the row. Per-hunk deltas against merge-base: ten cuts of 137, 44, 20, 87, 161, 85, 241, 50, 223 and 275 bytes, 1323 in all; three additions of 144, 400 and 1261, 1805 in all; net 482. The row moves +111 over main's 10011, pinned at the measurement, and the row comment says the same. Ruling 6513306068 letter B still permits it: the deletions are same-file restatements shown in the diff, and the PR body quotes the 2026-10-27 words and the record, with each of the ten cuts and its other home listed.

② Semver level

Unchanged and right: @objectstack/skills patch, Clause-②: no, Metadata-protocol: none, both lines in the PR body and the changeset body. The changeset prose was brought in line with the fix (default datasource, the key, ten cuts). Check Changeset is green on this head.

③ Boundary flags

④ Design judgment

No must-fix, no should-fix.

skills/objectstack-data/references/data-hooks.md: the three fixes hold against the code they cite (① items 1 to 3), the restored sentence is exact, and the four new cuts keep every rule stated (① item 5).

N4 (nit) — two of the new cuts leave a rule stated less directly, and both are accepted as they stand. The ctx.email row of the hook ctx table now reads only "Gated by email.send"; the hook-body ban is in the capability row at :331, and the refusal is at parse, so the gap is loud. "Plain ctx.title() needs no token" is now carried by "no extra read" at :261 rather than said outright; the worst outcome is an unneeded api.read grant.

skills/objectstack-data/evals/hooks-security-seeds-datasources.json: cases 28 and 29 test what the text teaches and their expected answers now agree with the code (① items 7 and 8). The file is valid, 27 cases, ids unique.

scripts/check-skills-token-ratchet.mjs (implementing file): the ceiling equals the measured count and the comment's arithmetic matches the diff (① item 9).

Implemented-by: claude/issue-34967-transaction-row
Reviewed-by: session_01Utp6CbUb7TcZK1XUAddUmQ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

维护者速读

席位核对 — ACCEPT · repo:objectstack#5 · head 84b73e214610ea6179b01f0411b3488806aef1dd · 2026-11-19T04:59Z

@objectstack-fleet objectstack-fleet Bot added pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue security labels Nov 19, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 19, 2026 05:20
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit e4bfa33 Nov 19, 2026
59 of 60 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-34967-transaction-row branch November 19, 2026 05:39
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 19, 2026
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 security size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

3 participants