fix(polecat): release pool slot on submit (worktree+branch cleanup)#9
Open
eric-jones wants to merge 1 commit into
Open
fix(polecat): release pool slot on submit (worktree+branch cleanup)#9eric-jones wants to merge 1 commit into
eric-jones wants to merge 1 commit into
Conversation
95d2e69 to
8099cd3
Compare
…emove worktree
Polecat slots are bounded; a stale per-polecat branch and worktree
pinned to a dead bead is counted as "occupied" by the reconciler.
Under fan-out the next sling either reuses a stale workspace
(subtle) or never spawns a polecat at all (visible — the stuck
"3rd fan-out child unassigned" symptom). The polecat formula's
submit-and-exit step had a `git checkout --detach && git branch -D`
fragment that deleted the local branch but left the worktree on
detached HEAD; nothing removed the worktree. Worse, the agent
prompt template's FINAL REMINDER done sequence (which is what the
agent actually follows — agents in a session don't re-pour the
formula) had no cleanup at all. Result: every polecat session
across L4 / L5a / L5b / L5c left its worktree behind, and the
reconciler counted those slots as in-use.
`examples/gastown/packs/gastown/agents/polecat/prompt.template.md`
— FINAL REMINDER done sequence now captures `WORKTREE_PATH=$(pwd)`
and `BRANCH=$(git branch --show-current)`, `cd "$GC_RIG_ROOT"`, then
`git branch -D "$BRANCH"` and `git worktree remove --force
"$WORKTREE_PATH"` BEFORE `gc runtime drain-ack`. The cd is
load-bearing: `git worktree remove` refuses to delete the cwd, and
`$GC_RIG_ROOT` is the canonical rig checkout (the only worktree
guaranteed to exist after this cleanup). Subsequent `gc bd` and
`gc runtime` calls are path-agnostic.
`examples/gastown/packs/gastown/formulas/mol-polecat-work.toml` —
submit-and-exit step renumbered: old step 3 ("Clean up local
branch") removed in favor of new step 5 ("Release the pool slot")
that does branch-D + worktree-remove together, after the
reassign-to-refinery step. Description spells out the "cd before
remove" gotcha and the consequence of skipping the step.
`examples/gastown/gastown_test.go` — new
TestPolecatReleasesPoolSlotOnSubmit asserts the chained shape in
both files (prompt template's done sequence and formula's
submit-and-exit step), and explicitly rejects the prior `git
checkout --detach` shape so reverting half the fix fails the test.
Surface: polecat agent prompt template + mol-polecat-work formula
step prompt; not gascity Go code.
A runtime-level worktree janitor (gc reconciler that prunes
worktrees of closed beads as defense-in-depth) — would be a Go
behavior change, larger surface. Prompt-only fix closes the
observed regression.
- [x] `make build` — clean
- [x] `make check` — full suite passes (only failure is documented EXPECT-FAIL `TestDoctorScriptIgnoresDocumentedSystemSchemasForBackupFreshness`, unrelated to this PR)
- [x] `go test ./examples/gastown/ -run TestPolecatReleasesPoolSlotOnSubmit -count=1 -v` — passes
- [ ] `make check-docs` — not run (no docs files touched)
- [ ] `make test-integration` — not run (per CONTRIBUTING; prompt-only formula edit, no runtime/controller behavior touched)
- [x] Linked an issue, or explained why one is not needed: prompt-only fix surfaced from internal L5 fan-out testing; no public issue.
- [x] Added or updated tests for behavior changes: `TestPolecatReleasesPoolSlotOnSubmit` covers both files in sync.
- [x] Updated docs for user-facing changes: formula prompt + agent prompt updated directly; the new shape and the rationale prose are the user-visible change.
- [x] Called out breaking changes or migration notes: none — the prompt is what the LLM agent reads each cycle; no runtime contract change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Upstream-PR: gastownhall#1925
8099cd3 to
10c596d
Compare
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.
Fork-PR for review. Upstream: gastownhall#1925 WITHDRAWN 2026-05-20 (Q3 lifecycle-hook). Retained on fork.