Skip to main content

Module trace

Module trace 

Source
Expand description

CLI-native JSONL command trace (gh#85).

Appends one JSON line per invocation to a per-agent, per-day file under traces/ (next to config.json, override with TASKFAST_TRACE_DIR). The line’s corr is the server x-request-id, the join key back to mix taskfast.trace <task_id>.

Redaction is the whole point. The CLI holds keystores, wallet passwords and signed payloads, so the record is a strict allowlist: subcommand path (never flag values), the server correlation id, response-derived ids, the exit class, and a stable error category (never a free-form message). A new field is opt-in by construction — nothing reaches disk unless added here.

Writing is best-effort: any failure is logged at debug and swallowed so the trace can never change a command’s outcome.

Structs§

TraceRecord
One redaction-safe trace line. Field order mirrors the AgentTrace vocabulary so server- and CLI-emitted lines align.

Functions§

emit
Emit a trace line for one invocation. Best-effort: never propagates errors.
enabled
Whether tracing is on. On by default; --no-trace or TASKFAST_TRACE in {0,false,off,no} turns it off.
subcommand_path
Walk clap’s matched subcommand names into a space-joined path. This reads only subcommand names, never argument values — that is the redaction guarantee for op: escrow sign --wallet-password X yields escrow sign.
take_corr
Take the last-captured server correlation id (x-request-id), if any. Consumes it — the caller must take it exactly once per invocation and share the value between the trace line and the stdout envelope (gh#91), since a second take always sees None.