Skip to content

✨ feat(plan): Node.catch — failure arms as static topology - #188

Merged
roninjin10 merged 8 commits into
mainfrom
node-catch
Aug 13, 2026
Merged

✨ feat(plan): Node.catch — failure arms as static topology#188
roninjin10 merged 8 commits into
mainfrom
node-catch

Conversation

@roninjin10

Copy link
Copy Markdown
Contributor

Summary

Node.catch — the one primitive the coverage table called genuinely missing: failure handling as visible topology. Was an open question in the vault; per the maintainer's directive, decided and implemented.

Decisions taken (review these)

  1. No filter = the full typed error channel; a schema filter catches only matching errors — mirrors effect's catch/catchTag split.
  2. Defects and compensation failures are never intercepted — rollback guarantees and invariant failures stay outside ordinary recovery.
  3. Filter schemas digest into the serializable AST, live schemas in side tables — detached filtered catches propagate safely.
  4. Failure topology is an explicit failure edge reason, not a new plan node kind — "on failure →" renders without widening PlanNode.kind or its SQL CHECK.
  5. The caught error settles the protected node's planned reference — failure arms consume the error value without re-executing failed work.

Depends-on: #187

Verification

  • Whole-repo npm run check clean; lint clean (plan, flow); conformance green
  • Full suites at 100% coverage: plan 6/85 · flow 18/188 · flows 2/149; coverage: construction, symbolic error binding, filter identity, matching/unmatched/nested recovery, pass-through skip, detached filter safety, compiled-plan topology

…Error

The authoring half of the plan: seven closure-free node variants (Succeed,
All, Map, AndThen, FlowCall, ActivityCall, Branch) with digested deferred
functions in out-of-band tables, the Planned<T> branded placeholder whose
proxy throws GraphBuildError on any computation (toPrimitive, valueOf,
toString, toJSON, application), and the GraphBuildError vocabulary.

Docs: docs/specs/Concepts/Unified Flow Authoring.md
(cherry picked from commit 64624ac)
Activity.make gains a string-first overload: a named, schema-typed atom
(payload/success/error/tier/idempotencyKey) whose implementation attaches
separately via .toLayer(execute) through the existing registration and
activity machinery, and whose .call(payload) records an ActivityCall node
for plans. The inline options form is unchanged.

Docs: docs/specs/Concepts/Unified Flow Authoring.md
(cherry picked from commit b883814)
…otations

Flow.make accepts an optional plan-time body (required once the migration
completes), Flow.prototype.call records a FlowCall node, the trampoline
outcome vocabulary lands as pure data (Flow.done / flow.to / Flow.park over
the existing Waiting reasons), and Capabilities / EffectsDeclaration /
Placement join the annotation keys.

Docs: docs/specs/Concepts/Unified Flow Authoring.md
Docs: docs/specs/Concepts/Trampoline Loops.md
(cherry picked from commit ad7df62)
@roninjin10

Copy link
Copy Markdown
Contributor Author

Review round 1 complete (sol + fable, independent). Findings for this PR were fixed and folded into its commit; the full ledger (15 fixes, 6 resolved-as-designed) lives in the stack's review notes. All 14 branches rebased and re-verified: whole-repo check green, all package suites at 100% coverage, rebuilt tip byte-identical to the verified fix tree.

Evaluates a body against its real payload with strict Planned placeholders
for step results, expands branch arms as static topology, splices inline
flow calls with capability intersection, rejects recursive calls with
recursion_requires_boundary, reads effects/capabilities/placement from the
authoring annotations, and emits NodeDrafts that Plan.compile keys directly.

Docs: docs/specs/Concepts/Unified Flow Authoring.md
(cherry picked from commit f8bf150)
Interpreter.layer(flow) registers a generic handler over the FlowRuntime
port: Graph.build against the real payload, dependency-order driving of the
compiled drafts, activity calls through the existing persistence machinery
with declared implementations resolved from an Implementations table, branch
predicates on real values running only the taken arm, Ref-path projection
threading, and journaled replay on execution-id reuse. Bodied flows reject
toLayer; behavior comes from exactly one place.

Docs: docs/specs/Concepts/Unified Flow Authoring.md
(cherry picked from commit 42ee5ce)
(cherry picked from commit 72f9b1e)
A bodied flow's root value settles as Complete (done), Suspended (park,
existing Waiting vocabulary), or the new encoded Handoff (to): the engine
plans the target and runs it as the next round. Rounds chain under one
lineage via parent_run_id with deterministic (lineage, ordinal) execution
ids, the settle-and-create seam is one storage transaction, maxRounds is
declared on the origin flow and enforced at the handoff with a typed
terminal failure, and the root caller's polling follows handoff chains
transparently to the final value.

Docs: docs/specs/Concepts/Trampoline Loops.md
(cherry picked from commit acafd2e)
(cherry picked from commit e1f2cc8)
flow.child(payload) records a non-expanded boundary node whose material
carries the child's tag, payload, and declared envelope. The interpreter
runs it as a genuine child execution with a deterministic id derived from
the parent execution and node address, parent edges and suspension
propagate through the existing machinery, and placement conflicts on
inline .call() now error with placement_requires_boundary directing to
.child().

Docs: docs/specs/Concepts/Unified Flow Authoring.md
(cherry picked from commit f09bc16)
(cherry picked from commit b4ec945)
The branch move applied to the error channel: Node.catch protects a
subgraph with a failure arm that is plan-visible via an explicit failure
edge reason, filters errors by digested schema (missing filter = the full
typed error channel), never intercepts defects or compensation failures,
and settles the protected node's planned reference with the caught error
so failure-arm payloads consume it without re-running failed work.

Docs: docs/specs/Concepts/Unified Flow Authoring.md
(cherry picked from commit 47ffb00)
(cherry picked from commit 37d8dc2)
@roninjin10

Copy link
Copy Markdown
Contributor Author

Swap pass complete — review loop closed. Both seats have now reviewed every PR. Swap findings (6: nested-catch subject scoping, foreign-flow wait tokens, two __proto__ cloner recurrences, drafts-field refusal, re-drive test + lineage-id doc) fixed and folded into owning PRs; tail rebuilt tree-identical; whole-repo check + all suites green at 100% coverage.

@roninjin10
roninjin10 changed the base branch from flow-child-boundary to main August 13, 2026 01:13
@roninjin10
roninjin10 merged commit 35f7a89 into main Aug 13, 2026
0 of 2 checks passed
@roninjin10
roninjin10 deleted the node-catch branch August 13, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant