S4 (设备中心补齐): - capability_matrix.py: per-board capability support (supported/degraded/ unavailable) with S100P + generic-SSH matrices; unknown boards fail closed; serial-only link is never Agent-runnable. Classify is the pure decision the device center and Agent both consult (docs/06 §8.1, docs/11). - serial_console.py: discover /dev/cu.*/tty.* + a READ-ONLY log tail with high-confidence secret redaction. Policy: serial is never an Agent-run target and never Agent-writable; the Agent only reads redacted lines (§8.2 — don't mistake a serial link for an Agent-run target). S5 (系统准备烧录): - flashing.py: FlashState machine (idle->selected->confirmed->writing-> verifying->done/failed/cancelled), FlashImage catalog, FlashManifest with recovery steps + a human-only confirm token. - flashing_service.py: FlashingService — Agent-facing suggest_flash (builds the wizard plan, NEVER executes); human-only confirm_flash (rejects any non-USER actor — FLASH_AGENT_DENIED); pluggable write engine; fake engine covers the state machine. The real XBurn engine runs only under human-watch HIL (§9.1; CLAUDE.md: Agent never triggers the final flash). S6 (替代发布门禁): - docs/11 replacement matrix gains an 证据 column per row (automated/HIL/ usability or honest pending-<phase>); scripts/check_replacement_matrix.py machine-checks every row has an evidence cell; S6 closure asserts pending==0. Gates: pytest 681 (+14), ruff/mypy clean (48 files).
71 lines
2.6 KiB
Python
71 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""S6 replacement-matrix checker (docs/11 §3, §10.2).
|
|
|
|
Every row of the replacement matrix must carry an evidence cell (automated
|
|
test / HIL evidence / usability). `pending-<phase>` is an honest "not done
|
|
yet" marker — it satisfies the *structure* gate (the row is tracked) but not
|
|
the S6 *closure* gate (which requires zero pending). This script enforces
|
|
structure and reports the pending count; S6 closure asserts pending == 0.
|
|
|
|
Exit 0 if every data row has a non-empty evidence cell; exit 1 otherwise.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
MATRIX = Path(__file__).resolve().parent.parent / "docs" / "11-rdk-studio-replacement-plan.md"
|
|
TABLE_START = "## 3. 替代矩阵"
|
|
|
|
|
|
def parse_rows() -> list[tuple[str, str]]:
|
|
"""Return [(workflow, evidence)] for each data row of the matrix."""
|
|
lines = MATRIX.read_text(encoding="utf-8").splitlines()
|
|
try:
|
|
start = next(i for i, line in enumerate(lines) if line.startswith(TABLE_START))
|
|
except StopIteration as exc:
|
|
raise SystemExit(f"matrix section '{TABLE_START}' not found in {MATRIX}") from exc
|
|
rows: list[tuple[str, str]] = []
|
|
for line in lines[start + 1 :]:
|
|
if not line.startswith("|"):
|
|
if line.startswith("## "): # next section
|
|
break
|
|
continue
|
|
cells = [c.strip() for c in line.strip().strip("|").split("|")]
|
|
if len(cells) < 5 or cells[0] in ("用户工作流", "---"):
|
|
continue
|
|
if set(cells[0]) <= {"-", ":"}:
|
|
continue
|
|
rows.append((cells[0], cells[4] if len(cells) > 4 else ""))
|
|
return rows
|
|
|
|
|
|
def main() -> int:
|
|
rows = parse_rows()
|
|
if not rows:
|
|
print("FAIL: no matrix data rows found", file=sys.stderr)
|
|
return 1
|
|
missing = [(wf, ev) for wf, ev in rows if not ev]
|
|
pending = [(wf, ev) for wf, ev in rows if ev.startswith("pending")]
|
|
evidenced = [(wf, ev) for wf, ev in rows if ev and not ev.startswith("pending")]
|
|
for wf, ev in rows:
|
|
print(f" [{'x' if ev else ' '}] {wf}: {ev[:80]}")
|
|
print(
|
|
f"\n{len(rows)} rows: {len(evidenced)} evidenced, "
|
|
f"{len(pending)} pending, {len(missing)} missing"
|
|
)
|
|
if missing:
|
|
print("FAIL: rows missing an evidence cell:", file=sys.stderr)
|
|
for wf, _ in missing:
|
|
print(f" {wf}", file=sys.stderr)
|
|
return 1
|
|
print("OK: every row has an evidence cell (structure gate).")
|
|
if pending:
|
|
print(f"NOTE: {len(pending)} pending — S6 closure requires zero pending.")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|