Skip to content

The detection tests' zip cases have the same ids in every worker - #299

Merged
zlareb1 merged 8 commits into
mainfrom
tests/zip-ids-deterministic
Nov 6, 2026
Merged

zlareb1 merged 8 commits into
mainfrom
tests/zip-ids-deterministic

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

...

Why

The unit job runs under pytest-xdist, and every worker must collect the same test ids. tests/unit/test_document_extraction.py builds four zip fixtures at import time, and their bytes become the parametrize ids of test_detect_format_reads_content_before_the_name and test_detect_format_refuses_what_the_bytes_do_not_support. ZipFile.writestr with a bare name stamps each entry with the current time, in two-second steps. Two workers that import the module in different two-second windows therefore collect different ids, and xdist stops the run with "Different tests were collected between gw13 and gw4". On the development host it happened in one of six full -n 16 runs.

The four zip cases now carry names as their ids (docx, pptx, xlsx, plain-zip), which read better in a failure than 600 characters of escaped zip. _zip also writes each entry through a ZipInfo, which dates it 1980-01-01, so its bytes are the same in every process and a zip row added later without a name keeps a stable id. What the tests detect is unchanged: detection reads the entry names, not their dates.

Scope and risk

Four parametrize rows and their helper in one test file. No server or extractor code changes. The other zip helpers in the unit suite build their bytes inside a test or a fixture, not in a parametrize list, so their timestamps never reach an id.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none.
  • Rollback: revert; the run can stop at collection again.

Tests

Collecting the whole unit suite twice, three seconds apart, gives the same 27,592 ids with this change. Without it, collecting test_document_extraction.py twice the same way gives four different ids. tests/unit/test_document_extraction.py passes (186).

a=$(mktemp); b=$(mktemp)
.venv/bin/python -m pytest tests/unit --co -q -p no:randomly > "$a"; sleep 3
.venv/bin/python -m pytest tests/unit --co -q -p no:randomly > "$b"; diff "$a" "$b"

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. The author reproduced the collection difference and checked it is gone.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version.
  • The frontend builds and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s).

🤖 Generated with Claude Code

zlareb1 and others added 2 commits November 6, 2026 18:24
Their bytes are parametrize ids, and an entry written by name alone carries the current time, so two xdist workers collecting in different seconds collected different ids and the run stopped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…f the bytes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1 zlareb1 changed the title The detection tests' zip fixtures are the same bytes in every worker The detection tests' zip cases have the same ids in every worker Nov 6, 2026
zlareb1 and others added 6 commits November 6, 2026 18:43
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…stable ids

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 4abdcda into main Nov 6, 2026
25 of 28 checks passed
@zlareb1
zlareb1 deleted the tests/zip-ids-deterministic branch November 6, 2026 19:36
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.

1 participant