Skip to main content

Module agent_result

Module agent_result 

Source
Expand description

Agent completion detection — parses DEVFLOW_RESULT markers and evaluates exit codes to determine whether a coding agent succeeded or failed.

Four-layer decision engine: 0. Run operator-authored external post-condition probes (authoritative failure)

  1. Parse DEVFLOW_RESULT from agent stdout (authoritative for ordinary plans)
  2. Exit code + commit count gate (reliable fallback)
  3. Process gone + commits exist (last resort warning)

Structs§

AgentResult
Parsed agent completion result.
IdleTimeoutCommit
One commit the agent made before its stream went silent (D-07, 31-02).
IdleTimeoutRecord
The pipe-owning monitor’s authoritative idle-timeout verdict, as written to idle_timeout_path BEFORE the child is terminated (D-05, 31-02).

Enums§

AgentStatus
Agent completion status determined by DevFlow.
ResultError
Errors produced by agent result evaluation.
Verdict
The Validate stage’s self-reported verdict (13b verdict-vs-ran split).

Functions§

agent_pid_path
Path to the file where the monitor records the launched agent’s PID.
archive_phase_files
Archive the prior stage’s stdout/exit captures into bounded per-phase history instead of wiping them outright, so a false-positive self-report can be diagnosed after the fact (16b). Replaces the old cleanup_phase_files, which deleted these files unconditionally.
blocking_human_checkpoint_reported
Confirm whether captured stdout reports a human-blocking checkpoint, by searching for a **Gate:**-labeled line whose VALUE is exactly [HUMAN_GATE_VALUE] — see that constant’s doc comment for the live observation (2026-07-31) the matched rendering is built from.
capture_shows_rate_limit_denial
Read the monitor’s own idle-timeout verdict, if it wrote one.
checkpoint_reported_in_capture
Thin file-reading wrapper over blocking_human_checkpoint_reported: reads the phase’s captured stdout file (via stdout_path) and delegates. false for a missing capture file, never an error.
claude_session_id
Read the top-level session_id string from a Claude JSON result envelope (--output-format json). Returns None for plain-text stdout, a non-JSON-object envelope, an envelope with no session_id key, or a session_id of a non-string JSON type — never panics.
claude_stream_session_id
Read the CLI-emitted session_id from a Claude --output-format stream-json JSONL capture: the top-level session_id of the LAST system/init event. None for any other capture shape.
detect_rate_limit
Detect agent-specific rate-limit output and return the retry description.
evaluate_agent_result
Full four-layer evaluation: returns the best available AgentResult.
evaluate_layer1
Layer 1: Try to detect agent result from the native per-adapter envelope or the DEVFLOW_RESULT marker in stdout.
evaluate_layer2
Layer 2: Use exit code + commit count to determine result.
evaluate_layer3
Layer 3: Last resort — agent process is gone.
exit_code_path
Path to the exit code file for a given phase.
history_dir
Path to the archived-capture-history directory for a phase (16b).
idle_timeout_path
Path to the pipe-owning monitor’s idle-timeout verdict for a phase (D-05/D-06, 31-02).
monitor_log_path
Path to the pipe-owning monitor’s own log for a phase (Phase 31).
parse_devflow_result
Search stdout for a DEVFLOW_RESULT marker.
phase_commit_count
Commits on the phase’s feature branch that are not on develop.
phase_verification_exists
Whether /gsd-verify-work has produced a {phase:02}-VERIFICATION.md artifact for phase yet.
phase_verification_fingerprint
A content fingerprint of the phase’s {phase:02}-VERIFICATION.md, or None when no such artifact exists under evidence_root (999.79, 35-05).
phase_verification_mtime_nanos
The mtime of the same {phase:02}-VERIFICATION.md phase_verification_fingerprint hashes, in nanoseconds since the Unix epoch, or None when no such artifact exists under evidence_root.
prompt_path
Path to the file holding the stage prompt handed to the pipe-owning monitor (Phase 31).
session_id_from_capture
Thin file-reading wrapper over the two session-id readers: reads the phase’s captured stdout file (via stdout_path) and delegates. None for a missing capture file, never an Err — mirrors evaluate_layer1’s lossy-read convention (CR-01: one invalid UTF-8 byte from raw sh redirection must not silently disable this reader).
stderr_path
Path where the agent’s stderr is captured for a given phase. Lives alongside stdout_path under .devflow/.
stdout_path
Path to the stdout file for a given phase.
token_reported_in_capture
Whether a declared canary token came back inside a TOP-LEVEL result event of this capture (D-13).