Files
Conor Luddy fe99cee12d fix: append-only JSONL for auto_samples to remove read-modify-write race
Closes #81.

The worker's auto-sample stash previously wrote auto_samples.json as a
read-modify-write of an aggregate dict, with no locking. Under
concurrent stashes (busy worker, many distinct fingerprints) one stash
could clobber another's writes.

Switch to auto_samples.jsonl: append-only, one record per line, fsync on
each write. Mirrors the events.jsonl discipline.

- SessionStore.stash_auto_sample(session_id, fingerprint, sample) — appends
- SessionStore.read_auto_samples(session_id) — reduces last-write-wins per fp
- HangBuster._stash_auto_sample now delegates to the store; no local I/O

Tests: 5 new in tests/test_hang_sessions.py covering basic append, last-write-wins,
missing-file, 50-thread concurrent stash, and corrupt-line skip.

Verification: ruff/black clean; 93 passed (88 → 93).
2026-05-23 10:12:33 +01:00
..