Skip to content

Keep worker records holding unlanded branches past the crew cap - #1610

Merged
currentbits merged 9 commits into
mainfrom
coder/p2-worker-cap-can-purge-branch-provenanc-d3193f
Oct 13, 2026
Merged

currentbits merged 9 commits into
mainfrom
coder/p2-worker-cap-can-purge-branch-provenanc-d3193f

Conversation

@currentbits

Copy link
Copy Markdown
Owner

What changed

The per-orchestrator worker cap (MAX_WORKERS_PER_ORCHESTRATOR) archived any finished worker that had no worktreePath. But a null worktreePath doesn't mean the worker had nothing left to land. When worktree GC or clearMissingWorktree removes a worker's directory, the branch ref stays in the repo. They were also clearing branch on the thread, so the cap could purge the only record linking back to those commits (#1404).

  • worktrees-gc.js / worktrees-lifecycle.js: when clearing worktreePath and branch, save the old branch name as retainedBranch so the record still points at the ref.

  • runner-orch-notices.js: add holdsUnlandedBranch(t). The cap now skips a worker if its branch or retainedBranch still has commits that haven't landed on its base, i.e. recordedBaseBranch or, failing that, the repo's default branch. A worker can still be purged if:

    • it has no branch,
    • its PR state is MERGED,
    • its ref no longer exists, or
    • branchLanded reports it as landed.

    If the answer is unknown (missing project, remote project, project path gone, or a git error), the worker is treated as unlanded and kept.

The cap only drops the thread record. It never deletes the branch ref.

Tests

Two new cases in orchestrator-threads.test.js. Each creates a real worktree for the oldest worker, lets gcClean reclaim it, then adds MAX_WORKERS_PER_ORCHESTRATOR newer workers:

  • With a unique commit on the branch, the old worker survives, retainedBranch is set, and the crew ends at cap + 1.
  • With no new commits, the old worker is still purged and the branch ref is still in the repo.

Notes

holdsUnlandedBranch runs git synchronously for each worker over the cap. Workers kept this way get checked again every time the crew finishes. A ponytail: comment notes that results could be cached by ref sha if crews grow large.

🤖 Generated with Claude Code

Willem and others added 6 commits October 12, 2026 12:06
@currentbits
currentbits enabled auto-merge (squash) October 12, 2026 20:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T20:07:23.122111Z d66a5ec PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d66a5ece6a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread electron/worktrees-gc.js
store.updateThread(cand.threadId, {
worktreePath: null,
branch: null,
...(thread.branch ? { retainedBranch: thread.branch } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve earlier retained refs across repeated GC

When clearMissingWorktree has already saved an unlanded branch in retainedBranch, the next run rematerializes the worker on a new branch, and a later gcClean unconditionally replaces the saved name here with that new branch. If the earlier ref contains the unique work and the newer branch is already landed, holdsUnlandedBranch can then purge the worker record, recreating the lost branch-to-thread link this change is intended to prevent. Preserve or evaluate every retained ref rather than overwriting the prior one.

Useful? React with 👍 / 👎.

Comment thread electron/orchServer.js
: {}),
trigger: hasTrigger ? { type: "github", ...triggerRaw } : null,
tier: args && args.tier,
...(args && args.memory != null ? { memory: args.memory } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add memory to the registered tool schema

Although the handler now forwards args.memory, the automation_create input schema at lines 1711–1739 does not declare a memory property. MCP clients therefore are not told they can supply it, and schema parsing may strip or reject it before this handler runs, so chat-created automations cannot use the optional memory field documented by this commit. Add the field to the registered schema and tool description.

Useful? React with 👍 / 👎.

Willem and others added 3 commits October 13, 2026 08:49
HtmlPage used plain React.lazy, which mount() never preloads, so on a
cold CI runner the tool.html card suspended past three flushes and its
late resolve tripped the next test's act() gate. lazyNamed puts it in
the preload set like every other lazy view.

automation-create-mcp and store round-trip expectations predate the
Linear/Sentry trigger fields (#1588) and prLinks normalization.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…indows CI

node --test applies --test-timeout to each file as well as each test.
On windows-latest several renderer files now take 17-20s, so whichever
crosses 20s fails as testTimeoutFailure (appWiring on main #1615,
threadView here) while running in under 3s locally. 60s still catches
a wedged file well inside the 25-minute job limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	electron/test/fixtures/replay/claude-2.1.283-steer.ndjson
#	electron/test/replay-scenarios.test.js
@currentbits
currentbits merged commit 945fbba into main Oct 13, 2026
6 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