fix(01): WR-02 recover interrupted Windows runs without invented clocks
This commit is contained in:
1 parent
548c97aa58
commit
2608517c37
5 files changed
+86
-2
No files matched your search
@@ -333,12 +333,28 @@ function Complete-FidelityRun {
|
||||
$null = Test-FidelityId $SessionId
|
||||
$run = Get-FidelityPath $Bundle ('results/' + $SessionId)
|
||||
$null = Test-FidelityBundle $Bundle
|
||||
$receipt = Read-FidelityJson (Join-Path $run 'run.json')
|
||||
$runPath = Join-Path $run 'run.json'
|
||||
$recovering = -not (Test-Path -LiteralPath $runPath)
|
||||
if ($recovering) {
|
||||
if ($Outcome -ne 'aborted') { throw 'Interrupted initial record can only be finalized as aborted' }
|
||||
$runPath = Join-Path $run 'incomplete.json'
|
||||
}
|
||||
$receipt = Read-FidelityJson $runPath
|
||||
if ($recovering) {
|
||||
if ($receipt.status -ne 'incomplete' -or $receipt.session_id -cne $SessionId) { throw 'Interrupted initial record does not match the incomplete session' }
|
||||
# Initial records from older collectors contain placeholder end values.
|
||||
# Neither those placeholders nor recovery time observed the process end.
|
||||
$receipt.clocks.PSObject.Properties.Remove('wall_end')
|
||||
$receipt.clocks.PSObject.Properties.Remove('monotonic_end')
|
||||
$receipt.missing_evidence += 'Interrupted collector: end clocks and launch-aligned observations unavailable'
|
||||
$receipt | Add-Member -Force -NotePropertyName diagnostic -NotePropertyValue $true
|
||||
}
|
||||
if (Test-Path -LiteralPath (Join-Path $run 'receipt.json')) { throw 'Result already finalized; preserve it and use a new result ID' }
|
||||
if (-not $AnnotationPath -or -not $ArtifactsDirectory) { throw 'Finish requires actual annotations and a local artifact directory' }
|
||||
$annotation = Read-FidelityJson $AnnotationPath
|
||||
$requested = Get-FidelityOutcome $receipt.status $Outcome $Reason
|
||||
if ($annotation.schema_version -ne 1) { throw 'Unsupported annotation schema' }
|
||||
if ($recovering -and @($annotation.events).Count) { throw 'Interrupted run has no observed end interval; retain annotations without launch-aligned events' }
|
||||
if (@($annotation.artifacts).Count -gt 10000) { throw 'Too many artifacts' }
|
||||
$names = @{}
|
||||
foreach ($file in $annotation.artifacts) {
|
||||
@@ -366,6 +382,11 @@ function Complete-FidelityRun {
|
||||
}
|
||||
}
|
||||
$receipt.artifacts = @()
|
||||
if ($recovering) {
|
||||
$initial = Copy-FidelityEvidence $runPath $run 'recovery-initial.json'
|
||||
$initial.role = 'diagnostic'
|
||||
$receipt.artifacts += $initial
|
||||
}
|
||||
foreach ($file in $annotation.artifacts) {
|
||||
$source = Get-FidelityPath $ArtifactsDirectory $file.path
|
||||
$id = Copy-FidelityEvidence $source $run ('media/' + $file.path)
|
||||
|
||||
Reference in new issue
Block a user