Skip to content

fix: stabilize concurrent trace snapshots - #6

Draft
Iams4kura wants to merge 1 commit into
mainfrom
agent/daily-improvements-20260813
Draft

fix: stabilize concurrent trace snapshots#6
Iams4kura wants to merge 1 commit into
mainfrom
agent/daily-improvements-20260813

Conversation

@Iams4kura

Copy link
Copy Markdown
Owner

What changed

  • Guard every in-process TraceStore accessor with the existing reentrant lock.
  • Capture record references as an immutable snapshot under the lock, then deep-copy outside the critical section.
  • Add a deterministic reader/writer regression test that freezes snapshot copying while another thread appends.

Why

TraceStore.append() updates the in-memory record index while holding _thread_lock, but records() iterated the same dictionary without that lock. A concurrent append could resize the dictionary mid-iteration and raise RuntimeError: dictionary changed size during iteration.

Impact

Readers now observe one stable same-instance snapshot. Large deep copies do not block appends after snapshot references are captured. On-disk JSONL format, cross-process flock behavior, and resume semantics are unchanged.

Validation

  • Regression reproduced before the fix.
  • TraceStore suite: 8 passed.
  • Concurrent regression: 20/20 local repetitions; 30/30 independent review repetitions.
  • make ci: Ruff and strict mypy; 245 tests passed with 11 optional Qwen tests deselected; 64 smoke evaluation units; 20 deterministic semantic canary repetitions; reproducible sdist/wheel and isolated installed-wheel contract.
  • Independent diff review found no blocking issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant