lab: claim AFK-run issues via the afk/<N> branch, not an in-progress label #92
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos#92
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Agent Brief
Category: enhancement
Summary: Make lab claim an AFK-run issue by creating its
afk/<N>branch instead of flipping a trackerin-progresslabel, so the claim can't be clobbered by triage/humans and can't flap.Current behavior:
lab claims a
ready-for-agentissue by flipping its labelready-for-agent -> in-progressbefore spawning the run (rolling back toready-for-agentif the spawn fails), per ADR-0007. Thein-progresslabel is the sole claim record; the queue query (open +ready-for-agent) excludes claimed issues "for free".land-prclearsin-progresson merge.Because the claim is a shared, mutable tracker label, any other actor can overwrite it. The triage skill (or a human) re-applying
ready-for-agentto a claimed issue un-claims it. Worse, a failed run keeps itsafk/<N>branch and worktree for inspection; ifready-for-agentis then re-added (the obvious "requeue" move), the next claim flips the label, the worktree-add fails becauseafk/<N>already exists, the rollback flips the label back, and the issue flapsready-for-agent <-> in-progressevery scheduler tick while the real run is still working it.Desired behavior:
lab no longer reads or writes any claim label. An AFK run's claim is its
afk/<N>branch -- a durable artifact lab already creates that survives a lab restart (local ref on disk). Issue selection treats an openready-for-agentissue that already has a localafk/<N>branch as already-claimed and skips it. As a result:ready-for-agent; it can never clobber a claim or cause flapping, because the branch -- not the label -- is the source of truth. No coordination between triage and lab is required.afk/<N>branch keeps its issue out of the claimable set (parked); the scheduler drains around it with no flapping. Requeue is a single action: delete theafk/<N>branch (and its worktree).afk/<N>branches/PRs, not in the tracker. This is an accepted trade-off (it loses the tracker-visible "in-progress with no PR = failed run" signature; the lab UI is the dashboard).Selection signal: the local
afk/<N>branch only. A merged run closes its issue, so an open-state query excludes it; a failed or PR-still-open run keeps its branch, which the reaper preserves. The one hole -- deleting anafk/<N>branch while its PR is still open -- is operator error already forbidden by convention. Do NOT add a PR-based exclusion to selection.Key interfaces (names may have shifted -- explore; do not trust paths):
Trackerinterface -- remove the label-mutation methods (EnsureLabel,Relabel); keepReadyIssuesandListPulls. Thein-progresslabel name/color constants go away.Gitinterface -- add a read-only method returning the set of issue numbers that have a localafk/<N>branch (e.g. viagit for-each-ref refs/heads/afk/). One local call; restart-safe.launchAFKRun) -- drop the label flip and its label-rollback; the claim becomes "worktree/branch created", and failed-spawn rollback tears down only the worktree+branch.pickLowestIssueand its caller) -- filterReadyIssuesto the claimable set (no existingafk/<N>branch) before choosing the lowest.scheduleAFKRuns) and the ready-count cache feeding the "(N ready)" hint andReadyExists-- must count the claimable set, not the rawready-for-agentcount, so the hint stays honest and a project whose only ready issues are all parked does not loop.classifyAFKRun/reapAFKRun) and theconsecutiveFailures/3-strikes/Reset machinery -- unchanged (already label-independent).Documentation (part of this issue):
docs/agents/triage-labels.md: remove thein-progresslifecycle-label section; state that lab claims viaafk/<N>branches (invisible to triage) and triage manages only the five canonical state roles.land-prskill (underutils/home-manager/claude-code/skills/): drop the "clear thein-progressclaim label" step and thein-progress-trigger phrasing; keep theafk/<N>head-branch +Closes #Ncontract.Acceptance criteria:
Trackerinterface exposes no label-mutation method.afk/<N>; a failed spawn rolls back by tearing down only the worktree/branch (no label restore).ready-for-agentissue that has a localafk/<N>branch; the scheduler's ready count andReadyExistsuse the same claimable set.ready-for-agentto a claimed or parked issue causes neither a re-claim nor any label change (no flapping) -- covered by a unit test.consecutiveFailures/3-strikes/Reset behave exactly as before.land-prperforms noin-progresslabel removal; itsafk/<N>+Closes #Nvalidation is intact.docs/agents/triage-labels.mdno longer presentsin-progressas a lifecycle label.go build ./...,go vet ./..., andgo test ./...run locally -- the pre-commit hook is eval-only (nix-instantiate) and does NOT run Go tests.Out of scope:
afk/<N>branches with a requeue/discard action) -- file as a follow-up.in-progresstracker label -- optional cleanup, not required here.