Install and verify corrected Windows control pair passively; preserve failed preparation evidence
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -102,6 +102,16 @@ function OpenFrozenState {
|
||||
if(!(Test-Path -LiteralPath $p)){if($p-cnotmatch '-(wal|shm)$'){throw 'Original database/lock absent.'};$proof[$p]=$null;continue}
|
||||
$item=Get-Item -LiteralPath $p -Force;if($item.PSIsContainer-or($item.Attributes-band[IO.FileAttributes]::ReparsePoint)){throw 'Regular original state file required.'}
|
||||
for($ancestor=$item.Directory;$null-ne$ancestor;$ancestor=$ancestor.Parent){if($ancestor.Attributes-band[IO.FileAttributes]::ReparsePoint){throw 'Original state reparse ancestry.'}}
|
||||
if($p-ceq(Join-Path $agentState 'agent.lock')-or$p-ceq(Join-Path $helperState 'executor.lock')){
|
||||
# Actual first Prepare failed with ERROR_LOCK_VIOLATION only
|
||||
# when hashing these already exclusively held lifetime locks
|
||||
# through a second data handle. All four database reads passed;
|
||||
# the case remained empty and no product replacement occurred.
|
||||
# The original RmmStoppedPairLocks handles remain held here.
|
||||
$meta=FileIdentityMetadata $p
|
||||
if($meta.bytes-ne0){throw 'Original lifetime lock must remain empty.'}
|
||||
$proof[$p]=[ordered]@{metadata=$meta;sha256=(BytesHash ([byte[]]@()));bytes=0};continue
|
||||
}
|
||||
$f=[IO.File]::Open($p,'Open','Read','Read');$held.Add([pscustomobject]@{path=$p;stream=$f})
|
||||
$meta=FileIdentityMetadata $p;$h=[Security.Cryptography.SHA256]::Create();try{$hash=[BitConverter]::ToString($h.ComputeHash($f)).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()}
|
||||
$proof[$p]=[ordered]@{metadata=$meta;sha256=$hash;bytes=$f.Length}
|
||||
@@ -114,6 +124,10 @@ function CheckFrozenState($frozen) {
|
||||
foreach($p in $frozen.proof.Keys){
|
||||
$before=$frozen.proof[$p]
|
||||
if($null-eq$before){if(Test-Path -LiteralPath $p){throw 'Original sidecar namespace changed.'};continue}
|
||||
if($p-ceq(Join-Path $agentState 'agent.lock')-or$p-ceq(Join-Path $helperState 'executor.lock')){
|
||||
$current=FileIdentityMetadata $p
|
||||
if($current.bytes-ne0-or$before.bytes-ne0-or$before.sha256-cne(BytesHash ([byte[]]@()))-or!(JsonEqual $before.metadata $current)){throw 'Original held empty lock identity, length or ACL changed.'};continue
|
||||
}
|
||||
$entry=@($frozen.held|Where-Object{$_.path-ceq$p});if($entry.Count-ne1){throw 'Original held file missing.'};$f=$entry[0].stream;$f.Position=0
|
||||
$h=[Security.Cryptography.SHA256]::Create();try{$hash=[BitConverter]::ToString($h.ComputeHash($f)).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()}
|
||||
if($hash-cne$before.sha256-or$f.Length-ne$before.bytes-or!(JsonEqual $before.metadata (FileIdentityMetadata $p))){throw 'Original database/lock bytes, file identity or ACL changed.'}
|
||||
@@ -128,9 +142,13 @@ if($Action-ceq'Read'){
|
||||
[ordered]@{id=$id;manifest_sha256=$ManifestSha256;read_only=$true;files=(CurrentFiles);device=(PreservedNativeState);agent=(Service 'agent');helper=(Service 'helper');profile=(FileIdentity $target);marks=@(Get-ChildItem -LiteralPath $work -Filter '*.json' -File -ErrorAction SilentlyContinue|Select-Object -ExpandProperty Name)}|ConvertTo-Json -Depth 18 -Compress;return
|
||||
}
|
||||
if($Action-ceq'PrepareStopped'){
|
||||
if(Test-Path -LiteralPath $work){throw 'Existing case means readback only.'}
|
||||
VerifyFiles (CurrentFiles) $oldHashes;if((Hash $target)-cne$profileHash){throw 'Current Profile8 changed.'}
|
||||
[IO.Directory]::CreateDirectory($work)|Out-Null;CheckControl $work $true
|
||||
if(Test-Path -LiteralPath $work){
|
||||
CheckControl $work $true
|
||||
if(@(Get-ChildItem -LiteralPath $work -Force -ErrorAction Stop).Count-ne0){throw 'Any existing case entry means readback only; no retry.'}
|
||||
}else{[IO.Directory]::CreateDirectory($work)|Out-Null;CheckControl $work $true}
|
||||
# Only the independently observed empty no-effect preparation case may be
|
||||
# reused. Any intent, backup, marker, hidden file or child blocks this path.
|
||||
WithStoppedState {
|
||||
param($frozen)
|
||||
$before=CurrentFiles;$retained=PreservedNativeState
|
||||
|
||||
Reference in New Issue
Block a user