Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneeszack

Relationships

#4911 workflow validate and run re-walk models/ once per distinct behavior name in nested workflows (follow-up to #4903)

Opened by zack · 11/19/2026· Shipped 11/19/2026

Summary

swamp workflow validate and swamp workflow run still walk models/ once per distinct behavior name for steps inside nested workflows (type: workflow steps). The fix for swamp-club#4903 / swamp-club#4902 primes name hints for the top-level workflow's literal step behaviors only, so the nested part stays O(nested step names x definition files).

Where

  • The reserved-tag check (reservedWorkflowTags -> collect in src/domain/workflows/reserved_workflow_tags.ts) follows literal type: workflow steps into child workflows and looks up each child step's behavior with findDefinitionByIdOrName -> findByNameGlobal.
  • The prime (primeStepLookups in src/domain/workflows/execution_service.ts and in createWorkflowValidateDeps, src/libswamp/workflows/validate.ts) uses stepBehaviorNames([workflow]), which does not follow workflow steps. Every nested name is therefore unhinted and costs a full walk until it matches.

Measurements

In-process diagnostic tally (primary_walks / files_read), with 600 definitions and 20 steps per workflow. "parent" calls a 20-step child; "deep" calls two children, one of which calls a grandchild (60 nested names).

Scenario before #4903 current main of the fix with nested priming
validate flat 20 / 6,051 1 / 632 1 / 632
validate parent 20 / 6,011 20 / 6,011 1 / 592
validate deep 60 / 18,093 60 / 18,093 1 / 634
run parent 60 / 18,653 21 / 7,243 2 / 1,824
run deep 200 / 62,170 83 / 27,823 4 / 4,353

CLI wall clock (3,000 definitions, a parent calling a 30-step child, best of 2): workflow validate parent 1.31s -> 0.54s, workflow run parent 2.07s -> 1.18s.

Proposed fix (prototyped, not merged)

  • Add reachableStepBehaviorNames(workflows, findWorkflow) to src/domain/workflows/step_targets.ts. It returns stepBehaviorNames of the workflows plus every workflow reached through literal type: workflow steps. It follows them as the reserved-tag check does: it skips names given by expression and children that cannot be found or read, and visits each workflow once so a cycle ends.
  • Prime with it in both primeStepLookups (run/resume) and createWorkflowValidateDeps (validate). Resolve children with the same lookups those paths already use: lookupWorkflow, or findByName ?? findById.
  • The validate-path prime must ignore errors, as the run path already does. A nested step's name is otherwise looked up only by the reserved-tag check, which ignores read errors. Without the catch, a child step naming a missing behavior plus an unreadable definition file sorted after every match turns a report into "Failed to read definition file". For top-level names the catch changes nothing, because the validator's own lookup walks to the same file and raises the same error.

The prototype passed deno check and deno lint, and 955 related tests passed with 0 failures. An e2e comparison against the current code (child by name and by id, missing child, a cycle, a child step naming a missing behavior, unreadable files and directories) gave identical output apart from parallel step order and one stack trace.

Tests to add

  • A unit test for reachableStepBehaviorNames: nesting, a cycle, a missing child, and a child named by expression.
  • A nested case in integration/definition_name_lookup_reads_test.ts asserting that workflow validate of a parent costs 1 primary walk.
  • Validate a parent whose child names a missing behavior while an unreadable definition sorts last: the report is still produced.

Known remaining cost

A run still costs one walk per workflow, because each child run builds its own WorkflowExecutionService and definition repository. That is linear in workflows rather than in names.

02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 8 MOREPR_LINKED+ 2 MORESESSION_SUMMARIZED

Shipped

11/19/2026, 7:47:46 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
zack assigned zack11/19/2026, 6:35:43 PM

Sign in to post a ripple.