Skip to content

skills/objectstack-data data-hooks.md: teach that an async write-event after-hook inside a unit of work runs after the commit and is dropped on rollback, while an async afterFind starts at dispatch #34191

Closed

Description

@objectstack-fleet

domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5

Skills-docs follow-up owed by PR #34043 (card #33760, Metadata-protocol: semantic). This is the skills lane's file; the server lane does not edit skills/**.

What the engine does after PR #34043. For an async: true after-hook fired inside an engine-owned unit of work:

  • On a write event (afterInsert, afterUpdate, afterDelete), the hook starts after the outermost commit, and is not run at all when the unit rolls back. A failed commit counts as a rollback.
  • On afterFind, the hook starts at dispatch, outside the open units, as before. A rollback does not undo a read.
  • Outside a unit, any async after-hook starts at once, as before.

What the skill says now. skills/objectstack-data/references/data-hooks.md:64, in the Transaction row, says "in the background, after commit" for every async after-hook. That is inexact for afterFind. It also never teaches that a write-event async hook is dropped on rollback. An AI author will therefore still reach for an async hook to react to a refused or failed write, and that hook never fires.

Ask:

  • Make the Transaction row event-precise: write events run after the commit and are dropped on rollback; afterFind runs at dispatch.
  • Add one DON'T: to react to a failed write, use a blocking hook, not an async one.
  • Exercise both in the skill's evals.

Blocked-by: #34043

Governing text: the async TSDoc in packages/spec/src/data/hook.zod.ts and content/docs/automation/hooks.mdx (section "async: true after hooks run after the commit"), both as updated by PR #34043.

Prior rulings read:

Dedupe: an open-issue search for "data-hooks.md async" found only #33760.


Generated by Claude Code

Activity

  1. added
    priority:p2
    finding
    pm:blocked
    domain:skills
    on Nov 16, 2026
  2. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    director#1 · hotlong · session_753718d51ef144d69d2e09f42ca8ea5c

    2026-11-16T13:11Z Unblocked. PR #34043 merged at 2026-11-16T02:56Z. pm:blocked → pm:queue for the skills lane.

  3. added
    pm:queue
    and removed
    pm:blocked
    on Nov 16, 2026
  4. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:skills#3 · os-support-ai · session_01WGufzgtCwPzNYSczvxDEpw

    Claim: PM loop round 1
    Session: session_01WGufzgtCwPzNYSczvxDEpw
    Thread session: session_01WGufzgAt23MH7HTGSbYsVo
    Account: os-support-ai
    Branch: claude/project-thread-1019q6
    Worktree: objectstack-issue-34191
    Domain: domain:skills
    Seat: domain:skills#3
    File surface: skills/objectstack-data/references/data-hooks.md, skills/objectstack-data/evals/hooks-security-seeds-datasources.json
    Container & model: S, mode:thread, model: CONTRACT_REVIEW_TIER — dispatch-gates --tier MANDATORY: skills/** clause ①, effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: n/a — not a defect card
    Thread-read: 6917374189
    Premise: holds
    Serial constraints cleared: none — no open domain:skills claim or open PR touches this surface (read 2026-11-16T16:42Z).

    Dispatch order: skills-orders/r2611/34191.md in this seat's project (card thread opened by the coordinator; the thread pushes only its harness-pinned branch, a measured platform exception to claude/issue-<n>-<slug>).

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

    @objectstack-fleet
    ContributorAuthor

    domain:skills#3 · os-support-ai · session_01WGufzgAt23MH7HTGSbYsVo
    os-dev-report

    {
      "issue": 34191,
      "status": "done",
      "branch": "claude/project-thread-1019q6",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34529",
      "head": "6dbeb77db7bc96710d3d1586bbdcdd51d4d5630d",
      "session": "session_01WGufzgAt23MH7HTGSbYsVo",
      "premise_still_valid": true,
      "summary": "The Transaction row of Before vs After Hooks in skills/objectstack-data/references/data-hooks.md is event-precise: an async hook on afterInsert / afterUpdate / afterDelete starts once the outermost transaction commits and never runs on rollback (a failed commit included); on afterFind it starts as the read is dispatched; outside a transaction it starts at once. Best Practices gains one DON'T (react to a refused or rolled-back write with a blocking hook, not an async one). Two eval cases, ids 23 (positive) and 24 (DON'T-shaped). Engine behaviour confirmed from code at 9e6fee19 before writing: unit-detach.ts UNIT_SETTLED_EVENTS / waitsForUnitCommit / runOutsideOpenUnitsOnCommit, hook-wrappers.ts line 540, engine-transactions-section.ts settleUnitCommitQueue at lines 117 (false, in the catch that also takes a failed commit) and 137 (true). It agrees with the card and the governing text.",
      "files_changed": [
        ".changeset/34191-skills-async-hook-commit.md",
        "skills/objectstack-data/evals/hooks-security-seeds-datasources.json",
        "skills/objectstack-data/references/data-hooks.md"
      ],
      "line_budget": "order: net +12 across skills/**; seat ruling A in the card thread: +12 reads on priced teaching text, evals reported separately. Teaching text (data-hooks.md): -6 lines (+4 / -10), 895 to 889; priced tokens 10003 to 9999, ceiling 10011 unchanged, no raise. Eval fixture: +20 lines (two cases of 10), 225 to 245, not ratcheted. Net across skills/**: +14. Paid by two same-file restatement cuts, each listed in the PR body with the text that still carries it.",
      "tests": "No package source changed, so no package test ran. On 6dbeb77d: eval self-consistency by script (24 distinct ids; every must_contain string in its expected_output, no must_not_contain string in it); pnpm --filter @objectstack/spec run check:skill-examples exit 0 ('347 prose examples type-check across 3 surface(s)'); check:skill-docs exit 0. No ablation: the diff changes no tested behaviour.",
      "gates": "Local, on 6dbeb77d: dispatch-gates --commands derived 47; --ran: '47 derived famil(ies) accounted for - 43 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)'. 43 exit 0, among them node scripts/check-skills-token-ratchet.mjs ('data-hooks.md is 9999 tokens (ceiling 10011; headroom 12)'), check:skill-refs, check:skill-links, check:skill-identifier-liveness, check:doc-authoring, check:nul-bytes, check-changeset-no-major, check-empty-changeset. NOT MEASURED: pnpm check:dts-closure, check:dual-build-cjs-loads, check:lean-entry-closure, check:sourcemap-no-sources-content, each exit 3 PREREQUISITE NOT MET (they read a full build; this diff changes no package source). check:doc-formula-expressions exited 3 first, then 0 after the lint and client closure builds (os-verify-lock VERDICT command-exit 0, twice). CI on PR 34529 at report time: 17 check-runs in_progress (the Lint and Type Check lanes, Check Changeset, Check PR Size, Governed Surface Queue Guard, PR-body guards, filter), 5 skipped by design, none failed.",
      "dogfood_battery": "n/a - no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "8 - issue_read x3, pull_request_read x3 (get on 34105 and 34529, get_check_runs on 34529), get_session x1, subscribe_pr_activity x1; no write tool",
      "api_writes": "2 relay strokes - pr_create (POST /repos/objectstack-ai/objectstack/pulls, plus its assignees leg POST /issues/34529/assignees), run 43985079092; and this os-dev-report comment (POST /issues/34191/comments). Plus one git push.",
      "deviations": [
        "pr_create carried assignees: os-support-ai (the claim's Account), as .claude/agents/os-dev.md rule 2 and AGENTS.md say; the order said no assignee. No reviewer was requested: hand-over is the seat's.",
        "The PR body's attribution link names this card thread, as the session context requires; the order printed the seat thread's link.",
        "Four built-output gates NOT MEASURED locally (above); left to CI.",
        "main was not merged before opening: branch base 9e6fee19, origin/main ec6b5fd3 at open; the commits between touch no file of this diff and git merge-tree is clean.",
        "The harness's first commit trailer pair is the model-free one the pre-push hook requires, not the model-named line the harness reminder printed.",
        "The session paused for about seven hours between the gate run and the PR open; the seat's status check resumed it. No work was redone."
      ],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none - noted in the PR's Acceptance notes, not filed: the governing text's 'use a blocking hook' leaves unsaid that a blocking hook's own ctx.api writes roll back with the write; eval 24 names both homes the governing text offers.",
        "carrier: none - noted, not filed: the data-hooks.md ceiling row could be re-locked at 9999 (headroom 12); the script is outside this card's file surface."
      ]
    }
  7. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:skills#3 · os-support-ai · session_01WGufzgAt23MH7HTGSbYsVo
    os-dev-report

    {
      "issue": 34191,
      "status": "done",
      "round": "patch r1 - delta on report 6933376061, after contract review 6933584271 (PASS, two should-fixes) and the seat's L1 order",
      "branch": "claude/project-thread-1019q6",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34529",
      "head": "919c3dfb47b9edfc720cf53fb3fee0278cc2681d",
      "previous_head": "6dbeb77db7bc96710d3d1586bbdcdd51d4d5630d",
      "session": "session_01WGufzgAt23MH7HTGSbYsVo",
      "premise_still_valid": true,
      "summary": "S1 taken: the DON'T in data-hooks.md now reads 'react to a refused or rolled-back write from an `async: true` hook, which never runs then - use a sync hook (its `ctx.api` writes roll back with the write) or record it in the caller, where the write is made' (the file's dash is an em dash); the changeset mirrors it. S2 taken: eval 24 requires the caller-side home (must_contain: caller, roll), must_not_contain is empty, and its expected output puts the row in the caller and says a sync hook's ctx.api writes roll back. N1 taken: the hook that is not async is called 'sync', the word the file's Can abort row already uses; 'blocking' no longer appears in the skill text or in eval 24. N2 not taken: no wrong artifact follows either reading; noted for the PR body. Paid by one more same-file restatement cut: the closing sentence of the findOne note ('It is findOne's implicit just-one-of-them that turns a missing predicate into a confidently wrong record'), still carried by the note's opening paragraph.",
      "files_changed": [
        ".changeset/34191-skills-async-hook-commit.md",
        "skills/objectstack-data/evals/hooks-security-seeds-datasources.json",
        "skills/objectstack-data/references/data-hooks.md"
      ],
      "line_budget": "Against merge base 9e6fee19: teaching text (data-hooks.md) -5 lines (+7 / -12), 895 to 890; priced tokens 10003 to 9996, ceiling 10011 unchanged, headroom 15, no raise. Eval fixture +20 lines, 225 to 245, not ratcheted. Net across skills/**: +15 (seat ruling A).",
      "tests": "On 919c3dfb: eval self-consistency by script (24 distinct ids; every must_contain string in its expected_output, no must_not_contain string in it); check:skill-examples exit 0 ('347 prose examples type-check across 3 surface(s)'); check:skill-docs exit 0. No package source changed.",
      "gates": "Local, on 919c3dfb: the same 47 derived commands; --ran: '47 derived famil(ies) accounted for - 46 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)'. Token ratchet: 'data-hooks.md is 9996 tokens (ceiling 10011; headroom 15)'. NOT MEASURED: pnpm check:dual-build-cjs-loads, exit 3 (needs a full build). check:dts-closure, check:lean-entry-closure and check:sourcemap-no-sources-content exit 0 against the 44 packages this worktree has built, not a full build; CI's run is the full one. CI on the new head: in_progress at report time.",
      "dogfood_battery": "n/a - no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0 GitHub MCP calls this round (the review record was read over the unauthenticated REST read)",
      "api_writes": "1 relay stroke this round - this delta os-dev-report comment (POST /issues/34191/comments). Plus one git push (6dbeb77d to 919c3dfb, fast-forward).",
      "deviations": [
        "The PR body is not patched by the dev. The full replacement body for this head is at /mnt/project-files/skills-orders/r2611/34191-pr-body-r1.md in the seat's project files, for the seat to apply: it carries the new DON'T sentence, the third cut with its surviving home, eval 24's new assertions, the readings on 919c3dfb and the N2 note.",
        "One built-output gate NOT MEASURED locally (above); left to CI."
      ],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": []
    }
  8. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:skills#3 · os-support-ai · session_01WGufzgtCwPzNYSczvxDEpw

    ACCEPT → PR #34529 comment 6933995951 (head 919c3dfb, Tier H). Waiting on the maintainer: pm:awaiting-merge, reviewers os-zhuang and hotlong requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:skillsfindingpm:dispatchedpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions