File size: 7,641 Bytes
7e9a520 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | """Generate a release-readiness gate report for AtlasOps.
The goal is to provide a single command that validates core shipping evidence
before hackathon submission and emits a human-readable markdown report.
"""
from __future__ import annotations
import argparse
from dataclasses import dataclass
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parents[1]
DEFAULT_OUTPUT = ROOT / "docs" / "RELEASE_READINESS.md"
@dataclass
class CheckResult:
name: str
status: str # PASS | FAIL | WARN
details: str
critical: bool = True
def _exists(path: Path) -> bool:
return path.exists()
def _read_text(path: Path) -> str:
return path.read_text(encoding="utf-8") if path.exists() else ""
def check_artifact_presence() -> list[CheckResult]:
required = [
ROOT / "docs" / "AMD_FINAL_DELIVERY_SCORECARD_AND_REWARD_SPEC.md",
ROOT / "docs" / "MI300X_EVIDENCE.md",
ROOT / "bench" / "results" / "comparison_table.md",
ROOT / "tests" / "test_app_endpoints.py",
ROOT / "tests" / "test_bench_runner.py",
ROOT / "tests" / "test_chaos_manifests.py",
]
missing = [str(p.relative_to(ROOT)) for p in required if not _exists(p)]
if missing:
return [CheckResult("Required artifacts", "FAIL", f"Missing: {', '.join(missing)}", True)]
return [CheckResult("Required artifacts", "PASS", "All required docs/results/tests present.", True)]
def check_chaos_manifest_inventory() -> list[CheckResult]:
expected = {
"single_fault": 8,
"cascade": 5,
"multi_fault": 5,
"named_replays": 10,
}
results: list[CheckResult] = []
for tier, count in expected.items():
actual = len(list((ROOT / "bench" / "chaos_manifests" / tier).glob("*.yaml")))
if actual != count:
results.append(
CheckResult(
f"Chaos manifest count ({tier})",
"FAIL",
f"Expected {count}, found {actual}.",
True,
)
)
else:
results.append(
CheckResult(
f"Chaos manifest count ({tier})",
"PASS",
f"Expected {count}, found {actual}.",
True,
)
)
return results
def check_runtime_tiers() -> list[CheckResult]:
runtime_text = _read_text(ROOT / "config" / "runtime.py")
expected_tiers = ["warmup", "single_fault", "cascade", "multi_fault", "adversarial"]
missing_from_speed = [t for t in expected_tiers if f'"{t}"' not in runtime_text]
base = []
if missing_from_speed:
base.append(
CheckResult(
"Difficulty tiers declared",
"FAIL",
"Missing tier labels in runtime config: " + ", ".join(missing_from_speed),
True,
)
)
else:
base.append(
CheckResult(
"Difficulty tiers declared",
"PASS",
"All five required tiers are declared in runtime config.",
True,
)
)
# Advisory: warmup/adversarial scenario pools are often omitted accidentally.
advisory_missing = [
t for t in ("warmup", "adversarial") if f'SCENARIOS_BY_TIER = {{' in runtime_text and f'"{t}":' not in runtime_text
]
if advisory_missing:
base.append(
CheckResult(
"Tier scenario pool coverage",
"WARN",
"No explicit SCENARIOS_BY_TIER entries for: " + ", ".join(advisory_missing),
False,
)
)
else:
base.append(
CheckResult(
"Tier scenario pool coverage",
"PASS",
"Scenario pools include all required tiers or intentionally map tiers elsewhere.",
False,
)
)
return base
def check_ui_runtime_config() -> list[CheckResult]:
app_text = _read_text(ROOT / "app.py")
static_text = _read_text(ROOT / "static" / "index.html")
checks = [
("/config endpoint", '@app.get("/config")' in app_text),
("Static UI dynamic config", "fetch('/config'" in static_text),
]
out: list[CheckResult] = []
for name, ok in checks:
out.append(
CheckResult(
name,
"PASS" if ok else "FAIL",
"Configured correctly." if ok else "Missing expected runtime-config wiring.",
True,
)
)
return out
def check_benchmark_columns() -> list[CheckResult]:
table = _read_text(ROOT / "bench" / "results" / "comparison_table.md")
if not table:
return [CheckResult("Benchmark output sanity", "FAIL", "comparison_table.md missing or empty.", True)]
expected_tokens = ["avg_reward_contract", "avg_penalty", "unsafe_actions", "false_resolution", "hallucinated_evidence"]
missing = [t for t in expected_tokens if t not in table]
if missing:
return [
CheckResult(
"Benchmark output sanity",
"WARN",
"Missing newer anti-gaming columns: " + ", ".join(missing),
False,
)
]
return [CheckResult("Benchmark output sanity", "PASS", "Anti-gaming benchmark columns present.", False)]
def run_checks() -> list[CheckResult]:
results: list[CheckResult] = []
results.extend(check_artifact_presence())
results.extend(check_chaos_manifest_inventory())
results.extend(check_runtime_tiers())
results.extend(check_ui_runtime_config())
results.extend(check_benchmark_columns())
return results
def render_report(results: list[CheckResult]) -> str:
critical_failures = [r for r in results if r.critical and r.status == "FAIL"]
warnings = [r for r in results if r.status == "WARN"]
overall = "PASS" if not critical_failures else "FAIL"
lines = [
"# AtlasOps Release Readiness",
"",
f"- Overall: **{overall}**",
f"- Critical failures: **{len(critical_failures)}**",
f"- Warnings: **{len(warnings)}**",
"",
"## Checks",
]
for r in results:
icon = "PASS" if r.status == "PASS" else ("FAIL" if r.status == "FAIL" else "WARN")
gate = "critical" if r.critical else "advisory"
lines.append(f"- [{icon}] `{r.name}` ({gate}) - {r.details}")
lines.append("")
if critical_failures:
lines.append("## Blockers")
for r in critical_failures:
lines.append(f"- `{r.name}` - {r.details}")
lines.append("")
return "\n".join(lines) + "\n"
def main() -> int:
parser = argparse.ArgumentParser(description="Run AtlasOps release readiness gate.")
parser.add_argument("--output", default=str(DEFAULT_OUTPUT), help="Markdown report output path.")
parser.add_argument("--strict", action="store_true", help="Return non-zero on critical failures.")
args = parser.parse_args()
results = run_checks()
report = render_report(results)
output_path = Path(args.output)
output_path.parent.mkdir(parents=True, exist_ok=True)
output_path.write_text(report, encoding="utf-8")
print(f"Wrote release readiness report: {output_path}")
critical_failures = [r for r in results if r.critical and r.status == "FAIL"]
if args.strict and critical_failures:
print("Release gate failed (critical checks).", file=sys.stderr)
return 1
return 0
if __name__ == "__main__":
raise SystemExit(main())
|