Skip to content

cvcGL: belief/fog raster bridge for realtime nav-stats viz (Track 3b-2) - #426

Merged
transfix merged 2 commits into
masterfrom
feat/nav-stats-rasters
Sep 26, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/nav-stats-rasters

Conversation

@transfix

@transfix transfix commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Stacked on Track 3b-1 (#425, merged). Adds the belief/fog raster bridge so a realtime viewer (ImGui panel / cvcGL UI DSL / VolRover3) can render the nav belief planes live — the piece the user flagged: "make sure the rasters are stored in the state tree in an efficient way because we will likely be visualizing them in realtime."

What

cvc::gl::publish_nav_rasters(app, pub, prefix, dims, truth, belief, everseen, lastvis, versions, st):

  • Wraps each [rows*cols] uint8 plane as a z=1 cvc::volume stored on the state node's data() lane (the handle lane VolumeNode renders) — the raw-ptr ctor deep-copies once into a boost::shared_array, so the source rasters may be freed/reused and re-publishing a plane refcount-drops the old buffer.
  • Version-gated (nav_raster_pub_state, one per scene): an unchanged plane skips the deep wrap entirely — only planes whose sim_world::plane_version(m) changed are re-wrapped. Truth is published once. This is the "efficient" path for realtime.
  • Paired .version + .dims scalars go on the coalesced value lane through the state_publisher.
  • sim_world::plane_version(int m) accessor added (out-of-range → -1).

Same-process only (the data() lane doesn't cross a process boundary; a remote viewer opts into brick escalation behind the identical version/dims).

Review (adversarial, pre-merge) — 4 defects found + fixed

  1. Consumer UAF: VolumeNode::onDataChanged bound a const volume& into the boost::any that state::data() returns by value → dangles at the semicolon. This raster bridge is its first real producer; fixed by copying out by value (data<cvc::volume>()).
  2. LLP64 overflow: long plane offset truncates on Windows → widened to size_t.
  3. Sentinel collision: "never published" -1 clashed with plane_version()'s out-of-range -1 → now INT_MIN.
  4. nullptr-versions freeze: captured once then froze → now un-gated (always fresh) when versions==nullptr.

Test

cvcgl_nav_stats_publish extended: dims/version scalars, data<cvc::volume>() holds the z=1 volume with round-tripped voxels, version-gate skips an unchanged plane, and a nullptr-versions no-freeze case (mutate source between calls, assert the stored volume tracks it). Local: cvcgl_nav_stats_publish: OK.

Additive / off nothing: no existing behavior changes. Next: downstream extension-layer publisher + app wiring (Track 3b-3).

Add publish_nav_rasters() to cvc::gl::nav_stats_publish + sim_world::plane_version(m).
Publishes the belief/fog rasters into <prefix>.nav_stats.rasters.* for realtime
visualization (the cvcdbg#127 raster design): each plane's truth/belief/ever_seen/
last_visible is wrapped as a z=1 cvc::volume and stored on the node's data() lane
(a shallow-share handle VolumeNode renders directly), with paired .version + .dims
scalars on the value lane. The cvc::volume raw-pointer ctor deep-copies the raster
ONCE per publish (an immutable snapshot); the handoff is then a refcount bump.
Version-gated by sim_world's per-plane version_[m] (new plane_version accessor) so an
unchanged plane skips the deep wrap; truth is static (published once). Same-process
only (the data() lane doesn't cross a process boundary — a remote viewer escalates
to the brick path behind the identical version/dims contract).

Storing a cvc::volume VALUE (not shared_ptr<const volume>) matches VolumeNode's
onDataChanged as-is (no VolumeNode change) and is cheap because voxels/volume are
shallow-copy (boost::shared_array). Test extended: dims + version scalars, the data()
lane holds a cvc::volume with z=1 dims + round-tripped voxels, and the version gate
skips an unchanged plane while re-publishing a bumped one.
…tr (3b-2 review)

Adversarial review of the raster bridge surfaced four defects; all fixed + a
regression test added:

- VolumeNode::onDataChanged bound a reference into the boost::any returned BY
  VALUE from state::data() -> use-after-free the moment the raster feature (its
  first real producer) wires a VolumeNode to a data-lane plane. Copy the volume
  out by value via data<cvc::volume>() (a cheap shared_array bump).
- publish_nav_rasters used `long` for cells / plane offset -> truncates on LLP64
  (Windows long is 32-bit); a fog-of-war twin with O(N) planes over a large grid
  would wrap the offset and read OOB. Widened to std::size_t (matches the int64
  discipline already used for i2s).
- The per-plane "never published" sentinel was -1, colliding with
  sim_world::plane_version()'s out-of-range -1 -> a -1 version was frozen out
  forever. Sentinel is now INT_MIN, so a -1 still publishes once.
- versions == nullptr captured each plane once then froze the fog (0 == 0 skip).
  Now un-gated when versions is null: every plane re-publishes each call.

Test adds a nullptr-versions no-freeze case (mutate source between calls, assert
the stored volume tracks it). Local cvcgl_nav_stats_publish: OK.
@transfix
transfix merged commit f68118c into master Sep 26, 2026
13 checks passed
@transfix
transfix deleted the feat/nav-stats-rasters branch September 26, 2026 05:19
transfix added a commit that referenced this pull request Sep 26, 2026
…b-3 PRs open (#427)

Reflect actual state: Track 1 (a-d) MERGED (#421-#424), Track 2 MERGED (GRL-SNAM#96),
Track 3a MERGED (cvcdbg#128/#129), Track 3b-1 MERGED (#425). Track 3b-2 (raster bridge,
#426) + Track 3b-3 (RF publisher + demo3 wiring, cvcdbg#130) PRs open in CI. Document the
3b split (3b-1 base/formation, 3b-2 version-gated volume rasters, 3b-3 RF+demo) and the
Track-4 reserved RF fields (composite_score / cvar_jam_loss / worst_jam_loss).
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