Skip to content

fix(approvals): a record delete cancels the flow run its voided approval gated - #38293

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-sz9xxz
Nov 28, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-sz9xxz

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Refs #37763

Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:单据在等审批时被删掉,等这条审批的流程运行现在当场结束,状态为「已取消」并写明原因是单据被删;批准、驳回两条后续都不走。审批套在子流程里时上层一并取消;批量审批里的一条被删,批量接着走下一条。
  • 为什么做:维护者在这张卡上选了「自动取消」;此前这类运行永远停在「暂停」,和真在等人批的运行分不出来。
  • 出错会怎样:取消失败不会让删除失败,那条运行照旧停着并在告警里点名,和今天一样;本 PR 之前留下的旧运行不自动清理。可直接撤回。
  • 要你做什么:无。审批技能与审批指南各补的一句另开 PR(受治理路径,需你合并)。

What changes

  • packages/plugins/plugin-approvals/src/approval-service.ts
    • cancelForDeletedRecord: after voiding every pending request of the deleted record (unchanged), it ends the run each request gated through the new private cancelRunsOfVoidedRequest. It answers a new cancelledRuns list (a new member of a public method's answer on the exported ApprovalService, hence Clause-②: yes (widening)); suspendedRuns keeps its meaning, the runs left behind, which are now only the runs that could not be cancelled, and the warning fires only for those. With no cancelRun on the engine it logs at error in the delete's own words (not the decision door's missingRunCapability line) and the run is left.
    • cancelRunsOfVoidedRequest: cancels the request's run with the reason approval request ID was cancelled because the record it is about was deleted, then every subflow parent above it on the same record, deepest first, through the engine's existing cancelRun. If the top of that chain is a map item, the batch above it is read first (batchAboveItem, as the revise-window recall does) and woken afterwards through the existing resumeBatchOfRecalledItem, which now takes a cause so its log and message say which of the two cancelled the item. ⛔ No resume is ever sent to a subflow parent; neither the approve nor the reject branch runs.
    • voidedRunChain: finds the chain with existing reads only. The request row's record_run_id (ADR-0162 Execution item 7) is the highest run over the same record; the walk goes down from it along each parent's correlation (subflow:CHILD, map:CHILD) through suspensionOf, one keyed read per hop, until it reaches the request's flow_run_id, and cuts the chain below its lowest map: link (a batch is woken, never ended). Bounded at 32 hops.
    • Docblocks of cancelForDeletedRecord, REQUEST_STATUS_STRANDABILITY and ApprovalResumeSurface.suspensionOf updated to the ruling.
  • Tests: the existing "must not cancel" pin in record-delete-cancel.integration.test.ts is rewritten to the ruling, plus a failed-cancel case; the real-engine cases are a new top-level describe in batch-item-recall-resumes-batch.test.ts (the shared harness for a cancelled batch item).
  • Changeset: .changeset/approval-delete-cancels-parked-run.md, @objectstack/plugin-approvals patch, which also says how an administrator finds the runs left paused by earlier deletes.

⛔ Not changed: service-automation (no engine member added, run-resume.ts untouched), packages/spec, the delete hook in lifecycle-hooks.ts (it already calls cancelForDeletedRecord and swallows its failures).

Why

Maintainer ruling on #37763, option A (card comment 7237973760): the run parked on a request its record's delete voided is cancelled in the same step, end state cancelled, reason the delete; neither branch runs; the delete is never refused and a failed cancel never fails it; a batch item wakes its batch (as PR #28228 does for a revise-window recall); inside a subflow the parent chain is cancelled too, never resumed; runs parked by earlier deletes are not cleaned up.

The ruling's three premises, measured before writing

Probe: real AutomationEngine + real ApprovalService over the fake engine of batch-item-recall-resumes-batch.test.ts, in-memory suspended-run store, on main f19350b4. Probe file and its output are kept outside the repo (the project's shared folder, 37763/probe-37763.test.ts and probe-37763-readings.txt); 5/5 passed.

premise reading
① cancelRun on a run parked at an approval node succeeds and leaves no other state true; history cancelled with the reason as error; nothing parked; hasSuspendedRun false; inspectConsumedSuspension answers NO_CONSUMED_SUSPENSION; a second call answers false; the request row untouched (cancelled / record_deleted). On main the run stays parked after the delete.
② the existing wake-the-parent path moves a batch on batchAboveItem before, cancelRun on the item, resumeBatchOfRecalledItem after: no error, item 2's request opens; after approving it the batch completes, its reader ran once.
③ inside a subflow the parent stays parked, and the existing cancel suffices Measured: after cancelling the child the parent stays parked at the subflow node on subflow:CHILD. The parent is reachable with existing surfaces: record_run_id names the top of the chain and suspensionOf names each child; a three-level chain was cancelled deepest first with all three cancelled and nothing run after the subflow; a batch item that runs its sign-off in a subflow was cancelled as a chain and the batch moved on. No new contract surface.

Small decisions taken in the thread (listed for review):

  • The chain is cut below its lowest map: link, so a batch whose items carry no record of their own is woken, not cancelled (the ruling's batch rule, read literally).
  • A request with no record_run_id (opened before requests recorded it, or on an engine that hands no record run) cancels only its own run and logs nothing: that is also every flat run on such an engine, where a warning would be noise (seat ruling on review finding S1). An engine without suspensionOf, or a walk that does not reach the request's run, cancels the request's own run alone and warns that a run above it may stay parked.
  • A cancelRun that throws stops the chain there: that run and the runs above it are logged at error (as the revise-window recall's failed cancel is) and named in the summary warn. A false answer (no suspension under that id, or a store the engine could not read, which the engine names at error itself) does not stop the chain.
  • The runs are cancelled after every request of the record is voided, so a failing cancel never leaves a later request in the inbox.

Verification

  • batch-item-recall-resumes-batch.test.ts, new describe('a record delete cancels the run its voided request gated (#37763)'), 7 cases: a flat run (cancelled with the reason, neither branch's node ran, nothing parked, no log); a batch item (cancelled marker in its slot, outside count, next item opens, batch completes); a three-level subflow chain (cancelled deepest first, every reason the delete, resume never called, nothing after the subflow ran); a batch item whose sign-off is in a subflow; a request with no record_run_id (own run cancelled, no log); a suspensionOf that throws; a cancelRun that throws.
  • record-delete-cancel.integration.test.ts (real ObjectQL + SQLite, the real delete hook): the "runs no flow node" pin now asserts one cancelRun('run_1', reason), no resume, no left-behind warning; two new cases: cancelRun rejects, the delete lands, the request is cancelled, the run is named in the warning; and an engine with no cancelRun, where the delete lands and the run is named in the delete's own error line and in the warning.
  • Reverse check: with approval-service.ts restored to main, 8 of the new or rewritten cases fail (all 7 above, and the rewritten pin); restored to the head (git hash-object equal to HEAD), all pass.
Local runs

Head e103c2e0 (base main f19350b4; e103c2e0 is the review fix on top of 948f4494; the 9 commits main gained since touch none of plugin-approvals, service-automation or objectql).

  • pnpm --filter @objectstack/plugin-approvals test (whole package, under the verify lock): 131 files, 1988 tests passed, 0 failed (at the head; 1987 at 948f4494). pnpm --filter @objectstack/plugin-approvals typecheck: exit 0.
  • npx eslint on the four changed source and test files: exit 0.
  • Reverse check above: 8 failed / 21 passed in the two touched test files with approval-service.ts at main; 29/29 at 948f4494; the two touched files 30/30 at the head.
  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran FILE (exit codes recorded before any pipe): 72 derived, 69 run, 3 NOT-MEASURED, 0 UNRUN, every run family exit 0 (at 948f4494; the review fix touches the same four files and re-ran the package suite, typecheck and eslint). NOT MEASURED (exit 3, prerequisite not met): check-plugin-teardown-shape.mjs --self-test (its fixture commit is outside this shallow clone), check:dual-build-cjs-loads and check:i18n (they read dists of packages not built in this container; only the plugin-approvals closure is).

Acceptance notes

  • A record deleted while its request is returned (in a revision window) is outside the ruling: only pending requests are voided by a delete, so that run is untouched, as before.
  • The approvals skill and the approvals guide gain one sentence each in a separate PR, docs(approvals): a record delete cancels the parked flow run #38295 (skills/** is Tier H); that one is the PR that finishes the card, so this one only refers to it.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; eslint on the changed files passes (the full pnpm lint was not run locally; CI runs it).
  • 4. One issue, one branch off an up-to-date main, one pull request. (branch claude/project-thread-sz9xxz is the harness-assigned name)
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: no.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 block is the maintainer summary).
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD

…val gated

The record-delete void now cancels the run parked on the request it voids,
with the reason, cancels every subflow parent above it on the same record
(deepest first, never resumed), and wakes the batch whose item it was.
A failed cancel never fails the delete.

Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-approvals, touching 7 documentable anchor(s).

2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/automation/approvals.mdx (via ApprovalService (symbol, a top-level class))
  • content/docs/automation/flows.mdx (via ApprovalService (symbol, a top-level class))

⛔ 2 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-6.mdx (via ApprovalService (symbol, a top-level class))
  • content/docs/releases/v18/18-1.mdx (via ApprovalService (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 73ec085afa2f9689ef96263a9c25b82cde6fda47 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 0aee8367a823928a74300e87a99330ba68e4d951 — the merge of head e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88 into base 73ec085afa2f9689ef96263a9c25b82cde6fda47, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 0aee8367a823928a74300e87a99330ba68e4d951 && git checkout 0aee8367a823928a74300e87a99330ba68e4d951
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 73ec085afa2f9689ef96263a9c25b82cde6fda47 e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88 && git checkout -B drift-repro 73ec085afa2f9689ef96263a9c25b82cde6fda47 && git merge --no-ff e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88

node scripts/docs-audit/affected-docs.mjs --json 73ec085afa2f9689ef96263a9c25b82cde6fda47

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 73ec085afa2f9689ef96263a9c25b82cde6fda47 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 28, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 948f4494b0081d76f16d59b7e3d7c07e3c2c71d2
Local-runs: none

Inputs read: card #37763 (body, triage 7207999396, ruling 7237973760, claim 7238037976); PR #38293 body, its 5 files and the net diff against main (merge base f19350b4); the check-runs on this head. Code outside the diff was read, not reviewed: engine cancelRun (run-resume.ts), the strand side channel in engine.ts, the delete hook in lifecycle-hooks.ts.

① Derived judgments

  • Behaviour against the ruling (option A): right. After every pending request of the deleted record is voided (unchanged), cancelRunsOfVoidedRequest calls the engine's existing cancelRun(id, reason) on the request's run. The end state is cancelled and the reason names the delete. No resume goes to the run, so neither approve nor reject runs. The new real-engine case pins history cancelled, the reason, no mark_ok/mark_no step and nothing parked.
  • Subflow chain (sub-question 1): right. The walk goes down from record_run_id through suspensionOf correlations (subflow:/map:), cancels deepest first and never resumes a subflow parent. The three-level case pins all three cancelled, resume never called and nothing after the subflow ran. Premise ③ holds as claimed: there is no diff in service-automation or packages/spec, and only existing members are used (suspensionOf, cancelRun, suspendedMapParentOf, resume).
  • Batch item (premise ②): right. batchAboveItem is read before the cancel, because cancelRun removes the linkage, and the batch is woken through the existing resumeBatchOfRecalledItem only when the chain's top was cancelled. The cause parameter changes only log and message wording (read in the head file). The chain is cut below its lowest map: link, so a batch is woken and never ended, which is the ruling read literally. Both batch cases (flat item, and an item whose sign-off is in a subflow) pin the cancelled marker outside count, the next item opening and the batch completing. The batch-wake answer is discarded, but a strand above the batch is still logged at error by the engine (read in engine.ts), so nothing goes untold.
  • The delete still lands when a cancel throws: allowed by the ruling. The ruling says a failed cancel "never fails the delete; it degrades to today's warning". On a throw the chain stops. That run and the runs above it stay parked, are logged at error, and are named in the summary warn and in suspendedRuns. The request is still cancelled, because runs are cancelled only after every request is voided. A partial chain (child cancelled, parent's cancel throws) leaves the parent parked and named, with no resume sent. That is the same parked-and-named state class as today, not one the ruling forbids. Nothing in the new path throws past the delete hook: the walk, the batch lookup and the batch wake each catch their errors, and the hook's own catch stays as before.
  • Fallbacks. An engine without suspensionOf, a walk that throws, or a walk that does not reach the request's run cancels the request's own run alone and warns. These are right and pinned (the "store unavailable" case asserts the warn and that the parent stays parked). The no-record_run_id fallback is not as described: see finding S1.
  • The rewritten "must not cancel" pin: right, and not weakened. record-delete-cancel.integration.test.ts now asserts one cancelRun('run_1', reason matching the delete), resume not called, and no left-behind warning. The old "reported" assertion moved into the new failed-cancel case, which also asserts that the delete lands and the request is cancelled. No other assertion in the file was touched (the only hunks are the spy's return value and these two cases). The run-status-liveness.test.ts change is comment-only.
  • Public-surface changes the diff implies. ApprovalService is exported from the package root, and its public method cancelForDeletedRecord changes its answer. It gains a member, cancelledRuns: string[]. suspendedRuns now holds only runs that could not be cancelled. No exported constant changes value: REQUEST_STATUS_STRANDABILITY changes only in comments. No event, spec schema or HTTP answer changes. RecordDeleteCancelSurface in lifecycle-hooks.ts still declares the old answer type, but it is not exported and the extra member is structurally compatible.
  • Nothing in the diff changes what a contract accepts or refuses.

② Semver level

  • Changeset level: right. @objectstack/plugin-approvals patch is the right level: it is a bug fix in a released package, with Metadata-protocol: none (no change to what a metadata author can write), and a non-protocol widening ships patch.
  • The Clause-②: line: wrong. Clause-②: no does not hold, and the right arm is Clause-②: yes (widening). Clause ② covers a change that widens the public surface. A new member in the answer of a public method on an exported class is that kind of change, and this package's own CHANGELOG declares the same shape yes (widening) (the optional ApprovalServiceOptions.positionLabelSource).
  • The suspendedRuns change is not a narrowing. On main the member's documented meaning is "the suspended run ids left behind", and it keeps that meaning. The set is smaller only because the behaviour now leaves fewer runs behind. Every run the old answer named is now in exactly one of cancelledRuns or suspendedRuns. No type narrows, no value is refused, and no in-repo caller reads the member: the delete hook ignores the answer. So neither (narrowing) arm applies, and no BREAKING banner or ADR-0087 disposition is owed. The changeset body already says what changed; only the declaration line is wrong.
  • M1 (must-fix). Change Clause-②: no to Clause-②: yes (widening) in both the changeset body and the PR body. The line is machine-read: it decides the release-notes section (新增能力 rather than 其他修复) and the owed-review face (check-owed-reviews.mjs). A widening declared no escapes the gate that owes this very review.

③ Boundary flags

  • The four decisions the dev listed:

    • The chain cut below map: is right (see ①).
    • The no-record_run_id / no-suspensionOf / unreachable-walk fallbacks are right in effect. They are a degradation the ruling's "degrades to today's warning" covers. The no-record_run_id case is told less than claimed: see S1.
    • Stopping at a throwing cancel is right (see ①).
    • Cancelling runs only after every request is voided is right.
  • S1 (should-fix): the no-record_run_id path is silent. voidedRunChain returns [runId] on !recordRunId before any warning. Three texts say this case "warns that a run above it may stay parked": the PR body, the cancelRunsOfVoidedRequest docblock and the test title "…says a parent may stay parked". The test asserts no log at all, so the claim is unpinned and false. Staying silent is a defensible choice, because a flat run on an engine that hands no record run is the ordinary shape and a warning there would be noise. If silence is intended, make the docblock, the PR body and the test title say so; otherwise warn and pin it. Either way, the text and the code must agree.

  • N1 (nit): a false from cancelRun is read as "not parked" and the walk keeps going up. The engine's false also covers an unreadable store: the run is still parked, and the engine logs that at error with a re-issue instruction. So the docblock's "no run is ever cancelled while a run it waits on is still parked" is not strictly true, and that run appears in neither cancelledRuns nor suspendedRuns. The outcome is no worse than today and the engine names the run, so this is a nit. Soften the docblock line, or put a false on the request's own run into left.

  • N2 (nit): a misleading log when no cancelRun exists. With no cancelRun on the engine, missingRunCapability logs "no automation engine to advance the recorded outcome". That wording is the decision door's ("recall the request to release the record") and misleads on the delete path. It is reached only when there is no automation service.

  • Docs are owed by the second PR. The skill and the approvals guide each get one sentence in the second PR (Tier H, Fixes #37763). This PR correctly says Refs #37763.

  • Sub-question 2 (runs parked by earlier deletes): honoured. Nothing cleans them up, and the changeset says how an administrator finds them (request cancelled, cancel_reason record_deleted, flow_run_id).

  • SQL push-down: no finding. The walk is keyed reads through the engine's suspended-run surface, one per hop, bounded at 32. Those are engine-store lookups behind an interface, not business-table reads or an in-app join that SQL could push down. The request read is unchanged: one find filtered in the query.

  • Check-runs without a conclusion at this read. Every run that has concluded is success or skipped. These had none:

    • in progress: Check Changeset; Flag docs affected by code changes; Lint · CI, release & engine gates; Lint · PM dispatch-gates; Lint · docs & code guards; Lint · scoped · query-options erasure; Lint · scoped · slot lookup & corpus; Live E2E UI; Plan Test Core shards; Type Check · consumer gates; Type Check · debt ledger.
    • queued: Auto Label; Build Core; Dogfood Regression Gate; Lint · ESLint; Lint · repo & tooling gates; Lint · scoped · tooling self-tests; Test UI; Type Check · source gates; Type Check · workspace.

    The combined commit status is pending. Their verdicts are not part of this record; the ACCEPT waits on them.

Implemented-by: claude/project-thread-sz9xxz
Reviewed-by: session_01L6bhgV6i8jfWwSXjpWJrjA (isolated contract-review sub-agent)

VERDICT: FAIL

Close-out: fix M1 (both declaration lines to Clause-②: yes (widening)) and S1 (text and code agree on the no-record_run_id case). N1 and N2 are optional. The behaviour itself matches the ruling and its premises.

…e no-record-run and no-cancelRun texts

Contract review 7238672789 on the #37763 services change:
- M1: `cancelForDeletedRecord` answers a new `cancelledRuns` member on the
  exported `ApprovalService`, so the changeset declares
  `Clause-②: yes (widening)`.
- S1: a request with no `record_run_id` cancels only its own run and logs
  nothing (a flat run on an engine that hands no record run); the
  docblock and the test title now say so, and the test pins no log.
- N1: the docblock no longer claims a run is never cancelled while the
  run it waits on is parked; a `false` from `cancelRun` goes on up.
- N2: with no `cancelRun` on the engine the delete path logs in its own
  words instead of the decision door's `missingRunCapability` line,
  pinned in the integration test.

Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD
Co-authored-by: Claude <noreply@anthropic.com>
os-sales pushed a commit that referenced this pull request Nov 28, 2026
…cancelled

From #38293 on, every request a delete voids carries
`cancel_reason: record_deleted`, including those whose run was cancelled
in the same step, so the guide says to cancel by hand only a run that is
still `suspended`. (Contract review 7238666618.)

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Contract review

Served-tier: TIER_DEFAULT
Head-sha: e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88
Local-runs: none

This is a delta review against the round-1 record 7238672789 (FAIL at 948f4494).

Inputs read:

Everything outside the delta stands as judged in round 1.

① Derived judgments

  • The code delta is limited to two edits:
    • No-cancelRun branch. cancelRunsOfVoidedRequest no longer calls missingRunCapability. With no cancelRun on the engine, it logs its own error ("…can cancel the run a record delete left with no decision to wait for — the run stays parked", meta { request, run }) and answers left: [runId]. The run still reaches suspendedRuns and the summary warn. A new integration case pins this: it removes cancelRun, and checks that the delete lands, the request is cancelled, exactly that one error line is logged, and the run is named in the warning.
    • Docblocks. cancelRunsOfVoidedRequest and voidedRunChain changed in their docblocks only.
  • Ruled behaviour unchanged. The no-record_run_id path is unchanged in code (returns [runId] silently), as the seat's S1 ruling directs.
  • Docblock and test now agree with the code:
    • The docblock now says that a request with no record_run_id cancels its own run alone and says nothing. A missing suspensionOf or an unreachable walk still warns.
    • The test title now reads "…cancels its own run alone, and says nothing", and the test now asserts runLogs() is empty, so the silence is pinned.
  • The false answer is described correctly. The deepest-first sentence now says a run is cancelled only after the run it waits on was cancelled, or after the engine answered false for that run (no suspension, or an unreadable store the engine logs itself). This matches the engine's cancelRun.
  • No public-surface change beyond round 1. The answer type of cancelForDeletedRecord is unchanged from 948f4494.
  • No new accept or refuse change.

② Semver level

  • Declaration lines. The changeset body and the PR body both now read Clause-②: yes (widening) / Metadata-protocol: none.
  • The PR body states the widening and the reason. It says cancelledRuns is a new member of a public method's answer on the exported ApprovalService, and that suspendedRuns keeps its meaning (the runs left behind). That agrees with round 1's reading.
  • The changeset text is accurate. Its closing sentence ("now lists only the runs that could not be cancelled") is consistent with that meaning.
  • Claim matches the PR. Claim amendment 7238689609 on the card records the same arm, so the claim and the PR agree.
  • Level stays patch. @objectstack/plugin-approvals stays patch, which is right for a non-protocol widening.

③ Boundary flags

M1: closed — Clause-②: yes (widening) in both the changeset and the PR body; the claim is amended to match.
S1: closed — by seat ruling the no-record_run_id path stays silent; the docblock, PR body and test title now say so, and a "no log" assertion pins it.
N1: closed — the docblock now says a false from cancelRun keeps the walk going up and that the engine names that run itself; the PR body says the same.
N2: closed — the delete path has its own error line when there is no cancelRun, and a new integration case pins it.

  • No new findings in the delta.

  • SQL push-down: no finding. The delta adds no reads.

  • Check-runs on this head with no conclusion at this read. The combined status is pending. Every check-run that concluded is success or skipped, except one superseded PR-body guards run that is cancelled; its rerun is success. These had no conclusion:

    • Build Core
    • Check Changeset (two runs)
    • Dogfood Regression Gate
    • Flag docs affected by code changes
    • Lint · CI, release & engine gates
    • Lint · ESLint
    • Lint · PM dispatch-gates
    • Lint · docs & code guards
    • Lint · repo & tooling gates
    • Lint · scoped · query-options erasure
    • Lint · scoped · slot lookup & corpus
    • Lint · scoped · tooling self-tests
    • Live E2E UI
    • Plan Test Core shards
    • Test UI
    • Type Check · consumer gates
    • Type Check · debt ledger
    • Type Check · source gates
    • Type Check · workspace

    Their verdicts are not part of this record; the ACCEPT waits on them.

Implemented-by: claude/project-thread-sz9xxz
Reviewed-by: session_01L6bhgV6i8jfWwSXjpWJrjA (isolated contract-review sub-agent)

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

席位核对 — ACCEPT · head e103c2e · card #37763 · area s2-ai · 2026-11-28T12:10Z

L1 checklist

  • Shape and checks. Every check on the head is green apart from expected skips (38 success, 18 skipped; one earlier PR-body guards run cancelled and superseded by a green rerun); mergeable clean. The PR is a draft. It changes packages/plugins/plugin-approvals/src/approval-service.ts (the record-delete path and a new private chain walk), rewrites the "must not cancel" pin, adds batch and subflow cases in record-delete-cancel.integration.test.ts and the two neighbouring test files, and one changeset. Dev report 7239036970.
  • Contract review at TIER_DEFAULT (declaration face). Round 1 (7238672789) was a FAIL on M1, the Clause-②: line. The delta record 7238779008 on this head closes M1, S1, N1 and N2 and is a PASS. The seat adopts the record.
  • What changes for an app. Per the maintainer's ruling A (7237973760): deleting a record whose approval request is in flight now also ends the flow run parked on it as cancelled, with the reason that the record was deleted, instead of leaving it paused forever. Inside a subflow the chain is cancelled from the deepest run up; a batch item's batch moves on through the existing wake path. If a cancel fails, those runs stay and are named in the log, and the delete still goes through. Runs parked before this lands are not cleaned up.
  • Declarations. Clause-②: yes (widening) (cancelForDeletedRecord's answer gains cancelledRuns; suspendedRuns keeps its meaning), amended on the claim (7238689609). Metadata-protocol: none, @objectstack/plugin-approvals patch. Refs #37763 is right: the skills and guide PR docs(approvals): a record delete cancels the parked flow run #38295 closes the card and merges after this one.

Tier: M. Landing: ready and auto-merge in this stroke.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 28, 2026 12:10
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit f28091a Nov 28, 2026
57 of 58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-sz9xxz branch November 28, 2026 12:59
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…tack-ai#38295)

<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu39QwNEMYYq9N1C1xLDGdAJ)_

Fixes objectstack-ai#37763

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:写流程的开发者(和帮他写的
AI)在审批技能和审批指南里读到:单据在等审批时被删掉,等它的流程运行会被取消,批准、驳回两条后续都不走;要在删除时做事,写在单据的删除钩子上。指南还写明子流程、批量的情形,以及管理员如何找到此前遗留的暂停运行并手动取消。
- 为什么做:维护者在这张卡上选了「自动取消」,代码改动在另一个 PR;技能和指南此前没说删除后流程会怎样。
- 出错会怎样:只改说明文字,不改行为;技能页仍在字数上限内,新增的话由同页压缩旧措辞抵付,没有删规则。可直接撤回。
- 要你做什么:这个 PR 碰 `skills/**`,属受治理路径,需你审批合并;请在代码 PR objectstack-ai#38293 合入后再合,免得文档先于行为。

## What changes

-
`skills/objectstack-automation/references/state-machines-and-approvals.md`,
Approval Best Practices item 2: deleting the pending record now also
cancels its parked run; neither `approve` nor `reject` runs, so a
delete-time action goes in the record's delete hook. The page is at its
token ceiling (headroom 0); the clause is paid for on the same page by
cutting restatements, no rule dropped:
  - "exactly **three roots** — nothing else" drops "nothing else";
- "guard genuinely-optional inputs explicitly" is "guard optional
inputs";
  - item 2's "the child object declares" is "the child declares";
- item 3's prohibition is one clause ("⛔ a `notify` node there tells
them twice");
- item 4 is compressed. Two rewordings there are worth a look: "a
`runAs: 'user'` flow fired by one has its data steps refused" now reads
"and refuse a `runAs: 'user'` flow's data steps" (the two transitions as
subject), and "runs with the decider's own grants" reads "with that
person's grants" (which also covers the submitter on submit).
- `content/docs/automation/approvals.mdx`, the paragraph on deleting a
pending record: two sentences. The flow run waiting on the request is
cancelled for the same reason, so neither branch runs; inside `subflow`
steps on the same record every run up the chain is cancelled; a batch
(`map`) item's batch goes on to its next item and records the deleted
one as cancelled. Runs left paused by earlier deletes are not cleaned
up: find them by the cancelled request whose `cancel_reason` is
`record_deleted`, which names its run in `flow_run_id`, and cancel that
run by hand if it is still `paused`: requests voided by a delete after
objectstack-ai#38293 carry the same reason, and their runs already show `cancelled`
(half-sentence added at `4d8dea85` per contract review 7238666618 ③;
`paused` per 7238784724 at `4fdcc1aa`).
- Changeset: `.changeset/37763-skills-delete-cancels-parked-run.md`,
`@objectstack/skills` patch (a `skills/**` change releases that
package).

## Why

Maintainer ruling on objectstack-ai#37763, option A (card comment 7237973760): a
record delete cancels the run parked on the approval it voids. The
behaviour lands in objectstack-ai#38293, which only refers to the card (this PR is the
one that closes it); the ruling's landing names one sentence in the
approvals skill (paid for on the same page) and one in the approvals
guide, which unlocks the card's second checkbox. The guide's addition is
two sentences: subflow, batch and the hand clean-up of earlier runs did
not fit one.

## Verification

- Token ratchet: `state-machines-and-approvals.md` 5927 before, 5927
after (ceiling 5927); bytes 23706 → 23706; lines 388 → 388; whole skills
bundle 303542 → 303542. Ceiling and baseline untouched.
- Wording checked against the shipped code in objectstack-ai#38293
(`cancelForDeletedRecord`, `cancelRunsOfVoidedRequest`): the run's
cancel reason is a sentence, not `record_deleted`, so the guide says
"for the same reason" and keeps `record_deleted` for the request's
`cancel_reason`.

<details><summary>Local runs</summary>

Head `4fdcc1aa` (base `main` `216524a2`); `4d8dea85` and `4fdcc1aa`
touch only `content/docs/automation/approvals.mdx`, the skill page and
its tokens are as at `8001d106`. Written by an isolated sub-agent served
at the contract-review tier for every turn (`verify-review-tier.mjs` on
its transcript: PASS).

- `node scripts/pm/dispatch-gates.mjs --commands` (derived before the
changeset commit): 62 families; 58 exit 0 (5 of them after building
`@objectstack/lint...` and `@objectstack/client-react...`, their
prerequisite), 4 NOT MEASURED, exit 3, needing a whole-repo build:
`check:dts-closure`, `check:dual-build-cjs-loads`,
`check:lean-entry-closure`, `check:sourcemap-no-sources-content` (they
read package dists; this diff touches none). `check:skill-docs`,
`check:skill-refs`, `check-skills-token-ratchet.mjs` and its
`--self-test` exit 0. The changeset-only families are left to CI.

</details>

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind. (none added)
- [x] 3. No formatter ran.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request. (branch `claude/project-thread-sz9xxz-skills`; the code half is
objectstack-ai#38293 on `claude/project-thread-sz9xxz`)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: no.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English (the 维护者速读 block is the
maintainer summary).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD

<!-- signed: repo:objectstack#2 · os-sales ·
session_01L6bhgUpmvWke9Z2P4VKvaD -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
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/l tests 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.

2 participants