Repository navigation
feat(bin): per-run scratch worktrees for scheduled tasks - #11486
Merged
Merged
Conversation
bin/scratch-worktree.mjs names each scratch tree with a UTC timestamp and random suffix, refuses to adopt an existing path, fetches the base and reports worktree add failures, and records an owner token in the worktree's git dir. remove only deletes a clean tree whose token matches, and never forces. The parallel-writers doc points scheduled briefs at it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dezren39
marked this pull request as ready for review
November 18, 2026 04:14
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed.
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. |
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.
Before: The improvement-issue-creator briefs named their scratch worktree from the date and a per-day counter, guarded it with
test -d … ||, pipedworktree addthroughtail, and cleaned up withgit worktree remove --force. A crashed run's tree was adopted by the next run (skipping fetch and base checks) and then force-removed by a run that never created it.After:
bin/scratch-worktree.mjsgives every run its own path (<prefix>-<UTC timestamp>-<random>), refuses loudly (exit 3) to adopt a path that exists, fetches the base and fails (exit 4) whenworktree addfails, and prints the path plus an owner token as JSON.removedeletes a tree only when the token matches and the tree is clean, never with--force, and prints what it removed. The parallel-writers doc tells scheduled briefs to use it.How: The owner token lives in the worktree's own git dir (
.git/worktrees/<name>/scratch-worktree-owner), so it never dirties the tree and a tree made any other way has no record and is never removed.Not in this PR: the creator briefs themselves live in the laptop OpenChamber project store, outside this repo. They still need their scratch steps switched to
add/removebefore #11348's acceptance test is met.Testing:
node --test bin/scratch-worktree.test.mjs(11 passed) against a real bare origin and clone: same-second runs get distinct paths, an existing path is refused, the base is freshly fetched, a bad base fails loudly, remove refuses another run's tree, a dirty tree and a foreign worktree, and the CLI exit codes. Runs in the existingbin/*.test.mjsworkflow.Part of #11348
Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.