Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .agents/skills/manage-ci/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ contract; no downstream product's workflow topology applies here.
deadline includes preparation and candidate export; full CI runs separately.
Seed the protected current patch queue before replaying a new
upstream revision so cold repositories have intermediate merge-base blobs.
A bounded agent repair produces a fresh candidate and fresh full CI. Only the
Use one named Goose session with verification feedback and a shared 11h30
coding deadline. Each returned turn gets up to 12h verification, with a 23h40
outer preparation deadline. Rebuild patch staging every turn, exclude native
preparation stamps from Git staging and reject them in repaired patches.
Checkpoint outer/native source before verification and on final exit, including
committed native changes against upstream. Upload unverified recovery on
failure/cancellation before verbose logs; never admit it as CI evidence.
A repaired candidate receives fresh full CI. Only the
publisher receives scoped publication credentials. It can publish only the
exact candidate selected by successful full CI. The four established inference
models retain their separate PR/manual/nightly/release workflow.
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/llama-upgrade.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test('candidate preparation and repair run with Goose on the native JY runner',
assert.match(job, /run: just automation-run upgrade runner-check/);
const fallback = job.match(/SKIPPY_UPGRADE_REPAIR_COMMAND: .*\|\| '([^']+)'/);
assert.deepEqual(JSON.parse(fallback[1]),
['goose', 'run', '--no-session', '--with-builtin', 'developer', '--text']);
['goose', 'run', '--with-builtin', 'developer', '--text']);
assert.doesNotMatch(job, /SKIPPY_UPGRADE_REPAIR_COMMAND: \$\{\{ vars\.SKIPPY_UPGRADE_REPAIR_COMMAND \}\}/);
}
});
22 changes: 18 additions & 4 deletions .github/workflows/llama-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
LIBCLANG_PATH: /usr/lib/llvm-22/lib
GOOSE_MODE: auto
GOOSE_DISABLE_SESSION_NAMING: 'true'
SKIPPY_UPGRADE_REPAIR_COMMAND: ${{ vars.SKIPPY_UPGRADE_REPAIR_COMMAND || '["goose","run","--no-session","--with-builtin","developer","--text"]' }}
SKIPPY_UPGRADE_REPAIR_COMMAND: ${{ vars.SKIPPY_UPGRADE_REPAIR_COMMAND || '["goose","run","--with-builtin","developer","--text"]' }}
outputs:
changed: ${{ steps.resolve.outputs.changed }}
validate: ${{ steps.resolve.outputs.validate }}
Expand Down Expand Up @@ -101,8 +101,15 @@ jobs:
target/llama-upgrade/candidate.json
if-no-files-found: error
retention-days: 14
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
if: ${{ failure() || cancelled() }}
with:
name: llama-preparation-diagnostics-recovery
path: target/llama-upgrade/diagnostics/recovery
if-no-files-found: warn
retention-days: 14
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: failure()
if: ${{ failure() || cancelled() }}
with:
name: llama-preparation-diagnostics
path: |
Expand Down Expand Up @@ -150,7 +157,7 @@ jobs:
LIBCLANG_PATH: /usr/lib/llvm-22/lib
GOOSE_MODE: auto
GOOSE_DISABLE_SESSION_NAMING: 'true'
SKIPPY_UPGRADE_REPAIR_COMMAND: ${{ vars.SKIPPY_UPGRADE_REPAIR_COMMAND || '["goose","run","--no-session","--with-builtin","developer","--text"]' }}
SKIPPY_UPGRADE_REPAIR_COMMAND: ${{ vars.SKIPPY_UPGRADE_REPAIR_COMMAND || '["goose","run","--with-builtin","developer","--text"]' }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
Expand Down Expand Up @@ -203,7 +210,14 @@ jobs:
if-no-files-found: error
retention-days: 14
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
if: failure()
if: ${{ failure() || cancelled() }}
with:
name: llama-repair-diagnostics-recovery
path: target/llama-upgrade/diagnostics/recovery
if-no-files-found: warn
retention-days: 14
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
if: ${{ failure() || cancelled() }}
with:
name: llama-repair-diagnostics
path: target/llama-upgrade/diagnostics
Expand Down
46 changes: 38 additions & 8 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ actual stage graphs, required tensors, activation boundaries and backend
compatibility. There is no family certification or experimental bypass.

On the JY workflow jobs, the default repair command is
`goose run --no-session --with-builtin developer --text`, with the diagnostic
`goose run --with-builtin developer --text`, with the diagnostic
prompt appended as one argument. `GOOSE_MODE=auto` keeps repair noninteractive and session naming is disabled. The JY runner must
already provide Goose and its provider authentication. A repository variable
`SKIPPY_UPGRADE_REPAIR_COMMAND` may override the command with a JSON argv array.
Expand All @@ -643,13 +643,43 @@ The job deadline includes setup, regeneration and candidate export. Mesh also
allocates a separate 12-hour verification window inside its build job; Skippy
runs full CI in separate jobs after the candidate is frozen.

Preparation can make one repair attempt when native regeneration fails. After a full CI failure, the controller collects
failed job logs and CI artifacts, repairs the disposable candidate, and reruns
the complete gate. Native patch queues, bindings and generated API documentation
may change. Policy, workflow, fixture selection, upstream pin and commit-history
changes by the agent are rejected. An unavailable agent or exhausted attempt
fails the upgrade. An initial failed CI attempt remains visible as a failure in
Actions even when the repaired candidate later passes and opens a PR.
Preparation follows the [Mesh repair lifecycle](https://github.com/Mesh-LLM/mesh-llm/blob/37f1590cffa15e88c951a635ab42aa249b60ab73/scripts/llama-canary-agent-repair.sh#L752).
A unique named Goose session receives the first failure and resumes with exact
verification errors and per-command logs until preparation passes or the coding
window expires. Legacy Goose overrides containing `--no-session` are upgraded
to named sessions. Custom executable adapters receive the prompt each turn and
own any session persistence they require.

All turns share one 11h30 wall-clock coding window. Each returned turn receives
a fresh 12-hour verification window; the complete preparation/export process
is bounded at 23h40 inside the 23h50 job. Existing individual command limits
also apply. Verification runs real preparation, native builds, generation,
bindings, graph coverage and recipe generation before freezing the candidate.
Full CI then validates its exact SHA. A failed full CI candidate enters the same
preparation loop with its retained CI evidence before receiving fresh full CI.

Every returned repair turn and final exit retains an explicitly unverified
source checkpoint outside the temporary checkout. It includes the outer diff,
untracked source files and native changes against the selected upstream,
including native commits not yet exported to patches. Missing native bases use
a full tracked-tree patch. Manifests record bases and heads; tracked patches and
untracked inputs each have a 256 MiB capture limit. Recovery errors are reported
without replacing the original outcome. Failure/cancellation uploads recovery
before verbose diagnostics. Hard runner loss can still prevent a final capture;
completed checkpoints remain available. These files are diagnostic recovery
inputs, never successful qualification evidence or publication authority.

Patch staging is rebuilt on every verification attempt. Preparation excludes
`.skippy-*` bookkeeping files from Git staging; repaired patch inputs touching
those files are rejected and returned to the session. Repair may change native
patch queues, bindings and API docs. Agent changes to policy, workflows,
fixtures, the selected pin, outer history or generated admission inputs fail.

Run offline lifecycle regressions with `just ci-automation`. A live provider
rehearsal is explicit: set `SKIPPY_UPGRADE_REPAIR_COMMAND` to the installed Goose
argv and run `just upgrade-goose-rehearsal`. This checks two real agent turns,
session resumption, failure feedback and checkpoint capture; it does not qualify
a native upgrade or model.

Only the publisher uses `SKIPPY_UPGRADE_APP_ID` and
`SKIPPY_UPGRADE_APP_PRIVATE_KEY`. Its Contents and Pull requests write permissions
Expand Down
5 changes: 5 additions & 0 deletions ci/automation.just
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ automation-contracts: inference-contracts
@PYTHONPATH=scripts "{{ automation_python }}" scripts/tests/ci_process_environment.py
@PYTHONPATH=scripts "{{ automation_python }}" scripts/tests/automation_contracts.py
@PYTHONPATH=scripts "{{ automation_python }}" scripts/tests/upgrade_contracts.py
@PYTHONPATH=scripts "{{ automation_python }}" scripts/tests/upgrade_lifecycle.py
@PYTHONPATH=scripts "{{ automation_python }}" scripts/tests/graph_contracts.py
@PYTHONPATH=scripts "{{ automation_python }}" scripts/tests/release_contracts.py

Expand All @@ -27,3 +28,7 @@ ci-automation: automation-contracts inference-publication-test
[positional-arguments]
ci-automation-setup directory:
@bash scripts/ci-automation-setup.sh "$@"

# Explicit model-backed controller rehearsal; excluded from offline defaults.
upgrade-goose-rehearsal:
@PYTHONPATH=scripts "{{ automation_python }}" scripts/tests/upgrade_goose_rehearsal.py
37 changes: 37 additions & 0 deletions scripts/lib/ci_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@
import threading
import time
from contextlib import contextmanager
from contextvars import ContextVar

DEADLINE = ContextVar("command_deadline", default=None)
LOGS = ContextVar("command_logs", default=None)


@contextmanager
def time_budget(seconds):
deadline = time.monotonic() + seconds
previous = DEADLINE.get()
token = DEADLINE.set(min(previous, deadline) if previous is not None else deadline)
try:
yield
finally:
DEADLINE.reset(token)


@contextmanager
def command_logs(directory):
directory.mkdir(parents=True, exist_ok=True)
token = LOGS.set([directory, 0])
try:
yield
finally:
LOGS.reset(token)


def environment(overrides=None):
Expand Down Expand Up @@ -147,6 +172,18 @@ def read():

def command(args, timeout=180, overrides=None, capture_stdout=False, cwd=None, *,
limit=16 * 1024 * 1024, raw=False, inherit_env=True, stdout=None, stderr=None):
if DEADLINE.get() is not None:
timeout = min(timeout, DEADLINE.get() - time.monotonic())
if timeout <= 0:
raise subprocess.TimeoutExpired(args, 0)
logs = LOGS.get()
if logs is not None and not capture_stdout and stdout is None and stderr is None:
logs[1] += 1
path = logs[0] / f"step-{logs[1]:03d}.log"
print(f"Verification step {logs[1]}: {args[0]} (log: {path})", flush=True)
with path.open("wb") as stream:
return command(args, timeout=timeout, overrides=overrides, cwd=cwd, limit=limit,
raw=raw, inherit_env=inherit_env, stdout=stream, stderr=subprocess.STDOUT)
deadline = time.monotonic() + timeout
with start(args, overrides, cwd=cwd, inherit_env=inherit_env,
stdout=subprocess.PIPE if capture_stdout else stdout, stderr=stderr) as child:
Expand Down
55 changes: 55 additions & 0 deletions scripts/lib/upgrade_lifecycle.py
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")
74 changes: 74 additions & 0 deletions scripts/lib/upgrade_recovery.py
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")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
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)
20 changes: 18 additions & 2 deletions scripts/lib/upgrade_regeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
SCRIPTS = Path(__file__).resolve().parents[1]


def validate_patch_metadata(patches):
for patch in patches.rglob("*.patch"):
paths = command(["git", "apply", "--numstat", "-z", str(patch.resolve())], capture_stdout=True)
for entry in paths.split("\0"):
path = entry.rsplit("\t", 1)[-1]
if path.split("/", 1)[0].startswith(".skippy-"):
raise ValueError(f"repair patch contains preparation metadata: {patch}: {path}")


def stage_patches(source, destination):
shutil.rmtree(destination, ignore_errors=True)
patches_only(source, destination, exclude_generated=True)
validate_patch_metadata(destination)


def patches_only(source, destination, exclude_generated=False):
destination.mkdir(parents=True, exist_ok=True)
for item in source.iterdir():
Expand All @@ -31,7 +46,7 @@ def patches_only(source, destination, exclude_generated=False):
def regenerate(checkout):
scratch = checkout / "target/llama-regeneration"
patches, native, tools = (scratch / name for name in ("core-patches", "native", "rewriter"))
patches_only(checkout / "llama_cpp/patches", patches, exclude_generated=True)
stage_patches(checkout / "llama_cpp/patches", patches)
source = checkout / ".deps/llama.cpp"
env = {"LLAMA_WORKDIR": str(source), "LLAMA_PIN_FILE": str(checkout / PIN),
"LLAMA_PATCH_DIR": str(patches), "LLAMA_STAGE_BUILD_DIR": str(native),
Expand All @@ -46,6 +61,7 @@ def regenerate(checkout):
command(["cmake", "--build", str(tools), "--parallel"], timeout=3600)
command(["ctest", "--test-dir", str(tools), "--output-on-failure", "--no-tests=error"], timeout=600)
generated, report = scratch / "generated", scratch / "report.json"
shutil.rmtree(generated, ignore_errors=True)
family_map = checkout / "ci/llama-canary/generated-family-map.json"
manifest = checkout / "ci/llama-canary/model-fixtures.json"
argv = [sys.executable, str(SCRIPTS / "generate-skippy-family-patch.py"), "generate",
Expand All @@ -65,7 +81,7 @@ def regenerate(checkout):
"--root", str(checkout), "--source-root", str(source), "--report", str(report),
"--output", str(scratch / "graph-coverage.json")])
destination = checkout / "llama_cpp/patches/generated"
shutil.rmtree(destination)
shutil.rmtree(destination, ignore_errors=True)
patches_only(generated, destination)
env.pop("LLAMA_PATCH_DIR")
command([*just, "llama-build"], overrides=env, timeout=7200)
Expand Down
Loading
Loading