fabro/lib/crates/fabro-cli/tests/it/cmd
Bryan Helmkamp 41c47dbe12
fix(workflow): emit terminal run event from FINALIZE, not on_run_end
The `WorkflowRunCompleted` / `WorkflowRunFailed` event was emitted from
`EventLifecycle::on_run_end`, a callback the executor fires at the end of
the EXECUTE phase. But the run isn't done at that point — RETRO and
FINALIZE still need to run, and FINALIZE writes the meta branch's finalize
commit. Observers that treat the event as "done" (CLI attach, daemon SSE
consumers) could observe terminal state and act on it before the worker
flushed its remaining writes.

The recovery scenario test exposed this: it deletes the meta branch
right after `fabro run` returns, then asserts the branch is empty. On
loaded CI runners the worker's finalize commit landed after the delete,
recreating the branch and failing the assertion.

Move the terminal event emission to `pipeline::finalize::finalize`, after
`write_finalize_commit`. The lifecycle's `on_run_end` overrides for event
and git become empty (deleted — the trait already provides a no-op
default). Three pieces of cross-cutting state (`final_patch`,
`captured_artifact_count`, the dead `EventLifecycle` reads of
`last_git_sha`) only existed to ferry data from EXECUTE to the terminal
event; deleted those too. The aggregator collapses to a one-line
delegate to `hook.on_run_end`.

`write_finalize_commit` now takes the conclusion as a parameter and
injects it into the projection copy, since the terminal event hasn't run
through the run store yet when the meta branch is written.

`build_terminal_event` is `pub(crate)` so `test_support` helpers (which
stop at EXECUTE) can mirror the production payload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 17:48:56 -04:00
..
archive.rs refactor(run-status): unify tagged lifecycle states 2026-04-22 17:15:13 -04:00
artifact_cp.rs perf(cli): reduce slow integration test overhead 2026-04-07 22:57:45 -04:00
artifact_list.rs perf(cli): reduce slow integration test overhead 2026-04-07 22:57:45 -04:00
attach.rs refactor(auth): use per-run worker JWTs for subprocesses 2026-04-23 11:04:45 -04:00
auth.rs feat(auth): add CLI GitHub login and logout flow 2026-04-20 07:12:52 -04:00
config.rs refactor settings API entrypoints 2026-04-22 18:58:47 -04:00
create.rs Merge remote-tracking branch 'origin/main' 2026-04-22 21:18:50 -04:00
diff.rs refactor(scratch): remove store-backed diff and blob cache writes 2026-04-07 22:31:59 -04: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 chore(clippy): require reasons on allow attributes 2026-04-19 20:24:24 -04:00
dump.rs simplify: flatten commands/store/ after dump rename 2026-04-23 07:58:26 -04:00
exec.rs feat(cli): exit with code 4 on authentication-required failures 2026-04-21 23:34:21 -04:00
fabro.rs feat(cli): rename store dump to dump 2026-04-23 07:48:03 -04:00
fork.rs refactor: unify run vocabulary and metadata snapshot layout 2026-04-20 22:17:23 -04:00
graph.rs refactor: wire vendored Graphviz into fabro-graphviz, remove dot dependency 2026-04-13 22:46:29 -04:00
inspect.rs fix(status): align archive outcomes and clean lint drift 2026-04-22 17:55:07 -04:00
install.rs refactor(server): unify daemon runtime metadata 2026-04-22 16:07:52 -04:00
json_global.rs refactor(cli): finish command context cleanup 2026-04-23 07:14:32 -04:00
logs.rs refactor(auth): use per-run worker JWTs for subprocesses 2026-04-23 11:04:45 -04:00
mod.rs test(auth): backfill worker jwt regression coverage 2026-04-23 11:35:08 -04:00
model.rs lint(clippy): disallow blocking std::fs on Tokio paths 2026-04-19 17:22:21 -04:00
model_list.rs refactor(cli): separate local socket and storage defaults 2026-04-06 11:57:14 -04:00
model_test.rs fix(tests): make bulk_skip model test independent of local credentials 2026-04-15 11:22:02 -04:00
parse.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
pr.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
pr_close.rs refactor(cli): make run-adjacent commands server-only 2026-04-06 06:12:16 -04:00
pr_create.rs refactor: unify run vocabulary and metadata snapshot layout 2026-04-20 22:17:23 -04:00
pr_list.rs test: de-flake pr_list and full_http_lifecycle_cancel 2026-04-20 15:04:08 -04:00
pr_merge.rs refactor(cli): make run-adjacent commands server-only 2026-04-06 06:12:16 -04:00
pr_view.rs chore(clippy): require reasons on allow attributes 2026-04-19 20:24:24 -04:00
preflight.rs feat(template): unify workflow and config template syntax 2026-04-11 10:58:50 -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 refactor(server): lock down server secrets 2026-04-23 07:15:27 -04:00
render_graph.rs lint(clippy): disallow blocking std::io and std::net on Tokio paths 2026-04-19 16:06:02 -04:00
repo.rs refactor(config): move project state under .fabro 2026-04-11 12:55:46 -04:00
repo_deinit.rs refactor(config): move project state under .fabro 2026-04-11 12:55:46 -04:00
repo_init.rs lint(clippy): disallow blocking std::fs on Tokio paths 2026-04-19 17:22:21 -04:00
resume.rs lint(clippy): disallow blocking std::fs on Tokio paths 2026-04-19 17:22:21 -04:00
rewind.rs fix(status): align archive outcomes and clean lint drift 2026-04-22 17:55:07 -04:00
rm.rs refactor(run-status): unify tagged lifecycle states 2026-04-22 17:15:13 -04:00
run.rs refactor(auth): use per-run worker JWTs for subprocesses 2026-04-23 11:04:45 -04:00
runner.rs fix(workflow): emit terminal run event from FINALIZE, not on_run_end 2026-04-23 17:48:56 -04:00
sandbox_cp.rs lint(clippy): disallow blocking std::fs on Tokio paths 2026-04-19 17:22:21 -04:00
sandbox_preview.rs fix(cli): suppress preview open for JSON output 2026-04-23 07:29:37 -04:00
sandbox_ssh.rs refactor(cli): make run-adjacent commands server-only 2026-04-06 06:12:16 -04:00
secret.rs chore(clippy): require reasons on allow attributes 2026-04-19 20:24:24 -04:00
secret_list.rs feat: add typed secrets metadata and API 2026-04-12 12:47:08 -04:00
secret_rm.rs refactor(cli): deglobalize server and storage target flags 2026-04-05 16:06:42 -04:00
secret_set.rs feat(secret): accept secret value via stdin or interactive prompt 2026-04-15 07:34:33 -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 fix(server): cover secret boundary enforcement 2026-04-23 07:51:28 -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 refactor(run-status): unify tagged lifecycle states 2026-04-22 17:15:13 -04:00
support.rs Merge remote-tracking branch 'origin/main' 2026-04-22 17:59:59 -04:00
system.rs feat(system): add server-backed system commands 2026-04-06 16:10:06 -04:00
system_df.rs lint(clippy): disallow blocking std::fs on Tokio paths 2026-04-19 17:22:21 -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): narrow system prune coverage for speed 2026-04-07 23:42:15 -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 refactor(run-status): unify tagged lifecycle states 2026-04-22 17:15:13 -04:00
uninstall.rs refactor(server): unify daemon runtime metadata 2026-04-22 16:07:52 -04:00
upgrade.rs lint(clippy): disallow blocking std::fs on Tokio paths 2026-04-19 17:22:21 -04:00
validate.rs refactor(cli): separate local socket and storage defaults 2026-04-06 11:57:14 -04:00
version.rs feat(cli): add fabro version command 2026-04-14 16:30:53 -04:00
wait.rs fix(status): align archive outcomes and clean lint drift 2026-04-22 17:55:07 -04:00
worker_auth.rs chore: fix nightly clippy lints on worker jwt branch 2026-04-23 12:08:55 -04:00
workflow.rs test(cli): refresh list output expectations 2026-04-14 11:30:34 -04:00
workflow_create.rs lint(clippy): disallow blocking std::fs on Tokio paths 2026-04-19 17:22:21 -04:00
workflow_list.rs test(cli): refresh list output expectations 2026-04-14 11:30:34 -04:00