Commit graph

70 commits

Author SHA1 Message Date
jedarden
e16680820e Add bf-168 notes: claude-print-ci WorkflowTemplate added to declarative-config
WorkflowTemplate claude-print-ci committed to jedarden/declarative-config at
k8s/iad-ci/argo-workflows/claude-print-ci-workflowtemplate.yml. Phase 9 scope:
verify step only, delegating to rust-verify. Build+release steps deferred to Phase 11.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:53:23 -04:00
jedarden
f81e54d894 Close bead bf-3n3: claude-print.yaml NEEDLE adapter complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:52:15 -04:00
jedarden
8ef28b339b Add bf-3n3 notes: claude-print.yaml NEEDLE adapter installed and validated
Copied claude-print.yaml to ~/.config/needle/adapters/ and confirmed
needle test-agent returns Status: READY with stdin input and
needle-transform-claude transform.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:50:08 -04:00
jedarden
f5d6a0c381 Close bead bf-3vj: install.sh verified complete
install.sh already existed (Phase 9, commit 50b2132) and passes all
acceptance criteria: bash -n passes, detects platform, installs with
-m 755 to ~/.local/bin, runs --check post-install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:47:51 -04:00
jedarden
86c51495a9 Add bf-3vj verification notes: install.sh already complete
install.sh was created in Phase 9 (commit 50b2132). Verified it passes
bash -n, covers x86_64/aarch64 musl targets, installs with -m 755 to
~/.local/bin, and runs claude-print --check post-install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:46:35 -04:00
jedarden
fbd3a8c860 Close bead bf-360: --check subcommand verified complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:45:34 -04:00
jedarden
6b5d114a03 Add bf-360 verification notes for --check subcommand
Confirms the --check subcommand (src/check.rs) is fully implemented:
openpty probe, mkfifo probe, optional mock_claude PTY round-trip,
exits 0 on success with diagnostic table, exits 2 on any FAIL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:44:16 -04:00
jedarden
dfdf76300a Add Phase 9 verification notes for bead bf-42j
Confirms all deliverables complete: claude-print.yaml, install.sh,
claude-print-ci WorkflowTemplate, and --check subcommand. All probes
pass (openpty, mkfifo, mock_claude PTY round-trip). README flags match
--help output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:39:04 -04:00
jedarden
50b213285a Add Phase 9: NEEDLE integration — install.sh, claude-print.yaml, --check subcommand
- claude-print.yaml: NEEDLE agent config with stdin input_method, needle-transform-claude
  output_transform, and invoke_template for subscription-billed claude-print runs
- install.sh: download release binary from GitHub, backup existing, install mock_claude,
  install NEEDLE config if present, run --check to verify, print --version
- src/check.rs: --check doctor subcommand with openpty probe, mkfifo probe, and optional
  mock_claude PTY round-trip (skipped if mock_claude not in PATH)
- src/main.rs + src/lib.rs: wire up check::run() for --check flag
- README.md: add Install, Usage, Flags table (matches --help exactly), Exit codes,
  and NEEDLE integration sections
- test-fixtures/mock-claude: extend with all MOCK_* env var controls needed for
  integration tests (MOCK_SILENT, MOCK_EXIT_BEFORE_STOP, MOCK_TRUST_DIALOG, etc.)
- tests/cli.rs, tests/hooks.rs, tests/version_compat.rs: Phase 10 unit test stubs

claude-print --check passes: openpty PASS, mkfifo PASS, mock_claude PTY PASS
bash -n install.sh: syntax OK

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:36:28 -04:00
jedarden
08420de402 Re-verify bead bf-2f1: Phase 8 Emitter tests confirmed passing (second run)
All 13 emitter unit tests pass on re-verification. Implementation was
already complete from prior run; this run confirms correctness and
commits the bead close state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:20:27 -04:00
jedarden
4cf7acb8f8 Close bead bf-2f1: Phase 8 Emitter verification complete
All 13 emitter unit tests pass. Phase 8 implementation verified:
text/json/stream-json output formats, error result objects, exit
code mapping, and stream-json reader thread all confirmed correct.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:18:12 -04:00
jedarden
aaee3d31a1 Update beads tracking for bf-2f1 (Phase 8 Emitter verification)
All 13 emitter unit tests pass; Phase 8 was already implemented.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 01:16:09 -04:00
jedarden
bfb50da40c Add Phase 8: Emitter — text/json/stream-json output formats
Adds emitter.rs with three output format handlers and stream-json reader thread,
ClaudePrintError enum with exit codes and JSON subtypes to error.rs,
and 13 unit tests in tests/emitter.rs covering all plan requirements.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:57:30 -04:00
jedarden
c6241e37b7 Add Phase 7: transcript reader with retry loop and dedup
Implements src/transcript.rs: lenient JSONL parsing, message.id dedup
with usage-fingerprint fallback, text extraction from ContentBlock arrays,
40×50ms retry loop for Stop-before-JSONL races (PO-5), and last_assistant_message
fallback. All 18 tests in tests/transcript.rs pass; AS-6 verified with
MOCK_DELAY_JSONL=100.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:51:59 -04:00
jedarden
343fa3898c Clean up duplicate bf-64s entries in issues.jsonl (Phase 6 already complete)
Phase 6 Stop Poller was implemented in 59e170e and verified complete.
Both integration tests (test_stop_hook_fires, test_missing_transcript_path_derived) pass.
Compaction removed duplicate in-progress entry for bf-64s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:41:22 -04:00
jedarden
3e711ae009 Close bead bf-64s: Phase 6 Stop Poller complete
All Phase 6 implementation was committed in prior sessions (59e170e).
Both completion criteria tests pass: test_stop_hook_fires and
test_missing_transcript_path_derived.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:40:32 -04:00
jedarden
c688d2c84c Verify Phase 6 completion on retry (bf-64s)
All tests pass including test_stop_hook_fires and
test_missing_transcript_path_derived. Implementation complete in 59e170e.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:38:49 -04:00
jedarden
2760d9b07f Add Phase 6 completion notes for bf-64s
Verifies test_stop_hook_fires and test_missing_transcript_path_derived pass;
documents the FIFO open race resolution (OQ-4) and path derivation algorithm.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:30:40 -04:00
jedarden
ed7790f6e2 Update bead tracking for Phase 6 completion (bf-64s)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:17:20 -04:00
jedarden
ab1e9d6d64 Fix clippy warnings: upper_case_acronyms and manual_range_contains
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:10:43 -04:00
jedarden
0b43ece3ca Merge remote-tracking branch 'origin/main' 2026-06-10 00:05:41 -04:00
jedarden
59e170ed03 Implement Phase 6: Stop Poller (bf-64s)
Add src/poller.rs with FIFO O_NONBLOCK open (read-end + keeper write-end),
Stop hook JSON payload parsing, transcript path derivation via cwd slug,
and StopInfo resolution. Wire poller into EventLoop via add_fifo_fd() which
was already present in event_loop.rs from Phase 3.

Update mock-claude to emit proper JSON Stop payloads (with and without
transcript_path via MOCK_OMIT_TRANSCRIPT_PATH=1) and update the pty_integration
assertion to match.

Tests test_stop_hook_fires and test_missing_transcript_path_derived both pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:05:14 -04:00
jedarden
2407b640f8 Close bf-5bl: starvation alert resolved (dependency chain, not config error)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bead-Id: bf-5bl
2026-06-10 00:00:25 -04:00
jedarden
e422edfe75 Close bf-5bl: starvation alert resolved (dependency chain, not config error)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:00:16 -04:00
jedarden
71a3a70a84 Investigate starvation alert: all beads blocked by dependency chain (bf-5bl)
All open beads are transitively blocked waiting on bf-64s (Phase 6, in_progress).
No configuration error — sequential dependency chain is working as designed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 23:59:09 -04:00
jedarden
89e051666c Close bead bf-vsm: Phase 5 Startup Sequencer complete
All four Phase 5 components implemented and verified: keyword trust
dismiss, idle-gap timing, bracketed paste injection, and large-prompt
file relay. 55 tests pass (20 startup unit + 11 test_trust_dialog_*
integration + 24 others).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 22:41:15 -04:00
jedarden
71a4cb9f96 Implement large-prompt file relay in startup.rs (bf-1cx)
Prompts exceeding INLINE_PROMPT_MAX (32 KB) are written to a NamedTempFile
and a shell $(< path) read command is injected via bracketed paste instead
of the raw bytes, avoiding PTY pipe-buffer saturation.

Adds four unit tests: threshold boundary (inline), threshold+1 (file relay),
temp-file content verification, and end-to-end state-machine coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:26:16 -04:00
jedarden
066f1e060b Close bead bf-9u4: bracketed paste injection verified complete
Implementation was already present from bf-54m. make_prompt_payload()
wraps the startup prompt in ESC[200~ / ESC[201~\r; injection fires after
the post-dismiss idle gap. All 41 tests pass confirming correct behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:17:59 -04:00
jedarden
3e17fdcfe0 Close bead bf-54m: idle-gap timing implemented and verified
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:16:57 -04:00
jedarden
adaf26e523 Add idle-gap detection to startup.rs (bf-54m)
After trust-dismiss fires, the post-dismiss wait is now an idle-gap:
injection fires only after idle_gap_ms of uninterrupted silence.
Any PTY output chunk resets the gap via last_output_at, preventing
premature injection during TUI redraws after the dismiss CR.

- Rename POST_DISMISS_IDLE_MS → DEFAULT_POST_DISMISS_IDLE_MS (pub const)
- Add idle_gap_ms field to StartupSeq; expose via with_idle_gap() ctor
- TrustDismissed timer now uses last_output_at instead of trust_dismiss_at
- Reset last_output_at when entering TrustDismissed via idle-fallback path
- Add three unit tests: resets on output, fires after silence, no double-fire

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:10:46 -04:00
jedarden
02cf4c1cfc Close bead bf-38q: trust-keyword scanner complete
All test_trust_dialog_* integration tests pass (11/11).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:07:46 -04:00
jedarden
edd9470038 Add startup.rs: trust-keyword scanner with test_trust_dialog_* integration tests (Phase 5)
Implements StartupSeq with scan_line() that detects 2+ trust keywords
("trust", "Allow", "continue", "folder", "permission", "proceed") on a
PTY output line and returns CR to dismiss the dialog.  Includes idle
fallback (0.8 s after 200+ bytes) and hard timeout (45 s / <200 bytes →
HardTimeout).  Phase 2 injects the prompt via bracketed paste after a
2 s post-dismiss idle.

11 test_trust_dialog_* integration tests cover keyword match, threshold,
case sensitivity, chunk-boundary assembly, one-shot dismiss, and CR- vs
LF-terminated lines.  12 unit tests in startup::tests cover scan_line
and feed() in isolation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:05:27 -04:00
jedarden
f504fadc07 Close bead bf-gvw: Phase 4 Terminal Emulator complete
All 9 terminal unit tests pass. TerminalEmu in terminal.rs handles
DA1/DA2/DSR/XTVERSION/WinSize probes with dedup bitmask and split-chunk
accumulation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:27:56 -04:00
jedarden
7b64f5b340 Add terminal.rs: probe scanner with response table, dedup bitmask, unknown-probe passthrough (Phase 4)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:25:54 -04:00
jedarden
3adcdb19ac Close bead bf-5h9: Phase 3 Event Loop complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:19:31 -04:00
jedarden
78b06ed27f Add event_loop.rs: poll() loop with dynamic fd set and EIO detection (Phase 3)
Implements EventLoop with master_fd + self_pipe_read as the initial 2-fd
pollfd Vec. add_fifo_fd() pushes the stop FIFO fd at PROMPT_INJECTED. run()
dispatches PTY output chunks to a callback and returns ExitReason on child
exit (EIO), FIFO payload, or self-pipe interrupt. Both required tests pass:
test_event_loop_reads_pty_output and test_event_loop_detects_child_exit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:18:54 -04:00
jedarden
5f4910a879 Close bead bf-rw7: Phase 2 Hook Installer + PTY Spawner complete
All Phase 2 deliverables (hook.rs, pty.rs, --no-inherit-hooks, mock-claude
fixture, test_pty_spawns_tty) were implemented in prior commits. All 14 unit
tests and the integration test pass. This commit records the bead close.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bead-Id: bf-rw7
2026-06-08 09:11:07 -04:00
jedarden
3214201761 Fix issues.jsonl corruption and close bead bf-l5z
Removed Python CUDA error output that had been injected into issues.jsonl,
contaminating the JSONL stream. Rebuilt the beads database from the cleaned file.
Bead bf-l5z (test_pty_spawns_tty) was already implemented and passing — this
commit records the clean close.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:09:43 -04:00
jedarden
4edf5220a8 Close bead bf-l5z: verify test_pty_spawns_tty acceptance
All three deliverables (--no-inherit-hooks flag, mock-claude fixture,
test_pty_spawns_tty integration test) were implemented in 17c35f4.
This commit records the bead closure and verified acceptance.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:00:10 -04:00
jedarden
17c35f40a7 Add mock-claude fixture, test_pty_spawns_tty integration test, and hook module export
- test-fixtures/mock-claude: implement mock binary that writes 'stop' to FIFO then checks isatty(stdin), exiting 0 on TTY
- tests/pty_integration.rs: test_pty_spawns_tty uses HookInstaller + PtySpawner to verify controlling TTY is established
- src/lib.rs: expose hook module publicly
- Cargo.lock: add libc dependency for mock-claude

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 08:56:36 -04:00
jedarden
a1e74b59fa Add signal forwarding, I/O relay, and wait to PtySpawner
- Install a SIGWINCH handler that sets a static AtomicBool; the relay loop
  re-issues TIOCSWINSZ on the master fd each time it fires.
- relay() poll-loops over the master fd and stdin, copying master output to
  stdout and stdin input to the master fd, with 100 ms timeout so SIGWINCH
  is handled promptly on EINTR.
- Loop exits on EIO/EOF/POLLHUP from the master fd (slave side closed).
- waitpid() at the end of relay() surfaces the child exit code (or
  128+signum for signal termination).
- New tests: master_fd_carries_child_stdout (acceptance criterion),
  relay_echo_exits_zero_and_produces_output, relay_surfaces_nonzero_exit_code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:47:09 -04:00
jedarden
dcbdb8c173 Close bead bf-21b: execvp and window-size implementation complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:43:01 -04:00
jedarden
ffbe0f298e Add execvp and TIOCSWINSZ to PtySpawner::spawn
Change spawn() to spawn(cmd, args): on the parent side set the PTY
window size via TIOCSWINSZ mirroring stdin or defaulting to 80x24; on
the child side call execvp with the given command after login_tty.
Update the test to exercise /bin/true through the full exec path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:42:00 -04:00
jedarden
1be8048845 Close bead bf-2ug: PTY open and fork implementation complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:40:16 -04:00
jedarden
1ff77156db Add hook.rs and update bead state for Phase 2 completion
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:38:45 -04:00
jedarden
4a38e8f6a3 Phase 2: implement PTY open and fork in pty.rs
Adds PtySpawner struct that calls openpty() for master/slave fds, forks,
and runs login_tty on the child side before it exits. Fixes nix feature
flag (pty module is gated by `term`, not a `pty` feature in nix 0.29).
Adds mock-claude workspace stub so the workspace resolves cleanly.

Unit test: fork_and_login_tty_does_not_panic passes (child exits 0).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:38:14 -04:00
jedarden
689edda117 Close bead bf-2z4: Phase 1 Crate Scaffold complete
All completion criteria met: musl build succeeds, --version prints
expected format, cargo test --lib passes (5 tests), CI stub exists
in declarative-config.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:04:27 -04:00
jedarden
ba41ebd32f Update bead state for Phase 1 completion
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:03:08 -04:00
jedarden
6f67cd5b00 Phase 1: crate scaffold with CLI, config, and error types
Adds Cargo.toml with pinned deps (clap, anyhow, serde, thiserror,
toml), src/{main,lib,cli,config,error}.rs. --version prints
"claude-print <ver> (wrapping claude <ver>)". All lib tests pass.
Builds clean for x86_64-unknown-linux-musl.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 16:00:19 -04:00
jedarden
140d830d26 Flush beads to JSONL for persistence
12 beads (genesis + 11 phases) flushed from SQLite to issues.jsonl.
JSONL is the authoritative, corruption-immune data source.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 15:37:07 -04:00