mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
247fcccb5f
## Outcome Defines the GC 3.3 factory as one semantic intelligence loop with deterministic delivery: - Fable Mayor plus a bounded, nonbinding ambiguity adviser - Sol-high for plan binding and fresh exact-subject validation - Terra-high as the default writer and Opus 4.8 medium as explicit overflow/repair - Luna dormant and unroutable until later qualification - no model-driven delivery-policy/refinery loop - native GC sling/claim/scale-from-zero semantics retained - exact provider/model/reasoning/fallback runtime attestation - legacy composed program/refinery entry points and opposite-provider lifecycle roles removed Controller dispatch to the Fable adviser stays fail-closed until GC33-4 proves process/filesystem isolation. This does not claim that manual operator sling to the named on-demand target is impossible. ## Evidence Fresh Sol-high `verdict.v2`: PASS (`bb31806fc5e0714363a9e539121ee7aa19231431fb04ddfee1fce8376b57d272`) over subject manifest `119b7a6db2380af47d87a24aced60d96858dd9e413a54dc640376e27767e8d1e` (52 paths, 18 deletions). - focused acceptance: 124 tests PASS - projection owner: 4 tests PASS - bootstrap fixtures: 25 Bats tests PASS - complete GC static contract: PASS - factory/executor doctors: PASS - generated projection check: PASS - exact official GC v1.3.5 and Beads v1.1.0 provenance replay: PASS - `git diff --check`: PASS No city, model session, supervisor, tmux session, Dolt server, or canary was started for this pre-canary bead.
147 lines
6.3 KiB
Python
147 lines
6.3 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
import stat
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
SCRIPT = REPO_ROOT / "scripts" / "sync-gc-pack.py"
|
|
|
|
|
|
class SyncGCPackTests(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.tempdir = tempfile.TemporaryDirectory()
|
|
self.addCleanup(self.tempdir.cleanup)
|
|
self.root = Path(self.tempdir.name)
|
|
for skill in ("implement", "validate", "using-gc"):
|
|
source = self.root / "skills" / skill
|
|
source.mkdir(parents=True)
|
|
(source / "SKILL.md").write_text(f"# {skill}\n", encoding="utf-8")
|
|
(source / "prompt.md").write_text("codex prompt\n", encoding="utf-8")
|
|
(source / ".agentops-generated.json").write_text("{}\n", encoding="utf-8")
|
|
|
|
implement_script = self.root / "skills" / "implement" / "scripts" / "validate.sh"
|
|
implement_script.parent.mkdir()
|
|
implement_script.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")
|
|
implement_script.chmod(0o755)
|
|
|
|
validate_cache = self.root / "skills" / "validate" / "scripts" / "__pycache__"
|
|
validate_cache.mkdir(parents=True)
|
|
(validate_cache / "validate.cpython-314.pyc").write_bytes(b"cache")
|
|
(self.root / "skills" / "validate" / "scripts" / "helper.pyc").write_bytes(b"cache")
|
|
|
|
def run_sync(self, *args: str) -> subprocess.CompletedProcess[str]:
|
|
return subprocess.run(
|
|
[sys.executable, str(SCRIPT), "--repo-root", str(self.root), *args],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
def destination(self, skill: str, provider: str = "codex") -> Path:
|
|
suffix = "" if provider == "codex" else "-claude"
|
|
if skill == "implement":
|
|
return self.root / "packs" / "agentops-executor" / "agents" / f"implementer{suffix}" / "skills" / skill
|
|
if skill == "validate":
|
|
return self.root / "packs" / "agentops-executor" / "agents" / f"validator{suffix}" / "skills" / skill
|
|
return self.root / "packs" / "agentops-executor" / "skills" / skill
|
|
|
|
def snapshot(self) -> dict[str, tuple[bytes, int, int]]:
|
|
return {
|
|
path.relative_to(self.root).as_posix(): (
|
|
path.read_bytes(),
|
|
stat.S_IMODE(path.stat().st_mode),
|
|
path.stat().st_mtime_ns,
|
|
)
|
|
for path in sorted(self.root.rglob("*"))
|
|
if path.is_file()
|
|
}
|
|
|
|
def test_regen_projects_runtime_payload_and_stable_manifest(self) -> None:
|
|
result = self.run_sync()
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
|
|
for skill in ("implement", "validate", "using-gc"):
|
|
providers = {
|
|
"implement": ("codex", "claude"),
|
|
"validate": ("codex",),
|
|
"using-gc": ("codex",),
|
|
}[skill]
|
|
for provider in providers:
|
|
destination = self.destination(skill, provider)
|
|
self.assertEqual((destination / "SKILL.md").read_text(encoding="utf-8"), f"# {skill}\n")
|
|
self.assertFalse((destination / "prompt.md").exists())
|
|
self.assertFalse((destination / ".agentops-generated.json").exists())
|
|
self.assertFalse((self.destination("validate") / "scripts" / "__pycache__").exists())
|
|
self.assertFalse((self.destination("validate") / "scripts" / "helper.pyc").exists())
|
|
self.assertTrue((self.destination("implement") / "scripts" / "validate.sh").stat().st_mode & stat.S_IXUSR)
|
|
self.assertTrue((self.destination("implement", "claude") / "scripts" / "validate.sh").stat().st_mode & stat.S_IXUSR)
|
|
|
|
manifest_path = self.root / "packs" / "agentops-executor" / "assets" / "generated-skill-manifest.json"
|
|
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
self.assertEqual(manifest["schema_version"], "agentops.gc-skill-projection.v1")
|
|
self.assertEqual(manifest["source"], "skills")
|
|
self.assertEqual(
|
|
[row["destination"] for row in manifest["files"]],
|
|
sorted(row["destination"] for row in manifest["files"]),
|
|
)
|
|
for row in manifest["files"]:
|
|
self.assertIn("source", row)
|
|
self.assertIn("destination", row)
|
|
self.assertRegex(row["source_sha256"], r"^[a-f0-9]{64}$")
|
|
self.assertEqual(row["source_sha256"], row["sha256"])
|
|
|
|
first = manifest_path.read_bytes()
|
|
result = self.run_sync()
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
self.assertEqual(manifest_path.read_bytes(), first)
|
|
|
|
def test_check_detects_drift_without_mutating_any_file(self) -> None:
|
|
self.assertEqual(self.run_sync().returncode, 0)
|
|
drifted = self.destination("implement") / "SKILL.md"
|
|
drifted.write_text("manual drift\n", encoding="utf-8")
|
|
retired = self.destination("validate", "claude") / "stale.txt"
|
|
retired.parent.mkdir(parents=True)
|
|
retired.write_text("retired\n", encoding="utf-8")
|
|
before = self.snapshot()
|
|
|
|
result = self.run_sync("--check")
|
|
|
|
self.assertEqual(result.returncode, 1)
|
|
self.assertIn("implement", result.stderr)
|
|
self.assertIn("retired projection", result.stderr)
|
|
self.assertEqual(self.snapshot(), before)
|
|
|
|
def test_regen_exact_deletes_stale_destination_files(self) -> None:
|
|
self.assertEqual(self.run_sync().returncode, 0)
|
|
stale = self.destination("validate") / "stale.txt"
|
|
stale.write_text("stale\n", encoding="utf-8")
|
|
retired = self.destination("validate", "claude") / "stale.txt"
|
|
retired.parent.mkdir(parents=True)
|
|
retired.write_text("retired\n", encoding="utf-8")
|
|
|
|
result = self.run_sync()
|
|
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
self.assertFalse(stale.exists())
|
|
self.assertFalse(retired.parent.exists())
|
|
|
|
def test_check_on_missing_projection_is_nonmutating(self) -> None:
|
|
before = self.snapshot()
|
|
|
|
result = self.run_sync("--check")
|
|
|
|
self.assertEqual(result.returncode, 1)
|
|
self.assertIn("missing", result.stderr)
|
|
self.assertEqual(self.snapshot(), before)
|
|
self.assertFalse((self.root / "packs").exists())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|