{"record":{"id":"4e15b41333fce421","repo":"affaan-m/ECC","slug":"incomplete-harness-health-evidence-integrity-metad","errorCode":null,"errorMessage":"incomplete harness health evidence integrity metadata","messagePattern":"incomplete harness health evidence integrity metadata","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/session/store.rs","lineNumber":5596,"sourceCode":"        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() {\n            \"promoted\" => status == \"healthy\" && asserted,\n            \"promotion_rolled_back\" => status == \"unhealthy\" && !asserted,\n            \"health_check_error_rolled_back\" => status == \"error\",","sourceCodeStart":5578,"sourceCodeEnd":5614,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/session/store.rs#L5578-L5614","documentation":"An audit entry's four health-evidence fields are partially populated (some NULL, some not). The integrity model requires them to be all-present or all-absent together; a partial set cannot be verified and indicates a malformed write.","triggerScenarios":"An audit row where the tuple (health_evidence_json, health_evidence_sha256, asserted_health, health_check_status) has a mix of Some and None, so the let-else (Some, Some, Some, Some) destructure fails.","commonSituations":"An INSERT that set json+digest but not asserted/status (or any subset); a schema migration that backfilled one column but not the others; a bug in the audit-writing code path.","solutions":["Rewrite the row so all four fields are set together (or all NULL only for legacy_unverifiable / initial_activation / promotion_rejected rows).","Audit every INSERT into harness_eval_audit to confirm it populates the four fields as one atomic group.","Add a CHECK constraint (all four NULL or all four NOT NULL) to catch malformed writes at the DB layer."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm all four fields are present together (or all absent for exempt rows).\nlet present = [json.is_some(), digest.is_some(), asserted.is_some(), status.is_some()];\nlet all_present = present.iter().all(|b| *b);\nlet all_absent = present.iter().all(|b| !*b);\nif !all_present && !all_absent {\n    return Err(anyhow::anyhow!(\"audit row {id} has partially-populated health evidence\"));\n}","typeGuard":"fn health_fields_consistent(json: Option<&str>, digest: Option<&str>, asserted: Option<bool>, status: Option<&str>) -> bool {\n    let p = [json.is_some(), digest.is_some(), asserted.is_some(), status.is_some()];\n    p.iter().all(|b| *b) || p.iter().all(|b| !*b)\n}","tryCatchPattern":"match verify_audit_entry(&store, &entry) {\n    Ok(()) => { /* ok */ }\n    Err(e) if e.to_string().contains(\"incomplete harness health evidence integrity metadata\") => {\n        // rewrite the row so all four fields are set together (or all NULL + legacy_unverifiable)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Write the four health-evidence columns as a single atomic group in one INSERT.","Add a CHECK constraint requiring all-NULL-or-all-NOT-NULL.","Never UPDATE one of the four columns in isolation."],"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"}