{"record":{"id":"cfd2bd7e383b5c4a","repo":"affaan-m/ECC","slug":"missing-harness-health-evidence-integrity-metadata","errorCode":null,"errorMessage":"missing harness health evidence integrity metadata","messagePattern":"missing harness health evidence integrity metadata","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/session/store.rs","lineNumber":5593,"sourceCode":"    }\n\n    fn verify_harness_audit_entry(&self, entry: &HarnessAuditEntry) -> Result<()> {\n        let fields = (\n            &entry.health_evidence_json,\n            &entry.health_evidence_sha256,\n            entry.asserted_health,\n            &entry.health_check_status,\n        );\n        if matches!(fields, (None, None, None, None)) {\n            if entry.legacy_unverifiable\n                || matches!(\n                    entry.event_type.as_str(),\n                    \"initial_activation\" | \"promotion_rejected\"\n                )\n            {\n                return Ok(());\n            }\n            anyhow::bail!(\"missing harness health evidence integrity metadata\");\n        }\n        let (Some(json), Some(digest), Some(asserted), Some(status)) = fields else {\n            anyhow::bail!(\"incomplete harness health evidence integrity metadata\");\n        };\n        if json.len() > 8192 {\n            anyhow::bail!(\"harness health evidence exceeds integrity verification bound\");\n        }\n        let snapshot: HealthEvidenceSnapshot = serde_json::from_str(json)?;\n        let snapshot_candidate_id =\n            Self::resolve_harness_candidate_id(&self.conn, &snapshot.candidate_id)?;\n        if snapshot.canonical_json()? != *json\n            || snapshot.digest()? != *digest\n            || snapshot.asserted_healthy != asserted\n            || snapshot_candidate_id != entry.candidate_id\n        {\n            anyhow::bail!(\"harness health evidence integrity verification failed\");\n        }\n        let event_consistent = match entry.event_type.as_str() {","sourceCodeStart":5575,"sourceCodeEnd":5611,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/session/store.rs#L5575-L5611","documentation":"When verifying an audit entry, all four health-evidence fields (json, digest, asserted, status) are None. This is permitted only when legacy_unverifiable is set or the event_type is initial_activation or promotion_rejected; for any other event (promoted, rolled back, etc.) health evidence is mandatory.","triggerScenarios":"An audit row whose event_type is promoted/promotion_rolled_back/health_check_error_rolled_back, legacy_unverifiable is false, and all four health-evidence columns are NULL.","commonSituations":"A DB migrated from an older schema that lacked health-evidence columns; a code path that wrote a promotion audit row without populating health metadata; a partial migration that left rows half-populated.","solutions":["Backfill health evidence for existing promoted/rolled_back rows from the authoritative source.","Ensure every promotion code path persists health_evidence_json, health_evidence_sha256, asserted_health, and health_check_status as a group.","Mark genuinely unverifiable historical rows with legacy_unverifiable = 1 so the verifier skips them."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before verifying, confirm the row is either exempt or fully populated.\nlet (json, digest, asserted, status, legacy, event): (Option<String>, Option<String>, Option<bool>, Option<String>, bool, String) =\n    conn.query_row(\n        \"SELECT health_evidence_json, health_evidence_sha256, asserted_health, health_check_status, legacy_unverifiable, event_type\n         FROM harness_eval_audit WHERE id = ?1\", [id],\n        |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?, r.get(3)?, r.get(4)?, r.get(5)?)))?;\nlet exempt = legacy || matches!(event.as_str(), \"initial_activation\" | \"promotion_rejected\");\nif matches!((json, digest, asserted, status), (None, None, None, None)) && !exempt {\n    return Err(anyhow::anyhow!(\"audit row {id} missing required health evidence\"));\n}","typeGuard":"fn audit_has_required_health(json: Option<&str>, legacy: bool, event: &str) -> bool {\n    legacy || matches!(event, \"initial_activation\" | \"promotion_rejected\") || json.is_some()\n}","tryCatchPattern":"match verify_audit_entry(&store, &entry) {\n    Ok(()) => { /* ok */ }\n    Err(e) if e.to_string().contains(\"missing harness health evidence integrity metadata\") => {\n        // backfill the four fields, or mark the row legacy_unverifiable=1 if unverifiable\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Ensure every promotion write populates all four health-evidence columns.","Mark historical, pre-health-evidence rows with legacy_unverifiable=1 during migration.","Add a NOT NULL constraint on those columns for non-exempt event types."],"tags":["rust","sqlite","harness","audit","integrity"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}