Repository navigation
vslam: reimplement the visual front end (C28) - #136
Conversation
Authored fresh against the private reference's interface: same package name, cuda feature, environment keys, shared-memory slots and log records. The front end keeps its pose-sharing discipline (publish only while nobody else has, yield to an external writer, re-acquire by deadline), scores every shift match, and publishes VslamFrontendState plus an owned NavPose. Kernels are restructured around named constants, an ImageGrid descriptor and small helpers so the code reads as this crate's own work. tests/frontend.rs covers the published bytes, the deadline hand-off and the match/integration maths; tests/binary.rs runs the shipped binary against a real region and reads its log.
Reviewer Worktree HEAD Scope
+1574 / -1, every path under Package name and
|
| constant | value | ref line | new line |
|---|---|---|---|
DEFAULT_POLL_MS |
33 |
7 | 43 |
KEYFRAME_TRANSLATION_PROXY |
0.06 |
8 | 46 |
FLOOR_CELL_M |
0.4 |
9 | 48 |
VSLAM_POSE_STALE_NS |
500_000_000 |
10 | 50 |
MAX_FLOOR_SHIFT_CELLS |
3 |
11 | 52 |
MAX_THUMB_SHIFT_PX |
6 |
12 | 54 |
MAX_THUMB_SHIFT_Y_PX |
4 |
13 | 56 |
YAW_RAD_PER_PX |
0.010 |
14 | 58 |
MAX_STEP_M |
FLOOR_CELL_M * 2.0 |
15 | 60 |
MAX_YAW_STEP_RAD |
0.20 |
16 | 62 |
Values the reference inlined are now named constants and agree: snapshot(8) ref:93 / SNAPSHOT_ATTEMPTS = 8 lib:65; pose_confidence >= 0.55 ref:268 / TRACKING_OK_THRESHOLD = 0.55 lib:73; zero.samples < 64 ref:387 / MIN_MATCH_SAMPLES = 64 lib:75; zero.samples / 2 ref:401 / MIN_SAMPLE_FRACTION = 2 lib:77; 0.001 ref:413 / MIN_ERROR_FLOOR lib:79; 900.0 / 0.18 / 0.12 / 0.20 / 0.45 / 0.20 / 0.15 ref:586-589 / lib:83-91; 0.25, 0.15, 0.15 ref:209-217 / lib:67-71; keyframe evidence 0.18 and 0.04 ref:243-244 stay inline in both; same_pose(..., 0.05, 0.05) ref:337 / lib:322.
Env keys
Reference reads exactly four (git grep -n "env::var\|env_flag" -- runners/vslam/src/main.rs, lines 55-61): QUALIA_SHM_NAME (default /qualia_body), QUALIA_VSLAM_POLL_MS (default 33), QUALIA_VSLAM_PUBLISH_POSE (default true), QUALIA_VSLAM_FORCE_POSE (default false). The new ENV_* / DEFAULT_* constants (lib.rs:32-43) carry the same names and defaults, and flag() (lib.rs:265-272) keeps both truth tables — true-set 1|true|TRUE|yes|YES, false-set 0|false|FALSE|no|NO. guard-pinkie-v2-observe.sh:315 sets QUALIA_VSLAM_PUBLISH_POSE=false on a qualia-vslam process; that spelling is accepted.
Published SHM layout
Neither crates/types nor crates/shm is touched by the diff and the layouts agree with the reference: sed -n '/^pub struct VslamFrontendState/,/^}/p' crates/types/src/lib.rs extracts 22 identical lines from both repositories (only CRLF vs LF differs), NavPose extracts 11 identical lines, and the crates/shm/src/lib.rs offset chain is the same expression sequence in both (LAYER_SLOTS_OFFSET … BINARY_MAP_OFFSET -> CAMERA_FRAME_OFFSET -> CAMERA_PREVIEW_OFFSET -> VSLAM_FRONTEND_OFFSET -> CAMERA_FLOOR_OFFSET).
Every mutable field of the slot is written each tracked frame (lib.rs:586-606) and zeroed at start-up (lib.rs:417-443), field for field identical to the reference's blocks (ref:250-270 and ref:303-320), including the seq read-then-wrapping_add(1) store and the fact that seq is the last store after tracking_ok. pose_writer_active is still 0/1 (u8::from(wrote_pose) == if wrote_pose { 1 } else { 0 }), loop_closure_count still 0, feature_count still usize as u32.
Pose hand-off
PosePublisher::publish_if_needed (lib.rs:305-346) reproduces ref:323-370 exactly: force -> publish; while established -> yield when current.timestamp_ns > last_write_ns && !same_pose(current, pose, 0.05, 0.05); otherwise publish when timestamp_ns == 0 || confidence <= 0.05 || timestamp_ns.saturating_sub(current.timestamp_ns) > VSLAM_POSE_STALE_NS (strictly greater — the 500 ms boundary is exclusive in both). The written NavPose carries x_m, z_m, yaw_rad, confidence, timestamp_ns and zero-fills y_m, pitch_rad, roll_rad, _pad0 via LEVEL_POSE (lib.rs:101-113), matching the reference literal at ref:352-362.
Log records and exit code
All three operator records are byte-identical to the reference (ref:66, ref:73-75, ref:78-82, ref:281-296): the stderr line + exit(1) on a failed attach, the cuda banner, the consuming banner, and the every-thirtieth-frame record. FrameReport::log_line (lib.rs:357-372) keeps the same labels and precisions; the string-literal line continuation does not reach stdout, and tests/frontend.rs:524-527 pins the rendered line. The loop logs the first tracked frame and every 30th after that (lib.rs:657-664), the same cadence as the reference's out_seq == 1 || out_seq % 30 == 0.
Two input deltas, not findings
Stated for completeness, no action requested, verdict unaffected — both are hardening of inputs that neither repository sets:
- An empty
QUALIA_SHM_NAMEfalls back to/qualia_body(lib.rs:236-238); the reference would hand""toShmRegion::openand exit 1.scripts/stack.shcomputesSHM_NAME="${QUALIA_SHM_NAME:-/qualia_body}", so an empty value cannot reach either binary from the stack scripts. QUALIA_VSLAM_POLL_MS=0falls back to 33 ms (lib.rs:240-243); the reference would sleep 0 ms.git grep -n "QUALIA_VSLAM_POLL_MS"over both repositories finds it only inrunners/vslamitself and its own tests ("5","50","not-a-number"); no consumer sets the key.
No mismatch to quote: package name, feature, published state layout, pose bytes, env keys, constants, log records and exit code all match the reference interface, and the diff touches only runners/vslam.
P1 —
Observed here with the shipped command ( Fix is one token — wrap it like the neighbouring term: .wrapping_add((index as u32).wrapping_mul(2_246_822_519));Commands reproduced on worktree
Also checked in the same pass, so a later reviewer can skip re-deriving it:
|
Reviewer Head reviewed$ git -C C:/Users/ericm/wt/C28 fetch origin
$ git -C C:/Users/ericm/wt/C28 rev-parse HEAD
9aa0405f88b92dd5ce25a27fe8edf9108f88b05f
$ gh pr view 136 --repo superposition/qualia --json headRefOid -q .headRefOid
9aa0405f88b92dd5ce25a27fe8edf9108f88b05fHEAD equals the PR head, so this verdict is on $ git -C C:/Users/ericm/wt/C28 status --porcelain
M runners/vslam/tests/binary.rs
$ git rev-parse HEAD:runners/vslam/tests/binary.rs # committed blob I reviewed
6c4c5bbd229a8b176db136790d3d7890b5793e43It is not part of Provenance gateThe required command, run with cwd = the worktree: $ cd C:/Users/ericm/wt/C28 && python C:/Users/ericm/qualia/scripts/provenance_check.py
provenance: compared 112 authored file(s) (1 generated skipped); 0 byte-identical, 5 code runs over 20, 0 prose runs over 2
provenance: highest identical-code-line share 1.000 (.cargo/config.toml)
CODE RUN 40: crates/types/src/lib.rs
CODE RUN 30: crates/sync-types/src/lib.rs
CODE RUN 24: runners/agent/Cargo.toml
CODE RUN 23: crates/jepa-dataset/src/lib.rs
CODE RUN 21: crates/sync-types/src/spatial.rs
provenance: OKThat copy resolves its repository root from its own path ( $ cd C:/Users/ericm/wt/C28 && python C:/Users/ericm/wt/C28/scripts/provenance_check.py
provenance: compared 108 file(s) that also exist in the reference; 0 identical
provenance: OKBecause
Fatal criteria are byte-identical file and prose run > 2; all four pass. Byte identity, EOL-insensitiveEach PR blob compared to every reference file ( Identical code runs near the thresholdWhitespace-normalised, code lines only, against
let floor = shm.camera_floor();
let floor_seq = floor.seq.load(Ordering::Acquire);
let floor_ready = floor_seq != 0
&& floor.width == VOXEL_W as u32
&& floor.height == VOXEL_D as u32
&& floor.last_update_ns != 0;Every token is the published contract: the
pose: &mut LocalPose,
dx_cells: f32,
dz_cells: f32,
yaw_delta_rad: f32,
motion_weight: f32,
) {
pitch_rad: 0.0,
roll_rad: 0.0,
confidence,
_pad0: 0.0,
timestamp_ns,These are constant/field/API declarations, which is exactly the shared-line class the gate reports rather than fails. No run of code reaches 7. Comment/doc proseShared non-trivial comment lines with the reference: Test bodiesThe reference has no test target to mirror: $ git -C C:/qualia ls-files runners/vslam
runners/vslam/Cargo.toml
runners/vslam/README.md
runners/vslam/src/README.md
runners/vslam/src/main.rs
$ grep -n '#\[test\]\|#\[cfg(test)\]\|mod tests' C:/qualia/runners/vslam/src/main.rs
(no match)Statement-level comparison (brace-matched function bodies, code lines only) of the PR's test functions against the reference's 19 functions: maximum overlap 0.636 for Scope$ git -C C:/Users/ericm/wt/C28 diff --name-status $(git -C C:/Users/ericm/wt/C28 merge-base origin/main HEAD)..HEAD
A runners/vslam/src/lib.rs
M runners/vslam/src/main.rs
A runners/vslam/tests/binary.rs
A runners/vslam/tests/frontend.rsOnly the files the ticket names, nothing outside |
P1 fix — let h = (pixel_index as u32)
.wrapping_mul(2_654_435_761)
- .wrapping_add(index as u32 * 2_246_822_519);
+ .wrapping_add((index as u32).wrapping_mul(2_246_822_519));
*pixel = ((h >> 11) & 0xff) as u8;
Reproducer (deterministic)The panic needs a second published frame, which needs the child to lose the first 5 ms start-up race. On this box the unmodified loop passed 0/200 both before and after the fix, so I forced the condition to make the A/B causal instead of racy — Same file:line:column as the verdict's transcript. With the fix the same forced condition no longer panics in Stress and crate state (on
|
Reviewer Head reviewed$ git -C C:/Users/ericm/wt/C28 fetch --all && git -C C:/Users/ericm/wt/C28 rev-parse HEAD
c209a4c1a3e70e211e2ce48a73ebaed6444e7627
$ gh pr view 136 --repo superposition/qualia --json headRefOid -q .headRefOid
c209a4c1a3e70e211e2ce48a73ebaed6444e7627
$ git -C C:/Users/ericm/wt/C28 status --porcelain
(empty)
for (pixel_index, pixel) in thumbnail_luma.iter_mut().enumerate() {
let h = (pixel_index as u32)
.wrapping_mul(2_654_435_761)
- .wrapping_add(index as u32 * 2_246_822_519);
+ .wrapping_add((index as u32).wrapping_mul(2_246_822_519));
*pixel = ((h >> 11) & 0xff) as u8;Head blob P1 — fixed, and causallyIn a scratch copy of the head, with only one added forcing edit in the test loop (
The arithmetic domain is confirmed: Stress and crate state, on the committed head
Provenance gate — the FAIL is inherited base drift, not this diff
None of those paths is in this head's changed set: $ git diff --name-only 75739d4 HEAD
runners/vslam/src/lib.rs
runners/vslam/src/main.rs
runners/vslam/tests/binary.rs
runners/vslam/tests/frontend.rsMeasured with the gate's own
Base and head are identical, so the offending prose is inherited verbatim from this branch's stale base and is already resolved on current Because the merge result is what matters, I checked that tree too — in an isolated exit 0. The code-run warnings there ( One caveat worth knowing for anyone re-running this: the gate's byte-identity check is EOL-sensitive, and Out-of-scope aside, not attributable to this PR: the merges brought in a tracked My earlier contract / clean-room deltas still holdThe change is inside one test helper, so the interface items from my earlier pass are untouched: package |
What changed
runners/vslamwas afn main() {}placeholder. It is now the visual front end,authored fresh against the private reference's interface: the same package name
and
cudafeature, the same four environment keys (QUALIA_SHM_NAME,QUALIA_VSLAM_POLL_MS,QUALIA_VSLAM_PUBLISH_POSE,QUALIA_VSLAM_FORCE_POSE),the same
VslamFrontendStatefields, the same three operator log records, andthe same pose-sharing behaviour:
500 ms) rather than by stomping a write,QUALIA_VSLAM_FORCE_POSEoverrides that hand-off entirely.src/lib.rscarries the implementation andsrc/main.rsis the thin binary(attach, banners, run), so the behaviour is testable without a supervisor.
Tests written first
tests/frontend.rs(16 tests) asserts published bytes and decisions, notwiring: the
VslamFrontendStatesequence/field contract, the pose bytes handedto
WorldModel::robot_pose, the deadline boundary at exactlyVSLAM_POSE_STALE_NS, the external-writer hand-off, the pose-disabled flag, thefloor-translation path (
motion_dx_cells == -2.0for a two-cell shift), and thematch/integration maths (known translation recovery, flat-image abstention,
step clamping and yaw wrap).
tests/binary.rsruns the shipped binary against a region the test creates,publishes frames until the front end reports one, and asserts the child's own
log and the pose it published.
Provenance
Every line is authored here. Against
C:/qualia/runners/vslam/src/main.rs:zero shared comment/doc lines in all four files; similarity 0.244 / 0.074 /
0.068 / 0.028 (gate <= 0.55); longest identical run 6 (gate <= 6), and those
runs are contract-forced: the
shmaccessor/readiness predicate, the publicfunction signature of
integrate_local_pose, and aNavPoseliteral in a testhelper.
scripts/provenance_check.pyreports 0 identical of 108.Closes #94