Skip to content

feat(macos): run the kernel under an XPC supervisor service in each extension (#64 part 1) - #98

Merged
gerchowl merged 7 commits into
mainfrom
feature/64-xpc-supervisor-1
Oct 13, 2026
Merged

gerchowl merged 7 commits into
mainfrom
feature/64-xpc-supervisor-1

Conversation

@gerchowl

Copy link
Copy Markdown
Contributor

#64 part 1: the XPC supervisor service, bundled and probed

Refs #64. Part 2 switches both extensions onto the service and Closes #64.

What changes

  • StepvSupervisor.xpc in each appex (macos/Supervisor/main.swift, protocol and client in macos/Shared/StepvSupervisor.swift):
    • The service spawns its own Contents/Helpers/stepv-occt /dev/fd/3 --format … --stream --mesh …, with the file's descriptor passed over XPC.
    • It forwards TREE and PROGRESS, then replies with the summary and the mesh, which it hands back as an unlinked file.
    • It kills the kernel when the connection goes (cancel), at the deadline, or past the memory cap.
  • Bundling: each .xpc has its own OCCT closure (31 dylibs, 51 MB). The service's sandbox blocks dyld from opening the app's shared Contents/Frameworks ("file system sandbox blocked open()").
  • Signing:
  • The SVEV reader in Swift (macos/Shared/StepvFrames.swift) has read_events' framing bounds.
  • ql-e2e in the repo (scripts/ql-e2e/, just ql-e2e):
    • Quick Look itself runs the installed extensions (QLThumbnailGenerator, a QLPreviewView host), and their own log lines are the verdict.
    • A sandboxed probe placed in a copy of the built appex drives the real service. test-macos.sh runs the probe too.

Findings on the way

  • fd 3: XPC hands the descriptor over as the lowest free fd, often 3. adddup2(3,3) doesn't survive POSIX_SPAWN_CLOEXEC_DEFAULT, so the kernel's dup(stdout) landed on fd 3 and the read failed with "Illegal seek". The service now moves the descriptor to fd 10 or higher first.
  • Memory cap: proc_pid_rusage on the child is EPERM in the sandbox, so the cap uses PROC_PIDTASKINFO resident size. The trade-off is documented in plan.md.
  • Stale extension processes: an extension process left running from an older install keeps serving Quick Look's requests. ql-e2e refuses to run while one exists.

Tests (sage, macOS 26.4)

  • scripts/test-macos.sh: exit 0.
    • Frames: a real stream in 1-, 7-, 9- and 4096-byte chunks, and every broken stream. Dropping the MAX_FRAME guard or the trailing-bytes check fails the tests.
    • Layout and entitlements are checked.
    • The supervisor probe passes 12 of 12:
      • STEP (TREE first, macos-outer), IGES and BREP;
      • a deadline kill at 1.5 s, reaped in about 8 ms, while a concurrent run finishes in about 65 ms;
      • the next run right after the kill in about 65 ms;
      • the memory cap;
      • cancel (signal 9, reaped about 4.5 ms after the cancel);
      • a refused format;
      • all 8 kernels gone.
  • scripts/ql-e2e/run-all.sh: exit 0, ALL PASS (thumbnail and preview for STEP, IGES and BREP, plus the probe).
  • CI: the new "Quick Look end to end" step tries just ql-e2e in the runner's session. If the runner can't register extensions, it becomes a documented local gate with an issue.
  • No Rust or kernel changes.

gerchowl added a commit that referenced this pull request Oct 13, 2026
#64 part 1)

Review round 2 on #98:
- stepv-occt --lifeline N: the kernel exits when its caller's end of
  pipe N closes, so a service killed mid-run (kill -9, jetsam) takes its
  kernel with it; a pipe, not kqueue on the parent pid: portable, no
  sandbox right needed, no race
- the service refuses unbounded or malformed requests before spawning:
  deadlineMs and memoryMB required and in range (Int.max overflowed and
  crashed the service), linearRel and angularDeg finite and in range
- the read loop drains the pipe to its end after the kernel exits; only
  a stream ending in DONE is a finished run
- leftover meshes are swept when a service starts
- tests: the service killed under a kernel (gone in 16 ms), a 256 MB cap
  on a ~500 MB run, 11 refusals, a stand-in kernel for streams the real
  one never writes on cue (an exit before its frames is deterministic),
  no mesh left in the container; tests/fd.rs for --lifeline
- ql-e2e: a failing line fails the run, the log is polled not slept on,
  an unreadable process start time fails loudly
- plan.md: #101 as a known limit; the CI claim withdrawn

Refs: #64
@gerchowl
gerchowl force-pushed the feature/64-xpc-supervisor-1 branch from c39d8e6 to 48829f2 Compare October 13, 2026 02:02
gerchowl added a commit that referenced this pull request Oct 13, 2026
#64 part 1)

Review round 2 on #98:
- stepv-occt --lifeline N: the kernel exits when its caller's end of
  pipe N closes, so a service killed mid-run (kill -9, jetsam) takes its
  kernel with it; a pipe, not kqueue on the parent pid: portable, no
  sandbox right needed, no race
- the service refuses unbounded or malformed requests before spawning:
  deadlineMs and memoryMB required and in range (Int.max overflowed and
  crashed the service), linearRel and angularDeg finite and in range
- the read loop drains the pipe to its end after the kernel exits; only
  a stream ending in DONE is a finished run
- leftover meshes are swept when a service starts
- tests: the service killed under a kernel (gone in 16 ms), a 256 MB cap
  on a ~500 MB run, 11 refusals, a stand-in kernel for streams the real
  one never writes on cue (an exit before its frames is deterministic),
  no mesh left in the container; tests/fd.rs for --lifeline
- ql-e2e: a failing line fails the run, the log is polled not slept on,
  an unreadable process start time fails loudly
- plan.md: #101 as a known limit; the CI claim withdrawn

Refs: #64
gerchowl added a commit that referenced this pull request Oct 13, 2026
…/N (#102) (#103)

## The kernel reads an input descriptor directly (#102)

Closes #102. Refs #91, #64, #98.

### The bug
#91 passed `/dev/fd/N` as a path and let OCCT's path readers re-open it.
On CI's `macos-15-arm64` runner, the sandbox the kernel inherits from
#64's Quick Look service denies that re-open: `cannot open input:
Operation not permitted` (#98's CI). macOS 26.4 allows it. The root
cause is the re-open by name, so the kernel now reads the open
descriptor and never `open()`s `/dev/fd/N`.

### The choice, per format (probed in OCCT 7.9.3's sources and headers)
- **STEP: A, a stream over the fd.**
- `STEPCAFControl_Reader::ReadStream` for runs,
`STEPControl_Reader::ReadStream` for `--outline`.
- `StepSelect_WorkLibrary::ReadFile` and `ReadStream` both call
`StepFile_Read`. The path version only opens an istream first, so the
parser is identical.
- **BREP: A.**
  - `BRepTools::Read(shape, istream, builder)`.
- The path overload opens an istream and runs the same
`BRepTools_ShapeSet` reads.
- **IGES: B, a private copy.**
- `IGESSelect_WorkLibrary` doesn't override
`IFSelect_WorkLibrary::ReadStream`, whose default returns failure, so
there is no IGES stream reader.
- The kernel copies the fd to `$TMPDIR/stepv-input-XXXXXX.igs` (its real
path, because macOS's `/var` is a symlink) and reads that by path.
- `stepv-occt` makes the copy before its sandbox and grants that one
file.
- The sandbox can't let the kernel remove a file it may read (Landlock
removes through the parent directory). A child forked before the
sandbox, holding only its end of a pipe, unlinks the copy when the pipe
closes. On a normal exit the kernel waits for it, and a killed kernel
still has its copy removed.
- `FdStreamBuf` reads with `pread` from offset 0, so the caller's shared
file offset is no longer moved.
- **Sandbox:** a descriptor input is now granted nothing by path, not
even `/dev/fd/N`.

### Tests
- **New in `tests/fd.rs`:
`the_kernel_reads_its_descriptor_without_reopening_it`.**
- The file is set to mode 000 once open, so re-opening `/dev/fd/N` fails
on macOS (fdesc) and Linux (`/proc/self/fd`) alike.
- Run, `--outline` and `--serve` must equal the path's, for STEP, IGES
and BREP.
- **It fails on the previous kernel** with `cannot open input:
Permission denied`, the macOS 15 failure.
- **New: `the_iges_copy_is_unlinked`.** With a private `$TMPDIR`,
nothing is left after a successful run or a failed one. This test caught
the in-sandbox unlink failing, which the forked remover fixes.
- The #91 tests (`tests/fd.rs`, `tests/sandbox.rs`) are unchanged and
pass.

### Results (sage, macOS 26.4)
- Rust gate (`cargo fmt --check && cargo clippy --all-targets -- -D
warnings && cargo test`): exit 0, 254 passed.
- `just harness --strict --outline --min-pass 95 nist-pmi malformed
tests/data`: exit 0. Outlines: 38 agree, 0 differ.
- `nix build .#checks.aarch64-darwin.nextest`: exit 0, 254 passed, 17
skipped, under nix's own Seatbelt.
- **Corpus diff** of 401 path inputs against the `origin/main` kernel:
exit 0.
- 2 files differed, both copies of one ABC model
(`00000011`/`00000012`). In that run the base kernel left 1 face
missing.
- Re-run 3 times each, base and new are identical (27983 triangles, 0
missing).
- The difference was a timing-dependent heal in the base run, not this
change. Path reads have no code change.
…xtension (#64 part 1)

Each Quick Look extension embeds StepvSupervisor.xpc, with its own
sandboxed stepv-occt (app-sandbox + inherit) and its own copy of the
OCCT closure: the service's sandbox reads its own bundle, not the app's
Frameworks. The service runs the kernel on the file's descriptor
(/dev/fd/3, #91), forwards TREE and PROGRESS, replies with the summary
and the mesh as an unlinked file, and kills the kernel on cancel (the
connection goes), at the deadline or past the memory cap. The Swift
SVEV reader mirrors read_events' bounds.

ql-e2e moves into scripts/ql-e2e (just ql-e2e): Quick Look itself runs
the installed extensions, and a sandboxed probe drives the real service
from a copy of the built extension (also in test-macos.sh, so CI).

The extensions still run the kernel in-process; part 2 switches them.

Refs: #64
- cancel() never aims at a reaped pid: the exit is seen with WNOWAIT and
  the child cleared under the lock before the reap
- a stream that breaks after good frames in one chunk kills the kernel
  at once (StepvFrameReader.failed)
- the cancel path logs the wait status and the time from cancel to reap;
  supervisor.sh requires signal 9, so a kernel that merely finished
  cannot pass for a killed one
- the client resumes a connection before invalidating it
- the probe reads the slow run under its lock; plan.md: the inherited
  descriptors, and the payload checks part 2 owns

Refs: #64
#64 part 1)

Review round 2 on #98:
- stepv-occt --lifeline N: the kernel exits when its caller's end of
  pipe N closes, so a service killed mid-run (kill -9, jetsam) takes its
  kernel with it; a pipe, not kqueue on the parent pid: portable, no
  sandbox right needed, no race
- the service refuses unbounded or malformed requests before spawning:
  deadlineMs and memoryMB required and in range (Int.max overflowed and
  crashed the service), linearRel and angularDeg finite and in range
- the read loop drains the pipe to its end after the kernel exits; only
  a stream ending in DONE is a finished run
- leftover meshes are swept when a service starts
- tests: the service killed under a kernel (gone in 16 ms), a 256 MB cap
  on a ~500 MB run, 11 refusals, a stand-in kernel for streams the real
  one never writes on cue (an exit before its frames is deterministic),
  no mesh left in the container; tests/fd.rs for --lifeline
- ql-e2e: a failing line fails the run, the log is polled not slept on,
  an unreadable process start time fails loudly
- plan.md: #101 as a known limit; the CI claim withdrawn

Refs: #64
A teardown that kills the kernel's whole job also kills the child that
would have removed its IGES copy (#102), so the service's start-up sweep
removes stepv-input-* as well as stepv-*.msh. supervisor.sh plants a
stale mesh and copy before a fresh service starts and checks neither is
left.

Refs: #64
@gerchowl
gerchowl force-pushed the feature/64-xpc-supervisor-1 branch from 48829f2 to 653ca3e Compare October 13, 2026 05:47
…exit 4 (#64 part 1)

Review round 3 on #98:
- XPC does not order the events against the reply (4 of 200 stand-in
  runs lost the last PROGRESS): the reply carries how many events were
  sent, and StepvSupervisorRun completes only once it has them all.
  STANDIN_ROUNDS=500 scripts/ql-e2e/supervisor.sh: 0 failures
- two client processes start two instances of the service in one
  container, and a sweep by name removed the other's live mesh: each run
  now has its own directory, stepv-run-<uuid>, with a lock created
  locked (O_EXLOCK) and held for the run; the start-up sweep removes only
  directories whose lock it can take. Tested: a planted dead run is
  swept, and a live run finishes with its mesh while a second instance
  sweeps beside it
- the lifeline exit is status 4 (3 is a failure its summary explains),
  in the usage text and tests/fd.rs

Refs: #64
#64 part 1)

Quick Look's thumbnail cache is keyed on the file's inode (measured: a
repeat of a path or a hard link is answered in 7-9 ms without the
extension; a new inode runs it). Each request now gets freshly written
bytes; the thumbnail extension logs its requests at notice level; the
verdict fails a thumbnail with no request line as "QL served a cached
thumbnail; the extension did not run", and one with a request but no
result as such; a failed verdict prints the window's log. run-all.sh
asks for one file twice and requires the second to be caught.

Refs: #64
@gerchowl
gerchowl merged commit bca808e into main Oct 13, 2026
15 of 16 checks passed
@gerchowl
gerchowl deleted the feature/64-xpc-supervisor-1 branch October 13, 2026 07:57
gerchowl added a commit that referenced this pull request Oct 13, 2026
…64 part 2)

Both extensions hand the file to their supervisor service (#98) and
link no kernel: no libstepvocct, no OCCT (otool-checked in
test-macos.sh).

- Thumbnail: one reply with the rendered image; deadline 15 s (QL's
  thumbnail watchdog is reportedly ~20 s), a 17 s backstop for a
  service that cannot reply.
- Preview: the header at once, then the assembly tree and progress as
  they stream, then the scene. handler(nil) once the header and tree are
  on screen; with no tree, on the first mesh or the failure; at the latest
  after 20 s (watchdog ~30 s). The run may take 120 s, and is cancelled
  when the view goes.
- ql-e2e on the real extensions: preview and thumbnail for STEP, IGES and
  BREP, with the handler rule checked from the log; a thumbnail past its
  deadline killed with no survivor, a concurrent request beside it, and
  the next request with no throttle.
- plan.md and CHANGELOG: the design, the deadline values and why, the
  limits (#92, #97, #101, macos-outer).

Refs: #64
gerchowl added a commit that referenced this pull request Nov 8, 2026
…64 part 2)

Both extensions hand the file to their supervisor service (#98) and
link no kernel: no libstepvocct, no OCCT (otool-checked in
test-macos.sh).

- Thumbnail: one reply with the rendered image; deadline 15 s (QL's
  thumbnail watchdog is reportedly ~20 s), a 17 s backstop for a
  service that cannot reply.
- Preview: the header at once, then the assembly tree and progress as
  they stream, then the scene. handler(nil) once the header and tree are
  on screen; with no tree, on the first mesh or the failure; at the latest
  after 20 s (watchdog ~30 s). The run may take 120 s, and is cancelled
  when the view goes.
- ql-e2e on the real extensions: preview and thumbnail for STEP, IGES and
  BREP, with the handler rule checked from the log; a thumbnail past its
  deadline killed with no survivor, a concurrent request beside it, and
  the next request with no throttle.
- plan.md and CHANGELOG: the design, the deadline values and why, the
  limits (#92, #97, #101, macos-outer).

Refs: #64
gerchowl added a commit that referenced this pull request Nov 8, 2026
## Description

Fixes #104. The Viewer (Linux, lavapipe) job's window tests
intermittently failed with `winit EventLoopError … Failed to open
connection to X server`.

**Root cause:** Xvfb was started by `xvfb-run` without `-noreset`. An X
server *resets* whenever its last client disconnects, and a connection
that arrives during the reset is dropped. `scripts/test-window-tests.sh`
runs the 14 window tests in parallel under one `xvfb-run`, and each
`stepv view` is its own short-lived client. When all the running clients
had closed at the same moment that another test's stepv connected,
winit's `XOpenDisplay` failed. The GPU viewer then fell back to software
for the wrong reason, and the test's note assertion
(tests/cache.rs:1034) failed.

**Ruled out:**
- *Start race:* `xvfb-run` starts the command only after Xvfb signals
readiness (SIGUSR1). Each failure was mid-suite, about 21 s in, after
other tests had already connected.
- *Server dying:* the same server served the software fallback in the
same test, which drew and passed.
- *Connection limit:* there are at most 4 clients at once, against
Xvfb's 256.
- *Display shared with another server:* there is one `xvfb-run -a` per
step, run in sequence.
- *#84 watchdog:* it kills the kernel only, never X.

**Occurrences (kernel.yml run history):** 38337928702 (#103),
38362262033 (#98), 38377606897 (main push), 38378915656, 38848855133.
Each time it was the same test and the same error.

## Type of Change

- [x] `fix` -- Bug fix
- [x] `ci` -- CI/CD pipeline changes

## Changes Made

- `scripts/test-linux-viewer.sh`: one `xvfb <size> <cmd>` helper,
`xvfb-run -a -s "-screen 0 <size>x24 -noreset"`, used for all three Xvfb
steps (window tests, `test-viewer.sh`, no-GPU fallback). There are no
sleeps, retries or skips.

## Demonstration

These ran on Linux x86_64 (vm-dev), in CI's own container
(`test-linux-viewer.sh`'s Debian trixie image and env). stepv was built
once, then CI's window-test step was looped: `xvfb-run -a -s "<args>"
scripts/test-window-tests.sh -q --release`.

| Xvfb args | runs | pass | X-server failures |
|---|---|---|---|
| `-screen 0 1600x1000x24` (main) | 40 | 39 | **1**: run 38,
`a_gpu_that_refuses_the_pipelines_falls_back_to_software`, `Failed to
open connection to X server`, tests/cache.rs:1034, the same failure as
CI |
| `… -noreset` (this PR) | 120 | 118 | **0** |

Neither of the 2 non-X failures after the fix was an X error.
- One was observed as `Text file busy (os error 26)`
(`closing_the_viewer_mid_load_cancels_the_kernel`, tests/cache.rs:992),
from the tests' `script()` helper. That race has a different root cause
and is filed as #117.
- The other (`a_viewer_with_no_cache_leaves_no_artifact`,
tests/cache.rs:862) failed on an exit-code/status mismatch, but its
output wasn't kept. It is only **inferred** to be the same ETXTBSY race,
because that test also execs a `script()` kernel.

**The reset, deterministically:** one client sets a root-window property
and disconnects, then a new client reads it back.
- Default: `STEPV_104: no such atom on any window.` The server reset
when its only client left.
- `-noreset`: `STEPV_104(STRING) = "still-here"`.

**Connections dropped during a reset:** 3 workers each opening and
closing `xdpyinfo` in a loop, 5 × 3000 connections. With the default
server, 3 were refused (`unable to open display ":99"`); with
`-noreset`, 0.

The Viewer (Linux, lavapipe) job passed on this PR.

## Changelog Entry

### Fixed
- **The Linux viewer job's Xvfb no longer drops a window test's
connection** ([#104](#104)):
- Each Xvfb runs with `-noreset`. An X server resets when its last
client disconnects and drops a connection that arrives during the reset.
The window tests run in parallel, so one could connect just then and
fail with `Failed to open connection to X server`

Refs: #104
gerchowl added a commit that referenced this pull request Nov 8, 2026
…64 part 2)

Both extensions hand the file to their supervisor service (#98) and
link no kernel: no libstepvocct, no OCCT (otool-checked in
test-macos.sh).

- Thumbnail: one reply with the rendered image; deadline 15 s (QL's
  thumbnail watchdog is reportedly ~20 s), a 17 s backstop for a
  service that cannot reply.
- Preview: the header at once, then the assembly tree and progress as
  they stream, then the scene. handler(nil) once the header and tree are
  on screen; with no tree, on the first mesh or the failure; at the latest
  after 20 s (watchdog ~30 s). The run may take 120 s, and is cancelled
  when the view goes.
- ql-e2e on the real extensions: preview and thumbnail for STEP, IGES and
  BREP, with the handler rule checked from the log; a thumbnail past its
  deadline killed with no survivor, a concurrent request beside it, and
  the next request with no throttle.
- plan.md and CHANGELOG: the design, the deadline values and why, the
  limits (#92, #97, #101, macos-outer).

Refs: #64
gerchowl added a commit that referenced this pull request Nov 8, 2026
…64 part 2)

Both extensions hand the file to their supervisor service (#98) and
link no kernel: no libstepvocct, no OCCT (otool-checked in
test-macos.sh).

- Thumbnail: one reply with the rendered image; deadline 15 s (QL's
  thumbnail watchdog is reportedly ~20 s), a 17 s backstop for a
  service that cannot reply.
- Preview: the header at once, then the assembly tree and progress as
  they stream, then the scene. handler(nil) once the header and tree are
  on screen; with no tree, on the first mesh or the failure; at the latest
  after 20 s (watchdog ~30 s). The run may take 120 s, and is cancelled
  when the view goes.
- ql-e2e on the real extensions: preview and thumbnail for STEP, IGES and
  BREP, with the handler rule checked from the log; a thumbnail past its
  deadline killed with no survivor, a concurrent request beside it, and
  the next request with no throttle.
- plan.md and CHANGELOG: the design, the deadline values and why, the
  limits (#92, #97, #101, macos-outer).

Refs: #64
gerchowl added a commit that referenced this pull request Nov 8, 2026
…64 part 2) (#107)

## #64 part 2: the Quick Look extensions run the kernel out of process

Closes #64. Builds on #98 (part 1: the supervisor service), #103 (the
kernel reads its descriptor directly) and #91.

### What changes
- **No kernel in the extensions.** They link `libstepv_capi.a` only (the
renderer and header reader). `otool -L` shows no libstepvocct and no
OCCT, and `scripts/test-macos.sh` now checks that. The app's
`Frameworks/` serves the CLI's kernel alone.
- **Thumbnail:**
- The fd goes to the service, which runs the kernel; the extension
replies once with the rendered image.
- **Deadline 15 s**, enforced by the service, plus a 17 s backstop in
the extension. Quick Look's thumbnail watchdog is reportedly about 20 s,
and a thumbnail has nothing to show partway, so the kernel gets 15 s and
the render and reply get the rest.
- **Preview:**
- The header shows at once, then the assembly tree (the outline,
indented, at most 14 lines) and live progress, then the scene.
- **`handler(nil)`:** once the header and tree are on screen. With no
tree (IGES, BREP, a failed or oversized outline), on the first mesh or
the failure. At the latest **after 20 s** (the watchdog is about 30 s;
10 s of margin).
- The view lives on, so the run may take up to **120 s** (the 42 s
Ultimaker assembly loads). The run is cancelled when the view goes away.
- **Memory cap:** 4096 MB in both, the CLI's default.

### ql-e2e on the real extensions (`just ql-e2e`)
Every check reads #113's single `log stream` and matches by identity,
never by time:
- Each extension logs which run of which service took its file:
`accepted: run #N (service pid P), thumbnail|preview <path>`.
`scripts/ql-e2e/runs.py` reads that run's own lines and judges by stream
order alone. `runs_test.py` checks each verdict on made-up streams
first, with a pid-prefix decoy among them.
- A preview and a thumbnail for STEP, IGES and BREP. Each preview must
be ready exactly once: on its tree before the scene for STEP, on its
mesh for IGES and BREP.
- A 4000-part file is thumbnailed past its 15 s deadline, with
`box.brep` beside it.
- At L ≥ 2, box.brep's run is never queued and exits before the held
run's kill.
- At L = 1, box.brep's run is queued and spawns only after that kill, if
at all.
- Then the held run's `killed (deadline)`, no thumbnail, its kernel
gone, and the next thumbnail under 3 s.
- **Closed preview:** the host closes on a signal sent once the file's
ready line is in the stream, never at a set time. It logs its close and
its quit 3 s later. The kernel's SIGKILL cancel must fall between the
two, be reaped within 1 s, and be gone.
- **Closed before ready:** Quick Look keeps the controller until its
handler is called, so the kernel is cancelled at the preview's ready (20
s at the latest), not at the close (#122). The case closes on the
kernel's spawn. The close must come before the ready line, and the
cancel after it, before the quit.
- **Switched preview:** the host switches the view to `box.brep` once
the file is ready. The old kernel must be cancelled between the switch
and the quit, and box.brep must be shown.
- Quick Look makes a new controller per item; this was measured again:
no controller is prepared twice.
- For a closed or switched preview, no result line may follow for the
file that went, and its handler must complete exactly once.
- **A cancelled session** (closed, or superseded by a second prepare:
`StepvPreviewSlot`):
  - Its kernel is killed.
- Nothing of it reaches the view: a late tree, progress, result, ready
or decode is dropped and logged `stale, dropped`.
- Quick Look's handler completes exactly once: `nil` when ready,
`CocoaError(.userCancelled)` if cancelled first. It is then released,
because it retains the controller.
- The supervisor probe and the cache control are unchanged from main.

### Results (head 08eb056; sage, macOS 26.4; rebased on main after #113,
#81, #116 and #119)
- `just macos-test`: exit 0. That includes the preview-session unit
tests, the linkage check and the supervisor probe.
- **Linkage check fails closed:** it requires a Mach header and at least
one `(compatibility version` line. A text file fails it, and so does
`/nonexistent`. The old check passed a text file, because `otool -L`
exits 0 on one.
- `just ql-e2e` on the product build (L = 4): exit 0, **ALL PASS**.
  - Deadline: killed at 15 023 ms, reaped in 22.4 ms, gone.
  - Concurrent: box.brep was never queued and exited before the kill.
  - No throttle: 112 ms.
  - Closed: cancelled between the close and the quit, reaped in 17.7 ms.
  - Switched: the same, reaped in 18.7 ms.
- **The same run on an L = 1 test build** (CI's 7 GB case): exit 0, ALL
PASS. box.brep was queued and spawned after huge.step's kill (killed at
15 031 ms).
- **Without the `deinit` cancel** (mutant): FAILURES. The closed and the
switched preview were each cancelled only after the host quit.
- **Controller reuse** (round 6, `PreviewSessionTests`): A's result
arrives and its decode is still running when B supersedes it.
- Passes: A shows nothing and its handler completes once, cancelled. B
is ready on its own result, and its handler completes once.
- Without the liveness check: exit 1. A's result is shown, and it marks
B ready.
- Without the handler's release: exit 1. In ql-e2e the closed and the
switched previews were then cancelled only at the quit.
- cbbe55e's macos-15 CI was red: the closed preview was cancelled only
at the quit. The tree had not come by the fixed 8 s close, and the
controller lives until its handler is called. Closes and switches are
now ordered on the logged ready (08eb056).
- Round 6 on 08eb056: `just macos-test` exit 0, `just ql-e2e` exit 0,
ALL PASS. Closed before ready: ready (tree) at 4.47 s, then the cancel,
reaped in 15.9 ms.
- Nits filed: #120 (`.p21`), #121 (a mesh decode error is reported as
"no geometry"). Design question: #122 (call the handler sooner?).
- `scripts/ql-e2e/supervisor.sh`: exit 0. `cargo fmt --check`: exit 0.
`cargo clippy --all-targets -- -D warnings`: exit 0. No kernel change.

### Known limits
- #92: multi-file assemblies.
- #97: Developer ID and the hardened runtime.
- #101: three OCCT copies, +117 MB.
- `macos-outer`: the kernel's own Seatbelt profile can't nest inside the
service's sandbox.
- The watchdog figures are reports, not documented values. The reasoning
is in `macos/Shared/StepvKernel.swift` and plan.md.
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.

1 participant