Files
ARCADIA-Studio/harness/experiments/ordinary-source8-20260925/inspect_runtime.py
T

511 lines
30 KiB
Python

"""Read-only ordinary source8 gate reconciliation. Run only after the final gates, integration suites and CLI captures.
Usage: python -I -B inspect_runtime.py FULL_SOURCE_SHA PIN7 EXPECTED_NEW_COUNT
Only Git read commands are executed; Cargo, launchers and binaries are never run.
"""
from pathlib import Path
import hashlib
import io
import json
import re
import subprocess
import sys
import zipfile
if sys.flags.optimize:
raise SystemExit('Optimized Python forbidden: verification uses assertions')
assert len(sys.argv) == 4
source, stem, expected_added = sys.argv[1], sys.argv[2], int(sys.argv[3])
assert re.fullmatch(r'[0-9a-f]{40}', source)
assert stem == source[:7]
assert 1 <= expected_added <= 100
assert expected_added == 6, 'Selected ordinary compatibility contract adds six tests'
base = Path(__file__).resolve().parents[2]
root = base / '.local/as3batch'
directory = base / '.local/ordinary-source8-gates-20260925'
prior = base / '.local/analysis-output-acceptance-gates-20260925'
destination = Path(__file__).with_name('ORDINARY-RUNTIME-READBACK.json')
assert not destination.exists(), 'Preserve prior readback; do not overwrite'
BASELINE = 'edf096cd33350865ecfc3c65ec266a6c0d3c4000'
ARCHIVE_SHA = '2f5e0c5257eba11908b60e02b76d529fcd53f11edd057c859d3cb1b34f41d7c4'
COMPONENT = '0c07f53ab517626f536f79dbaa2885a587bf1db7'
FINAL_LAUNCHER = 'c0126c93f371c6f8f2b38daace73d06e1cac741021faeff10f18d34628eca6c8'
sha = lambda raw: hashlib.sha256(raw).hexdigest()
def git(*args):
return subprocess.check_output(['git', '--no-replace-objects', *args], cwd=root)
def within(folder, relative):
candidate = (folder / relative).resolve()
assert candidate.is_relative_to(folder.resolve()), relative
return candidate
def receipt(folder, name):
raw_receipt = (folder / (name + '.result.json')).read_bytes()
data = json.loads(raw_receipt)
raw = (folder / (name + '.log')).read_bytes()
assert data['log_sha256'] == sha(raw)
return data, raw, raw_receipt
def outcomes(raw):
rows = re.findall(r'^test ([^\r\n]+) \.\.\. (ok|FAILED|ignored)\r?$', raw.decode(), re.M)
assert len(rows) == len(dict(rows)), 'Duplicate runtime name'
return rows
def members(raw):
names = re.findall(r'^([^\r\n]+): test\r?$', raw.decode(), re.M)
assert len(names) == len(set(names)), 'Duplicate listing name'
return names
def failure_blocks(raw):
# Preserve every byte of block whitespace/body except the numeric thread identifier.
rows = re.findall(rb'^---- ([^\r\n]+) stdout ----\r?\n(.*?)(?=^---- |^failures:|\Z)',
raw, re.M | re.S)
assert len(rows) == len(dict(rows)), 'Duplicate failure block'
return {name.decode(): re.sub(rb"(?m)^(thread '[^\r\n]*') \(\d+\) panicked",
rb'\1 (<PID>) panicked', body) for name, body in rows}
# Anchor baseline local full/list/fmt logs AND receipts to the immutable locally committed ZIP (server publication is blocked).
archive_raw = (base / 'harness/experiments/analysis-output-acceptance-20260925/evidence.zip').read_bytes()
assert sha(archive_raw) == ARCHIVE_SHA
baseline = {}
with zipfile.ZipFile(io.BytesIO(archive_raw)) as archive:
names = archive.namelist()
assert len(names) == len(set(names))
for mode in ('full', 'list', 'fmt'):
name = f'acceptance-{mode}-edf096c-1'
data, raw, raw_receipt = receipt(prior, name)
assert data['source'] == data['head_after'] == BASELINE
for suffix, content in [('.log', raw), ('.result.json', raw_receipt)]:
matches = [n for n in names if n == name + suffix or n.endswith('/' + name + suffix)]
assert len(matches) == 1, (name, suffix, matches)
assert archive.read(matches[0]) == content
baseline[mode] = (data, raw)
old, old_raw = baseline['full']
old_rows = outcomes(old_raw)
assert old_rows == [tuple(x) for x in old['outcomes']]
assert len(old_rows) == 292 and old['exit'] == 101
assert sum(v == 'ok' for _, v in old_rows) == 276
assert sum(v == 'FAILED' for _, v in old_rows) == 16
old_out = dict(old_rows)
renames = {
'language::analysis_source::declarations::tests::inherited_version_root_and_short_word_contracts_do_not_enable_public8':
'language::analysis_source::declarations::tests::inherited_version_root_and_short_word_contracts_do_not_enable_public_typed8',
'language::analysis_source::tests::public_source_headers_and_existing_numeric_token_controls_are_unchanged':
'language::analysis_source::tests::public_ordinary_source8_preserves_typed_refusal_and_numeric_controls',
}
assert set(renames) <= set(old_out) and not set(renames.values()) & set(old_out)
mapped_old = {renames.get(name, name): status for name, status in old_out.items()}
assert len(mapped_old) == len(old_out)
old_listing = members(baseline['list'][1])
assert old_listing == baseline['list'][0]['listing_members']
assert baseline['list'][0]['exit'] == 0 and set(old_listing) == set(old_out)
assert baseline['fmt'][0]['exit'] == 1
assert git('rev-parse', 'HEAD').decode().strip() == source
assert not git('status', '--porcelain', '--untracked-files=no').strip()
scope = ['Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml', '.cargo', 'build', 'crates',
'assets', 'docs', 'examples', 'harness/fixtures', 'vendor']
paths = git('ls-tree', '-r', '--name-only', source, *scope).decode().splitlines()
blobs = subprocess.check_output(['git', '--no-replace-objects', 'cat-file', '--batch'], cwd=root,
input=''.join(f'{source}:{p}\n' for p in paths).encode())
offset, expected_inputs = 0, []
for path in paths:
end = blobs.index(b'\n', offset)
_, kind, count = blobs[offset:end].split()
count = int(count)
raw = blobs[end + 1:end + 1 + count]
assert kind == b'blob' and within(root, path).read_bytes() == raw, path
expected_inputs.append({'path': path, 'bytes': count, 'sha256': sha(raw)})
offset = end + count + 2
assert offset == len(blobs)
changed_paths = git('diff', '--name-only', COMPONENT, source).decode().splitlines()
assert sorted(changed_paths) == ['crates/oa-core/tests/r3_migration.rs', 'harness/ordinary-source8-compatibility-implementation-20260925.md']
assert git('ls-tree', '-r', '--name-only', COMPONENT, *scope).decode().splitlines() == paths
component_inputs = []
for item in expected_inputs:
if item['path'] == 'crates/oa-core/tests/r3_migration.rs':
content = git('show', COMPONENT + ':' + item['path'])
component_inputs.append({'path': item['path'], 'bytes': len(content), 'sha256': sha(content)})
else:
component_inputs.append(item)
assert [a['path'] for a, b in zip(component_inputs, expected_inputs) if a != b] == ['crates/oa-core/tests/r3_migration.rs']
assert len(expected_inputs) == 560 and len(component_inputs) == 560
prefix = ['cargo', 'test', '--locked', '--offline', '-p', 'oa-core', '--lib']
commands = {
'focused': prefix + ['ordinary_source8', '--', '--test-threads=1'],
'full': prefix + ['--', '--test-threads=1'],
'list': prefix + ['--', '--list'],
'clippy': ['cargo', 'clippy', '--locked', '--offline', '-p', 'oa-core', '--all-targets', '--', '-D', 'warnings'],
'fmt': ['cargo', 'fmt', '--all', '--', '--check'],
}
expected_env = baseline['full'][0]['environment']
assert expected_env['CARGO_BUILD_JOBS'] == '1' and expected_env['CARGO_INCREMENTAL'] == '0'
for key in ('RUSTFLAGS', 'RUSTC', 'RUSTUP_TOOLCHAIN', 'ARCADIA_CODEC_LIFECYCLE_PHASE', 'RUST_MIN_STACK'):
assert expected_env[key] is None
current_env = expected_env.copy()
verified, all_receipts, raw_logs = {}, {}, {}
artifact_identity = launcher_identity = None
for mode, command in commands.items():
name = f'ordinary-{mode}-{COMPONENT[:7]}-1'
data, raw, receipt_raw = receipt(directory, name)
assert data['source'] == data['head_after'] == COMPONENT
assert data['mode'] == mode and data['command'] == command
assert data['invocation'] == 'cargo' and data['test_target'] is None
assert data['filter'] == ('ordinary_source8' if mode == 'focused' else '')
assert not data['changed_inputs'] and not data['verification_failures']
assert data['cwd'] == str(root) and data['environment'] == current_env
manifest_raw = within(directory, data['inputs']).read_bytes()
assert sha(manifest_raw) == data['inputs_sha256']
assert json.loads(manifest_raw) == {'source': COMPONENT, 'inputs': component_inputs}
launcher = within(directory, data['launcher_copy']).read_bytes()
assert sha(launcher) == data['launcher_sha256'] == data['launcher_sha256_after']
assert COMPONENT.encode() in launcher
if launcher_identity is None:
launcher_identity = sha(launcher)
assert sha(launcher) == launcher_identity, 'Unexpected mixed launchers: review explicitly'
assert sha(launcher) == 'ba5b84b6eae0e5c24dc2eb52b4cc20b5ba648261b36fd72edddd5b2fbf791765', 'Review any final launcher successor before execution'
rows = outcomes(raw)
assert rows == [tuple(x) for x in data['outcomes']]
listing = members(raw) if mode == 'list' else []
assert listing == data['listing_members'] and len(listing) == data['listing_count']
if mode in ('focused', 'full'):
counts = tuple(sum(v == state for _, v in rows) for state in ('ok', 'FAILED', 'ignored'))
summary = re.findall(r'^test result: (ok|FAILED)\. (\d+) passed; (\d+) failed; (\d+) ignored; 0 measured; (\d+) filtered out;', raw.decode(), re.M)
assert len(summary) == 1 and tuple(map(int, summary[0][1:4])) == counts
assert summary[0][0] == ('FAILED' if counts[1] else 'ok')
assert int(summary[0][4]) == (291 if mode == 'focused' else 0)
else:
assert not rows
assert data['exit'] == {'focused': 0, 'full': 0, 'list': 0, 'clippy': 0, 'fmt': 1}[mode]
assert len(data['artifacts']) == (1 if mode in ('focused', 'full', 'list') else 0)
for artifact in data['artifacts']:
path = Path(artifact['path'])
assert path.resolve().is_relative_to(Path(expected_env['CARGO_TARGET_DIR']).resolve())
actual = path.read_bytes()
assert len(actual) == artifact['bytes'] and sha(actual) == artifact['sha256']
assert str(path).replace('\\', '/') in raw.decode().replace('\\', '/')
if artifact_identity is None:
artifact_identity = artifact
assert artifact == artifact_identity, 'Test/list artifact mismatch'
all_receipts[mode], raw_logs[mode] = data, raw
verified[name] = {'source': COMPONENT, 'exit': data['exit'], 'outcomes': len(rows),
'listing': len(listing), 'log_sha256': sha(raw), 'result_sha256': sha(receipt_raw),
'inputs_sha256': sha(manifest_raw), 'launcher_sha256': sha(launcher)}
new_out = dict(all_receipts['full']['outcomes'])
assert len(new_out) == 292 + expected_added
assert not set(renames) & set(new_out), 'Old names must be replaced only by the two exact authorized names'
assert all(new_out.get(k) == 'ok' for k in mapped_old), 'Every prior mapped name must pass, including all 16 former failures'
added = set(new_out) - set(mapped_old)
assert len(added) == expected_added
assert all(new_out[k] == 'ok' and 'ordinary_source8' in k for k in added)
focused_control = 'language::analysis_source::tests::public_ordinary_source8_preserves_typed_refusal_and_numeric_controls'
assert focused_control in renames.values() and focused_control not in added
assert set(dict(all_receipts['focused']['outcomes'])) == added | {focused_control}
assert len(all_receipts['focused']['outcomes']) == 7
assert all(status == 'ok' for _, status in all_receipts['focused']['outcomes'])
assert set(all_receipts['list']['listing_members']) == set(new_out)
old_blocks = failure_blocks(old_raw)
assert len(old_blocks) == 16 and set(old_blocks) == {k for k, v in old_out.items() if v == 'FAILED'}
assert not failure_blocks(raw_logs['full'])
assert all(value == 'ok' for value in new_out.values())
assert raw_logs['fmt'] == baseline['fmt'][1]
def additional(name, mode, command, target=None, selected_filter='', *, checkpoint=COMPONENT, exit_code=0, artifact_count=1, current_artifact=True, allow_failures=False):
data, raw, raw_receipt = receipt(directory, name)
assert data['source'] == data['head_after'] == checkpoint
assert data['mode'] == mode and data['command'] == command
assert data['filter'] == selected_filter and data['test_target'] == target
assert data['invocation'] == 'cargo' and data['cwd'] == str(root)
assert data['environment'] == current_env and data['exit'] == exit_code
assert not data['changed_inputs']
assert not data['verification_failures'] or allow_failures
manifest_raw = within(directory, data['inputs']).read_bytes()
assert sha(manifest_raw) == data['inputs_sha256']
assert json.loads(manifest_raw) == {'source': checkpoint, 'inputs': expected_inputs if checkpoint == source else component_inputs}
launcher = within(directory, data['launcher_copy']).read_bytes()
assert sha(launcher) == data['launcher_sha256'] == data['launcher_sha256_after'] == (FINAL_LAUNCHER if checkpoint == source else launcher_identity)
assert outcomes(raw) == [tuple(x) for x in data['outcomes']]
assert len(data['artifacts']) == artifact_count
artifact = data['artifacts'][0] if artifact_count else None
if artifact is not None and current_artifact:
path = Path(artifact['path'])
assert path.resolve().is_relative_to(Path(current_env['CARGO_TARGET_DIR']).resolve())
actual = path.read_bytes()
assert len(actual) == artifact['bytes'] and sha(actual) == artifact['sha256']
verified[name] = {'result_sha256': sha(raw_receipt), 'log_sha256': sha(raw),
'inputs_sha256': sha(manifest_raw), 'artifact': artifact}
return data, raw
suites = {
'source_project': '', 'source_identity_updates': '', 'source_nested_updates': '',
'source_files': '', 'r3_migration': '', 'review_regressions': 'checked_save_',
'source7_contract': 'source7_source_bundle_migration_is_token_only_and_new_link_stays_with_caller',
}
integration_counts = {}
for target, selected_filter in suites.items():
selected = {}
for mode in ('integration-list', 'integration-suite'):
command = ['cargo', 'test', '--locked', '--offline', '-p', 'oa-core', '--test', target]
if selected_filter:
command.append(selected_filter)
command += ['--', '--list' if mode == 'integration-list' else '--test-threads=1']
if target == 'source7_contract':
command.append('--exact')
checkpoint = source if target == 'r3_migration' else COMPONENT
data, raw = additional(f'ordinary-{mode}-{target}-{checkpoint[:7]}-1', mode, command, target, selected_filter, checkpoint=checkpoint)
assert Path(data['artifacts'][0]['path']).name.startswith(target + '-')
running = re.findall(r'Running [^\r\n]+ \(([^\r\n]+\.exe)\)', raw.decode())
assert len(running) == 1
assert (root / running[0]).resolve() == Path(data['artifacts'][0]['path']).resolve()
listed = members(raw) if mode == 'integration-list' else []
assert data['listing_members'] == listed and data['listing_count'] == len(listed)
if mode == 'integration-list':
assert listed and not outcomes(raw)
else:
rows = outcomes(raw)
assert rows and all(status == 'ok' for _, status in rows)
assert not failure_blocks(raw)
summary = re.findall(r'^test result: ok\. (\d+) passed; 0 failed; 0 ignored; 0 measured; \d+ filtered out;', raw.decode(), re.M)
assert summary == [str(len(rows))]
selected[mode] = data
listing, suite = selected['integration-list'], selected['integration-suite']
assert listing['artifacts'] == suite['artifacts']
assert set(listing['listing_members']) == {name for name, _ in suite['outcomes']}
if target == 'review_regressions':
assert set(listing['listing_members']) == {
'checked_save_returns_exact_bytes_and_accepts_unchanged_external_content',
'checked_save_rejects_external_changes_and_preserves_their_exact_bytes',
'checked_save_rejects_external_deletion_without_recreating_the_file'}
if target == 'source7_contract':
assert listing['listing_members'] == [selected_filter]
integration_counts[target] = len(suite['outcomes'])
old_r3 = {}
for mode in ('integration-list', 'integration-suite'):
command = ['cargo', 'test', '--locked', '--offline', '-p', 'oa-core', '--test', 'r3_migration',
'--', '--list' if mode == 'integration-list' else '--test-threads=1']
data, raw = additional(f'ordinary-{mode}-r3_migration-0c07f53-1', mode, command, 'r3_migration',
exit_code=0 if mode == 'integration-list' else 101,
current_artifact=False, allow_failures=mode == 'integration-suite')
if mode == 'integration-list':
assert len(members(raw)) == 5 and members(raw) == data['listing_members']
assert data['listing_count'] == 5 and not outcomes(raw)
else:
assert data['verification_failures'] == ['Every selected integration outcome must actually pass',
'Expected one complete all-passed selected integration summary']
rows = outcomes(raw)
assert len(rows) == 5 and sum(status == 'ok' for _, status in rows) == 4
assert {name for name, status in rows if status == 'FAILED'} == {'frozen_v4_json_and_source_preserve_the_old_review_without_fabricating_semantics'}
assert set(failure_blocks(raw)) == {'frozen_v4_json_and_source_preserve_the_old_review_without_fabricating_semantics'}
assert sha(raw) == 'ee55320de5e208beb921ce219afb38db7b27c86cd64d176837c952b803a48582'
assert re.findall(r'^test result: FAILED\. (\d+) passed; (\d+) failed; (\d+) ignored; 0 measured; (\d+) filtered out;', raw.decode(), re.M) == [('4', '1', '0', '0')]
old_r3[mode] = data
assert old_r3['integration-list']['artifacts'] == old_r3['integration-suite']['artifacts']
assert set(old_r3['integration-list']['listing_members']) == {name for name, _ in old_r3['integration-suite']['outcomes']}
new_r3_list, _ = receipt(directory, f'ordinary-integration-list-r3_migration-{stem}-1')[:2]
assert set(new_r3_list['listing_members']) == set(old_r3['integration-list']['listing_members'])
for mode in ('clippy', 'fmt'):
data, raw = additional(f'ordinary-{mode}-{stem}-1', mode, commands[mode], checkpoint=source,
exit_code=0 if mode == 'clippy' else 1, artifact_count=0)
assert not outcomes(raw) and not data['listing_members'] and data['listing_count'] == 0
if mode == 'fmt':
assert raw == baseline['fmt'][1] == raw_logs['fmt']
build_command = ['cargo', 'build', '--locked', '--offline', '-p', 'oa-cli', '--bin', 'arcadia', '--message-format=json']
build, build_raw = additional(f'ordinary-cli-build-{COMPONENT[:7]}-1', 'cli-build', build_command)
assert not build['outcomes'] and build['listing_members'] == [] and build['listing_count'] == 0
emitted = []
for line in build_raw.splitlines():
try:
row = json.loads(line)
except (json.JSONDecodeError, UnicodeDecodeError):
continue
if row.get('reason') == 'compiler-artifact' and row.get('target', {}).get('name') == 'arcadia' and row.get('executable'):
assert row['target']['kind'] == ['bin'] and not row['profile']['test']
emitted.append(row['executable'])
assert len(emitted) == 1 and Path(emitted[0]).resolve() == Path(build['artifacts'][0]['path']).resolve()
original = {
'project.arcadia': '// \u96e8\r\narcadia 8;\r\nproject p "Project" id "00000000-0000-0000-0000-000000000001" {\r\ninclude "participants.arcadia"; include "children.arcadia";\r\n}\r\n',
'participants.arcadia': '// @team remains documentation\r\noa_entity team "Team @team" id "00000000-0000-0000-0000-000000000002" {}\r\n',
'children.arcadia': 'oa_entity child "Child" id "00000000-0000-0000-0000-000000000003" { parent @team; }\r\n',
}
expected_after = {
'participants.arcadia': '// @team remains documentation\r\noa_entity rescue_team "Team @team" id "00000000-0000-0000-0000-000000000002" {}\r\n',
'children.arcadia': 'oa_entity child "Child" id "00000000-0000-0000-0000-000000000003" { parent @rescue_team; }\r\n',
}
inventory = {name: {'bytes': len(text.encode()), 'sha256': sha(text.encode())} for name, text in original.items()}
fixture = directory / f'cli-fixture-{COMPONENT[:7]}'
assert sorted(p.relative_to(fixture).as_posix() for p in fixture.rglob('*')) == sorted(original)
for name, text in original.items():
assert (fixture / name).read_bytes() == text.encode()
cli_launcher_hash = None
for operation in ('check', 'rename-alias'):
name = f'ordinary-cli-{operation}-{COMPONENT[:7]}-1'
record_raw = (directory / (name + '.cli.json')).read_bytes()
data = json.loads(record_raw)
stdout = (directory / (name + '.stdout.json')).read_bytes()
stderr = (directory / (name + '.stderr.txt')).read_bytes()
assert data['stdout_sha256'] == sha(stdout) and data['stderr_sha256'] == sha(stderr)
assert data['source'] == COMPONENT and data['build_artifact'] == build['artifacts'][0]
assert data['environment'] == current_env and data['cwd'] == str(root)
assert data['inputs'] == build['inputs'] and data['inputs_sha256'] == build['inputs_sha256']
assert not data['changed_inputs'] and not data['verification_failures']
assert data['exit'] == 0 and stderr == b''
assert data['expected_input_inventory'] == data['after_inventory'] == inventory
entry = str(fixture / 'project.arcadia')
command = [build['artifacts'][0]['path'], operation, entry]
if operation == 'rename-alias':
command += ['team', 'rescue_team']
command.append('--json')
assert data['argv'] == command
launcher = within(directory, data['launcher_copy']).read_bytes()
assert sha(launcher) == data['launcher_sha256']
if cli_launcher_hash is None:
cli_launcher_hash = sha(launcher)
assert sha(launcher) == cli_launcher_hash
assert cli_launcher_hash == '308fdd08011a57ccdf896868c6abd34d2e5c7637a95bfe0d8fccb456439dbd5d'
report = json.loads(stdout)
expected = {'format_version': 1, 'entry': entry, 'operation': operation,
'status': 'checked' if operation == 'check' else 'preview',
'exit_code': 0, 'written': False, 'diagnostics': [],
'identities_to_stabilize': 0, 'migration': None}
for key, value in expected.items():
assert key in report and report[key] == value
if operation == 'check':
assert report['changes'] == []
else:
assert [r['path'] for r in report['changes']] == ['children.arcadia', 'participants.arcadia']
for change in report['changes']:
path = change['path']
assert change['before'] == original[path] and change['after'] == expected_after[path]
for marker, text in [('-', original[path]), ('+', expected_after[path])]:
assert marker + next(line for line in text.splitlines() if line.startswith('oa_entity')) in change['diff']
verified[name] = {'receipt_sha256': sha(record_raw), 'stdout_sha256': sha(stdout),
'stderr_sha256': sha(stderr), 'launcher_sha256': sha(launcher)}
# Preserve and account for the actual first failed focused run, not an invented baseline.
initial, initial_raw, initial_receipt = receipt(directory, 'ordinary-focused-33b86a4-1')
assert initial['source'] == initial['head_after'] == '33b86a4d6b4bc1b156a93ae3596fe0ad7b4dbbe5'
assert initial['exit'] == 101 and not initial['changed_inputs']
initial_rows = outcomes(initial_raw)
assert initial_rows == [tuple(row) for row in initial['outcomes']]
assert len(initial_rows) == 6 and sum(v == 'ok' for _, v in initial_rows) == 5
assert [n for n, v in initial_rows if v == 'FAILED'] == ['language::ordinary_source8::current_formatter_roundtrips_complete_ordinary_examples_and_history']
assert set(dict(initial_rows)) == added
assert initial['command'] == commands['focused'] and initial['environment'] == current_env
assert not initial['verification_failures']
initial_launcher = within(directory, initial['launcher_copy']).read_bytes()
assert sha(initial_launcher) == initial['launcher_sha256'] == initial['launcher_sha256_after'] == '6e2fad2fff3066861a42f85ab6c3ada8b4c8954075fb402e555c5f686dae840b'
initial_manifest_raw = within(directory, initial['inputs']).read_bytes()
assert sha(initial_manifest_raw) == initial['inputs_sha256']
initial_manifest = json.loads(initial_manifest_raw)
assert initial_manifest['source'] == initial['source']
initial_paths = git('ls-tree', '-r', '--name-only', initial['source'], *scope).decode().splitlines()
assert initial_paths == [item['path'] for item in initial_manifest['inputs']]
initial_blobs = subprocess.check_output(['git', '--no-replace-objects', 'cat-file', '--batch'], cwd=root,
input=''.join(f"{initial['source']}:{p}\n" for p in initial_paths).encode())
offset = 0
for item in initial_manifest['inputs']:
end = initial_blobs.index(b'\n', offset)
_, kind, size = initial_blobs[offset:end].split()
size = int(size)
raw = initial_blobs[end + 1:end + 1 + size]
assert kind == b'blob' and size == item['bytes'] and sha(raw) == item['sha256']
offset = end + size + 2
assert offset == len(initial_blobs)
assert b'assertion failed: !example.traces.is_empty()' in initial_raw
initial_failure = {'source': initial['source'], 'receipt_sha256': sha(initial_receipt),
'log_sha256': sha(initial_raw), 'passed': 5, 'failed': 1}
intermediate_source = '520e50ce62f067dff69f03760c8b12929df9b920'
intermediate_failures = {
*renames,
'language::analysis_source::lower::tests::staged_oa_and_sa_lowering_match_complete_independent_17_uuid_oracles',
'language::analysis_source::write::tests::typed_oa_sa_canonical_roundtrips_match_independent_projects',
}
intermediate = {}
intermediate_artifact = None
for mode in ('focused', 'full', 'list'):
name = f'ordinary-{mode}-520e50c-1'
data, raw, raw_receipt = receipt(directory, name)
assert data['source'] == data['head_after'] == intermediate_source
assert data['command'] == commands[mode] and data['mode'] == mode
assert data['environment'] == current_env and data['cwd'] == str(root)
assert not data['changed_inputs'] and not data['verification_failures']
launcher = within(directory, data['launcher_copy']).read_bytes()
assert sha(launcher) == data['launcher_sha256'] == data['launcher_sha256_after'] == '59104b1acd39b3981b7339e585af9bd7f9cb87865ee82ffb763f0e7ce527713c'
manifest_raw = within(directory, data['inputs']).read_bytes()
assert sha(manifest_raw) == data['inputs_sha256']
manifest = json.loads(manifest_raw)
assert manifest['source'] == intermediate_source
historic_paths = git('ls-tree', '-r', '--name-only', intermediate_source, *scope).decode().splitlines()
assert historic_paths == [item['path'] for item in manifest['inputs']]
historic_blobs = subprocess.check_output(['git', '--no-replace-objects', 'cat-file', '--batch'], cwd=root,
input=''.join(f'{intermediate_source}:{p}\n' for p in historic_paths).encode())
offset = 0
for item in manifest['inputs']:
end = historic_blobs.index(b'\n', offset)
_, kind, size = historic_blobs[offset:end].split()
size = int(size)
content = historic_blobs[end + 1:end + 1 + size]
assert kind == b'blob' and size == item['bytes'] and sha(content) == item['sha256']
offset = end + size + 2
assert offset == len(historic_blobs)
assert len(data['artifacts']) == 1
if intermediate_artifact is None:
intermediate_artifact = data['artifacts'][0]
assert data['artifacts'] == [intermediate_artifact]
rows = outcomes(raw)
assert rows == [tuple(row) for row in data['outcomes']]
if mode == 'focused':
assert data['exit'] == 0 and dict(rows) == {name: 'ok' for name in added}
assert re.findall(r'^test result: ok\. (\d+) passed; (\d+) failed; (\d+) ignored; 0 measured; (\d+) filtered out;', raw.decode(), re.M) == [('6', '0', '0', '292')]
elif mode == 'full':
assert data['exit'] == 101 and len(rows) == 298
assert {name for name, status in rows if status == 'FAILED'} == intermediate_failures
assert sum(status == 'ok' for _, status in rows) == 294
assert set(dict(rows)) == set(old_out) | added
assert all(dict(rows)[name] == 'ok' for name, status in old_out.items() if status == 'FAILED')
assert set(failure_blocks(raw)) == intermediate_failures
assert re.findall(r'^test result: FAILED\. (\d+) passed; (\d+) failed; (\d+) ignored; 0 measured; (\d+) filtered out;', raw.decode(), re.M) == [('294', '4', '0', '0')]
else:
assert data['exit'] == 0 and not rows
assert members(raw) == data['listing_members'] and data['listing_count'] == 298
assert set(members(raw)) == set(old_out) | added
intermediate[name] = {'receipt_sha256': sha(raw_receipt), 'log_sha256': sha(raw),
'inputs_sha256': sha(manifest_raw), 'exit': data['exit']}
result = {'source': source, 'baseline': BASELINE, 'baseline_archive_sha256': ARCHIVE_SHA,
'checker_sha256': sha(Path(__file__).read_bytes()), 'inputs': len(expected_inputs),
'focused_passed': 7, 'focused_existing_renamed_control': focused_control,
'prior_passes_preserved': 276, 'prior_failures_now_passed': 16, 'added_passed': expected_added, 'added_names': sorted(added),
'full_passed': sum(v == 'ok' for v in new_out.values()), 'full_failed': 0,
'former_failure_names': sorted(old_blocks),
'identical_fmt_sha256': sha(raw_logs['fmt']), 'artifact': artifact_identity,
'environment': current_env, 'baseline_environment': expected_env,
'receipts': verified, 'integration_pass_counts': integration_counts,
'component_source': COMPONENT, 'reused_component_inputs': len(component_inputs),
'successor_only_declared_delta': 'crates/oa-core/tests/r3_migration.rs',
'old_r3_recorded_artifact': old_r3['integration-suite']['artifacts'][0],
'cli_artifact': build['artifacts'][0], 'initial_failed_run': initial_failure,
'exact_authorized_name_mapping': renames, 'intermediate_520_records': intermediate,
'intermediate_recorded_artifact': intermediate_artifact,
'scope': 'Committed declared inputs, pinned baseline archive, raw logs and current artifact bytes; no Cargo/executable execution. Launcher semantics require independent source review.'}
with destination.open('x', encoding='utf-8', newline='\n') as stream:
stream.write(json.dumps(result, indent=2) + '\n')
print(json.dumps(result, indent=2))