Skip to content

fleet creator tasks: clock-derived scratch worktree paths collide across runs — a crashed run's tree is adopted by the next run and then force-removed #11348

Closed

Description

@dezren39

Problem

The improvement-issue-creator scheduled tasks build their scratch worktree path from a per-day counter, not from a run identity:

~/git/fleet/improvement-issue-creator-<repo>-<YYYYMMDD>-lane-b-<N>

Any later run that computes the same counter finds the path already on disk, silently adopts it, skips its own git fetch / base verification, and at the end removes it with git worktree remove --force. A run killed mid-work leaves a worktree behind, and the next run in the same slot inherits and then deletes a tree it did not create — with --force discarding whatever uncommitted work the dead run left in it. The same shape applies to the lane-A and single-lane creator tasks, which use plain date suffixes.

Evidence

1. The 12:30 lane-B run left a worktree behind. Session ses_e5e153a18deffeXNjy7x6pWWL0 (Improvement issue creator — lane B, 2026-11-17 12:30) ran

git -C ~/git/openchamber-fork fetch origin main -q && git rev-parse origin/main &&
git worktree add --detach ~/git/fleet/improvement-issue-creator-openchamber-20261117-lane-b-3 origin/main -q 2>&1 | tail -3

created the tree at 8726d55da, worked in it through an issue filing, then died at 12:32:08 CST with provider.invalid-output: "Gemini stopped with MALFORMED_RESPONSE". The worktree stayed registered and on disk.

2. The 15:00 lane-B run adopted that tree instead of creating its own. Session ses_e5e14b0c236ffeTqatGhbwCswN computed the same path and guarded it with

cd ~/git/fleet && (test -d improvement-issue-creator-openchamber-20261117-lane-b-3 && echo exists ||
  git -C ~/git/openchamber-fork fetch -q origin main &&
  git -C ~/git/openchamber-fork worktree add --detach ~/git/fleet/improvement-issue-creator-openchamber-20261117-lane-b-3 origin/main 2>&1 | tail -n 2)

The test -d succeeded, so the || branch — the only place a fetch and a base check happen — never ran. The run then read code out of the leftover tree, evaluated freshness against it, and filed from it. Its own closing message:

"the scratch path I used already existed before this run, so my cleanup removed a worktree I did not create. Its status was clean and detached at 8726d55da, so no uncommitted work was lost."

3. The cleanup is unconditional and forced. Same session, final tool call:

cd /home/user/git/openchamber-fork && git worktree remove --force ~/git/fleet/improvement-issue-creator-openchamber-20261117-lane-b-3

--force removes a tree even when it is dirty. In this instance the tree happened to be clean, so nothing was lost; the guard against loss is the dead run's good luck, not the design.

4. The path is not per-run. Other runs of the same task in the same day used improvement-issue-creator-openchamber-20261117-lane-b (ses_e5e15dedab2ffeTmoac5fMzqYw, 09:30), …-lane-b-2 (ses_e5e155592aaffeLO8ELG17jTIc, 12:00) and …-c (ses_e5e14f57015ffe7uavuSE9O4AR, 13:45). The counter is the only distinguishing element, so any run that recomputes an occupied counter collides, and a crashed run's path stays occupied until the counter advances.

5. worktree add failure is invisible. The add is piped (… 2>&1 | tail -3, … | tail -n 2), so the recorded exit status is tail's. Both runs recorded exit 0; neither status proves the add succeeded.

Why it matters

  • A crashed creator run does not fail cleanly: it holds a path that the next run adopts, so the fleet's "fresh worktree from origin/<base>" rule (doc/agents/parallel-writers-and-subsessions.md) is silently skipped and issues can be filed against a stale tree.
  • The adopting run's --force removal can destroy uncommitted work belonging to another run, and nothing records that it happened.
  • Concurrent invocation is not excluded: the path is a function of the clock, not of the run.

Suggested fix shape

  • Put a per-run unique id in the path (…-lane-b-<YYYYMMDDTHHMMSSZ> or the session id), so no two runs can ever name the same directory.
  • Refuse, loudly, to adopt a pre-existing scratch path: test -d should abort the run with a message naming the path, not fall through to reuse.
  • Drop --force on cleanup, or gate it on the tree being clean and belonging to this run; record what was removed.
  • Stop masking worktree add failure: don't pipe it through tail, or check the real status.

Acceptance test (one line)

Two runs of the same creator task — including a run that follows a crashed one — never share a scratch worktree: each path carries a per-run unique id, adoption of an existing path aborts with a loud error, and no run removes a worktree it did not create.

Filing note

Filed by the builder's-advocate run of 2026-11-17 15:00 CST from the fleet census. The scheduled-task brief that produces these paths lives in the laptop OpenChamber project store (~/.config/openchamber/projects/path_L2hvbWUvdXNlci9naXQvY29kZQ.json, task 8560b7ff… "Improvement issue creator — lane B"), which doc/fleet-schedule-registry.md §2a points at; the brief text and the registry pointer both change under this issue. A triage packet is enqueued in repo-health-code-pilot in the same pass.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/highImportant and time-sensitive
    effort/sSmall: expected under 2 hours of work
    on Nov 17, 2026
  2. developing-today commented on Nov 17, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Repo-side verification (repo-health queue task 20768, openchamber scheduled lane, 2026-11-18). PR #11486 (feat(bin): per-run scratch worktrees for scheduled tasks) is MERGED 2026-11-18T04:14Z. It covers the in-repo half: per-run unique paths, abort on adoption, ownership-gated removal, and no masking of worktree add failures (bin/scratch-worktree.test.mjs is on main). Still outside the repo: the laptop OpenChamber project-store brief (task 8560b7ff) must adopt the same contract. Left open for the owner to confirm the laptop brief update before closing.

  4. removed their assignment
    on Nov 20, 2026
  5. dezren39 commented on Nov 21, 2026

    @dezren39
    MemberAuthor

    The laptop half is done too. Checked on the laptop just now: both scheduled creator tasks in OpenChamber ("Improvement issue creator" and "Improvement issue creator — lane B") take their worktree from the per-run scratch-worktree helper from #11486, and neither builds the old date or -lane-b-<N> path any more. They're the only scheduled tasks that create worktrees. With #11486 on main, this issue can be closed as fixed.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/highImportant and time-sensitivesource/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions