opencode-mission-control icon indicating copy to clipboard operation
opencode-mission-control copied to clipboard

feat: Persistent run history and ledger

Open nigel-dev opened this issue 9 months ago • 0 comments

Description

Once a plan completes (or fails), all operational context is lost. There is no way to review past runs, compare performance across plans, or perform post-mortem analysis on failures. A persistent run history would enable learning from past executions.

Use Case

  • Post-mortem analysis: "Why did last Tuesday's plan fail?" — currently impossible to answer.
  • Performance tracking: How long do similar plans take? Are merge conflicts becoming more frequent?
  • Failure patterns: Which jobs fail most often? Which file paths cause the most merge conflicts?
  • Audit trail: For teams, a record of what was orchestrated and when.

Proposed Solution

Storage format

Create a .mc/history/ directory (or under the existing MC state directory) with JSONL files:

~/.local/share/opencode-mission-control/{project}/history/
  runs.jsonl          # One line per plan/standalone run
  events.jsonl        # Granular events (job start, merge, fail, etc.)

Run record schema

interface RunRecord {
  id: string;              // plan ID or job ID
  type: 'plan' | 'job';
  name: string;
  status: 'completed' | 'failed' | 'cancelled';
  startedAt: string;
  completedAt: string;
  duration: number;        // ms
  jobs?: {
    name: string;
    status: string;
    duration: number;
    branch: string;
    mergeResult?: 'success' | 'conflict' | 'test-failed';
    filesChanged?: number;
  }[];
  mergeConflicts?: string[];  // file paths
  error?: string;
}

Integration points

  • Write run record when a plan completes/fails/is cancelled (orchestrator.ts)
  • Write run record when a standalone job completes (monitor.ts or cleanup.ts)
  • Add mc_history tool to query past runs
  • Surface recent history in mc_overview

Retention

  • Keep last 100 runs by default (configurable).
  • JSONL format allows simple append + periodic truncation.

Files Involved

  • src/lib/orchestrator.ts — write history on plan completion
  • src/lib/monitor.ts — write history on standalone job completion
  • New: src/lib/history.ts — history read/write logic
  • New: src/tools/history.ts — mc_history tool
  • src/tools/overview.ts — surface recent history

Additional Context

From the master audit report (Section 9: Phase 2 roadmap): "Persistent run ledger (.mc/history/*.jsonl)." This is a new capability with no existing implementation.

nigel-dev avatar Feb 12 '26 03:02 nigel-dev