Skip to content

feat: S2–S6 — CLI, limits, Linux + macOS front-ends, release train - #17

Merged
gerchowl merged 21 commits into
mainfrom
feature/5-s2-cli
Oct 4, 2026
Merged

gerchowl merged 21 commits into
mainfrom
feature/5-s2-cli

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

S2–S6: the rest of stepv on top of the S1 kernel (#15). After this PR, the CLI, the Linux
thumbnailer/MIME/KF6 plugin, the viewer window and the macOS Quick Look extensions all work and
are tested, and the release train is wired. Publishing waits only on human credentials (plan.md
§7 "Owed").

Type of Change

  • feat -- New feature
  • ci -- CI/CD pipeline changes
  • docs -- Documentation only
  • test -- Adding or updating tests
  • build -- Build system or dependency changes

Modifiers

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

Changes Made

Tests: 66 Rust (unit, end-to-end CLI against the real kernel, C ABI), plus the Linux integration
and macOS checks.

Bugs found and fixed along the way, each recorded in its commit:

  • a dropped PRODUCT count at the stream tail
  • IGES Hollerith fields hidden by record padding
  • debug-only integer overflows
  • .gitignore swallowing tests/data
  • Scaffold Drift from a hand-edited managed file
  • the Quick Look type traps (public.3d-content, and the agent's cached type graph)

Changelog Entry

See CHANGELOG.md ## Unreleased → Added: the CLI, stepv view, the Linux front-ends, macOS
Quick Look, the release train, NOTICE, kernel CI and cargo-deny.

Closes #4
Closes #5
Closes #6
Closes #7
Closes #8
Closes #9
Closes #11
Closes #13
Refs #10

Faces now carry their own XCAF colour next to their status: a colour on a
shell or solid sub-shape applies to its faces, a face label wins over
both. 81% of parts in the S1 corpus are coloured only per face, so
without this every Onshape preview came out grey. The format goes to v3
(14 bytes per face) and src/occt.rs decodes it into lib::Face.

kernel/fixture-gen writes the small committed corpus in tests/data/
(an instanced, named, per-face-coloured assembly; a sketch; IGES; BREP)
so the CLI tests and nix flake check need no network. The kernel also
gains a STEPV_OCCT_TEST_BALLOON_MB hook so the memory-cap test is
deterministic. tests/data/ is re-included past the managed .gitignore's
blanket data/ rule.

Refs: #5
occt::run takes Limits { timeout, memory } and kills the kernel when its
footprint (macOS ri_phys_footprint via proc_pid_rusage; Linux RSS from
/proc) passes the cap, sampled every 5 ms, reporting Outcome::MemoryCap.
RLIMIT_AS was tried and rejected: macOS ignores it, and on Linux it caps
virtual address space, which OCCT and glibc's malloc arenas reserve by
the hundreds of MB, so a resident-memory cap would kill the kernel at
load. Default 4 GiB. Verified on ABC 00000046 (7.2 GB uncapped): killed
at a 1 GB cap. The harness gains --memory-gb and a memory-cap verdict;
kernel_path() also looks in ../libexec/stepv/ for packaged installs.

Refs: #4
A Part 21 HEADER parser (FILE_DESCRIPTION / FILE_NAME / FILE_SCHEMA,
with the standard's string escapes decoded and AP203/214/242 named),
the IGES Start and Global sections, and the BREP banner, plus a bounded
streaming PRODUCT count. Reads the head of the file only, and cannot
fail: problems become header_error. This is the honest-degradation path
the front-ends fall back on.

Refs: #5
…overlay

src/render.rs draws a Scene to RGBA with no GPU (z-buffer, isometric,
2x supersampled, per-face colour). Approximated faces are striped
amber, missing faces' outlines drawn red on top, a warning badge marks
the image; sketch curves are drawn, construction curves hidden.

src/glb.rs writes glTF 2.0 with a node per named part under a
Z-up-mm to Y-up-m root, primitives grouped by colour and face status,
an amber stepv:approximated material and extras.stepv_face_status so a
viewer can flag what the kernel only approximated. Tests validate with
the gltf crate.

Refs: #5
--info, --png, --glb; every run past argument parsing prints one JSON
line (header metadata, outcome, kernel summary), including on failure.
Exit codes as documented: 0 ok, 2 usage, 3 no geometry (unreadable,
tessellation failed, memory cap) with metadata intact, 4 timeout. Hits
and failures are both cached (keyed on path/len/mtime/deflection/output/
size); timeouts are not. Outputs are written atomically.

tests/cli.rs runs the real binary and kernel against tests/data and
FAILS when the kernel is missing unless STEPV_SKIP_KERNEL_TESTS=1 is
set on purpose. The flake builds the kernel as packages.kernel, points
every crane check at it, and packages.default ships the CLI with the
kernel in libexec/stepv; tests/data is excluded from the text hooks.

Refs: #5
@gerchowl
gerchowl changed the base branch from feature/1-s1-kernel-harness to main October 4, 2026 15:15
The standalone viewer plan.md §1 asks for: drag to orbit, right/shift-
drag to pan, scroll to zoom, R/F/T presets, C construction curves. It
renders through src/render.rs, so the window shows exactly the pixels,
colours and broken-face overlay the thumbnails do. The rasteriser gains
a Camera (azimuth/elevation/zoom/pan), non-square output and a sphere
fit so an orbiting model does not resize as it turns.

Input is the pure Controls state machine, unit-tested headlessly; only
the window loop needs a display. Behind a default-on viewer feature
(minifb, which dlopens X11/Wayland, so no build-time system libs);
--no-default-features builds a headless stepv. Opens a window on macOS
(smoke-tested: runs until killed).

Refs: #7
…and kernel

devkit's CI lanes ran no Rust and reported green: the scaffolded just
test/lint are pytest/ruff-only, ci.yml never runs nix flake check, and
the hooks have no rustfmt or clippy (filed as vig-os/devkit#1811).
justfile.project's test/lint now run rustfmt, clippy -D warnings on both
feature sets and the whole suite against a freshly built kernel, so the
existing Tests lane becomes a real check.

New .github/workflows/kernel.yml (Linux + macOS): nix build of the
product, kernel and KF6 plugin; nix flake check; harness --strict and
the CLI sweep on the redistributable corpus; and the Linux desktop
integration test. scripts/cli-sweep.py (S3) holds the real CLI to its
exit-code contract: on the full 401-file corpus with default limits all
391 real files exit 0 and the 10 malformed exit 3 with metadata.

packaging/linux (S4): a freedesktop .thumbnailer (GNOME, XFCE), MIME
definitions with content magic for STEP and a model/x-brep type, a
.desktop entry opening the formats in stepv view, and install.sh in
the libexec/stepv layout. packaging/kde: a KF6 ThumbnailCreator that
shells to the same CLI. The flake's default package carries the share/
files; kde-thumbnailer is Linux-only. scripts/test-linux-integration.sh
checks the thumbnailer exactly as the desktop invokes it (4 formats; a
broken file fails with no image), the compiled MIME database and the
desktop entry. Passes locally.

Refs: #11, #6, #7
The tests/data re-include was hand-appended to the generated .gitignore,
which the Scaffold Drift check rightly rejected: the managed file must be
the template plus .gitignore.project verbatim, in the template's place.

Refs: #5
For front-ends that build their own scene from the buffers (the macOS
preview). Goes through the cache (Output::Buffers), the timeout and the
memory cap like --png and --glb; tested end to end, including that the
plate's own red top face survives the round trip.

Refs: #5
The macOS Quick Look extensions cannot run the kernel as a subprocess:
their sandbox forbids exec (posix_spawn fails with EPERM, while stat of
the very same file succeeds). So the kernel splits into
stepv-occt-core.cpp, exported as stepv_occt_run() behind a C header,
plus the thin stepv-occt CLI main the Rust side keeps running as a
subprocess. The library serialises calls: OCCT's data-exchange layer
keeps global state, and Quick Look issues concurrent requests.

Refs: #9
The second library consumer plan.md §"Crate layout" named as the split
trigger: a staticlib exposing stepv_render_png (STEPVMSH to PNG through
the same rasteriser and broken-face overlay as stepv --png) and
stepv_info_json (the --info header reader), with no panic able to unwind
into Swift. A workspace member; the library stays in the stepv crate so
crates.io still sees one crate. Built on its own (just macos-app), since a
--workspace build unifies the CLI's viewer feature into it.

Refs: #9
…ut Xcode

macos/: a host app declaring STEP/IGES/BREP types, a QLThumbnailProvider
and a QLPreviewingController. Both call the kernel and the renderer
IN-PROCESS (the sandbox forbids exec); the extension process is the
containment, which the system kills on hang or memory pressure. The
thumbnail is pixel-identical to Linux's; the preview is an interactive
SceneKit view built straight from the STEPVMSH buffers (buffers, not
USDZ: plan.md §4), and degrades to header metadata when there is no
geometry. scripts/build-macos-app.sh assembles the bundles with the
Command Line Tools' swiftc, relocates OCCT out of /nix/store into one
shared Frameworks/ (57 MB), and signs inside-out (ad-hoc, or Developer ID
+ hardened runtime via STEPV_SIGN_IDENTITY).

Found the hard way and recorded in the code: the types must NOT conform
to public.3d-content (Apple's SceneKit thumbnailer claims that and then
fails), and ThumbnailsAgent caches type graphs until logout.

scripts/test-macos.sh: the Swift reader agrees with the Rust one on
parts and triangles, the preview scene renders offscreen with its
per-face colours, and with --quicklook Quick Look itself thumbnails all
four formats through the installed app. All pass. package-macos.sh
builds the DMG and notarises once Apple credentials exist.

Refs: #9
…ery package

The Open CASCADE exception asks for prominent notice that the software uses
OCCT; LGPL-2.1 asks for the licence text and a way to replace the library.
NOTICE states both, per artefact (AppImage, stepv.app, source builds), and
lists the other bundled libraries (FreeType, libpng, zlib, bzip2, Brotli,
GNU libiconv) with their licences. The texts are byte-for-byte OCCT's at
V7_9_3, so licenses/ is excluded from the whitespace hooks. stepv.app
carries them in Contents/Resources, the nix package and install.sh in
share/doc/stepv; the crate includes them.

Refs: #8
release-extension.yml (devkit's pre-publication seam, which blocks the
Release on failure): an AppImage of the whole nix closure, smoke-tested;
stepv.app as a DMG, Developer-ID signed, notarised and stapled when the
Apple secrets exist (a final release refuses to ship without them, a
candidate falls back to ad-hoc and says so); build-provenance
attestations for both; and cargo publish from the gated crates-io
environment on final releases, by token for the first publish and by
Trusted Publishing (OIDC) after. release-assets.yml attaches the attested
artefacts to the published Release (the seam's token cannot), by version.
prepare-release-extension.yml sets the crate versions on the release
branch (scripts/set-version.py), which devkit's changelog freeze does not.

The Kernel CI now also builds and smoke-tests the AppImage on Linux and
the macOS app with its headless checks on macOS, so neither artefact is
first built on release day. The crate gets an include list (34 files, 98
KB) and verifies from its own tarball.

Refs: #10
The README still said the kernel was unproven and named occt-wasm.

Refs: #10
deny.toml turns on mkRustProject's cargo-deny check, which runs crane's
network-free default (bans licenses sources) inside nix flake check, so it
cannot turn the sandboxed check red the way plan.md §7 feared. The one
check that needs the RustSec database, advisories, runs in the Kernel
workflow with network. Licences: an explicit permissive allowlist, trimmed
to what the graph actually contains. All four checks pass.

Refs: #13
S2–S5 are done and tested; S6 is wired and waits on credentials. The
plan now says how each step was built and why (the memory cap by
footprint, not RLIMIT_AS; in-process kernel on macOS because the Quick
Look sandbox forbids exec; buffers over USDZ; the two Quick Look type
traps), closes the open questions those answered, and turns §7 Owed into
the checklist of things only a human can do: approve the org-config
apply, grant the workflow credentials (#3), enable the dependency graph
(#16), the Apple Developer ID and crates.io secrets (#10), corpus
collection (#12), the upstream report (#14).

Refs: #5, #10
@gerchowl gerchowl changed the title feat(cli): S2 — --info, --png with overlay, --glb, cache, timeout and memory cap feat: S2–S6 — CLI, limits, Linux + macOS front-ends, release train Oct 4, 2026
The AppImage failed in CI with 'cannot write uid_map: Operation not
permitted': nix-appimage bind-mounts /nix through an unprivileged user
namespace, and Ubuntu 24.04+ forbids those by default. That is not a CI
quirk; stock Ubuntu desktops refuse it the same way.

scripts/package-linux.sh now ships the binaries, every library they load
and nix's own dynamic loader, started through launcher scripts, so it
needs no FUSE, no namespaces, no root, and not the host's glibc. CI and
the release prove it by unpacking and rendering every test format in
debian:11, ubuntu:22.04, ubuntu:24.04 and fedora:41 containers, none of
which has /nix, so a leftover store dependency cannot hide. NOTICE lists
the C/C++ runtime the tarball now carries.

Refs: #10
The release tarball step failed with 'Permission denied': the file was
committed as 100644. The Python scripts get the same fix for
consistency; they were only ever run via python3.

Refs: #10
The distro-container test ran mkdir /opt, which exists, inside an && chain
that sh -e does not abort on, so nothing was unpacked and the launcher was
"not found". Unpack into a fresh /tmp directory instead. The tarball
itself built fine (29 MB).

Refs: #10
@gerchowl
gerchowl merged commit f1b784b into main Oct 4, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment