Skip to content

feat(run): Add optional self-reflection summary after run completion #179

Closed

Description

@admarble

Summary

Add an optional --reflect flag to sequant run that analyzes the completed run and suggests improvements for future runs.

Problem

From verbose run review:

  • Run completed with pass/fail summary only
  • No analysis of what could be improved
  • No suggestions for workflow optimization
  • Patterns (e.g., spec taking same time for trivial vs complex issues) not surfaced

Current Output

Results: 3 passed, 0 failed
✓ #113: spec → exec → qa (9m 10s)
✓ #114: spec → exec → qa (10m 18s)
✓ #115: spec → exec → qa (15m 51s)

📝 Log: .sequant/logs/run-xxx.json

Proposed Output (with --reflect)

Results: 3 passed, 0 failed
✓ #113: spec → exec → qa (9m 10s)
✓ #114: spec → exec → qa (10m 18s)
✓ #115: spec → exec → qa (15m 51s)

📝 Log: .sequant/logs/run-xxx.json

┌─ Run Analysis ──────────────────────────────────────────────────┐
│                                                                 │
│  Observations:                                                  │
│  • #113 spec phase (2m 55s) similar to #115 (3m 37s) despite   │
│    10x complexity difference — consider fast-track for trivial  │
│  • All 3 issues ran same phases despite different requirements  │
│  • No browser testing ran despite #115 touching .tsx files      │
│                                                                 │
│  Suggestions for next run:                                      │
│  • Add `ui` label to component extraction issues                │
│  • Consider `--phases exec,qa` for simple fixes                 │
│  • Run `/solve` first to get phase recommendations              │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Acceptance Criteria

  • AC-1: Add --reflect flag to sequant run command
  • AC-2: Analyze phase timing patterns across issues
  • AC-3: Detect potential phase mismatches (e.g., .tsx without /test)
  • AC-4: Suggest workflow improvements based on patterns
  • AC-5: Output is concise (max 10 lines of suggestions)

Analysis Points

Pattern Detection Suggestion
Similar spec times for different complexity Compare title length/AC count to duration Consider solve analysis
.tsx files without /test Check diff for .tsx, check phases Add ui label
All issues same phases Compare recommended vs executed Use /solve or per-issue flags
Long QA times Duration > 5 minutes Check sub-agent spawning
Quality loop triggered Loop phase in results Consider complex label upfront

Priority

Low — Nice-to-have for workflow optimization. Not blocking correctness.

References

  • Run command: src/commands/run.ts
  • Metrics writer: src/lib/workflow/metrics-writer.ts
  • Existing /reflect skill: templates/skills/reflect/SKILL.md

Activity

  1. added
    enhancement
    on Jan 23, 2026
  2. added
    auto-ready
    ai-in-progress
    on Feb 16, 2026
  3. admarble commented on Feb 22, 2026

    @admarble
    ContributorAuthor

    Spec Plan — #179: Add optional self-reflection summary after run completion

    AC Quality Check

    ✅ All 5 acceptance criteria are clear and testable.

    Scope Assessment

    Metric Value Status
    Feature count 1 ✅
    AC items 5 ✅
    Directory spread 2 ✅

    Verdict: ✅ SCOPE_OK — Single focused feature with clear boundaries.

    Non-Goals

    • Historical trend analysis across multiple runs
    • AI-powered suggestions (just pattern matching)
    • Modifying run behavior based on analysis (read-only output)
    • Persistent reflection storage

    Acceptance Criteria

    AC-1: Add --reflect flag to sequant run command

    Verification Method: Integration Test

    Test Scenario:

    • Given: A completed run with results data
    • When: --reflect flag is passed
    • Then: Reflection analysis section appears after the summary output

    AC-2: Analyze phase timing patterns across issues

    Verification Method: Unit Test

    Test Scenario:

    • Given: Results with issues having varying spec/exec durations
    • When: analyzeRun() is called
    • Then: Observations about timing disparities are returned (e.g., similar spec times for different complexity)

    AC-3: Detect potential phase mismatches (e.g., .tsx without /test)

    Verification Method: Unit Test

    Test Scenario:

    • Given: RunLog with an issue that modified .tsx files but had no test phase
    • When: analyzeRun() is called
    • Then: Observation flagging missing test phase for .tsx changes is returned

    AC-4: Suggest workflow improvements based on patterns

    Verification Method: Unit Test

    Test Scenario:

    • Given: Results showing all issues ran identical phases, or loop was triggered
    • When: analyzeRun() is called
    • Then: Relevant workflow improvement suggestions are returned

    AC-5: Output is concise (max 10 lines of suggestions)

    Verification Method: Unit Test

    Test Scenario:

    • Given: Input data that generates many observations/suggestions
    • When: formatReflection() is called
    • Then: Output has ≤10 content lines (observations + suggestions combined)

    Implementation Plan

    Phase 1: Create reflection analysis module

    1. Create src/lib/workflow/run-reflect.ts with:
      • ReflectionInput / ReflectionOutput interfaces
      • analyzeRun(input) — orchestrates analysis
      • analyzeTimingPatterns() — compares phase durations across issues
      • detectPhaseMismatches() — checks fileDiffStats for .tsx without /test
      • suggestImprovements() — pattern-based workflow suggestions
      • formatReflection(output) — renders box-formatted output (max 10 lines)

    Phase 2: Wire into CLI and run command

    1. Add reflect?: boolean to RunOptions interface in src/commands/run.ts
    2. Add .option("--reflect", "Analyze run and suggest improvements") in bin/cli.ts
    3. After summary output (~line 3121), if mergedOptions.reflect is true:
      • Call analyzeRun() with results, issueInfoMap, logWriter?.getRunLog(), config
      • Print formatReflection() output

    Phase 3: Tests

    1. Add unit tests in src/lib/workflow/run-reflect.test.ts covering:
      • Timing pattern detection
      • Phase mismatch detection
      • Suggestion generation
      • Output truncation at 10 lines

    Data sources at integration point:

    • results: IssueResult[] — per-issue phase success/failure/duration
    • logWriter.getRunLog() — full RunLog with fileDiffStats, labels
    • issueInfoMap — issue titles and labels
    • config — run configuration (phases, qualityLoop)

    Feature Quality Planning

    Completeness: All 5 ACs map to implementation steps. Integration with existing run summary.

    Error Handling: Graceful fallback if logWriter is null (--no-log) — just skip fileDiff-based analysis. Never crash the run for reflection failures.

    Code Quality: Typed interfaces, follows existing workflow module patterns.

    Test Coverage: Unit tests for each analyzer + format output.


    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: disabled
    Reasoning: CLI/backend feature, no UI components. Pure logic with unit tests.

    Label Review

    Current: enhancement, auto-ready, ai-in-progress
    Recommended: enhancement, auto-ready, ai-in-progress, cli
    Reason: This is a CLI flag addition.

    → gh issue edit 179 --add-label cli

  4. added
    ai-in-progress
    and removed
    ai-in-progress
    on Feb 22, 2026
  5. added 3 commits that reference this issue on Feb 22, 2026
  6. admarble commented on Feb 22, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #179
    Status: READY_FOR_MERGE ✅

    Summary

    • AC: 5/5 met
    • Tests: 15/15 passed (run-reflect) + 94 passed (run.test)
    • Build: Passing
    • Lint: Clean (0 errors, 0 warnings)

    AC Coverage

    AC Description Status
    AC-1 Add --reflect flag to sequant run ✅ MET
    AC-2 Analyze phase timing patterns across issues ✅ MET
    AC-3 Detect potential phase mismatches ✅ MET
    AC-4 Suggest workflow improvements ✅ MET
    AC-5 Output concise (max 10 lines) ✅ MET

    Key Changes

    • src/lib/workflow/run-reflect.ts — analysis module with analyzeRun() and formatReflection()
    • src/lib/workflow/run-reflect.test.ts — 15 unit tests
    • src/commands/run.ts — wiring: import, reflect?: boolean in RunOptions, integration after summary
    • bin/cli.ts — .option("--reflect", ...)

    Iterations

    • Spec: 1 (pre-existing)
    • Exec: 1
    • QA: 1
    • Test loop: 0 (no UI)

    PR: #333 (merged)

  7. removed
    ai-in-progress
    on Feb 22, 2026
  8. added a commit that references this issue on Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-readyenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions