Skip to content

refactor(git): every git the core waits on is one owned async run; blocking_git, the blocking-thread admission and github's git_output are deleted (card bfa87dd5) - #5037

Merged
joelteply merged 7 commits into
canaryfrom
bfa87dd5/code-git-bridge-every-git-call-becomes-a
Oct 14, 2026
Merged

joelteply merged 7 commits into
canaryfrom
bfa87dd5/code-git-bridge-every-git-call-becomes-a

Conversation

@joelteply

@joelteply joelteply commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Why

Card bfa87dd5, the git half of #5030/#5035's one-owner work. code::git_bridge ran about 20 git calls as sync std::process children with no bound.

  • Callers wrapped them in blocking_git (hands::spawn_blocking). A cancelled command couldn't end the git or what it started, and a hung git held a release forever.
  • The act-end sync ran about 12 of them on one blocking thread. SYNC_BOUND bounded the caller's wait, not the git: a hung push kept running past it.

The design was reviewed before it was written (Codex root, fc2f8e6f): one async owned runner; delete blocking_git; keep env and authority; one absolute deadline across a sync's calls.

What

One runner. git_bridge::run_git_input (with run_git and run_git_with_env over it) runs every git through lane_process::run_owned_with_input. It is owned, its tree ends with its waiter, and it holds the hands' admission until that end. Output not read whole, or stdin not delivered whole, is an Err, never a result.

  • The env hygiene stays in that one place: GIT_DIR etc. stripped, GIT_CEILING_DIRECTORIES, GIT_TERMINAL_PROMPT=0.
  • The caller's env is now applied LAST, as the doc already said. The one deliberate exception names itself: the citizen layer's rev-parse --show-toplevel lifts the ceiling, because that call is the upward discovery.
  • Every git_bridge fn is async.

One deadline. git_bridge::within(deadline, fut) is a task-local absolute deadline. Every git under it gets only what is left, and none starts with nothing left.

  • A git the deadline ends reads as interrupted (its effect unknown), never "failed".
  • The act-end sync (sync_by) spends the deadline on the checkout lock too. The lock is now a tokio::sync::Mutex held across the awaits.
  • A push the deadline ends is PushOutcome::PushInterrupted. It marks the remote unknown, and the next sync fetches the branch before deciding to publish.
  • A cancelled sync can't let the next one in early (reviewer, bf7c5ada). Every git the sync starts keeps the checkout lock until that git's tree has ended, through the new lane_process::holding(value, work). That generalizes the lifetime the hands lease already had, instead of adding a parallel path. An unconfirmed end hands kept to the gate beside lingering, and a re-check releases it. holding without an admission is refused before spawning.
  • The remote is unknown from BEFORE the push. The runner returns GitError { end: NeverRan | Refused | Unknown }, and only a conclusive end clears the mark. A cut-off push, output that wasn't whole or readable, or a runner error all leave it unknown.
  • The runner reads the shared OwnedOutput::answer() (fix(process): an exited child's own failure outranks an input-delivery note; OwnedOutput::answer is the one projection (card 25160dd7) #5038). A non-zero exit is git's own failure, with any delivery note beside it.
  • move_blocker_bounded and arrive_for run within their existing bounds. SYNC_BOUND is still unmeasured; card c1bdc29b measures it.

Callers migrated:

  • the seven code/git/* commands;
  • ensure_engine, ensure_citizen_layer and the workspace-map RAG reader. WorkspaceLayoutReader::layout is now async. It used to run git_sync_from_shared synchronously inside an async RAG load, blocking a runtime worker;
  • cognition/replay;
  • benchmark/dispatch's origin slug. Its comment said git walks up from the cwd, but the runner caps discovery there; the comment is corrected;
  • code/github/pr-create's preflight.

Deleted

  • commands/code/git::blocking_git.
  • hands::spawn_blocking, BlockingAdmission and BLOCKING_ADMITTED (blocking-thread admission). No caller is left: a git's child keeps the admission through run_owned. That removes three tests that pinned the deleted mechanism; the replacement contract is tested below.
  • code/github::git_output and git_quiet, the same spawn_blocking pattern. pr-create reads run_git through a 3-line git_line, and its ls-remote now gets GIT_TERMINAL_PROMPT=0.
  • The citizen layer's six raw git spawns, including a try_wait + thread::sleep(200ms) poll loop that killed only the direct child at 600 s. That bound is carried as-is, through within, and is still unmeasured; card c1bdc29b covers it.
  • PlacementSwitch::has_unpushed_work, which had no caller.

Net: 19 files, +780 / −805.

Not here

23 raw git spawns remain in 14 other files (benchmarks, staged_workspace, the CLI). That's card 7b13425f (owner: Cormac), with a per-file count.

Tests

  • a_git_ends_with_its_waiter_and_says_how_it_ended (git_bridge). A pre-commit hook sleeps 600 s, and four cases are checked:
    • a deadline ends the git: interrupted, its tree's end confirmed;
    • no time left: never started;
    • cancelled under a hands lease: the release completes with nothing lingering;
    • 1 MiB of stdin to git --version: an Err, not its output.
  • waiting_for_the_checkout_spends_the_sync_deadline_and_runs_no_git: a held checkout lock makes the sync TimedOut, and the edit stays uncommitted.
  • a_sync_cancelled_mid_push_frees_the_checkout_once_its_git_has_ended_and_leaves_the_remote_unknown. The sync runs under an admission and is cancelled once the pre-receive hook has recorded itself. Then the test checks:
    • the checkout comes free, and close() finds nothing lingering;
    • the remote is unknown;
    • the next sync reads the remote and publishes.
  • In lane_process, a Witness held through holding reads the grandchild at the instant it is released, and must find it gone. That is the strict release-order proof. The same tests check that a pipe-holder's kept stays held after close, and that a confirmed timeout releases it.
  • a_push_the_deadline_ends_is_interrupted_and_the_next_sync_reads_the_remote_first: a pre-receive hook holds the push. The result is PushInterrupted and the remote is marked unknown; the next sync reads the remote, then publishes.
  • Tree-ending, the mid-drain cancel and input delivery are lane_process's contract, tested once there (refactor(process): one owned run for every child the core waits on; the group kill, run_bounded and four timeout+kill_on_drop copies are deleted (card de211a71) #5030, refactor(process): the remaining timed child waits run owned (card 679ae815) #5035), not re-tested here.
  • The existing git_bridge, workspace_transfer, apply, citizen-layer and workspace-map tests now run on tokio with the same assertions.
  • Not run locally: IntelMac doesn't compile the core, so CI is the first build. Source-hygiene: 32 passed at 39cd437 (2026-10-14). At 992b027, CI passed 8875 / failed 0, with the three earlier new tests ok.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply and others added 3 commits October 14, 2026 05:47
…ocking_git, the blocking-thread admission and github's git_output are deleted (card bfa87dd5)

git_bridge's ~20 sync git calls ran unbounded on blocking threads, so a cancelled
command or a passed deadline abandoned the git and what it started. run_git is now
the one async runner over lane_process::run_owned_with_input (env hygiene kept, caller
env applied last as its doc said); a task-local deadline (`within`) carries ONE
absolute bound across a caller's calls. A git the deadline ends is INTERRUPTED (effect
unknown), never "failed"; a push it ends is PushInterrupted and the next sync reads the
remote before deciding to publish.

Deleted: blocking_git, hands::spawn_blocking + BlockingAdmission + BLOCKING_ADMITTED
(no caller left), github::git_output/git_quiet, PlacementSwitch::has_unpushed_work,
and the citizen layer's six raw git spawns incl. a try_wait/sleep poll loop.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…5038): a non-zero exit is git's own failure with its stderr, a delivery note beside it, never in its place

The runner had copied ext's ordering (input note before exit status), the defect #5038 fixed
at the owner. Its error is now 'git <args>[ interrupted…]: <unanswered>', the one rendering.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply force-pushed the bfa87dd5/code-git-bridge-every-git-call-becomes-a branch from f3489d5 to 992b027 Compare October 14, 2026 10:48
…s git has ended; the remote is unknown from before the push (Codex reviewer on #5037)

Two findings from the reviewer (bf7c5ada) at 992b027:
- A sync cancelled mid-git dropped the checkout's lock with its future, while
  OwnedChild's drop ended the git's tree after it. The next sync could run beside
  that git.
- REMOTE_UNKNOWN was set only when a DEADLINE ended a push, so a cancelled push
  left the next sync trusting a stale tracking ref.

Fixes:
- lane_process::holding(value, work): every owned child started in `work` keeps
  `value` until its tree has ended. It's the same lifetime the hands lease already
  had, now available to any exclusion.
- sync_by takes the lock owned and holds it through `holding`. It takes the sync as
  a future, so tests can pass a granted carry.
- The remote is unknown from BEFORE the push. Only a completed push (landed,
  rejected or unreachable) clears it.

Regression: a_sync_cancelled_mid_push_holds_the_checkout_until_its_git_has_ended_and_leaves_the_remote_unknown,
phase-synchronized on the pre-receive hook's pid file:
- after the cancel, the lock is still held;
- it frees within 10 s;
- the hook is gone;
- the remote is unknown;
- the next sync publishes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

ACK reviewer bf7c5ada (REQUEST CHANGES at 992b027), both fixed at 54060cc: (1) a cancelled sync's checkout lock is now kept by each git child until its tree has ended (lane_process::holding, the hands lease's lifetime generalized); (2) REMOTE_UNKNOWN is set before the push and cleared only by a completed one. Regression: a_sync_cancelled_mid_push_holds_the_checkout_until_its_git_has_ended_and_leaves_the_remote_unknown.

…y a conclusive push settles the remote (Codex reviewer on #5037 at 54060cc)

P1: `kept` was released when the end's task returned, even when the end was unconfirmed:
survivors, an unwalked tree, or an exited child whose pipes a process it started still held.
It now goes where the unconfirmed end goes: HandsLease::keep_held puts it on the gate beside
`lingering`, and retain_processes releases it only when a re-check finds nothing left.
With no admission nothing can re-check, so it is never released (fail closed, probed).

P2: every push error except a timeout cleared REMOTE_UNKNOWN. The runner now returns a
typed GitError { end: NeverRan | Refused | Unknown }; run_git and run_git_with_env convert
it to String, so their callers are unchanged. A push clears the mark only on a conclusive
end: Ok, Refused or NeverRan. Unknown (cut off, output not whole, invalid UTF-8) is
PushInterrupted.

Test: the abort test no longer assumes a cleanup phase. It checks the order, which holds at
any timing: the lock is seen free only after the hook is gone, with liveness read after the
lock. lane_process pins what `kept` does:
- the pipe-holder case keeps it after close;
- a confirmed timeout releases it;
- git's undelivered-input case is GitEnd::Unknown.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

ACK reviewer db1b4343 (REQUEST CHANGES at 54060cc), all three addressed at bbeaba1: P1 an unconfirmed end hands kept to the gate beside lingering (HandsLease::keep_held), released only by a re-check finding nothing left. P2 a typed GitError { end: NeverRan | Refused | Unknown }; a push clears REMOTE_UNKNOWN only on a conclusive end. Test the abort test checks order (free ⇒ hook already gone), not a cleanup phase; lane_process pins kept held/released.

… an admission; the strict release order is witnessed at the release (Codex reviewer on #5037 at bbeaba1)

- P1: run_git_input mapped every run_owned_with_input error to NeverRan, but a failed wait
  or an end that couldn't run happens after the spawn. Those are GitEnd::Unknown now, so a
  push keeps the remote unknown. Only "no time left" is NeverRan.
- No release owner: `holding` without an admission is refused in run_owned_with_input
  before anything starts. kept is then non-empty only under a lease, and the mem::forget
  branch is deleted.
- Test order: my "holds at any timing" claim was wrong; liveness read after seeing the lock
  free can miss a hook dying in between. The strict proof is now in lane_process: a Witness
  held through `holding` reads the grandchild AT its drop, the instant the exclusion is
  released, and must find it gone. The workspace_transfer test now runs under an admission,
  as the turn path does, and checks: the checkout frees, close confirms nothing lingers,
  the remote is unknown, and the next sync publishes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

ACK reviewer 546936b7 at bbeaba1, all three addressed at 39cd437: runner errors are GitEnd::Unknown (only no-time-left is NeverRan); holding without an admission is refused before spawn, and the mem::forget branch is deleted; retracted my claim that the sampled order check was strict. The strict proof is a Witness in lane_process that reads the grandchild at the instant the exclusion drops.

… only an answered push or one that never ran settles it (Codex reviewer on #5037 at 39cd437)

A non-zero push exit isn't proof the remote is unchanged: the remote can take the ref and
the connection fail before git hears so. Refused keeps its classified outcome (Rejected or
Unreachable) for the turn, but REMOTE_UNKNOWN stays set; the next sync's one fetch reads
the remote. The unreachable-remote test pins it: unknown after the refused push, settled
by the next sync.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

ACK reviewer 0029bb72 at 39cd437, addressed at c3a4979: Refused keeps REMOTE_UNKNOWN set (a non-zero push doesn't prove the remote unchanged); only Ok/NeverRan settle it. Pinned in an_unreachable_remote_is_named_and_defers_the_move_until_the_push_lands.

@joelteply

Copy link
Copy Markdown
Contributor Author

Source approved at exact c3a4979 after independent lifecycle review. Verified shared run_owned_with_input replaces blocking_git, one absolute deadline spans checkout admission and commands, and retained exclusion follows child cleanup through the existing admission owner. Missing admission refuses before spawn. Failed or interrupted pushes retain remote uncertainty; the next sync reconciles before retrying. Only success or proven pre-start refusal clears it.

Root independently verified all seven hosted checks successful at 12:07Z. Approval is for source and CI; deployed git consumer acceptance remains owed. Existing timeout value is inherited and unmeasured, not a new performance measurement. No learning claim.

@joelteply
joelteply merged commit 8ebe5a0 into canary Oct 14, 2026
7 checks passed
@joelteply
joelteply deleted the bfa87dd5/code-git-bridge-every-git-call-becomes-a branch October 14, 2026 12:07
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