fix(#3799): scope legacy cleanup to the install's resolved config dir and add --no-legacy-cleanup (#4013)

* fix(#3795): read the interrupted agent id before clearing the stale marker (#4006)

* test(#3795): the interrupted-agent read must precede the stale-id clear

* fix(#3795): read the interrupted agent id before clearing the stale marker

execute-plan's init_agent_tracking step ran `rm -f
.planning/current-agent-id.txt` BEFORE the existence check that read it,
so the interrupted-agent branch and the Task resume prompt it exists to
offer were unreachable (#3795) — a kill -9 mid-executor left the file,
and the next run deleted it before looking. The read now precedes the
clear; fresh-run semantics (no stale id leaking into the new spawn) are
preserved. A structural guard pins the order.

Emitted-Drift-Ack-Growth: execute-plan.md — #3795: +bytes from reordering the interrupted-agent read before the rm plus the explaining comment

* chore(#3795): changeset fragment (pr number backfilled after PR creation)

* chore(#3795): backfill changeset PR number (4006)

---------

Co-authored-by: sim <sim@local>

* fix(#3799): scope legacy cleanup to the install's resolved config dir and add --no-legacy-cleanup

* chore(#3799): changeset fragment (pr number backfilled after PR creation)

* chore(#3799): backfill changeset PR number (4013)

* test(#3799): mark the legacy-name fixtures with gsd-allow-legacy-name

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-08-28 20:16:50 -04:00
committed by GitHub
parent 83273f9642
commit 1051c6d8d4
4 changed files with 213 additions and 20 deletions

View File

@@ -262,8 +262,14 @@ function planLegacyCleanup(configDirs, opts = {}) {
}
}
// Legacy shared cache (fixed name from the old package)
const legacyCachePath = path.join(homeDir, '.cache', 'gsd', 'gsd-update-check.json');
// Legacy shared cache (fixed name from the old package). #3799: under an
// explicit configDirs override the cache lives under the SCOPE root(s), not
// the default home — the override means "clean only what this redirected
// install owns", and the default home's cache belongs to the live install.
const cacheRoot = (Array.isArray(opts.configDirs) && opts.configDirs.length > 0)
? opts.configDirs[0]
: homeDir;
const legacyCachePath = path.join(cacheRoot, '.cache', 'gsd', 'gsd-update-check.json');
try {
const stat = fsMod.statSync(legacyCachePath);
if (stat.isFile()) {