{"record":{"id":"63afeb43cd4afa15","repo":"astrid-runtime/astrid","slug":"valid-history-is-accepted-by-the-derived-helper","errorCode":null,"errorMessage":"valid history is accepted by the derived helper","messagePattern":"valid history is accepted by the derived helper","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/audit_retirement_tests.rs","lineNumber":52,"sourceCode":"    std::fs::create_dir(&outside).expect(\"outside fixture\");\n    std::os::unix::fs::symlink(&outside, principal_home.audit_dir().join(\"redirect\"))\n        .expect(\"redirect fixture\");\n\n    assert!(retire_legacy_audit_dir(&home, &principal_home.audit_dir()).is_err());\n    assert!(principal_home.audit_dir().exists());\n}\n\n#[test]\nfn derived_audit_recertify_helper_rejects_invalid_history() {\n    let valid = vec![(\n        SessionId::new(),\n        ChainVerificationResult {\n            valid: true,\n            entries_verified: 1,\n            issues: Vec::new(),\n        },\n    )];\n    require_audit_integrity(&valid).expect(\"valid history is accepted by the derived helper\");\n\n    let invalid = vec![(\n        SessionId::new(),\n        ChainVerificationResult {\n            valid: false,\n            entries_verified: 1,\n            issues: Vec::new(),\n        },\n    )];\n    assert!(require_audit_integrity(&invalid).is_err());\n}\n\n#[test]\nfn audit_boot_rejects_unhandled_non_default_source() {\n    let directory = tempfile::tempdir().expect(\"temporary home\");\n    let home = AstridHome::from_path(directory.path().join(\".astrid\"));\n    home.ensure().expect(\"home layout\");\n    let other = astrid_core::PrincipalId::new(\"other\".to_owned()).expect(\"principal id\");","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/audit_retirement_tests.rs#L34-L70","documentation":"The message \"valid history is accepted by the derived helper\" is the expect() on require_audit_integrity(&valid) at audit_retirement_tests.rs:52 in derived_audit_recertify_helper_rejects_invalid_history. require_audit_integrity takes a slice of (SessionId, ChainVerificationResult) and succeeds only when every entry's verification is valid; the test feeds one entry with valid: true, entries_verified: 1, no issues, so the helper must return Ok. The expect fires when the helper wrongly rejects an all-valid history — a bug in the derived recertify/integrity check, not in the fixture.","triggerScenarios":"require_audit_integrity returns Err for input where every ChainVerificationResult has valid: true — e.g. it also inspects entries_verified/issue fields with stricter rules, inverts the valid flag, requires a non-empty session id, or was changed to demand a minimum entry count.","commonSituations":"Regressions after refactoring the helper from hand-written matching to a derived macro/impl; a new policy that treats entries_verified == 0 or particular issue strings as fatal even when valid is true; test data drift where ChainVerificationResult gained fields the fixture no longer populates sensibly.","solutions":["Panic with the error text (match on Err) to see which rule rejected the valid history.","Compare the helper's acceptance conditions with the fixture: valid: true, entries_verified: 1, issues: []. Update whichever is stale.","Check for an inverted boolean or an off-by-one after a refactor of require_audit_integrity.","If ChainVerificationResult gained fields, populate them correctly in the fixture instead of relying on defaults."],"exampleFix":"// before\nrequire_audit_integrity(&valid).expect(\"valid history is accepted by the derived helper\");\n// after\nrequire_audit_integrity(&valid)\n    .unwrap_or_else(|e| panic!(\"valid history is accepted by the derived helper: {e}\"));","handlingStrategy":"try-catch","validationCode":"let all_valid = valid.iter().all(|(_, r)| r.valid);\nassert!(all_valid, \"fixture must contain only valid results before calling the helper\");\nrequire_audit_integrity(&valid).expect(\"valid history is accepted by the derived helper\");","typeGuard":"fn is_valid_history(h: &[(SessionId, ChainVerificationResult)]) -> bool {\n    !h.is_empty() && h.iter().all(|(_, r)| r.valid)\n}","tryCatchPattern":"require_audit_integrity(&valid)\n    .unwrap_or_else(|e| panic!(\"valid history is accepted by the derived helper: {e}\"));","preventionTips":["Keep the valid/invalid fixture pair in sync with ChainVerificationResult's fields.","When the helper's acceptance rules change, update the fixture or the rule — never silence the assertion.","Panic with the helper's error text to make regressions diagnosable.","Add a unit test directly on require_audit_integrity with minimal valid input to catch inversions early."],"tags":["rust","audit","verification","test-panic"],"backgroundTag":"schema-validation-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}