fix: reconcile configured APT effect without retroactive acceptance and retain host reboot evidence
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -93,8 +93,19 @@ def main():
|
||||
operations = []; submit_contexts = {}
|
||||
for path in args.checkpoint:
|
||||
checkpoint, source = witness(path)
|
||||
if checkpoint.get('case') == 'reboot_last' and checkpoint.get('verified') is not True:
|
||||
final, final_source = witness(Path(path).with_name('result.json'))
|
||||
job = checkpoint['plan']['jobs'][0]
|
||||
require(final.get('verified') is True and final['result']['state'] == 'succeeded'
|
||||
and final['result']['job_id'] == job['job_id'] and final['result']['attempt_id'] == job['attempt_id']
|
||||
and final['result']['result']['evidence']['postconditions_passed'] is True
|
||||
and final['result']['result']['evidence']['reconciled_after_reboot'] is True
|
||||
and final['central']['grant_id'] == final['result']['result']['grant_id'],
|
||||
'separate verified reboot result is not bound to original checkpoint')
|
||||
source['completion'] = final_source
|
||||
checkpoint = dict(checkpoint, verified=True, audit=final['audit'], postapproval=final['postapproval'])
|
||||
require(checkpoint.get('verified') is True, 'native checkpoint not verified')
|
||||
plan = checkpoint['plan']; job = checkpoint['job']
|
||||
plan = checkpoint['plan']; job = checkpoint.get('job', plan['jobs'][0])
|
||||
require(hashlib.sha256(bytes(plan['plan_payload_bytes'])).hexdigest() == plan['plan_hash'], 'immutable plan bytes mismatch')
|
||||
require(plan['resolved_targets'] == [identity] and len(plan['jobs']) == 1
|
||||
and plan['jobs'][0] == job and job['agent_id'] == identity['agent_id']
|
||||
@@ -130,20 +141,34 @@ def main():
|
||||
and cloud.contract.timestamp(receipt['observed_at']) < context['valid_until'],
|
||||
'live existing-submit receipt not bound to selected operation')
|
||||
receipt = dict(source=source, observation=receipt)
|
||||
required_cases = {'hello','refresh_inventory','service_setup','service_start','service_stop','offline_wait'}
|
||||
successful_cases = {o['case'] for o in operations if o['operation']['execution_state'] == 'succeeded'
|
||||
and o['operation']['counts'] == dict(succeeded=1)}
|
||||
reference_complete = (required_cases <= successful_cases and receipt is not None
|
||||
and all(o['operation']['execution_state'] in ('succeeded','failed','cancelled') for o in operations))
|
||||
health = backend.call('monitoring.get_health', dict(tenant_id=cloud.TENANT))
|
||||
# Keep the health projection's honest timestamps/coverage without repeating
|
||||
# every device's full inventory in this bounded private reference report.
|
||||
health['items'] = [{k: d.get(k) for k in ('agent_id','asset_id','presence','health','quality',
|
||||
'completeness','last_contact_at','observed_at','received_at','source_id')}
|
||||
for d in health['items']]
|
||||
report = dict(schema_version=1, observed_at=cloud.contract.now().isoformat(),
|
||||
target=dict(tenant_id=cloud.TENANT,**identity), verified=reference_complete,
|
||||
scope='one explicitly selected real Linux Cloud VM; no multi-device concurrency proof',
|
||||
tenants=tenants, list_pages=pages, selected_targets=[identity], selected_device=device,
|
||||
other_devices=[{k: d.get(k) for k in ('agent_id', 'asset_id', 'presence', 'source_id', 'observed_at', 'received_at')}
|
||||
for d in devices if d['agent_id'] != identity['agent_id']],
|
||||
health=backend.call('monitoring.get_health', dict(tenant_id=cloud.TENANT)),
|
||||
health=health,
|
||||
operations=operations, live_submit_idempotency=receipt,
|
||||
idempotency_status='observed' if receipt else 'not_attached',
|
||||
no_new_plans_jobs_or_approvals=True)
|
||||
output.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
encoded = (json.dumps(report, indent=2)+'\n').encode()
|
||||
require(len(encoded) <= 1024*1024, 'bounded protected reference report size')
|
||||
fd = os.open(output, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600)
|
||||
with os.fdopen(fd, 'w') as stream:
|
||||
json.dump(report, stream, indent=2); stream.write('\n'); stream.flush(); os.fsync(stream.fileno())
|
||||
print('PASS stored MCP reference: one fixed Linux target, '+str(len(operations))+' existing operations; idempotency '+report['idempotency_status'])
|
||||
with os.fdopen(fd, 'wb') as stream:
|
||||
stream.write(encoded); stream.flush(); os.fsync(stream.fileno())
|
||||
print('Stored MCP reference saved: one fixed Linux target, '+str(len(operations))+' existing operations; verified='+str(reference_complete)+'; idempotency '+report['idempotency_status'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user