diff --git a/graph.fabro b/graph.fabro new file mode 100644 index 000000000..4bc3ad5ee --- /dev/null +++ b/graph.fabro @@ -0,0 +1,38 @@ +digraph ImplementAndSimplify { + graph [ + goal="Implement and simplify", + model_stylesheet=" + * { backend: api; model: claude-opus-4-6;} + " + ] + rankdir=LR + + start [shape=Mdiamond, label="Start"] + exit [shape=Msquare, label="Exit"] + + toolchain [label="Toolchain", shape=parallelogram, script="command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1", max_retries=0] + preflight_compile [label="Preflight Compile", shape=parallelogram, script="cargo check -q --workspace 2>&1", max_retries=0] + preflight_lint [label="Preflight Lint", shape=parallelogram, script="cargo clippy -q --workspace -- -D warnings 2>&1", max_retries=0] + fix_lints [label="Fix Lints", prompt="The preflight lint step failed. Read the build output from context and fix all clippy lint warnings.", max_visits=3] + implement [label="Implement", prompt="Read the plan file referenced in the goal and implement every step. Make all the code changes described in the plan. Use red/green TDD."] + simplify_opus [label="Simplify (Opus)", prompt="@prompts/simplify.md"] + simplify_gemini [label="Simplify (Gemini)", prompt="@prompts/simplify.md", model="gemini-3.1-pro-preview-customtools"] + simplify_gpt [label="Simplify (GPT-54)", prompt="@prompts/simplify.md", model="gpt-54"] + verify [label="Verify", shape=parallelogram, script="cargo clippy -q --workspace -- -D warnings 2>&1 && cargo nextest run --cargo-quiet --workspace --status-level fail 2>&1", goal_gate=true, retry_target="fixup"] + fixup [label="Fixup", prompt="The verify step failed. Read the build output from context and fix all clippy lint warnings and test failures.", max_visits=3] + fmt [label="Format", shape=parallelogram, script="cargo fmt --all 2>&1", goal_gate=true, max_retries=0] + + start -> toolchain + toolchain -> preflight_compile [condition="outcome=success"] + toolchain -> exit + preflight_compile -> preflight_lint [condition="outcome=success"] + preflight_compile -> exit + preflight_lint -> implement [condition="outcome=success"] + preflight_lint -> fix_lints + fix_lints -> preflight_lint + implement -> simplify_opus -> simplify_gemini -> simplify_gpt -> verify + verify -> fmt [condition="outcome=success"] + verify -> fixup + fixup -> verify + fmt -> exit +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 000000000..c8e9ed74e --- /dev/null +++ b/manifest.json @@ -0,0 +1,13 @@ +{ + "run_id": "01KKTGHPD8WHF5W8RBSNARR0QH", + "workflow_name": "ImplementAndSimplify", + "goal": "# Add Sentry panic reporting to fabro CLI\n\n## Context\n\nFabro has no panic reporting. When the CLI panics, we lose visibility. We want Sentry-based panic reporting modeled on qlty's approach: serialize a Sentry event to a temp file, double-fork a detached subprocess to upload it.\n\nThe existing `__send_analytics` sender uses a simple `Command::spawn()` which is unreliable — the child can get killed when the parent exits or the terminal session ends. We'll fix both senders to use the double-fork pattern (fork → setsid → close_fd → fork → exec) from qlty, which fully detaches the subprocess.\n\n## Files to modify\n\n### 1. `Cargo.toml` (workspace root) — add deps\n```toml\nsentry = { version = \"0.35\", default-features = false, features = [\"backtrace\", \"contexts\", \"ureq\", \"rustls\"] }\nfork = \"0.2\"\nexec = \"0.3\"\n```\n\n### 2. `lib/crates/fabro-util/Cargo.toml` — add deps\n```toml\nsentry.workspace = true\nfork.workspace = true\nexec.workspace = true\n```\n\n### 3. `lib/crates/fabro-util/src/telemetry/mod.rs`\n- Add `pub mod panic;`\n- Add `pub mod spawn;`\n\n### 4. `lib/crates/fabro-util/src/telemetry/spawn.rs` — NEW FILE\n\nExtract a shared `spawn_detached(args: &[&str], env: &[(&str, &str)])` function used by both analytics sender and panic sender. Implements:\n- **Unix**: double-fork via `fork` crate (fork → setsid → close_fd → fork → exec)\n- **Windows**: `Command::new().creation_flags(DETACHED_PROCESS).spawn()`\n\n### 5. `lib/crates/fabro-util/src/telemetry/sender.rs` — refactor to use `spawn_detached`\n\nReplace the `Command::new().spawn()` call with `spawn::spawn_detached()`.\n\n### 6. `lib/crates/fabro-util/src/telemetry/panic.rs` — NEW FILE\n\nCore logic:\n\n- `install_panic_hook()` — chains onto default hook (like qlty). Calls `report_panic()` then delegates to default.\n- `report_panic(info: &PanicHookInfo)` — checks telemetry level (Off → return), filters \"Broken pipe\" panics, builds `sentry::protocol::Event` with:\n - Exception with `mechanism.ty = \"panic\"`, `handled = false`\n - Panic message as `value`\n - `sentry_backtrace::current_stacktrace()`\n - OS context\n - Level = Fatal\n- `spawn_panic_sender(event)` — serialize event to `~/.fabro/tmp/fabro-panic-{id}.json`, double-fork `fabro __send_panic ` with `FABRO_TELEMETRY=off`.\n- `pub async fn send_panic_to_sentry(path: &Path)` — read JSON, init sentry client with `SENTRY_DSN` (compile-time `option_env!`), `sentry::capture_event()`, delete temp file.\n\n### 7. `lib/crates/fabro-cli/src/main.rs` — two changes\n\n**a) Install panic hook early in `main()`** (before `main_inner()`):\n```rust\nfabro_util::telemetry::panic::install_panic_hook();\n```\n\n**b) Add `__send_panic` hidden subcommand** (same pattern as `__send_analytics`).\n\n## Key design decisions\n\n- **Double-fork for all background senders** — ensures subprocess survives parent exit and terminal close. Fixes existing `__send_analytics` reliability too.\n- **Shared `spawn_detached`** — avoids duplicating the fork logic between analytics and panic senders.\n- **Telemetry level respected** — `Off` skips panic reporting. `Errors` and `All` both report.\n- **Recursion prevention** — subprocess sets `FABRO_TELEMETRY=off`.\n- **Compile-time DSN** — `option_env!(\"SENTRY_DSN\")`, no-ops when unset (dev builds).\n- **Filter broken pipe** — CLI tools get SIGPIPE from `| head` etc., not a real bug.\n\n## Implementation order (red/green TDD)\n\nWork bottom-up through the dependency chain. For each step, write the test first (red), then write the minimal code to make it pass (green).\n\n### Step 1: `spawn_detached` (fabro-util)\n- **Red**: Test that `spawn_detached` constructs the right args (unit-testable parts: temp file writing, arg assembly). On Unix, test the double-fork integration by spawning a real process that writes a marker file.\n- **Green**: Implement `spawn.rs` with fork/setsid/close_fd/fork/exec on Unix, DETACHED_PROCESS on Windows.\n\n### Step 2: Refactor `sender.rs` to use `spawn_detached`\n- **Red**: Existing `send_noops_without_write_key` test still passes. Add test verifying temp file is written with correct JSON.\n- **Green**: Replace `Command::spawn()` with `spawn_detached()`.\n\n### Step 3: `panic.rs` — event building\n- **Red**: Test `build_panic_event()` produces correct Sentry event structure (exception type, mechanism, level, stacktrace present).\n- **Green**: Implement event builder.\n\n### Step 4: `panic.rs` — hook + spawn\n- **Red**: Test that `report_panic` filters broken pipe. Test that it no-ops when telemetry is Off.\n- **Green**: Implement `install_panic_hook()`, `report_panic()`, `spawn_panic_sender()`.\n\n### Step 5: `panic.rs` — Sentry sender\n- **Red**: Test `send_panic_to_sentry` no-ops without DSN (like analytics no-ops without write key).\n- **Green**: Implement the `__send_panic` worker function.\n\n### Step 6: Wire up in `main.rs`\n- Add `__send_panic` subcommand + install panic hook.\n- Verify: `cargo build --workspace && cargo test --workspace && cargo clippy --workspace -- -D warnings`\n", + "start_time": "2026-03-16T05:05:29.164020Z", + "node_count": 13, + "edge_count": 16, + "run_branch": "fabro/run/01KKTGHPD8WHF5W8RBSNARR0QH", + "base_sha": "470fcfe1200b2102c0cdf91c73b0ed8d925f258a", + "base_branch": "main", + "workflow_slug": "implement", + "host_repo_path": "/Users/bhelmkamp/p/fabro-sh/fabro" +} \ No newline at end of file diff --git a/sandbox.json b/sandbox.json new file mode 100644 index 000000000..9a579859e --- /dev/null +++ b/sandbox.json @@ -0,0 +1,5 @@ +{ + "provider": "daytona", + "working_directory": "/home/daytona/workspace", + "identifier": "fabro-01KKTGHPD8WHF5W8RBSNARR0QH" +} \ No newline at end of file