"""Bind completed Windows gate inputs and preserved GUI for a development trial.""" from pathlib import Path from datetime import datetime, timezone import hashlib import json import re import subprocess import sys BASE = Path(__file__).resolve().parent ROOT = Path('C:/ar-text-9e8r6t') attempt = sys.argv[1] assert re.fullmatch(r'attempt-[0-9]+', attempt) gate = ROOT / '.local/text-workspace-gates-20260912' / attempt destination = BASE / (attempt + '-launch-manifest.json') assert not destination.exists() def identity(path): raw = path.read_bytes() return {'path': str(path.resolve()), 'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()} def read(name): return json.loads((gate / name).read_text(encoding='utf-8')) names = ['clippy', 'membership', 'focused', 'selection', 'tests', 'timing', 'gui'] complete = read('complete.json') assert complete['inputsUnchanged'] is True and complete['gates'] == names inputs = read('inputs.json') assert identity(gate / 'inputs.zip')['sha256'] == inputs['archiveSha256'] assert subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT).decode().strip() == inputs['baseCommit'] scopes = ['Cargo.toml', 'Cargo.lock', 'crates', 'build', '.cargo', 'docs', 'examples', 'harness/fixtures'] raw_names = subprocess.check_output(['git', 'ls-files', '-z', '--cached', '--others', '--exclude-standard', '--', *scopes], cwd=ROOT) current_names = sorted(set(name.decode() for name in raw_names.split(b'\0') if name)) assert current_names == [item['path'] for item in inputs['files']] for item in inputs['files']: path = (ROOT / item['path']).resolve() assert path.is_relative_to(ROOT.resolve()) measured = identity(path) assert all(measured[key] == item[key] for key in ['bytes', 'sha256']) evidence = [identity(gate / name) for name in ['inputs.json', 'inputs.zip', 'environment.json', 'complete.json']] receipts = {} for name in names: receipt = read(name + '-result.json') assert receipt['exitCode'] == 0 and receipt['inputsUnchanged'] is True for stream in ['stdout', 'stderr']: log = identity(gate / (name + '-' + stream + '.log')) assert log['sha256'] == receipt[stream + 'Sha256'] evidence.append(log) evidence.append(identity(gate / (name + '-result.json'))) receipts[name] = receipt membership = receipts['membership']['testMembership'] assert not membership['missing'] and membership['diagnosticGuardCount'] == 20 assert any('queued_group_toggle_cannot_mutate' in name for name in membership['required']) assert any('all_reference_exceptions_fit_allocated_width' in name for name in membership['required']) assert sum('text_workspace::focus_selection_tests::' in name for name in membership['required']) == 4 assert sum('source_navigation::selection::tests::' in name for name in membership['required']) == 7 test_output = (gate / 'tests-stdout.log').read_text(encoding='utf-8') result = re.search(r'test result: ok\. (\d+) passed; 0 failed; (\d+) ignored;', test_output) assert result and sum(map(int, result.groups())) == membership['listed'] timing_output = (gate / 'timing-stdout.log').read_text(encoding='utf-8') assert 'test result: ok. 1 passed; 0 failed;' in timing_output binary_record = receipts['gui']['binary'] binary = identity(Path(binary_record['preserved'])) assert all(binary[key] == binary_record[key] for key in ['bytes', 'sha256']) artifact = binary_record['artifact'] assert Path(artifact['manifest_path']).resolve() == ROOT / 'crates/oa-desktop/Cargo.toml' assert artifact['target']['name'] == 'arcadia-studio' assert artifact['executable'] == binary_record['path'] manifest = { 'atUtc': datetime.now(timezone.utc).isoformat(), 'nativeReady': True, 'scope': 'Completed Windows source gates authorize development GUI evaluation; native and packaged acceptance remain pending.', 'target': 'x86_64-pc-windows-gnullvm', 'baseCommit': inputs['baseCommit'], 'sourceFiles': len(inputs['files']), 'sourceArchiveSha256': inputs['archiveSha256'], 'membership': membership, 'binary': binary, 'evidence': evidence, 'helper': identity(Path(__file__)), } with destination.open('x', encoding='utf-8', newline='\n') as output: json.dump(manifest, output, indent=2) output.write('\n') print(json.dumps(identity(destination)), flush=True)