Repository navigation
fix(chat): prevent stale attachment metadata writes - #1259
Conversation
Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 4:38 AM ET / 08:38 UTC. ClawSweeper reviewWhat this changesThe PR versions local chat attachment-metadata saves so an older snapshot cannot overwrite newer completed-send metadata on disk. Merge readinessKeep open. Current main still permits an older attachment snapshot to write after a newer one, while this focused patch versions mutations and rejects that stale final write; the collaborator-authored work is actively landing and has a deterministic regression test. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherThe native Tray chat provider records attachment metadata after a completed send and persists it to a local JSON cache. Later chat history restoration reads that cache to associate local attachment details with messages. flowchart LR
A[Completed chat send] --> B[Attachment metadata cache]
B --> C[Versioned snapshot]
C --> D[Stale-write check]
D --> E[Atomic JSON cache]
E --> F[Chat history restore]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the versioned attachment writer and land it once the exact-head full Tray validation confirms the focused race fix integrates cleanly. Do we have a high-confidence way to reproduce the issue? Yes, from source. On the base revision, two concurrent saves can snapshot different cache states, and the older snapshot can acquire the writer gate last and overwrite the newer cache file. Is this the best way to solve the issue? Yes. A monotonic per-mutation version with a final gated recheck directly prevents the source-proven last-stale-writer race without holding the metadata lock during serialization or disk I/O. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4c078f9ee5f9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Summary
AttachmentMetadata_ConcurrentSavesPreserveEveryCompletedSenddeterministic by pausing the older snapshot until the newer save completes, then verifying both completed sends remain on disk.Validation
./build.ps1: passed.dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 3,819 passed, 32 skipped.dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore: 1,022 passed.AttachmentMetadata_ConcurrentSavesPreserveEveryCompletedSend: 25/25 passed before the final rebase and 10/10 passed on the current head.OpenClaw.Tray.Testswas attempted twice. The runner hung without a test failure summary and the second diagnostic run was externally stopped. Hosted CI remains the full-suite proof.python .agents\skills\autoreview\scripts\autoreview --mode local --engine codex --model gpt-5.6-sol --thinking high --stream-engine-output: clean, no accepted or actionable findings, overall confidence 0.94.Real behavior proof
The deterministic regression test captures attachment save version 1, blocks it after snapshot capture, completes version 2 with both sends, and then releases version 1. The stale version 1 writer is rejected and the persisted JSON retains both
first.pngandsecond.png.PR #1205 dependency
PR #1205 must merge this fix from
mainafter this PR lands, then rerun its GitHub CI. This PR does not merge #1205 or itself.