feat(01-03): reconcile full-game capability and checkpoint coverage
Map all 33 requirements across six groups and reconcile 33 hashed source rows. Preserve startup current/history, unimplemented work and open native/reference acceptance; bind imported receipt identities and generate navigation.
This commit is contained in:
1 parent
fafbd05811
commit
4d07d60e2f
4 files changed
+4225
-10
No files matched your search
@@ -85,6 +85,14 @@ class LedgerTests(unittest.TestCase):
|
||||
self.assertTrue((Path(temporary) / 'review' / link['href']).is_file())
|
||||
self.assertIn('native Windows', str(nav['acceptance']))
|
||||
self.assertEqual(loaded['acceptance']['state'], 'open')
|
||||
self.assertEqual(len(loaded['ledger']['capabilities']), len(model['capabilities']))
|
||||
for exported_row in model['capabilities']:
|
||||
viewed = next(r for r in loaded['ledger']['capabilities'] if r['id'] == exported_row['id'])
|
||||
for key in ('current', 'history', 'scenario_ids', 'acceptance', 'discrepancies'):
|
||||
self.assertEqual(viewed[key], exported_row[key])
|
||||
self.assertTrue(all(link['validated_local'] for link in viewed['source_links']))
|
||||
self.assertTrue(all((Path(temporary) / 'review' / link['href']).is_file()
|
||||
for link in viewed['source_links']))
|
||||
|
||||
def test_empty_ledger_fails(self):
|
||||
with self.assertRaises(ValueError): self.api().validate_ledger(ledger(), ROOT)
|
||||
@@ -273,6 +281,59 @@ class LedgerTests(unittest.TestCase):
|
||||
artifact.write_text('tampered fixture log')
|
||||
with self.assertRaises(ValueError): api.validate_ledger(ledger(row), ROOT)
|
||||
|
||||
def test_receipt_identity_conflict_across_capabilities_rejected(self):
|
||||
a, b = capability('alpha'), capability('beta')
|
||||
self.api().validate_ledger(ledger(a, b), ROOT)
|
||||
b['evidence'][0]['method'] = 'Conflicting bytes under a shared receipt ID'
|
||||
with self.assertRaises(ValueError): self.api().validate_ledger(ledger(a, b), ROOT)
|
||||
|
||||
def test_component_and_inferred_categories_cannot_claim_native_execution(self):
|
||||
for kind in ('component', 'managed', 'synthetic', 'inferred'):
|
||||
with self.subTest(kind=kind):
|
||||
row = capability()
|
||||
row['evidence'][0]['evidence_kind'] = kind
|
||||
with self.assertRaises(ValueError): self.api().validate_ledger(ledger(row), ROOT)
|
||||
|
||||
def test_reconciliation_requires_actual_retained_source_link(self):
|
||||
model = json.loads(LEDGER.read_text())
|
||||
identifier = model['reconciliation'][0]['capability_ids'][0]
|
||||
row = next(row for row in model['capabilities'] if row['id'] == identifier)
|
||||
row['source_links'] = [link for link in row['source_links'] if link['path'] != 'docs/checkpoint/coverage.md']
|
||||
with self.assertRaises(ValueError): self.api().validate_ledger(model, ROOT)
|
||||
|
||||
def test_cli_full_model_rejects_unmapped_requirement_without_optional_flag(self):
|
||||
model = json.loads(LEDGER.read_text())
|
||||
for row in model['capabilities']:
|
||||
row['requirement_ids'] = [req for req in row['requirement_ids'] if req != 'EVID-03']
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
path = Path(temporary) / 'broken.json'
|
||||
path.write_text(json.dumps(model))
|
||||
result = subprocess.run([sys.executable, str(TOOL), 'validate', '--ledger', str(path)],
|
||||
capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertIn('Unmapped or unknown requirements', result.stderr)
|
||||
|
||||
def test_real_imported_receipt_reference_binds_bytes_scope_and_platform(self):
|
||||
from test_fidelity_review import fixture
|
||||
from fidelity_receipts import identify_file
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / 'artifacts') as temporary:
|
||||
receipt_path, receipt = fixture(Path(temporary), 'ledger')
|
||||
row = capability()
|
||||
record = row['evidence'][0]
|
||||
record.update(receipt_id=receipt['receipt_id'], evidence_kind='synthetic', historical=False,
|
||||
platform=receipt['platform'], scope=[receipt['scope']],
|
||||
receipt_path=receipt_path.relative_to(ROOT).as_posix(),
|
||||
content={'receipt_sha256': identify_file(receipt_path)['sha256']})
|
||||
row['targets'] = [dict(id='imported-test', **target(record))]
|
||||
self.api().validate_ledger(ledger(row), ROOT)
|
||||
for key, value in [('scope', ['wrong scope']),
|
||||
('platform', {'os':'wrong host','execution':'synthetic'}),
|
||||
('content', {'receipt_sha256':'0'*64})]:
|
||||
broken = copy.deepcopy(row)
|
||||
broken['evidence'][0][key] = value
|
||||
broken['targets'] = [dict(id='imported-test', **target(broken['evidence'][0]))]
|
||||
with self.assertRaises(ValueError): self.api().validate_ledger(ledger(broken), ROOT)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user