Repository navigation
The unit job runs as six parts that each collect only their own files, their coverage combined in one job - #297
Merged
Merged
Conversation
zlareb1
force-pushed
the
ci/unit-parts
branch
2 times, most recently
from
November 7, 2026 07:08
48e4249 to
6c6615d
Compare
…ombined in one job With two cores per runner, one unit job took 30 minutes. LOOM_TEST_SHARD splits the suite by whole files (tests/_shards.py); each part writes its own coverage data file, and unit-coverage combines them and applies the 40% and per-module floors. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…note Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e checks time the parser with the tracer off A coverage run's tracer tripled the SQL split's CPU time to 11 s against its 10 s bound; every _within caller runs extractor code, which the unit coverage does not measure. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…st of its own The branch was covered only when an earlier test in the same process left a snapshot behind; split into parts the unit run stopped covering it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Every part collected the whole suite under coverage before dropping five sixths of it, which took about four minutes per runner, and parts dealt by test count ran from 6 to 14 minutes. LOOM_TEST_SHARD now picks files before collection (pytest_ignore_collect), weighted by tests/shard_weights.json, seconds per file from a run's JUnit reports, which the unit-coverage job regenerates as an artifact. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…code-search timing tests have margin, docs name the integration weights Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…der needs a report, the snapshot test moves time Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A trace task of another loop, a wider outline row for one declaration and the per-row extraction cost were covered only when another test left state behind or fed rows in a hash-seeded order; split into parts, the unit coverage lost them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…weights upload first, one test-module check, the clock seam, a directory-argument test Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ll-clock bounds get the sleeps' margin, stale comments Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… the TTL test counts its reads, the outline test pins the signature, the node-id test names its own file Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…, fresh contexts, resolved paths, the stray file under tmp_path, a weights sanity test Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tory test splits the integration suite, coverage pins the C tracer, a failing part still uploads its times, make test-unit-cov measures as CI Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…he pre-push skill point at make test-unit-cov, a local part matches CI's in a clean checkout Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…the conftest docstring, re-runs overwrite a part's artifact Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…r shard tests 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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
ci/unit-parts
branch
from
November 7, 2026 08:32
6c6615d to
d4d5b88
Compare
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
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
With pytest-xdist the unit job runs on both cores of its runner, and it still takes about 30 minutes (29:39 and 30:35 for the pytest step). The repository's runners have two cores, so going faster means more runners. The unit job is now six parts, and a
unit-coveragejob combines their coverage.A first version split the suite the way the integration job does: each part collected the whole suite, then deselected the other parts' tests by test count. On CI those parts ran from 5:56 to 13:55. Two causes:
test_delete_version_sqlandtest_grep_planeach take several minutes, while most files take under a second.So the shared split (
tests/_shards.py) changes in two ways:LOOM_TEST_SHARD=k/npicks a part's files before collection, throughpytest_ignore_collectintests/conftest.py, so a part imports and collects only its own files. A file or node id named on the command line is never offered to that hook, sopytest_collection_modifyitemsalso deselects what such an argument brought in from another part. A test file the walk does not find runs in part 1. Either way every test file runs in exactly one part.tests/shard_weights.jsonrecords for each. A file it does not list weighs its count of test functions times the recorded seconds per test function, or one second each when nothing is recorded, as for every integration file. The weights only balance the parts; they cannot drop or repeat a file.unit-coverageuploads ashard-weightsartifact rebuilt from the parts' JUnit reports, for refreshing the committed file when the parts drift apart (python -m tests._shards junit-*.xml).In CI:
unitis a matrix of six parts, eachpytest tests/unit -n autowithLOOM_TEST_SHARD=k/6and its own coverage data file (COVERAGE_FILE=.coverage.unit-k) and JUnit report.unit-coveragerunscoverage combine, the 40% floor (coverage report --fail-under=40) and the per-module floors on the combinedcoverage.json. It also runs the bench harnesses and the generic integration sample, the steps the old job ran after its tests.Parallel parts exposed these test problems, each fixed at its source:
_withinnow pauses the tracer while it times, so a coverage run times the parser and not itself. Coverage's tracer had taken the one-line SQL split to 11.2 s of CPU against its 10 s bound on CI; on the development host the split takes 1.46 s untraced, 3.23 s traced and 1.41 s with the tracer paused (sql._spanson the test's input undercoverage.Coverage(branch=True)). Every_withincaller runs extractor code, which the unit coverage does not measure.pyproject.tomlpins coverage's C tracer (core = "ctrace", the 3.12 default), the onesys.settrace(None)pauses.test_code_search_legs.py,test_code_grep_scan.py::test_as_of_runs_beside_the_chunk_read, and the two intest_memory_code_grounding.py. Their fake reads now sleep 0.2 s instead of 0.05 s, with each bound scaled by the same factor. The check is the same, with four times the margin for a loaded runner. Two of them had failed at the old size: 0.185 s against 0.17, and 0.0965 s against 0.095. The two timed tests intest_code_search_legs.pyalso failed when one was the first code search in its process: that search imports the tracing modules on the event loop, about 0.2 s on a cold start, inside the vector chain before the embed. The vector read then started on the tick the lexical read ended, or the fuzzy-vote search ran over its bound. Both tests now run one untimed search first and empty the corpus-stats cache that search filled. With a 0.25 s blocking first span injected, both old tests fail (the fuzzy one at 0.81 s against 0.68) and both new ones pass.cost_accumulator.begin_op()binds the op's tally to the current context, and sync tests that call it left it bound in the main thread's context for every later test in the process. A new autouse guard intests/unit/conftest.pystarts each test with no accumulator and puts back what was there, as the query-tag guard does; accounting state is reset rather than failing the test that bound it.test_session_brief.py's redaction checks assert that4111from a test card number is absent from the stored row. They left out onlyversion, so a part failed when the row'screated_atread21:47:23.941119. They now leave out every*_atcolumn too. The same checks fail onmainwhenever a timestamp holds those digits.Scope and risk
CI configuration,
tests/_shards.pyand the root conftest, the unit conftest's new guard, the weights file, ten unit test files (test_test_shards.py,test_session_brief.py,test_code_search_legs.py,test_code_grep_scan.py,test_memory_code_grounding.py,test_document_extraction.py,test_loom_search_fanout_kinds.py,test_code_observability.py,test_code_outline.py,test_build_cost_accounting.py), aMakefilecomment,pyproject.toml(its coverage comment andcore),make test-unit-cov(now with branches and the per-module floors, as CI), the testing and local-development docs, the tests README, and theloom-investigate-ciandloom-pre-pushskills' rows. No server code changes.The integration job uses the same split, now before collection too. Its files are weighed by test-function count instead of collected test count: the four parts now collect 514, 505, 462 and 461 tests, 1,942 in all, as before (
LOOM_TEST_SHARD=k/4 pytest --co -q tests/integration, k = 1..4).A part's failure skips
unit-coverage, because coverage from five parts would miss the floors for the wrong reason.Compatibility, rollout and rollback
pytest unit + coveragejob.Tests
CI with the split before collection, at three heads (6c6615d is this head, on
mainat f92e76e):unit-coverageEarlier heads: at 8321160 the parts took 5:43 to 7:45 and
unit-coverage1:29, 9:17 for the stage.At 0b3e1f1 the parts took 5:43 to 8:18 and
unit-coverage1:41, 10:01 for the stage.main's single unit job took 31 to 32 minutes.Coverage. Combined across the parts, coverage first came out a few lines short of
main's single job at the same base: 178,318 against 178,324 lines and 46,731 against 46,734 branches at 46f5031. Every missing line was a path that some test reached only by chance, either through state an earlier test in the same process left behind or through rows in a hash-seeded order. Splitting changes which tests share a process, so these lines come and go. Each now has a test of its own:namespace_kinds.kind_mapserving its last snapshot when a read fails after the TTL, and narrowing nothing with no snapshot (test_loom_search_fanout_kinds.py);schedule_code_tracedropping a trace task of another loop (test_code_observability.py);collapse_outline_rowsmerging a wider row for the same declaration, with a scip row on either side (test_code_outline.py);_account_buildpricing each written row from the request's cost accumulator (test_build_cost_accounting.py).At 0b3e1f1, rebased on
mainat 4abdcda, the combined coverage covers 178,572 of 193,260 lines and 46,796 of 55,000 branches;main's single job at 4abdcda covered 178,567 lines and 46,792 branches. The per-module floors pass on the combined data in every run.Collection. On the development host the six parts' collections add up to the whole suite, and so do the four integration parts' (1,942).
tests/unit/test_test_shards.pycovers the following:The full unit suite passes at d4d5b88 (this branch rebased on
mainat 29a6d7e, which adds only extractor changes), run locally as twoLOOM_TEST_SHARDhalves under-n 8(27,757 passed). The exception is the four cases of the delimiter-sniff test, which fail on the development host's CPU and pass on CI.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 checked the combined coverage against
main's, the parts' collections and the CI times.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no merged migration is edited.frontend/changed.docs/describe the system as it now is.git commit -s).🤖 Generated with Claude Code