Skip to content

feat(placement): fleet host order and lane caps, branch reuse, held-setup retry - #138

Merged
nullStack65 merged 4 commits into
release/native-0.1.10from
feat/clo-932-host-caps
Nov 20, 2026
Merged

nullStack65 merged 4 commits into
release/native-0.1.10from
feat/clo-932-host-caps

Conversation

@nullStack65

@nullStack65 nullStack65 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Lane placement, per-host caps and the memory check (Linear CLO-932).

Why "no machine with spare capacity" kept appearing

The refusal was correct. R720 was at about 1.27 load per CPU against a headless limit of 1, and ASUS was over its limits as well. The refusal message then told callers to "name an environment". Callers did that and pinned R720 by id, which skipped placement altogether. About 14 lanes piled onto R720 and it hung around 01:30 UTC. Two other gaps contributed: headless hosts had no lane cap, and the origin fallback let a laptop keep work it started.

Changes

  1. Host order and caps (Closura default, rule 19). The new automaticPlacementHosts server setting defaults to:

    Host Lane cap
    R720 4 lanes
    ASUS 1 lane
    omarchy 1 lane
    laptop 0 lanes

    Every host also has a 4 GiB available-memory floor. Within each tier the order listed wins, then whichever host has the most room. A host at its cap, below its memory floor, or not reporting its lane count is refused. Hosts that are not listed come after the listed ones and have no cap.

  2. No origin fallback. When nothing has room the result is no-eligible-environment, and the caller retries later (cloud overflow is separate work, Linear CLO-929). The laptop is used only for laptop-bound work (requiresOrigin). For byDefault placement, the fallback to here now happens only within here's own cap. The refusal text no longer encourages pinning.

  3. Worktree branch reuse. When git branch fails with branch_already_exists, an existing branch is reused (git branch --force) if both of these hold:

    • it is not checked out in any worktree
    • it is an ancestor of the start point, meaning it has no commits of its own

    Otherwise the original error stands. The normal path makes no extra git calls. Only thread launches opt in (reuseEmptyBranch). If setup fails after a reuse, the branch goes back to its old tip instead of being deleted.

  4. Held runs after a failed setup. An MCP thread_send that comes back queued and held behind a failed worktree preparation now calls retryPreparation for that run. Before, only the UI Retry button released the hold. The websocket message.dispatch path is unchanged and still relies on Retry.

  5. Caps count active runs. Host snapshots now carry activeRuns: the threads on that server with a preparing, starting, running, waiting or unheld queued run. Caps use that number. Idle provider sessions keep an agent scope populated for 30 minutes to 4 hours, so the scope count kept caps closed while little was running. Peers that do not report activeRuns yet fall back to the scope count. Each placement also reserves a lane, recording the lane count the host reported at that moment. Until the host's own count catches up, it is counted as the larger of what it reports and any reservation's count plus the reservations made since, for up to 60 seconds. So launches that see the same sample cannot both take the last lane, and sequential launches still fill every lane.

Tests

  • shared threadPlacement (fleet order, caps, never the laptop, laptop-bound work)
  • server RemoteDelegation (cap refusal, 0-lane laptop, reservation, active runs preferred over scopes)
  • HostResources (snapshot carries activeRuns) and ProjectionRecovery (active-run thread count)
  • GitVcsDriverCore (reuse versus refuse)
  • OrchestratorMcpService (held send retries setup)
  • typecheck for contracts, shared, server and client-runtime

Failures that already happen on the base, unchanged by this PR:

  • projectGrouping load-balancing fixtures, which have no placementRole
  • shared sqlite WAL, terminalOutput and DST timing tests

Deploy notes

Deploy: fleet

  • omarchy-desktop reports no hostResources, so it is never eligible until it does.
  • R720 had 18 populated agent scopes at 08:35 UTC, but only 5 running runs at 10:15 UTC. With active-run counting it is refused only while 4 or more threads are active.
  • Follow-ups (minor, from the focused re-check):
    • The web composer's placement preview does not yet apply the host order and caps.
    • A reservation stays for up to 60 s when a placement is accepted but its launch is then refused or fails.
    • Reservations do not reach the interactive-tier agent limit.
    • Restoring a reused branch after a failed setup does not restore its upstream.
    • waiting runs, for example a thread waiting on an approval, hold a lane until answered.
    • activeRuns covers one server, not the whole host.
    • A settings entry with a bad maxLanes or environmentId still fails the whole settings decode.

🤖 Generated with Claude Code

…; retry held worktree setup

Automatic placement now tries hosts in a configured order (R720, ASUS,
omarchy, then the laptop) and refuses a host at its lane cap or memory
floor. It never falls back to the machine the work started on, so a
full fleet answers no-eligible-environment and cloud overflow can take
it. The refusal no longer tells callers to name an environment, which
is how R720 was pinned past its limits.

Worktree setup reuses an existing branch with no commits of its own
instead of failing with branch_already_exists. A send held behind a
failed worktree setup now retries that setup.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

nullStack65 and others added 3 commits November 20, 2026 10:11
Branch reuse now needs the caller to ask for it, and only thread launch
does, so the worktree handoff tool and worktree restore keep refusing
an existing branch. A failed worktree add after a reuse puts the branch
back on its old tip instead of deleting it.

Placement counts its own accepted choices from the last minute against
a host's lanes, so launches fanned out against one resource sample
cannot all land on the same host. The refusal no longer names a cloud
overflow route this server does not have, and a host entry without a
memory floor decodes with 4 GiB instead of discarding the settings.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t scopes

Idle provider sessions keep an agent scope populated for 30 minutes to 4 hours, so the
scope count held host lane caps closed with little running. Snapshots now carry
activeRuns: threads with a preparing, starting, running, waiting or unheld queued run.
Caps and the recent-placement reservation use it, falling back to the scope count for
peers that do not report it yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… run

A placement reserved a lane for a flat 60 seconds on top of the host's fresh count, so
sequential launches were refused at about half the cap. Each reservation now records the
lane count the host reported when it was placed, and a host counts the larger of its
reported lanes and any reservation's lanes plus the reservations made since.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@nullStack65
nullStack65 merged commit 3ad1bfd into release/native-0.1.10 Nov 20, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant