feat(polecat): self-cleaning model and new review formulas

Polecats now self-clean when done:
- gt done always exits session (no more --exit flag needed)
- gt done requests self-nuke (sandbox cleanup)
- No idle polecats - done means gone
- Refinery re-implements on conflict (never sends work back)

New formulas:
- mol-polecat-review-pr: review external PRs, approve/reject
- mol-polecat-code-review: review code, file beads for findings

Docs updated:
- polecat-lifecycle.md: self-cleaning model, identity vs session
- polecat-CLAUDE.md: updated contract and completion protocol
- mol-polecat-work: updated for self-cleaning

Implementation beads filed:
- gt-yrz4k: gt done always exits
- gt-fqcst: polecat self-nuke mechanism
- gt-zdmde: abstract work unit completion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gus
2026-01-10 17:11:55 -08:00
committed by Steve Yegge
parent ad6386809c
commit 8219fd5abe
8 changed files with 1349 additions and 90 deletions

View File

@@ -1,26 +1,29 @@
description = """
Full polecat work lifecycle from assignment through MR submission.
Full polecat work lifecycle from assignment through completion.
This molecule guides a polecat through a complete work assignment. Each step
has clear entry/exit criteria and specific commands to run. A polecat can
crash after any step and resume from the last completed step.
## Polecat Contract (Ephemeral Model)
## Polecat Contract (Self-Cleaning Model)
You are an ephemeral worker. You:
You are a self-cleaning worker. You:
1. Receive work via your hook (pinned molecule + issue)
2. Work through molecule steps using `bd ready` / `bd close <step>`
3. Submit to merge queue via `gt done`
4. Become recyclable - Refinery handles the rest
3. Complete and self-clean via `gt done` (submit + nuke yourself)
4. You are GONE - Refinery merges from MQ
**Self-cleaning:** When you run `gt done`, you push your work, submit to MQ,
nuke your sandbox, and exit. There is no idle state. Done means gone.
**Important:** This formula defines the template. Your molecule already has step
beads created from it. Use `bd ready` to find them - do NOT read this file directly.
**You do NOT:**
- Push directly to main (Refinery merges)
- Push directly to main (Refinery merges from MQ)
- Close your own issue (Refinery closes after merge)
- Wait for merge (you're done at MR submission)
- Handle rebase conflicts (Refinery dispatches fresh polecats for that)
- Wait for merge (you're gone after `gt done`)
- Handle rebase conflicts (Refinery spawns fresh polecats for that)
## Variables
@@ -407,30 +410,23 @@ bd sync
[[steps]]
id = "submit-and-exit"
title = "Submit to merge queue and exit"
title = "Submit work and self-clean"
needs = ["prepare-for-review"]
description = """
Submit your work to the merge queue. You become recyclable after this.
Submit your work and clean up. You cease to exist after this step.
**Ephemeral Polecat Model:**
Once you submit, you're done. The Refinery will:
1. Process your merge request
2. Handle rebasing (mechanical rebases done automatically)
3. Close your issue after successful merge
4. Create conflict-resolution tasks if needed (fresh polecat handles those)
**Self-Cleaning Model:**
Once you run `gt done`, you're gone. The command:
1. Pushes your branch to origin
2. Creates an MR bead in the merge queue
3. Nukes your sandbox (worktree removal)
4. Exits your session immediately
**1. Submit with gt done:**
**Run gt done:**
```bash
gt done
```
This single command:
- Creates an MR bead in the merge queue
- Notifies the Witness (POLECAT_DONE)
- Updates your agent state to 'done'
- Reports cleanup status (ZFC compliance)
**2. Verify submission:**
You should see output like:
```
✓ Work submitted to merge queue
@@ -438,20 +434,19 @@ You should see output like:
Source: polecat/<name>
Target: main
Issue: {{issue}}
✓ Sandbox nuked
✓ Session exiting
```
**3. You're recyclable:**
Your work is in the queue. The Witness knows you're done.
Your sandbox can be cleaned up - all work is pushed to origin.
**What happens next (not your concern):**
- Refinery processes your MR from the queue
- Refinery rebases and merges to main
- Refinery closes the issue
- If conflicts: Refinery spawns a FRESH polecat to re-implement
If you have context remaining, you may:
- Pick up new work from `bd ready`
- Or use `gt handoff` to cycle to a fresh session
You are NOT involved in any of that. You're gone. Done means gone.
If the Refinery needs conflict resolution, it will dispatch a fresh polecat.
You do NOT need to wait around.
**Exit criteria:** MR submitted, Witness notified, polecat recyclable."""
**Exit criteria:** Work submitted, sandbox nuked, session exited."""
[vars]
[vars.issue]