Skip to content

Computational assurance and coverage policy ​

SurfView's test policy treats coverage as a backstop for explicit scientific and lifecycle contracts. A high aggregate percentage cannot compensate for a missing oracle, an untested backend, or a zero-coverage critical module.

Named invariant suites ​

Risk domainExecutable contractMain evidence
StatisticsValid domains; finite bounded outputs; tToZ(0, df) = 0; odd symmetry; monotonicity in abs(t); continuity in dfstatistics.test.ts compares 40 points against an independently generated R upper-tail oracle and adds metamorphic/adversarial cases.
LoadersExact geometry and laterality; dimensions and encodings agree; finite coordinates; bounded indices and allocation; atomic typed failureloaders.test.ts covers ASCII, Base64, gzip, zlib, endian routes, truncation, malformed XML/headers, non-finite values, hostile lengths, invalid UTF-8, aborts, deadlines, and maxBytes.
GeometryValid adjacency indices; symmetric neighborhood construction; finite curvature; normalization boundscurvature.test.ts, numeric-validation.test.ts, loaders.test.ts, and adjacency assertions in statistics.test.ts.
BlendingStraight-RGBA Porter-Duff semantics; opacity applied once; mode and order laws; transparent/opaque boundariesrgba-compositing.test.ts uses hand-derived results and a separate scalar oracle; gpu-compositing.spec.ts reads pixels from the production shader and compares them to that oracle.
LifecycleOne coalesced frame; zero recurring RAF when settled; context-loss pause/recovery; idempotent listener/resource disposalDirect scheduler/context tests, viewer-lifecycle.test.ts, and viewer-lifecycle.spec.ts in a real browser.
Picking transformsScreen-to-NDC conversion; world transforms; closest face/vertex; miss/null contract; CPU/GPU metadatapicking.test.ts, viewer-picking-controller.test.ts, GPUPicker.test.ts, and cortical-scale GPU picking in performance-benchmark.spec.ts.
SerializationVersioned round-trip; finite/schema/reference validation; stable order; legacy selection rule; no partial mutationserialization.test.ts exercises corrupted/future payloads, invalid numbers and references, migration fixtures, event reports, and transactional restoration.

Rendering evidence layers ​

Rendering claims require distinct evidence because one layer cannot substitute for another:

  1. Pure algebra: rgba-compositing.test.ts checks hand-derived scalar and full-buffer results without WebGL.
  2. GPU readback: gpu-compositing.spec.ts renders the production GLSL path to a target, reads pixels, and compares every supported blend case with the pure oracle.
  3. Browser behavior: surface, volume, controls, lifecycle, gzip, embed, and regression Playwright suites exercise real package behavior.
  4. Visual baselines: the required macOS visual-regression job runs controls-panel.spec.ts with SURFVIEW_GOLDEN_SNAPSHOTS=1 and compares the first-party control layouts with reviewed snapshots. The Ubuntu browser job retains cross-platform functional and image-change assertions without pretending a missing platform baseline is a pass. These snapshots cover presentation only; they are not numerical or shader oracles.

Risk-weighted thresholds ​

vitest.config.ts enforces a modest global floor and higher reviewed thresholds for the critical modules below. The exact-file gates are evaluated separately, so excess coverage elsewhere cannot hide a drop.

BoundaryBranch floorWhy
Statistics85%Numerical domains, tails, and invariants
Loader boundary68%Multiple encodings and adversarial failure routes
Mesh adjacency / curvature90% / 72%Geometry integrity and degenerate meshes
RGBA composition / validation90% / 90%Renderer semantics and transactional input safety
CPU picking / GPU picker55% / 30%Pure transforms plus browser-only WebGL paths
Viewer state / serializer / deserializer78% / 48% / 58%Versioning and atomic restoration
Picking, render, and WebGL lifecycle controllers48% / 82% / 85%State-machine and resource ownership
React viewer / hook48% / 24%Shipped optional entry, including SSR and StrictMode behavior

The lower GPU-picker and React-hook branch floors reflect code that must execute in a browser or React lifecycle and is also covered by Playwright or fixture builds. They are explicit ratchets, not permission to replace those integration tests with unit coverage.

Only declaration files are excluded. Type-only barrels remain visible as zero runtime coverage because they emit no runtime behavior; critical implementation files are named individually. Coverage includes src/react/**/*.ts(x) and src/index.react.ts.

CI behavior ​

npm run test:coverage is the CI unit command. It fails both the global and critical-file thresholds and writes text, JSON summary, and LCOV reports. CI publishes the complete coverage/ directory even after failure so reviewers can distinguish a real critical regression from instrumentation or runner trouble.

Large deterministic performance cases have separate time/memory budgets. See the performance benchmark report for the noise policy and stored baselines.

Released under the MIT License.