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
@@ -177,6 +177,37 @@ try {
|
||||
Assert-True ($saved.status -eq $state -and $saved.artifacts.Count -eq 1 -and $saved.events -is [array] -and $saved.events.Count -eq 0 -and $saved.acceptance.state -eq 'open') 'Terminal fixture changed'
|
||||
}
|
||||
}
|
||||
Check 'incomplete-only interrupted recovery preserves launch bytes and absent end clocks' {
|
||||
$script:SessionId = 'fixture-interrupted'
|
||||
$interruptedRun = Join-Path $bundleRoot ('results/' + $SessionId)
|
||||
$null = [IO.Directory]::CreateDirectory($interruptedRun)
|
||||
$initial = New-FidelityReceipt $SessionId 'fresh-natural-ordinary' 'continuous' 'synthetic' 'incomplete' @{os='test';execution='synthetic'} $clock 'Interrupted synthetic collector'
|
||||
Write-FidelityJson (Join-Path $interruptedRun 'incomplete.json') $initial
|
||||
$before = Get-FidelityIdentity (Join-Path $interruptedRun 'incomplete.json')
|
||||
$script:AnnotationPath = Join-Path $temporary 'interrupted-notes.json'
|
||||
Write-FidelityJson $AnnotationPath @{schema_version=1;artifacts=@(@{path='raw.mkv';role='video';duration_seconds=2});events=@();derivatives=@();limitations=@('Recovered synthetic media only')}
|
||||
$script:Reason = 'Interrupted before final collector state'
|
||||
$script:Outcome = 'captured'
|
||||
Assert-Throws { Complete-FidelityRun }
|
||||
Assert-True (-not (Test-Path -LiteralPath (Join-Path $interruptedRun 'receipt.json'))) 'Interrupted record promoted'
|
||||
$script:Outcome = 'aborted'
|
||||
[IO.File]::Delete($AnnotationPath)
|
||||
Write-FidelityJson $AnnotationPath @{schema_version=1;artifacts=@();events=@(@{name='invented';artifact='raw.mkv';elapsed_seconds=1});derivatives=@();limitations=@()}
|
||||
Assert-Throws { Complete-FidelityRun }
|
||||
Assert-True (-not (Test-Path -LiteralPath (Join-Path $interruptedRun 'recovery-initial.json'))) 'Invalid recovery wrote evidence'
|
||||
[IO.File]::Delete($AnnotationPath)
|
||||
Write-FidelityJson $AnnotationPath @{schema_version=1;artifacts=@(@{path='raw.mkv';role='video';duration_seconds=2});events=@();derivatives=@();limitations=@('Recovered synthetic media only')}
|
||||
Complete-FidelityRun
|
||||
$saved = Read-FidelityJson (Join-Path $interruptedRun 'receipt.json')
|
||||
Assert-True ($saved.status -eq 'aborted' -and $saved.acceptance.state -eq 'open' -and $saved.session_id -ceq $SessionId) 'Recovery changed launch/status'
|
||||
Assert-True ($saved.clocks.PSObject.Properties.Name -notcontains 'wall_end' -and $saved.clocks.PSObject.Properties.Name -notcontains 'monotonic_end') 'Recovery invented end clocks'
|
||||
$rawInitial = Read-FidelityJson (Join-Path $interruptedRun 'incomplete.json')
|
||||
Assert-True ($saved.clocks.wall_start -eq $rawInitial.clocks.wall_start -and $saved.clocks.monotonic_start -eq $rawInitial.clocks.monotonic_start) 'Recovery changed initial clocks'
|
||||
Assert-True ((Get-FidelityIdentity (Join-Path $interruptedRun 'incomplete.json')).sha256 -eq $before.sha256) 'Recovery changed raw initial bytes'
|
||||
Assert-True ($saved.artifacts[0].path -eq 'recovery-initial.json' -and $saved.artifacts[0].sha256 -eq $before.sha256) 'Missing raw initial identity'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $interruptedRun 'media/raw.mkv')) 'Missing recovered media'
|
||||
Assert-Throws { Complete-FidelityRun }
|
||||
}
|
||||
if ($FixtureOutput) {
|
||||
if (Test-Path -LiteralPath $FixtureOutput) { throw 'Fixture output must be new' }
|
||||
$null = [IO.Directory]::CreateDirectory($FixtureOutput)
|
||||
|
||||
@@ -193,6 +193,24 @@ class FidelityScenarios(unittest.TestCase):
|
||||
value['acceptance'] = {'state': 'open', 'remaining': [status]}
|
||||
self.assertEqual(api.audit_scenarios(self.protocol(), [(value, root)])['accepted'], 0)
|
||||
|
||||
def test_aborted_missing_end_clocks_imports_without_invented_observations(self):
|
||||
value, root = self.receipt()
|
||||
value['status'] = 'aborted'
|
||||
value['acceptance'] = {'state': 'open', 'remaining': ['interrupted']}
|
||||
value['events'] = []
|
||||
for field in ('wall_end', 'monotonic_end'):
|
||||
del value['clocks'][field]
|
||||
(root / 'receipt.json').write_bytes(api.canonical_bytes(value))
|
||||
imported = api.import_receipt(root / 'receipt.json', root, self.base / 'imports')
|
||||
path = Path(imported['path'])
|
||||
saved = api.read_receipt(path)
|
||||
result = api.validate_receipt(saved, path.parent)
|
||||
self.assertFalse(result['accepted'])
|
||||
self.assertNotIn('wall_end', saved['clocks'])
|
||||
self.assertNotIn('monotonic_end', saved['clocks'])
|
||||
value['status'] = 'reviewed'
|
||||
with self.assertRaises(ValueError): api.validate_receipt(value, root)
|
||||
|
||||
def test_missing_event_and_media_out_of_range_rejected(self):
|
||||
value, root = self.receipt()
|
||||
value['events'].pop()
|
||||
|
||||
Reference in new issue
Block a user