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

Relationships

#4613 Lazy loading L3: load only the invoked subcommand in data and workflow

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

Next step of the routing track in the lazy command loading plan. It depends on the route table (#4592) and uses the benchmark and parity scripts from #4590.

Why

After #4592, swamp data get loads only the data group, but still loads all nine data subcommands, and workflow run still loads all 20 workflow subcommands. Measured on a prototype under deno run, data get costs 286 ms with the whole group against 184 ms with only its own subcommand. This PR introduces the group pattern on the two most used groups. behavior / model and the other groups follow with the same pattern.

The same rule as #4592 applies: a module loaded through import() misses Deno's code cache. So a subcommand loads dynamically only when routing has chosen it, and the paths that load the whole group stay few.

Scope

  • A group is a header factory (createDataCommand(rest), createWorkflowCommand(rest)) plus a route table of its subcommands, with the same name, aliases, module and load fields as the root table, and the same selectRoute. Each row has a literal import(), so deno compile embeds it.

  • The header factory keeps the group's description, options and actions, and registers only the routed subcommand. An unknown or missing subcommand word loads them all, so the group's help and the unknown-subcommand suggestion list see what they see today.

  • Subcommand files don't change. Routing is one level deep: a third-level word (workflow history search) is left to the subcommand it belongs to, which loads its own children as it does today.

  • Subcommand aliases go in the table. workflow search is also workflow list; without that alias in the table, workflow list would load the whole group.

  • Root routes for data and workflow pass rest through. help data get then loads one subcommand as well.

  • dataCommand and workflowCommand stop being module-level instances. Update their users to call the factories:

    • src/cli/mod.ts;
    • integration/usecase_sync_fixtures.ts;
    • the data_*_test.ts and workflow_*_test.ts files under src/cli/commands/ that import them, and data_test.ts.

    (workflowCommand in main.ts and error_output.ts is an unrelated boolean flag; leave it.)

  • Extend the route rules from #4592 to groups:

    • each group's table equals its fully loaded children (names, aliases, hidden, order);
    • every subcommand alias appears in the table (otherwise routing silently loads the whole group);
    • schema parity and the per-route Worker test cover each subcommand path;
    • the composition-root guard names the group tables, for static and dynamic imports alike.

Not in scope

behavior / model (they share subcommands through behavior_twin.ts and get their own issue) and the remaining groups.

Acceptance

  • The parity script passes against the base binary, including data --help, workflow --help, help data, help workflow and a mistyped subcommand in each group.
  • The benchmark shows data get at about 184 ms and no workflow run regression, both quoted before and after from builds taken in the same session.
  • affectedCommands produced by the attestation generator is unchanged on a sample of changes, compared with the base commit: a group factory still links its subcommands through their literal import().

Release impact

data.ts and workflow.ts sit only in their own group's closure, so the attestation selects data and workflow. Group modules now import command_routes.ts, so later edits to it select every routed group plus the startup flag; that is correct, since they all depend on it.

Risk

Low; it uses the same mechanism as #4592, one level down.

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

Shipped

11/10/2026, 10:48:55 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
zack assigned zack11/10/2026, 9:47:30 PM

Sign in to post a ripple.