Repository navigation
fix(apps): probe the clone's .git off the event loop - #24124
KiroCrewCaptain merged 1 commit into
Conversation
_clone_origin_url checked whether the registry checkout had a .git directory with a bare is_dir() at the top of the coroutine, before the sandboxed git spawn that reads its origin. The checkout lives in the data home's apps directory, so on a mount that has stopped answering the stat blocks the gateway's single event loop and stalls every session until the loop watchdog restarts the gateway. Run the probe with asyncio.to_thread, the lane the module's other clone-metadata reads already use. Lower the checkout.py row of the sync-io baseline with --update-baseline and add tests that the probe runs off the loop thread both for a directory that is not a clone and for one whose origin is read. Closes kirodotdev#24123
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This is a disclosed point patch: one of ten baselined loop-thread stats in Notes
What this change shipsInventory (3 items) — 3 justifiedIntent: a stalled data-home mount should not freeze the gateway while an installed registry app updates. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 12ed7b9 Description read[DESCRIPTION-READ] c1ac28614d278ee4f7c6c191e8edc1a4dc817811e368a7b61906b680404af71f That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: a one-line hop off the event loop, using the lane this module's other clone-metadata reads already use. Return values are unchanged. Notes
[DESIGN-REVIEWED] 12ed7b9 Description read[DESCRIPTION-READ] 9bff293ba45eafff20ebe2c384e4573de53960658460626cce8c662fc78c2ee7 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
|
Replies to the non-blocking notes on 12ed7b9:
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: moves the .git stat in the registry clone origin read off the event loop with asyncio.to_thread and lowers its sync-io baseline row by one; tests pin the thread.
Problem / Motivation
Goal: Reading a persisted registry clone's
origin(_clone_origin_url) no longer blocks the gateway's event loop on its.gitprobe._clone_origin_urlinapps/registry_pipeline/checkout.pyopens withif not (dest / ".git").is_dir(): return None, a bare stat inside the coroutine, before the sandboxedgit remote get-url originspawn it exists for. The checkout lives in the data home's app-sources directory. On a mount that has stopped answering, that stat blocks in the kernel on the loop thread.check_sync_io_in_asyncalready counts it in thecheckout.pyrow of its baseline.Why it matters
The gateway runs one event loop. A stalled syscall there freezes every session, channel, cron and MCP call at once, and once the stall outlasts
dashboard.loop_stall_exit_after_secsthe watchdog restarts the gateway and every in-flight turn is lost (#1572, #3057). The origin read runs on every update of an installed registry app (_clone_origin_matches, and the origin-mismatch path in_git_clone_or_pull).Not a goal
_clone_origin_urlreturns:Nonefor a directory that is not a clone, a spawn failure, a timeout or a non-zero exit; the stripped URL otherwise.checkout.py. They decide which fetch, move-aside and rollback branch_git_fetch_refand_git_clone_or_pulltake (see Sibling sweep).install_clone.py's baseline row.What changed (motivation → approach → change)
Symptom: a slow or wedged data-home mount can stall every session while an installed registry app updates. Root cause: the
.gitprobe at the top of_clone_origin_urlran on the event-loop thread.The probe now runs through
await asyncio.to_thread((dest / ".git").is_dir). That is the lane this module's other clone-metadata reads already use (_read_clone_branch,_resolved_clone_commit).destis the gateway's own app-sources path, so it goes to the default executor, not the bounded path-probe pool that request-chosen paths use (the same call as #22222 and #23967).--update-baselinelowers thecheckout.pyrow of.github/sync-io-in-async-fs-baseline.txtfrom 10 to 9.Backwards compatibility
Compatible: return values and the git spawn are unchanged. Only the thread the
.gitstat runs on moves.Removes nothing: the baseline row drops by one because the call it allowed no longer runs on the loop. No reader, route or key goes away.
Tests
test/test_external_registry_origin.py::TestCloneOriginProbeOffLoop::test_missing_git_dir_returns_none_without_spawning: on a plain directory,_clone_origin_urlreturnsNonewithout spawning git, and the.gitprobe ran on a thread other than the event loop's....::test_existing_clone_reads_origin_after_off_loop_probe: on a clone, it returns the origin thatgit remote get-url originprinted (the spawn runs indest), and the probe ran off the loop thread.2 passed. The whole file passes (18 passed). It passes 10/10 on repeat runs. The tests only look atthreading.get_ident()and use no timing.Proof: PROVEN test/test_external_registry_origin.py::TestCloneOriginProbeOffLoop::test_missing_git_dir_returns_none_without_spawning, test/test_external_registry_origin.py::TestCloneOriginProbeOffLoop::test_existing_clone_reads_origin_after_off_loop_probe (head 12ed7b9)
Gates run locally:
check_sync_io_in_async.py(130 calls / 55 files),check_black_formatting.py,check_subprocess_encoding.py, comment-history, brand-name, isort, flake8, mypy,docs-lint.sh,test_flake_pattern_ratchet.pyandtest_sync_io_in_async_gate.py(189 passed).local-gate.py's related backend set: 29,248 passed, 73 failed and 10 errors, across 72 unique node ids. Every one of those ids also fails when run on a cleanorigin/mainworktree on this host, so this diff did not cause them. They come from this host's environment: the sandbox refusesgit initintest_ledger_sync_git.py,test_design_tweak_backend.pygets 403s because of the checkout path, and coreutilsenvhere has no--default-signal. semgrep is not installed here, so the SAST lane covers it.Manual verification
N/A: this is a thread hop with no user-visible output. The unit tests drive the real
_clone_origin_urland check which thread the stat runs on, which is the property this change is for.Related Issues
Closes #24123
Sibling sweep
Swept: the
checkout.pysitesscripts/check_sync_io_in_async.py's_scan()reports (lines 527, 529, 806, 896, 960, 1263), plusgit grep -n '\.git").is_dir()' -- src/kiro_crew/apps/registry_pipeline/Sibling: src/kiro_crew/apps/registry_pipeline/checkout.py:527 -- not affected --
_git_fetch_ref's.git/existsprobe chooses between fetching into an existing checkout and the refuse-or-create branch that thecreated_herecleanup relies on. Moving it belongs with that lifecycle, in its own PR.Sibling: src/kiro_crew/apps/registry_pipeline/checkout.py:806 -- not affected -- in
_git_clone_or_pull, along with 896, 960 and 1263. These gate the origin-mismatch move-aside, branch re-convergence, pinned-install move-aside and Windows partial-rename rollback, and should move together with that transaction.Sibling: src/kiro_crew/apps/registry_pipeline/install_clone.py -- not affected -- its own baseline row, handled separately.
Pattern harvest
Not generalizable:
scripts/check_sync_io_in_async.pyalready enforces this class (a blocking fs call insideasync def) across the repo. This PR pays down one baselined call of it.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.