Files
ARCADIA-Studio/harness/experiments/text-find-selection-20260913/helpers/archive_focus.py
T
sorokin.oleg.edu 2df7f580aa Make the Text workspace compact and preserve editing context
Replace the oversized header and reference rail with stable editor slots and a retained supporting drawer. Bind diagnostic, result and menu actions to their original publication and visit; preserve effective selections on navigation and dismiss Actions, Find and the drawer one surface per Escape.

Retain exact Windows source captures, eight final gates (871 desktop passes), independent reviews, native selection/rename/recovery trials and the original failures. All 526 tested inputs and staged evidence were byte-checked before commit. Combined preview integration and packaging remain with issue 27; Linux remains paused.
2026-09-12 22:00:36 -07:00

50 lines
2.6 KiB
Python

"""Preserve the Find regression sequence and verify exact red/green input deltas."""
from pathlib import Path
import hashlib
import json
import shutil
base = Path(__file__).resolve().parent
root = base.parents[1]
dest = root / 'harness/experiments/text-find-selection-20260913'
dest.mkdir()
labels = ['focus-red-1', 'focus-red-2', 'focus-green-1', 'focus-green-2']
records = []
def keep(path, relative):
raw = path.read_bytes()
target = dest / relative
target.parent.mkdir(parents=True, exist_ok=True)
assert not target.exists()
shutil.copyfile(path, target)
assert target.read_bytes() == raw
records.append({'path': relative, 'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()})
inputs = {}
for label in labels:
inputs[label] = json.loads((base / label / 'inputs.json').read_text())['files']
receipt = json.loads((base / label / 'result.json').read_text())
assert receipt['inputsUnchanged']
for stream in ['stdout', 'stderr']:
raw = (base / label / (stream + '.log')).read_bytes()
assert receipt[stream] == {'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()}
for path in sorted((base / label).iterdir()):
if path.is_file():
keep(path, label + '/' + path.name)
def differences(a, b):
assert inputs[a].keys() == inputs[b].keys()
return [name for name in inputs[a] if inputs[a][name] != inputs[b][name]]
red_fixture = differences('focus-red-1', 'focus-red-2')
fix = differences('focus-red-2', 'focus-green-2')
retry = differences('focus-green-1', 'focus-green-2')
assert red_fixture == ['crates/oa-desktop/src/app/text_workspace/focus_selection_tests.rs']
assert fix == ['crates/oa-desktop/src/app/source_symbols.rs']
assert retry == []
for name in ['focus_regression.py', 'prepare_focus_red.py', 'archive_focus.py']:
keep(base / name, 'helpers/' + name)
keep(base / 'focus-corrected-source/manifest.json', 'corrected/manifest.json')
keep(base / 'focus-corrected-source/source_symbols.rs', 'corrected/source_symbols.rs')
manifest = {'scope': 'Historical Find-only regression sequence. Red1 fixture failure and green1 cache rejection are not correction acceptance. Red2 vs green2 differs only in production source_symbols.rs.', 'redFixtureDelta': red_fixture, 'redGreenDelta': fix, 'greenRetryByteDelta': retry, 'files': records}
with (dest / 'manifest.json').open('x', encoding='utf-8', newline='\n') as stream:
json.dump(manifest, stream, indent=2)
stream.write('\n')
print(json.dumps({'directory': str(dest), 'payloads': len(records), 'bytes': sum(r['bytes'] for r in records), 'manifestSha256': hashlib.sha256((dest / 'manifest.json').read_bytes()).hexdigest()}))