Repository navigation
Conversation
Previews
The landing-page preview creates workspaces on staging-coder.ddev.com, and its Documentation links open the docs preview. Read the Docs posts its build status and changed pages in its own comment; the docs preview may take a minute or two after a push to update. Updated for 7cacb65 |
Documentation build overview
|
claude-runner-sweep cleans a self-hosted runner's checkouts after each session. A macOS runner reuses one checkout per repository across sessions too, so it needs the same cleanup. Under macOS's bash 3.2 the script exited with "candidates[@]: unbound variable" when the runner directory held no checkouts. It also logged with GNU `date -Is`, which BSD date may not support. The script now expands the array safely, logs UTC timestamps in a format every date supports, and skips the `sessions` directory that the runner creates in its base directory on macOS, as it already skipped `_sessions`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3Cc2FfNKgEMqAZMMRVvjp
git worktree list prints paths with symlinks resolved. When the runner directory sits behind a symlink, as under macOS /var, claude-runner-sweep didn't recognize the main checkout in that list. It labeled the checkout's stash as a worktree and ran git worktree remove --force on the checkout, which git refused. The sweep now compares worktree paths with the checkout's resolved path too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3Cc2FfNKgEMqAZMMRVvjp
The runner clears each clone's stash reflog between sessions, so `git stash list` showed none of the sweep's runner-rescue stashes. Only the newest survived, as refs/stash, and the older ones were left for git gc. The sweep now also points a ref under refs/runner-rescue/ at each rescue stash. Names get a counter when one already exists. The sweep adopts an earlier sweep's rescue still in refs/stash, and expires rescue refs after CLAUDE_RUNNER_RESCUE_DAYS. The docs, runner README, skill and SessionStart hook now say to list rescues with `git for-each-ref refs/runner-rescue` and restore one with `git stash apply <ref>`. Leftovers a session stashes itself get a ref too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3Cc2FfNKgEMqAZMMRVvjp
rfay
force-pushed
the
20261117_rfay_portable_runner_sweep
branch
from
November 17, 2026 18:03
3f6be7a to
cad7e74
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3Cc2FfNKgEMqAZMMRVvjp
The macOS runner keeps session state in _sessions, like the Coder runner, so the extra skip for sessions matched nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3Cc2FfNKgEMqAZMMRVvjp
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short Summary (TL;DR)
claude-runner-sweepnow runs on macOS, and its rescues can be found again. The macOS Claude Code runner can use it as a post-session hook. Each rescue stash also gets a ref underrefs/runner-rescue/, because the runner clears the stash list between sessions.The Issue
The sweep cleans a self-hosted runner's checkouts after each session, and stashes uncommitted work as
runner-rescuestashes.git stash listshowed none of them, although the docs said to look there. Only the newest rescue per clone survived, asrefs/stash, and the older ones were left forgit gc. On a Coder runner workspace, the rescue log recorded 49 rescues, andgit stash listshowed none in any clone.candidates[@]: unbound variablewhenever the runner directory held no checkouts.date -Is, which BSDdatemay not support./var→/private/var, it didn't recognize the main checkout ingit worktree list, which prints resolved paths. It labeled the checkout's stash as a worktree, and rangit worktree remove --forceon the checkout, which git refused.How This PR Solves The Issue
refs/runner-rescue/<time>-<session>-<what>for every rescue stash, with a counter when the name existsrefs/stashasrefs/runner-rescue/<time>-earlier-sweepCLAUDE_RUNNER_RESCUE_DAYSgit for-each-ref refs/runner-rescueandgit stash apply <ref>${candidates[@]+"${candidates[@]}"}in both loopsset -u.date -u +%Y-%m-%dT%H:%M:%SZdatesupports this format.pwd -PtooBoth module copies changed, through
make sync-claude-runner-module.Manual Testing Instructions
On a runner with this sweep as its post-session hook, start a session, leave an untracked file in its checkout, and end the session. Start a second session in the same repository and run:
Automated Testing Overview
Claude Code ran scenario scripts with bash 5.2 on Linux and with bash 3.2.57 in the
bash:3.2container, on a runner directory reached through a symlink:.git/logswas deleted, as the runner does. The new sweep adopted that stash as a rescue ref..git/logsdeletions.CLAUDE_RUNNER_RESCUE_DAYS=-1expired all rescue refs.On a macOS 27.2.1 runner, the sweep ran as the post-session hook, with
/bin/bash3.2 and BSD tools. An earlier version found the symlink problem, and showed the session's own rescue missing fromgit stash listin the next session. With this version, one session left a dirty checkout, a dirty worktree, a pushed extra clone and an unpushed extra clone. After it ended, the next session found:-earlier-sweepref in every clone that still had a hidden rescue~/.local/state/claude-runner-rescue/git stash apply <ref>restoring the checkout's changes, including the untracked file🤖 Generated with Claude Code
https://claude.ai/code/session_01T3Cc2FfNKgEMqAZMMRVvjp