claude-print/tests
jedarden 7d40c937fb feat(bf-2f5): add comprehensive watchdog timeout mechanism
Implement a complete watchdog timeout system that ensures hung child
processes are terminated cleanly with proper diagnostics and cleanup.

Features:
- PTY first-output timeout (default 90s): detects if child produces no PTY output
- Stream-json first-output timeout (default 90s): detects if child produces no stream-json events
- Overall session timeout (default 3600s): prevents indefinite hangs
- Stop hook watchdog timeout (default 120s): detects if Stop hook doesn't fire after prompt injection

Timeout handling:
- Sends SIGTERM to child process when timeout fires
- kill_child() ensures SIGTERM → SIGKILL sequence (2s grace period)
- Writes clear diagnostic to stderr indicating timeout type
- Emits stream-json error event for downstream consumers
- CleanupGuard ensures temp dir/FIFO cleanup on all exit paths
- Returns Error::Timeout and exits non-zero (code 3) for retry loop

Fixes:
- Pass temp_dir_path to Watchdog so stream-json monitoring works correctly
- Remove unused constants (duplicates of watchdog module defaults)
- Improve mock-claude binary path resolution for workspace builds

This prevents the indefinite hang that occurs when Claude Code wedges
during session initialization or tool use, ensuring marathon loops and
NEEDLE can retry cleanly instead of blocking forever.

Bead-Id: bf-2f5
2026-06-25 07:42:17 -04:00
..
fixtures Add Phase 9: NEEDLE integration — install.sh, claude-print.yaml, --check subcommand 2026-06-10 01:36:28 -04:00
integration Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
cli.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
emitter.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
hooks.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
integration.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
pty_integration.rs Implement Phase 6: Stop Poller (bf-64s) 2026-06-10 00:05:14 -04:00
startup.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
stop_poller.rs Implement Phase 6: Stop Poller (bf-64s) 2026-06-10 00:05:14 -04:00
terminal.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
transcript.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
version_compat.rs Add bf-5nr validation notes: claude-print-ci WorkflowTemplate YAML is valid 2026-06-10 02:11:37 -04:00
watchdog.rs feat(bf-2f5): add comprehensive watchdog timeout mechanism 2026-06-25 07:42:17 -04:00