Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions v2/crates/ruview-unified/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,30 @@ mod tests {
assert_ne!(fresh.z, moved.z);
}

#[test]
fn content_representation_excludes_the_geometry_term() {
// z = g ⊙ gate + Wg·geo + bg; encode_content returns g ⊙ gate with the
// window-mean token features and no additive room offset. This is the
// complement of stale_windows_are_gated_toward_geometry_prior, which
// pins that z *does* move with geometry: together they are the
// factorization the pose head relies on. Exercised against the real
// encoder, so wiring geometry into the content path fails here.
let e = RfEncoder::new(EncoderConfig::default(), 7);
let tokens = toy_tokens(8);
let room_a =
TokenizedWindow { tokens: tokens.clone(), age_s: 0.25, geometry: [0.2; 6] };
let room_b = TokenizedWindow { tokens, age_s: 0.25, geometry: [0.9; 6] };

// The fused representation separates the two rooms.
assert_ne!(
e.forward(&room_a.tokens, &[], WindowContext::from(&room_a)).z,
e.forward(&room_b.tokens, &[], WindowContext::from(&room_b)).z
);
// The content representation cannot tell them apart.
assert_eq!(e.encode_content(&room_a), e.encode_content(&room_b));
assert_eq!(e.encode_content(&room_a).len(), e.content_dim());
}

#[test]
fn masking_excludes_tokens_from_context() {
let e = RfEncoder::new(EncoderConfig::default(), 5);
Expand Down
19 changes: 13 additions & 6 deletions v2/crates/ruview-unified/src/heads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,19 @@ mod tests {
);
}

/// The RePos leakage experiment: in the training rooms, room position
/// correlates with body scale (small people in room A, tall in room B).
/// A monolithic absolute-pose head exploits the room feature as a
/// shortcut and collapses in an unseen room that breaks the
/// correlation; the factorized head's skeleton branch never sees room
/// features and generalizes.
/// The RePos leakage experiment, on synthetic latents: in the training
/// rooms, room position correlates with body scale (small people in room
/// A, tall in room B). A monolithic absolute-pose head exploits the room
/// feature as a shortcut and collapses in an unseen room that breaks the
/// correlation; the factorized head's skeleton branch is given a latent
/// without the room column and generalizes.
///
/// Scope: the content and full latents here are hand-built
/// (`content = [scale, 1]`, `full = [scale, room_x/3, 1]`), so the
/// skeleton branch's room-independence is true by construction. What this
/// verifies is the head's algebra given such a factorization, not that the
/// encoder produces one. `RfEncoder`'s side of the contract is covered by
/// `encoder::tests::content_representation_excludes_the_geometry_term`.
#[test]
fn factorized_pose_resists_room_shortcut_leakage() {
use crate::eval::mpjpe;
Expand Down