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

This commit is contained in:
Agent Control Runner
2026-10-15 00:32:39 +09:00
parent f5f85ae08c
commit d369d1c399
5 changed files with 175 additions and 12 deletions
+23 -8
View File
@@ -116,6 +116,9 @@ def expected_operation(formal, result, event_type):
recent['items'] = recent['items'][-256:]
return expected
def r09_reuse(index):
return index.get('commit') == R09_COMMIT
def png(data):
require(data.startswith(b'\x89PNG\r\n\x1a\n'), 'missing OS screenshot')
offset = 8; chunks = []; payload = b''
@@ -135,6 +138,7 @@ def png(data):
require(bool(zlib.decompress(payload)), 'empty OS screenshot')
except zlib.error as exc:
raise ValueError('invalid OS screenshot pixels') from exc
return struct.unpack('>II', data[16:24])
def input_map(root):
names = [SPEC, CONTRACT, 'AGENTS.md', RECORDER, RECORDER+'.uid',
@@ -633,21 +637,25 @@ def check(project_root, evidence_dir):
require(index['schema'] == 'p08-normal-placement-v1' and index['acceptance'] == 'pending', 'schema/acceptance')
require(index['collection_error'] is None, 'collection failed')
require(index['conditions'] == CONDITIONS, 'missing condition')
actual = {n: v['sha256'] for n, v in runner.source_refs(root).items()}
original = evidence
pins_path = root/R09_DOCS/'ROOT_NATIVE_R09_COLLECTION_PINS.json'
if pins_path.exists():
reuse = r09_reuse(index)
dimensions_path = root/R09_DOCS/'ROOT_R09_READONLY_IMAGE_DIMENSIONS.json'
if reuse:
require(pins_path.is_file() and dimensions_path.is_file(), 'R09 reuse candidate')
r09_applicability(root, index)
r09_runner_binding(evidence, index, load(pins_path))
original = r09_collection(evidence, index, load(pins_path))
r09_images(evidence, index, load(root/R09_DOCS/'ROOT_R09_READONLY_IMAGE_DIMENSIONS.json'), load(pins_path))
r09_images(evidence, index, load(dimensions_path), load(pins_path))
actual = index['source_map']
else:
actual = {n: v['sha256'] for n, v in runner.source_refs(root).items()}
require(index['source_map'] == actual, 'stale source')
require(index['inputs'] == input_map(root), 'stale input')
require(index['spec_sha256'] == SPEC_SHA == hashlib.sha256((root/SPEC).read_text().strip().encode()).hexdigest(), 'immutable spec')
require(index['marker_contract_sha256'] == sha(root/CONTRACT), 'stale marker')
require(re.fullmatch('[0-9a-f]{40}', index['commit']) is not None, 'commit')
if not pins_path.exists():
if not reuse:
require(index['commit'] == subprocess.check_output(['git','-C',str(root),'rev-parse','HEAD'],text=True).strip(), 'stale commit')
def artifact(name):
require(isinstance(name, str) and name and not Path(name).is_absolute() and '..' not in Path(name).parts, 'unsafe/missing artifact')
@@ -969,13 +977,20 @@ def check(project_root, evidence_dir):
and raw['tool_name'] and raw['tool_call_id'], 'fake OS provenance')
require(raw['events'] and observed['events'], 'missing OS events')
require(raw['collector_pid'] > 0 and raw['collector_pid'] not in os_pids, 'fake OS collector')
screen_dimensions = []
for key in ('screen_before', 'screen_after'):
require(ack[key] == folder+key.replace('_', '-')+'.png', 'R09 screenshot request binding')
data = artifact(ack[key]).read_bytes()
if pins_path.exists():
require(ack[key] == folder+key.replace('_', '-')+'.png', 'R09 screenshot request binding')
jpeg_dimensions(data)
if reuse:
dimensions = jpeg_dimensions(data)
elif data.startswith(b'\x89PNG\r\n\x1a\n'):
dimensions = png(data)
elif data.startswith(b'\xff\xd8'):
dimensions = jpeg_dimensions(data)
else:
png(data)
raise ValueError('missing OS screenshot')
screen_dimensions.append(dimensions)
require(screen_dimensions[0] == screen_dimensions[1] and all(v > 0 for v in screen_dimensions[0]), 'OS screenshot dimension mismatch')
if request['action'] == 'cell' and 'position' in row:
dispatch_gate(row['position'], observed['events'])
if row['id'] == 'pan_zoom':