Skip to content

Zcode watchdog replacement can write its route after a signal exit handoff when it was waiting on the config lock #67

Closed

Description

@anuzzolilli-oss

(ai: anthropic/claude-fable-5-2)

Problem

Follow-up to #14 / PR #64. On SIGINT or SIGTERM the exit handoff does not wait for an in-flight watchdog tick. If that tick is replacing a dead proxy and is waiting for the config lock inside routeZcodeConfig, this can happen:

  1. The store still shows the old origin, so the exit handoff treats it as its own, reverts it (or hands it off) and stops. It never tries the new origin.
  2. The lock frees. The tick's write lands and routes the shared store to the proxy it just spawned.
  3. The process exits. The store is left routed by a session that no longer exists.

Evidence and limits

  • Checked on master a22daa7f4, Windows 11, Node v24.14.0.
  • Reproduced in a test only, by holding the config lock from the test and releasing it after the handoff returned. On unchanged master the store reads http://127.0.0.1:28787 at the moment exit is called; expected is no route.
  • Not observed on a real ZCode install. It needs both lock contention from another process and the write landing in the short gap between the handoff finishing and process.exit (the logger close). With a free lock the write happens without yielding and there is no window.
  • stdin EOF is not affected: it waits for the tick before the handoff.

Agreed fix (owner decision, 2026-11-14)

  • The signal path keeps not waiting for the tick.
  • routeZcodeConfig gets an optional check, asked while holding the config lock immediately before the write. The watchdog tick passes "shutdown has not begun". A declined write is a clean stop, not a watchdog error.
  • A proxy respawned during shutdown is left running. The tick does not route to it; the exit handoff routes the store to it only if replacement discovery reports it attachable. A test pins both outcomes through the discovery seam.

Accepted risks (owner decision, 2026-11-14)

Out of scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions