Skip to content

test(unified): cover the encoder half of the pose factorization - #2537

Open
rudycelekli wants to merge 1 commit into
ruvnet:mainfrom
rudycelekli:test/real-encoder-room-invariance
Open

rudycelekli wants to merge 1 commit into
ruvnet:mainfrom
rudycelekli:test/real-encoder-room-invariance

Conversation

@rudycelekli

Copy link
Copy Markdown

Addresses the first item of #1438 (factorized_pose_resists_room_shortcut_leakage) by adding the coverage it is missing rather than by renaming it.

What the existing test does and does not verify

heads.rs builds its latents by hand:

let content = vec![scale, 1.0];
let full = vec![scale, room_x / 3.0, 1.0];

content simply lacks the room_x column, so the skeleton branch's room-independence is true by construction. The test never calls RfEncoder::encode_content. What it genuinely verifies is FactorizedPoseHead's algebra given a factorized latent — which is worth keeping — not that the encoder produces one. That is the gap.

The missing half

The encoder documents the contract itself:

z = g ⊙ gate + Wg·geo + bg      fused window representation

encode_content returns g ⊙ gate concatenated with the window-mean token features, deliberately without the additive Wg·geo room offset (encoder.rs:294-300: "the additive Wg·geo term is a room-specific offset a linear adapter would memorize").

So two windows differing only in geometry must produce an identical content representation while their fused z differs. The new test asserts exactly that against the real encoder, and it is the complement of the existing stale_windows_are_gated_toward_geometry_prior, which pins that z does move with geometry. Together the two bracket the factorization the pose head relies on.

Why the name is unchanged

#1438 is titled around names that overclaim, so to be explicit: I did not rename factorized_pose_resists_room_shortcut_leakage.

docs/adr/ADR-281-ble-cs-delay-doppler-pose-factorization.md:39 cites it by name, and that ADR already states the scope correctly — "on a toy that isolates the mechanism. MEASURED-CODE for the mechanism; not a pose-accuracy claim." Renaming would break an accepted ADR's reference in order to describe something the ADR already describes accurately. Instead the test's own doc comment now records that its latents are synthetic and points at the new encoder test. Happy to rename and update ADR-281 in the same PR if you would rather have the name changed.

This also leaves items 2 and 3 of #1438 (empty_map_returns_exact_friis, inverse_update_learns_a_wall_from_link_residuals) alone — PR #2326 covers those two in gaussian/gain.rs.

Validation

Rust 1.89.0, at ce8d296c:

cargo test -p ruview-unified --no-default-features
test encoder::tests::content_representation_excludes_the_geometry_term ... ok
test heads::tests::factorized_pose_resists_room_shortcut_leakage ... ok
test result: ok. 91 passed; 0 failed    (+ 3 and 8 in the other targets)

The new test is verified to be sensitive rather than merely green: mutating encode_content to return cache.z — i.e. letting the Wg·geo term into the content path — fails it:

test encoder::tests::content_representation_excludes_the_geometry_term ... FAILED
assertion `left == right` failed

Mutation reverted; the committed tree is the unmutated source.

factorized_pose_resists_room_shortcut_leakage builds its latents by
hand — content = [scale, 1], full = [scale, room_x/3, 1] — so the
skeleton branch's room-independence holds by construction. It verifies
FactorizedPoseHead's algebra given a factorized latent, not that
RfEncoder produces one, which is the gap ruvnet#1438 describes.

Add the missing half against the real encoder. z = g ⊙ gate + Wg·geo +
bg, and encode_content returns g ⊙ gate with the window-mean token
features and no additive room offset, so two windows differing only in
geometry must produce the same content representation while their fused
z differs. That is the complement of
stale_windows_are_gated_toward_geometry_prior, which pins that z does
move with geometry.

Also record the existing test's scope in its doc comment and point at
the new one.

The test name is deliberately unchanged: ADR-281 cites it by name, and
that ADR already states the toy scope ("on a toy that isolates the
mechanism. MEASURED-CODE for the mechanism; not a pose-accuracy
claim"), so renaming would break an accepted ADR's reference to
describe something it already describes correctly.

cargo test -p ruview-unified --no-default-features: 102 passed, 0
failed. Mutating encode_content to return cache.z (which carries the
Wg·geo term) fails the new test, so it is sensitive to the property it
names.

This branch has not been deployed

No deployments
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