test(01-06): require full Linux matrix continuity and resume history

This commit is contained in:
UnixNight committed 2026-11-13 11:57:23 -05:00
1 parent 16f5e126be
commit e17cfbebe3
1 file changed
+65
+65
View File
@@ -151,6 +151,71 @@ class CaptureTests(unittest.TestCase):
with self.assertRaises(ValueError): self.execute() with self.assertRaises(ValueError): self.execute()
with self.assertRaises(ValueError): self.execute(output=self.package / 'capture') with self.assertRaises(ValueError): self.execute(output=self.package / 'capture')
def matrix(self, records=(), **kwargs):
api = self.api()
self.assertTrue(hasattr(api, 'matrix'), 'Linux matrix must enumerate and preserve all forty obligations')
return api.matrix(receipts.read_json(ROOT / 'docs/evidence/scenarios.json'), records, **kwargs)
def test_matrix_enumerates_eight_cells_forty_open_obligations(self):
result = self.matrix(dependency={'receipt_id': 'failed-preflight', 'reasons': ['No real display']})
self.assertEqual(len(result['cells']), 8)
self.assertEqual(sum(len(c['obligations']) for c in result['cells']), 40)
self.assertTrue(all(o['state'] == 'open' and o['dependencies'] for c in result['cells'] for o in c['obligations']))
def test_matrix_preserves_dialogue_lifetime_and_input_procedures(self):
result = self.matrix()
for cell in result['cells']:
self.assertIn(cell['lifetime'], ('fresh', 'retained'))
self.assertIn(cell['dialogue'], ('natural', 'skipped'))
self.assertIn(cell['input'], ('ordinary', 'edge'))
for obligation in cell['obligations']:
if cell['dialogue'] == 'skipped' and obligation['id'] == 'dialogue-return':
self.assertIn('dialogue_skip', obligation['required_events'])
if cell['input'] == 'edge' and obligation['id'] == 'continuous':
self.assertIn('held_return', obligation['required_events'])
def test_continuous_route_cannot_be_replaced_by_focused_capture(self):
self.execute()
receipt = self.api().collect(self.run, probe=self.probe)
result = self.matrix([(receipt, self.run)])
cell = next(c for c in result['cells'] if c['id'] == receipt['case_id'])
continuous = next(o for o in cell['obligations'] if o['id'] == 'continuous')
focused = next(o for o in cell['obligations'] if o['id'] == 'dialogue-return')
self.assertFalse(continuous['attempts'])
self.assertEqual(focused['attempts'][0]['receipt_id'], receipt['receipt_id'])
self.assertEqual(continuous['route'], ['lab', 'VR04', 'lab', 'outside'])
def test_resume_preserves_failed_history_and_requires_new_launch(self):
self.settings['display'] = ''
self.execute()
first = self.api().collect(self.run, probe=self.probe)
previous = self.matrix([(first, self.run)])
new_run = self.root / 'test-second'
self.execute(output=new_run, session_id='test-second')
second = self.api().collect(new_run, probe=self.probe)
resumed = self.matrix([(second, new_run)], previous=previous)
attempts = next(o['attempts'] for c in resumed['cells'] for o in c['obligations'] if o['attempts'])
self.assertEqual([a['session_id'] for a in attempts], ['test-launch', 'test-second'])
second['session_id'] = first['session_id']
with self.assertRaises(ValueError): self.matrix([(second, new_run)], previous=previous)
def test_collection_exposes_shared_scenario_identity_without_claiming_continuity(self):
self.execute()
receipt = self.api().collect(self.run, probe=self.probe)
self.assertEqual(receipt.get('obligation_id'), 'dialogue-return')
self.assertEqual(receipt['clocks'].get('clock_id'), 'test-launch-monotonic')
matrix = self.matrix([(receipt, self.run)])
self.assertEqual(matrix['accepted'], 0)
self.assertFalse(matrix['complete'])
def test_disconnected_or_missing_retained_setup_remains_open(self):
self.execute(case_id='retained-skipped-edge', scope='continuous')
receipt = self.api().collect(self.run, probe=self.probe)
result = self.matrix([(receipt, self.run)])
attempted = next(o for c in result['cells'] for o in c['obligations'] if o['attempts'])
self.assertEqual(attempted['state'], 'open')
self.assertTrue(any('scenario' in x.lower() for x in attempted['dependencies']))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()