Pan flywheel

From eltmon/overdeck · View interactive version

Pan flywheel is an AI agent skill from the GitHub repository eltmon/overdeck. pan flywheel start — run the Fix-All Flywheel as a loop skill: tick the order books and backlog sequence in `.pan/`, pick the next issue, launch work with `pan start`, watch its PR and checks to landing, run `pan reload` after an overdeck merge lands with green CI, and park whatever it cannot decide

How to use this skill

Skill file

pan flywheel

The Flywheel is a loop, not a daemon. It runs inside this conversation, ticks

the backlog, and keeps issues moving through pan start → PR → review →

merge without a supervising process or a stored run record. State is never

duplicated here: every fact this loop acts on is read live from .pan/, the

tracker, and the forge.

pan flywheel start
pan orders start <book-id>

pan flywheel start opens this skill in a conversation working the open

backlog directly. pan orders start <book-id> opens the same skill bound to

one order book (pan orders show <book-id>).

The Flywheel page (/flywheel) and pan flywheel status show this loop by

reading what it leaves behind — this conversation's transcript, the pipeline

journals, the tracker, and .pan/flywheel/. Nothing else records a run.

Verbs

pan flywheel start
pan flywheel start --orders <book-id>
pan flywheel start --fresh
pan flywheel stop
pan flywheel abort
pan flywheel pause
pan flywheel resume
pan flywheel report
pan flywheel status --json
pan flywheel stats --json

start --fresh replaces a paused conversation. The old one is retired, not

deleted, and its last tick reaches the new loop as previousRun (Phase 1).

stop asks this loop to write its report, waits, then pauses the

conversation; abort pauses without a report; pause stops the session and

keeps the conversation; resume respawns it and re-sends /pan-flywheel

(re-entry is safe: Orient re-reads everything); report asks a running loop

for its report; status and stats are derived reads.

Mission

A loop with a metabolism. Every revolution must permanently improve the

substrate — Overdeck itself. *An agent without a metabolism ships and rots;

one with a metabolism ships and compounds.* A workaround is a failed tick.

When a tick hits a substrate bug, the tick's job becomes fixing it (file it

with the substrate-improvement label, launch the fix with pan start), not

routing around it. Record each substrate fix in the state file below.

Doctrine and rails

These come from roles/flywheel.md, which is never loaded on its own: this

section is how they reach the loop. They bind every tick.

never write code, specs or plans yourself. The only files you write are the

state file and the report.

failing check.

> Main's CI verdict is the newest CI run on main that concluded success or

> failure: gh run list --branch main --workflow CI --limit 20 --json headSha,status,conclusion --jq '[.[] | select(.conclusion == "success" or .conclusion == "failure")][0]'.

> Queued, in-progress and cancelled runs are no verdict (a newer push cancels a

> superseded run), and bookkeeping commits (only .pan/** or

> .overdeck/memory/**) run no CI (PAN-4618), so the verdict's headSha is

> usually older than origin/main HEAD. That is expected, not "unknown".

substrate bug. An issue that restates an error message is a symptom log, not

a diagnosis.

same failure on two issues is a class, and a class is never fixed

instance-by-instance. File the issue that removes the cause.

first pan resume, pan tell, pan sync-main or pan review restart on an

issue, form a root-cause hypothesis from evidence (the agent's

~/.overdeck/agents/<agent>/lifecycle.log, the pane, the transcript, the PR's

reviews and checks) and write it in the state file. The same recovery verb

twice on one issue without a confirmed cause is a failed tick.

author.login ∈ {eltmon, panopticon-agent[bot]} or eltmon ∈ assignees

(gh issue view <num> --json author,assignees). For Linear projects, only

issues assigned to the operator. Never weaken this default-deny.

while main is red.

Phase 1 — Orient

  1. Read the policies from pan flywheel status --json (the .policies

object) — never assume their defaults. Read .pan/flywheel/state.md for

what earlier runs learned.

1a. On the first tick of this conversation, read .previousRun from the same

pan flywheel status --json. When it is not null, it is the run before this

one (a fresh start, a crash, a reboot), and its last tick is all that

survives of it. Add .previousRun.lastTick.inFlight to the set Phase 1b

drains, and drain those issues first. Carry every item of

.previousRun.lastTick.needsYouItems forward verbatim into your first tick

marker's needs-you, with the same wording, so the page keeps matching it.

Keep each item in later ticks until you verify it is resolved: an item you

leave out of a tick reads as resolved.

  1. Read .pan/backlog/sequence.md for the operator-set pickup order.
  2. If a book is active (pan orders list shows one book with phase active),

read it with pan orders show <book-id>: its Lane A/B items and prereqs

take priority over the general backlog. A

/pan-flywheel <book-id> --project <key> message that arrives while the

loop is running binds that book. On every later tick, read it with

pan orders show <book-id> --project <key> and work its lane items. Use the

unqualified pan orders list and pan orders show only when no book is bound.

  1. List in-flight work: gh pr list --search "is:open" for this repo,

pan status for live sessions, and every issue with a workspace, branch,

agent or PR (GET /api/issues/resource-allocated on the dashboard, the

pipeline-list skill's view). This is the set Phase 1b drains.

Phase 1b — Drain what is already in flight

Every tick, before picking anything new, walk every in-flight issue and ask

"is it moving?". Clearing the pipeline outranks adding to it.

| Stall | How you see it | First move |

| --- | --- | --- |

| Planned but never started | planning finished, no work agent; agent.start_blocked in the agent's lifecycle.log | read the block reason; it is usually a substrate bug |

| Agent dead or idle | pan show <id> --health says the session is not running, or no activity for a long time with work left | read the pane and transcript tail, then pan resume or pan tell |

| PR conflicts with main | gh pr view <pr> --json mergeable is CONFLICTING | tell the work agent to merge main; pan sync-main stops at conflicts and does not resolve them |

| Review never reports | review requested, no verdict, no reviewer activity | pan review restart <id> |

| Checks red | the PR's checks fail | if main is green, the PR broke it: tell the agent |

| Merged, not closed out | PR merged, issue still open, issue NOT labeled epic | pan close <id>; a close-out refused on the deploy row needs pan reload first. Never pan close an epic issue because a PR merged: an epic lands in slices, a merged PR is one slice, and the close-out gate refuses it until the operator accepts --accept-merged |

| Merged, not deployed (Overdeck) | the deployed build lacks the merge | pan reload once the newest CI run on main succeeded (deploy rule); it waits for the operator's restart approval, so say so in needs-you |

For every stall: form the root-cause hypothesis first (Doctrine), act once,

and if the cause is in Overdeck itself, file it with the substrate-improvement

label and file:line evidence and launch the fix with pan start (TENET-10

machinery goes to needs-handoff instead; see Guardrails). Two issues stuck the

same way is a class: file the class.

Pickup gate

A backlog issue is auto-pickable — eligible to start work — iff:

ready && planned && (released || auto_pickup_backlog || activeBookMember) && !parked && !vetoed && !objection && !inPipeline && !epic

This mirrors isAutoPickable() in src/lib/backlog/pickup.ts. The gates:

auto-start when auto_pickup_backlog is OFF unless the issue belongs to the active order book;

when ON, the toggle is the blanket release. Operator-only — never add the label yourself.

vetoed is absolute. Never pick up, plan, or strike a vetoed issue, even to unblock

the pipeline. The one exception to "never block on the operator."

released and vetoed are operator-only labels: this loop never adds or

removes either one. The same holds for auto-merge and hold-for-uat. The

Flywheel conversation's gh shim refuses these grant-label writes

(released, auto-merge, hold-for-uat, vetoed) and exits non-zero; when one seems

needed, park the item and ask the operator.

Phase 2 — Pick the next item

Walk the backlog sequence (or the active order book's next lane item whose

prereqs are terminal) and pick the first issue that is not already in flight,

not blocked, and not parked. "Parked" means the tracker issue carries the

parked label or is listed in .pan/parked.md — skip it silently, it was

parked on purpose.

If nothing is pickable — every remaining item is blocked, parked, or the

book/backlog is empty — do not invent work. If anything is still in flight,

keep ticking and draining it (phase=watch). Only when nothing is pickable

and nothing is in flight, say so plainly in the tick marker (`phase=idle

needs-you=pipeline idle — nothing pickable`) and stop the loop.

Phase 3 — Launch

pan start <issue-id>

pan start plans (if unplanned) and starts the work agent in one command.

Do not use pan spawn, pan swarm, or any lower-level launcher for the

Flywheel's own picks — pan spawn is for the foreman dispatching item

workers within an already-started issue, not for the Flywheel picking a

new one.

If pan start fails with "Disk low — new workspace starts are held", the

disk cannot take another workspace setup. Launch nothing more this tick, put

needs-you=disk low (<free> GiB free) in the tick marker (the free GiB is in

the message), and do not retry that issue until a later tick. If the message

instead says "the disk reservation ledger at <path> is unavailable", the disk

is not the problem: put `needs-you=disk reservation ledger unavailable at

<path>` in the marker, because every start is held until that directory is

fixed. A planning handoff deferred for low disk retries on its own for 2 hours;

after that it needs pan start <id>, which the loop runs on a later tick once

starts succeed again.

Phase 4 — Watch to landing

Poll the issue's derived state, not a stored one:

| Signal | Source |

|---|---|

| Is work still running? | pan status / pan show <id> |

| Is a PR open? | gh pr view for the feature branch |

| Is it in review? | PR review requested, or a reviewer pane live |

| Changes requested? | Latest PR review state is CHANGES_REQUESTED |

| Ready to merge? | PR approved, checks green, mergeable true |

| Merged? | PR merged |

An issue sitting in "changes requested" for a while is normal — the work

agent handles its own review feedback loop. Only intervene (pan tell) if

the agent looks stuck (idle with unaddressed feedback) — deacon-lite already

nudges this case; give it a chance before you do.

Once a PR onto Overdeck's own main merges, apply the deploy rule, then run:

Deploy with pan reload only when the newest CI run on main succeeded:

gh run list --branch main --workflow CI --limit 1 --json status,conclusion,headSha

must show status: completed and conclusion: success. Queued or in progress:

wait for it. Cancelled: only an operator cancels the newest run, so ask; do not

deploy. Bookkeeping commits run no CI (PAN-4618), so this run's headSha may be

older than HEAD; the build is the same code.

pan reload

pan reload exits 0 when a reload of the same or a newer commit is already waiting, and

replaces a waiting reload of an older commit (PAN-4888), so the Flywheel never

needs to wait for, or retry around, a held reload. Exit 2 still means a

non-reload restart holds the lock.

Only for an Overdeck merge — not for merges in other projects the loop is

also driving. Other projects deploy their own way; do not pan reload on

their behalf.

Policies

backlog item individually — the Flywheel picks up only items marked

released. ON: blanket release — every ready and planned backlog item is

pickable without individual operator release.

passed.

Tick marker

End every tick — every revolution of orient → pick → launch → watch → park —

by printing exactly one line in this shape, on its own line, as the last line

of your message:

flywheel-tick: tick=3 pick=PAN-3964 phase=watch in-flight=PAN-3964,PAN-3920 needs-you=none

stopping.

always the last key and may contain spaces. Separate several items with

; ; the Flywheel page shows one row per item and links each row to the

tick that first raised it. Keep an item's wording identical from tick to

tick until it is resolved: the page matches items by exact text, so a

reworded item looks newly raised. Always write a pull request outside this

project as owner/repo#<n> (for example `PR eltmon/overdeck-landing#7

merge); a bare #<n>` from another repo stays unlinked. When an item has a

place to act — a console page, a settings page, a PR or issue URL — end the

item with its URL in angle brackets: `upload AAB

<https://play.google.com/console/…>`. The page renders the item text as a

link to it. Only http and https URLs work, and the URL must contain no

spaces and no ;. Adding or changing the URL does not make the item look

newly raised.

The Flywheel page and pan flywheel status parse this line from the

transcript; it is the only status this loop reports. Never curl or POST a

status anywhere. Draining in-flight work reports as phase=watch.

Cadence

Every tick schedules the next one before it ends: run sleep 450 as a

background Bash command (run_in_background); its completion starts the next

tick. Use 450 seconds while anything is in flight and 1000 seconds when idle.

Never wait longer than 1000 seconds: a gap past 20 minutes reads as a hung

loop. Skip scheduling only when stopping.

If Claude Code stops that timer (it does under memory pressure), the Deacon's

Flywheel watchdog sends /pan-flywheel to this conversation once the last

tick is 20 minutes old and the conversation is idle, and it resumes the loop

after a host reboot. A /pan-flywheel that arrives this way is an ordinary

tick. Do not raise a needs-you item asking the operator to resume the loop

because the timer stopped.

State file

.pan/flywheel/state.md is this loop's durable memory across runs: substrate

fixes it drove (issue, what broke, what fixed it) and learnings worth keeping.

Append to it — never rewrite history — when a tick produces one, then commit

and push it so main does not diverge:

git add .pan/flywheel/state.md
git commit -m "chore(workspace): flywheel state"
git push

It is memory, not status: never write a pipeline state, a run id, or a

counter into it.

Phase 5 — Park what you cannot decide

Some calls are the operator's: ambiguous scope, a design tradeoff with no

clear default, anything destructive, anything outside the issue's stated

acceptance criteria. For those, write the issue to .pan/parked.md with a

one-line reason and move to the next pickable item. Do not block the loop on

an operator decision — park it and keep going.

Stop conditions

to stop, stop cleanly and report what shipped, what's in flight, and

what's parked.

blocked with no path forward. Report and stop; do not manufacture more

scope.

To report — on stop, or whenever asked for a report — write

.pan/flywheel/report.md (what shipped, what is in flight, what is parked,

substrate fixes this run), overwriting the previous report, then commit and

push it:

git add .pan/flywheel/report.md
git commit -m "chore(workspace): flywheel report"
git push

When stopping, print the tick marker with phase=stopping and end the loop.

When only asked for a report, print it with phase=watch and continue.

Guardrails

in another conversation — check pan status first.

human-triggered actions (the MERGE button, gh pr merge, pan wipe).

report to: GET /api/flywheel/status is a derived read of your transcript,

and the tick marker is how you report. The derived state table above is the

only source of truth for an issue's position.

deacon, the flywheel loop, conversation live-control, the merge or review

routes, or the agents runtime. Mark them needs-handoff and route them

through a supervised pan handoff instead. A broken change there turns

main red and stalls every other merge.

See Also

once the Flywheel has started it

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.