Skip to content

feat(run): redirect firma run logs to run.log while agent TUI owns tty#292

Merged
luca-iachini merged 2 commits into
mainfrom
fir-433
Jul 14, 2026
Merged

feat(run): redirect firma run logs to run.log while agent TUI owns tty#292
luca-iachini merged 2 commits into
mainfrom
fir-433

Conversation

@luca-iachini

Copy link
Copy Markdown
Contributor

Why

While a wrapped agent's TUI owns the terminal, firma run's own tracing lines leak to stderr and corrupt the interface. Redirect them to a per-run log file for the session, then restore stderr for teardown. Closes FIR-433.

What Changed

  • Redirect the foreground (stderr) log surface to run.log in the per-run marker dir <runtime>/run/<sandbox_id>/run.log while the agent runs; restore stderr on exit.
  • Swappable Destination sink (Disabled/Stderr/RunLog) behind the compact layer; ANSI suppressed when redirected to a file.
  • log::init() returns a ForegroundLog handle (DI) instead of OnceLock globals; main passes it to services::run only. --log-file -> inert handle.
  • firma-run gains LaunchHooks around the tty-handoff and supplies the marker dir.
  • Docs: firma-run guide documents run.log location + per-session lifecycle.

Risks / Notes

  • Marker dir is removed on teardown -> run.log is a live per-session record, not
    a durable archive; use --log-file for a lasting log. Fail-closed behavior
    unchanged.
  • Includes an unrelated rust-1.96 elidable_lifetime_names clippy fix in
    firma-http (separate commit) that unblocks just check.
  • Cargo.lock catch-up (pasetors/tokio-stream from merged FIR-428) rides along.

AI Assistance

Authored with Claude Code (claude-opus-4-8).

…ippy

`clippy::elidable_lifetime_names` (default-deny under `-D warnings` in rust
1.96) rejected the explicit `'a` on the fuzz-only `Arbitrary` impl. Elide it.
Unrelated to FIR-433, but blocks `just check`.
@luca-iachini
luca-iachini requested a review from veeso July 13, 2026 16:57
@luca-iachini
luca-iachini marked this pull request as ready for review July 13, 2026 16:59
@luca-iachini
luca-iachini force-pushed the fir-433 branch 2 times, most recently from efef848 to 21147fc Compare July 13, 2026 17:23
…y (FIR-433)

While a wrapped agent's TUI owns the terminal, firma run's own tracing lines
corrupt it. Redirect the foreground (stderr) log surface to run.log in the
per-run marker dir <runtime>/run/<sandbox_id>/run.log (beside sidecar.log /
authority.log) once the agent is spawned, then restore stderr for teardown
output after it exits.

- Swappable Destination sink (Disabled/Stderr/RunLog) behind the compact
  stderr layer; ANSI color suppressed while redirected to a file.
- log::init() returns a ForegroundLog handle (dependency injection) instead of
  OnceLock globals; main passes it to services::run only. File mode (--log-file)
  yields an inert handle.
- firma-run exposes LaunchHooks fired around the tty-handoff and supplies the
  marker dir.
- Docs: firma-run guide documents run.log location and per-session lifecycle.

The marker dir is removed on teardown, so run.log is a live per-session record,
not a durable archive; use --log-file for a log that outlives the run.
@luca-iachini
luca-iachini merged commit 0bcdf44 into main Jul 14, 2026
15 checks passed
@luca-iachini
luca-iachini deleted the fir-433 branch July 14, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants