Skip to content

One truncated run-meta.json aborts end-of-batch stats before batch-summary.json is written; metadata writes are not atomic #303

Description

@reacher-z

Two cheap robustness gaps around run metadata:

1. One corrupt run-meta.json crashes end-of-batch stats. src/clawbench/runner/batch.py:451 does an unguarded json.loads(meta_file.read_text()) inside print_run_stats, which runs at batch.py:753before write_summary_json at :754. So a single malformed metadata file throws after a multi-hour batch, and batch-summary.json is never written at all.

2. The tool can produce that corrupt file itself. run_support/metadata.py:286-288 writes with a plain write_text (no temp file + rename). A run killed mid-write — and batch.py:338/:701 do SIGKILL on double Ctrl+C — can leave truncated JSON on disk.

Together: interrupt a batch, resume it, and the resumed batch can die at the summary step because of a file the previous interrupt truncated.

Ask:

  1. try/except (json.JSONDecodeError, OSError) per run directory in print_run_stats — skip and warn, never abort the summary.
  2. Make write_run_meta atomic (NamedTemporaryFile in the same directory + os.replace).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions