Skip to content

Spec: keep working Ready issues - a Failure limit for pickup and a Command limit for Passes #1564

Closed
4 of 4 issues completed

Description

@JacobStephens2

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 while pickup.failure_limit open 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: puts ready-for-agent back, takes in-progress off 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.limit line is accepted, ignored and warned about, so cron jobs on every host keep running across thirdshift update.

User Stories

Failure limit:

  1. 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.
  2. As the Day shift, I want merged work to never count against any limit, so that a busy day of merges never slows pickup.
  3. 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.
  4. 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.
  5. As the Day shift, I want a failed Spec run that keeps its Claim to label its Spec agent-failed too, so that Spec failures count the same way.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. As the Day shift, I want agent-failed taken off when I put ready-for-agent back, so that handing a failure back frees its slot straight away.
  12. As the Day shift, I want agent-failed taken off when I take in-progress off to take the issue over, so that taking over a failure also frees its slot.
  13. As the Day shift, I want the Sweep to take agent-failed off closed issues, as it takes in-progress off them, so that closing a failure frees its slot.
  14. As the Day shift, I want to be able to take agent-failed off by hand, so that I can say a failure is dealt with without relabelling anything else.
  15. 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.
  16. As the Day shift, I want to set the count with pickup.failure_limit in the User config, so that I can choose how many failures I'll let pile up.
  17. 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.
  18. 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.
  19. As the Day shift, I want agent-failed added even when the Command was interrupted, as Claim ending is, so that a failure that ended by interruption still counts.
  20. As the Day shift, I want my old pickup.limit line to keep my cron jobs running after thirdshift update, so that one release doesn't stop every Pass on both hosts.
  21. As the Day shift, I want a warning naming pickup.failure_limit while pickup.limit is still in my config, so that I know to replace it.
  22. 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.
  23. As the Day shift, I want pickup.failure_limit = 0 refused with the same message as other limits, so that a typo can't switch off the brake by accident.

Command limit:

  1. As the Day shift, I want to set [pass] command_limit in the User config, so that I can let a repository run more than one Command at once on a machine big enough for it.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. As the Day shift, I want a Security run's dispatch of a fix to take that reservation too, for the same reason.
  8. 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.
  9. 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:

  1. As the Day shift, I want thirdshift status and 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.
  2. 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.
  3. 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-failed label joins thirdshift's own labels, beside in-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 adds agent-failed. Labelling finishes even after Command interruption, as Claim ending does.
  • Taking agent-failed off. The Sweep takes agent-failed off closed issues as well as in-progress, and keeps the issue's other labels. Before counting, a Pickup run takes agent-failed off any open issue that also has ready-for-agent, or has neither in-progress nor needs-triage, and doesn't count it. Making a Claim on an issue takes agent-failed off 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 labelled in-progress. At or above pickup.failure_limit the 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_limit is 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_limit is 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.limit is accepted and ignored. Each Command warns on stderr that it is ignored and names pickup.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 = 1 the old and new binaries behave the same.
  • 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 thirdshift the way the Day shift does: the CLI against the fake gh and the fake Harnesses. It checks what thirdshift prints, its exit code, the labels and calls the fake gh records, and the Activity log. It never reaches into internals. No new seams.

  • Pickup runs (tests/pickup_run.rs):

    • three agent-failed issues skip the Pass, naming them;
    • three in-progress issues with ready pull requests don't skip it;
    • each way of taking the label off frees the slot;
    • the Sweep clears agent-failed on 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, beside decide), two_machines_racing_for_a_ready_issue_start_exactly_one_run, and pickup_race.

  • 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.
  • The Pickup decision unit tests beside decide count agent-failed in place of in-progress, and keep the Sweep-first order.

  • User config (tests/user_config.rs and the config unit tests):

    • both new keys are read and defaulted;
    • 0, negative, fractional and quoted values are refused;
    • pickup.limit is accepted, ignored and warned about.

    Prior art: pickup_limit_is_read_and_defaults_to_3 and the refusal table.

  • The Command limit, with two thirdshift processes 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_RUNNING tests in tests/architect_run.rs.

  • 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.limit value onto pickup.failure_limit (Q3.4).

Further Notes

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    enhancement
    needs-triage
    on Oct 28, 2026
  2. added
    ready-for-agent
    in-progress
    and removed
    needs-triage
    ready-for-agent
    on Oct 28, 2026
  3. added a commit that references this issue on Oct 29, 2026
  4. added
    ready-for-agent
    in-progress
    and removed
    in-progress
    ready-for-agent
    on Oct 29, 2026
  5. added a commit that references this issue on Oct 29, 2026
  6. removed
    in-progress
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions