Skip to content

fix(volume): writeVolumeFile(app, vol, filename) creates a missing target - #111

Merged
transfix merged 1 commit into
masterfrom
feat/writevolumefile-create-missing
Jul 20, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/writevolumefile-create-missing

Conversation

@transfix

Copy link
Copy Markdown
Owner

Summary

Hardens libcvc's low-level volume write so the natural single-volume call is robust for every SDK consumer, not just callers who know to create the file first.

writeVolumeFile(app, vol, filename) (the var=0…off=0 overload) writes into an already-existing file — it's the chunk/offset path. For a not-yet-created target the format handler fails to open the missing file, and the error is re-wrapped as unsupported_volume_file_type. That is the exact footgun that made pycvc's Volume.save('x.rawiv') look like a missing-handler problem (see #110) — the handler was registered all along.

Change

When the caller writes a whole volume (default offset/var/time) to a path that does not exist yet, create the file first from the volume's own metadata (bounding_box / voxel_dimensions / voxelType), then fall through to fill it in — mirroring what volume::write() and the std::vector<volume> overload already do. This is idempotent with those callers (the file exists by the time the single-volume path runs, so it is not re-created).

Partial writes (nonzero offset/var/time) are unchanged: they still require createVolumeFile() up front, since a single chunk does not describe the full target geometry.

Why this layer

Centralizing in the free function means all formats benefit (rawiv, rawv, mrc, spider, cvc/hdf5). Consumers (pycvc, volrover3, the planned lab .rawiv/.mrc loaders) get a valid file from the obvious call instead of a cryptic exception.

Tests

volume_io_test:

  • WriteVolumeFileCreatesMissingFile — the single-volume overload creates + round-trips a fresh .rawiv.
  • WriteVolumeFileUnknownExtensionStillThrows — an unknown extension still throws (create path validates the extension).

Verified locally: ctest -R VolumeIOTest → 25/25 pass (Debug, shared libcvc).

Note on CI

package-{macos,windows} are red on master already (pre-existing): gtest_discover_tests runs app_test at build time and it can't load libgmpxx.4.dylib from an ephemeral cvcpkg temp-install rpath. That failure is unrelated to this change; the Linux build+test and clang-format checks are the relevant ones here.

…rget

The single-volume writeVolumeFile overload writes *into* an already-existing
file (the chunk/offset path). For a not-yet-created target the format handler
fails to open the missing file, and the error surfaces (misleadingly) as
unsupported_volume_file_type — the footgun that made pycvc's Volume.save()
appear to be a missing-handler problem.

Create the file first from the volume's own metadata when the caller is
writing a whole volume (default offset/var/time) to a path that does not
exist yet, mirroring what volume::write() and the std::vector<volume>
overload already do. This makes the low-level call robust for every SDK
consumer (pycvc, volrover3, the planned lab .rawiv/.mrc loaders). Partial
writes (nonzero offset/var/time) still require createVolumeFile() up front,
since a single chunk does not describe the full target geometry.

Add volume_io_test coverage: the single-volume overload creates+round-trips
a fresh .rawiv, and still throws on an unknown extension.
@transfix
transfix merged commit 6c4395d into master Jul 20, 2026
4 of 8 checks passed
@transfix
transfix deleted the feat/writevolumefile-create-missing branch July 20, 2026 22:12
transfix added a commit that referenced this pull request Aug 11, 2026
Draft of the recipe-first CI path: build libcvc from its in-tree cvcpkg
recipe (recipes/libcvc) instead of apt + cvc-requirements.yaml + hand-written
cmake. The same `cvcpkg build libcvc --recipes-dir recipes` a developer runs
locally is what CI runs, with cvcpkg as the sole source of third-party deps on
every platform. Includes a find_package(cvc CONFIG) smoke test that writes and
reads back a .rawiv (exercising the #111 write path end to end).

Gated on workflow_dispatch (not PRs) until the closure is published to the
cvcpkg catalog — libxml2 and the ImageMagick delegates need published bundles
per platform (or --fallback-to-source), and Windows needs bundles published at
all. Publishing is blocked on the cvcpkg token rotation. Once unblocked, flip
the trigger to pull_request/push and retire the matching ci.yml jobs.
transfix added a commit that referenced this pull request Sep 26, 2026
A second, non-ImGui backend that renders the SAME cvc::ariadne Widget tree on a
terminal — no ImGui, no VTK, no GL. This is what the §16 Backend seam existed to
support, now demonstrated end to end.

- inc/cvc/ariadne/ftxui_backend.h + src/cvc/ariadne/ftxui_backend.cpp — FtxuiBackend
  : cvc::ariadne::Backend, in libcvc core (a terminal lib, no graphics deps). Bridges
  the paradigm gap: FTXUI is a functional/reactive DOM, so the immediate-mode walk
  accumulates an FTXUI Element tree via a container stack (windows -> ftxui::window,
  menubar -> hbox, sliders -> gauges, checkbox -> [x]/[ ], combo -> < option >).
  render_to_string() rasterizes headless (no TTY — for tests/SSH/CI); run() drives
  FTXUI ScreenInteractive. capabilities().owns_loop == TRUE — the framework-owned-loop
  counterpart to the ImGui backend owns_loop == false, so the seam now carries BOTH
  drive models. fx:: alias (not using-namespace) so FTXUI text()/window()/separator()
  are never shadowed by the same-named cvc::ariadne widget builders.
- src/cvc/CMakeLists.txt — OPTIONAL, like the yaml loader: find_package(ftxui) present
  -> real backend (CVC_ARIADNE_FTXUI) + link ftxui::component/dom/screen; absent -> a
  stub (available()==false), so libcvc still builds. FTXUI pulls in no VTK/GL/ImGui.

Verified end to end against real FTXUI 7.0.3: ftxui_backend.cpp compiles both ways
(stub + real); a full libcvc.so build links it; and a harness mounting a programmatic
tree on Runtime + FtxuiBackend renders LIVE cvc::state (agents=128 as a gauge, speed=2.50,
wireframe [x], belief=<grouped>) to a terminal string. The recipes it needs are cy-pca/
cvcpkg PR #111 (ftxui + nlohmann-json + json-schema-validator + tvision).
transfix added a commit that referenced this pull request Sep 26, 2026
Wires json-schema-validator (over nlohmann-json) into the loader for structural
validation, completing the 3-layer story (yaml parse -> JSON Schema -> semantic).

- inc/cvc/ariadne/loader.h + loader.cpp: a permissive draft-2020-12 schema for .ari
  (kAriSchema) enforcing the meta block (min_libcvc required) and widget FIELD types
  (bind string, lo/hi numbers, options string[], pos/size number[], ...) while leaving
  the type-key and forward-compat keys unconstrained. Exposed via ari_schema_json()
  (for editors / `ari validate`) regardless of whether the validator is linked;
  have_jsonschema() reports the runtime capability.
- When json-schema-validator is present, load_* convert the yaml-cpp doc to
  nlohmann::json (yaml_to_json: scalars coerced to int/double/bool where the whole
  token parses, else string) and validate against the schema, adding violations to
  LoadResult.warnings ("ari: schema: <ptr>: <msg>"). Advisory (the min_libcvc gate is
  the only fatal provenance check) so the lenient loader still loads what it can.
- src/cvc/CMakeLists.txt: OPTIONAL, find_package(nlohmann_json_schema_validator) ->
  CVC_ARIADNE_HAVE_JSONSCHEMA + link (its config find_dependency(nlohmann_json)); absent
  -> the schema is still exposed but no runtime validation runs.

Verified against the real validator (json-schema-validator 2.4.0 + nlohmann-json 3.12.0):
hello.ari -> 0 schema warnings; a doc with lo:"not-a-number" and no meta.min_libcvc ->
exactly two precise warnings (/meta required min_libcvc; /windows/0/children/0/lo type).
Also compiles with the validator absent and with yaml absent (stubs). The recipes it
needs are cy-pca/cvcpkg #111 (nlohmann-json + json-schema-validator).
transfix added a commit that referenced this pull request Sep 26, 2026
…libcvc

Closes the loop now that the four Ariadne deps are published (cy-pca/cvcpkg #111,
merged): wire the three new ones into libcvc so the Layer-2 JSON-Schema validation
and the FTXUI terminal backend compile their REAL paths in real/published libcvc
builds, not just a local prefix.

- cvcpkg/recipes/libcvc/recipe.yaml: add nlohmann-json + json-schema-validator +
  ftxui to depends.runtime (alongside the already-added yaml-cpp). SCOPED to linux
  for now — the three are published for linux-x86_64 only so far; drop the scoping
  once the macos/windows/BSD variants are published. All remain OPTIONAL in CMake
  (find_package; absent -> stubs), so a minimal libcvc still builds.
- .github/workflows/ci.yml: install all four alongside vtk for the libcvc matrix,
  so CI exercises Layer-2 + the FTXUI backend (real paths, not stubs).

Verified end to end against the LIVE catalog: cvcpkg install yaml-cpp nlohmann-json
json-schema-validator ftxui pulls all four from cvcpkg.org (ftxui 7.0.3+cvc.1,
json-schema-validator 2.4.0+cvc.1, nlohmann-json 3.12.0+cvc.1, yaml-cpp 0.8.0+cvc.5),
and configuring libcvc against that prefix reports all three Ariadne features ENABLED
(loader, FTXUI backend, Layer-2 validation).
transfix added a commit that referenced this pull request Oct 20, 2026
…hed libcvc (#720)

* Ariadne terminal backends on macOS and Windows: libcvc recipe deps, tvision on WIN32

The libcvc recipe scoped ftxui (and the .ari Layer-2 schema deps) to linux, so
every macOS and Windows libcvc, and the macOS / Windows CI lanes, built the stub
terminal backend; the AriadneFtxui tests reported Skipped there. ftxui,
nlohmann-json and json-schema-validator are published for linux, macOS (arm64,
x86_64) and windows, so declare them there.

tvision was in no published libcvc. Add it as a build dep (a static archive,
linked PRIVATE and BUILD_INTERFACE-only) on linux, macos and windows, and
ncurses as a runtime dep on linux and macos (libncursesw + the terminfo
database). The Windows tvision (cy-pca/cvcpkg#414, tvision cvc.3) draws through
the Win32 console, so src/cvc/CMakeLists.txt skips the ncursesw lookup on WIN32.
Under MSVC tvision_backend.cpp gets the flags tvision's config makes PUBLIC:
without /Zc:__cplusplus, tvision/ttypes.h #defines constexpr, noexcept and
thread_local away.

Also drops the stale #111 notes in ci.yml and the tvision test.

* ariadne(tvision): find the bundled terminfo database from libcvc itself

ari pointed ncurses at <prefix>/share/terminfo from its own executable path, and
only on Linux. Other hosts (arigl, cvcGL's ariadne_terminal) did not, and the
cvcpkg ncurses bundle's compiled-in search path names the builder's /tmp prefix.

TvisionBackend::run now does it before tvision starts ncurses: dladdr locates
libcvc's own library, and TERMINFO_DIRS becomes <libdir>/../share/terminfo: when
it is unset and that directory exists. Every host gets it, on Linux, macOS and
the BSDs. ari's behaviour is unchanged (same rule, same prefix in a cvcpkg
install); its copy is removed.

* publish: guard the Ariadne terminal backends; ari for macOS and Windows

publish-cvcpkg.yml tees each libcvc configure and fails the job when it lacks
'Ariadne: .ari YAML loader ENABLED', 'Ariadne: FTXUI terminal backend ENABLED' or
'Ariadne: tvision terminal backend ENABLED', so a stub can no longer ship
silently (like ci.yml's ari-wasm guard).

ari: macos and windows matrix entries, files bin/ari*, and build.ps1 (cvc-cli's
pattern, pointed at src/ari). The workflow gains macOS (bash) and Windows (pwsh)
twins of the Linux ari step, taking cmake and ninja from cvcpkg. Each ari step,
Linux included, now renders the terminal tour with the binary it is about to
pack before packing it.

* ci: fail the package lanes when a terminal backend is a stub

Without ftxui or tvision the Ariadne terminal backends compile to stubs and the
AriadneFtxui / AriadneTvision tests skip rather than fail, which is how the
macOS and Windows lanes ran them until now. Tee each package-* configure and
fail when it lacks 'Ariadne: FTXUI terminal backend ENABLED' or 'Ariadne:
tvision terminal backend ENABLED'.

* ari: keep the main.cpp change to deleting use_bundled_terminfo

Leaves the __linux__ includes and the call site's surroundings as they were, so
this merges cleanly with the arigl branch's rewrite of ari's argument parsing.
Whichever lands second drops the now-unused includes.

* cvc: scope FTXUI's interface compile options to C++

The Windows ftxui export puts /utf-8 in the INTERFACE_COMPILE_OPTIONS of
ftxui::screen, ::dom and ::component. Linked into cvc, it reached the CUDA
sources too, and nvcc took the bare /utf-8 for a second input file: "nvcc
fatal : A single input file is required for a non-link phase when an
outputfile is specified" (package-windows / libcvc-release-grpc-static).
Wrap each of FTXUI's options in $<$<COMPILE_LANGUAGE:CXX>:...>, as cvc already
does for -openmp:llvm.
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