P08-03: 配置の通常操作受入

This commit is contained in:
Agent Control Runner
2026-10-14 04:21:06 +09:00
parent c2b59f04f9
commit 8e3d79d5f2
12 changed files with 543 additions and 54 deletions
+36 -5
View File
@@ -117,10 +117,17 @@ def make(base, source, checker):
folder.mkdir()
runtime = {k: {} for k in sorted(checker.RUNTIME_KEYS)}
runtime.update(world={'occupancies': [], 'bounds':{'min_x':-10,'max_y':10}}, construction={'facilities': [], 'jobs': []},
id_generator={'version':1,'counters':{'domain_event':7}},
domain_events={'version':1,'published_ids':[],'recent_events':[]},
facilities={'instances': []}, next_command_id=1,
command_queue={'processed': [], 'pending': [], 'in_flight': [], 'accepted': [], 'idempotency': {}})
model = {'schema_version': 1, 'clock': {'absolute_minute': 360, 'paused': True},
'game_state': {'resources': {'gold': 5000, 'materials': 50}}, 'systems': {'runtime': runtime}}
runtime['domain_events']['published_ids'] = ['domain_event.%012d' % n for n in range(1,8)]
runtime['domain_events']['recent_events'] = [
{'event_id':'domain_event.%012d' % n, 'event_type':'SYNTHETIC_HISTORY',
'absolute_minute':360, 'source_service':'synthetic', 'entity_ids':[],
'payload':{'ordinal':n}, 'causation_command_id':0} for n in range(1,8)]
target = [-8, 0, 0]
cost = {'reception': {'gold': 500, 'materials': 8}, 'guest_stairs': {'gold': 40, 'materials': 0}, 'standard_room':{'gold':350,'materials':5}}
rooms = 0
@@ -236,8 +243,10 @@ def make(base, source, checker):
budget = {'setup': 'diagnostic', 'costs': [{'definition': d, 'cost': cost[d]} for d in ('reception', 'reception', 'guest_stairs', 'guest_stairs')],
'needed': {'gold': 1080, 'materials': 16}, 'initial': {'gold': 5000, 'materials': 50}, 'deltas': {}}
put(folder/'writer-actions.json', {'setup': 'diagnostic', 'actions': actions, 'budget': budget})
snap('writer-checkpoint')
snap('reader-checkpoint')
snap('writer-presave')
snap('writer-formal-model')
snap('reader-formal-model')
formal_model = typed(model)
formal = folder/'formal'
formal.mkdir()
for member in checker.MEMBERS: (formal/member).write_text('synthetic '+member+'\n')
@@ -251,14 +260,36 @@ def make(base, source, checker):
'members':{n:{'sha256':sha(folder/name/n),'bytes':(folder/name/n).stat().st_size} for n in checker.MEMBERS}}
for name,suffix in [('formal',''),('formal.bak','.bak')]},
'slot_metadata':{'file':'formal-slot-metadata.json','sha256':sha(formal/'manifest.json')}})
for role,pid,op in [('writer',pids[0],'save'),('reader',pids[1],'load')]:
for role,pid,op in [('writer',pids[0],'save'),('reader',pids[1],'recovery')]:
returned = {'ok':True,'operation':op,'save_path':'user://saves/manual_ui',
'code':'OK','message':'synthetic result','duration_us':13,'runtime_duration_us':17,
'manifest':{'save_id':'synthetic-save','absolute_minute':360}}
if role == 'reader':
returned['selected'] = {'id':'formal','kind':'formal','generation':0}
expected = checker.expected_operation(formal_model,returned,
'SAVE_CHECKPOINT_SUCCEEDED' if role == 'writer' else 'SAVE_RECOVERY_LOADED')
for label in ('checkpoint','expected-operation','operation-actual'):
put(folder/(role+'-'+label+'.json'),expected)
(folder/(role+'-'+label+'.var')).write_bytes(json.dumps(expected,sort_keys=True).encode())
count = len(model['systems']['runtime']['domain_events']['recent_events'])
put(folder/(role+'-operation-comparison.json'), {'pid':pid,'delta_kind':'source_defined_notification',
'formal_model':role+'-formal-model','actual_model':role+'-checkpoint',
'expected_model':role+'-expected-operation','returned_result':typed(returned),
'saved_recent_count':count,'expected_recent_count':count+1,'actual_recent_count':count+1,
'whole_raw_equal':True})
stem = role+'-save-result-0001'
(folder/(stem+'.var')).write_bytes(b'synthetic raw Dictionary stand-in')
put(folder/(stem+'.json'), {'pid':pid,'operation':'runtime_operation',
'requested_path':'user://saves/manual_ui','absolute_path':absolute,'user_data_dir':profile,
'result':typed({'ok':True,'operation':op,'save_path':'user://saves/manual_ui'}),
'result':typed(returned),
'raw_sha256':sha(folder/(stem+'.var'))})
put(folder/(role+'-save-results.json'), {'pid':pid,'records':[stem]})
inspect_stem = role+'-save-result-0002'
(folder/(inspect_stem+'.var')).write_bytes(b'synthetic inspection Dictionary stand-in')
put(folder/(inspect_stem+'.json'), {'pid':pid,'operation':'formal_inspect',
'requested_path':'user://saves/manual_ui','absolute_path':absolute,'user_data_dir':profile,
'result':typed({'ok':True,'read_only':True,'snapshot':copy.deepcopy(model)}),
'raw_sha256':sha(folder/(inspect_stem+'.var'))})
put(folder/(role+'-save-results.json'), {'pid':pid,'records':[stem,inspect_stem]})
put(folder/'save.json', {'members': {n: sha(formal/n) for n in checker.MEMBERS},
'pid': pids[0], 'cell': target, 'instance_id': 'f4'})
row = {'id': 'resume_overlap', 'kind': 'build', 'position': position(target),