Skip to content

Harden post-crash logs: fatal catches, latest-run filtering, and incremental follow #670

Description

@carlospedreira

Context

PR #663 adds dotbot logs, --last, --follow, and crash-summary persistence. The initial implementation is being merged pragmatically; these known limitations are explicitly deferred from #657 and must be completed together so post-run diagnostics are correct and remain efficient on long-lived projects.

Scope

  • Persist .bot/.control/last-crash.json from caught fatal workflow/process failures, not only from the outer PowerShell crash trap.
  • Make default dotbot logs output represent the true latest workflow run by identifying run boundaries / run_id, while retaining explicit --tail N behavior.
  • Make dotbot logs --follow consume only appended bytes/events instead of rereading and splitting the full append-only activity log on every poll.

Acceptance criteria

Crash coverage

  • A fatal exception handled by the process-level catch writes a valid last-crash.json with reason, process/run identifiers, last task, and up to 20 recent per-process events.
  • The crash writer remains best-effort and cannot mask the original failure.
  • Tests cover both the existing outer-trap path and a caught fatal workflow/process failure.

Latest-run filtering

  • With multiple runs in activity.jsonl, default dotbot logs shows events belonging to the most recent run only.
  • A latest run longer than 50 events is not silently represented as an arbitrary project-wide tail unless that behavior is explicitly requested/documented.
  • Missing or malformed run-boundary events degrade predictably and are covered by tests.
  • --tail N remains available with clearly documented semantics.

Follow performance/regression

  • Follow mode tracks a byte offset or equivalent incremental reader and does not read the full historical file on each poll.
  • Append, truncation/replacement, partial final lines, and malformed JSONL entries are handled without duplicate output or a busy loop.
  • A performance regression test uses a large pre-existing activity log, appends a small number of events, and verifies work scales with appended data rather than total file size.
  • Existing Logs CLI, ProcessRegistry, and ProcessDispatch tests continue to pass on Windows, macOS, and Linux.

Dependency

Follow-up to #663 and #657. The integration must preserve the kill-on-close behavior merged in #660.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions