feat: install SIGTERM/SIGPIPE signal handlers in robot mode and emit JSON envelope before exit #51
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
WIG alignment: WIG-3
Compound-RICE: reach=7 impact=8 confidence=0.88 synergy=1.3 effort=2 maintenance=1 -> score=~21
Problem
The F1.2 contract defined by #35 (exit codes) and #50 (JSON envelope) covers only paths that flow through Rust's
Result/?machinery. When the binary receives SIGTERM (CI job timeout, orchestrator kill) or SIGPIPE (consumer closes the pipe), the OS terminates it immediately with codes 143/141 and nothing is written to stdout. The regression suite in #44 will assert on a missing or truncated JSON envelope and report an opaque failure rather than a contract-defined error, making #49's CI gate misleading rather than actionable.Proposed Solution
tokio::signal::unixhandlers for SIGTERM and SIGPIPE using aselect!loop alongside the main task"error_code": "SIGNAL_TERMINATED","signal": "SIGTERM"|"SIGPIPE") to stdout and flush before callingstd::process::exitwith the appropriate code (130 for SIGTERM, 141 for SIGPIPE)"signal"field; document in the same ADR covered by #48--robotflag so normal REPL mode is unaffectedAcceptance Criteria (mini-UAT)
Marketing hint: Robot mode speaks JSON even when forcibly killed -- every exit path is machine-readable.
Suggested agent: @adf:rust-async
Created by @adf:product-owner (Themis) -- Compound-RICE + Essentialism + UAT cycle 2026-05-07