fix(gc): guard cleanup by observed generation - #125
Merged
myobie merged 1 commit intoJul 30, 2026
Conversation
agent-session-id: dev3.dotfiles-cos-misc-agent-runtime-simplification agent-tool: Codex agent-tool-version: 0.145.0 agent-model: gpt-5.6-sol agent-runtime-profile: /home/schickling/.config/coding-agents/profile.json agent-skills-manifest: /nix/store/nk9iml2841l1yjjg0f6f0d3y60zkg1nn-agent-skills-corpus/share/agent-skills/manifest.json tooling-profile: dotfiles@4a0515f
myobie
force-pushed
the
schickling-assistant/2026-07-30-generation-guarded-gc
branch
from
July 30, 2026 14:30
1bcc72b to
00e6738
Compare
myobie
changed the base branch from
schickling-assistant/2026-07-30-pure-session-observation
to
main
July 30, 2026 14:30
myobie
marked this pull request as ready for review
July 30, 2026 14:38
myobie
approved these changes
Jul 30, 2026
myobie
left a comment
Collaborator
There was a problem hiding this comment.
Approved exact head 00e6738. Independent patch walk confirms generation/legacy compare-and-swap semantics, stale-observation zero-mutation behavior, and lock ownership through bundled fallback publication. Focused 66/66 plus hosted Vitest/Nix are green.
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.
Problem
pty gcdecides from a session snapshot, but residual sweep and permanentrespawn previously called unowned
cleanupAll(name)later. A same-namereplacement created after the snapshot could therefore have its files removed
or be overwritten by the stale gc pass.
Goal
Cleanup and respawn apply only when the on-disk session is still the exact
generation that gc observed.
Decisions
replacement publication.
any intervening update suppresses the action.
failures. The next reconciliation pass observes the current generation.
generation-CAS hardening and its CLI-fallback lock handoff.
Verification
From the branch based directly on current main:
The focused regressions prove replacement generations suppress residual cleanup
and permanent respawn, unchanged legacy metadata permits cleanup, changed
legacy metadata suppresses cleanup, and bundled CLI fallback retains the CAS
lock through replacement socket publication.
Hosted checks at exact head
00e67384a0cd3b366ad1dbe8e33908d85d486b37:Complexity
One internal compare-and-swap cleanup primitive and one lock-held cleanup
helper centralize the ordering. Bundled CLI fallback receives a one-hop lock
owner PID, validates the live lock, and scrubs the control value before daemon
or session environment inheritance. No new dependency, daemon, or persisted
session field is introduced.
Concerns
Holding the per-name lock through
spawnDaemonintentionally serializessame-name creation until the replacement socket is published. Lock scope is
per session name, not fleet-wide.
Friction & bottlenecks
Node ESM module namespace exports cannot be spied on under Vitest. The tests
therefore exercise two explicitly internal, non-client-API CAS primitives
directly. No runtime bottleneck was observed.
Follow-ups
reap as a separate lifecycle-policy change; this PR intentionally covers
residual sweep and permanent respawn only.
References