Commit graph

168 commits

Author SHA1 Message Date
jedarden
53d5e1ea4e docs(bf-5gz3): verify Rust toolchain installation 2026-07-02 17:02:29 -04:00
jedarden
ec7bf4d1ae docs(bf-4q2): verify plan.md is already up to date with v0.2.0
Verified all acceptance criteria:
- Status table: v0.2.0 complete, E2E tests tracked as bf-46x
- Module Layout: all src/ and tests/ files documented
- Watchdog component: section 10 exists with timeout types table
- CLI flags: --first-output-timeout, --stream-json-timeout, --stop-hook-timeout documented
- Emitter section: stream-json replay implementation noted, live tailing tracked as bf-5vm
- Phase 1 --version text: already version-agnostic

No plan.md updates required — all facts already correct.
2026-07-02 15:54:07 -04:00
jedarden
3f79378e87 docs(bf-1ae5): document local claude-print binary build 2026-07-02 15:48:26 -04:00
jedarden
151b3ae38e docs(plan): make version examples generic
Update CI/CD section to use vX.Y.Z placeholder instead of specific
version v0.1.0 in tag examples, making documentation version-agnostic.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 15:20:49 -04:00
jedarden
03c967dd86 docs(bf-1irl): document test environment verification
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 15:07:29 -04:00
jedarden
1d0799531c chore(bf-3k2): remove repo cruft
- Remove notes/bf-1ae5.md (per-bead scratch file, not in Module Layout)
- Add .gitignore to exclude:
  - target/ (Rust build artifacts)
  - .beads/beads.db.backup.* (database backups)
  - .needle-predispatch-sha (NEEDLE worker artifact)

Root now contains only files specified in plan Module Layout:
AGENTS.md, build.rs, CI YAMLs, docs/, scripts/, src/, tests/,
Cargo.toml/lock, claude-print.yaml, install.sh, README.md
2026-07-02 14:59:36 -04:00
jedarden
076056b239 docs(bf-1ae5): document local build of claude-print binary
- Successfully built claude-print 0.2.0 using cargo build --release
- Binary created at /home/coding/target/release/claude-print (1014K, stripped)
- Build completed with only minor unused import warnings
- Verified binary runs correctly and reports correct version

Bead-Id: bf-1ae5
2026-07-02 14:55:34 -04:00
jedarden
ce0a13bb81 docs(bf-4q2): update plan.md - stale Status table, module layout, and undocumented watchdog/flags
- Update Status table: main() session orchestration COMPLETE (shipped as v0.2.0), E2E tests now reference bead bf-46x
- Add missing files to Module Layout: src/check.rs, lib.rs, poller.rs, session.rs, watchdog.rs; tests/hooks.rs, stop_poller.rs, pty_integration.rs, integration.rs, watchdog.rs; build.rs; scripts/ directory; CI YAMLs
- Document watchdog component (section 10): no-output/max-turn/stop-hook timeout monitoring with TimeoutType enum and WatchdogConfig
- Add watchdog CLI flags to table: --first-output-timeout, --stream-json-timeout, --stop-hook-timeout
- Update stream-json description: note current implementation is post-session replay, live tailing tracked as bead bf-5vm
- Make Phase 1 --version text version-agnostic
- Renumber Install Script section from 11 to 12
2026-07-02 14:42:48 -04:00
jedarden
7a8945ae00 feat(bf-1n6): add scripts/check-billing.sh for AS-4 billing conformance
- Implement check-billing.sh script that verifies the most recent
  transcript has entrypoint 'cli' (subscription pool) not 'sdk-cli'
- Script finds newest *.jsonl under ~/.claude/projects/ and scans
  for entrypoint field, exiting 0 iff it equals 'cli'
- Handle no-transcripts and no-directory cases with distinct errors
- Update README with Troubleshooting and Release checklist sections
  referencing the script as the pre-release gate

Acceptance criteria:
- bash -n passes (syntax valid)
- Executable mode 755
- README updated with troubleshooting/release checklist references

Bead-Id: bf-1n6
2026-07-02 14:42:48 -04:00
jedarden
1544ef9e99 docs(bf-1irl): update test environment verification report
- Confirmed cargo 1.95.0 and rustc 1.95.0 installed
- Verified all Rust components (clippy, rustfmt, llvm-tools, etc.)
- All Cargo.toml dependencies compile successfully
- Test compilation succeeded with 13 test targets
- No missing system dependencies

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 14:36:14 -04:00
jedarden
b5a0f33f76 test(bf-1irl): verify test environment and dependencies
- Confirmed cargo 1.95.0 and rustc 1.95.0 installed
- Verified all build dependencies (build-essential, libssl-dev, pkg-config)
- Confirmed 84 packages resolvable across 2 workspace members
- Ran 90 library tests successfully

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 14:29:38 -04:00
jedarden
c1b986539e test(bf-27hl): verify cargo test suite passes all tests 2026-07-02 14:13:10 -04:00
jedarden
afb06df308 test(bf-27hl): verify cargo test suite passes all tests
- Created notes/bf-27hl.md documenting test results
- All 235 tests passed with 0 failures
- 1 test intentionally ignored (slow timeout test)
- Non-blocking compiler warnings present but do not affect functionality

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 14:03:08 -04:00
jedarden
0b37771d6a notes(bf-1v8): verification that all requirements are complete 2026-07-02 13:57:00 -04:00
jedarden
930aeafd0f docs(bf-1v8): fix README exit codes and sync flags table, add docs/notes stubs
- Fix exit-code table: change incorrect codes 3/4 to correct values 124 (timeout) and 130 (interrupted), matching src/error.rs implementation
- Add missing timeout flags to flags table: --first-output-timeout (90s), --stream-json-timeout (90s), --stop-hook-timeout (120s), matching src/cli.rs defaults
- Add docs/notes/hook-design.md covering relay hook mechanics, FIFO protocol, and keeper fd pattern (from src/hook.rs, src/poller.rs)
- Add docs/notes/terminal-probes.md covering Ink probe table and response bytes (from src/terminal.rs)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 13:57:00 -04:00
jedarden
7aec53faca docs(bf-60pc): verify test environment and dependencies 2026-07-02 13:18:57 -04:00
jedarden
098283c197 docs(bf-68nl): verify stream-json reader join on all exit paths
Add verification note confirming that the stream-json reader thread is
properly joined on all exit paths (success, timeout, interrupted, child
exit, early error).

All exit paths in session.rs correctly:
- Send drain signal and join (success, early error)
- Drop handle and join (timeout, interrupted, child exit)

Tests pass (90 passed).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 13:18:57 -04:00
jedarden
0293c5a655 docs(bf-68nl): verify stream-json reader join on all exit paths
Verified that all exit paths properly join the stream-json reader thread:
- Timeout: drop drain_tx, immediate exit + join
- Success: send drain signal + join
- Error before transcript: send drain signal + join
- Child exit: drop drain_tx, immediate exit + join
- Interrupted: drop drain_tx, immediate exit + join

All 131 tests pass. Implementation was already complete in commit e0cf57a.
2026-07-02 11:43:30 -04:00
jedarden
b3d97e7a12 docs(bf-549b): verify stream-json reader spawn at PROMPT_INJECTED
Confirm that emitter::spawn_stream_json_reader is correctly wired
at the PROMPT_INJECTED transition in the event loop callback.

The implementation at src/session.rs:358-376:
- Detects phase change to PromptInjected
- Only spawns when output_format is StreamJson
- Captures start_offset from transcript file metadata
- Calls spawn_stream_json_reader with correct arguments
- Stores StreamJsonHandle for later joining

All acceptance criteria met. Code compiles successfully.
2026-07-02 11:31:52 -04:00
jedarden
8b807a7888 docs(bf-5uv2): verify StreamJsonHandle storage and spawned flag setting
- Confirmed stream_json_handle = Some(...) assignment at src/session.rs:370-373
- Verified stream_json_spawned_clone.store(true, SeqCst) at src/session.rs:374
- Checked Ordering::SeqCst is used for atomic store
- Ensured stream_json_handle is Option<emitter::StreamJsonHandle>
- Verified spawned flag visibility via Arc<AtomicBool> with SeqCst ordering

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 11:10:38 -04:00
jedarden
f33b1f7d83 docs(bf-5uv2): verify StreamJsonHandle storage and spawned flag setting
- Confirmed stream_json_handle = Some(...) assignment exists (src/session.rs:370-373)
- Verified stream_json_spawned_clone.store(true, SeqCst) call is present (src/session.rs:374)
- Checked that Ordering::SeqCst is used for the atomic store
- Ensured stream_json_handle is the correct type (Option<emitter::StreamJsonHandle>)
- Verified spawned flag will be visible to other parts of the code due to SeqCst ordering

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 11:00:07 -04:00
jedarden
bde54b78f8 docs(bf-5k9t): verify spawn_stream_json_reader implementation
- Confirmed output_format check with matches!(output_format, crate::cli::OutputFormat::StreamJson)
- Verified spawn_stream_json_reader call with transcript_path.clone() and start_offset parameters
- Confirmed placement inside PROMPT_INJECTED detection block
- Code compiles successfully (cargo check passed)
- All acceptance criteria met
2026-07-02 10:48:15 -04:00
jedarden
d7e0a1ec73 docs(bf-5t5n): verify transcript_path and start_offset availability
Confirm variables exist and contain correct values at PROMPT_INJECTED:
- transcript_path points to <temp_dir>/transcript.jsonl (session.rs:303)
- start_offset uses std::fs::metadata correctly (session.rs:366-368)
- unwrap_or(0) handles missing file case (defaults to 0)
- Both variables in scope at spawn_stream_json_reader call (session.rs:370-373)
2026-07-02 10:31:25 -04:00
jedarden
729547b470 docs(bf-47pw): verify PROMPT_INJECTED transition detection
- Verified phase change detection logic at session.rs:359-360
- Confirmed last_phase update at session.rs:377
- Verified is_prompt_injected() method in startup.rs
- Confirmed detection fires only once when transitioning TO PromptInjected

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 10:26:22 -04:00
jedarden
cd2206f554 docs(bf-549b): verify stream-json reader spawn at PROMPT_INJECTED
Verify that the stream-json reader spawn call is correctly wired
at the PROMPT_INJECTED transition in the event loop callback.

Code is already implemented in src/session.rs:359-377 with:
- Phase transition detection
- Output format check (StreamJson only)
- Transcript path and start_offset capture
- Handle storage for cleanup on all exit paths
- Compiles without errors
2026-07-02 10:00:51 -04:00
jedarden
4d09ce8a9a chore(bf-3wya): close bead after verification
All acceptance criteria met:
- Identified exact point where bracketed-paste write completes (PromptInjected phase)
- Captured file size using std::fs::metadata().map(|m| m.len()).unwrap_or(0)
- Stored offset in start_offset variable for reader thread
- Handles missing transcript case with .unwrap_or(0)

Implementation verified at src/session.rs:363-375
2026-07-02 09:51:59 -04:00
jedarden
50f3fdd982 docs(bf-3wya): verify transcript byte offset capture implementation
- Verified implementation at lines 363-375 in src/session.rs
- Acceptance criteria met: captures transcript file size at PromptInjected phase
- Fixed warning: removed unnecessary mut from stream_json_spawned
- Added notes/bf-3wya.md documenting the implementation
2026-07-02 09:45:58 -04:00
jedarden
c90ed57dfd docs(bf-3p8h): verify spawn_stream_json_reader signature and retry logic 2026-07-02 09:37:41 -04:00
jedarden
4d5f020b1f docs(bf-30e): verify stream-json reader thread spawn implementation
All acceptance criteria verified:
- Reader thread spawned at PROMPT_INJECTED transition
- Byte offset captured from transcript file length
- Retry logic (50ms intervals, 5s timeout) implemented in emitter.rs
- Reader thread drains to mpsc channel

All 90 library tests and 13 emitter tests pass.
2026-07-02 09:37:41 -04:00
jedarden
e0cf57abf1 Pre-release commit for v0.2.0
- Various source code improvements
- Updated beads tracking
- Ready for first release tag
2026-07-02 08:22:36 -04:00
jedarden
fbff7094eb Merge branch 'main' of https://git.ardenone.com/jedarden/claude-print 2026-07-02 07:29:16 -04:00
jedarden
2e4c8791b6 beads: plan-gap review 2026-07-02 2026-07-02 07:29:08 -04:00
jedarden
1bc8699d33 close(bf-3eq): regression test for watchdog timeout completion
- Completed integration test with stub child that produces no output
- Implemented MOCK_SILENT=1 flag in mock-claude to block forever
- Added cleanup verification tests for temp dirs and FIFOs
- Tests verify claude-print exits non-zero within watchdog window
- Both 2-second and 1-second timeout tests passing
- CI workflow already runs cargo test --verbose (line 51)

All requirements met:
✓ Child produces no output (MOCK_SILENT=1)
✓ Never fires Stop hook (infinite loop)
✓ Asserts non-zero exit (Error::Timeout returned)
✓ Kills the stub (cleanup verified)
✓ No orphaned temp dirs (cleanup verification)
✓ Wired into CI (cargo test --verbose)

Bead-Id: bf-3eq
2026-06-25 19:28:47 -04:00
jedarden
c58952ae98 close(bf-3eq): regression test for watchdog timeout completion
- Completed integration test with stub child that produces no output
- Implemented MOCK_SILENT=1 flag in mock-claude to block forever
- Added cleanup verification tests for temp dirs and FIFOs
- Tests verify claude-print exits non-zero within watchdog window
- Both 2-second and 1-second timeout tests passing
- CI workflow already runs cargo test --verbose (line 51)

All requirements met:
✓ Child produces no output (MOCK_SILENT=1)
✓ Never fires Stop hook (infinite loop)
✓ Asserts non-zero exit (Error::Timeout returned)
✓ Kills the stub (cleanup verified)
✓ No orphaned temp dirs (cleanup verification)
✓ Wired into CI (cargo test --verbose)
2026-06-25 19:28:33 -04:00
jedarden
bf40e6bc6f docs(bf-3eq): document regression test completion
Create summary document noting that watchdog regression tests
are fully implemented and passing. The tests verify that a
child that produces no output and never fires Stop is correctly
terminated by the watchdog with proper cleanup.

Co-Authored-By: Claude <noreply@anthropic.com>
Bead-Id: bf-3eq
2026-06-25 18:58:56 -04:00
jedarden
356dbc296c fix(bf-3eq): add --version flag to mock-claude for watchdog test support
The watchdog test requires mock-claude to handle --version before entering
MOCK_SILENT mode. This allows Session::run() to resolve the version before
spawning the PTY child, which is necessary for the timeout path to work
correctly.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 17:57:20 -04:00
jedarden
ff5bc22a5f fix(bf-3eq): increase cleanup verification timeout for aggressive 1-second watchdog test
The watchdog_one_second_timeout_fires_cleanly test was failing because
the OS cleanup of temp directories didn't complete within the 500ms polling
window. This is expected because the 1-second watchdog timeout is very
aggressive, and the OS needs time to reap the child process and remove the
temp directory after SIGTERM.

Changes:
- Increased cleanup verification timeout from 500ms to 2 seconds
- Maintains 50ms retry intervals for responsive cleanup detection
- Test now passes reliably on all systems

The regression test already existed and was properly wired into CI via
cargo test. This fix ensures the test passes consistently.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 17:56:57 -04:00
jedarden
88faf1443d docs(bf-2w7): document cleanup implementation completeness
Verify and document that all exit paths are covered:
- Orphan cleanup on startup via cleanup_orphans()
- RAII CleanupGuard ensures cleanup on drop
- Global cleanup_temp_dir() before process::exit()
- Atexit handler registration for external signals
- Signal handling for SIGINT/SIGTERM
- HookInstaller cleanup with idempotent flag
- Panic safety with catch_unwind

All 90 library tests + 28 integration tests pass.
Exit path matrix shows all scenarios covered with defense in depth.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 16:02:02 -04:00
jedarden
565999d13a chore: update bead state for bf-2f5, bf-2w7, bf-3eq 2026-06-25 15:35:17 -04:00
jedarden
f6fb2fe63f fix(bf-2f5): overall max-turn timeout now applies throughout entire session
Previously, the overall timeout only applied before prompt injection.
This change makes it apply throughout the entire session, preventing
indefinite polling of stop.fifo regardless of when the child wedges.

The overall timeout ensures claude-print exits non-zero (exit code 124)
with proper SIGTERM→SIGKILL cleanup, clear diagnostics, and temp resource
teardown even if the child hangs during tool use or model inference.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 15:35:17 -04:00
jedarden
4600aa6598 fix(bf-2w7): improve cleanup robustness and orphan detection
- Lower orphan cleanup threshold from 10 minutes to 60 seconds for faster cleanup
- Add debug logging to orphan cleanup (warn on errors, info on success)
- Improve FIFO removal with explicit retry loop (3 attempts, 5ms delays)
- Apply same robust FIFO removal logic to both cleanup paths

The cleanup implementation now:
- Removes orphans within 1 minute instead of 10 minutes
- Logs cleanup operations for debugging
- Retries FIFO removal to handle transient file system errors
- Ensures FIFO is removed before directory removal in all cases

All 90 tests pass with these improvements.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 14:30:37 -04:00
jedarden
10530ec429 docs(bf-2w7): verify cleanup implementation is complete and robust
Verified that temp dir and FIFO cleanup happens on all exit paths:
- Normal exit: CleanupGuard Drop
- Error exit: CleanupGuard Drop
- Watchdog timeout: CleanupGuard Drop after event loop exits
- Signal interruption: CleanupGuard Drop after event loop exits
- Panic: catch_unwind + CleanupGuard Drop
- process::exit(): explicit cleanup_temp_dir() call
- External signals: atexit handler

Orphan cleanup on startup implemented in cleanup_orphans():
- Sweeps claude-print-* dirs older than 10 minutes
- Removes FIFO first, then entire directory
- Called early in main() before any session runs

All cleanup-related tests pass (90 tests total).
Implementation is idempotent with retry logic for transient errors.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 13:59:52 -04:00
jedarden
e97a8413b5 feat(bf-2f5): watchdog timeout implementation complete
Implement comprehensive watchdog timeout mechanism to prevent indefinite hangs
when child process wedges. All four timeout types are now enforced:

Timeout Types:
- PTY first-output timeout (default 90s): Detects if child produces no PTY output
- Stream-json first-output timeout (default 90s): Detects if child emits no stream-json events
- Overall timeout (default 3600s): Maximum session duration
- Stop hook timeout (default 120s): Detects if Stop hook doesn't fire after prompt injection

Timeout Behavior:
- Sends SIGTERM to child process
- Signals event loop via self-pipe to wake up
- Calls kill_child() which waits 2s then SIGKILL if needed
- Writes clear diagnostic to stderr
- Tears down temp resources via CleanupGuard
- Exits with code 124 (GNU timeout convention)

CLI Arguments:
- --timeout <seconds>: Overall timeout
- --first-output-timeout <seconds>: PTY first-output timeout
- --stream-json-timeout <seconds>: Stream-json first-output timeout
- --stop-hook-timeout <seconds>: Stop hook watchdog timeout

Testing:
- All 90 unit tests pass (6 watchdog-specific tests)
- Integration tests verify end-to-end timeout behavior

This ensures marathon loop/NEEDLE can retry cleanly instead of hanging indefinitely.
2026-06-25 13:39:29 -04:00
jedarden
7f19ac116a docs(bf-2f5): confirm watchdog implementation is complete and verified
All requirements verified:
- No-output timeout (PTY 90s, stream-json 90s) ✓
- Max-turn timeout (overall 3600s, stop hook 120s) ✓
- SIGTERM → SIGKILL with descendants ✓
- Clear diagnostics to stderr ✓
- Temp resource teardown ✓
- Exit non-zero (124) ✓

Implementation was completed in commits:
- 7d40c93: add comprehensive watchdog timeout mechanism
- 07013f8: add self-pipe signaling
- ea162c0: correct timeout exit code from 3 to 124
- 11e9b72: document watchdog timeout implementation
- d116dae: verify watchdog timeout implementation is complete

Co-Authored-By: Claude <noreply@anthropic.com>
Bead-Id: bf-2f5
2026-06-25 11:17:34 -04:00
jedarden
3c43436729 docs(bf-2w7): verify cleanup implementation is complete
Verified that all cleanup mechanisms are properly implemented:
- Orphan cleanup on startup (10-minute threshold)
- CleanupGuard for automatic RAII cleanup
- Global cleanup before process::exit()
- Idempotent cleanup with retry logic

All exit paths covered:
- Normal exit (success/error)
- Timeout exit
- Signal interruption (SIGINT/SIGTERM)
- Watchdog timeout
- Panic
- Early returns

All tests passing. No orphaned temp directories found.

Bead-Id: bf-2w7
2026-06-25 11:17:34 -04:00
jedarden
5826607cf7 docs(bf-2f5): verify watchdog timeout implementation is complete
All requirements from bead bf-2f5 have been verified:
- No-output timeout (PTY 90s, stream-json 90s) ✓
- Max-turn timeout (overall 3600s, stop hook 120s) ✓
- SIGTERM → SIGKILL with descendants ✓
- Clear diagnostics to stderr ✓
- Temp resource teardown ✓
- Exit non-zero (124) ✓

Implementation was completed in commits:
- 7d40c93: add comprehensive watchdog timeout mechanism
- 07013f8: add self-pipe signaling
- ea162c0: correct timeout exit code from 3 to 124

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 10:46:51 -04:00
jedarden
5275f5ad78 docs(bf-2w7): document cleanup implementation verification
This commit documents that the cleanup implementation is complete
and covers all exit paths as required by bead bf-2w7:

- Normal exit: CleanupGuard drops → HookInstaller::cleanup()
- Error exit: CleanupGuard drops → HookInstaller::cleanup()
- Watchdog timeout: self-pipe → event loop exit → CleanupGuard drops
- Signal interruption: self-pipe → event loop exit → CleanupGuard drops
- process::exit(): exit_with_cleanup() → session::cleanup_temp_dir()
- Panic: catch_unwind → CleanupGuard drops
- Startup orphans: hook::cleanup_orphans() sweeps stale dirs

All tests pass (90 unit tests + integration tests verify cleanup).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 10:38:45 -04:00
jedarden
4a4d5862f4 docs(bf-2w7): document cleanup implementation verification
- Verify comprehensive cleanup on all exit paths
- Document all cleanup mechanisms and their locations
- Confirm all 90 tests pass including cleanup-specific tests
- Exit path matrix shows all paths covered

Co-Authored-By: Claude <noreply@anthropic.com>
Bead-Id: bf-2w7
2026-06-25 10:01:26 -04:00
jedarden
11e9b72967 docs(bf-2f5): document watchdog timeout implementation
Add comprehensive documentation for the watchdog timeout mechanism
that prevents indefinite hangs in claude-print.

The implementation includes:
- PTY first-output timeout (90s default)
- Stream-json first-output timeout (90s default)
- Overall timeout (3600s default)
- Stop hook timeout (120s default)

Each timeout type triggers SIGTERM→SIGKILL child cleanup,
writes clear diagnostics to stderr, and exits with code 124.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 09:35:19 -04:00
jedarden
a19e2b0aed chore(bf-2w7): verify cleanup implementation is complete and remove unused imports
- Confirm comprehensive cleanup on all exit paths:
  - Startup orphan sweep via cleanup_orphans()
  - RAII cleanup guard (CleanupGuard)
  - process::exit cleanup via exit_with_cleanup()
  - Signal safety via self-pipe pattern
  - Watchdog timeout cleanup via self-pipe signaling
  - Panic safety via catch_unwind

- Remove unused imports from watchdog.rs and session.rs

All cleanup paths verified:
✓ Normal exit → CleanupGuard drop
✓ Error return → CleanupGuard drop
✓ Timeout → Self-pipe → Event loop exit → CleanupGuard drop
✓ Signal → Handler writes to self-pipe → Event loop exit → CleanupGuard drop
✓ Panic → catch_unwind → CleanupGuard drop
2026-06-25 09:32:01 -04:00