Skip to content

Stats: persisted failed_chunks is always 1; completed can exceed total #229

Description

@hydropix

Summary

The persisted failed_chunks count is always 1 regardless of how many chunks failed, and the live stats can report completed + failed > total because failed units are also counted as completed.

Where

  • src/core/adapters/generic_translator.py:215-229 (_record_failure passes failed_chunks=1), :271-285 (success reports completed_chunks: i + 1)
  • src/persistence/database.py:213-220 (update_job_progress sets progress['failed_chunks'] = 1, doesn't accumulate)

Details

_record_failure always passes failed_chunks=1, and update_job_progress overwrites rather than accumulates, so a job with 12 failed units persists failed_chunks: 1 — wrong in the resumable-jobs list and any post-resume accounting.

Separately, the success path reports completed_chunks: i + 1 (the absolute index), which counts previously failed units as completed. Example: unit 3 fails → failed=1, completed=3; unit 4 succeeds → completed=5, failed=1 for 5 processed units, so completed + failed > total is reportable.

Suggested fix

  • Accumulate failed_chunks (track a running count, or count the failed-index set), not a constant 1.
  • Report completed_chunks as the number of genuinely successful units, not the absolute loop index.

Found during the June 2026 repo audit. Severity: medium. Confidence: certain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — bounded impactaudit-2026-06Found during the June 2026 repo auditbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions