astrid-runtime/astrid · error
home layout
Error message
home layout
What it means
Continuation of the same test setup: after creating the temp dir, `home.ensure()` must create the `.astrid` home layout (including the audit dir). The `expect("home layout")` fires when `ensure` returns an `Err` — directory creation or the audit-dir layout step failed on the constructed path.
Source
Thrown at crates/astrid-kernel/src/audit_retirement_tests.rs:10
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");View on GitHub (pinned to affd8760f4)
Solutions
- Verify `ensure` creates all parent directories recursively before the audit dir.
- Check the `audit_dir` path is under the ensured home, not an absolute path outside the temp tree.
- Inspect the underlying io::Error from `ensure` — surface it in the panic message.
- If the test filesystem is unusual, run against a standard writable temp dir via TMPDIR.
Example fix
// before
home.ensure().expect("home layout");
// after
home.ensure().unwrap_or_else(|e| panic!("home layout creation failed at {:?}: {e}", home.path())); Defensive patterns
Strategy: validation
Validate before calling
// Rust: confirm the home path is inside the temp dir before ensure()
let home = AstridHome::from_path(directory.path().join(".astrid"));
assert!(home.path().starts_with(directory.path()), "home must live under tempdir"); Try / catch
// Rust: surface the io error source on ensure failure
home.ensure().unwrap_or_else(|e| panic!("AstridHome::ensure failed for {:?}: {e}", home.path())); Prevention
- Implement ensure() with recursive directory creation (create_dir_all).
- Derive audit_dir from the home root so parents always exist first.
- Test AstridHome layout creation on its own before higher-level tests depend on it.
- Keep io errors attached to panics via context, never bare expects on setup.
When it happens
Trigger: Calling `AstridHome::from_path(tempdir/.astrid).ensure()` when mkdir of the home or `audit_dir` fails: nested-path permission problems, filesystem errors inside the temp dir, or a bug in `ensure` not creating parent directories (`audit_dir().join("entry")` write would also fail later).
Common situations: A regression in `AstridHome::ensure` (missing recursive create), path-length or permission issues on exotic temp filesystems, or `principal_home.ensure()`/`audit_dir()` paths computed before the parent exists.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- temporary home
- legacy principal layout
- directory symlink {} not allowed in capsule source tree (ref
- mountpoint is already registered: {}
- capsule path escaped source root
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/a12a36093a131253.
Report an issue: GitHub.