Repository navigation
test(md-notebook): stub the hook scan in the staging-sync test - #39279
Conversation
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Test-only. The stub replaces a module-global that Notes
[DESIGN-REVIEWED] 7dc11e6 Description read[DESCRIPTION-READ] e549101aa91f0ad6c93ad6be46c55ba559c206fd3945b3a83621568e151e5472 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: |
… drain times lock ordering, not ~120 git starts
b30a6c9 to
7dc11e6
Compare
Code change approver recommendation: A person should decideWhy: the decider estimates a 5% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier 2: reviewer-finding: Design Review. Test-only change. In one lock-ordering test, it stubs the md_notebook hook scan ( Tier: 2, held for a person: reviewer-finding: Design Review. 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.
I reviewed head 7dc11e6. The stub takes effect: run_git looks up the module-global config_hook_disable_args on every call, and the fixture never reloads git_ops. The patch is scoped to the existing MonkeyPatch.context, and both tasks are drained before that context exits, so nothing leaks into other tests. _BARRIER_LOST_RUN_SEC and every assertion are unchanged. The three hook behaviours this test stops exercising are still pinned in test/test_git_config_hooks.py (lines 289, 310 and 322). All eight Backend Tests (Windows) shards passed on this head.
Done well: the PR removes work the test never needed to prove instead of raising the timeout. The new failure text names the bound it measures.
Optional:
- Lines 780 to 788 of
test/test_md_notebook_write_safety.pystill blame shared executor starvation, which the body rules out. You could reword them to match the new drain comment. - The stub returns
[], so it also drops the submodule recursion pins. Returninglist(git_config_hooks._SUBMODULE_RECURSION_PINS)would keep the argv the same as production, or the comment could say that the pins are dropped too. - The body's Tests section still says CI is pending. You could link the green Windows run.
Problem / Motivation
Goal:
test_a_sync_while_the_temp_is_still_staging_never_commits_itstops failing on Windows CI when nothing is wrong with lock ordering.On Windows the test fails at
test/test_md_notebook_write_safety.py:849:Seen on main at 0330200 (job 135089405882, Backend Tests (Windows) (4), gw3), and earlier on
fix/resume-restored-queuec5aa0d8 (check run 119475800273, Backend Tests (Windows) (5)). Both hits I could retrieve are Windows. A scan of 800 failed CI runs back to 11-16 found only the main hit.Why it matters
It turns main red and blocks unrelated PRs on the Windows shard.
Not a goal
to_thread(temp_written.wait, 10),_parked_behind). Neither spans any git process (see below).test_a_symlink_landing_while_a_writer_waits_on_the_lock_is_refused. It runs a real Sync too, but awaits it with no wall-clock bound, so it is slow (32.2 s in the same job) but not exposed.What changed (motivation → approach → change)
Symptom → cause. The failure text blames a starved shared executor. That is not possible: pytest-asyncio 0.21.2 gives each test its own
event_loop,conftest_floor_restores.pyshuts its default executor down after each test, and that executor hasmin(32, cpu+4)≥ 8 threads (4 xdist workers). The released chain needs at most 2 to 3 at once. Every Sync and save hop is sequential.What the 30 s
_BARRIER_LOST_RUN_SECdrain actually times is real git work.md_notebook.git_ops.run_gitrunsconfig_hook_disable_argsbefore every git command, and that scan starts 3 git processes (config,rev-parse --show-toplevel,ls-files -s -z). One whole-scope Sync makes about 30run_gitcalls (branch, origin ×2, gitdir, driver ×4, status ~7, auto_commit ~10, fetch, rev-parse ×2, merge, push):Plus upload-pack and receive-pack for the real fetch and push, in both cases. On a loaded Windows runner, 120 starts do not fit in 30 s. In the failing job no worker finished a test from 20:16:26 to 20:17:03 (37 s), the sibling real-Sync test took 32.2 s (
"elapsed":32.215722), and this test'sFprinted at 20:17:20.Change (test only, one file):
git_ops.config_hook_disable_argsis monkeypatched to return[]. The test proves lock ordering between staging, Sync and publish, not hook handling. The hook scan inrun_gitstays covered intest/test_git_config_hooks.py:test_md_notebook_run_git_carries_the_disable(the disable flags reach the real git argv)test_md_notebook_scan_failure_is_a_git_error(a scan failure fails closed)test_md_notebook_commit_does_not_fire(a planted config hook does not fire on commit)_BARRIER_LOST_RUN_SECand every assertion are unchanged.Other waits checked, not changed.
to_thread(temp_written.wait, 10)spans the save'sread_vaults, oneos.stat, onemkdirand the temp write: no git process._parked_behindspans the Sync'srequire_vault(avaults.jsonread) up tovault_write_lock, andresolve_authruns inside the lock: no git process. Neither shares this cause.Backwards compatibility
Compatible: test-only change. Production code is untouched.
Removes nothing: only a test stub and a failure message change.
Tests
test/test_md_notebook_write_safety.py::test_a_sync_while_the_temp_is_still_staging_never_commits_it: the same unconditional assertions (committed list, ls-files, remote ls-tree, save 200, note content, temp gone), with the hook scan stubbed.Proof: not provable -- test-only change
Static gates run locally:
scripts/check_black_formatting.py(black 26.10.1) passed,flake8passed,isort --check-onlypassed,mypyon the file passed.Manual verification
N/A -- test-only change; CI runs it on Linux, macOS and Windows.
Real-machine verification
N/A -- the diff changes a test stub and a message; no product code runs differently.
Related Issues
Related: #39275 (the production hook-scan cost; this PR only removes it from this one test)
Sibling sweep
Swept:
git grep -n '"/api/sync"' -- 'test/test_md_notebook_*.py', then each hit's bounded waits checked for a real Sync inside themSibling: test/test_md_notebook_write_safety.py:92 -- not affected -- its lost-run waits bound lock parking; the real Sync is awaited unbounded
Sibling: test/test_md_notebook_write_safety.py:201 -- not affected -- awaits its real Sync with no wall-clock bound
Sibling: test/test_md_notebook_write_safety.py:675 -- not affected -- real Sync awaited unbounded; its lost-run waits bound staging and rename only
Sibling: test/test_md_notebook_notes.py:297 -- not affected -- plain awaited Sync, no lost-run bound
Sibling: test/test_md_notebook_git_trust.py:256 -- not affected -- plain awaited Sync, no lost-run bound
Pattern harvest
Rule candidate: review-prompt
Pattern: a wall-clock lost-run bound wrapped around a chain of many real subprocess starts measures the runner; stub the per-call overhead that the test does not prove
Checklist
Contribution License Agreement
Contributed under the project's Apache-2.0 license.