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

Relationships

#4838 Load serve's subcommands lazily through a serve route table

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

Prerequisite for swamp-club#4835 (swamp serve host).

Problem

serve loads all its subcommands eagerly. src/cli/commands/serve.ts is about 11k lines and defines the serve action and its reload, check-config and daemon subcommands (reloadCommand, checkConfigCommand, daemonCommand) in that one module. It statically imports the vault and datastore type registries and everything a running serve needs. Any swamp serve <subcommand> loads all of it.

data, workflow, model, extension, vault, datastore and access load their subcommands lazily through a *_routes.ts table read by loadGroupRoutes in src/cli/command_routes.ts. serve has no such table.

This blocks swamp-club#4835. swamp serve host must load no extensions, no datastore and none of the model, vault or datastore registries. Hung off serveCommand as things are now, it would load all of serve.ts just to start.

Change

  • Add src/cli/commands/serve_routes.ts with a CommandRoute row for each serve subcommand.
  • Move reload, check-config and daemon into their own modules so each row's load imports only that subcommand.
  • Build the serve group from the table through loadGroupRoutes, as access does. swamp serve with no subcommand still runs the server, so the group keeps its own action and options. Only the subcommands become lazy.
  • Add serve to the list of lazily routed groups in AGENTS.md.

There is no change to the CLI surface: the flags, help text and json output stay the same.

Done when

  • integration/command_routes_rules_test.ts covers serve: each row's module is the file its load imports, the full tree's serve children equal the table, and a subcommand path loads only that subcommand.
  • A route for a serve subcommand whose module does not import serve.ts loads without serve.ts, so swamp serve host can be added as one more row in swamp-club#4835.
  • Existing serve tests (serve_test.ts, serve_daemon_test.ts) pass unchanged.
02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MORETRIAGE+ 2 MOREREVIEW+ 6 MOREPR_LINKED+ 2 MORESESSION_SUMMARIZED

Shipped

11/17/2026, 4:06:26 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
zack assigned zack11/17/2026, 3:24:50 PM

Sign in to post a ripple.