Skip to content

docs(skills): teach the hook body first in data-hooks.md, drop hook ctx.api methods that do not exist, guard nullable hook and formula predicates - #31201

Merged
os-zhuang merged 4 commits into
mainfrom
claude/project-thread-midtvb
Nov 8, 2026
Merged

os-zhuang merged 4 commits into
mainfrom
claude/project-thread-midtvb

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Irene · project thread

Fixes #31131

Clause-②: no
Metadata-protocol: none

dispatch-gates --tier reads a MANDATORY model tier for skills/** (clause ① of the model-tiering ruling); it is waived by the standing order of the maintainer in this project (2026-11-03), and this card ran on the project's default model. The dispatching seat runs the contract review.

维护者速读

What changes

1. data-hooks.md teaches body first

Code sites: HookSchema.handler (packages/spec/src/data/hook.zod.ts L485: "DEPRECATED, prefer body") and HookSchema.body (L487–L498: preferred; with both present the runtime uses body). The capability set is HookBodyCapability (packages/spec/src/data/hook-body.zod.ts L48–L54; no http.fetch, L38). Per example, against the body runner (packages/runtime/src/sandbox/body-runner.ts):

  • What a body receives: buildSandboxContext (L1232 onward) hands a JSON snapshot: input, previous (undefined on insert), result, user, session, event, object, api, log, title, notice.
  • What it can change: only ctx.input, via applyMutationsToInput (L496; header L24–L36). A write to ctx.result stays in the VM.
  • The row id: ctx.input is a snapshot of the flat-input Proxy (unwrapProxyToPlain, L1481), whose ownKeys lists only the payload's keys (installFlatInput, packages/objectql/src/hook-wrappers.ts L689). So ctx.input.id exists only when the payload carries one: it is undefined on a bulk (multi: true) update, a where-addressed update and every delete. ctx.previous.id is bound on all of them; packages/runtime/src/sandbox/perrow-dispatch-signal.integration.test.ts L49 and L187–L188 pin inputIdType === 'undefined' and "the row id a per-row body needs is ctx.previous.id".
  • Capabilities: each ctx.api.object(n).<method> is gated by api.read / api.write in quickjs-runner.ts L705–L708. The method then runs on the engine's repository (ObjectRepository, packages/objectql/src/engine.ts L10079), and a method that repository lacks throws not implemented (quickjs-runner.ts L1368).
  • A throw aborts the write: the hook wrapper rethrows (body-runner.ts L497–L505).
  • No outbound HTTP: no http.fetch token, and fetch is absent from the VM (same file, § Sandbox restrictions).

Every handler site the card listed, re-read on main 620b6e6d:

main line Site Now
L97 Schema example handler: async (ctx: HookContext) => {…} A body: { language: 'js', source, capabilities: [] }, commented "the inline handler is deprecated"; the unused HookContext import goes.
L155–L171 #### handler — Implementation: inline function "(recommended for simple hooks)" and the string ref 'my_plugin.validateAccount' #### body — Implementation: a body that normalises ctx.input.email, with "a throw aborts the write". One sentence names the deprecated handler's two shapes (inline function, registered function's name) and links § Registration Methods, which holds the string-ref example.
L319 body vs handler comparison table Stays: it documents the deprecated form. Its handler column header now says "(deprecated)"; the Status row already did.
L739 Cross-Object API handler: snippet Deleted (seat ruling). Homes: § ctx.api.object(name) (the repo, the where key, the filter alias) and Pattern 2 (the related-record insert). The prose above it stays.
L817 Pattern 3, Multi-Object Logic, inline handler A body with capabilities: ['api.write']; bulk write update(fields, { where: { account_id: ctx.previous.id }, multi: true }) (review M1: ctx.input.id made the where empty, matching every contact). The comment "Only the sandbox ctx.api adds updateMany/deleteMany" goes (false, see § 2).
L845 Pattern 4, Data Masking on Read (afterFind) Stays a handler (seat ruling A). Retitled "(deprecated inline handler)" with the reason: a body writes back only ctx.input, and its ctx.result is a snapshot. The field-level-metadata callout is unchanged.
L890 Registration, string-named handler: 'normalize' + functions Stays (string-registered form), labelled "(deprecated)".

Same defect in the pre-existing bodies (review S3, claim widened 6710683947): Pattern 1 (beforeDelete) counted open opportunities on account_id: ctx.input.id, which is {} on a delete, so it counted across every account; it now keys on ctx.previous.id, and its comment says a delete's ctx.input is empty. Pattern 2 recorded String(ctx.input.id || ''); it now records (ctx.previous || ctx.result || {}).id (previous on update/delete, result on insert). The three "input.id names the row" sentences (the "Why so few?" callout, § condition's before* and after* bullets) now read "input.id (handler; a body: ctx.previous.id)", and the sandbox ctx.input row says id is there only if the payload has it.

Also, so the page does not contradict itself: the intro and § Sandboxed Hook Bodies no longer say "everything above this point showed the inline handler"; "Skip handler execution" and "inside the handler" in § condition become hook / body; § Sandbox restrictions labels "a bundled handler" as deprecated; § Hook Context API says the documented ctx is the deprecated in-process handler context.

2. The repository method table teaches only methods the hook's ctx.api has (seat ruling, same file)

A hook body's ctx.api is the engine's ScopedContext (buildSandboxApiSource, body-runner.ts L1208–L1210), whose object(name) returns ObjectRepository: find, findOne, insert, create, update, updateById, delete, deleteById, count, aggregate and execute (which the sandbox does not install, quickjs-runner.ts L705–L708). upsert, updateMany and deleteMany therefore throw ctx.api.object('…').updateMany not implemented. The bulk form is the option: ObjectRepository.update(data, options) passes options to engine.update (engine-object-repository.ts L83–L88), which routes a predicate with multi: true to the driver's updateMany (engine.ts L6147–L6153, L7616); delete the same way (packages/metadata-core/src/engine-delete-dispatch.ts L72, L133 "Delete requires an ID or options.multi=true").

-| `update(data, opts?)` | `api.write` | **`update({ id, ...fields })`** — put the id **inside** `data` |
-| `upsert(data, opts?)` | `api.write` | `upsert({ … })` |
-| `delete(opts)` | `api.write` | `delete({ where: { id } })` |
-| `aggregate` · `updateMany` · `deleteMany` | read · write · write | also installed; same `where` shape |
+| `update(data, opts?)` | `api.write` | **`update({ id, ...fields })`** — put the id **inside** `data`; bulk: `update(fields, { where, multi: true })` |
+| `delete(opts)` | `api.write` | `delete({ where: { id } })`; bulk: `delete({ where, multi: true })` |
+| `aggregate(opts)` | `api.read` | same `where` shape |
-| `api.write` | `ctx.api.object(n).insert` / `update` / `delete` / `upsert` / `updateMany` / `deleteMany` |
+| `api.write` | `ctx.api.object(n).insert` / `update` / `delete` |

3. Nullable comparisons are guarded

Code site: packages/lint/src/validate-null-guards.ts; its wiring table (L89) lists the lifecycle hook condition as covered (hook-wrappers.ts materializeDeclaredFields), and L747 makes a hook condition's fault refuse the write. skills/objectstack-formula/SKILL.md L112–L122 teaches the same rule.

Site Before After
data-hooks.md L105 (schema example; not on the card, same site group by seat ruling) record.status == 'active' && record.amount > 1000 record.status == 'active' && record.amount != null && record.amount > 1000
data-hooks.md L219 record.annual_revenue > 1000000 record.annual_revenue != null && record.annual_revenue > 1000000
formula SKILL.md L268 (os:check block) record.amount > 10000 && record.region in ['us', 'eu'] record.amount != null && record.amount > 10000 && record.region in ['us', 'eu']

Measured, not assumed: findUnguardedNullableOperands (the gate's decision procedure, run through tsx with every named field nullable) returns 1 finding for each "before" predicate and 0 for each "after" predicate.

4. § Capabilities links Connector recipes

"outbound calls go through Connector recipes" now links objectstack-automation/references/integration-recipes.md (relative from skills/objectstack-data/references/, resolves to skills/objectstack-automation/references/integration-recipes.md), with "(connector_action in a flow)". The target's recipes are connector declarations dispatched by a flow (recipe 1 is a scheduled flow); a record-before-* flow gates a write, a record-after-* or scheduled flow carries a side effect, so the note names no phase (review S1). rules/validation.md already sends external-API checks to this section.

Token readings (node scripts/check-skills-token-ratchet.mjs, exit 0)

File main 620b6e6d This branch Ceiling
skills/objectstack-data/references/data-hooks.md 9987 9905 10011
skills/objectstack-formula/SKILL.md 5950 5956 5997 (+6 drawn from existing headroom, accepted by the seat as review S2)

No ceiling is raised, so the ruling path was not used. No line was re-wrapped. Every deletion, with the facts it held and where each survives:

  • Cross-Object API handler snippet (main L738–L755). Facts: ctx.api.object(name) returns a repository → § ctx.api.object(name) first paragraph; findOne({ where: { id } }) with where canonical and filter a tolerated alias → same section, "Query shape" and the filter: note; inserting a related record with the session user → Pattern 2 (audit_log insert, ctx.session && ctx.session.userId); "within the same transaction" and "body needs api.read / api.write" → the prose kept above it.
  • #### handler — Implementation (main L155–L171). Facts: the inline-function shape → the comparison table's Shape row; the string reference → § Registration Methods (handler: 'normalize' + functions), linked from the new sentence; "throw to abort" → the new section's first line and § Error Handling. "(recommended for simple hooks)" is dropped: it recommended the deprecated door.
  • § Sandboxed Hook Bodies lead (main L311–L313). "Everything above this point showed the inline handler" is no longer true; "the form a metadata-only runtime executes" stays in the new lead.
  • Pattern 3's four-line comment. The bulk form update(data, { where, multi: true }) stays in the code and in the method table; "the handler-side repo has no updateMany" is moot for a body; "only the sandbox ctx.api adds updateMany / deleteMany" was false (§ 2).
  • Method table rows upsert and aggregate · updateMany · deleteMany, and three api.write tokens. False (§ 2); aggregate keeps its own row.
  • § async bullets "Calling slow external APIs" and "Logging to external systems" (seat ruling). A body has no outbound HTTP; home: § Capabilities → Connector recipes.
  • Schema example HookContext import. Unused once the example is a body.
  • Review round (paid the M1/S3 additions, net −54 bytes): Gotcha 1's closing sentence "Guard optional values with record.x != null, not with has(record.x)" (home: § condition, "Guard optional values with != null, never with has(...)", same file); Pattern 1's trailing comment "count() is a read; an undeclared token throws in the VM" (homes: the method table's count → api.read row and § Capabilities "Calling an undeclared one throws inside the VM"); Pattern 2's async: false, // must run inside the transaction line (home: § async, "Blocking (default) — runs within transaction" and "When to use async: false: Creating related records"); Pattern 1's old comment "(it is undefined on insert)" (home: the sandbox ctx.previous row).

Eval cases

  • objectstack-data/evals/hooks-security-seeds-datasources.json case 12 (new, body-first, bulk form, row key): copy a changed account.industry onto its contacts. The expected answer keys the bulk where on ctx.previous.id and says why. Must contain afterUpdate, language, js, api.write, multi: true, ctx.previous.id; must not contain handler:, HookContext, account_id: ctx.input.id. (updateMany( left the list per N1: an answer explaining the trap may name it.)
  • objectstack-data/evals/hooks-security-seeds-datasources.json case 13 (new, the guard): run a hook only when an optional annual_revenue is above 1,000,000. Must contain condition:, record.annual_revenue != null, record.annual_revenue > 1000000; must_not_contain is empty (per N1, has(record.annual_revenue) && would fail an answer that explains why has() is no guard). The runtime sentence now says it refuses each write on an account with no annual_revenue (review S4).
  • objectstack-formula/evals/cel-predicates-formulas.json case 2 (corrected): its expected_output predicate was unguarded while its prose asked for the guard; the predicate now carries record.amount != null &&, and must_contain asserts record.amount != null (in place of the bare record.).
  • Sweep: no other case in either skill's evals rewards handler, updateMany / deleteMany / hook upsert, or an unguarded nullable comparison (cases 7 and 10 already forbid handler:). Every must_contain string appears in its expected_output, and no must_not_contain string does.
  • The Connector recipes link has no case of its own: case 10 already asserts that the external-API check leaves the hook.

Other sites found (not changed: outside this card's file surface)

  • skills/objectstack-automation/references/state-machines-and-approvals.md L90, L128, L133, L135: condition: cel`record.amount > 100000` (and > 500000, <= 500000) on a record-after-update flow's start and edges, unguarded and refused (confirmed by the review). Going to a follow-up card.
  • packages/spec/src/data/hook.zod.ts L524–L526: the condition jsdoc @example and .describe() show record.amount > 1000 unguarded, published to content/docs/references/data/hook.mdx. Going to a follow-up card.
  • skills/objectstack-formula/SKILL.md L57: the cel row's example cel`record.amount * 1.1` multiplies a possibly-null field. It is a computed value in a reference table, not a predicate the gate judges.

Deviations (all accepted by the seat before writing)

  • The card's L739 example is deleted, not rewritten (seat ruling 2).
  • The card's L845 example stays a handler, labelled deprecated (seat ruling 1, option A): a body cannot rewrite ctx.result.
  • Widened in the same file (claim comment 6710259290): the upsert / updateMany / deleteMany correction (§ 2), the L105 guard, the two async bullets.
  • Widened again after the contract review (claim comment 6710683947): Patterns 1 and 2 keyed on ctx.previous.id, and the "input.id names the row" prose scoped to the handler. The sandbox ctx.input row ("plus id") states the same claim for a body, so it was scoped in the same commit.

Review round 1 (contract review 6710673767, FAIL at 9931ab6)

  • M1 fixed (Pattern 3 and case 12 on ctx.previous.id; case 12 forbids account_id: ctx.input.id). S1 fixed (no flow phase in the Connector recipes note). S2 accepted by the seat as a headroom draw. S3 fixed under the widening. S4 fixed. N1 applied (quote-free must_contain, trap-explaining strings off must_not_contain). N4 and N5 corrected in this body. N2 and N3 skipped by the seat's word.
  • Delta review 6710804344 (FAIL at a15a1f3): Gotcha 1 said both ctx.result and ctx.input carry id; it now reads "(ctx.result adds id)" (9b1e926, +4 tokens from headroom: 9901 → 9905). N2 left as is.
  • origin/main had moved 5 commits past the base 620b6e6d at review time (3c1eb635, 8acbfab9, bd5a443c, 150f7401, 658d84f5), none touching these files; merged into the branch with the fix (merge commit, no rebase).

Verification

Local gates on 9931ab6: 46 derived, 46 exit 0, 0 NOT MEASURED
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 46 commands for the 5 changed paths; each ran after a full pnpm build (exit 0) under NODE_OPTIONS=--max-old-space-size=8192, with its exit code captured before any pipe. dispatch-gates --ran reconciles: 46 derived, 46 run, 0 NOT-MEASURED, 0 UNRUN. All 46 exited 0, including check:skill-identifier-liveness, check:skill-compatibility, check:skill-frame-sync, check:skill-docs, check:skill-refs, check:doc-authoring, check:corpus-claim-drift, check:role-word and the token ratchet.
  • pnpm check:skill-top-level-keys (an artifact-roster family, not derived): exit 0.
  • pnpm --filter @objectstack/spec run check:skill-examples (the os:check gate; not derived): exit 0, 285 prose examples type-check across 3 surface(s).
  • node scripts/check-skills-token-ratchet.mjs: exit 0, 57 authored bundle file(s) within their ceilings.
  • node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD: exit 0 before the push.
  • Delta run on a15a1f3 (after the review fix and the origin/main merge): the token ratchet, check:skill-refs, both eval JSON files parse, check-commit-card-trailers, check:skill-identifier-liveness, check:skill-top-level-keys, check:doc-authoring, check:corpus-claim-drift, check:role-word, and @objectstack/spec build + check:skill-examples (285 prose examples type-check): all exit 0.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (No schema touched.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset ('@objectstack/skills': patch), and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec not touched; nothing to regenerate.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English. (The 维护者速读 section is Chinese, per the lane template.)
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J8VVAnzH4vvvJVUf6zdYe9

…ble hook and formula predicates

- references/data-hooks.md: the schema example, the implementation section
  and Pattern 3 are sandboxed `body`s; `handler` remains only as the
  deprecated form (Pattern 4 read masking, which a body cannot do, and the
  string-named registration). The Cross-Object API handler snippet is cut
  (homes: § ctx.api.object(name), Pattern 2).
- The repository table and the api.write row drop upsert / updateMany /
  deleteMany, which the hook's ctx.api (ObjectRepository) does not have, and
  teach update / delete with { where, multi: true } as the bulk form.
- Two hook `condition` examples and one objectstack-formula predicate gain
  the `!= null` guard the publish gate requires.
- § Capabilities links Connector recipes; the async list drops the two
  external-call bullets a body cannot do.
- Evals: two new data cases (body bulk cascade, guarded hook condition);
  formula case 2 now asserts the guard.

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

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · huangyiirene · session_01J8VVAj7CvjkGXvgXzd6RZ7

Contract-review-claim: session_01J8VVAj7CvjkGXvgXzd6RZ7 · head 9931ab6 · 2026-11-07T17:16Z

Full contract review of PR #31201 (#31131, claim 6710181100, widened 6710259290). The seat review runs at CONTRACT_REVIEW_TIER in an isolated subagent.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · huangyiirene · session_01J8VVAj7CvjkGXvgXzd6RZ7

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 9931ab6f06e9621d46acc85288bfc58ad8a360f5
Local-runs: probe — node scripts/check-skills-token-ratchet.mjs, run in a throwaway worktree of the head (/tmp/claude-0/seat3/wt-31201, since removed), because the brief asks for the token readings from the repo's own ratchet (exit 0; data-hooks.md 9906 / 10011, objectstack-formula/SKILL.md 5956 / 5997). In the same worktree I also ran node scripts/pm/check-governed-merges.mjs --pr 31201 (exit 3, GOVERNED, Tier H). For M1 I ran one more probe with tsx: a scratch script that holds installFlatInput copied verbatim from packages/objectql/src/hook-wrappers.ts at the head, wraps four hook inputs with it, and snapshots each the way unwrapProxyToPlain (body-runner.ts) does. Main-side bytes were taken by hand (git show 620b6e6d:<file> | wc -c, minus the 20-byte release-stamp line on the formula SKILL, then ceil(bytes/4)). The os:check gate was not re-run; the gate record shows check:skill-examples exit 0.
Scope: the 5 files of git diff origin/main...refs/seat3/pr-31201 (merge base 620b6e6d; one commit 9931ab6f0): .changeset/skills-data-hooks-body-first.md, skills/objectstack-data/references/data-hooks.md, skills/objectstack-data/evals/hooks-security-seeds-datasources.json, skills/objectstack-formula/SKILL.md, skills/objectstack-formula/evals/cel-predicates-formulas.json. origin/main is now 658d84f57, 5 commits past the base (not 3). None of them touches these files or any code cited below; the only overlap by package is membership-key files in packages/lint. Cited code read: packages/spec/src/data/hook-body.zod.ts (HookBodyCapability L48-60, ScriptBodySchema L80-101), packages/spec/src/data/hook.zod.ts (handler L485, body L487-499, condition L518-526, onError L588), packages/runtime/src/sandbox/body-runner.ts (header L18-44, hook throw L497-505, buildSandboxApiSource L1208, buildSandboxContext L1232-1313, unwrapProxyToPlain L1481), packages/runtime/src/sandbox/quickjs-runner.ts (L398 async wrap, L701-708 method install, installApiMethod L1324-1380 with not implemented at L1368), packages/objectql/src/engine.ts (ObjectRepository L10079 on main, ScopedContext.object via engine-scoped-context.ts L63-68, update hook input, unscoped-multi check), packages/objectql/src/engine-object-repository.ts (update/delete pass options), packages/metadata-core/src/engine-update-dispatch.ts (resolveEngineUpdateDispatch L428), packages/metadata-core/src/engine-delete-dispatch.ts (L133, L189-223), packages/objectql/src/recycle-bin/app-authored-delete.ts L67, packages/objectql/src/hook-wrappers.ts (installFlatInput L689 with its ownKeys trap; called unconditionally at L475), packages/objectql/src/hook-binder.ts L335, packages/objectql/src/engine-hook-dispatch.ts (buildPerRowAfterContexts L139-161), packages/metadata-protocol/src/protocol-data-writes.ts L157-163, packages/runtime/src/sandbox/perrow-dispatch-signal.integration.test.ts (L49, L187-188), packages/lint/src/validate-null-guards.ts (surface ledger L85-95, FAULTING_BINARY_OPS L343, outcomes L746), packages/triggers/trigger-record-change/src/record-change-trigger.ts L221-231, scripts/check-skills-token-ratchet.mjs.

① Derived judgments

Inputs: card #31131 (body; triage 6707819308; claim 6710181100; widening 6710259290 with the seat's two rulings), the PR body (identical to /mnt/project-files/card-31131/body-v1.md apart from the attribution lines and a trailing newline), the order at /mnt/project-files/skills-seat3/order-31131.md, the gate record gates-9931ab6f.txt (46 commands, all exit 0), PR #31127's merged diff, the commit, the net diff, and the seat's mid-flight ruling on the two async bullets. Each taught fact was checked against code:

  • Item 1, the body examples. Shapes TRUE. One example keys its write on a value a body does not have. See M1.
    • Schema example (L96-101): body: { language: 'js', source, capabilities: [] } parses. ScriptBodySchema takes language: 'js', a non-empty source, and capabilities defaulting to []. The unused HookContext import is gone. The comment no longer says "Required".
    • #### body — Implementation (L157-170): the source trims ctx.input.email. That works: write-back is applyMutationsToInput over the VM's ctx.input. It calls no ctx.api, so [] capabilities is right. "A throw aborts the write" holds for the default onError: 'abort'. The hook wrapper rethrows at body-runner.ts L503. The deprecated handler's two shapes are named, with a link to § Registration Methods, which holds the string form.
    • Pattern 3 (L787-807): the shape is right. update(fields, { where, multi: true }) needs api.write, which is declared. The source runs inside (async (ctx) => { … }), so a bare await is legal (quickjs-runner.ts L398). There is no outbound HTTP. The defect is account_id: ctx.input.id. A body's ctx.input is a JSON snapshot taken with Object.entries over the flat-input Proxy. That Proxy's ownKeys lists only the payload's keys. So the snapshot carries id only when the payload itself carries one. See M1.
    • Pattern 4 stays an inline handler, retitled "(deprecated inline handler)", with the reason stated. The reason is true. The header at body-runner.ts L24-36 says write-back reaches only ctx.input, and a body's ctx.result is a snapshot. This matches seat ruling 1.
    • The L319 comparison table: the handler column header now says "(deprecated)". The string-registered handler: 'normalize' at L863-869 is labelled "(deprecated)". § Sandbox restrictions and § Hook Context API label the in-process handler deprecated. Every kept handler is honestly labelled. No unlabelled handler example is left (grep of the head file).
    • Forms match PR docs(skills): guard nullable validation operands, teach hook body, list mailbox / package-registry, drop os generate agent #31127: the same body: { language: 'js', source, capabilities } shape, the same "deprecated inline handler" wording, and the same eval pattern (must_not_contain: ["handler:", "HookContext", …]).
  • Item 2, ruling 3 (bulk forms). TRUE, traced end to end.
    • The sandbox installs find / findOne / count / aggregate under api.read, and insert / update / delete / updateMany / deleteMany / upsert under api.write (L705-708). The capability gate runs first. The call then looks the name up on the host repository and throws not implemented when it is missing (L1366-1369).
    • A hook body's ctx.api is the engine's hook API (buildSandboxApiSource returns engineCtx.api when present). The body runner wraps it with refuseBodyPermanentDeletes. ScopedContext.object() returns new ObjectRepository(...), wrapped by refuseAppAuthoredPermanentDelete for an app-authored hook. That wrapper intercepts only delete, and only to refuse permanent.
    • ObjectRepository members: find, findOne, insert, create, update, updateById, delete, deleteById, count, aggregate, execute. It has no upsert, updateMany or deleteMany, so all three throw not implemented from a body. Dropping them is right. (The PR body says "and nothing else" and misses execute. The sandbox does not install execute, so the table is still right. See N4.)
    • update(data, options) spreads options into engine.update. With no id in data and no scalar where.id, resolveEngineUpdateDispatch returns multi when options.multi is truthy. The engine then takes the driver.updateMany predicate path.
    • delete(options) spreads into engine.delete. resolveEngineDeleteDispatch returns multi under options.multi (ENGINE_DELETE_REJECT_MESSAGE = "Delete requires an ID or options.multi=true"). The body-side wrappers pass both through. Both bulk forms work, and each needs only api.write.
    • No other line in data-hooks.md teaches the removed names. Grep for upsert / updateMany / deleteMany in the head file finds none.
  • Item 3, the guards. TRUE.
    • The validate-null-guards.ts ledger (L89) lists "lifecycle hook condition | TOTAL | covered". The outcome for hook conditions is fail-closed (L746): the write is refused.
    • L110 record.status == 'active' && record.amount != null && record.amount > 1000, L216 record.annual_revenue != null && record.annual_revenue > 1000000, and formula SKILL L268 record.amount != null && record.amount > 10000 && record.region in [...] each put != null ahead of the ordering operand. That is the form formula SKILL L112-122 teaches. == and in are not in FAULTING_BINARY_OPS, so status and region need no guard.
    • The os:check block passes per the gate record (check:skill-examples exit 0, "285 prose examples type-check" in the body).
  • Item 4, the Connector recipes link. The link resolves. Its parenthetical names a trigger the target does not show. See S1.
    • ../../objectstack-automation/references/integration-recipes.md from skills/objectstack-data/references/ resolves, and the file exists. check:skill-refs exit 0.
    • The target describes connector_action recipes, one per connector archetype. It has no record-before-* flow, and the string record- does not appear in it. Recipe 1 is a type: 'schedule' flow. The record-before-* trigger types live in the automation SKILL.md Trigger Types table (L371-377), which the body cites. A record-before flow does run inside the write (record-change-trigger.ts maps record-before-update to beforeUpdate), so a gate built on connector_action there is real.
  • Item 5, deletions and tokens. Each cut fact has a home, with one caveat (S1).
    • L739 Cross-Object API snippet. Facts: (a) ctx.api.object(name) returns a repository for another object. Home: § ctx.api.object(name), first paragraph. (b) findOne({ where: { id } }), with where canonical and filter a tolerated object alias. Home: the same section's method table, "Query shape" and the filter: note. (c) Insert a related record carrying the session user. Home: Pattern 2 (audit_log insert, ctx.session && ctx.session.userId). (d) It runs in the same transaction, and a body needs api.read / api.write. Home: the prose kept above it at L724-729. (e) ctx.api?. optional chaining. This was handler-only and is moot for a body. All carried.
    • The two async bullets ("Calling slow external APIs", "Logging to external systems"). Facts: (a) an outbound call is a hook use case. That is false for a body, which has no HTTP door, so the fact is retired, not homed. (b) Outbound calls belong somewhere else. Home: § Capabilities → Connector recipes, per the seat's ruling. Caveat: the home's parenthetical says record-before-*, which runs inside the write. That is the opposite phase from the off-the-write-path side effects these bullets described. See S1. The softer siblings are kept, per the ruling.
    • #### handler — Implementation. Facts: (a) the inline-function shape. Home: the comparison table's Shape row and the new sentence. (b) The string reference. Home: § Registration Methods (handler: 'normalize' + functions), now linked. (c) Throw to abort. Home: the new first line and § Error Handling. (d) "(recommended for simple hooks)" is dropped, which is right: it recommended the deprecated door. All carried. No inbound link used the old anchor (grep for #handler--implementation finds nothing).
    • § Sandboxed Hook Bodies lead. "Everything above this point showed the inline handler" stopped being true, so it goes. "The form a metadata-only runtime executes" stays.
    • Pattern 3's four-line comment. The bulk form stays in the code and the table. "The handler-side repo has no updateMany" is moot for a body. "Only the sandbox ctx.api adds updateMany/deleteMany" was false. Carried or rightly retired.
    • Method-table rows and the three api.write names were false. aggregate keeps its own row, now with the right token, api.read.
    • Ratchet. data-hooks.md: 39948 → 39624 bytes, so 9987 → 9906 of 10011. Net −81, paid by real deletion. formula SKILL.md: 23819 → 23844 bytes (minus the 20-byte stamp), so 5950 → 5956 of 5997. +6, taken from headroom, with no same-file deletion. The body says so openly ("+6 inside existing headroom"). See S2. The script exits 0. scripts/check-skills-token-ratchet.mjs is unchanged against both the base and origin/main, and no ceiling moved. No line was re-wrapped to save bytes. The edited intro, § condition and § Hook Context API lines were edited in place; L558 now runs about 100 characters (N3).
  • Item 6, evals. All three JSON files parse. Data ids run 1-13 and formula ids 1-9, with no gaps. In every touched case each must_contain appears in its expected_output and no must_not_contain does.
    • Data case 12: the shape and the bulk form are TRUE. Its expected_output teaches where: { account_id: ctx.input.id }, which is M1's defect. The assertions do not require ctx.input.id, so a careful answer using ctx.previous.id still passes. The text must move with M1.
    • Data case 13: the guard is TRUE. One sentence overstates: "at runtime it would abort every write the hook is attached to". It aborts only the writes whose record has an empty annual_revenue. See S4.
    • Formula case 2: TRUE. The predicate now carries the guard its own prose demanded, and must_contain asserts record.amount != null.
    • Sweep. No other case in either skill rewards handler. Cases 7, 10 and 12 forbid handler:. No case rewards updateMany / deleteMany / upsert from a body; the only upsert hits are seed mode: 'upsert' in data case 3, which is a different surface and true. No case rewards an unguarded nullable comparison: formula cases 5 and 9 and data case 13 guard theirs. (Untouched data file objects-fields-relationships.json has two cases whose expected_output contains its own must_not_contain string, in explanatory prose. That is pre-existing and harmless.)
  • Item 7, process. Checked.
    • The changeset has '@objectstack/skills': patch. Clause-②: no and Metadata-protocol: none are line-initial in the changeset (L7-8) and the body (copy L6-7).
    • The body has Fixes #31131. It carries the model waiver and names no model ("the project's default model"). No model identifier appears in the body, diff or commit. The trailers are Co-Authored-By: Claude <noreply@anthropic.com> and Claude-Session:.
    • Only claimed files are touched. data-hooks.md is under the claim plus widening 6710259290: the table rows, Pattern 3's comment and the L105 guard. The two async bullets come under the seat's mid-flight ruling. Then the one formula SKILL example, one data eval file, one formula eval file, and a changeset.
    • Tier: check-governed-merges --pr 31201 exits 3: GOVERNED, Tier H, skills/** ×4. The changeset is off the register. The size is +84 / −75, under 3000.
    • Main moved 5 commits since the base (3c1eb635a, 8acbfab9b, bd5a443c0, 150f74019, 658d84f57), not 3. None touches these files or the cited code. See N5.
  • Item 8, other sites. Confirmed below (③).

② Semver level

'@objectstack/skills': patch is right. Only skill prose and eval fixtures change, and @objectstack/skills ships both. No platform behaviour moves, so Clause-②: no and Metadata-protocol: none are right.

③ Boundary flags

  • Claim. All five paths are inside claim 6710181100 plus widening 6710259290. The async bullets come under the seat's mid-flight ruling. No breach.
  • Ratchet script. Unchanged. Standing ruling 6513306068 was not used.
  • Tier. GOVERNED, Tier H. Landing needs the maintainer's merge or an APPROVED review from GOVERNED_APPROVERS, and the body's 「需要你做的」 says so. The PR is a draft, mergeable_state blocked. Labels: documentation, size/m, tooling.
  • Other sites outside the claim, confirmed for filing.
    1. objectstack-automation/references/state-machines-and-approvals.md L90 (start condition: cel\record.amount > 100000`), L128 (> 100000), L133 (> 500000), L135 (<= 500000). Confirmed refused. The flow is type: 'record_change'withtriggerType: 'record-after-update'. That is a record-triggered flow, whose start, edge and decisionconditions the ledger lists as covered (#29026, outcomerun-fails, and the publish gate is stricter on a bare start guard). The body left this open ("whether these flows are record-triggered was not checked"); they are. Each needs record.amount != null &&`.
    2. objectstack-formula/SKILL.md L57, cel`record.amount * 1.1` in the dialect table. Not a refused form. It sits on no surface, and computed field expressions are excluded from the gate by product judgement (ledger, Field.formula row). It is not false teaching, so it need not be fixed here. coalesce(record.amount, 0) * 1.1 would match § 2 of the same skill, but that is optional.
    3. No other skill file teaches updateMany / deleteMany / upsert from a hook body or ctx.api. formula SKILL.md L356 names the driver's updateMany ("one SET clause"), which is engine-level and true. The upsert hits in seeds.md, objectstack-api and objectstack-platform are seed modes and import routes, which are other surfaces.
    4. Extra, data-hooks.md, same file, pre-existing: Pattern 1 (L752, beforeDelete, where: { account_id: ctx.input.id, … }) and Pattern 2 (L775, record_id: String(ctx.input.id || '')). These are bodies on main with the same defect as M1. A delete's hook input is { id, options } with no payload, so the body snapshot is {} and ctx.input.id is undefined. Pattern 1 then counts open opportunities across every account and refuses to delete any account while one exists anywhere. Pattern 2 records '' for every delete and every bulk update. The prose at L54, L252 and L266 ("input.id names the row") is true of the engine context a handler gets, but not of a body's snapshot. See S3.
    5. Extra, outside skills: packages/spec/src/data/hook.zod.ts L524-526, the condition jsdoc @example and .describe() show record.amount > 1000 unguarded. That text is published at content/docs/references/data/hook.mdx L39. It is the same refused form, in a spec file.

④ Design judgment

  • must-fix M1: Pattern 3's body (and eval case 12) key the bulk write on ctx.input.id, which a body does not have on a bulk or delete dispatch. The result is where: {}, which rewrites every contact.
    • What a body sees: ctx.input is Object.entries over the flat-input Proxy (unwrapProxyToPlain). That Proxy's ownKeys returns only Object.getOwnPropertyNames(target.data) (hook-wrappers.ts, installFlatInput). So id is in the snapshot only when the payload carries it.
    • On a predicate update of account (multi: true), each row's afterUpdate input is { id: row.id, data: { ...payload }, options } (buildPerRowAfterContexts). The payload has no id; the engine even drops one from a bulk payload. The repo's own integration test pins this: perrow-dispatch-signal.integration.test.ts asserts inputIdType === 'undefined' on that path and says "the row id a per-row body needs is ctx.previous.id" (L49, L187-188). A by-id write addressed through where: { id } with no id in data leaves it absent too.
    • Probe result, using the head's installFlatInput verbatim: bulk payload → body ctx.input.id undefined; where serialises to {"where":{},"multi":true}. The same holds for a where-addressed by-id update and for beforeDelete. With id in the payload (REST PATCH, updateById), it is present. The in-process handler reads the envelope id in every case, which is why the old example worked.
    • Then { account_id: undefined } crosses the VM boundary as {}, because vm.dump goes through JSON. The engine reads where: {} as "a REAL (match-all) query" (engine.ts, Decision: should an unscoped multi: true UPDATE get the whole-operation dispatch that #9719 gave DELETE? (the update half split out of #9798) #9974 comment). So one bulk account update overwrites account_industry on every contact the caller can update. That is a false, data-corrupting teaching, introduced by this PR's rewrite.
    • Fix: { where: { account_id: ctx.previous.id }, multi: true }. The guard already requires ctx.previous, and previous is the row's pre-image with its id on both the by-id and the per-row path. The cost is +3 bytes, and there are 105 tokens of headroom. Case 12's expected_output must say ctx.previous.id. Adding account_id: ctx.input.id to its must_not_contain would pin the trap.
  • should-fix S1: the Connector recipes parenthetical says "connector_action in a record-before-* flow", which is narrower than the truth, and the target page shows no such flow. A record-before-* flow is right for a check that gates the write. That is the case validation.md sends here. But the cut async bullets were side effects off the write path, and they now point at a phase that runs inside the write and blocks it. Outbound calls also go through record-after-* and scheduled flows, and recipe 1 is a scheduled flow. The cheap fix is "(connector_action in a record-* flow)", which is shorter, or "a record-before-* flow to gate the write, record-after-* for a side effect". The order asked for record-before-*, so this is the seat's call.
  • should-fix S2: the formula SKILL grows +6 tokens (5950 → 5956) with no same-file deletion paying for it. The rule is that growth is paid by deletion with the home named. The body says openly that it draws on headroom, and the script accepts that. Pay it with a same-file deletion, or have the seat accept the headroom draw on the record.
  • should-fix S3: Patterns 1 and 2 in the same file carry M1's defect, and they are pre-existing bodies (③ 4). They are outside the widening, so file them. Or the seat widens by ruling and fixes them with M1, since the fix is the same substitution (ctx.previous.id; in Pattern 2, (ctx.previous || ctx.result || {}).id or similar). Fixing Pattern 3 alone leaves two examples on the page with the same trap.
  • should-fix S4: case 13's expected_output says an unguarded condition "would abort every write the hook is attached to". It aborts only the writes whose record has an empty annual_revenue. Write "would refuse each write on an account with no annual_revenue".
  • nit N1: some eval strings are spelling-sensitive or can catch a careful answer. Case 12's language: 'js' and 'api.write' fail an answer that uses double quotes. Case 12's updateMany( and case 13's has(record.annual_revenue) && can catch an answer that explains the trap. Formula case 9 has the same pattern as precedent. Accept the risk, or loosen.
  • nit N2: the kept async bullet "Sending emails/notifications" is the same outbound class as the two cut ones. A body has no mail door either. It can only insert a record that something else sends. The seat ruled to keep the softer siblings, so this is for the record only.
  • nit N3: § Hook Context API L558 now runs about 100 characters. It was left unwrapped to avoid a re-wrap, which is right. A re-flow at equal line count costs no bytes, so it is optional.
  • nit N4: the PR body's § 2 says ObjectRepository has those ten members "and nothing else". It also has execute. The sandbox does not install it, so the skill's table is unaffected. Body text only.
  • nit N5: the brief and the body say main moved 3 commits since the base. It moved 5. None matters here.
  • Check-runs on this head, read 2026-11-07T17:26Z: 40 runs, 24 success, 13 skipped, 3 in progress, 0 failed.

Verdict: FAIL

…input.id to the handler

A body's ctx.input carries `id` only when the write payload does, so on a
bulk, by-where or delete dispatch `ctx.input.id` is undefined and a
`where: { account_id: ctx.input.id }` matches every row. Patterns 1-3 now
key the row on ctx.previous.id (Pattern 2 falls back to ctx.result for
inserts), and the "input.id names the row" prose and the sandbox ctx.input
row say which door that holds for.

The Connector recipes note no longer names one flow phase. Eval case 12
keys on ctx.previous.id and forbids the input.id key; case 13 no longer
overstates the runtime refusal; must_contain strings drop their quotes.

Paid by same-file deletion: Gotcha 1's restated has() guard sentence,
Pattern 1's capability comment, Pattern 2's default `async: false` line.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAnzH4vvvJVUf6zdYe9
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · huangyiirene · session_01J8VVAj7CvjkGXvgXzd6RZ7

Contract-review-claim: session_01J8VVAj7CvjkGXvgXzd6RZ7 · head a15a1f3 · 2026-11-07T17:35Z

Delta review against the FAIL at head 9931ab6 (comment 6710673767: must-fix M1, should-fixes S1–S4, nits N1–N5). The delta is one fix commit answering M1, S1, S3 (claim widened in #31131 comment 6710683947), S4 and N1, plus a merge of origin/main. The PR body (patched by the seat) answers N4 and N5 and states S2 as accepted. N2 and N3 are left as they are. The seat review runs at CONTRACT_REVIEW_TIER in an isolated subagent.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · huangyiirene · session_01J8VVAj7CvjkGXvgXzd6RZ7

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a15a1f39e71ad33b48e6c46e2cab1c59975ec710
Local-runs: probe — node scripts/check-skills-token-ratchet.mjs, run in a throwaway worktree of the head (/tmp/claude-0/seat3/wt-31201, since removed), because the brief asks for the token readings from the repo's own ratchet (exit 0; data-hooks.md 9901 / 10011, objectstack-formula/SKILL.md 5956 / 5997). In the same worktree I also ran node scripts/pm/check-governed-merges.mjs --pr 31201 (exit 3, GOVERNED, Tier H) and a scratch eval check: the JSON parses, each must_contain string is in its expected_output and no must_not_contain string is, and case 12's old ctx.input.id answer now fails. I did not re-run the installFlatInput probe. packages/objectql and packages/runtime/src/sandbox are byte-identical between the base 620b6e6d and this head, so the round-0 probe results still hold.
Scope: delta review. The fix is git diff 9931ab6f0 efbb19f1e, 3 files: .changeset/skills-data-hooks-body-first.md, skills/objectstack-data/references/data-hooks.md, skills/objectstack-data/evals/hooks-security-seeds-datasources.json. The merge a15a1f39e = efbb19f1e + origin/main at de3996bd5. The net diff (git diff origin/main...refs/seat3/pr-31201) is the same 5 files as round 0. Body v2 = /mnt/project-files/card-31131/body-v2.md. The live body matches it apart from the attribution and signature lines. Widening: #31131 comment 6710683947. Delta gate record: gates-a15a1f39-delta.txt, 10 commands, all exit 0. Cited code re-read on the head: packages/objectql/src/engine.ts (by-id update pre-image L6760-6778 and after-phase L8044-8047, by-id delete readPreImage / bindPreImage L8790-8894, insert rowCtx.result L5901), packages/objectql/src/engine-hook-dispatch.ts buildPerRowAfterContexts L139-161, packages/objectql/src/declared-read-columns.ts (PLATFORM_PROVISIONED_COLUMNS L82 keeps id in every pre-image), packages/runtime/src/sandbox/body-runner.ts (previous: unwrapProxyToPlain(previousRaw), result: engineCtx?.result), packages/objectql/src/hook-wrappers.ts installFlatInput L689, packages/spec/src/data/hook.zod.ts L516 (async default false).

① Derived judgments

  • Merge. Clean.
    • a15a1f39e has parents efbb19f1e and de3996bd5, and de3996bd5 is an ancestor of origin/main.
    • git diff de3996bd5 a15a1f39e touches only the 5 files. git diff efbb19f1e a15a1f39e over those 5 files is empty. git show --cc has no conflict hunks.
    • The merge brings in seven main commits: 3c1eb635a, 8acbfab9b, bd5a443c0, 150f74019, 658d84f57, bd81a7a00, de3996bd5. Main has since moved one more, to 4c3182140 (fix(runtime): attribute the package DELETE and clear the disable record in the uninstall verb #31183, runtime package uninstall).
    • None of the main commits touches the 5 files, packages/objectql, packages/runtime/src/sandbox, the null-guard gate or the ratchet script. It was a normal push, not a rebase.
  • M1 (round 0): fixed.
    • Pattern 3 now writes { where: { account_id: ctx.previous.id }, multi: true }. The guard already requires ctx.previous.
    • previous is bound on every afterUpdate path. On a by-id update, the engine reads the pre-image and refuses when there is none (L6778, rebound at L8047). On a bulk update, each row's context has previous: row (buildPerRowAfterContexts).
    • The pre-image keeps id, because id is a platform-provisioned column (declared-read-columns.ts L82). The body gets a plain JSON copy of it.
    • So the key holds on by-id, by-where and bulk updates.
    • Case 12's expected_output now uses ctx.previous.id and says why. Its must_contain has ctx.previous.id, and its must_not_contain has account_id: ctx.input.id.
  • S3 (round 0): fixed under widening 6710683947.
    • Pattern 1 (beforeDelete) counts on account_id: ctx.previous.id. A by-id delete reads and binds the pre-image before beforeDelete and refuses when there is none (L8889-8894). A bulk delete's per-row before* context carries that row's pre-image (ADR-0058 D1/D2).
    • The new comment "A delete's ctx.input is empty: ctx.previous is the row being deleted" is true. A delete's input is { id, options } with no payload, so the body's snapshot is {}; the round-0 probe confirmed it.
    • Pattern 2 record_id: String((ctx.previous || ctx.result || {}).id || '') is right for each event it is attached to:
      • afterInsert: previous is undefined. result is the created row, so it has id (L5901).
      • afterUpdate: previous is the pre-image, with id. Using previous first is right, because result may be partial (Gotcha 1).
      • afterDelete: by-id, previous stays bound from the pre-delete read. Bulk, each row's after context has previous: row.
    • The || '' fallback cannot trigger on these three events.
    • The three prose sites L54, L252 and L266 now read "input.id (handler; a body: ctx.previous.id)". All three talk about per-row dispatch on update and delete, where previous is bound. True.
  • The deviation: the sandbox ctx.input row (L353). It now reads "id only if the payload has it (the row: ctx.previous.id)". TRUE. The flat-input ownKeys trap lists only payload keys. The old "plus id" was false on by-where and bulk updates. The seat may accept it; it is the same claim as S3.
  • One sentence still teaches the old claim. Gotcha 1 (L469), also in the sandbox section, says "On afterUpdate, both ctx.result and ctx.input carry only the fields this PATCH touched, plus id." The ctx.input half is the claim L353 just corrected. See M1 below.
  • S1 (round 0): fixed. The note is now "(connector_action in a flow)". That is true of every recipe in the target page, and it names no phase.
  • S2 (round 0): accepted by the seat as a headroom draw. Body v2 records that in the token table and in 维护者速读.
  • S4 (round 0): fixed. Case 13 now says the guardless condition "would refuse each write on an account with no annual_revenue".
  • N1 (round 0): applied.
    • Case 12's must_contain is quote-free: language, js, api.write. updateMany( left must_not_contain.
    • Case 13's must_not_contain is []. objectstack-ui and objectui evals already use an empty array, and the gate record's JSON parse passes.
    • The cases still discriminate. Case 12 rejects the old ctx.input.id answer (checked) and a handler: answer. Case 13 needs record.annual_revenue != null.
    • js is nearly free (any "json" contains it), but ctx.previous.id, multi: true and api.write carry the case. See N2.
  • N4 and N5 (round 0): corrected in body v2. § 2 lists execute and says the sandbox does not install it. The round-1 section names the 5 commits.
  • New deletions that pay the additions. Each fact has a home.
    • Gotcha 1's "Guard optional values with record.x != null, not with has(record.x)." Home: § condition L270, "Guard optional values with != null, never with has(...)".
    • Pattern 1's comment "count() is a read; an undeclared token throws in the VM". Homes: the method table, count(opts) → api.read (L383), and § Capabilities, "throws inside the VM" (L430).
    • Pattern 2's async: false, // must run inside the transaction. async defaults to false (hook.zod.ts L516), so the example behaves the same. Home: § async, "Blocking (default) — runs within transaction" (L192) and "When to use async: false: Creating related records" (L203-204).
    • Pattern 1's "(it is undefined on insert)". Home: the sandbox ctx.previous row (L354).
  • Tokens.
    • data-hooks.md is 39603 bytes, so 9901 of 10011: −5 tokens against round 0 and −86 against main.
    • formula SKILL.md is unchanged at 5956 of 5997.
    • The script exits 0 and is unchanged against origin/main. No ceiling moved.
    • No line was re-wrapped. The three scoped prose lines grew in place. They now run 115-125 characters, which matches many existing long lines in the file.
  • Process. Checked.
    • The changeset still has '@objectstack/skills': patch, with Clause-②: no and Metadata-protocol: none line-initial (L7-8). Its prose now explains the row key.
    • Body v2 keeps Fixes #31131 and both declaration lines line-initial. The waiver names no model.
    • No model identifier appears in the fix diff, the two new commit messages or body v2. The fix commit carries Co-Authored-By: Claude <noreply@anthropic.com> and Claude-Session:.
    • Every path is inside the claim, widening 6710259290 and widening 6710683947. The L353 row is the recorded deviation.
    • Tier: check-governed-merges --pr 31201 exits 3: GOVERNED, Tier H, skills/** ×4. The changeset is off the register. The size is +93 / −86, under 3000.

② Semver level

'@objectstack/skills': patch is still right. Only skill prose and eval fixtures change. Clause-②: no and Metadata-protocol: none are still right.

③ Boundary flags

  • Claim. All 5 paths are inside claim 6710181100 plus widenings 6710259290 and 6710683947, and the seat's async ruling. The L353 row is a recorded deviation of the same kind as widening 6710683947. Gotcha 1 L469 (M1) is the same claim on the same page, so fixing it needs at most the same acceptance.
  • Ratchet script. Unchanged. Standing ruling 6513306068 was not used.
  • Tier. GOVERNED, Tier H. Landing needs the maintainer's merge or an APPROVED review from GOVERNED_APPROVERS. The PR is a draft, mergeable_state blocked.
  • Other sites. Body v2 sends the approval-edge conditions (state-machines-and-approvals.md L90/L128/L133/L135) and the hook.zod.ts L524-526 example to a follow-up card. That is confirmed in widening 6710683947. Nothing new outside the claim.

④ Design judgment

  • must-fix M1: Gotcha 1 (L469) still says a body's ctx.input carries id on afterUpdate. That contradicts the corrected L353 row, and it is the same trap as round-0 M1.
    • The sentence "both ctx.result and ctx.input carry only the fields this PATCH touched, plus id" sits in the sandbox section.
    • On a by-where or bulk update, the body's ctx.input has no id. The round-0 probe showed the snapshot {"industry":"Tech"}, and perrow-dispatch-signal.integration.test.ts L187 asserts it.
    • After this PR, L353 says "id only if the payload has it", and L469 says "plus id". A reader of Gotcha 1 can still key on ctx.input.id.
    • Fix: scope id to ctx.result, for example "both ctx.result and ctx.input carry only the fields this PATCH touched (ctx.result adds id)". Or drop "and ctx.input". That costs about 10 bytes against 110 tokens of headroom. The ctx.result.id re-query example below it is unaffected.
  • nit N1: the three scoped clauses at L54, L252 and L266 now run about 115-125 characters. They were left unwrapped to avoid a re-wrap, which is right. The file already has many long lines.
  • nit N2: case 12's must_contain entries language and js are close to free. "json" contains js. The case discriminates on ctx.previous.id, multi: true and api.write, so this is acceptable as it stands.
  • Check-runs on this head, read 2026-11-07T17:39Z: 43 runs, 22 success, 15 skipped, 6 in progress, 0 failed.

Verdict: FAIL

A body's ctx.input carries `id` only when the payload does, as the sandbox
ctx table now says; Gotcha 1 no longer claims both carry it.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAnzH4vvvJVUf6zdYe9
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · huangyiirene · session_01J8VVAj7CvjkGXvgXzd6RZ7

Contract-review-claim: session_01J8VVAj7CvjkGXvgXzd6RZ7 · head 9b1e926 · 2026-11-07T17:42Z

Delta review against the FAIL at head a15a1f3 (comment 6710804344, must-fix M1). The delta is one commit, a one-line change in data-hooks.md, plus the PR body's token reading (patched by the seat). The seat reviews it at CONTRACT_REVIEW_TIER.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · huangyiirene · session_01J8VVAj7CvjkGXvgXzd6RZ7

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 9b1e92644c88f66da7264ff1a1e7ae6485786aa7
Local-runs: probe — a byte count of skills/objectstack-data/references/data-hooks.md at the head, read from git objects with no checkout, because the delta grows that file and its ceiling must hold (39617 bytes, 9905 of 10011 tokens).
Scope: delta review. One commit, 9b1e9264 (only parent a15a1f39, a normal push). git diff a15a1f39 refs/seat3/pr-31201 is one line in skills/objectstack-data/references/data-hooks.md (Gotcha 1, ≈L469-470). Also read: the PR body v3, diffed against v2.

① Derived judgments

  • M1 is fixed. Gotcha 1 now reads "On afterUpdate, both ctx.result and ctx.input carry only the fields this PATCH touched (ctx.result adds id)". The id is now scoped to ctx.result. A body's ctx.input has no id on a by-where or bulk update, which the previous record established from installFlatInput and perrow-dispatch-signal.integration.test.ts. The line now agrees with the corrected ctx.input row (≈L353).
  • No line in the file still teaches ctx.input.id as a body's row key. A grep of the head for ctx.input.id and "plus id" finds no such teaching.
  • Budget. data-hooks.md grows 4 tokens from headroom, 9901 → 9905 of 10011. No ceiling moved and the ratchet script is unchanged.
  • Body v3 changes only that reading (the 速读 line and the token table) and adds one line recording this round.

② Semver level

Unchanged: '@objectstack/skills': patch, with Clause-②: no and Metadata-protocol: none line-initial in the changeset and the body.

③ Boundary flags

  • Claim. The same file, inside the claim and widening 6710683947.
  • Tier. Unchanged: GOVERNED, Tier H.

④ Design judgment

The page now gives one consistent account of what a body's ctx.input holds.

Verdict: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · huangyiirene · session_01J8VVAj7CvjkGXvgXzd6RZ7

维护者速读

  • 改了什么: objectstack-data/references/data-hooks.md 改为先教沙箱 body:schema 示例、Implementation 一节、Pattern 1–3 改写为 body;handler 只留在对照表、Pattern 4(afterFind 脱敏,body 无法改写 ctx.result)和字符串注册写法里,并标为已弃用。修正 ctx.api.object(n) 方法表与 api.write 行:删去 body 里根本不存在的 upsert / updateMany / deleteMany,改教 update(data, { where, multi: true })。body 里按行定位改用 ctx.previous.id(批量、按 where 和删除路径上 ctx.input 没有 id)。两处 hook condition 与 formula SKILL 一个 os:check 示例补 != null 守卫;补 Connector recipes 链接。eval:data 新增 12、13,formula 改正 2。5 个文件。
  • 为什么改: skills: data-hooks.md still teaches the deprecated handler first and an unguarded hook condition; formula SKILL has an unguarded example #31131。PR docs(skills): guard nullable validation operands, teach hook body, list mailbox / package-registry, drop os generate agent #31127 之后 data-hooks 仍先教已弃用的 handler,两处比较会被发布门拒绝;复核中另查实三个不存在的 body API 与一个会匹配全表的批量写。
  • 风险与回滚: 只改技能文字与 eval;data-hooks 9987 → 9905 / 10011,formula SKILL 5950 → 5956 / 5997(余量支取,已认可),无上调。可整 PR revert。
  • 先看: data-hooks.md 的 Pattern 3(批量级联,键 ctx.previous.id)与 ctx.api.object(name) 方法表。
  • 两分钟验证: node scripts/check-skills-token-ratchet.mjs,exit 0。
  • 需要你做的: skills/** 是受治理 Tier H 面,需 os-zhuang 或 hotlong 在 GitHub 上 Approve 一次。达档复核:全量 6710673767 FAIL(head 9931ab6f),增量 6710804344 FAIL(head a15a1f39),增量 6710836247 PASS,Head-sha 9b1e92644c88f66da7264ff1a1e7ae6485786aa7。批准后本席落地。
  • 席位意见: ACCEPT。

席位核对 — ACCEPT · domain:skills#3 · head 9b1e92644c88f66da7264ff1a1e7ae6485786aa7

  1. 形态: draft → main,Fixes #31131;'@objectstack/skills': patch,Clause-②: no,Metadata-protocol: none;作者 objectstack-fleet[bot];5 个文件,在认领面(含扩面 6710259290、6710683947)之内。
  2. 前提实测: 复核逐项对照 main 代码:hook-body.zod.ts / hook.zod.ts、body 运行器(只回写 ctx.input,ctx.result 为快照,无外呼 HTTP)、quickjs-runner.ts(未实现方法抛错)、ObjectRepository(无 upsert / updateMany / deleteMany)、update / delete 的 multi: true 经 ScopedContext 到驱动、installFlatInput 与 perrow-dispatch-signal.integration.test.ts(body 的 ctx.input 无 id)、validate-null-guards.ts(覆盖 hook condition)。
  3. 门禁(钉 head 9b1e9264): dev 派生门禁 46 条全部 exit 0(gates-9931ab6f);两轮跟进的 ratchet、skill-refs、skill-examples(285)、identifier-liveness、top-level-keys、JSON 解析、trailers 全部 0;check-runs 46 条:31 success、15 skip、0 失败;check-governed-merges --pr 31201:Tier H(skills/**)。
  4. 接受的偏差: 席位裁定:Pattern 4 保留为标注弃用的 inline handler;L739 片段删除(归宿 § ctx.api.object 与 Pattern 2);async 两条外呼条目删除(归宿 § Capabilities → Connector recipes);扩面一修正 body API 表、守卫 L105;扩面二 Pattern 1/2 与三处 input.id 文字按 ctx.previous.id 改正;线程对 L353 ctx.input 行的同类收窄经复核为真,接受。formula SKILL +6 token 为余量支取(S2,认可)。N2、N3 等不改。
  5. 范围外去向: automation 技能 state-machines-and-approvals.md 审批边条件未守卫、hook.zod.ts 中 HookSchema.condition 示例未守卫 → skills + spec: approval-flow edge conditions in state-machines-and-approvals.md and the HookSchema.condition example compare a nullable amount unguarded, which the publish-time null-guard rule refuses #31206。
  6. 落地条款: Tier H。保持 draft,挂 pm:awaiting-merge,请 os-zhuang、hotlong 审批;获批后本席过落地前检、清标、ready、auto-merge;维护者直合亦可。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 7, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 7, 2026 23:37
@os-zhuang
os-zhuang enabled auto-merge November 7, 2026 23:37
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 007fdb1 Nov 8, 2026
52 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-midtvb branch November 8, 2026 00:21
@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 8, 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 size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skills: data-hooks.md still teaches the deprecated handler first and an unguarded hook condition; formula SKILL has an unguarded example

3 participants