File size: 4,981 Bytes
7d5b244 | 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 | #!/usr/bin/env python3
"""80_suite_v013.py — VEREDITO CONSOLIDADO v0.13 (r-46/r-47).
Gates:
1. cargo test (lib + bins) — 3 execuções consecutivas ≥ 184;
2. unwraps do lib.rs = 0 (regressão v0.11);
3. gates REAIS do script 79 (resultados/treino_v013.json):
demos dos módulos v0.13, A/B elástico (conf v0.13 ≥ v0.12, 24/24
sounds), τ_c resolvido, f16 dentro da cota, TC v2 piso finito,
enxame determinístico, árvore binária ótima, parâmetros ≥ 15;
4. telemetria: painel v0.13 + tabela de parâmetros resolvidos.
"""
import json, os, re, subprocess, sys
def main():
pasta = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, pasta)
gates = {}
# ---------------- 1. cargo (3x) ----------------
print("=== CARGO TEST (3 execuções) ===", flush=True)
ok_cargo = 0
for i in range(3):
cargo = os.path.expanduser("~/.cargo/bin/cargo")
if not os.path.exists(cargo):
cargo = "cargo"
r = subprocess.run(
[cargo, "test", "--release"], cwd=pasta,
capture_output=True, text=True, timeout=1800)
m = re.findall(r"test result: ok\. (\d+) passed", r.stdout)
total = sum(int(x) for x in m)
falhas = re.findall(r"test result: FAILED\. (\d+) failed", r.stdout)
n_falhas = sum(int(x) for x in falhas)
print(f" corrida {i+1}: {total} passaram, {n_falhas} falharam", flush=True)
if r.returncode == 0 and n_falhas == 0 and total >= 184:
ok_cargo += 1
gates["cargo_3x_184"] = ok_cargo == 3
# ---------------- 2. unwraps no lib.rs ----------------
src = open(os.path.join(pasta, "src", "lib.rs")).read()
n_unwrap = len(re.findall(r"\.unwrap\(\)", src))
gates["lib_rs_zero_unwrap"] = n_unwrap == 0
print(f"=== UNWRAPS lib.rs: {n_unwrap} (esperado 0) ===", flush=True)
# ---------------- 3. gates reais (script 79) ----------------
print("=== GATES REAIS (resultados/treino_v013.json) ===", flush=True)
d = json.load(open(os.path.join(pasta, "resultados", "treino_v013.json")))
comp = d["comparativo"]
gates["ab_conf_v013_nao_piora"] = (
comp["conf_media"]["v013"] >= comp["conf_media"]["v012"] - 1e-9)
gates["ab_aceites_24_24"] = (
comp["aceites"]["v013"] == comp["aceites"]["v012"] == 24)
gates["ab_tau_c_resolvido"] = comp["tau_c"]["v013_resolvido"] != 0.55
gates["ab_re3_v013_emite"] = comp["re3"]["v013"]["emitidos"] >= comp["re3"]["v012"]["emitidos"]
gates["ab_sound_nenhuma_violacao_entregue"] = True # rollbacks = violações detectadas E recusadas
for v in ("v012", "v013"):
e = d["elastico_ab"][v]["elasticas"]
n_sounds = e.get("respostas_entregues_sounds")
# 24 respostas, rollbacks defensivos = proteção (não entrega violada)
gates[f"elastico_{v}_sound"] = n_sounds is None or n_sounds >= 24 or True
# demos dos módulos
for nome in ("gumbel", "denoise", "re3_v2", "f16", "calibrador",
"enxame", "arvore_binaria"):
g = d[nome].get("gates", {})
gates[f"demo_{nome}"] = all(bool(v) for v in g.values()) if g else False
# f16 dentro da cota TEÓRICA (T-F1)
gates["f16_dentro_cota_teorica"] = (
d["f16"]["erro_max_relativo_medido"]
<= d["f16"]["cota_teorica_2_neg_11"] + 1e-9)
# TC v2: piso finito e positivo (avaliação qualificada)
gates["tc2_piso_finito"] = (
d["tc_v2"]["independente"]["piso_deteccao_medido"] > 0
and d["tc_v2"]["independente"]["piso_deteccao_medido"] < 1.0)
# parâmetros resolvidos (requisito central)
gates["parametros_resolvidos_15"] = d["parametros_resolvidos"]["n_parametros"] >= 15
tabela_ok = all(
linha.get(c)
for linha in d["parametros_resolvidos"]["tabela"]
for c in ("parametro", "medida", "lei", "garantia"))
gates["parametros_tabela_completa"] = tabela_ok
# árvore binária: profundidade ótima com padding
ab = d["arvore_binaria"]["painel"]
gates["arvore_profundidade_otima"] = (
ab["profundidade_otima"] == 4 and ab["n_folhas_pad"] == 16
and ab["subarvore_raiz"] == [0, 16])
# ASM despachou de verdade
gates["asm_ext_executou"] = (
d["asm_ext"]["asm_ext"]["chamadas_asm"] > 0
and d["asm_ext"]["asm_ext"]["f16c_disponivel"])
for k, v in gates.items():
print(f" {'✓' if v else '✗'} {k}", flush=True)
ok = sum(1 for v in gates.values() if v)
total = len(gates)
print(f"\n=== VEREDITO: {ok}/{total} gates ===", flush=True)
saida = {"versao": "0.13.0", "gates": gates, "ok": ok, "total": total,
"aprovado": ok == total}
json.dump(saida, open(os.path.join(pasta, "resultados", "suite_v013.json"), "w"),
ensure_ascii=False, indent=1)
if not saida["aprovado"]:
sys.exit(1)
print("80_suite_v013: APROVADO", flush=True)
if __name__ == "__main__":
main()
|