Skip to content

feat(kernel): S1 — native OCCT kernel, recovery ladder, harness (99.5% on 391 files) - #15

Merged
gerchowl merged 4 commits into
mainfrom
feature/1-s1-kernel-harness
Oct 4, 2026
Merged

gerchowl merged 4 commits into
mainfrom
feature/1-s1-kernel-harness

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Description

Step S1 of plan.md: prove a kernel against a real STEP corpus. Plan A (occt-wasm) was run and
failed its gate, so this lands Plan B: native OCCT 7.9.3 as a subprocess. On 391 files it shows
99.5% of them faithfully; 0 crash and 0 time out.

Type of Change

  • feat -- New feature
  • docs -- Documentation only
  • build -- Build system or dependency changes

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • kernel/stepv-occt.cpp: STEPCAF/IGESCAF/BREP → XCAF walk → BRepMesh at a bbox-relative
    deflection → the per-face recovery ladder → STEPVMSH v2 buffers + a JSON summary that survives
    failure (exit 3). kernel/stress-gen.cpp generates the stress fixture.
  • src/occt.rs: the subprocess driver (timeout = kill) and the STEPVMSH decoder.
  • src/lib.rs: FaceStatus, LineKind, Lines, Part::is_well_formed.
  • examples/harness.rs, plus just fixtures (scripts/fetch-fixtures.py) with a sha256-pinned
    corpus recorded in tests/fixtures/corpus.sha256.
  • flake.nix: OCCT plus devkit's native module. Also fixes the statix/deadnix failures the
    scaffold shipped with (mkRustProject drops the .vig-os hook knobs, so the Rust scaffold fails deadnix/statix devkit#1810).
  • plan.md: S1 results, corrections (the claim that tessellateRelative is bbox-relative; the
    credentials claim), and an issue for every remaining step.

Verification: cargo fmt --check, cargo clippy --all-targets -D warnings, cargo test (19)
and cargo doc pass locally. nix flake check didn't run locally (sage's build governor held
it), so CI on this PR is its first run.

Changelog Entry

Added

  • Native OCCT kernel (#1): see CHANGELOG.md
  • Kernel harness and corpus (#1)

Closes #1
Refs #3

Plan A was run, not read. crates.io occt-wasm 4.0.0 cannot instantiate
its own module (unknown import), and on upstream main both STEP
importers trap: the facade writes input to /tmp inside a WASI module
whose import list has no `open`. 0% pass rate and a 2.2 s JIT cold
start trip two of plan.md §3's overturn criteria, so this lands Plan B.

- kernel/stepv-occt.cpp: STEPCAF/IGESCAF/BREP reader into XCAF, walk
  for names, colours and instances, BRepMesh at a bbox-diagonal-
  relative deflection, planar buffers in a STEPVMSH file plus a JSON
  summary that survives failure (exit 3). Run as a subprocess so a
  crash is contained and the deadline is a kill.
- src/occt.rs: subprocess driver with the timeout, and the STEPVMSH
  decoder, tested against truncation and absurd counts.
- examples/harness.rs: per-file verdicts (pass, partial, clean-fail,
  bad-mesh, crash, timeout), JSONL results, the Markdown gate table.
- just fixtures: scripts/fetch-fixtures.py fetches NIST PMI, 300 ABC
  models, the occt-import-js corpus, a synthetic 221 MB assembly and a
  malformed set, every download sha256-pinned; the corpus bytes are
  recorded in the committed tests/fixtures/corpus.sha256.

Result on 391 files: 97.2% pass, 0 crashes, 0 timeouts, 0 bad meshes,
all 10 malformed files fail cleanly; p95 337 ms under 1 MB; 62–69 ms
cold start. The harness also found two kernel bugs, both fixed here:
relative input paths silently dropped multi-file assemblies' external
references, and OCCT auto-naming inflated the names column.

plan.md records the numbers, corrects the tessellateRelative claim
(OCCT's per-edge flag, not bbox-relative), and carries the S2 items
S1 surfaced: memory cap (a perforated plate peaks at 7.2 GB), per-face
colour, and a header-only --info that skips the slow transfer.

Not run: `nix flake check` was held by the sage build governor (vnodes
87% over its 80% gate); fmt, clippy -D warnings, tests and docs were
run directly through cargo instead.

flake.nix also gets the two lint fixes its hooks had been failing on
since c888499: `inherit (rust) checks packages` for statix, and
`# deadnix: skip` on the five .vig-os bindings that are unused only
because mkRustProject does not forward them (the gap plan.md §7 owes
devkit an issue for). The managed block's logic is unchanged.

Refs: #1
Every face the first meshing pass leaves without triangles now goes down
a ladder, each rung on an isolated copy so neighbours' shared edges are
never disturbed: clean re-mesh, ShapeFix + re-mesh, re-mesh at a
deflection relative to the FACE's size, a degenerate check (zero
parametric width or sub-pixel area), relaxed parameters, a UV-grid
approximation clipped by the face classifier, and finally outline-only.

Which rung produced each face is recorded as a FaceStatus in the
contract (STEPVMSH v2), with is_faithful() as the line between drawing
normally and drawing with a warning. That is what lets a renderer give
approximated and missing faces a broken-face overlay instead of passing
them off as the model.

Faceless parts are drawn as line segments: LineKind::Sketch when the
whole file has no faces (ABC 00000092 is a sketch exported as STEP),
LineKind::Construction when they sit beside solids (149 parts in 43
files: construction geometry, axes, PMI curves), which renderers hide by
default.

Face-by-face diagnosis of the old 2.8%: 4 files needed ShapeFix (a clean
re-mesh alone does not help), 4 had faces far smaller than the model or
boundaries that self-intersect only at the model-relative deflection, 3
were zero-area exporter slivers rather than holes, and 2 are genuinely
unmeshable visible faces (self-intersecting planes; a cone missing its
apex edge), now approximated and flagged.

Result on the same 391 files: 99.5% faithful (388 pass + 1 wireframe),
2 degraded, 0 partial, 0 crashes, 0 timeouts; p95 under 1 MB unchanged
at 335 ms. plan.md §5 "S1 follow-up" records the table.

Refs: #1
§7 said stepv's workflows get their credentials once org-config applies
the declaration. They don't: otterdog does not reconcile
selected_repositories for dummy-valued org secrets (org-config#318), so
an org owner has to add stepv to six secret lists by hand (#3). §7 now
says so, and records that the declaration merged as org-config#317 and
its apply is waiting on the production environment.

Every remaining step and owed item now has an issue (#4–#14, plus
vig-os/devkit#1810), tabled in §5, so plan.md is the design record and
the issues are the tracker.

Refs: #1, #3
@gerchowl
gerchowl merged commit 87e0820 into main Oct 4, 2026
8 of 10 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.

S1: prove the kernel against a real STEP corpus (occt-wasm failed → native OCCT)

1 participant