Skip to content

sync,tests(fix): Stabilize worker sync tests and inspection - #617

Merged
tony merged 3 commits into
masterfrom
fix/616-sync-subprocess-timeouts
Dec 6, 2026
Merged

tony merged 3 commits into
masterfrom
fix/616-sync-subprocess-timeouts

Conversation

@tony

@tony tony commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Closes #616

Summary

  • Raise post-timeout and post-interrupt recovery inspection deadline to five seconds in sync_process.
  • Defer vcspull.cli.sync imports in sync_process._main() to sync worker runs.
  • Poll post-checkout hook connections with selectors.DefaultSelector and child liveness checks in test_sync_interrupt_stops_worker.
  • Select interrupted NDJSON events by target repository or worktree in test_sync_interrupt_stops_worker.
  • Raise test_hg_configured_remote_reaches_native_sync worker deadline to 15 seconds across Mercurial updates.
  • Update docs/cli/sync.md and CHANGES for the five-second recovery-inspection deadline.

1. Owner and boundary

  • Rule changed and module that owns it: Post-failure recovery-inspection process supervision and worker module loading in src/vcspull/_internal/sync_process.py, documented in docs/cli/sync.md and CHANGES, alongside subprocess test coordination in tests/cli/test_sync_sigint.py, tests/cli/test_sync_watchdog.py, and tests/test_sync.py.
  • Sibling entry points checked (sync/async, CLI/API, single/batch, or N/A): Checked sequential vcspull sync, parallel vcspull sync --jobs, vcspull sync --include-worktrees, standalone vcspull worktree sync, and direct update_repo vs run_sync_process worker execution.
  • Why this belongs here (owner fix, boundary adapter, or single-PR ownership transfer): Owner fix in vcspull._internal.sync_process, keeping "worktree" and "inspect" workers inside vcspull._internal and vcspull.validator without pulling vcspull.cli subcommands into non-CLI-sync worker startups.

2. Failure before the fix (N/A for docs, lockfile bumps, or pure refactors)

  • Baseline (<base> commit, or <pre_fix_head> SHA if fixing a defect introduced in this PR): cb7ac9e
  • Failing input or command and observed failure before the fix:
    • uv run py.test tests/test_sync.py -k "test_hg_configured_remote_reaches_native_sync and True" failed with AssertionError: assert 'timed_out' == 'synced' (duration=5.39s across 16 sequential hg processes against timeout=5).
    • uv run py.test tests/cli/test_sync_sigint.py -k test_sync_interrupt_stops_worker failed intermittently with TimeoutError: timed out on server.accept() (3s budget across a multi-interpreter chain), AssertionError: assert 'not-started' == 'unknown' in parallel_main when sibling_repo emitted its interrupted event ahead of git_repo, and missing retained_recoveries under CPU contention when sync_process.run_sync_process timed out at 1.0s importing vcspull.cli.sync during "inspect".

3. Verification and tool disclosure

  • Gates run (plus production-only revert check for behavioral fixes, or N/A): uv run ruff format ., uv run ruff check . --fix --show-fixes, uv run ty check --error-on-warning . (Python 3.11 and 3.15), just build-docs, PYTHON_COLORS=0 NO_COLOR=1 uv run sphinx-build -W -b dirhtml -d docs/_build/doctrees docs docs/_build/html, uv run python scripts/generate_schema.py --check, uv run --isolated --no-cache --no-dev --no-editable --frozen python scripts/runtime_dep_smoketest.py, full uv run py.test, two 16-worker CPU-contention stress runs, and the production-only revert check (BITE_TEST="tests/cli/test_sync_watchdog.py::test_watchdog_inspection_tolerates_slow_worker_startup" failing on cb7ac9e with AssertionError: assert () == (SyncResult(...),)).
  • .github/workarounds.toml updates (None if none): None
  • Tool use: Antigravity (Gemini) diagnosed the worker inspection and test timeout races via /spike-ratchet, drafted the changes, and ran the local lint, typecheck, documentation, production-revert test-bite, CPU-contention, and pytest gates.

Test plan

  • test_watchdog_inspection_tolerates_slow_worker_startup fails when src/vcspull/_internal/sync_process.py is reverted to origin/master and passes with the fix
  • _accept_hook_connection fails within 50 ms with returncode, stdout, and stderr when a CLI child exits before connecting to the hook socket
  • tests/cli/test_sync_sigint.py and test_hg_configured_remote_reaches_native_sync pass repeatedly under 16-process CPU contention
  • Full uv run py.test, ruff, ty (Python 3.11 and 3.15), strict Sphinx build (-W), and isolated scripts/runtime_dep_smoketest.py pass locally
  • Python 3.11 / 3.15 coverage matrix and check-workarounds in GitHub Actions

tony added 2 commits December 5, 2026 18:33
why: Post-timeout and post-interrupt recovery inspection spawned a
fresh Python worker with a 1.0s deadline while importing the full CLI
package, timing out under CPU or coverage load and dropping retained
dirty: preserve recovery tokens.

what:
- Raise _INSPECTION_TIMEOUT_SECONDS from 1.0 to 5.0 in
  vcspull._internal.sync_process
- Defer importing vcspull.cli.sync in sync_process._main() to sync
  operations so worktree and inspect workers load only _internal and
  validator modules
- Add test_watchdog_inspection_tolerates_slow_worker_startup and raise
  the Subversion inspection test timeout to 5s
- Update docs/cli/sync.md and CHANGES for the five-second deadline
why: test_sync_interrupt_stops_worker used a fixed 3s accept timeout,
dropped --timeout 30 in worktree mode, and matched the first
interrupted NDJSON event in parallel_main even when sibling_repo
finished first, while test_hg_configured_remote_reaches_native_sync
gave 16 sequential hg processes only 5s.

what:
- Poll the hook socket with selectors.DefaultSelector and
  process.poll() so crashed CLI children fail within 50ms while slow
  hosts get 20s startup and 15s shutdown budgets
- Run hook.py with python -S, pass --timeout 30 to worktree sync, bound
  accepted hook socket reads to 5s, and select NDJSON events by target
  repository or worktree
- Raise test_hg_configured_remote_reaches_native_sync worker timeout
  from 5s to 30s
@codecov

codecov Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.25%. Comparing base (cb7ac9e) to head (50a1a07).

Files with missing lines Patch % Lines
src/vcspull/_internal/sync_process.py 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #617      +/-   ##
==========================================
- Coverage   85.29%   85.25%   -0.05%     
==========================================
  Files          38       38              
  Lines        7658     7663       +5     
  Branches     1566     1567       +1     
==========================================
+ Hits         6532     6533       +1     
- Misses        747      751       +4     
  Partials      379      379              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

why: 10s (_DEFAULT_REPO_TIMEOUT_SECONDS) clips 16 sequential hg startups
on WSL2 (~10.9s), while 15s bounds the worker without a 30s ceiling.

what:
- Lower test_hg_configured_remote_reaches_native_sync worker timeout
  from 30s to 15s
@tony
tony merged commit d83187e into master Dec 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_sync_interrupt_stops_worker and hg worker test time out

1 participant