Skip to content

mcpx e2e shard-packer tests keep NamedTemporaryFile open while reopening its path — fails on Windows (PR #7897 review finding) #8096

Closed

Description

@dezren39

mcpx e2e shard-packer tests keep NamedTemporaryFile open while reopening its path — fails on Windows

Finding (from PR review)

On PR #7897 (mcpx(ci): guard malformed e2e timing seeds), Copilot review comments 4508758212, 4508758233, 4508758244, 4508758252, and 4508758267 (Copilot, 2026-11-09T01:50:15Z–01:50:16Z, pkgs/mcpx/scripts/tests/test_e2e_shard_packer.py:33,65,89,100,136) — one finding repeated at five call sites:

NamedTemporaryFile is kept open while load_weights() (and the subprocess in the CLI test) tries to open the same path. This is a known portability issue on Windows (file locking can cause PermissionError / open failures). Consider writing to a temp path that is closed before reading (e.g., TemporaryDirectory() + open()), or using NamedTemporaryFile(delete=False) and explicitly closing it before calling load_weights() / running the subprocess (with a finally cleanup).

No-response evidence

Still-live evidence (current PR head)

Raw read at head dc84f22fcf agrees — the pattern is present verbatim at every flagged site in pkgs/mcpx/scripts/tests/test_e2e_shard_packer.py:

  • Lines 30–33 (load_seed helper): with tempfile.NamedTemporaryFile(mode="w", suffix=".json") as seed: … return packer.load_weights(seed.name, …) inside the with block.
  • Lines 62–65, 86–89, and 97–100: the same open-while-reopening pattern in three more tests.
  • Lines 122–139 (CLI test): with tempfile.NamedTemporaryFile(mode="w+", suffix=".out") as output: is passed as --github-output to a subprocess and then read/seeked while still open.

Acceptance criteria

  • No test in test_e2e_shard_packer.py reopens (directly or via subprocess) a path whose NamedTemporaryFile is still open: write-close-read via a temp directory/path, or delete=False + explicit close with cleanup, at all five sites (including the CLI output file).
  • The shard-packer test suite still passes.
  • Resolving by a documented decision on this issue is also acceptable.

Filed by the pr-comment-review job (run 2026-11-09 19:54 CST) under the queue cutover: labels applied at filing, standard agent note posted after filing, and a repo-task/v1 triage packet (kind: triage, priority 30) enqueued on repo-health-code-pilot.

Activity

  1. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    on Nov 10, 2026
  2. developing-today commented on Nov 10, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  5. added
    work/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 10, 2026
  6. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (triaged)

  7. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 10, 2026
  8. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — Agent: queue worker (repo-worker-code), lane code-j — Session/ID: task 14489, repo-queue-worker-shift-j 2026-11-09 run. Task 14489 (small_fix, direct lane) fixed issue #8096: all five sites in pkgs/mcpx/scripts/tests/test_e2e_shard_packer.py that reopened a path whose NamedTemporaryFile was still open now use write-close-read (shared write_seed helper with delete=False + addCleanup unlink for the four seed sites; the CLI test closes its output file before the subprocess opens it by path and reads it back after). Landed as commit ca91de1 on PR #7897's branch queue/11046-6822-e2e-seed-shape-guards (the file exists only on that branch; PR head verified fresh at ca91de1 after push). Oracle: python3 -m unittest discover -s pkgs/mcpx/scripts/tests -p 'test_e2e_shard_packer.py' on the laptop — 6/6 tests pass. Per packet scope, the source PR review thread was not replied to or resolved (pr-comment-review job rules). Issue stays open until PR #7897 merges.

  9. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    Agent: repo-worker-code / any-f
    state: done (triaged — already fixed, closing) (task 18586, lane any-f)
    issue: #8096

    Verdict: the Windows temp-file finding is fixed on main — closing as completed

    Bulk-intake re-triage (2026-11-16 reload), verified fresh 2026-11-17:

    • PR mcpx(ci): guard malformed e2e timing seeds #7897 (the PR whose review raised this finding) MERGED 2026-11-14T21:52:33Z.
    • In the current pkgs/mcpx/scripts/tests/test_e2e_shard_packer.py, all five cited call sites now funnel through the write-close-read pattern Copilot prescribed:
      • write_seed() uses NamedTemporaryFile(delete=False) inside a with block — the file is closed before load_weights() reopens its path — with addCleanup(os.unlink, path) and a comment naming the Windows constraint.
      • The CLI subprocess test uses the same pattern for its output file.
      • The discovery tests use a TemporaryDirectory with cleanup.
        No NamedTemporaryFile is kept open across a reopen anywhere in the file.
    • Test run verified this shift: python3 -m unittest discover -s pkgs/mcpx/scripts/tests -p 'test_e2e_shard_packer.py' — 15 tests, OK.

    The tracking issue was simply never closed after the fix landed.

  10. removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions