Skip to content

test(query): three conjunctions no fixture could tell from their halves - #3131

Merged
louistrue merged 1 commit into
mainfrom
mutation-sweep/spatial-query
Aug 24, 2026
Merged

test(query): three conjunctions no fixture could tell from their halves#3131
louistrue merged 1 commit into
mainfrom
mutation-sweep/spatial-query

Conversation

@BIMvoice

Copy link
Copy Markdown
Collaborator

Mutation-swept packages/spatial and packages/query. Test-only. One real gap in query; spatial turned out to be already hardened and is reported as such rather than padded.

The gap: three conjunctions whose halves never disagreed

packages/query/src/fluent-api.tsQueryBuilder.ofType() and both branches of withProperty() each rebuild the filter as previousFilter(entity) && <own predicate>.

No existing fixture had an entity satisfying the new predicate while failing the prior one, so the conjunction was never actually exercised. Three separate mutants, each dropping the previousFilter(entity) && half, all passed the full 218-test baseline:

  • ofType: this.currentFilter = (entity) => entity.type === type;
  • withProperty(key, value): dropped if (!previousFilter(entity)) return false;
  • withProperty(key) (existence form): same drop

Classification: untested-but-correct. The source was never wrong; the suite could not tell.

The fix is a fixture where the two match sets genuinely disagree — door #3 shares wall #2's exact Pset_WallCommon.IsExternal: false, so the property-only set {2,3} and the type-only set {1,2} differ on entity 3. The pre-existing "chain ofType and withProperty" test could never have caught this, because its two sets never diverged. Each mutant is now killed by its own dedicated test.

packages/spatial: already swept, and the near-miss is worth recording

The agent's initial worktree checkout was stale and showed zero test files for spatial — which it nearly reported as a finding. Re-branching from a freshly fetched upstream/main showed aabb.test.ts, bvh.test.ts and spatial-index-builder.test.ts, 50 tests, with git log attributing them to four prior sweeps (#2147, #2158, #2312, #2764).

That is the same class of error as the branch-drift trap: a stale checkout makes existing work invisible, and the natural conclusion is "untested" rather than "I am looking at the wrong tree."

Rather than take the hardening on trust, it spot-checked by hand: mutating bvh.ts's ray-behind-origin boundary return tmax >= 0> 0 fails exactly 1 test (bvh.test.ts:175), 49 passing. Restored, 50/50. No changes made to spatial.

Negative evidence

entity-query.ts's execute() offset-then-limit ordering — swapping the two .slice() calls is caught by should combine limit and offset. resolve-type-name.ts's fallback is already pinned by entity-node-unknown-type.test.ts. bvh.ts's raycast boundary, above.

packages/query was already substantially hardened too — entity-query.ts, entity-node.ts and resolve-type-name.ts all carry sweep-derived comments and fixtures referencing specific prior bugs. The fluent API was the part that had escaped.

Prior-sweep check

~35 candidate branches, each diffed against its own merge-base rather than current main. Only query-diff-create-sweep touched either package, and it is already merged (131e3dc84, #3009).

Verification

packages/query 218 → 221; packages/spatial 50 → 50, untouched. check-module-size.mjs exit 0, ratchet not moved. No changeset — test-only, no published behaviour change.

Leads not chased: duckdb-integration.ts (507 lines) is largely worker/AsyncDuckDB plumbing that is not meaningfully unit-testable without the WASM runtime, and its pure helpers already have dedicated tests. entity-node.ts's traversal is pinned by an explicit diamond-graph regression test whose comment already names the exact mutant a plain visited-set would introduce.

🤖 Generated with Claude Code

…overlap

Mutation sweep of packages/spatial and packages/query. QueryBuilder's
ofType()/withProperty() each build currentFilter as `previousFilter(entity)
&& <own check>`, but no existing fixture ever had an entity that satisfied
the new predicate while failing the prior one — so dropping `previousFilter`
from any of the three call sites (ofType, withProperty-with-value,
withProperty-without-value) left the full suite green. Added a fixture where
a door shares a wall's exact pset/property/value, and a two-ofType() chain,
so each conjunction is now independently observable.

packages/spatial was already mutation-swept (#2147, #2158, #2312, #2764) —
confirmed by running its existing bvh.test.ts suite against a hand-mutated
tmax >= 0 -> tmax > 0 and watching it fail. No changes made there.
@BIMvoice
BIMvoice requested a review from louistrue as a code owner August 24, 2026 07:42
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 35 minutes.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3292a6a4-db62-494a-99ad-fa2ccb34870e

📥 Commits

Reviewing files that changed from the base of the PR and between 9359bc4 and 194ea49.

📒 Files selected for processing (1)
  • packages/query/test/fluent-api.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Viewer benchmark

✅ No threshold regressions detected.

01_Snowdon_Towers_Sample_Structural(1).ifc

Baseline recorded 2026-07-01T20:31:05.538Z on github-actions ubuntu-latest, viewer-benchmark-ci (headless Chrome, SwiftShader ANGLE), production build.

Metric Current Baseline Delta Threshold Status
firstBatchWaitMs 1980ms 2905ms -31.8% +50%
firstVisibleGeometryMs 2848ms 3652ms -22.0% +50%
streamCompleteMs 3114ms 3598ms -13.5% +50%
spatialReadyMs 1473ms 1032ms +42.7% +50%
metadataCompleteMs 2146ms 3063ms -29.9% +50%
totalWallClockMs 3200ms 3700ms -13.5% +50%

AC20-FZK-Haus.ifc

Baseline recorded 2026-07-01T20:30:59.972Z on github-actions ubuntu-latest, viewer-benchmark-ci (headless Chrome, SwiftShader ANGLE), production build.

Metric Current Baseline Delta Threshold Status
firstBatchWaitMs 289ms 1075ms -73.1% +50%
firstVisibleGeometryMs 1413ms 1572ms -10.1% +50%
streamCompleteMs 968ms 1980ms -51.1% +50%
spatialReadyMs 1005ms 915ms +9.8% +50%
metadataCompleteMs 1111ms 1392ms -20.2% +50%
totalWallClockMs 1500ms 3300ms -54.5% +50%

Refresh the baseline from a CI run: dispatch the Benchmark workflow with record_baseline, download the benchmark-baseline artifact, and commit baseline.json (see tests/benchmark/README.md).

@louistrue
louistrue merged commit 6643c22 into main Aug 24, 2026
24 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.

2 participants