{"record":{"id":"3f1113ae960381da","repo":"Hmbown/CodeWhale","slug":"compaction-coverage-floor-label-was-dropped-history-was-not","errorCode":null,"errorMessage":"Compaction coverage floor: {label} was dropped; history was not replaced.","messagePattern":"Compaction coverage floor: (.+?) was dropped; history was not replaced\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/compaction/last_round.rs","lineNumber":439,"sourceCode":"\npub(crate) fn require_text_survives(\n    replacement: &[Message],\n    needle: &str,\n    label: &str,\n) -> Result<()> {\n    let needle = needle.trim();\n    if needle.is_empty() {\n        return Ok(());\n    }\n    let kept = replacement.iter().any(|message| {\n        message.content.iter().any(|block| match block {\n            ContentBlock::Text { text, .. } => text.contains(needle),\n            ContentBlock::ToolResult { content, .. } => content.contains(needle),\n            _ => false,\n        })\n    });\n    if !kept {\n        anyhow::bail!(\"Compaction coverage floor: {label} was dropped; history was not replaced.\");\n    }\n    Ok(())\n}\n\npub(crate) fn validate_survival_contract(\n    original: &[Message],\n    replacement: &[Message],\n    anchors: Option<&str>,\n) -> Result<()> {\n    validate_last_round_coverage(original, replacement)?;\n    let checkpoints = replacement\n        .iter()\n        .filter(|message| is_compaction_checkpoint_message(message))\n        .count();\n    if checkpoints == 0 {\n        anyhow::bail!(\n            \"Compaction coverage floor: checkpoint receipt was dropped; history was not replaced.\"\n        );","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/compaction/last_round.rs#L421-L457","documentation":"`require_text_survives` is a targeted survival check for a specific labeled text needle (summary snippet, key content). It searches the replacement history for a message whose Text or ToolResult content contains the needle; if nothing keeps it, the rewrite is rejected. Used by `validate_survival_contract` and the duplicate-summary test.","triggerScenarios":"`require_text_survives(original, replacement, label, needle)` runs and no block in the replacement (Text content or ToolResult content) contains the needle substring.","commonSituations":"A rewrite drops the message containing the labeled anchor (e.g. prior compaction receipt text or a required snippet); a test fixture expects an anchor that the new rewrite no longer preserves.","solutions":["Keep the message containing the labeled text in the replacement history.","If the label/needle is stale (test drift), update the needle to match the current anchor content.","Check that rewrite does not drop Text blocks inside ToolResult content.","Run `second_compact_does_not_duplicate_prior_summaries` / `validate_survival_contract` tests to locate the anchor."],"exampleFix":"// before: replacement drops the anchored message\nlet replacement = summarized_only;\n// after: retain the anchor message\nlet replacement = [summarized_only, anchor_msgs.as_slice()].concat();","handlingStrategy":"validation","validationCode":"fn keeps_needle(replacement: &[Message], needle: &str) -> bool {\n    replacement.iter().any(|m| m.blocks.iter().any(|b| match b {\n        ContentBlock::Text { text, .. } => text.contains(needle),\n        ContentBlock::ToolResult { content, .. } => content.contains(needle),\n        _ => false,\n    }))\n}","typeGuard":null,"tryCatchPattern":"match compaction::apply_replacement(&replacement) {\n    Err(e) if e.to_string().contains(\"was dropped\") => keep_original_history(),\n    other => other,\n}","preventionTips":["Identify anchor texts (prior receipts, key snippets) and never drop their messages","Update labeled needles when anchor content legitimately changes","Search both Text and ToolResult content in checks","Run validate_survival_contract before swapping history"],"tags":["compaction","coverage-floor","survival-contract"],"backgroundTag":"internal-invariant-violation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}