Repository navigation
ci(sync-io): gate pathlib reads and writes inside async def - #22902
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change only widens a CI matcher, and the rise in the baseline is the true count of sites already on main. A revert undoes it cleanly. Notes
[DESIGN-REVIEWED] 34c4084 Description read[DESCRIPTION-READ] 2b6f5e4cf4e3b13be5b1ab43920b99d73f4bcd256736d659ef68e7b94b4954e6 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Every item comes from #22086, and the probe that was flipped was already labelled "follow-up work" by the paragraph this change removes. What this change shipsInventory (5 items) — 5 justifiedIntent: a new
[FIRST-PRINCIPLES-REVIEWED] 34c4084 Description read[DESCRIPTION-READ] 098933371aa49ef0ce3b25b0edaea9ee69253bac56b68f034dd3e3e1e78cf4ae That sha256 names the PR description this verdict read. 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: |
806e026 to
34c4084
Compare
|
Review-ready on head 34c4084.
🤖 AI-assisted comment 🤖 |
buluoray
left a comment
There was a problem hiding this comment.
Approving 34c4084.
Matching on the positional-argument count Path itself takes (PATH_METHODS, _family) is enough to keep reader.read_text(blob), z.open(name) and w.write_bytes(k, b) out without knowing the receiver type.
Checked for false positives on this head merged onto current main:
check_sync_io_in_async.py --test: 52 flagged / 33 clean probes, all right. The gate passes both ledgers.--reportfinds 158 fs calls in 61 files, which equals the committedfsbaseline, so main has added no sites since this branch was cut.- I read each of the 20 newly matched non-test sites (
worktree_ops_sync.py,apps/routes.py,agent_config.py,handlers/core.py,hooks_scripts.py,mcp.py×7,mcp_probe.py×4,backend_record.py,install_repair.py). Every one is a real pathlib read or write inside anasync def; none is another API. There are no zero-argument.open()matches, and no async path library in the tree to produce an awaited false positive.
test/test_sync_io_in_async_gate.py passes (129). Removing each new method, changing either write arity, or dropping the arity check turns named tests or self-test probes red.
Non-blocking: positional spellings such as p.open("w"), p.read_text("utf-8") or p.write_text(s, "utf-8") are not matched, because the arity is off by one. They are rare in this tree. Worth a line in the docstring as a known gap.
Problem / Motivation
Goal: A new
async defthat reads or writes a file throughpathlibon the event loop fails CI, the same way a new stat or resolve already does.scripts/check_sync_io_in_async.pygates filesystem calls inside anasync def(#22084), but itsfsfamily left outPath.read_text(),read_bytes(),.open(),write_text(...)andwrite_bytes(...). Each runs the same blockingopen(2), and nothing requires a stat before it. So a new on-loop read or write still lands green.Why it matters
The gateway runs one event loop. A read or write on an NFS or FUSE mount that stopped answering blocks every endpoint until the kernel gives up. A stall past
dashboard.loop_stall_exit_after_secsmakes the loop watchdog kill the process. The Design lane on #22084 named this gap, and #22086 tracks it.Not a goal
fsbaseline once, which can only shrink.iterdir(),glob(),mkdir(),unlink()and other pathlib calls the issue does not name.async def. The gate stays lexical, as it is for every family.What changed (motivation → approach → change)
Pathlib reads and writes were missing from the
fsfamily, so they kept arriving unflagged.PATH_METHODSnow records each method's family and the positional-argument countPathitself takes. A call matches only at that count:.read_text()/.read_bytes()/.open()reader.read_text(blob),z.open(name).write_text(data)/.write_bytes(data)w.write_text(),w.write_bytes(k, b)The module docstring now lists the five methods and drops the paragraph that called them a gap. The
backend-lintrow indocs/ci/ci-and-reviews.mdnames them too..github/sync-io-in-async-fs-baseline.txtrecords the sites this finds on main today, with the gate's own writer: 20 calls in 9 files (17read_text, 3write_bytes, no zero-argument.open()). The ledger goes from 138 calls in 57 files to 158 in 61.Backwards compatibility
Breaking: a new pathlib read or write inside an
async def, in a file a change touches, now fails the gate. Writer sweep on origin/main @ 86e61e6: the gate's scan finds 20 such sites in 9 files, and every one is in thefsbaseline, so the gate passes on main as it stands. An open PR that adds such a call goes red until it offloads the call or marks it with# on-loop-io-ok: <reason>.Removes nothing: the diff only widens what the
fsfamily matches and raises its ledger by the sites that widening finds.Ratchet note (
a-ratchet-may-only-tighten): thefsbaseline grows here, on purpose. No new on-loop IO is added: every added or raised entry is a call already on main that the wider matcher now sees, and the counts equal a full-tree scan. The rule allows a count that moves to the new true value. #22086 asks to record these sites in thefsbaseline with the gate's own writer. Offloading all 20 sites here would touch 9 more source files, past this change's size budget.Tests
test/test_sync_io_in_async_gate.pyand the script's--testcorpus (52 flagged, 33 clean probes):test_pathlib_reads_and_writes_are_matched_by_their_own_arityflags all five methods at their own arity and nothing at the wrong one (read_text(k),open(k),write_text(),write_text(k, s)).read_text(encoding=...),open(mode='w'),write_text(s, encoding=...)).to_thread, a write in a nesteddef. The old clean probe "a read is not gated" is now a flagged probe.fsbaseline.On origin/main's gate the five calls in the new test produce no findings.
prove.py --base origin/main: PROVEN. Determinism: the whole file passed 5/5 repeated runs and one shuffled order (seed 7), 129 tests each.Manual verification
python3 scripts/check_sync_io_in_async.py --reporton this head lists 158fscalls in 61 files, and the gate passes for both ledgers.Screenshots / video
N/A: CI script only, no user-visible UI change.
Related Issues
Closes #22086
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)