From b08032750f51dd98c158fbdf49fcda21c2b5ef77 Mon Sep 17 00:00:00 2001 From: Takeshi Date: Wed, 14 Oct 2026 10:51:56 +0900 Subject: [PATCH] Prepare complete reference-based P08 semantic review with exact CoW source --- .../execution/owner_model_cli.py | 11 + ...OMMANDER_CHECKOUT_RETIREMENT_PROPOSAL.json | 13 ++ .../p08-03/reference_semantic_review.py | 189 ++++++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 docs/plans/original-completion-2026-10-02/execution/p08-03/CLOSED_COMMANDER_CHECKOUT_RETIREMENT_PROPOSAL.json create mode 100644 docs/plans/original-completion-2026-10-02/execution/p08-03/reference_semantic_review.py diff --git a/docs/plans/original-completion-2026-10-02/execution/owner_model_cli.py b/docs/plans/original-completion-2026-10-02/execution/owner_model_cli.py index 45dab5d..9faccf4 100644 --- a/docs/plans/original-completion-2026-10-02/execution/owner_model_cli.py +++ b/docs/plans/original-completion-2026-10-02/execution/owner_model_cli.py @@ -287,5 +287,16 @@ def recorded_review_checkout(self, name, revision): return checkout Runner.detached = recorded_review_checkout +if os.environ.get('OWNER_P08_SEMANTIC_REFERENCE_REVIEW') == '7e2368f5': + import importlib.util + import runner.core as semantic_core + adapter = Path('/Users/korizatou114/Projects/とりにく工房ゲーム制作部/docs/plans/original-completion-2026-10-02/execution/p08-03/reference_semantic_review.py') + spec = importlib.util.spec_from_file_location('p08_reference_semantic_review', adapter) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + module.install(semantic_core) + module.run(semantic_core) + sys.exit(0) + from runner.cli import main main() diff --git a/docs/plans/original-completion-2026-10-02/execution/p08-03/CLOSED_COMMANDER_CHECKOUT_RETIREMENT_PROPOSAL.json b/docs/plans/original-completion-2026-10-02/execution/p08-03/CLOSED_COMMANDER_CHECKOUT_RETIREMENT_PROPOSAL.json new file mode 100644 index 0000000..379911d --- /dev/null +++ b/docs/plans/original-completion-2026-10-02/execution/p08-03/CLOSED_COMMANDER_CHECKOUT_RETIREMENT_PROPOSAL.json @@ -0,0 +1,13 @@ +{ + "status": "proposal only; no deletion; approval required", + "scope": "clean detached read-only commander source copies; preserve Git object data, implement/review/validation checkouts and all Runner records/proofs", + "rows": [ + { + "path": "/Users/korizatou114/Projects/TheTree-managed-worktrees/p08-03-code/P08-03-commander-5f939e63", + "commit": "12430ba89970bda349781e51157e72e48a4ac06f", + "clean": true, + "ignored_unique_files": 0, + "allocated_kib": 154268 + } + ] +} \ No newline at end of file diff --git a/docs/plans/original-completion-2026-10-02/execution/p08-03/reference_semantic_review.py b/docs/plans/original-completion-2026-10-02/execution/p08-03/reference_semantic_review.py new file mode 100644 index 0000000..f90f4e0 --- /dev/null +++ b/docs/plans/original-completion-2026-10-02/execution/p08-03/reference_semantic_review.py @@ -0,0 +1,189 @@ +"""Owner coordinator: complete, hash-frozen read-only proof references for P08.""" +import hashlib +import json +import os +import shutil +import subprocess +import uuid +from pathlib import Path + +CANDIDATE = '7e2368f5c453a3900ba1bb038d7138d25f7eb4fb' +TASK = 'P08-03' +PROJECT = 'the-tree-p08-03-code' + + +def digest_file(path): + value = hashlib.sha256() + with path.open('rb') as stream: + for block in iter(lambda: stream.read(1048576), b''): + value.update(block) + return value.hexdigest() + + +def install(core): + original = core.Runner.review_materials + detached_original = core.Runner.detached + + def detached(self, name, revision): + if self.config['project'] != PROJECT or revision != CANDIDATE or not name.startswith(TASK + '-review-semantic-'): + return detached_original(self, name, revision) + source = Path(self.task(TASK)['worktree']) + core.require(core.git(source, 'rev-parse', 'HEAD') == revision + and not core.git(source, 'status', '--porcelain'), 'clean existing exact-candidate source') + core.require(core.git(source, 'rev-parse', '--path-format=absolute', '--git-common-dir') + == core.git(self.repo, 'rev-parse', '--path-format=absolute', '--git-common-dir'), 'same registered repository') + names = [value for value in core.git(source, 'ls-tree', '-r', '-z', '--name-only', revision).split('\0') if value] + resume = os.environ.get('OWNER_P08_PREPARED_COW_CHECKOUT') + target = Path(resume) if resume else self.worktrees / name + if resume: + core.require(target.parent.resolve() == self.worktrees.resolve() + and target.name.startswith(TASK + '-review-semantic-') + and core.git(target, 'rev-parse', 'HEAD') == revision, + 'exact owned partial semantic checkout') + for path in target.rglob('*'): + if path.is_file() and path.name != '.git': + relative = path.relative_to(target).as_posix() + core.require(relative in names and not path.is_symlink() + and digest_file(path) == digest_file(source / relative), + 'only identical committed copies in partial checkout') + else: + core.require(not target.exists(), 'fresh semantic checkout') + core.git(self.repo, 'worktree', 'add', '--detach', '--no-checkout', str(target), revision) + for name in names: + current = source / name + core.require(current.is_file() and not current.is_symlink(), 'ordinary committed source') + copy = target / name + copy.parent.mkdir(parents=True, exist_ok=True) + subprocess.run(['/bin/cp', '-pc', str(current), str(copy)], check=True) + core.git(target, 'read-tree', 'HEAD') + core.require(core.git(target, 'rev-parse', 'HEAD') == revision + and not core.git(target, 'status', '--porcelain'), 'whole CoW checkout matches committed candidate') + self._owner_frozen_review_checkout = target + self.event(TASK, 'owner_exact_candidate_cow_checkout', + {'candidate': revision, 'source': str(source), 'target': str(target), + 'tracked_files': len(names), 'whole_git_clean': True}) + return target + + core.Runner.detached = detached + + def materials(self, task_id, checkout, revision): + if self.config['project'] != PROJECT or task_id != TASK or revision != CANDIDATE: + return original(self, task_id, checkout, revision) + core.require(not self.db.execute("SELECT 1 FROM runs WHERE status='running'").fetchone(), + 'no live proof writer during reference freeze') + checkout = Path(checkout) + destination = checkout / '.review-material' + core.require(not destination.exists(), 'fresh manifest destination') + destination.mkdir() + build = Path(self.allocation(task_id)['build_dir']).resolve() + core.require(build.is_relative_to(self.runtime(task_id).resolve()), 'existing task runtime only') + rows = [] + excluded = [] + + def row(path): + core.require(path.is_file() and not path.is_symlink(), 'ordinary full proof reference') + return {'path': str(path), 'bytes': path.stat().st_size, + 'sha256': digest_file(path), 'delivery': 'existing task-runtime read access'} + + evidence = self.db.execute( + "SELECT artifact FROM evidence WHERE task_id=? AND commit_sha=? AND kind='validation' AND passed=1", + (task_id, revision)).fetchall() + core.require(evidence, 'actual candidate validation receipt') + for number, entry in enumerate(evidence): + source = Path(entry['artifact']) + files = [(source, destination / 'receipts' / (str(number) + '-' + source.name))] + receipt = core.read_json(source) + for ordinal, check in enumerate(receipt['checks']): + for name in ('stdout.log', 'stderr.log', 'command.json'): + files.append((Path(check['artifact']) / name, + destination / 'validation-runs' / str(number) / str(ordinal) / name)) + for source, target in files: + core.require(source.resolve().is_relative_to((self.root / 'runs').resolve()) + and not source.is_symlink(), 'registered validation source only') + expected = digest_file(source) + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copy2(source, target) + core.require(digest_file(source) == digest_file(target) == expected, 'receipt copy bytes') + rows.append(row(target)) + for path in sorted(build.rglob('*')): + core.require(not path.is_symlink(), 'reference mode refuses unresolved aliases') + if path.is_file(): + if core.secret_path(str(path.relative_to(build))): + excluded.append(str(path.relative_to(build))) + else: + rows.append(row(path)) + manifest = {'candidate': revision, 'task_id': task_id, + 'delivery': 'complete SHA-frozen references, no duplicated build trees', + 'complete_nonsecret_registered_validation_material': True, + 'file_count_limit': None, 'byte_limit': None, + 'excluded_sensitive_paths': excluded, 'files': rows} + core.write_json(destination / 'manifest.json', manifest) + self._owner_reference_manifest = manifest + self._owner_reference_build = build + self.event(task_id, 'owner_complete_reference_review_material', + {'candidate': revision, 'files': len(rows), 'build': str(build), + 'existing_runtime_access_only': True, 'post_review_hash_check_required': True}) + return {'path': '.review-material/manifest.json', 'file_count': len(rows), + 'byte_limit': None, 'instruction': 'Read full absolute file paths in manifest; existing task runtime is readable. No proof omitted.'} + + core.Runner.review_materials = materials + + +def run(core): + runner = core.Runner(PROJECT) + task = runner.task(TASK) + core.require(task['state'] in ('review_pending', 'blocked') and task['submitted'] == CANDIDATE, + 'exact pre-full semantic review state and candidate') + runner.has_evidence(TASK, 'validation', CANDIDATE) + if task['state'] == 'blocked': + core.require(not runner.db.execute("SELECT 1 FROM runs WHERE status='running'").fetchone(), + 'recover actual terminated runs before review retry') + runner.state(TASK, 'review_pending', 'Retry interrupted semantic review; exact candidate validation retained') + checkout = runner.detached(TASK + '-review-semantic-' + uuid.uuid4().hex[:8], CANDIDATE) + material = runner.review_materials(TASK, checkout, CANDIDATE) + schema = core.read_json(core.CONTROL / 'schemas/result.json') + schema['properties']['task_id']['enum'] = [TASK] + schema['properties']['commit']['enum'] = [CANDIDATE] + prompt = runner.packet(TASK, 'reviewer', CANDIDATE) + prompt += '\nComplete proof access: ' + json.dumps(material) + prompt += ''' +This is an independent PRE-FULL semantic review of all five original P08-03 conditions, +requested by the recorded Opus commander. It is not final unit acceptance. +Read the real R09 native and OS evidence, exact candidate source, applicability checks, +and original five-condition contract. Explicitly judge each condition with raw evidence +references. In particular judge green missing_connection preview followed by +STAIR_LANDING_MISSING refusal, displayed reason and whole-state preservation; judge +lower_stair, upper_stair and STAIR_LANDING_IN_USE demolition separately. Do not invent +exceptions, waive original requirements, or infer Windows/manual held-input acceptance. +Registered validator passes, but final175, final independent acceptance and integration +remain pending. Status pass here may mean ONLY semantic/code suitability for proceeding +to final175. State this scope explicitly; the result is stored as semantic_pre_full_review, +never as final review evidence. Return changes_requested with concrete findings if a +product or checker defect exists, or blocked if actual proof access is insufficient. +All required full proof bytes remain accessible by manifest absolute paths within this +already permitted task runtime. There is no file-count or byte cap. Report any read denial. +''' + result, artifact = runner.llm(TASK, 'reviewer', 'claude', prompt, checkout, schema) + manifest = runner._owner_reference_manifest + for entry in manifest['files']: + path = Path(entry['path']) + core.require(path.is_file() and not path.is_symlink() + and path.stat().st_size == entry['bytes'] + and digest_file(path) == entry['sha256'], 'whole proof changed during review') + expected_build = {entry['path'] for entry in manifest['files'] + if Path(entry['path']).is_relative_to(runner._owner_reference_build)} + actual_build = {str(path) for path in runner._owner_reference_build.rglob('*') + if path.is_file() and not core.secret_path(str(path.relative_to(runner._owner_reference_build)))} + core.require(actual_build == expected_build, 'whole proof file set changed during review') + core.require(core.git(checkout, 'rev-parse', 'HEAD') == CANDIDATE + and not core.git(checkout, 'diff', 'HEAD', '--name-only'), 'review source changed') + contract = json.loads(task['contract']) + passed = result['status'] == 'pass' and set(result['acceptance_ids']) == set(contract['acceptance_ids']) and not any( + item['severity'] in ('critical', 'high', 'medium') for item in result['findings']) + runner.evidence(TASK, 'semantic_pre_full_review', CANDIDATE, artifact / 'result.json', passed) + runner.event(TASK, 'semantic_pre_full_review_finished', + {'candidate': CANDIDATE, 'artifact': str(artifact), 'passed': passed, + 'final175_pending': True, 'final_acceptance': False, + 'whole_reference_bytes_and_set_unchanged': True}) + print(json.dumps({'result': result, 'artifact': str(artifact), + 'final_acceptance': False}, ensure_ascii=False))