fix: recover transcripts after interrupted writes - #222
Conversation
Tiny Sweeper reviewTiny Sweeper reviewed this change across 6 lane(s) and found 2 active actionable finding(s). Detailed lane evidence and any incomplete work are listed below. State: Changes requested Review snapshot
Completeness: Complete What changedThe review could not produce a supported behavioral summary; inspect the cited changed surface and lane details below. FeaturesNone identified with supported citations. TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. Findings
Resolved this pass
Before merge
How this fits togetherflowchart LR
n0["read_transcript<br/>changed"]:::changed
n1["read_transcript_jsonl<br/>changed"]:::changed
n2["...cord_is_skipped_without_losing_valid_rows<br/>changed"]:::changed
n3["new"]:::impacted
n4["path"]:::impacted
n5["meta"]:::impacted
n6["tempdir"]:::impacted
n7["codec"]:::impacted
n8["...rget_does_not_corrupt_its_own_destination"]:::impacted
n0 -->|calls| n1
n2 -->|calls| n0
n2 -->|tests| n0
n2 -->|calls| n6
n8 -->|calls| n0
n8 -->|tests| n0
n8 -->|calls| n3
n8 -->|tests| n3
n8 -->|calls| n4
n8 -->|tests| n4
n8 -->|calls| n5
n8 -->|tests| n5
n8 -->|calls| n6
n8 -->|calls| n7
n8 -->|tests| n7
classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Agent review detailscritique
security
tests
commits
description
e2e
Evidence and run details
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reached
This review includes 3 billable files and costs up to $0.75. Or wait 44 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Comment |
There was a problem hiding this comment.
Requesting changes: 1 lane(s) blocking, worst finding is high.
Fix or reply to the findings below and push. The next review clears this automatically once they are gone — you should not need to dismiss anything by hand.
$0.0053 · 187,310 in / 16,343 out · 12,510 cached (7%) · ladder/vectors, gpt-5.6-luna, deepseek-v4-flash · 624 embedded
critique: $0.0021 · 65,597 in / 4,345 out · 2,114 cached (3%) · gpt-5.6-luna
security: $0.0023 · 90,341 in / 1,367 out · 3,740 cached (4%) · gpt-5.6-luna
tests: $0.0004 · 17,552 in / 4,644 out · 4,608 cached (26%) · deepseek-v4-flash
description: $0.0003 · 8,892 in / 3,531 out · 2,048 cached (23%) · deepseek-v4-flash
There was a problem hiding this comment.
Requesting changes: 2 lane(s) blocking, worst finding is high.
Fix or reply to the findings below and push. The next review clears this automatically once they are gone — you should not need to dismiss anything by hand.
$0.0054 · 172,683 in / 36,912 out · 27,758 cached (16%) · ladder/vectors, gpt-5.6-luna, deepseek-v4-flash · 634 embedded
critique: $0.0014 · 44,374 in / 3,287 out · 4,228 cached (10%) · gpt-5.6-luna
security: $0.0021 · 67,087 in / 5,135 out · 5,610 cached (8%) · gpt-5.6-luna
tests: $0.0013 · 49,435 in / 17,403 out · 16,896 cached (34%) · deepseek-v4-flash
description: $0.0004 · 6,529 in / 7,157 out · 1,024 cached (16%) · deepseek-v4-flash
| // stops mid-write. Such a file exists but cannot be resumed at all. | ||
| // Publish the complete first generation only after staging it, and | ||
| // never replace a file another writer created meanwhile. | ||
| anyhow::ensure!( |
There was a problem hiding this comment.
Handle a competing first writer without failing the turn
When two concurrent sessions both create the same transcript file, the second writer now fails with an error instead of using the existing file. The prior behavior (overwriting) was bad, but failing the turn is also unacceptable: the turn should detect the race and continue writing into the existing file. The test suite does not cover this scenario.
[RULE] race-condition-handling ·
Summary
Recover a session after a process stops partway through a transcript write. A torn JSONL tail previously merged with the next append, making that later turn disappear from replay. A tail cut inside a multibyte character made the whole transcript unreadable.
_metaheader is never visible.API Or Behavior Changes
No public API change. Model-context, display, metadata, and usage readers now tolerate a damaged non-header record, including invalid UTF-8. A damaged first header still returns an error.
Tests
cargo fmt --manifest-path vendor/tinyagents/Cargo.toml --package tinyagents-session --check(from OpenHuman worktree)cargo test -p tinyagents-session --lib(163 passed)The new torn-append and invalid-UTF-8 regressions failed before the fix and pass afterward.
Documentation
Updated the reader and writer contract comments in code; no external API documentation changed.
Summary by CodeRabbit