Skip to content

feat(bin): per-run scratch worktrees for scheduled tasks - #11486

Merged
dezren39 merged 1 commit into
mainfrom
claude/creator-scratch-run-id-11348
Nov 18, 2026
Merged

dezren39 merged 1 commit into
mainfrom
claude/creator-scratch-run-id-11348

Conversation

@dezren39

@dezren39 dezren39 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Before: The improvement-issue-creator briefs named their scratch worktree from the date and a per-day counter, guarded it with test -d … ||, piped worktree add through tail, and cleaned up with git 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.mjs gives 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) when worktree add fails, and prints the path plus an owner token as JSON. remove deletes 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/remove before #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 existing bin/*.test.mjs workflow.

Part of #11348


Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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
dezren39 marked this pull request as ready for review November 18, 2026 04:14
@dezren39
dezren39 requested a review from a team as a code owner November 18, 2026 04:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T04:15:38.551032Z d412475 Draft marked ready
ℹ️ 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.

@dezren39
dezren39 merged commit 44f991e into main Nov 18, 2026
@dezren39
dezren39 deleted the claude/creator-scratch-run-id-11348 branch November 18, 2026 04:14
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

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.

2 participants