Repository navigation
Description
This was generated by AI from a grill-with-docs session.
Decided in docs/grill-with-docs/1532-keep-working-the-backlog.md (Q1.1-Q4.2), from #1532. GLOSSARY.md already defines the Failure limit and the Command limit as this Spec builds them, and its Architect run, Pickup run, Security run and Pass entries are skipped "at its Command limit".
Problem Statement
The Day shift labels issues ready-for-agent and expects the factory to keep working them. Two things stop it while Ready issues wait.
The Claim limit counts every open issue carrying a Claim. A Claim stays on while its pull request waits for review, as well as when its Ticket run failed. So pull requests that nobody has reviewed yet stop the factory from taking more work, even when every one of them is green. On thirdshift itself, cron.log holds 5,121 lines of at the Claim limit on JacobStephens2/thirdshift at the default pickup.limit of 3. The Day shift's only lever is to raise the number, which also weakens the one protection that matters: stopping a broken Base branch or Harness from failing every Ready issue in turn.
On one machine, a Pass is skipped while any other Pass on the same repository is still running, its dispatched Spec run or Ticket run included. So each host works one Ready issue at a time, whatever the limit says, and an Architect run or Security run waits behind every Pickup run. The Day shift can't trade machine capacity for throughput.
Solution
Pickup counts failures, not Claims, and Passes share a repository up to a number the Day shift sets.
- Failure limit. When a Failed ticket run or Failed spec run keeps its Claim, whatever started it, thirdshift labels the issue
agent-failed. A Pickup run takes no more Ready issues whilepickup.failure_limitopen issues carry that label, 3 by default. A pull request that is ready for review or merged never counts. The label comes off when the Day shift acts on the failure: putsready-for-agentback, takesin-progressoff to take the issue over, or closes it. - Command limit.
[pass] command_limit, 1 by default, is how many live Commands on one repository on one machine skip a Pass there. Every live Command counts, a Ticket run started by hand on an Issue URL included, but only a Pass is ever skipped. A command the Day shift types always runs. - Mixed Passes. Up to the Command limit, Passes of different kinds run side by side: Pickup runs, one Architect run, one Security run. Never two Architect runs or two Security runs on one repository at once.
- Upgrade. An old
pickup.limitline is accepted, ignored and warned about, so cron jobs on every host keep running acrossthirdshift update.
User Stories
Failure limit:
- As the Day shift, I want pull requests waiting for my review to never stop a Pickup run, so that the factory keeps working Ready issues while I catch up on reviews.
- As the Day shift, I want merged work to never count against any limit, so that a busy day of merges never slows pickup.
- As the Day shift, I want a Pickup run to stop taking Ready issues once 3 open issues carry failures it left for me, so that a broken Base branch or Harness doesn't burn sessions on my whole backlog.
- As the Day shift, I want a failed Ticket run to label its issue
agent-failed, so that I can see on GitHub which Claims are waiting on me because the factory failed. - As the Day shift, I want a failed Spec run that keeps its Claim to label its Spec
agent-failedtoo, so that Spec failures count the same way. - As the Day shift, I want a failure in a Ticket run I started by hand on an Issue URL to count, so that the limit sees a broken Base branch whatever started the run.
- As the Day shift, I want a failed fix dispatched by an Architect run or a Security run to count, so that every failure waiting on me is in one count.
- As the Day shift, I want a Self-merge that a policy, security or merge hold stopped, leaving its pull request ready, to get no
agent-failed, so that a hold waiting for my review isn't mistaken for a broken factory. - As the Day shift, I want a Stop to never add
agent-failed, so that an issue I stopped on purpose doesn't count as a failure. - As the Day shift, I want a failed Ticket run that released its Claim, with nothing on origin, to get no
agent-failed, so that an issue already back in line doesn't count. - As the Day shift, I want
agent-failedtaken off when I putready-for-agentback, so that handing a failure back frees its slot straight away. - As the Day shift, I want
agent-failedtaken off when I takein-progressoff to take the issue over, so that taking over a failure also frees its slot. - As the Day shift, I want the Sweep to take
agent-failedoff closed issues, as it takesin-progressoff them, so that closing a failure frees its slot. - As the Day shift, I want to be able to take
agent-failedoff by hand, so that I can say a failure is dealt with without relabelling anything else. - As the Day shift, I want both of my hosts to see the same count, so that a failure on one host also holds pickup on the other.
- As the Day shift, I want to set the count with
pickup.failure_limitin the User config, so that I can choose how many failures I'll let pile up. - As the Day shift, I want the skipped line to say the repository is at its Failure limit and list the issues it counted, so that I know which failures to look at.
- As the Day shift, I want the label created on a repository that doesn't have it yet, as thirdshift does for its other labels, so that the first failure on a new repository doesn't fail to label.
- As the Day shift, I want
agent-failedadded even when the Command was interrupted, as Claim ending is, so that a failure that ended by interruption still counts. - As the Day shift, I want my old
pickup.limitline to keep my cron jobs running afterthirdshift update, so that one release doesn't stop every Pass on both hosts. - As the Day shift, I want a warning naming
pickup.failure_limitwhilepickup.limitis still in my config, so that I know to replace it. - As the Day shift, I want that warning in the Activity log only once, not on every pass, so that a Pass every minute doesn't flood it.
- As the Day shift, I want
pickup.failure_limit = 0refused with the same message as other limits, so that a typo can't switch off the brake by accident.
Command limit:
- As the Day shift, I want to set
[pass] command_limitin the User config, so that I can let a repository run more than one Command at once on a machine big enough for it. - As the Day shift, I want the default to stay 1, so that nobody's machine or harness plan suddenly runs more at once after an update.
- As the Day shift, I want a Ticket run I start by hand on an Issue URL to count toward the limit, so that cron backs off while I work on the repository.
- As the Day shift, I want a command I type to never be refused for the limit, so that I can always start work by hand.
- As the Day shift, I want a Pass's dispatched Spec run or Ticket run to count as part of that Pass, so that the limit counts Commands, not the Ticket runs inside them.
- As the Day shift, I want a Pass skipped for the limit to exit 0, say so in one line, and send no Run notification, as it does today, so that frequent cron lines stay quiet.
- As the Day shift, I want a skip for the Command limit to say how many Commands are running and what the limit is, so that I can tell it from a skip for the Failure limit.
- As the Day shift, I want a Command that ends, however it ends, a crash included, to free its slot, so that a dead process never holds the repository.
- As the Day shift, I want two Pickup runs that pick the same Ready issue to start one run on it, and the loser to try the next Ready issue, so that overlapping Pickup runs add throughput instead of skipping each other.
- As the Day shift, I want the limit to count only this repository, so that busy work on one repository doesn't stop another's cron line.
- As the Day shift, I want load across all my repositories to stay with the
[resources]memory and load waits, so that I have one place to protect the machine. - As the Day shift, I want a thirdshift from before this change and one from after to still keep each other out, so that a half-updated machine never runs two Passes the old binary thinks are exclusive.
Mixed Passes:
- As the Day shift, I want an Architect run to start while a Pickup run's Ticket run is still running, up to the Command limit, so that a busy backlog doesn't starve architecture review.
- As the Day shift, I want a Security run to start alongside Pickup runs and an Architect run, up to the limit, so that audits keep their schedule.
- As the Day shift, I want a second Architect run on a repository skipped while one is running, so that two reviews never race for the same top recommendation and publish duplicate plans.
- As the Day shift, I want a second Security run on a repository skipped while one is running, so that findings and fixes are never published twice.
- As the Day shift, I want an Architect run and a Security run running at once to each have their own review worktree, so that neither deletes the other's worktree mid-session.
- As the Day shift, I want an Architect run's dispatch of its plan to take the same origin reservation a Pickup run takes, so that an overlapping Pickup run can't start a second run on the same issue.
- As the Day shift, I want a Security run's dispatch of a fix to take that reservation too, for the same reason.
- As the Day shift, I want an issue-less Custom process to count toward the limit and to be skipped at it like any other Pass, so that my own processes share the same rule.
- As the Day shift, I want a Security run's rule about a pending fix to still be right with overlapping Passes, so that a live fix is never mistaken for a failed one.
Day shift visibility:
- As the Day shift, I want
thirdshift statusand the Console's Inbox to show each overlapping Command on its own row, as they do today, so that more at once doesn't hide any of them. - As the Day shift, I want the guide and the User config comments to describe both limits, their defaults and how to raise them, so that I can configure them without reading the code.
- As the Day shift, I want the Activity log to record skips for each limit, once per change of reason, so that I can see over time what held pickup back.
Implementation Decisions
- The
agent-failedlabel joins thirdshift's own labels, besidein-progress, and is created on a repository that lacks it, as the others are. It is added in the same ending path that decides whether a Claim is kept or released. It is added only when the Claim is kept and the Command did not end ready, merged or by a Stop. A hold that leaves the pull request ready (PolicyRefusal, SecurityHold, MergeHold) adds none. A failed Security fix keeps its Claim as today, and addsagent-failed. Labelling finishes even after Command interruption, as Claim ending does. - Taking
agent-failedoff. The Sweep takesagent-failedoff closed issues as well asin-progress, and keeps the issue's other labels. Before counting, a Pickup run takesagent-failedoff any open issue that also hasready-for-agent, or has neitherin-progressnorneeds-triage, and doesn't count it. Making a Claim on an issue takesagent-failedoff it too. A failure to take the label off is a warning, never a failure, like the Sweep. - The count. The Pickup decision counts open issues labelled
agent-failed, after the Sweep and that clean-up, in place of open issues labelledin-progress. At or abovepickup.failure_limitthe Pass is skipped, its line listing the counted issues, lowest number first. Overlapping Pickup runs each count before either makes a Claim, so the limit can be passed by up to the Command limit minus one. That is accepted, because it is a brake, not an exact count. - User config.
pickup.failure_limitis a whole number from 1 up, default 3, commented "how many open issues the factory failed on stop a Pickup run taking another".[pass] command_limitis a whole number from 1 up, default 1, commented "how many Commands running on one repository on this machine stop a Pass starting another".pickup.limitis accepted and ignored. Each Command warns on stderr that it is ignored and namespickup.failure_limit, and the Activity log records the warning once per change. The key is removed a few releases later. Setup's defaults and the guide list both new settings and not the old one.
- The Command limit replaces the Pass lock.
- Each live Command on a repository holds one slot in a per-repository directory under
~/.thirdshift. That includes Ticket runs and Spec runs started on an Issue URL, which take no lock today. - A slot is an advisory file lock that the operating system releases when the process ends, so a crash frees it.
- A Pass counts the held slots before it takes one, and is skipped when the count is at the limit. A Command started on an Issue URL takes a slot without checking the count.
- Counting and taking happen under a short lock, so that two Passes starting together can't both take the last slot.
- A dispatched child takes no slot of its own, because it runs inside its parent's process.
- Each Pass also tries today's lock file. The existing directory name was kept for this, so that an older thirdshift still sees a Pass running. With
command_limit = 1the old and new binaries behave the same.
- Each live Command on a repository holds one slot in a per-repository directory under
- Each kind alone with itself. An Architect run and a Security run each also take a lock per kind on the repository, and are skipped while another of their kind holds it. A Pickup run takes no lock per kind. An issue-less Custom process takes none, and counts only toward the Command limit.
- Review worktrees per kind. The Architect review keeps
<repo>-architect. The Security audit, fix and close move to a worktree of their own, beside the existing Security reproduction worktree. The stale disposal of each review worktree runs only under its kind's lock, so it never meets a live worktree of the same kind. - Reservations for every dispatch. An Architect run dispatching its plan, and a Security run dispatching a fix, take the origin reservation that ADR 0017 gives a Pickup run, before marking the issue Ready and dispatching it. They release it the same way. A Pickup run that finds the issue reserved moves on.
- A Pickup run that loses a reservation tries the next Ready issue in its order, instead of being skipped as
IssueUnavailable. It is skipped only when no Ready issue is left that it can reserve. - The Architect and Security gates keep their rules. Their comments and the Security run's pending-fix rule stop saying that the Pass lock rules out a live dispatch. A pending fix is read as failed only when no Security run holds that kind's lock.
- ADR. One ADR, written with the first Ticket: "Pickup counts failures, not Claims, and Passes share a repository up to a Command limit". It records why open pull requests stopped counting, why a label and not inference from branch heads, why the limit is per repository and not per machine, and that it supersedes ADR 0009's "one unattended run per repository at a time on a machine".
Testing Decisions
-
A good test drives
thirdshiftthe way the Day shift does: the CLI against the fakeghand the fake Harnesses. It checks what thirdshift prints, its exit code, the labels and calls the fakeghrecords, and the Activity log. It never reaches into internals. No new seams. -
Pickup runs (
tests/pickup_run.rs):- three
agent-failedissues skip the Pass, naming them; - three
in-progressissues with ready pull requests don't skip it; - each way of taking the label off frees the slot;
- the Sweep clears
agent-failedon closed issues; - the loser of a reservation takes the next Ready issue.
Prior art:
the_sweep_comes_before_the_count_on_a_pass_skipped_for_the_claim_limit(unit, besidedecide),two_machines_racing_for_a_ready_issue_start_exactly_one_run, andpickup_race. - three
-
Failed and stopped runs (
tests/failed_run.rs,tests/stop.rs,tests/merge_run.rs):- a failed Ticket run that keeps its Claim adds
agent-failed; - one that releases its Claim doesn't;
- a Stop and a held Self-merge don't;
- an interrupted failure still does.
- a failed Ticket run that keeps its Claim adds
-
The Pickup decision unit tests beside
decidecountagent-failedin place ofin-progress, and keep the Sweep-first order. -
User config (
tests/user_config.rsand the config unit tests):- both new keys are read and defaulted;
- 0, negative, fractional and quoted values are refused;
pickup.limitis accepted, ignored and warned about.
Prior art:
pickup_limit_is_read_and_defaults_to_3and the refusal table. -
The Command limit, with two
thirdshiftprocesses at once (tests/architect_run.rs,tests/pickup_run.rs):- at
command_limit = 1, a second Pass is skipped as today; - at 2, two Pickup runs both start;
- a hand-started Ticket run fills a slot but is never refused;
- a killed Command frees its slot.
Prior art: the
ALREADY_RUNNINGtests intests/architect_run.rs. - at
-
Mixed Passes (
tests/architect_run.rs,tests/security_run.rs):- an Architect run starts beside a live Pickup run;
- a second Architect run, or a second Security run, is skipped;
- an Architect run and a Security run at once keep separate review worktrees, and neither's stale disposal removes the other's;
- an Architect plan's dispatch takes a reservation that a Pickup run then respects.
Out of Scope
- A cap on Commands across all repositories on a machine. The
[resources]memory and load waits stay the machine-wide protection. A per-machine count would be its own issue (Q3.1). - Two Architect runs, or two Security runs, on one repository at once (Q2.4 (c)).
- Any change to the Ready issue rules, blockers included. A blocked issue still waits for its blocker (Q1.3).
- Stacking an issue's branch on its blocker's branch.
- Changing the default Command limit above 1 (Q3.2).
- Inferring failure from branch heads, pull request drafts or local history (Q2.5 (b)).
- Mapping an old
pickup.limitvalue ontopickup.failure_limit(Q3.4).
Further Notes
- Tickets, roughly in order:
- Failure limit. The
agent-failedlabel and its lifecycle, the count in place of the Claim limit,pickup.failure_limit, the ignoredpickup.limitwith its warning, the guide, Setup's defaults, and the ADR. - Command limit for Pickup runs.
[pass] command_limitin place of the one-wide Pass lock, slots for Commands started on an Issue URL, compatibility with the old lock file, and the loser of a reservation moving on. Architect runs, Security runs and issue-less Custom processes still need the repository to themselves. Blocked by nothing. - Mixed Passes. The locks per kind, the Security review worktree of its own, reservations for Architect and Security dispatches, and the pending-fix rule. Blocked by 2.
- Failure limit. The
- No Ticket needs a release of an earlier one, so the Spec needs no split ("Split a Spec at a release" in
docs/agents/triage-labels.md). After the Spec PR is released, the Day shift replacespickup.limitwithpickup.failure_limiton each host and raisescommand_limitwhere the machine allows. That edit is not a Ticket. - Today's backlog on thirdshift is held back by readiness, not by either limit: Spec: judge Experiments only on discriminating Eval tasks #1477 and its Tickets wait for Spec: a Bar a release that changes nothing can pass #1252, whose Spec PR Spec: a Bar a release that changes nothing can pass #1279 is a draft.
- make default thirdshift behavior to keep working ready-for-agent issues without being limited by number of in-progress issues on the repo or number of PRs unmerged or anything #1532 is the source issue. This Spec covers all of it.
Activity
Glossary: Failure limit and Command limit, from the #1532 grill
Spec #1564: address review of the whole Spec
Spec #1564: preserve legacy Pass exclusion across upgrades