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 samename,aliases,moduleandloadfields as the root table, and the sameselectRoute. Each row has a literalimport(), sodeno compileembeds 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 searchis alsoworkflow list; without that alias in the table,workflow listwould load the whole group.Root routes for
dataandworkflowpassrestthrough.help data getthen loads one subcommand as well.dataCommandandworkflowCommandstop being module-level instances. Update their users to call the factories:src/cli/mod.ts;integration/usecase_sync_fixtures.ts;- the
data_*_test.tsandworkflow_*_test.tsfiles undersrc/cli/commands/that import them, anddata_test.ts.
(
workflowCommandinmain.tsanderror_output.tsis 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
Workertest 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 workflowand a mistyped subcommand in each group. - The benchmark shows
data getat about 184 ms and noworkflow runregression, both quoted before and after from builds taken in the same session. affectedCommandsproduced 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 literalimport().
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.
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.