refactor(maestro): shape the replay backend as a create(host) plugin

Merged
TH
2mo ago
+595-330

Summary

Second half of the #3377 replay-backend prep. Builds on #3622 (merged); based on main. Behavior, wire shapes, help text and error wording are unchanged; the backend still resolves once per process (ADR 0015).

  • The Maestro adapter moved from replay-port into packages/maestro/src/replay-backend/ and ships as ReplayBackendPlugin = { create(host) } (@agent-device/maestro/replay-backend), with an engine-free declaration (.../replay-backend-declaration).
  • ReplayBackendHost (built in replay-backend-host.ts) is the only way the adapter reaches process state or daemon policy: trace append, builtin vars, script-source read, target-device resolution, request signal, and the divergence-failure builder from #3622.
  • The registry loads the plugin through a function-scoped import and calls create(host) once. replay-backend-declarations.ts holds the declaration table, so the registry's eager closure (and every daemon route that loads it) does not grow. Both tables are mapped over ReplayBackendId, so a declaration or plugin under another backend's id fails to type-check.
  • help maestro reads its topic from the declaration, so cli-help no longer imports the engine.
  • Failure tests now drive the plugin through getReplayBackend('maestro'); two warnings checks became unit tests.
  • Dropped the unused ./daemon-runtime-port export.
  • Only the two replay-port files above name @agent-device/maestro in production (scripts/fuzz still does).

32 files touched. Sign-off needed: the APPROVED_OVER_CEILING row for replay-maestro-backend.ts names thymikee as owner, so it needs his approval.

Refs #3377.

Validation

Tested SHA: 36d06fa8dc (pnpm check:affected --run).

  • pnpm check:affected --base <layer-1 branch> --run: all runnable checks passed.
  • pnpm check:quick and focused vitest (replay-port, maestro, daemon sessions, CLI help/MCP, startup closure, closure budgets) passed.
  • Diff against the layer-1 branch: +607/โˆ’314. A -M90% stat shows more because several moved files are 80โ€“91% similar after the host rewrite.
  • Coverage, provider integration and maestro-differential are CI-authoritative.

๐Ÿค– Generated with Claude Code