Skip to content

Pipeline Design 191

Seth Ford edited this page Mar 1, 2026 · 1 revision

ADR written to .claude/plan.md. Here's a summary:

Design: Self-healing smoke test for daemon worktree creation

Decision: Extract the real setup_dirs() from sw-daemon.sh at test time via sed + eval, run it in an isolated subshell with controlled env vars ($HOME, $DAEMON_DIR, cwd), and assert two behaviors:

  1. .claude/worktrees/ directory gets created when absent
  2. .gitignore gains the entry when missing

Key choices:

  • Real function extraction (not copy-paste) — catches actual regressions
  • Subshell isolation — no side effects on test env or real filesystem
  • Single test function — both assertions exercise one function call
  • Inline assertions — more readable than generic helpers for 2 checks

Alternatives rejected:

  1. Source full daemon script — setup_dirs() runs at parse time, creates real dirs
  2. Copy-paste function into test — goes stale silently, defeats the purpose
  3. New test file — one function doesn't justify ~100 lines of boilerplate + package.json registration

Risk areas: sed extraction pattern fragility (mitigated by loud failure on empty extraction), eval safety (mitigated by $TEMP_DIR sandbox)

Single file change: scripts/sw-daemon-test.sh — add function + register in tests=() array.

Clone this wiki locally