Skip to content

Evidence of legacy dot-lock writers (AGT-4024): a new src/taskState/legacyLockWriter.ts probe remembers the dot-lock tok - #967

Merged
unohee merged 1 commit into
mainfrom
goal/67-evidence-of-legacy-dot-lock-wr
Nov 21, 2026
Merged

unohee merged 1 commit into
mainfrom
goal/67-evidence-of-legacy-dot-lock-wr

Conversation

@unohee

@unohee unohee commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Milestone of an auto-claude run.

Check: (test -d node_modules || npm ci --prefer-offline --no-audit --no-fund) && npm run lint && npm run typecheck && grep -rqF 'records a dot-lock-only writer seen while holding the mutex' src && grep -rqF 'does not report a crashed dual-lock writer as a legacy writer' src && grep -rqF 'reports dot-lock-only writer evidence as a warning' src && test "$(wc -l < src/taskState/store.ts)" -le 1172 && npx vitest run src/taskState src/cli/doctor

Plan: .claude/auto-plan.md (local to the run).

…T-4024)

- New src/taskState/legacyLockWriter.ts. createLegacyWriterProbe is created
  once this process holds the SQLite mutex. It remembers the owner of the
  dot-lock it saw at EEXIST. It records evidence only when that lock later
  disappears (ENOENT, or openSync 'wx' succeeds) or carries a different
  token, and we did not reclaim it ourselves in between.
  - Only a live writer that takes no mutex can do that, which means a
    <=0.24.4 CLI. A crashed dual-lock writer's leftover never moves on its
    own, so it is never reported.
  - Evidence goes to <store>.legacy-writer.json through atomicWriteFileSync:
    firstSeenAt, lastSeenAt, and the released owner's pid and namespace.
  - It warns once per process. Every step is best effort and can never fail
    a lock acquisition or a store write.
- store.ts wires the four probe calls and exports getStorePath. It goes from
  1172 to 1171 lines. Locking, reclaim, staleness and buildLockPayload are
  unchanged.
- openswarm doctor gains a warn-only 'task-state lock' line (checkName
  task-state-lock). It names lastSeenAt when evidence exists, and otherwise
  says 'no dot-lock-only writer observed (absence is not proof)'. A check
  that cannot run reports ok with the reason and never fails doctor.
- Tests:
  - a real child process holding the dot-lock without the mutex records
    evidence (red when the probe calls are reverted);
  - a crashed writer's leftover (dead pid, or older than LOCK_ABANDON_MS)
    records none (red without reclaimedByUs);
  - an evidence-write failure does not fail upsertTaskState;
  - doctor's warn and ok cases.

Assumptions:
- The detection relies on the SQLite mutex excluding current writers. On a
  filesystem that does not honour fcntl locks (NFS, some virtiofs mounts),
  two current writers could be recorded; the doctor line and the module
  header say so.
- An operator removing the lock file by hand while a writer waits would be
  recorded too.
- The dual-lock release is 0.25.0 (#871 contains 5625efb). The remaining
  step, the CLI-floor decision and the dot-lock removal, is the operator's.
@unohee
unohee merged commit 5c72741 into main Nov 21, 2026
9 checks passed
@unohee
unohee deleted the goal/67-evidence-of-legacy-dot-lock-wr branch November 21, 2026 19:02
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