No lifecycle cleanup when a Conductor worktree backing a gbrain code source is deleted — autopilot permanently fails on the stale source forever
- Dominant language
- TypeScript
- Stars
- 133k
- Forks
- 19.9k
- Avg merge
- 18h 46m
- Merged PRs (30d)
- 26
Description
**Environment:**
- gstack v1.69.0.0, gbrain v0.46.28.0, macOS, Conductor host
**Summary:**
`/sync-gbrain` registers a per-worktree gbrain code source (`gstack-code-`) pointing at the worktree's absolute path. When the Conductor worktree is later deleted (a normal, disposable-by-design event in Conductor), nothing deregisters the corresponding gbrain source. `gbrain autopilot` keeps dispatching `sync` jobs against it every cycle indefinitely, each one permanently failing with `Not inside a git repository: `.
**Reproduce:**
1. Create a Conductor workspace on a repo with gbrain configured; run `/sync-gbrain --full` to register `gstack-code-` pointing at the workspace path.
2. Delete/archive the Conductor workspace (directory removed from disk).
3. Run `gbrain autopilot --install` (or wait for the next scheduled cycle).
4. Observe: `Job N (sync) permanently failed: Not inside a git repository: . GBrain sync requires a git-initialized repo (or a subdirectory of one).` — repeats every autopilot cycle (~150-300s) with no backoff beyond per-job retries, forever.
**Expected:** either (a) gstack registers a Conductor teardown hook (`conductor.json` → `scripts.archive`) that deregisters the source when the workspace is torn down, or (b) `gbrain sources`/autopilot detects a source whose `local_path` no longer exists and auto-archives it (or at minimum stops permanently re-dispatching against it) rather than failing identically forever.
**Actual:** Neither exists. Checked both sides directly:
- The affected repo has no `conductor.json` at all — no teardown hook configured.
- gstack's own example usage of the Conductor teardown hook (its own `conductor.json` → `bin/dev-teardown`) does nothing gbrain-related — it only removes dev-mode skill symlinks.
- `gbrain sources --help` has no prune/gc/stale-detection subcommand. The closest relative, `sync --all --missing-path skip`, downgrades the failure to a skip but doesn't deregister the source, and doesn't apply to autopilot's own per-cycle dispatch (which produced the failing job exactly as `sync --strategy code` would, not through the `--all --missing-path skip` path).
**Affected files (best guess, not verified against source):** likely `bin/gstack-gbrain-source-wireup` (registers the source, would need to also register cleanup) and/or a new `gbrain sources` subcommand for liveness checking.
**Logs:**
```
[dispatch] job #127 sync (freshness: gstack-code-gbrain-a93856f4; age=95min)
Job 127 (sync) failed, retrying in 1172ms (attempt 1/2)
Job 127 (sync) permanently failed: Not inside a git repository: /Users/dewanbayney/conductor/workspaces/AI/dar-es-salaam. GBrain sync requires a git-initialized repo (or a subdirectory of one).
```
Contributor guide
Research direction
Verify the lifecycle and source-registration paths in bin/gstack-gbrain-source-wireup, the repository's conductor.json and bin/dev-teardown, and the gbrain sources/autopilot commands described in the report. Determine whether cleanup belongs in the Conductor teardown hook or in gbrain stale-source handling; done means deleted worktrees no longer leave a source that is dispatched and permanently fails each autopilot cycle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100