Repository navigation
Resume llama upgrade repair after failed verification #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cb78b6d
Resume llama upgrade repair through verified feedback and recovery
i386 98357b4
Exclude preparation stamps before the cached-source fast path
i386 4720e00
Verify recovery restoration when the upstream base is unavailable
i386 e123143
Capture outer repair commits against the frozen preparation base
i386 bd55a8f
Require fresh complete recovery evidence in the Goose rehearsal
i386 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """Mesh-style repair feedback within shared coding and verification windows.""" | ||
|
|
||
| import json | ||
| import os | ||
| import subprocess | ||
| import time | ||
| import uuid | ||
|
|
||
| from .ci_process import command_logs, time_budget | ||
| from .upgrade_recovery import retain | ||
|
|
||
| CODING_SECONDS = 41400 | ||
| VERIFICATION_SECONDS = 43200 | ||
| FAILURES = (OSError, ValueError, RuntimeError, subprocess.SubprocessError) | ||
|
|
||
|
|
||
| def verify_or_repair(checkout, diagnostics, verify, repair, save_diagnostics, *, initial_repair=False): | ||
| diagnostics.mkdir(parents=True, exist_ok=True) | ||
| session = {"name": "skippy-upgrade-" + uuid.uuid4().hex, "started": False} | ||
| deadline = None | ||
| turn = 0 | ||
| needs_repair = initial_repair | ||
| try: | ||
| while True: | ||
| if needs_repair: | ||
| if not os.environ.get("SKIPPY_UPGRADE_REPAIR_COMMAND"): | ||
| raise ValueError("Automatic repair requires SKIPPY_UPGRADE_REPAIR_COMMAND; diagnostics retained") | ||
| if deadline is None: | ||
| deadline = time.monotonic() + CODING_SECONDS | ||
| remaining = deadline - time.monotonic() | ||
| if remaining <= 0: | ||
| raise TimeoutError("upgrade repair coding window exhausted") | ||
| turn += 1 | ||
| # This also bounds any tools invoked by the repair adapter. | ||
| with time_budget(remaining): | ||
| repair(checkout, diagnostics, session=session, timeout=remaining) | ||
| if retain(checkout, diagnostics / "recovery", f"turn-{turn}") is None: | ||
| raise RuntimeError("could not preserve returned repair work before verification") | ||
| try: | ||
| # Like Mesh, a returned coding turn gets a fresh verification pass. | ||
| with time_budget(VERIFICATION_SECONDS), command_logs(diagnostics / f"verification-{turn}"): | ||
| verify() | ||
| return | ||
| except FAILURES as error: | ||
| save_diagnostics(checkout, diagnostics) | ||
| (diagnostics / "last-check.json").write_text(json.dumps({ | ||
| "status": "fail", "turn": turn, "error": str(error), | ||
| "logs": str(diagnostics / f"verification-{turn}"), | ||
| }, indent=2) + "\n") | ||
| print(f"Candidate verification failed; returning evidence to repair: {error}", flush=True) | ||
| if not os.environ.get("SKIPPY_UPGRADE_REPAIR_COMMAND"): | ||
| raise | ||
| needs_repair = True | ||
| finally: | ||
| retain(checkout, diagnostics / "recovery", "final") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| """Preserve unverified source before disposable upgrade workspaces disappear.""" | ||
|
|
||
| import json | ||
| import os | ||
| import subprocess | ||
| import tarfile | ||
| import tempfile | ||
| from pathlib import Path | ||
|
|
||
| from .ci_process import DEADLINE, command, time_budget | ||
| from .upgrade_source import PIN, git | ||
|
|
||
| EMPTY_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904" | ||
| MAX_BYTES = 256 * 1024 * 1024 | ||
|
|
||
|
|
||
| def snapshot(root, destination, base): | ||
| destination.mkdir() | ||
| patch = destination / "tracked.patch" | ||
| with patch.open("wb") as stream: | ||
| command(["git", "-C", str(root), "diff", "--binary", "--no-ext-diff", base, "--"], | ||
| stdout=stream, timeout=120) | ||
| if patch.stat().st_size > MAX_BYTES: | ||
| raise ValueError("recovery patch exceeds 256 MiB") | ||
| names = command(["git", "-C", str(root), "ls-files", "--others", "--exclude-standard", "-z"], | ||
| capture_stdout=True).split("\0") | ||
| total = 0 | ||
| with tarfile.open(destination / "untracked.tar.gz", "w:gz", dereference=False) as archive: | ||
| for name in filter(None, names): | ||
| path = root / name | ||
| if name.startswith((".deps/", "target/", ".skippy-")): | ||
| continue | ||
| if path.is_symlink() or not path.is_file(): | ||
| raise ValueError(f"recovery untracked input is not a regular file: {name}") | ||
| total += path.stat().st_size | ||
| if total > MAX_BYTES: | ||
| raise ValueError("recovery untracked inputs exceed 256 MiB") | ||
| archive.add(path, arcname=name, recursive=False) | ||
| return {"base": base, "head": git(root, "rev-parse", "HEAD"), "unverified": True} | ||
|
|
||
|
|
||
| def checkpoint(checkout, recovery, label): | ||
| recovery.mkdir(parents=True, exist_ok=True) | ||
| # An interrupted checkpoint leaves previous completed snapshots intact. | ||
| with tempfile.TemporaryDirectory(dir=recovery, prefix=".capturing-") as scratch: | ||
| stage = Path(scratch) / "source" | ||
| stage.mkdir() | ||
| base = git(checkout, "rev-parse", "HEAD") | ||
| manifest = {"outer": snapshot(checkout, stage / "outer", base), "unverified": True} | ||
| native = checkout / ".deps/llama.cpp" | ||
| if (native / ".git").exists(): | ||
| pin = (checkout / PIN).read_text().strip() | ||
| try: | ||
| git(native, "cat-file", "-e", pin + "^{commit}") | ||
| except subprocess.CalledProcessError: | ||
| pin = EMPTY_TREE | ||
| manifest["native"] = snapshot(native, stage / "native", pin) | ||
| manifest["native"]["full_tracked_tree"] = pin == EMPTY_TREE | ||
| (stage / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n") | ||
| destination = recovery / f"{label}-{os.urandom(6).hex()}" | ||
| stage.replace(destination) | ||
| return destination | ||
|
|
||
|
|
||
| def retain(checkout, recovery, label): | ||
| token = DEADLINE.set(None) | ||
| try: | ||
| # Recovery must work after the coding or verification deadline expires. | ||
| with time_budget(180): | ||
| return checkpoint(checkout, recovery, label) | ||
| except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as error: | ||
| print(f"Unverified source checkpoint failed: {error}", flush=True) | ||
| finally: | ||
| DEADLINE.reset(token) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.