Normalize inactive State Anchor work storage

This commit is contained in:
ms2k 2026-07-23 21:44:16 +09:00
commit 42e197510e
3 changed files with 133 additions and 11 deletions

View file

@ -167,6 +167,9 @@ impl<'a> ColdStart<'a> {
);
let state_anchor_layout = StateAnchorLayout::create(inputs.configuration)
.map_err(|error| failure(format!("State Anchor layout: {error}")))?;
state_anchor_layout
.normalize_inactive_work_directory()
.map_err(|error| failure(format!("State Anchor work recovery: {error}")))?;
let staging = RuntimeStaging::create(
inputs.configuration.runtime_domain_root(),
inputs.container_id,

View file

@ -599,6 +599,9 @@ fn recover_state_anchor(
) && owners.ownership.state_anchor_mount.is_some();
if !full_mount {
let _ = owners.prove_absent().map_err(|error| error.to_string())?;
StateAnchorLayout::create(configuration)
.and_then(|layout| layout.normalize_inactive_work_directory())
.map_err(|error| error.to_string())?;
return clean_role_after_absence(
store,
generation.generation_id,
@ -652,6 +655,9 @@ fn recover_state_anchor(
) {
return Err("completed recovery witness changed State Anchor authority".into());
}
layout
.normalize_inactive_work_directory()
.map_err(|error| error.to_string())?;
coordinator
.complete_release_after_unmount(&authority, &layout, first, || {
fresh_absence(store, generation.generation_id, &layout)

View file

@ -206,6 +206,11 @@ fn complete_boot_mismatch_inventory_proves_only_after_every_holder_and_mount() {
#[test]
fn recovery_preflight_recovers_full_runtime_then_is_idempotent() {
let fixture = RecoveryFixture::new();
let layout = StateAnchorLayout::create(&fixture.configuration).unwrap();
let residue = layout.work().join("work/4");
fs::create_dir_all(&residue).unwrap();
fs::write(residue.join(".wh..wh..opq"), b"").unwrap();
drop(layout);
let mut boundaries = Vec::new();
fixture
.recover_with(|boundary, generation| {
@ -251,6 +256,8 @@ fn recovery_preflight_recovers_full_runtime_then_is_idempotent() {
.join(hex_lower(&[6; 32]))
.exists()
);
let layout = StateAnchorLayout::create(&fixture.configuration).unwrap();
assert!(layout.work().read_dir().unwrap().next().is_none());
recover_before_cold_start(
&fixture.configuration,