Commit Graph

1 Commits

Author SHA1 Message Date
Lukas May
0ed657b644 feat: Add VCR-style cassette testing system for agent subprocess pipeline
Implements cassette recording/replay to test the full agent execution
pipeline (ProcessManager → FileTailer → OutputHandler → SignalManager)
without real AI API calls.

Key components:
- `CassetteProcessManager`: extends ProcessManager, intercepts spawnDetached
  to replay cassettes or record real runs on completion
- `replay-worker.mjs`: standalone node script that replays JSONL + signal.json
  as a subprocess, exercising the complete file-based output pipeline
- `CassetteStore`: reads/writes cassette JSON files keyed by SHA256 hash
- `normalizer.ts`: strips dynamic content (UUIDs, temp paths, timestamps,
  session numbers) from prompts for stable cassette keys
- `key.ts`: hashes normalized prompt + provider args + worktree file content
  (worktree hash detects content drift for execute-mode agents)
- `createCassetteHarness()`: wraps RealProviderHarness with cassette support,
  same interface so existing real-provider tests work unchanged

Mode control via env vars:
  (default)                  → replay: cassette must exist (safe for CI)
  CW_CASSETTE_RECORD=1       → auto: replay if exists, record if missing
  CW_CASSETTE_FORCE_RECORD=1 → record: always run real agent, overwrite cassette

MultiProviderAgentManager gains an optional `processManagerOverride` constructor
parameter for clean dependency injection without changing existing callers.

Cassette files live in src/test/cassettes/ and are intended to be committed
to git so CI runs without API access.
2026-03-02 12:17:52 +09:00