P23-03: 生活の観察

This commit is contained in:
Agent Control Runner
2026-10-15 10:03:36 +09:00
parent 55c29f1192
commit 0b7727a66c
4 changed files with 177 additions and 8 deletions
+21 -1
View File
@@ -314,6 +314,25 @@ def compare_actor_rows(snapshot, report, root=ROOT):
def elevator_report(snapshot):
saved = snapshot['systems']['runtime']['elevators']
# ElevatorService.restore_snapshot validates this exact trip shape (412-438).
# QUEUED means no cabin seat yet, not an absent shaft assignment.
configs = {shaft['config']['shaft_id']: shaft['config'] for shaft in saved['shafts']}
for trip in saved['trips']:
keys = {'actor_id', 'request_id', 'shaft_id', 'connector_id', 'from', 'to',
'enqueued_at', 'state'}
if 'companion_id' in trip:
keys.add('companion_id')
require(isinstance(trip['companion_id'], str) and trip['companion_id'],
'invalid elevator companion identity')
require(set(trip) == keys, 'exact elevator trip keys')
require(trip['shaft_id'] in configs, 'elevator trip shaft attribution')
config = configs[trip['shaft_id']]
require(trip['from'] != trip['to'] and trip['from'] in config['stops']
and trip['to'] in config['stops'], 'elevator trip stops')
low, high = sorted((trip['from'][1], trip['to'][1]))
require(trip['connector_id'] == f"{trip['shaft_id']}.link.{low}.{high}",
'elevator trip connector attribution')
require(trip['state'] in ('QUEUED', 'BOARDED'), 'elevator trip state')
rows = []
for shaft in saved['shafts']:
row = copy.deepcopy(shaft)
@@ -325,7 +344,8 @@ def elevator_report(snapshot):
floor = shaft['phase_origin_floor'] + (destination - shaft['phase_origin_floor']) * progress
row.update(visual_floor=floor, passenger_count=len(shaft['boarded']),
passenger_ids=copy.deepcopy(shaft['boarded']),
waiting_count=sum(t['shaft_id'] == shaft['shaft_id'] and t['state'] == 'QUEUED'
# get_report() merges config before counting (345-359).
waiting_count=sum(t['shaft_id'] == row['shaft_id'] and t['state'] == 'QUEUED'
for t in saved['trips']))
rows.append(row)
# WorldPreview sorts its report's trip copy for queue placement.