Skip to content

fix(session): a swept fork stays retired - #1969

Merged
santoshkumarradha merged 3 commits into
devfrom
fix/sweep-retires-once
Oct 26, 2026
Merged

santoshkumarradha merged 3 commits into
devfrom
fix/sweep-retires-once

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Every launch's startup sweep asked furrow about the same two landed forks and logged "retired" again. The laptop's sweep.log shows the pair at every launch for days.

Cause:

  • A kept conversation's tasks.json keeps groundUniverse and merge: merged on a landed node forever.
  • retireCheckpointForks(landedOnly) reads only that file, so it picks the same forks on every sweep.
  • Workspace.DropFork returns success for a fork furrow no longer lists ("a previous successful retirement is safe to retry"), so the sweep logs "retired" again.
  • Each launch ran furrow status plus one furrow forks per fork in the person's project. Nothing was deleted again.

Fix: the sweep now writes down each fork it retires and skips those forks after that.

 retireCheckpointForks(dir)
   nodes = checkpointForks(dir)
+  retired = loadRetiredForks(dir)        # <session>/forks-retired.json
   for each landed universe fork
+    if retired.holds(fork): continue     # no furrow, no git, no log line
     ownership / later-work checks
     dropUniverse(fork)
     note("retired fork …")
+    retired.remember(dir, fork)          # atomic rename

The memory lives in its own file, not in tasks.json. The task store rewrites the checkpoint whole whenever the conversation reopens, so a mark written there could be lost on the next save, or could overwrite that save. A missing, unreadable or unknown-schema file counts as empty. That costs one more furrow question for each fork and never removes anything. Each record is keyed by ground, furrow name and directory. Fork names carry a random suffix, so a new fork can't match an old record.

Furrow does not need to change.

Evidence

  • Failing test first (commit 2381508): TestASweptLandedForkStaysRetired. A landed fork is left behind (furrow was unavailable when it landed), then a kept conversation is swept twice, as two separate processes.

    • Before: the second sweep retired 1-4121ab again: [sweep: retired fork 1-4121ab of /tmp/…]. This is the laptop's line.
    • After: pass. The second sweep makes zero furrow calls and logs nothing.
  • Rig on Spark: a copy of the laptop home, with the paths in this session's checkpoint rewritten to a furrow-watched afkit stand-in. Every furrow call is counted.

    launch first frame sweep lines furrow calls on afkit
    dev base1–3 0.55 / 0.49 / 0.43 s 2 each 3 each (status, forks, forks)
    fix1 0.55 s 2 (real retirement) 3
    fix2, fix3 0.43 / 0.55 s 0 0
  • The sweep never blocks the first frame: on dev, with each afkit forks call slowed by 4 s (8 s added to the sweep), the first frame was still 0.43 s on both launches.

  • Full suite: LC_ALL=C make check on Spark, fleet job 20261026-185034-002484, commit e5acfb8. Everything passes except failures that are already on dev (internal/release ×2, seniordev/util TestFindUpRootFirst) and one TestSealedTreeCarriesTheSessionTruth failure (TempDir RemoveAll: directory not empty). That test doesn't touch the sweep, and it passes 20/20 in isolation on both this branch and dev. The sweep, retire, fork and seal tests in internal/session and cmd/codeaf pass on rerun. c17e1b1 adds only the change entry (make changelog-check ok).

Merge Danger

Door: two-way

This adds one new file per session folder, and only once that session has had a fork retired. Reverting means the next sweep asks furrow again, which is the old behaviour.

Blast Radius: sweep

Only the background sweep's retirement path changes. Landing, reaping and ownership checks are unchanged.

🤖 Generated with Claude Code

The second sweep of a kept conversation asks furrow about a fork it retired
on the first sweep, and logs "retired" again.
The checkpoint keeps naming a landed fork forever, and furrow answers a
fork it no longer holds with success, so every launch asked furrow about
the same forks and logged "retired" again. The sweep now remembers what it
retired in forks-retired.json beside the checkpoint and skips those forks.
@santoshkumarradha
santoshkumarradha merged commit 08b922b into dev Oct 26, 2026
6 checks passed
@santoshkumarradha
santoshkumarradha deleted the fix/sweep-retires-once branch October 26, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant