fabro/lib/crates/fabro-cli/tests/it/cmd
fabro-sh-0530[bot] 475b4ab650
Replace stdin JSONL control pipe with WebSocket worker control bus (#440)
## Summary

Workers no longer receive control messages over stdin JSONL. A new
`WorkerControlBus` abstraction (backed by `LocalWorkerControlBus` for
local/single-node deployments) publishes `WorkerControlEnvelope`
messages server-side; a worker-initiated WebSocket at `GET
/runs/{id}/worker/control-stream` delivers them with ordered, replayable
delivery frames. The bus API is designed so a Redis Streams backend can
slot in later without touching API handlers or worker message handling.

### Plan Summary

- **Task 1 – Bus contract:** `WorkerControlBus` trait,
`WorkerControlDelivery`, `WorkerControlCursor` (`Start` / `After(id)`),
bus errors.
- **Task 2 – Local backend:** `LocalWorkerControlBus` — in-memory
per-run stream, replay from `Start`, reconnect via `After(id)`, 1
024-message trim bound, cleanup on terminal runs.
- **Task 3 – Server state:** `Arc<dyn WorkerControlBus>` added to
`AppState`; `LocalWorkerControlBus` constructed at startup.
- **Task 4 – Protocol extension:** `WorkerControlMessage::RunPause` /
`RunUnpause`, `WorkerControlDeliveryFrame`, WebSocket liveness constants
(`WORKER_CONTROL_WS_PING_INTERVAL = 15s`,
`WORKER_CONTROL_WS_LIVENESS_TIMEOUT = 45s`), close-reason strings.
- **Task 5 – Worker message handler:** `apply_worker_control_message`
split out; pause/unpause routing; delivery-id dedupe
(`AppliedWorkerControlDeliveryIds`, capacity 2 048).
- **Task 6 – Worker WebSocket client:** `spawn_worker_control_manager` —
HTTP→ws/wss and Unix-socket connection, backoff 100ms→5s,
first-connection gate before `operations::start/resume`, ping/pong
watchdog, fatal loss wired back to `execute`.
- **Task 7 – Server route:** `GET /runs/{id}/worker/control-stream`,
worker-only auth via new `RequireWorkerRunScoped` extractor,
`Start`/`After` cursor dispatch, 410 on invalid cursor, server-side
ping/pong.
- **Task 8 – Stdin removal:** `RunAnswerTransport::Subprocess` renamed
to `Worker { run_id, bus }`; `pump_worker_control_jsonl` deleted; worker
launched with `stdin(Stdio::null())`; pause/unpause transport methods
added.
- **Tasks 9–10 – E2E & verification:** reconnect, invalid-cursor,
cancel-over-WebSocket, and human-interview regression tests; no Redis
dependency added.

### Key design decisions

**`RunAnswerTransport::Subprocess` → `Worker { run_id, bus }`** — all
existing transport methods (`submit`, `cancel_run`, `steer`,
`interrupt`, `pair_*`) now call `bus.publish(run_id, envelope)` instead
of writing to a channel that fed stdin. The match arms are symmetric, so
the diff is mechanical but large.

**First-connection gate** — `execute()` calls
`control_manager.wait_for_first_connection().await?` before
`operations::start` or `operations::resume`. Temporary failures spin
with backoff; a fatal invalid-cursor or request-build failure propagates
as an error before the workflow starts.

**Fatal vs. reconnectable** — HTTP 410 or a WebSocket close with reason
`"invalid_cursor"` is fatal (infrastructure failure, not user
cancellation). Any other close/error triggers the reconnect loop while
the run is non-terminal.

**`AutomationStore::load` made synchronous** — startup load now uses
`std::fs` under a `clippy::disallowed_methods` exception; async
`tokio::fs` is no longer needed for the one-shot directory scan. Invalid
automation files now fail loudly instead of being silently skipped.

**`canRetry` extended to succeeded runs** — `status.kind ===
"succeeded"` is now retryable (non-archived). Tests and API docs updated
to match.

**Default model bumps** — OpenAI default: `gpt-5.4` → `gpt-5.5`; Gemini
default: `gemini-3.1-pro-preview` → `gemini-3.5-flash`.


### Fabro Details

<details>
<summary>Ran 9 stages in 129m 19s for $58.27</summary>

| Stage | Duration | Cost | Retries |
|---|---|---|---|
| start | 0s | – | 0 |
| toolchain | 1s | – | 0 |
| preflight_compile | 2m 10s | – | 0 |
| preflight_lint | 2m 23s | – | 0 |
| implement | 73m 48s | $41.53 | 0 |
| simplify_opus | 22m 55s | $11.75 | 0 |
| simplify_gpt | 7m 19s | $2.74 | 0 |
| verify | 8m 51s | – | 0 |
| fixup | 10m 59s | $2.24 | 0 |
| **Total** | **129m 19s** | **$58.27** | **0** |

</details>

<details>
<summary>Ran <code>ImplementPlan.fabro</code> (11 nodes and 14
edges)</summary>

```dot
digraph ImplementPlan {
    graph [
        goal="Implement and simplify",
        model_stylesheet="
            * { model: claude-opus-4-7; }
        "
    ]
    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 +nightly-2026-04-14 clippy -q --workspace --all-targets -- -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.", model="gpt-55", reasoning_effort="xhigh"]
    simplify_opus     [label="Simplify (Opus)", prompt="@prompts/simplify.md"]
    simplify_gpt      [label="Simplify (GPT-55)", prompt="@prompts/simplify.md", model="gpt-55"]
    verify            [label="Verify", shape=parallelogram, script="git fetch origin main 2>&1 && git merge --no-edit --no-stat origin/main 2>&1 && cargo +nightly-2026-04-14 fmt --all 2>&1 && cargo dev docs refresh 2>&1 && cargo +nightly-2026-04-14 fmt --check --all 2>&1 && { command -v rg >/dev/null 2>&1 || { echo 'rg is required for verify'; exit 127; }; } && ! rg -n 'AuthMode::Disabled|RunAuthMethod|RunSubjectProvenance|\bActorRef\b|\bActorKind\b|AuthenticatedSubject|AuthenticatedService|AuthorizeRunScoped|AuthorizeRunBlob|AuthorizeStageArtifact|AuthorizeCommandLog|auth_method\s*==\s*\"disabled\"' lib/crates apps lib/packages docs/public/api-reference/fabro-api.yaml 2>&1 && cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings 2>&1 && cargo nextest run --workspace --status-level slow --profile ci 2>&1 && cargo dev docs check 2>&1 && bun install --frozen-lockfile 2>&1 && (cd apps/fabro-web && bun run typecheck) 2>&1 && (cd apps/fabro-web && bun run test) 2>&1 && (cd lib/packages/fabro-api-client && bun run typecheck) 2>&1 && cargo dev build -- -p fabro-cli --release 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 format, clippy, Rust test, docs, TypeScript typecheck/test, and build failures.", max_visits=3]

    start -> toolchain
    toolchain -> preflight_compile [condition="outcome=succeeded"]
    toolchain -> exit
    preflight_compile -> preflight_lint [condition="outcome=succeeded"]
    preflight_compile -> exit
    preflight_lint -> implement [condition="outcome=succeeded"]
    preflight_lint -> fix_lints
    fix_lints -> preflight_lint
    implement -> simplify_opus -> simplify_gpt -> verify
    verify -> exit  [condition="outcome=succeeded"]
    verify -> fixup
    fixup -> verify
}

```

</details>

⚒️ Generated with [Fabro](https://fabro.sh)

---------

Co-authored-by: Fabro <noreply@fabro.sh>
Co-authored-by: Bryan Helmkamp <bryan@brynary.com>
2026-05-27 20:24:25 -04:00
..
approve.rs feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
archive.rs feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
artifact_cp.rs test(cli): trim slow integration fixture setup 2026-04-28 19:14:56 -07:00
artifact_list.rs test(cli): trim slow integration fixture setup 2026-04-28 19:14:56 -07:00
attach.rs chore(model): update provider default models (#437) 2026-05-27 18:45:51 -04:00
auth.rs test(cli): tighten env-dev-token-ignore tests 2026-05-01 16:25:13 -04:00
cli_reference.rs refactor(dev): decouple CLI reference generation 2026-05-06 12:31:02 -04:00
config.rs fix(model): retire GPT-5.2 and GPT-5.3 catalog entries (#412) 2026-05-26 00:06:50 -04:00
create.rs Replace run-scoped sandbox config with named environments (#360) 2026-05-23 13:03:21 -04:00
deny.rs feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
diff.rs test(cli): prune slow integration outliers 2026-04-28 19:26:27 -07:00
discord.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
docs.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
doctor.rs refactor(auth): split credential sources and vault schemas (#306) 2026-05-18 11:07:42 -04:00
dump.rs Replace queued with pending/runnable and add approval flow (web + API s… (#371) 2026-05-23 15:34:33 -04:00
events.rs fix: stabilize attach JSON timing snapshot (#385) 2026-05-24 13:09:09 -04:00
exec.rs fix(agent): retry retryable mid-stream LLM failures 2026-05-22 21:00:50 -04:00
fabro.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
fork.rs refactor(runs): simplify run projection shape 2026-05-09 23:31:43 -04:00
graph.rs feat(cli): allow rendering invalid graphs 2026-05-25 10:19:32 -04:00
inspect.rs feat(sandbox): secure daytona snapshot names (#429) 2026-05-27 11:52:35 -04:00
install.rs refactor: rationalize server secret scopes (vault-only for optional int… (#401) 2026-05-25 17:26:01 -04:00
json_global.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
logs.rs fix(cli): preserve API error details 2026-05-06 14:03:12 -04:00
mcp.rs feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
mod.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
model.rs test(cli): stabilize model list snapshots 2026-05-25 10:20:47 -04:00
model_list.rs refactor(cli): separate local socket and storage defaults 2026-04-06 11:57:14 -04:00
model_test.rs refactor(llm): split provider identity from adapters (#280) 2026-05-16 13:13:41 -04:00
parent.rs feat(cli): wire run parent commands (#288) 2026-05-16 15:15:28 -04:00
parse.rs feat(cli): render fatal errors with miette 2026-04-24 15:35:57 -04:00
pr.rs feat(pr): support GitHub pull request associations (#270) 2026-05-16 12:47:27 -04:00
pr_close.rs refactor(pr): simplify server-side PR plumbing 2026-04-24 11:17:01 -04:00
pr_create.rs feat(pr): support GitHub pull request associations (#270) 2026-05-16 12:47:27 -04:00
pr_link.rs feat(pr): support GitHub pull request associations (#270) 2026-05-16 12:47:27 -04:00
pr_merge.rs refactor(pr): simplify server-side PR plumbing 2026-04-24 11:17:01 -04:00
pr_unlink.rs feat(pr): support GitHub pull request associations (#270) 2026-05-16 12:47:27 -04:00
pr_view.rs feat(pr): support GitHub pull request associations (#270) 2026-05-16 12:47:27 -04:00
preflight.rs Replace run-scoped sandbox config with named environments (#360) 2026-05-23 13:03:21 -04:00
provider.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
provider_login.rs Complete provider credential auth and scripted install 2026-04-13 09:15:45 -04:00
ps.rs fix(server): persist manifest metadata names (#302) 2026-05-18 08:31:23 -04:00
render_graph.rs fix(graph): support dotted Fabro graph attributes (#324) 2026-05-20 09:31:08 -04:00
repo.rs feat(cli): render fatal errors with miette 2026-04-24 15:35:57 -04:00
repo_deinit.rs refactor(config): move project state under .fabro 2026-04-11 12:55:46 -04:00
repo_init.rs Replace run-scoped sandbox config with named environments (#360) 2026-05-23 13:03:21 -04:00
resume.rs test(cli): prune slow integration outliers 2026-04-28 19:26:27 -07:00
rewind.rs feat(api): unify public run shape 2026-05-10 20:48:55 -04:00
rm.rs fix(cli): print full run id on rm (#315) 2026-05-20 08:24:31 -04:00
run.rs Replace queued with pending/runnable and add approval flow (web + API s… (#371) 2026-05-23 15:34:33 -04:00
runner.rs Replace stdin JSONL control pipe with WebSocket worker control bus (#440) 2026-05-27 20:24:25 -04:00
sandbox_cp.rs Model run sandbox lifecycle explicitly (#431) 2026-05-27 12:48:56 -04:00
sandbox_preview.rs refactor(types): remove legacy run summary shape 2026-05-10 23:29:41 -04:00
sandbox_ssh.rs fix(cli): repair verification failures 2026-05-09 18:07:24 -04:00
secret.rs refactor(auth): split credential sources and vault schemas (#306) 2026-05-18 11:07:42 -04:00
secret_list.rs refactor(auth): split credential sources and vault schemas (#306) 2026-05-18 11:07:42 -04:00
secret_rm.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
secret_set.rs refactor(auth): split credential sources and vault schemas (#306) 2026-05-18 11:07:42 -04:00
send_analytics.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
send_panic.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
server_start.rs refactor: rationalize server secret scopes (vault-only for optional int… (#401) 2026-05-25 17:26:01 -04:00
server_status.rs refactor(server): unify daemon runtime metadata 2026-04-22 16:07:52 -04:00
server_stop.rs refactor(test): promote shared server-lifecycle test helpers into fabro-test 2026-04-19 16:43:26 -04:00
start.rs Replace run-scoped sandbox config with named environments (#360) 2026-05-23 13:03:21 -04:00
support.rs Model run sandbox lifecycle explicitly (#431) 2026-05-27 12:48:56 -04:00
system.rs fix(system): expose unreadable run repair flow 2026-05-06 07:15:18 -04:00
system_df.rs fix(server): count whole storage tree in Fabro-managed bytes 2026-05-21 11:28:39 -04:00
system_events.rs refactor(cli): finish command context cleanup 2026-04-23 07:14:32 -04:00
system_info.rs refactor(cli): finish command context cleanup 2026-04-23 07:14:32 -04:00
system_prune.rs test(cli): trim slow integration fixture setup 2026-04-28 19:14:56 -07:00
system_repair.rs fix(runs): repair deletion of unreadable runs 2026-05-09 17:45:55 -04:00
test_panic.rs test: speed up slow default-profile tests and tighten nextest thresholds 2026-04-05 13:15:59 -04:00
top_level.rs feat(cli): show curated landing output for bare fabro 2026-04-17 08:59:03 -04:00
unarchive.rs feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
uninstall.rs refactor(server): unify daemon runtime metadata 2026-04-22 16:07:52 -04:00
upgrade.rs feat(cli): render fatal errors with miette 2026-04-24 15:35:57 -04:00
validate.rs feat(template): resolve template error locations (#333) 2026-05-20 20:15:04 -04:00
variable.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
variable_get.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
variable_list.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
variable_rm.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
variable_set.rs Add fabro variable CLI namespace for server-managed variables (#434) 2026-05-27 13:57:25 -04:00
version.rs feat(cli): add fabro version command 2026-04-14 16:30:53 -04:00
wait.rs fix: stabilize attach JSON timing snapshot (#385) 2026-05-24 13:09:09 -04:00
worker_auth.rs refactor: rationalize server secret scopes (vault-only for optional int… (#401) 2026-05-25 17:26:01 -04:00
workflow.rs fix(workflow): ignore deprecated project directory 2026-05-09 10:55:56 -04:00
workflow_create.rs fix(workflow): ignore deprecated project directory 2026-05-09 10:55:56 -04:00
workflow_list.rs feat(cli): render fatal errors with miette 2026-04-24 15:35:57 -04:00