* Persist the dream stage result with read-modify-write semantics. * * Dream runs AFTER the sync lock releases, so a sibling worktree may have * written newer state in the meantime. Overwriting the whole file with our * pre-dream snapshot + dream result would clobber that sibling's sync. Instead
(dream: StageResult)
| 1449 | * merge is what prevents the clobber.) |
| 1450 | */ |
| 1451 | function mergeDreamIntoState(dream: StageResult): void { |
| 1452 | const fresh = loadSyncState(); |
| 1453 | const others = (fresh.last_stages || []).filter((s) => s.name !== "dream"); |
| 1454 | fresh.last_stages = [...others, dream]; |
| 1455 | fresh.last_sync = new Date().toISOString(); |
| 1456 | saveSyncState(fresh); |
| 1457 | } |
| 1458 | |
| 1459 | // ── Output ───────────────────────────────────────────────────────────────── |
| 1460 |
no test coverage detected