You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tower owner-lock robustness: surface refusal in the CLI, graceful-shutdown same-address overlap, clear-owner escape hatch (follow-up to #1629) #1690
Follow-up to #1629's owner-lock guard (PR #1689), split per the gate ruling: the guard resolves the incident class (different-port second Tower hijacking a live production DB); three robustness items remain, deliberately deferred to keep the guard's scope bounded.
Surface the refusal in the CLI (most urgent).afx tower start daemonizes, so the guard's loud "another Tower owns this DB (pid X, port Y — did you mean CODEV_AGENT_FARM_DIR?)" error today reaches only tower.log; the user sees the generic 30s "failed to respond" timeout — indistinguishable from tower startup can hang unbounded and unlogged in killOrphanedShellpers, tripping the 30s launcher timeout (field report on 3.3.3) #1685's hang class. The launcher should detect the fast-exit + read the refusal out of the log (or a status file) and print it verbatim.
Graceful-shutdown same-address overlap (codex's remaining RC on Fix #1629: refuse a second Tower against a live global.db (owner lock) #1689): between the old Tower closing its listener and process.exit, a same-host:port restart passes the bindHost-matched shortcut and claims while the old owner lives. Low severity (graceful shutdown never deletes rows — the overlap is a transient handoff to a legitimate successor), but closing it correctly needs a pid-is-actually-a-tower identity check — and doing that without the opposite failure (claude's warning: refusing on a recycled pid wedges startup on a phantom owner) is why this is its own design item, coupled with:
An escape hatch: afx tower start --clear-owner (or afx tower clear-owner) for a wedged/phantom owner record, with the teaching error naming it.
Items 2+3 ship together or not at all — a stricter refusal without the hatch converts a rare overlap into a rare lockout.
Addition from PR #1689's lock-file rewrite (builder's recommendation, endorsed): item 2's real fix should explicitly evaluate a native flock lifetime-lock — a kernel-held lock on an open fd is released automatically on process death, which simultaneously solves (a) the stale-takeover unlink race (the residual accepted on #1689 — no dep-free filesystem CAS exists), (b) the graceful-shutdown same-address overlap (lock held until true process exit), and (c) the phantom-pid wedge (no stale files to wedge on). The cost is a native/optional dependency decision (node has no built-in flock) — which is the owner's call, and why it lives in this follow-up rather than the shipped guard.
Trivial rider for whichever lane takes this: tower-owner.ts:355's docstring still says "the active global.db's .lock sibling" — the code correctly returns .tower-owner (renamed for the SQLite dotfile-VFS collision). Doc-only, one line.
Activity
amrmelsayed commentedon Sep 16, 2026
Addition from PR #1689's lock-file rewrite (builder's recommendation, endorsed): item 2's real fix should explicitly evaluate a native flock lifetime-lock — a kernel-held lock on an open fd is released automatically on process death, which simultaneously solves (a) the stale-takeover unlink race (the residual accepted on #1689 — no dep-free filesystem CAS exists), (b) the graceful-shutdown same-address overlap (lock held until true process exit), and (c) the phantom-pid wedge (no stale files to wedge on). The cost is a native/optional dependency decision (node has no built-in flock) — which is the owner's call, and why it lives in this follow-up rather than the shipped guard.
amrmelsayed commentedon Sep 16, 2026
Trivial rider for whichever lane takes this:
tower-owner.ts:355's docstring still says "the active global.db's.locksibling" — the code correctly returns.tower-owner(renamed for the SQLite dotfile-VFS collision). Doc-only, one line.Fix #1691: surface tower owner-guard refusal in the CLI, not a 30s ti…
Fix #1691: harden startup-outcome wait per CMAP feedback