Repository navigation
fix(example-todo): move both loop bodies into config.body so currentTask binds and the escalation notice is sent - #19262
Merged
Conversation
…ntTask` binds Claude-Session: https://claude.ai/code/session_01AhQASwqJr2Z7XfGWUdvnbF Co-authored-by: Claude <noreply@anthropic.com>
… pre-fix control Claude-Session: https://claude.ai/code/session_01AhQASwqJr2Z7XfGWUdvnbF Co-authored-by: Claude <noreply@anthropic.com>
huangyiirene
marked this pull request as ready for review
September 20, 2026 08:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19206
Clause-②: noWhat was wrong
Both
loopnodes inexamples/app-todo/src/flows/task.flow.tsdeclaredcollection+iteratorVariableand noconfig.body. That is the legacy flat-graph form:packages/services/service-automation/src/builtin/loop-node.tsopens withif (raw.body == null), sets$loopItems/$loopIndexand returns without bindingiteratorVariable. The per-item steps were wired as ordinary nodes after the container, so every{currentTask.…}token in them resolved to nothing.Measured on a real engine in this PR's control test (
CONTROL: the pre-fix body-less shape still dies at update_priority):notify_ownersits one node behind that refusal, so no escalation notice was sent at all — and the control asserts that too (emitshas length 0).task_reminderhad the identical shape.The repair — established from the schema and the engine
The authority is
LoopConfigSchema/FlowRegionSchemainpackages/spec/src/automation/control-flow.zod.ts(ADR-0031 representation (B), nested sub-structure) plus the executor's structured branch:config.bodyis aFlowRegionSchema:{ nodes: min 1, edges: default [] }, single-entry / single-exit / acyclic (analyzeRegion), rejected atregisterFlow()viavalidateControlFlowwhen it is not.iteratorVariablein the enclosing scope per item and runs the region throughengine.runRegion; the loop node's ordinary out-edge is the after-loop continuation, which is whye3now goesloop → end.Each body carries one
try_catch(flow-loop-body-uncontained, the shape the lint rule's own hint prescribes, and the formexamples/app-showcasealready demonstrates), with the minimal handler — one bareassignmentnode. Onoverdue_escalationonetry_catchwraps both per-item steps rather than one each: the notice announces the escalation the update performs, so a row whose update was refused must not be told its priority was raised.maxIterations: 200states, on the iterating side, the same bound theget_recordstep'slimit: 200already imposes.What the notice actually renders — the reading this card unblocks
With the loop body executing, the escalation notice is sent, and (composed with the
days_overdueformula that landed in #19205 / #18584) it interpolates. Read off the capturedmessaging.emit()payload in a real run:Three seeded rows render three distinct notices with their own owner, subject, due date and day count — no leaked binding, no blank hole.
Tests
examples/app-todo/test/loop-body-iteration.test.ts— drives the real flows on a realAutomationEngineover a real sqlite-wasm database holding the app's realtodo_task. The only double is themessagingservice, and it is a capture, not a simulation: capturingemit()is how the rendered title/body becomes readable at all.priorityisurgent(so the body's first node matched the right row), exactly one notice, and its rendered body carries the real day count and no unresolved brace.try_catchand the sweep still reaches the rows after it.update_priorityand notifies nobody.test/overdue-escalation-days-overdue.test.ts(the #18584 pin) keeps pinning: itsnode()helper now walks the ADR-0031 region slots, because the nodes it inspects moved into the loop body. The question it asks is about those nodes' config, which nesting does not change.Evidence
pnpm --filter @objectstack/example-todo exec vitest run— exit 0, 7 files / 238 tests passed.pnpm --filter @objectstack/example-todo typecheck— the package's own script istsc --noEmit(read from itspackage.json, one leg) — exit 0.pnpm --filter '@objectstack/example-todo^...' build— exit 0.node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --commands: 37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN (--ranreconciliation with exit codes recorded before any pipe).check:dual-build-cjs-loadsfirst answered exit 3 = PREREQUISITE NOT MET = not measured; after the missingdist/was present it was re-run and answered exit 0.pnpm lint(repo-wideeslint . --no-inline-config, the whole population, not a narrowed run) — exit 0 atc6ca194c2.Changeset
skip-changeset:examples/app-todo/package.jsondeclares"private": trueand the diff touches nothing else, so this publishes nothing from any released package.Scope
examples/app-todo/only. No engine change was needed — and none was made: the container the schema already declares is what binds the iterator.packages/spec/**andcontent/docs/releases/**are untouched.Acceptance notes
noted, not filed:the two scheduled sweeps read date macros ({tomorrow},{3_days_ago}) thatinterpolateFilterdeliberately passes through verbatim for the data layer to resolve. Working as designed here; recorded only because the same brace syntax means something different one line away in the same config. Not a defect, not filed.Generated by Claude Code