astrid-runtime/astrid · error
retire audit source
Error message
retire audit source
What it means
The message "retire audit source" is the expect() on retire_legacy_audit_dir(&home, &principal_home.audit_dir()) at audit_retirement_tests.rs:15. retire_legacy_audit_dir is the function under test: it validates the legacy per-principal audit tree and removes it, recording a migration marker under home.migrations_dir() only for verified sources. This expect fails when the retirement function returns Err — meaning the function refused to retire a tree the test believes is a legitimate, verified default-principal audit directory (no symlinks, non-empty).
Source
Thrown at crates/astrid-kernel/src/audit_retirement_tests.rs:15
use super::{preflight_legacy_audit_sources, require_audit_integrity, retire_legacy_audit_dir};
use astrid_audit::ChainVerificationResult;
use astrid_core::SessionId;
use astrid_core::dirs::AstridHome;
#[test]
fn audit_retirement_validates_tree_and_removes_only_verified_source() {
let directory = tempfile::tempdir().expect("temporary home");
let home = AstridHome::from_path(directory.path().join(".astrid"));
home.ensure().expect("home layout");
let principal_home = home.principal_home(&astrid_core::PrincipalId::default());
principal_home.ensure().expect("legacy principal layout");
std::fs::write(principal_home.audit_dir().join("entry"), b"audit").expect("audit fixture");
retire_legacy_audit_dir(&home, &principal_home.audit_dir()).expect("retire audit source");
assert!(!principal_home.audit_dir().exists());
assert!(
!home
.migrations_dir()
.join("audit-principal-home.retired")
.exists()
);
}
#[cfg(unix)]
#[test]
fn audit_retirement_rejects_redirects_before_removal() {
let directory = tempfile::tempdir().expect("temporary home");
let home = AstridHome::from_path(directory.path().join(".astrid"));
home.ensure().expect("home layout");
let principal_home = home.principal_home(&astrid_core::PrincipalId::default());
principal_home.ensure().expect("legacy principal layout");
let outside = directory.path().join("outside");View on GitHub (pinned to affd8760f4)
Solutions
- Print the returned error (change .expect("retire audit source") to match on Err and panic! with the error text) to see which validation rejected the tree.
- Confirm the test uses PrincipalId::default() — retire_legacy_audit_dir may only retire the default principal's source by design.
- Audit recent changes to retire_legacy_audit_dir for stricter redirect detection or new preconditions.
- Check that no leftover 'redirect' symlink from another test pollutes the audit dir; recreate the tempdir fixture.
Example fix
// before
retire_legacy_audit_dir(&home, &principal_home.audit_dir()).expect("retire audit source");
// after
retire_legacy_audit_dir(&home, &principal_home.audit_dir())
.unwrap_or_else(|e| panic!("retire audit source: {e}")); Defensive patterns
Strategy: try-catch
Validate before calling
// precondition check before retiring let dir = principal_home.audit_dir(); assert!(dir.is_dir(), "source must be a real directory"); assert!(!fs::symlink_metadata(dir).map(|m| m.file_type().is_symlink()).unwrap_or(true), "source must not be a symlink");
Try / catch
if let Err(e) = retire_legacy_audit_dir(&home, &principal_home.audit_dir()) {
panic!("retire audit source: {e}");
} Prevention
- Surface the underlying error (unwrap_or_else + panic!) so the refusing validation rule is visible.
- Keep retirement tests on the default principal unless testing the non-default rejection path explicitly.
- After refactors of redirect detection, re-check that plain directories are not misclassified as symlinks.
- Verify migrations_dir is writable since retirement records a marker there.
When it happens
Trigger: Calling retire_legacy_audit_dir() with a real, symlink-free audit directory that nonetheless fails its internal validation: e.g. it mistakes the tree for a redirect (symlink-detection false positive), rejects a non-default principal when the test intends the default one, fails to write the migration marker, or errors while removing the directory.
Common situations: A regression in the symlink/redirect validation in retire_legacy_audit_dir that misclassifies plain directories; changes to migrations_dir layout so the marker write fails; an API change where retire_legacy_audit_dir now requires a different argument (e.g. PrincipalHome instead of a PathBuf).
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- unsupported legacy audit source {audit_source}; only the def
- legacy audit retirement source is outside the default princi
- legacy audit retirement is ambiguous: {retired}
- valid history is accepted by the derived helper
- legacy capsule entry has a non-UTF-8 name
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/e5261e6545eb824a.
Report an issue: GitHub.