Skip to content

A save() that takes the state lock over logs nothing, so a stale window overwriting a newer state.json cannot be traced #1041

Closed

Description

@Birfy

Owner: Dev3

Found while landing #1027 / PR #1032 (review comment: #1032 (comment)).

Reproduce

refresh() prints a line when it takes the lock over from a host that has closed (core/src/host/store.js:400-408, "the other dsh has closed; this one now saves the Bot team"). The save() path added in #1027 takes the lock over through the same claimLock() (:434-441) but prints nothing at all, and warnReadOnly() (:410) is only reached when the takeover fails.

Why it matters

The case #1027 fixes is exactly "a window that showed the Bot team read-only writes over a state.json another window has updated meanwhile". When that happens the write is silent: there is no line saying a takeover occurred, which pid/host held it before, or that the file on disk had changed since this window's last read. A user reporting lost data has nothing to grep for, and we cannot tell a legitimate takeover from a stale window that overwrote a newer file.

Acceptance

  • a save() that takes the lock over from a holder that has closed emits exactly one line naming the previous holder's pid and host (same shape as the refresh() line, or a distinct wording — the repository is English);
  • the line is asserted by a test in core/test/home-lock.test.js (capture the logger/warn sink the same way the existing #14 read-only test does);
  • the successful path stays quiet when this window already held the lock, and a live holder still returns it read-only (Read-only host: flybot/* reads rejected, social timer ignores writer lock (PR #2 review) #14 unchanged).

Scope is the log line, not a change of behaviour.

Activity

  1. added
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    area:automationScheduled tasks and automation
    enhancementNew feature or request
    on Oct 25, 2026
  2. Birfy commented on Oct 25, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Triage

    Triage at main 1d5b5a5f: confirmed — refresh() logs the takeover (core/src/host/store.js:400-408), the save() path added in #1027 claims through the same claimLock() (:434-441) and logs nothing; warnReadOnly() (:410) only runs when the takeover fails. Acceptance as written. Small and local. Owner: Dev3.

  3. Birfy commented on Oct 25, 2026

    @Birfy
    CollaboratorAuthor

    Claimed. Branch dev3/fix/1041-takeover-log, cut from current main 1d5b5a5f.

    Plan: one log line in the save() takeover path (core/src/host/store.js:434-441), shaped like the refresh() one at :400-408 so the same text is greppable from both entry points; core/test/home-lock.test.js gets the assertion (same sink capture as the #14 read-only case). Quiet when this window already holds the lock; a live holder still returns read-only (#14 unchanged).

  4. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    and removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Oct 25, 2026
  5. removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:automationScheduled tasks and automationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions