Skip to content

A dead git's index.lock no longer blocks a citizen for days: one owner, continuum-git, for the deploy tree and her hands (card d7765b90) - #5464

Merged
joelteply merged 5 commits into
canaryfrom
d7765b90/git-lock
Oct 26, 2026
Merged

joelteply merged 5 commits into
canaryfrom
d7765b90/git-lock

Conversation

@joelteply

@joelteply joelteply commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Serves the "Useful" step: a resident can't land a PR while her git is locked. On enrico, six of them couldn't commit at all for about ten days.

The incident (enrico, 2026-10-26)

Six residents' workspaces (4c9bb8d9, cf6b4df6/Eitan, 0d5c1ffa, b6dcfc8e, 0051cdcf, 18c04c5b) each had a .git/index.lock:

  • dated 10-14T17:43 to 10-16T23:10;
  • empty;
  • held by no process (lsof empty).

Every git write failed with Unable to create '…/index.lock': File exists until Eitan reported it. I removed all six by hand after checking that no process held them. The deploy consumer hit the same failure on the M5 (card 677437fa) and had solved it for its own tree only.

Likely source (hypothesis, not proven): our own deadline. git_bridge::run_git_input hands git to run_owned_with_input, which kills a git that outlives its deadline (Why::TimedOut), and a killed git leaves its lock.

One owner: continuum-git::index_lock (moved, not copied)

  • verdict(age, stale_after, git_in_tree): stale only when older than the caller's bound and no git might be working in the tree.
  • git_running_in(root): the conservative scan, moved from bin/continuum/deploy_ledger.rs. An unreadable cwd counts as "may be working here".
  • lock_path(root): finds the lock in a clone or in a worktree's .git file, without spawning git.
  • settle(root, stale_after): judges and removes. The process scan runs only when a lock exists, so a clean tree costs one stat.

Users

  • Deploy consumer: settle_index_lock now just maps settle() onto its existing notes. The verdict, enum, bound and test leave cli-lifecycle::deploy_tracker.
  • A citizen's git: run_git_input settles before every git call, with the 10-minute bound. Right after it ends a git on its own deadline, it settles with a zero bound: that lock belongs to the git we just ended, unless another git now works in the tree. The scan runs in spawn_blocking. Every outcome is probed: hands.git.index_lock_{held,cleared,unremovable,unjudged}.

Wiring

continuum-git is in all four lists:

  • TESTED_CRATES, as NO_FIXTURES;
  • the crate-test allowlist;
  • MODULE_CRATES, through its index_lock.rs module;
  • the warning count.

The selector tests name the floor crates (base, host, git) once and pin the scope of a git change.

Measured

  • IntelMac, local:
    • continuum-git 2/2: the verdict table, plus clone and worktree locks found and cleared;
    • the selector test file passes;
    • cli-lifecycle 83/84, the one failure in installed_release, which this change doesn't touch.
  • CI: hands and core compile and test there. I stopped local builds on this node after they coincided with serving.throughput.degraded; enrico serves on the CPU.
  • Live receipt (owner: Cormac, 24 h after deploy on enrico):
    • hands.git.index_lock_cleared, with ages and stale bounds;
    • no Unable to create … index.lock in residents' git results;
    • whether any clear follows a deadline kill, which would confirm the hypothesis.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply added a commit that referenced this pull request Oct 26, 2026
…nly the judged lock is unlinked (Codex on #5464)

Holder matching: may_work_on (pure) judges a git by every way it can name the tree: cwd inside
the work root or the administrative gitdir, --git-dir/--work-tree/-C arguments, or
GIT_DIR/GIT_WORK_TREE in its environment, each as given or canonical. A git launched from
elsewhere with --git-dir=<a worktree's gitdir> names no work root, and was read as absent. An
unreadable cwd is still "may be working here". git_running_in(root, gitdir) reads cmd, cwd and
environ.

Replacement race: settle records the lock's file identity (continuum_host::file_identity) before
the scan and re-reads it before unlinking; a lock re-created in between is another file and is
left in place.

Tests: a_git_naming_the_tree_any_way_may_hold_its_lock (--git-dir, GIT_DIR, -C, cwd in root,
cwd in gitdir, unreadable cwd; another tree's GIT_DIR is not a holder); the worktree fixture
pins that a re-created lock reads as another identity. continuum-git now depends on
continuum-host, so a host change selects it (selector test updated, passes). Not built
locally: no cargo on enrico during the #5462 receipt window; CI compiles and tests it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 26, 2026
…m; the judged lock stays open until the unlink (Codex on #5464)

may_work_on resolves path-valued options against the cwd after each ordered -C (=value and
separate forms) and GIT_DIR/GIT_WORK_TREE against both the process cwd and the final -C
directory, normalizing . and .. lexically. Regressions: relative --git-dir (both forms),
relative GIT_DIR, -C then relative --git-dir, ordered -C into the root, a .. path, and a
relative path naming another tree (not a holder).

settle keeps the judged lock's handle open through revalidation and the unlink, so its
identity cannot be reused by a re-created file. The test now holds the handle rather than
assuming a fresh inode. The doc states the remaining window: a replacement landing between the
last identity read and the unlink would be removed (portable code cannot unlink by handle).
Not built locally (no cargo on enrico during the #5462 receipt window); CI compiles it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 26, 2026
… ALL -C options, as git does (Codex on #5464)

Regression: git --git-dir=.git/worktrees/tree -C /repo status from /elsewhere names
/repo/.git/worktrees/tree. The directory where the option sits is kept too, conservatively.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@github-actions github-actions Bot added size: XL and removed size: L labels Oct 26, 2026
joelteply added a commit that referenced this pull request Oct 26, 2026
joelteply added a commit that referenced this pull request Oct 26, 2026
…nly the judged lock is unlinked (Codex on #5464)

Holder matching: may_work_on (pure) judges a git by every way it can name the tree: cwd inside
the work root or the administrative gitdir, --git-dir/--work-tree/-C arguments, or
GIT_DIR/GIT_WORK_TREE in its environment, each as given or canonical. A git launched from
elsewhere with --git-dir=<a worktree's gitdir> names no work root, and was read as absent. An
unreadable cwd is still "may be working here". git_running_in(root, gitdir) reads cmd, cwd and
environ.

Replacement race: settle records the lock's file identity (continuum_host::file_identity) before
the scan and re-reads it before unlinking; a lock re-created in between is another file and is
left in place.

Tests: a_git_naming_the_tree_any_way_may_hold_its_lock (--git-dir, GIT_DIR, -C, cwd in root,
cwd in gitdir, unreadable cwd; another tree's GIT_DIR is not a holder); the worktree fixture
pins that a re-created lock reads as another identity. continuum-git now depends on
continuum-host, so a host change selects it (selector test updated, passes). Not built
locally: no cargo on enrico during the #5462 receipt window; CI compiles and tests it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 26, 2026
…m; the judged lock stays open until the unlink (Codex on #5464)

may_work_on resolves path-valued options against the cwd after each ordered -C (=value and
separate forms) and GIT_DIR/GIT_WORK_TREE against both the process cwd and the final -C
directory, normalizing . and .. lexically. Regressions: relative --git-dir (both forms),
relative GIT_DIR, -C then relative --git-dir, ordered -C into the root, a .. path, and a
relative path naming another tree (not a holder).

settle keeps the judged lock's handle open through revalidation and the unlink, so its
identity cannot be reused by a re-created file. The test now holds the handle rather than
assuming a fresh inode. The doc states the remaining window: a replacement landing between the
last identity read and the unlink would be removed (portable code cannot unlink by handle).
Not built locally (no cargo on enrico during the #5462 receipt window); CI compiles it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 26, 2026
… ALL -C options, as git does (Codex on #5464)

Regression: git --git-dir=.git/worktrees/tree -C /repo status from /elsewhere names
/repo/.git/worktrees/tree. The directory where the option sits is kept too, conservatively.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 26, 2026
joelteply and others added 5 commits October 26, 2026 09:15
…r, continuum-git, for the deploy tree and her hands (card d7765b90)

On enrico (2026-10-26) 6 residents' workspaces held .git/index.lock dated 10-14..16, empty, held
by no process. Every git write failed ("Unable to create .../index.lock: File exists") for
~10 days until Eitan reported it; I removed them by hand. The deploy consumer had the same
failure on the M5 (card 677437fa) and solved it for its own tree only.

The likely source is our own deadline: run_git_input's owner kills a git that outlives its
deadline (Why::TimedOut), and a killed git leaves its lock.

continuum-git::index_lock is now the one owner (moved, not copied):
- the verdict (stale only when older than the caller's bound AND no git might work in the tree);
- the conservative live-git scan (moved from bin/continuum deploy_ledger);
- a lock locator that needs no git process (clone or worktree .git file);
- settle(), which judges and removes.
Users:
- the deploy consumer's settle_index_lock is a thin mapping of settle() onto its notes; the
  verdict, enum, bound and test leave cli-lifecycle's deploy_tracker;
- a citizen's git (git_bridge::run_git_input) settles before every git with the 10-min bound,
  and with a zero bound right after it ends a git on its deadline (that lock is that git's
  unless another git now works in the tree). The scan runs in spawn_blocking and only when a
  lock exists, and each outcome is probed (hands.git.index_lock_{held,cleared,unremovable}).

The new crate is in all four lists (TESTED_CRATES with no fixtures feature, the crate-test
allowlist, MODULE_CRATES via its index_lock.rs module, the warnings count). The selector test
names the floor (base, host, git) once and pins a git change's scope.

Local (IntelMac, before stopping builds here): continuum-git 2/2; selector tests pass.
cli-lifecycle 83/84, one failure in installed_release (untouched by this change, judged by CI).
hands and core compile and test in CI: local builds were stopped on this CPU-serving node
after they coincided with serving.throughput.degraded.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…nly the judged lock is unlinked (Codex on #5464)

Holder matching: may_work_on (pure) judges a git by every way it can name the tree: cwd inside
the work root or the administrative gitdir, --git-dir/--work-tree/-C arguments, or
GIT_DIR/GIT_WORK_TREE in its environment, each as given or canonical. A git launched from
elsewhere with --git-dir=<a worktree's gitdir> names no work root, and was read as absent. An
unreadable cwd is still "may be working here". git_running_in(root, gitdir) reads cmd, cwd and
environ.

Replacement race: settle records the lock's file identity (continuum_host::file_identity) before
the scan and re-reads it before unlinking; a lock re-created in between is another file and is
left in place.

Tests: a_git_naming_the_tree_any_way_may_hold_its_lock (--git-dir, GIT_DIR, -C, cwd in root,
cwd in gitdir, unreadable cwd; another tree's GIT_DIR is not a holder); the worktree fixture
pins that a re-created lock reads as another identity. continuum-git now depends on
continuum-host, so a host change selects it (selector test updated, passes). Not built
locally: no cargo on enrico during the #5462 receipt window; CI compiles and tests it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…m; the judged lock stays open until the unlink (Codex on #5464)

may_work_on resolves path-valued options against the cwd after each ordered -C (=value and
separate forms) and GIT_DIR/GIT_WORK_TREE against both the process cwd and the final -C
directory, normalizing . and .. lexically. Regressions: relative --git-dir (both forms),
relative GIT_DIR, -C then relative --git-dir, ordered -C into the root, a .. path, and a
relative path naming another tree (not a holder).

settle keeps the judged lock's handle open through revalidation and the unlink, so its
identity cannot be reused by a re-created file. The test now holds the handle rather than
assuming a fresh inode. The doc states the remaining window: a replacement landing between the
last identity read and the unlink would be removed (portable code cannot unlink by handle).
Not built locally (no cargo on enrico during the #5462 receipt window); CI compiles it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
… ALL -C options, as git does (Codex on #5464)

Regression: git --git-dir=.git/worktrees/tree -C /repo status from /elsewhere names
/repo/.git/worktrees/tree. The directory where the option sits is kept too, conservatively.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@github-actions github-actions Bot added size: L and removed size: XL labels Oct 26, 2026
@joelteply
joelteply merged commit d600a5b into canary Oct 26, 2026
36 checks passed
@joelteply
joelteply deleted the d7765b90/git-lock branch October 26, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant