Repository navigation
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
Conversation
…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
…d a split-line await; CI E0277 at 537cb62) 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
f3489d5 to
992b027
Compare
…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
|
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 ( |
…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
|
ACK reviewer db1b4343 (REQUEST CHANGES at 54060cc), all three addressed at bbeaba1: P1 an unconfirmed end hands |
… 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
|
ACK reviewer 546936b7 at bbeaba1, all three addressed at 39cd437: runner errors are |
… 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
|
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. |
Why
Card bfa87dd5, the git half of #5030/#5035's one-owner work.
code::git_bridgeran about 20 git calls as syncstd::processchildren with no bound.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.SYNC_BOUNDbounded 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(withrun_gitandrun_git_with_envover it) runs every git throughlane_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 anErr, never a result.GIT_DIRetc. stripped,GIT_CEILING_DIRECTORIES,GIT_TERMINAL_PROMPT=0.rev-parse --show-toplevellifts the ceiling, because that call is the upward discovery.git_bridgefn 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.interrupted(its effect unknown), never "failed".sync_by) spends the deadline on the checkout lock too. The lock is now atokio::sync::Mutexheld across the awaits.PushOutcome::PushInterrupted. It marks the remote unknown, and the next sync fetches the branch before deciding to publish.lane_process::holding(value, work). That generalizes the lifetime the hands lease already had, instead of adding a parallel path. An unconfirmed end handskeptto the gate besidelingering, and a re-check releases it.holdingwithout an admission is refused before spawning.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.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_boundedandarrive_forrun within their existing bounds.SYNC_BOUNDis still unmeasured; card c1bdc29b measures it.Callers migrated:
code/git/*commands;ensure_engine,ensure_citizen_layerand the workspace-map RAG reader.WorkspaceLayoutReader::layoutis now async. It used to rungit_sync_from_sharedsynchronously 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,BlockingAdmissionandBLOCKING_ADMITTED(blocking-thread admission). No caller is left: a git's child keeps the admission throughrun_owned. That removes three tests that pinned the deleted mechanism; the replacement contract is tested below.code/github::git_outputandgit_quiet, the samespawn_blockingpattern. pr-create readsrun_gitthrough a 3-linegit_line, and itsls-remotenow getsGIT_TERMINAL_PROMPT=0.try_wait+thread::sleep(200ms)poll loop that killed only the direct child at 600 s. That bound is carried as-is, throughwithin, 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:interrupted, its tree's end confirmed;git --version: anErr, not its output.waiting_for_the_checkout_spends_the_sync_deadline_and_runs_no_git: a held checkout lock makes the syncTimedOut, 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:close()finds nothing lingering;Witnessheld throughholdingreads 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'skeptstays held afterclose, 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 isPushInterruptedand the remote is marked unknown; the next sync reads the remote, then publishes.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.🤖 Generated with Claude Code
https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE