Skip to content

tests: the suite is not hermetic — network, real home config, wall-clock sleeps, unreset module caches (T-01, T-06..T-09) #235

Closed

Description

@ViperJuice

From the 2026-09-01 codebase review (plans/codebase-review-2026-09-01.md), findings T-01 and T-06 – T-09.

The suite is strong — 3199 passing, 85% coverage, mutation evidence behind the CI guards — but not hermetic:

  • one test reaches the npm registry;
  • one reads the developer's real home configuration;
  • 65 tests wait on real wall-clock sleeps;
  • no fixture resets the module-level caches, so cross-test pollution is possible and ordering-dependent failures are hard to attribute.

This is not theoretical here. Three separate CI incidents in the last week came from exactly this class: #226 (a 0.2 s wall-clock assertion failing by 2 ms), the #200 SSE hang (order-dependent, and the local repro needed the module rather than the full suite), and the standing /tmp/package.json quirk that makes ~107 npm-identity tests fail on any host that happens to have that file — documented in tests/conftest.py, but documentation is not isolation.

Related and already open: #226 (the timing assertion). That one should probably be fixed as part of this rather than separately, since the fix is the same idea — assert the property, not the wall clock.

Suggested order, cheapest first: reset module caches in an autouse fixture; replace real sleeps with virtual/eventual assertions; point home-config reads at a tmp_path; mark or stub the network test. Effort M in total, but each item is independently landable.

Activity

  1. ViperJuice commented on Sep 15, 2026

    @ViperJuice
    CollaboratorAuthor

    Partial progress from PKGID (#246): tests/conftest.py now has an autouse _no_live_npm_registry guard. Any test whose package-identity lookup opens registry.npmjs.org fails at teardown and names the URL. There is also a fake_npm_registry fixture. Three tests had silently started calling the real registry once registration began resolving packages; they now use the fixture. This covers the package-identity path only (pmcp.manifest.package_identity), not other network use such as the npm resolver or version checker. Wall-clock sleeps, real-home reads and module-cache resets are untouched, so this stays open.

  2. 6 remaining items

  3. ViperJuice commented on Sep 26, 2026

    @ViperJuice
    CollaboratorAuthor

    Slice C3 (#292) review board: 0 blocking. Two deferred, pre-existing items are tracked in #293: wall-time consumers of the request clock outside ClientManager, and suites that wait out pytest-timeout when the idle timeout is broken.

  4. ViperJuice commented on Sep 26, 2026

    @ViperJuice
    CollaboratorAuthor

    Every slice is merged, so I'm closing this. Each of the four items in the issue maps to merged work:

    Item from the issue Slice Plan PR Implementation PR
    test reads the developer's real home config; cwd/temp isolation A #263 #266 (autouse HOME redirect + cwd isolation, temp-root guard)
    no fixture resets module-level caches B #265 #267
    wall-clock sleeps / timing assertions (incl. #226) C1 #264 #268
    fixed sleep-then-assert sites C2a #270 #273
    hand-rolled pollers onto one helper C2b (named in #270) #278
    wall-clock-window assertions C2c #279 #280
    idle-timeout tests waiting on wall time C3 #289 #292 (merged as 9ca081e; board 4/4 seats, 0 blocking)
    test reaches the npm registry — — #246 (autouse _no_live_npm_registry guard + fake_npm_registry; see the comment above)

    Verified at main 9ca081e on CI (3.10/3.11/3.12 green on the PR head that was merged). Locally, the full suite gives 4071 passed, 3 skipped, 25 deselected, with the idle-timeout tests at ≤ 10 ms each (40/40 flake loop).

    Two pre-existing items that C3's review deferred as out of scope are tracked in #293.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions