Repository navigation
feat(daemon): flock-only liveness, durable state with backup, checkpoints and crash recovery - #73
Merged
Merged
Conversation
write_private_file_durable keeps the previous file as <name>.bak (hard link), writes temp + fsync + rename and fsyncs the directory. read_with_backup falls back to the backup when the primary is missing, truncated or invalid, puts the good copy back and keeps the damaged one as <name>.corrupt. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ashed daemons - liveness.rs: daemon state comes from the lockfile flock (held = running, record without a holder = crashed, empty = stopped), so zombies and reused PIDs are never mistaken for a live daemon; kill(pid,0) also rejects zombies. - The lockfile is never unlinked (release/stop truncate the record under the lock), which removes the race where a concurrent starter lost its file. - acquire_lock no longer deletes sockets from a lock it does not hold; stale sockets are only removed after a refused connect. - spawn_daemon_in / spawn_background_daemon_for_session reap the child. - stop_daemon refuses to act on its own process instead of unlinking its own lock and socket while still running. - daemon.status / the daemon window report 'crashed' instead of 'locked'; daemon.* RPC resolves the runtime dir like the colon command does. - phase55_daemon_parity no longer locks and stops 'default' in the user's real runtime dir. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- wm/resilience.rs: debounced (750 ms) and periodic (30 s) checkpoints of the active session on layout, pane or cwd change; the UI thread only builds the snapshot, a worker serializes and writes <session>.ckpt. A <session>.running marker detects an unclean shutdown; the next start restores the last checkpoint and reports it. - :daemon start/stop run on a worker when a UI is attached and report through the tick, so the UI thread never waits on a daemon. - Session files carry format_version, are written durably with a .bak, and a corrupt or truncated file falls back to the backup with a message; a failed restore at startup is shown instead of silently starting fresh. - detach_client cancels and says why when the session cannot be saved; wording no longer implies programs keep running. - Journal writes/loads are durable and versioned and use one directory. - The session tree (reparenting) persists across restarts; the MCP reparent path reports rejected grafts (self, cycle, missing) instead of success. - session.save / session.restore over RPC share the colon command's function and default (the active session). - bilterm ctl auto-start retries on the socket the started daemon listens on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
src/secure_fs.rswrites state atomically with fsync and keeps a last-good backup. An older backup never replaces a newer saved layout.src/daemon/liveness.rs); pid files are no longer trusted. Children are reaped, and crashed daemons are shown as crashed.src/wm/resilience.rs.bilterm ctlauto-start used the wrong socket path; fixed insrc/main.rs.tests/phase55_daemon_parity.rsran against the user's real$XDG_RUNTIME_DIR/biltermand is now sandboxed.Not in this PR
Keeping programs alive across detach is a separate feature.
Note on running the gate
With
XDG_RUNTIME_DIRset to a very long path,phase51_1_tracingfails because ssh ControlMaster logs a path-length warning. That is an environment artifact: the same failure appears on the tmux branch (#74), which does not touch that code, and the test passes with a short path.Verification
./scripts/verify.sh: every stage passes exceptphase68_69_surface_parityandswarm_wiring. Both fail on unmodifiedmainand are fixed test-side in ci: six-cell OS/arch matrix, coverage gate, VT fuzz test, fix two stale swarm tests #71.scripts/check_classic_goldens.sh→GOLDENS OK 11🤖 Generated with Claude Code