Skip to content

Commit 7640f6d

Browse files
committed
test: pin the m0 never-empty floor for the CC marker planner
Thalamus's last_cacheable_ck_block skips media/reasoning/opaque and empty-text blocks when placing the cache marker; an m0 that rendered empty would silently lose its breakpoint. render_m0's unconditional session-history section is what keeps that unreachable — pin it so a future conditional-section refactor fails here instead of going quiet in production.
1 parent c340e29 commit 7640f6d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

crates/mc-module/src/memory_render.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,38 @@ mod tests {
367367
}
368368
}
369369

370+
/// CONSUMER CONTRACT (Thalamus marker planner, ck_map.rs last_cacheable_ck_block):
371+
/// the m0 message must ALWAYS carry at least one non-empty text block. Their
372+
/// cache-marker placement skips Media/Reasoning/Opaque blocks and EMPTY text
373+
/// blocks; an m0 whose text came out empty (or media-only, once the mural image
374+
/// part ships) would silently lose its cache breakpoint — no error, just a dead
375+
/// prefix cache on the CC leg. render_m0 guarantees this structurally via the
376+
/// unconditional session-history section (M0_EMPTY_BODY when no compartments),
377+
/// so even the emptiest possible inputs produce non-empty bytes. This test pins
378+
/// that floor; if someone makes the session-history section conditional, this
379+
/// fails before the marker planner goes quiet in production.
380+
#[test]
381+
fn render_m0_never_empty_even_with_all_inputs_empty() {
382+
let rendered = render_m0(
383+
&M0Inputs {
384+
project_docs: "",
385+
user_profile: &[],
386+
covered_system_messages: &[],
387+
compartments: &[],
388+
memories: &[],
389+
source_name_by_id: &Default::default(),
390+
history_budget_tokens: 0.0,
391+
decay_pressure_multiplier: 1.0,
392+
},
393+
|_| 0,
394+
);
395+
assert!(
396+
!rendered.trim().is_empty(),
397+
"m0 must never render empty: the marker planner needs a non-empty text block"
398+
);
399+
assert_eq!(rendered, M0_EMPTY_BODY);
400+
}
401+
370402
#[test]
371403
fn workspace_sources_attribute_only_foreign_memories() {
372404
let mut own = mem(1, "ARCHITECTURE", "own", Some(80));

0 commit comments

Comments
 (0)