astrid-runtime/astrid · error

valid history is accepted by the derived helper

Error message

valid history is accepted by the derived helper

What it means

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.

Source

Thrown at crates/astrid-kernel/src/audit_retirement_tests.rs:52

    std::fs::create_dir(&outside).expect("outside fixture");
    std::os::unix::fs::symlink(&outside, principal_home.audit_dir().join("redirect"))
        .expect("redirect fixture");

    assert!(retire_legacy_audit_dir(&home, &principal_home.audit_dir()).is_err());
    assert!(principal_home.audit_dir().exists());
}

#[test]
fn derived_audit_recertify_helper_rejects_invalid_history() {
    let valid = vec![(
        SessionId::new(),
        ChainVerificationResult {
            valid: true,
            entries_verified: 1,
            issues: Vec::new(),
        },
    )];
    require_audit_integrity(&valid).expect("valid history is accepted by the derived helper");

    let invalid = vec![(
        SessionId::new(),
        ChainVerificationResult {
            valid: false,
            entries_verified: 1,
            issues: Vec::new(),
        },
    )];
    assert!(require_audit_integrity(&invalid).is_err());
}

#[test]
fn audit_boot_rejects_unhandled_non_default_source() {
    let directory = tempfile::tempdir().expect("temporary home");
    let home = AstridHome::from_path(directory.path().join(".astrid"));
    home.ensure().expect("home layout");
    let other = astrid_core::PrincipalId::new("other".to_owned()).expect("principal id");

View on GitHub (pinned to affd8760f4)

Solutions

  1. Panic with the error text (match on Err) to see which rule rejected the valid history.
  2. Compare the helper's acceptance conditions with the fixture: valid: true, entries_verified: 1, issues: []. Update whichever is stale.
  3. Check for an inverted boolean or an off-by-one after a refactor of require_audit_integrity.
  4. If ChainVerificationResult gained fields, populate them correctly in the fixture instead of relying on defaults.

Example fix

// before
require_audit_integrity(&valid).expect("valid history is accepted by the derived helper");
// after
require_audit_integrity(&valid)
    .unwrap_or_else(|e| panic!("valid history is accepted by the derived helper: {e}"));
Defensive patterns

Strategy: try-catch

Validate before calling

let all_valid = valid.iter().all(|(_, r)| r.valid);
assert!(all_valid, "fixture must contain only valid results before calling the helper");
require_audit_integrity(&valid).expect("valid history is accepted by the derived helper");

Type guard

fn is_valid_history(h: &[(SessionId, ChainVerificationResult)]) -> bool {
    !h.is_empty() && h.iter().all(|(_, r)| r.valid)
}

Try / catch

require_audit_integrity(&valid)
    .unwrap_or_else(|e| panic!("valid history is accepted by the derived helper: {e}"));

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/63afeb43cd4afa15. Report an issue: GitHub.