Repository navigation
fix(autonudge): check the stop sentinel off the event loop - #39103
Conversation
The autonudge tick looked for the stop-sentinel file with a plain Path.exists() inside an async function. That is a blocking filesystem call on the loop that serves every session. Run it in a worker thread, as the neighbouring code in mutations.py already does, and drop the file from the sync-io baseline.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is a one-call mechanism fix: the stat moves off the loop, and the sync-io gate keeps the class from coming back. What this change shipsInventory (3 items) — 3 justifiedIntent: stop a slow or stuck mount under the stop-sentinel path from freezing every session's turn during an autonudge tick. FIX.
[FIRST-PRINCIPLES-REVIEWED] 0c5c8d9 Description read[DESCRIPTION-READ] e84a2652d1db480685c671f87e570141eab4457937d729417a09eb5a3486c5b4 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Moving the sentinel stat off the loop fixes the cause of the stall; the code after it already awaits, so the new suspension point adds no new interleaving. [DESIGN-REVIEWED] 0c5c8d9 Description read[DESCRIPTION-READ] a008580d5796aaa45612837654f193764572e5c4d77208a3202710fcbf0388e9 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: A person should decideWhy: the decider estimates a 6% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed. This is a one-call fix, and I'd merge it as it stands. In The change adds one new pause point (await) before the sentinel check. I checked what can happen to the loop's state during that pause:
The Tier: pending: being reviewed. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved. On this head, the stop sentinel's exists() check in firing.py now runs through asyncio.to_thread. It still sits behind the empty-path guard, and the log line, stop reason and early return are the same as before. A stop or re-arm can cancel the tick during the new await. That leaves the timer in the same state as a cancel at the awaits that already existed. The firing.py row is gone from the sync-io baseline, so the ratchet only got stricter. With main's firing.py restored, the new test fails with "sentinel stat ran on the loop thread". With this head's version it passes.
Done well: the test records which thread actually runs the stat and also asserts the stop reason, so it cannot pass if the check never runs.
Optional:
_stop_file_liftedinautonudge_service/mutations.py(line 92) runs the sameexists()on the event loop. It runs during resume, whileself._lockis held. The gate cannot see it because the call sits inside a sync helper. A follow-up could compute that result withasyncio.to_threadbefore taking the lock.- Open PR #11397 rewrites the same
ifinfiring.py, so whichever of the two lands second will need a small rebase.
Problem / Motivation
Goal: The autonudge timer tick stops checking its stop-sentinel file on the event loop, so a slow or stuck mount under that path cannot freeze every session's turn.
src/kiro_crew/autonudge_service/firing.pyis listed in.github/sync-io-in-async-fs-baseline.txt. In_run_timer_callback, every tick of every loop with a stop-sentinel path calledPath(loop.stop_sentinel_path).exists()directly inside theasync def.Why it matters
A stat on a mount that stops answering blocks the loop for as long as the kernel takes. Past the loop-stall limit the watchdog restarts the gateway and drops every in-flight turn. The check runs on every tick of every armed loop, so it is hit often.
Not a goal
What changed (motivation → approach → change)
await asyncio.to_thread(Path(loop.stop_sentinel_path).exists), the idiommutations.pyin the same package already uses for the same kind of file. An empty sentinel path still skips the check. The result is held insentinel_foundrather than joined to the path test withand, because mypy reads theandform as astrresult.firing.pyline is removed from the baseline withpython3 scripts/check_sync_io_in_async.py --update-baseline.Backwards compatibility
Compatible: same result, same log line, same stop reason, same order of effects; only the thread that runs the stat changes.
Removes nothing: no function, key or behaviour is removed.
Tests
test_sentinel_check_runs_off_the_event_looprecords the thread that callsPath.existsfor the sentinel and asserts it is not the loop thread, then checks the loop still stops with the sentinel reason.origin/mainsource: the test fails with "sentinel stat ran on the loop thread". The sync-io gate with the baseline line removed also fails:firing.py:200, "1 new offender(s)".Proof: PROVEN test_sentinel_check_runs_off_the_event_loop (head 0c5c8d9)
Related Issues
None.
Sibling sweep
Swept:
python3 scripts/check_sync_io_in_async.py --reportSibling: the other files in the baseline -- not affected -- each has its own row and a separate change
Pattern harvest
Not generalizable: the sync-io gate already catches this class; the fix is the one listed call.
Checklist