diff --git a/AGENTS.md b/AGENTS.md index 3189e15f..45b6b76a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -62,6 +62,10 @@ release remain frozen. names a stricter checked-in runner. The command owns one source/HOME/cache/ TMP/browser root and removes it after archiving compact evidence on success, failure, timeout or handled interruption. +- The attempt runner must block handled termination signals while it creates + and marks the owned root, then restore delivery only after its cleanup guard + is active. A signal during startup is not permission to leave an unowned or + half-initialized source/import root behind. - A zero child exit is not sufficient. Godot/runtime diagnostics remain strict, and formal calls must pass each expected terminal with `--require-marker`; every required marker must appear exactly once before the runner records PASS. diff --git a/CURRENT_CHECKPOINT.md b/CURRENT_CHECKPOINT.md index 683a0e6a..a5f816ff 100644 --- a/CURRENT_CHECKPOINT.md +++ b/CURRENT_CHECKPOINT.md @@ -2361,6 +2361,11 @@ Owner checkpoint 2 without changing gameplay, content or presentation. ## FG-4 Step 10 Test Attempt Hygiene - 2026-08-17 +- Owner cleanup found `1,280` accumulated temporary attempt directories using + about `110 GB`, plus about `27 GB` of Chrome/Playwright macOS signing copies. + macOS reported these `/private/tmp` and `/private/var/folders` products as + System Data. Owner cleanup restored about `140 GiB` free space; the later + repository preflight measured about `161 GiB` free. - `tools/run_test_attempt.py` now owns one fresh source/HOME/cache/TMP/browser root per attempt, archives only compact evidence, removes the owned root on pass/fail/timeout/handled interruption and cleans stale marked roots on the @@ -2376,6 +2381,12 @@ Owner checkpoint 2 without changing gameplay, content or presentation. archive_cleanup=true interrupt_cleanup=true strict_diagnostics=true marker_gate=true python_site_isolated=true stale_cleanup=true browser_cleanup=true`. +- A fresh self-test exposed one startup race where SIGTERM could arrive after + root creation but before the main cleanup guard. Handled signals are now + blocked while the root is created and marked, then restored only inside the + guarded lifecycle. Five consecutive complete self-test suites pass after the + repair; every work root is absent at terminal and failed payload retention + remains exactly three. - A real fresh-archive Godot import plus FG-4 content-registry smoke passes at `/private/tmp/abg-runner-smoke-evidence/fg4-runner-smoke/20260817T031332Z-96715/`. Its temporary work root is empty after the run and retained output is about diff --git a/docs/reviews/PHASE9_GODOT_VERTICAL_SLICE_LEDGER.md b/docs/reviews/PHASE9_GODOT_VERTICAL_SLICE_LEDGER.md index 98aa2e9d..ddcfe79e 100644 --- a/docs/reviews/PHASE9_GODOT_VERTICAL_SLICE_LEDGER.md +++ b/docs/reviews/PHASE9_GODOT_VERTICAL_SLICE_LEDGER.md @@ -2421,3 +2421,24 @@ the four profile/Save regressions, then commit the bounded Step-10 test source. Shortest next action: commit the environment repair, then run a fresh R2 from the new immutable source without reusing any R1 output. + +## FG-4 Step 10 Startup Cleanup Race Repair - 2026-08-17 + +- Owner cleanup found 1,280 accumulated attempt directories using about 110 GB + and about 27 GB of Chrome/Playwright macOS signing copies. The paths lived + under macOS temporary roots and appeared as System Data; this was test + infrastructure growth, not game content. +- Re-running `tools/test_run_test_attempt.py` exposed a SIGTERM startup race: + the owned directory could exist before the runner entered its cleanup guard. + Next-run stale recovery still existed, but same-attempt cleanup was not + proven, so the result was rejected as a runner failure. +- The runner now blocks SIGINT, SIGTERM and SIGHUP while creating and marking + the owned root, and restores signal delivery only inside the guarded + lifecycle. Five consecutive full self-test suites pass success, timeout, + strict failure, startup interruption, evidence archival, stale recovery, + browser cleanup and the combined three-failed-attempt retention ceiling. + Gameplay, content, Save, presentation and accepted midpoint evidence are + unchanged. + +Shortest next action: push the cleanup-race repair, then create the exact-source +runtime-only cached H5 through the repaired bounded runner. diff --git a/docs/runtime/fg4/IMPLEMENTATION_PLAN.md b/docs/runtime/fg4/IMPLEMENTATION_PLAN.md index 9aaf72eb..ac756efa 100644 --- a/docs/runtime/fg4/IMPLEMENTATION_PLAN.md +++ b/docs/runtime/fg4/IMPLEMENTATION_PLAN.md @@ -737,5 +737,6 @@ NEXT STEP: stop for Owner checkpoint 2; RG-05 and native delivery stay frozen. | `FG4-I09` | `RESOLVED_STEP_9` | The final Quillroot mix reserves 3 dB SFX headroom and the recording keeps RG-05 visible through teardown; R5 is strict-clean. | | `FG4-I10` | `RESOLVED_STEP_10_RUNNER` | Cleanup/retention passed; after dirty-tree attempt 01 proved Godot can return zero on parse error, the runner added strict diagnostic rejection and exact-one required-marker gates. Attempt 01 is development-only `INVALID_RUNNER_DIAGNOSTIC` and is not reused. | | `FG4-I11` | `RESOLVED_STEP_10_ENVIRONMENT` | Immutable candidate R1 stopped before Godot because isolated HOME hid Pillow. The forward runner exposes original-HOME identity only so the suite can bind the existing read-only Python 3.9 site; four media/audio validators pass without install/copy, and R1 remains unreused. | +| `FG4-I12` | `RESOLVED_STEP_10_STARTUP_CLEANUP` | Owner cleanup found 1,280 temporary attempt directories using about 110 GB plus about 27 GB of Chrome signing copies. A fresh self-test exposed a startup-signal race before the main cleanup guard. The runner now masks handled signals while creating/marking its root and unmasks only inside the guarded lifecycle; five consecutive lifecycle suites pass with work roots empty and failed payload retention fixed at three. | diff --git a/tools/run_test_attempt.py b/tools/run_test_attempt.py index aa4146ee..cfb740b9 100755 --- a/tools/run_test_attempt.py +++ b/tools/run_test_attempt.py @@ -34,6 +34,7 @@ STRICT_DIAGNOSTICS = ( ) _child: subprocess.Popen[bytes] | None = None _interrupted_signal: int | None = None +HANDLED_SIGNALS = (signal.SIGINT, signal.SIGTERM, signal.SIGHUP) def parse_args() -> argparse.Namespace: @@ -223,33 +224,50 @@ def handle_signal(sig: int, _frame) -> None: def main() -> int: global _child - args = parse_args() - label = safe_label(args.label) - repository = args.cwd.resolve() - workspace_root = args.workspace_root.resolve() - artifact_root = args.artifact_root.resolve() - workspace_root.mkdir(parents=True, exist_ok=True) - family_root = artifact_root / label - family_root.mkdir(parents=True, exist_ok=True) - stale_removed = cleanup_stale_workspaces(workspace_root) + previous_signal_mask = None + attempt_root: Path | None = None + artifact_dir: Path | None = None + if hasattr(signal, "pthread_sigmask"): + previous_signal_mask = signal.pthread_sigmask(signal.SIG_BLOCK, HANDLED_SIGNALS) - attempt_root = Path(tempfile.mkdtemp(prefix=f"{label}-", dir=workspace_root)) - started_epoch = time.time() - started_at = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(started_epoch)) - attempt_id = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime(started_epoch)) + f"-{os.getpid()}" - artifact_dir = family_root / attempt_id - artifact_dir.mkdir() - command_log = artifact_dir / "command.log" - evidence_dir = attempt_root / "evidence" - evidence_dir.mkdir() - owner = { - "created_by": RUNNER_ID, - "pid": os.getpid(), - "label": label, - "started_at": started_at, - "artifact_dir": str(artifact_dir), - } - write_json(attempt_root / OWNER_FILE, owner) + try: + args = parse_args() + label = safe_label(args.label) + repository = args.cwd.resolve() + workspace_root = args.workspace_root.resolve() + artifact_root = args.artifact_root.resolve() + workspace_root.mkdir(parents=True, exist_ok=True) + family_root = artifact_root / label + family_root.mkdir(parents=True, exist_ok=True) + stale_removed = cleanup_stale_workspaces(workspace_root) + + attempt_root = Path(tempfile.mkdtemp(prefix=f"{label}-", dir=workspace_root)) + started_epoch = time.time() + started_at = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(started_epoch)) + attempt_id = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime(started_epoch)) + f"-{os.getpid()}" + artifact_dir = family_root / attempt_id + artifact_dir.mkdir() + command_log = artifact_dir / "command.log" + evidence_dir = attempt_root / "evidence" + evidence_dir.mkdir() + owner = { + "created_by": RUNNER_ID, + "pid": os.getpid(), + "label": label, + "started_at": started_at, + "artifact_dir": str(artifact_dir), + } + write_json(attempt_root / OWNER_FILE, owner) + except BaseException: + if attempt_root is not None: + shutil.rmtree(attempt_root, ignore_errors=True) + if artifact_dir is not None: + shutil.rmtree(artifact_dir, ignore_errors=True) + if previous_signal_mask is not None: + signal_mask = previous_signal_mask + previous_signal_mask = None + signal.pthread_sigmask(signal.SIG_SETMASK, signal_mask) + raise source_revision = "WORKTREE" timed_out = False @@ -261,6 +279,10 @@ def main() -> int: diagnostics: list[str] = [] marker_counts: dict[str, int] = {} try: + if previous_signal_mask is not None: + signal_mask = previous_signal_mask + previous_signal_mask = None + signal.pthread_sigmask(signal.SIG_SETMASK, signal_mask) with command_log.open("wb") as log: if args.git_ref: source_root = attempt_root / "source" @@ -398,6 +420,6 @@ def main() -> int: if __name__ == "__main__": - for handled_signal in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP): + for handled_signal in HANDLED_SIGNALS: signal.signal(handled_signal, handle_signal) raise SystemExit(main())