Skip to content

[auto] #77 phase 3: detailed tt runs inspection for a single run - #99

Merged
nutt-adam merged 3 commits into
mainfrom
auto/issue-77-20260321063208
Mar 20, 2026
Merged

[auto] #77 phase 3: detailed tt runs inspection for a single run#99
nutt-adam merged 3 commits into
mainfrom
auto/issue-77-20260321063208

Conversation

@nutt-adam

@nutt-adam nutt-adam commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Automated SDLC cycle for #77.

  • planner: completed
  • implementation: completed
  • tests: updated
  • docs/changelog: updated
  • version: bumped if required

Summary by CodeRabbit

Release Notes

  • New Features
    • Added runs command to inspect SDLC run history with two subcommands
    • runs list displays all tracked runs
    • runs show provides detailed run view including steps table with execution status, duration, and agent scope, plus intelligent next-action recommendations based on step outcomes

Tutti Automation and others added 2 commits March 21, 2026 06:34
…n guidance

Add Runs subcommand (list/show) to CLI, refactor show() to display
ordered step table with status/duration/agent/failure columns, and
derive actionable next-step guidance for operators.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces a new runs CLI subcommand hierarchy to inspect SDLC run history. It adds a Commands::Runs variant with nested List and Show subcommands, extends the run ledger record with metadata fields (failure class, step tracking), implements step data loading from disk, and renders detailed run inspection output including step tables and next-action recommendations.

Changes

Cohort / File(s) Summary
CLI Command Structure
src/cli/mod.rs, src/main.rs
Introduced new Commands::Runs top-level subcommand with nested RunsSubcommand enum (List, Show { run_id }). Updated main command dispatch to route to cli::runs::list() and cli::runs::show(run_id) handlers.
Run Inspection Implementation
src/cli/runs.rs
Implemented show(run_id) to load and render per-run step data with step index/id/type, computed status (success/failed/timed_out/pending), derived duration, agent scope, and failure messages. Added derive_next_action() and format_duration_ms() helpers; updated output to use as_deref()/unwrap_or() for optional fields; added unit tests for duration formatting and next-action logic.
State & Data Model
src/state/mod.rs
Extended SdlcRunLedgerRecord with new optional/required fields: failure_class, current_step_id, last_successful_step_id, resume_eligible, and active_agents. Added public load_run_steps(project_root, run_id) function to load and deserialize workflow step intent records from disk, sorted by step index. Updated existing tests to populate new fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • wren-nutthouse

Poem

🐰 A runs command hops into view,
Step-by-step tales, now crystal clear,
Next actions whispered, old and new,
The ledger speaks what all hold dear! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete; critical sections from the template are missing (Versioning checkboxes, SemVer choice, Version number, Validation steps, Release planning). Complete all required template sections including versioning choices, SemVer selection, specific version number, and validation/release checkboxes.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding detailed inspection capability for a single run within the 'tt runs' command implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch auto/issue-77-20260321063208

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/cli/runs.rs (2)

168-197: Consider clarifying the failing-step + resume-eligible interaction.

The logic prioritizes inspection of failing steps over the resume suggestion. This is sensible (inspect failures before retrying), but the output doesn't inform the user that a resume is also available.

Consider enhancing the failing-step case to mention resume eligibility when applicable:

♻️ Optional enhancement
     if let Some(step) = failing_step {
         let agent = step.intent.get("agent_scope").and_then(|v| v.as_str());
+        let resume_hint = if ledger.resume_eligible {
+            format!(" (resume with: tt run --resume {})", ledger.run_id)
+        } else {
+            String::new()
+        };
         if let Some(agent_name) = agent {
             return format!(
-                "Inspect agent '{}' transcript for step '{}'",
-                agent_name, step.step_id
+                "Inspect agent '{}' transcript for step '{}'{}",
+                agent_name, step.step_id, resume_hint
             );
         }
-        return format!("Inspect step '{}' output", step.step_id);
+        return format!("Inspect step '{}' output{}", step.step_id, resume_hint);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli/runs.rs` around lines 168 - 197, derive_next_action currently returns
a message to inspect a failing step but omits that the run may also be
resume-eligible; update the failing-step branch in derive_next_action to append
or include a short note when ledger.resume_eligible is true (e.g., " — run can
be resumed with: tt run --resume <run_id>") so users are informed of both the
failure and the resume option; locate the failing_step handling that formats
messages using step.step_id and step.intent (agent_scope) and conditionally add
the resume hint using ledger.run_id and ledger.resume_eligible.

292-306: Test coverage could be expanded for derive_next_action.

The current tests cover the success and resume-eligible paths, but additional coverage for failing and pending step scenarios would strengthen confidence:

♻️ Suggested additional tests
#[test]
fn derive_next_action_failing_step() {
    use crate::state::{WorkflowStepIntentRecord, WorkflowStepOutcomeRecord};
    
    let ledger = stub_record(None);
    let steps = vec![WorkflowStepIntentRecord {
        run_id: "test".to_string(),
        workflow_name: "test".to_string(),
        step_index: 0,
        step_id: "step-fail".to_string(),
        step_type: "command".to_string(),
        planned_at: Utc::now(),
        intent: serde_json::json!({}),
        attempt: 1,
        outcome: Some(WorkflowStepOutcomeRecord {
            completed_at: Utc::now(),
            status: "failed".to_string(),
            success: false,
            exit_code: Some(1),
            timed_out: false,
            message: Some("error".to_string()),
            side_effects: None,
        }),
    }];
    assert!(derive_next_action(&ledger, &steps).contains("Inspect step"));
}

#[test]
fn derive_next_action_pending_step() {
    use crate::state::WorkflowStepIntentRecord;
    
    let ledger = stub_record(None);
    let steps = vec![WorkflowStepIntentRecord {
        run_id: "test".to_string(),
        workflow_name: "test".to_string(),
        step_index: 0,
        step_id: "step-pending".to_string(),
        step_type: "command".to_string(),
        planned_at: Utc::now(),
        intent: serde_json::json!({}),
        attempt: 0,
        outcome: None,
    }];
    assert!(derive_next_action(&ledger, &steps).contains("still in progress"));
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli/runs.rs` around lines 292 - 306, Add two unit tests for
derive_next_action: one that constructs a failing step using
WorkflowStepIntentRecord with an associated WorkflowStepOutcomeRecord (status
"failed", success false, exit_code Some(1), message Some(...)) and asserts the
returned string contains "Inspect step", and another that constructs a pending
step (WorkflowStepIntentRecord with attempt 0 and outcome None) and asserts the
returned string contains "still in progress"; place them alongside
derive_next_action tests (use stub_record(None) as the ledger and import
crate::state::{WorkflowStepIntentRecord, WorkflowStepOutcomeRecord} and Utc
timing helpers) so the failing and pending branches are covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/cli/runs.rs`:
- Around line 168-197: derive_next_action currently returns a message to inspect
a failing step but omits that the run may also be resume-eligible; update the
failing-step branch in derive_next_action to append or include a short note when
ledger.resume_eligible is true (e.g., " — run can be resumed with: tt run
--resume <run_id>") so users are informed of both the failure and the resume
option; locate the failing_step handling that formats messages using
step.step_id and step.intent (agent_scope) and conditionally add the resume hint
using ledger.run_id and ledger.resume_eligible.
- Around line 292-306: Add two unit tests for derive_next_action: one that
constructs a failing step using WorkflowStepIntentRecord with an associated
WorkflowStepOutcomeRecord (status "failed", success false, exit_code Some(1),
message Some(...)) and asserts the returned string contains "Inspect step", and
another that constructs a pending step (WorkflowStepIntentRecord with attempt 0
and outcome None) and asserts the returned string contains "still in progress";
place them alongside derive_next_action tests (use stub_record(None) as the
ledger and import crate::state::{WorkflowStepIntentRecord,
WorkflowStepOutcomeRecord} and Utc timing helpers) so the failing and pending
branches are covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 859ecad0-0384-433c-8650-a3fe9b448473

📥 Commits

Reviewing files that changed from the base of the PR and between b8b5978 and c1bc1d1.

📒 Files selected for processing (4)
  • src/cli/mod.rs
  • src/cli/runs.rs
  • src/main.rs
  • src/state/mod.rs

@nutt-adam
nutt-adam merged commit e61113b into main Mar 20, 2026
11 checks passed
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.

1 participant