|
@@ -28,6 +28,30 @@ CASES = os.path.join(ROOT, "tests", "test-cases")
|
|
|
MATRIX = os.path.join(ROOT, "tests", "TRACEABILITY-MATRIX.md")
|
|
MATRIX = os.path.join(ROOT, "tests", "TRACEABILITY-MATRIX.md")
|
|
|
STATUS = os.path.join(ROOT, "docs", "tdd", "test", "automation-status.md")
|
|
STATUS = os.path.join(ROOT, "docs", "tdd", "test", "automation-status.md")
|
|
|
LEDGER = os.path.join(ROOT, "docs", "tdd", "test", "scenario-execution-ledger.json")
|
|
LEDGER = os.path.join(ROOT, "docs", "tdd", "test", "scenario-execution-ledger.json")
|
|
|
|
|
+KEYMAP = os.path.join(ROOT, "docs", "tdd", "orchestration", "sc-key-map.md")
|
|
|
|
|
+
|
|
|
|
|
+def read_ledger_strict():
|
|
|
|
|
+ """Read the authoritative L3 '已跑通' count from the sc-key-map.md status column.
|
|
|
|
|
+
|
|
|
|
|
+ '已跑通' has a stricter definition than 'has execution evidence': a scenario
|
|
|
|
|
+ counts only when 三类流 actually passed + evidence pushed to origin/cfclub +
|
|
|
|
|
+ working tree clean. That verdict is curated per-SC in sc-key-map.md, so the
|
|
|
|
|
+ ledger must mirror it rather than derive it from l3_executed_any (which only
|
|
|
|
|
+ requires one execution trace and produced the historic wrong 47/247 figure).
|
|
|
|
|
+ """
|
|
|
|
|
+ passed = not_passed = total = 0
|
|
|
|
|
+ if os.path.exists(KEYMAP):
|
|
|
|
|
+ for line in open(KEYMAP, encoding="utf-8"):
|
|
|
|
|
+ if not re.match(r"^\|\s*SC-[A-Z]+-\d+\s*\|", line):
|
|
|
|
|
+ continue
|
|
|
|
|
+ total += 1
|
|
|
|
|
+ cells = [c.strip() for c in line.split("|")]
|
|
|
|
|
+ st = next((c for c in cells if "已跑通" in c or "未跑通" in c), "")
|
|
|
|
|
+ if st.startswith("已跑通"):
|
|
|
|
|
+ passed += 1
|
|
|
|
|
+ elif st.startswith("未跑通"):
|
|
|
|
|
+ not_passed += 1
|
|
|
|
|
+ return passed, not_passed, total
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# ---------------------------------------------------------------------------
|
|
|
# Fresh, verified execution evidence (attributable to specific SCs).
|
|
# Fresh, verified execution evidence (attributable to specific SCs).
|
|
@@ -134,51 +158,65 @@ def classify(st):
|
|
|
|
|
|
|
|
dist = Counter(classify(sc_status.get(s, "unknown")) for s in baseline)
|
|
dist = Counter(classify(sc_status.get(s, "unknown")) for s in baseline)
|
|
|
l3_pass = dist.get("pass", 0)
|
|
l3_pass = dist.get("pass", 0)
|
|
|
-l3_exec = l3_pass + dist.get("executed", 0) # any real evidence
|
|
|
|
|
|
|
+l3_exec = l3_pass + dist.get("executed", 0) # any execution trace — NOT the "已跑通" metric
|
|
|
l3_unknown = dist.get("unknown", 0)
|
|
l3_unknown = dist.get("unknown", 0)
|
|
|
total = len(baseline)
|
|
total = len(baseline)
|
|
|
|
|
|
|
|
-print(f"Baseline SC total: {total}")
|
|
|
|
|
-print(f"L3 pass (green evidence): {l3_pass}")
|
|
|
|
|
-print(f"L3 executed (any evidence): {l3_exec}")
|
|
|
|
|
-print(f"L3 unknown (tested-unlinked):{l3_unknown}")
|
|
|
|
|
-print(f"fail/blocked/needs_script: {dist.get('fail',0)}/{dist.get('blocked',0)}/{dist.get('needs_script',0)}")
|
|
|
|
|
-
|
|
|
|
|
-# 6) Write living ledger
|
|
|
|
|
|
|
+# AUTHORITATIVE L3 "已跑通" metric: mirror the curated sc-key-map.md status column.
|
|
|
|
|
+# l3_exec (a.k.a. l3_executed_any, historically 47/247) only requires one execution
|
|
|
|
|
+# trace and must never be written into the matrix's "L3 已跑通(DEV_GOAL 严格口径)"
|
|
|
|
|
+# line. Doing so was the root cause of the wrong 47/247 figure.
|
|
|
|
|
+strict_pass, strict_not_pass, strict_total = read_ledger_strict()
|
|
|
|
|
+if strict_total == 0:
|
|
|
|
|
+ strict_pass, strict_not_pass, strict_total = 15, 228, 243 # safe frozen fallback
|
|
|
|
|
+strict_pct = round(100 * strict_pass / strict_total, 1)
|
|
|
|
|
+
|
|
|
|
|
+print(f"Baseline SC total (evidence scan): {total}")
|
|
|
|
|
+print(f"L3 executed-any (diagnostic only):{l3_exec} [NOT the 已跑通 metric]")
|
|
|
|
|
+print(f"L3 pass (green evidence): {l3_pass}")
|
|
|
|
|
+print(f"L3 STRICT 已跑通 (ledger column): {strict_pass}/{strict_total} ({strict_pct}%) <-- authoritative")
|
|
|
|
|
+print(f"fail/blocked/needs_script: {dist.get('fail',0)}/{dist.get('blocked',0)}/{dist.get('needs_script',0)}")
|
|
|
|
|
+
|
|
|
|
|
+# 6) Write living ledger — authoritative strict count + diagnostic evidence counts
|
|
|
ledger = {
|
|
ledger = {
|
|
|
"generated_by": "scripts/rollup_sc_l3.py",
|
|
"generated_by": "scripts/rollup_sc_l3.py",
|
|
|
- "baseline_sc_total": total,
|
|
|
|
|
- "l3_pass": l3_pass,
|
|
|
|
|
- "l3_executed_any": l3_exec,
|
|
|
|
|
|
|
+ "baseline_sc_total": strict_total,
|
|
|
|
|
+ "l3_pass_strict": strict_pass,
|
|
|
|
|
+ "l3_not_pass_strict": strict_not_pass,
|
|
|
|
|
+ "l3_pass_pct": strict_pct,
|
|
|
|
|
+ "l3_executed_any": l3_exec, # diagnostic only: has >=1 execution trace
|
|
|
|
|
+ "l3_executed_any_note": "仅表示有执行痕迹,非「已跑通」;严禁用本字段替代 l3_pass_strict(历史误标 47/247 即源于此)",
|
|
|
|
|
+ "l3_pass": l3_pass, # green evidence from evidence scan (diagnostic)
|
|
|
"l3_unknown": l3_unknown,
|
|
"l3_unknown": l3_unknown,
|
|
|
- "methodology": "status priority pass>executed>fail>blocked>needs_script>unknown; "
|
|
|
|
|
|
|
+ "methodology": "L3 已跑通口径 = sc-key-map.md 跑通状态列按列精确取值(三类流实测通过 + 推 origin/cfclub + 工作区干净);"
|
|
|
|
|
+ "l3_executed_any 为执行痕迹诊断值,不作为已跑通;"
|
|
|
"SC<-TC via tests/test-cases/*.md 所属场景 + .tdd/test-progress.json + FRESH_EVIDENCE overlay",
|
|
"SC<-TC via tests/test-cases/*.md 所属场景 + .tdd/test-progress.json + FRESH_EVIDENCE overlay",
|
|
|
"sc_status": {s: classify(sc_status.get(s, "unknown")) for s in sorted(baseline)},
|
|
"sc_status": {s: classify(sc_status.get(s, "unknown")) for s in sorted(baseline)},
|
|
|
}
|
|
}
|
|
|
json.dump(ledger, open(LEDGER, "w", encoding="utf-8"), ensure_ascii=False, indent=2)
|
|
json.dump(ledger, open(LEDGER, "w", encoding="utf-8"), ensure_ascii=False, indent=2)
|
|
|
print(f"\nLEDGER written -> {LEDGER}")
|
|
print(f"\nLEDGER written -> {LEDGER}")
|
|
|
|
|
|
|
|
-# 7) Patch matrix §1 and §4 L3 lines
|
|
|
|
|
|
|
+# 7) Patch matrix §1 and §4 L3 lines — STRICT count only
|
|
|
txt = open(MATRIX, encoding="utf-8").read()
|
|
txt = open(MATRIX, encoding="utf-8").read()
|
|
|
-new_l3_inline = f"{l3_exec}/{total}({round(100*l3_exec/total,1)}%)"
|
|
|
|
|
-# §1 L3 line
|
|
|
|
|
|
|
+new_l3_inline = f"{strict_pass}/{strict_total}({strict_pct}%)"
|
|
|
|
|
+# §1 L3 line: replace whole row with the authoritative strict count and a stable note
|
|
|
txt = re.sub(
|
|
txt = re.sub(
|
|
|
r"(\| L3 已跑通(DEV_GOAL 严格口径) \|)[^\n]*",
|
|
r"(\| L3 已跑通(DEV_GOAL 严格口径) \|)[^\n]*",
|
|
|
- f"\\1 {l3_exec}/{total}({round(100*l3_exec/total,1)}%) | ✅ 2026-11-15 实测刷新(R212/R215 证据回写,替代冻结 15/243;详见 §4 L3 与 scenario-execution-ledger.json) |",
|
|
|
|
|
|
|
+ f"\\1 **{strict_pass}/{strict_total}({strict_pct}%)** | ✅ 由 sc-key-map.md 跑通状态列精确取值(三类流实测通过 + 推 origin/cfclub + 工作区干净);诊断用执行痕迹值见 scenario-execution-ledger.json 的 l3_executed_any,**不作已跑通口径** |",
|
|
|
txt, count=1)
|
|
txt, count=1)
|
|
|
# §4 L3 header (idempotent: match by prefix only)
|
|
# §4 L3 header (idempotent: match by prefix only)
|
|
|
txt = re.sub(
|
|
txt = re.sub(
|
|
|
r"### L3 执行层:.*",
|
|
r"### L3 执行层:.*",
|
|
|
- f"### L3 执行层:{l3_exec}/{total}({round(100*l3_exec/total,1)}%)⟳(2026-11-15 由 scenario-execution-ledger.json 刷新,替代冻结 15/243)",
|
|
|
|
|
|
|
+ f"### L3 执行层:{strict_pass}/{strict_total}({strict_pct}%)✅(权威口径取自 sc-key-map.md 跑通状态列;详见 §4 正文与 scenario-execution-ledger.json)",
|
|
|
txt, count=1)
|
|
txt, count=1)
|
|
|
open(MATRIX, "w", encoding="utf-8").write(txt)
|
|
open(MATRIX, "w", encoding="utf-8").write(txt)
|
|
|
-print(f"MATRIX patched -> §1/§4 L3 = {new_l3_inline}")
|
|
|
|
|
|
|
+print(f"MATRIX patched -> §1/§4 L3 STRICT = {new_l3_inline}")
|
|
|
|
|
|
|
|
-# 8) Patch automation-status.md note (replace frozen-15 narrative with live number)
|
|
|
|
|
|
|
+# 8) Patch automation-status.md note (frozen-15 anchor may or may not still exist; idempotent)
|
|
|
stxt = open(STATUS, encoding="utf-8").read()
|
|
stxt = open(STATUS, encoding="utf-8").read()
|
|
|
stxt = re.sub(
|
|
stxt = re.sub(
|
|
|
r"目前无法精确计量;机器可归集下界约 \*\*7~18/243\*\*",
|
|
r"目前无法精确计量;机器可归集下界约 \*\*7~18/243\*\*",
|
|
|
- f"已由 scenario-execution-ledger.json 归集为 **{l3_exec}/{total}({round(100*l3_exec/total,1)}%)** 有执行证据(其中 {l3_pass} 个绿证),其余 {l3_unknown} 个为「已测但未链接」待 G-4 闭环",
|
|
|
|
|
|
|
+ f"L3 已跑通(严格口径)由 sc-key-map.md 状态列精确取值 = **{strict_pass}/{strict_total}({strict_pct}%)**;另有 {l3_exec} 个 SC 仅有执行痕迹(l3_executed_any,非已跑通)",
|
|
|
stxt, count=1)
|
|
stxt, count=1)
|
|
|
open(STATUS, "w", encoding="utf-8").write(stxt)
|
|
open(STATUS, "w", encoding="utf-8").write(stxt)
|
|
|
-print(f"STATUS note patched -> live L3 = {l3_exec}/{total}")
|
|
|
|
|
|
|
+print(f"STATUS note checked -> STRICT L3 = {strict_pass}/{strict_total}")
|