fix(01): CR-03 bind lifetime continuity to named copy snapshots

This commit is contained in:
UnixNight committed 2026-11-13 17:02:22 -05:00
1 parent bda35e5bf5
commit 6e5ee0bd25
4 files changed
+34 -10

No files matched your search

+1 -1
View File
@@ -90,7 +90,7 @@ SHA-256, size and header. No path or command from returned metadata is executed.
| Original executable | Actual selected executable from the generated run (`Neutron.exe` or the recorded selected variant); retain its exact pristine relative path in `identity.executable.original_member` and compare size/header/hash to that member, retaining any mismatch as open | | Original executable | Actual selected executable from the generated run (`Neutron.exe` or the recorded selected variant); retain its exact pristine relative path in `identity.executable.original_member` and compare size/header/hash to that member, retaining any mismatch as open |
| Original package/resources | Both identify hashed `identify_tree(original-pristine)` inventories whose complete file records and recomputed digest equal the checkpoint baseline. Generated-copy pre/post inventories remain separate; preserve all raw original content identities | | Original package/resources | Both identify hashed `identify_tree(original-pristine)` inventories whose complete file records and recomputed digest equal the checkpoint baseline. Generated-copy pre/post inventories remain separate; preserve all raw original content identities |
| Original pre/post | Save complete actual `identify_tree(original-pristine)` before/after return validation; require files and tree digest equal to the baseline and manifest original_pre. These describe authoritative/pristine preservation, separately from writable copy changes | | Original pre/post | Save complete actual `identify_tree(original-pristine)` before/after return validation; require files and tree digest equal to the baseline and manifest original_pre. These describe authoritative/pristine preservation, separately from writable copy changes |
| Original copy pre/post/retained | Raw `copy-pre.json`, `copy-post.json`, `retained-copy.json`; preserve exact actual bytes/hashes and bind continuity to those hashes | | Original copy pre/post/retained | Raw `copy-pre.json`, `copy-post.json`, `retained-copy.json`; preserve exact actual bytes/hashes in `identity.copy_pre`, `identity.copy_post`, `identity.retained_copy`. For both lifetimes bind `copy_pre_sha256` to the named pre record; retained runs also bind `retained_copy_sha256` to the named retained snapshot. Native reviewed runs use the same explicit state-record contract |
| Original source/launcher | Save manifest `tool_source` as `collector-source.json` and identify the actual bundled Windows collector; source commit/dirty/diff describes collector tooling, never recovered original source code | | Original source/launcher | Save manifest `tool_source` as `collector-source.json` and identify the actual bundled Windows collector; source commit/dirty/diff describes collector tooling, never recovered original source code |
| Original DxWnd/profile | Retain hashed actual `dxwnd-tool.json`, source profile and relocated export; explicit wrapper settings/limits are required | | Original DxWnd/profile | Retain hashed actual `dxwnd-tool.json`, source profile and relocated export; explicit wrapper settings/limits are required |
| Platform/version/GPU/driver/Vulkan/SDL | Actual raw queries and human device/version records; absent observations remain missing, never guessed | | Platform/version/GPU/driver/Vulkan/SDL | Actual raw queries and human device/version records; absent observations remain missing, never guessed |
+2
View File
@@ -96,6 +96,8 @@ class AcceptanceTests(unittest.TestCase):
('original_dxwnd', 'windows')]: ('original_dxwnd', 'windows')]:
value, root = self.fixture.receipt(cell['id'], obligation, kind, os_name) value, root = self.fixture.receipt(cell['id'], obligation, kind, os_name)
value['identity'] = copy.deepcopy(self.record['identity']) value['identity'] = copy.deepcopy(self.record['identity'])
value['continuity']['copy_pre_sha256'] = value['identity']['copy_pre']['sha256']
value['continuity']['retained_copy_sha256'] = value['identity']['retained_copy']['sha256']
if kind == 'original_dxwnd': if kind == 'original_dxwnd':
value['identity'] = self.original_record()['identity'] value['identity'] = self.original_record()['identity']
for path in self.record_root.iterdir(): for path in self.record_root.iterdir():
+26 -3
View File
@@ -89,8 +89,13 @@ class FidelityScenarios(unittest.TestCase):
duration_seconds=100)) duration_seconds=100))
identity = {} identity = {}
for key in ('executable', 'package', 'resources', 'launcher', 'source', 'original_pre', for key in ('executable', 'package', 'resources', 'launcher', 'source', 'original_pre',
'original_post', 'copy_pre', 'copy_post', 'dxwnd', 'dxwnd_config'): 'original_post', 'copy_pre', 'copy_post', 'retained_copy', 'dxwnd', 'dxwnd_config'):
identity[key] = dict(api.identify_file(d / 'setup.txt'), path='setup.txt') if key in ('copy_pre', 'retained_copy'):
path = d / (key + '.json')
path.write_text(json.dumps({'copy_state': key, 'session': d.name}))
else:
path = d / 'setup.txt'
identity[key] = dict(api.identify_file(path), path=path.name)
identity['source'].update(commit='a' * 40, dirty=False, diff_sha256='b' * 64) identity['source'].update(commit='a' * 40, dirty=False, diff_sha256='b' * 64)
required = api.required_events(p, c, obligation) required = api.required_events(p, c, obligation)
events = [dict(name=name, artifact='video.txt', media_seconds=index + 2, events = [dict(name=name, artifact='video.txt', media_seconds=index + 2,
@@ -117,7 +122,7 @@ class FidelityScenarios(unittest.TestCase):
'continuity': {'lifetime_id': d.name, 'departure_session_id': d.name, 'continuity': {'lifetime_id': d.name, 'departure_session_id': d.name,
'return_session_id': d.name, 'prerequisite_artifact': 'setup.txt', 'return_session_id': d.name, 'prerequisite_artifact': 'setup.txt',
'copy_pre_sha256': identity['copy_pre']['sha256'], 'copy_pre_sha256': identity['copy_pre']['sha256'],
'retained_copy_sha256': identity['copy_post']['sha256']}} 'retained_copy_sha256': identity['retained_copy']['sha256']}}
return value, d return value, d
def test_identified_metadata_cell_can_cover_one_obligation(self): def test_identified_metadata_cell_can_cover_one_obligation(self):
@@ -143,6 +148,24 @@ class FidelityScenarios(unittest.TestCase):
del value['continuity']['retained_copy_sha256'] del value['continuity']['retained_copy_sha256']
self.assertEqual(api.audit_scenarios(self.protocol(), [(value, root)])['accepted'], 0) self.assertEqual(api.audit_scenarios(self.protocol(), [(value, root)])['accepted'], 0)
def test_copy_continuity_requires_named_state_for_both_lifetimes(self):
for lifetime in ('fresh', 'retained'):
for digest in ('f' * 64, 'launcher', 'package'):
with self.subTest(lifetime=lifetime, digest=digest):
value, root = self.receipt(lifetime + '-natural-ordinary', 'dialogue-return')
self.assertEqual(api.audit_scenarios(self.protocol(), [(value, root)])['accepted'], 1)
value['continuity']['copy_pre_sha256'] = (
value['identity'][digest]['sha256'] if digest in value['identity'] else digest)
result = api.audit_scenarios(self.protocol(), [(value, root)])
self.assertEqual(result['accepted'], 0)
self.assertTrue(result['invalid'])
def test_retained_snapshot_cannot_bind_unrelated_identity(self):
for name in ('copy_pre', 'copy_post', 'launcher'):
value, root = self.receipt()
value['continuity']['retained_copy_sha256'] = value['identity'][name]['sha256']
self.assertEqual(api.audit_scenarios(self.protocol(), [(value, root)])['accepted'], 0)
def test_reset_timestamps_fail(self): def test_reset_timestamps_fail(self):
value, root = self.receipt() value, root = self.receipt()
value['events'][-1]['elapsed_seconds'] = 0 value['events'][-1]['elapsed_seconds'] = 0
+5 -6
View File
@@ -656,17 +656,16 @@ def _scenario_observation(protocol, cell, receipt):
if continuity.get('prerequisite_artifact') not in { if continuity.get('prerequisite_artifact') not in {
a['path'] for a in receipt['artifacts'] if a.get('role') == 'prerequisite'}: a['path'] for a in receipt['artifacts'] if a.get('role') == 'prerequisite'}:
raise ValueError('Visible identified prerequisite setup required') raise ValueError('Visible identified prerequisite setup required')
if not re.fullmatch('[0-9a-f]{64}', continuity.get('copy_pre_sha256', '')): if (not re.fullmatch('[0-9a-f]{64}', continuity.get('copy_pre_sha256', '')) or
raise ValueError('Missing pristine copy/package session identity') continuity['copy_pre_sha256'] != receipt['identity'].get('copy_pre', {}).get('sha256')):
raise ValueError('Copy pre state must bind the actual named copy_pre identity record')
if cell['lifetime'] == 'retained': if cell['lifetime'] == 'retained':
if (continuity.get('departure_session_id') != receipt['session_id'] or if (continuity.get('departure_session_id') != receipt['session_id'] or
continuity.get('return_session_id') != receipt['session_id'] or continuity.get('return_session_id') != receipt['session_id'] or
not re.fullmatch('[0-9a-f]{64}', continuity.get('retained_copy_sha256', ''))): not re.fullmatch('[0-9a-f]{64}', continuity.get('retained_copy_sha256', ''))):
raise ValueError('Retained departure/return/copy must preserve the same session') raise ValueError('Retained departure/return/copy must preserve the same session')
identified = {item.get('sha256') for item in receipt['identity'].values() if isinstance(item, dict)} if continuity['retained_copy_sha256'] != receipt['identity'].get('retained_copy', {}).get('sha256'):
if (continuity['copy_pre_sha256'] not in identified or raise ValueError('Retained copy state must bind the actual named retained_copy identity record')
continuity['retained_copy_sha256'] not in identified):
raise ValueError('Retained copy state must bind actual hashed identity records')
prerequisite = [e for e in events if e['artifact'] == continuity['prerequisite_artifact']] prerequisite = [e for e in events if e['artifact'] == continuity['prerequisite_artifact']]
names = [e['name'] for e in prerequisite] names = [e['name'] for e in prerequisite]
if ('prerequisite_departure' not in names or 'prerequisite_return' not in names or if ('prerequisite_departure' not in names or 'prerequisite_return' not in names or