Skip to content

Improve core dumps: per-op sync steps, structured failures, and failure-only LLM/test traces #710

@vishalramvelu

Description

@vishalramvelu

Problem

When a PDD command fails, the debug snapshot saved to .pdd/core_dumps/ often lacks enough information to diagnose what went wrong. Example: pdd sync summarize_directory fails in a “5 consecutive fix operations” loop but the core dump may show:

  • errors: [] even though the run failed
  • steps has one opaque entry with missing/blank model
  • no per-attempt breakdown of sync operations
  • no test output for failed attempts
  • no LLM prompt/response context for “LLM keeps generating broken code” scenarios
  • terminal output contains ANSI noise

Goals

Make core dumps self-contained and actionable for debugging without reproduction, while keeping size reasonable and avoiding secret leakage.

Requirements

  • Core dump payload
    Bump/maintain schema_version and include:
    argv, cwd, platform, pdd_version, timestamp_utc
    global_options, invoked_subcommands, total_cost
    steps (top-level commands), errors (structured), file_contents, terminal_output
  • Top-level steps
    Ensure steps[*].model is never blank (default "unknown")
    If invoked_subcommands count exceeds returned results, still emit a step entry per command
  • Terminal output
    Strip ANSI escapes (CSI + OSC) before saving terminal_output
  • Sync operation visibility
    Auto-include .pdd/meta/_sync.log (JSONL) and .pdd/meta/_run.json in file_contents (size-capped)
    Ensure operation logs include duration so we can identify slow steps
    Expanded sync steps in core dump
    Add sync_steps derived from *_sync.log:
    one entry per operation row (skip type="event" rows)
    include: operation, success, cost (from actual_cost), model, duration, failure_summary, test_output_excerpt, source_log
  • Test output excerpts (failed attempts)
    For failed test runs (esp. those used to drive fix), capture combined stdout/stderr
    Store as details.test_output_excerpt on the relevant operation log entry
    Truncate to ~5KB with an explicit truncation marker
  • Structured logical failures (non-exception)
    If sync/fix loops terminate due to max retries, budget exhaustion, cycle detection, consecutive-op breaker, etc., record a structured entry in core dump errors:
    { command, type, message, details{ basename, language, counters/state } }
  • LLM trace (moderate, failure-only)
    For each failed operation, record the final prompt/messages sent and the raw LLM response
    Keep it bounded:
    only the last pair per operation
    only persisted on failure
    truncate prompt/response to reasonable limits (e.g. <= 20k chars each)
    redact obvious secrets/tokens
    Store on the operation log entry as details.llm_trace = { prompt, response, model }

Acceptance Tests

Add/extend unit tests to verify:

  • core dump has required fields + schema_version
  • steps[*].model never blank
  • ANSI stripping removes CSI+OSC
  • file_contents includes *_sync.log and *_run.json when present
  • sync_steps is populated from *_sync.log and includes source_log
  • logical failures generate structured errors[]
  • failed fix test runs attach truncated details.test_output_excerpt
  • failed operations attach details.llm_trace

Context

Related: #680 (Core Dump Fixes), #230 (add LLM model CSV to core dump), #391 (confusing error output in core dumps)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions