Conversation
…regression Concurrent `mem ingest qoder` processes for the same transcript shared a single `.tmp` staging path and committed unconditionally, so a delayed writer could overwrite a newer LastLine with an older value. Add a per-checkpoint OS-backed advisory lock (flock on Unix, LockFileEx on Windows, fcntl on AIX) that spans the read/merge/write sequence, replace the shared staging name with a unique same-directory CreateTemp file, and retain the highest successfully committed cursor under the lock. The OS releases the lock on process exit, so a crash cannot orphan it. Refs bytefolk#139
|
Closing under the fork-workflow decision recorded on 2026-09-03: repository A second attempt at the same fix as #141, also from a fork, so it cannot be The commits are not lost. A closed fork PR keeps its head ref: git fetch https://github.com/bytefolk/mem.git refs/pull/155/head:pr-155Every file in this branch was therefore available to the re-doing work, whether |
|
Closing as a content duplicate of #140. Mechanical finding, not a judgement on the work. Diffed head-to-head against
So the "prevent LastLine regression" in the subject line describes behaviour #140 already implements and already tests — there is no additional fix here, only the explanatory comments stripped out. Also worth noting: this head has zero check runs (fork PR at |
Tracking
Refs #139
Consumed requirement revision: #139 R1. This PR must not auto-close the issue; merge and product acceptance remain separate decisions.
Scope
Repairs only the local Qoder checkpoint persistence path on current
main. It adds a persistent per-checkpoint OS advisory-lock sidecar, merges competing writes under that lock without allowingLastLineor associated diagnostic state to regress, and replaces the shared*.tmpname with a unique private staging file plus sync and atomic rename.Traceability
flock/ AIXfcntl/ WindowsLockFileEx); staging uses same-directoryCreateTemp; an owner process exits throughos.Exitwhile holding the lock and a waiting writer proceeds after kernel release..lockand transient private temp files are added beside local state.Validation
go vet ./cmd/mem/...,gofmt,go build -trimpath ./cmd/mem/...pass.TestSaveQoderCheckpointKeepsHighestLastLineAcrossIndependentProcesses,TestSaveQoderCheckpointSerializesAndRecoversAfterOwnerExit.go test -race -count=1pass.go test ./...full suite passes.Risk / rollback
The lock is advisory and applies only to participating
memcheckpoint writers on a filesystem with normal OS locking semantics. A live writer can block a later save rather than allowing unsafe lock stealing; existing caller behavior reports a checkpoint-save error and does not advance the cursor. Revert this PR to restore the prior writer. No remote API, transcript format, release artifact, dependency, or repository-setting change is included.