Skip to content

feat(318): a fork is stored where it is decided — routes on the source task - #131

Merged
munchist merged 4 commits into
mainfrom
feat/routes-on-the-source-task
Oct 17, 2026
Merged

munchist merged 4 commits into
mainfrom
feat/routes-on-the-source-task

Conversation

@aflow-pr-agent

Copy link
Copy Markdown
Contributor

Plan 318 — a fork is stored on the task that decides it. Spec: docs/plans/318-a-fork-is-stored-where-it-is-decided.md.

What changes

  • Routes in the model. Any workflow task may carry routes: [{ when, enable }], where when compares the task's own output (output.<path> <op> <literal>, single or anyOf/allOf). The guards and dependencies of enabled tasks are derived at materialization — the only form ever executed — and never stored. deriveRouteGuards lives in @aflow/schemas so materialization and the designer share one derivation.
  • Routes are checked as a whole. Unknown or self targets, a target enabled by two sources, a routed target with its own when, a combination with no single-level guard, and a condition that is not a comparison on the source's output are each refused with a diagnostic naming the route. Operation-specific checks come from a small registry keyed by operation id; ai.decision.decide contributes unknown question / option and out-of-range score threshold.
  • Compose-skill lowers a decision to routes. The draft decision task becomes an ai.decision.decide operation task carrying its routes; its targets only depend on it. Agent, operation and human draft tasks accept routes, and the assembler carries them.
  • A route is edited as a route. Any patch under /tasks/{i}/routes stages update_task_routes with the complete new list, so adding a branch is one task plus one route. Ratification re-validates, so removing a task a route still enables is refused naming that route. The proposal card shows routes added and removed as when … → enable …. The op is authoring-only; the Coach union is unchanged.
  • The designer draws the fork. Edges come from the derived guards, so each route is a labelled conditional edge from its source, while nodes keep the stored task; the inspector shows a source's routes and a routed task's "Enabled by".

Existing skills with authored guards keep them and keep running (D6).

Verification

  • yarn build, yarn typecheck, yarn lint, yarn format:check clean.
  • yarn test:changed: 3546 passed. New suites: routes.test.ts (derivation, branch selection, every refusal), routeProposals.test.ts, workflowPatchRoutes.test.ts, route cases in skill-graph.test.ts, updated decision lowering tests.
  • Not yet run live: compose-skill on the Plan 316 triage request, and Helmsman adding a refund branch as one proposal (the P2/P3 exits).

🤖 Generated with Claude Code

munchist and others added 4 commits October 17, 2026 19:50
…ization

A task may declare routes: when its own output matches (output.<path> <op>
<literal>, single or combined), the tasks it names run. materializeSkillTasks
— the form every run and every validity check uses — gives each routed task
the guard its routes imply and the source as a dependency, so a fork is
stored once, on the task that decides it.

Routes are validated as stored: a route to a missing task or to itself, a
task enabled by two sources or carrying its own when, routes that combine
into no single-level guard, and a condition that is not a comparison on the
source's output. Paths are checked against the source's output through the
existing when-path check on the derived guards. A decision step's routes are
checked against its questions through a per-operation registry, so the
workflow model holds no decision-specific concept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…step

The decision draft task becomes an ai.decision.decide operation task carrying
routes over its own output; its targets only depend on it, and their guards
are derived at materialization. Draft agent, operation and human tasks accept
routes, and the assembler carries them onto the workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A patch under /tasks/{i}/routes stages update_task_routes with the complete
new list, so adding a branch is one task and one route. Ratification applies
it and re-validates the graph, so removing a task a route still enables is
refused naming that route. The proposal card shows routes added and removed
as "when … → enable …". The op is authoring-only: a Coach keeps replace_task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guard derivation moves to @aflow/schemas so materialization and the
designer share it. The designer draws edges from derived guards, so each
route is a labelled conditional edge from its source, while the node keeps
the stored task the inspector edits; the inspector shows a source's routes
and a routed task's "Enabled by". Route error kinds move to their own module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aflow-pr-agent
aflow-pr-agent Bot requested a review from munchist October 17, 2026 17:56
@munchist
munchist merged commit 6910abc into main Oct 17, 2026
3 checks passed
@munchist
munchist deleted the feat/routes-on-the-source-task branch October 17, 2026 19:41
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