v0.6.0: verificador NCM calibrado (sem oráculo, V-1..V-4) + treino conjunto Pensamento↔backbone (fase C, PCGrad, acoplador duplex AC) + MoEs redirecionáveis c/ atenção própria (M-R1..M-R5, JEPA+SOM) + autoajuste por telemetria (A-1..A-5, UCB1) — 46/46 gates, provas r-23..r-27
bb2363d verified Download scripts/59_suite_v060.py from PowerMachine/khtst-rust: direct link, hf CLI and curl.
- Browser
- Download file 5.98 kB
-
https://huggingface.co/PowerMachine/khtst-rust/resolve/main/scripts/59_suite_v060.py
- Command line
-
hf download hf://PowerMachine/khtst-rust/scripts/59_suite_v060.py
-
curl -L -o 59_suite_v060.py https://huggingface.co/PowerMachine/khtst-rust/resolve/main/scripts/59_suite_v060.py
5.98 kB
| #!/usr/bin/env python3 | |
| """59_suite_v060.py — Suíte de verificação consolidada v0.6.0. | |
| Agrega: verificador NCM (55), treino conjunto fase C (56), MoE | |
| redirecionável + acoplador (57), loop iterativo de autoajuste (58), suíte | |
| V legada (41 — bloqueadoras) e os testes cargo (54/54). Produz o veredito | |
| final com TODOS os gates. Saída: resultados/suite_v060_final.json | |
| """ | |
| import json, os, subprocess, sys | |
| def carrega(pasta, nome): | |
| c = os.path.join(pasta, "resultados", nome) | |
| return json.load(open(c)) if os.path.exists(c) else None | |
| def main(): | |
| pasta = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| res = {"versao": "0.6.0", "fontes": {}, "gates": {}, "contagens": {}} | |
| # 1) suítes v0.6.0 já executadas | |
| for arq, nome in [("verificador_ncm_v060.json", "verificador"), | |
| ("treino_conjunto_v060.json", "fase_c"), | |
| ("moe_redirecionavel_v060.json", "moe"), | |
| ("autoajuste_iterativo_v060.json", "iterativo")]: | |
| d = carrega(pasta, arq) | |
| if d is None: | |
| print(f"AVISO: {arq} ausente — rode o script correspondente antes") | |
| continue | |
| res["fontes"][nome] = arq | |
| if nome == "verificador": | |
| for n, s in d["demos"].items(): | |
| if isinstance(s, dict): | |
| res["gates"].update({f"{n}.{g[5:]}": v for g, v in s.items() if g.startswith("gate_")}) | |
| if isinstance(s.get("gates"), dict): | |
| res["gates"].update({f"{n}.{g[5:]}": v for g, v in s["gates"].items() if g.startswith("gate_")}) | |
| res["contagens"][nome] = d["resumo"] | |
| elif nome == "fase_c": | |
| res["gates"].update({f"fase_c.{k}": v for k, v in d["gates"].items()}) | |
| rc = d["fases"]["c"] | |
| res["contagens"][nome] = { | |
| "ce_global": [rc["ce_inicial"], rc["ce_final"]], | |
| "ce_gatilhada_sem_com": [rc["ce_gatilhada_sem_correcao"], rc["ce_gatilhada_com_correcao"]], | |
| "confianca": [rc["confianca_media_inicial"], rc["confianca_media_final"]], | |
| "ece": [rc["ece_antes"], rc["ece_depois"]], | |
| "rodadas_acoplador": rc["rodadas_acoplador"], | |
| "taxa_gatilho": rc["taxa_gatilho"], | |
| } | |
| elif nome == "moe": | |
| for n, s in d["demos"].items(): | |
| if isinstance(s, dict): | |
| res["gates"].update({f"{n}.{g[5:]}": v for g, v in s.items() if g.startswith("gate_")}) | |
| if isinstance(s.get("gates"), dict): | |
| res["gates"].update({f"{n}.{g[5:]}": v for g, v in s["gates"].items() if g.startswith("gate_")}) | |
| res["contagens"][nome] = d["resumo"] | |
| c = d["demos"]["som_moe"] | |
| res["contagens"]["som_qe"] = [c["qe_antes"], c["qe_depois_water_filling"]] | |
| j = d["demos"]["jepa_moe"]["bracos"] | |
| res["contagens"]["jepa_final"] = {k: v["perda_pred_final"] for k, v in j.items()} | |
| elif nome == "iterativo": | |
| res["gates"].update({f"iter.{k}": v for k, v in d["gates"].items()}) | |
| res["contagens"][nome] = { | |
| "vencedor": d["consolidacao"]["vencedor"], | |
| "gap_vs_baseline_pct": d["consolidacao"]["gap_vs_baseline_pct"], | |
| "arrependimento": d["consolidacao"]["arrependimento_medio"], | |
| "rodadas": len(d["rodadas"]), | |
| } | |
| # 2) suíte V legada (bloqueadoras — 41) | |
| d = carrega(pasta, "suite_v.json") | |
| if d: | |
| res["fontes"]["suite_v_legada"] = "suite_v.json" | |
| bloqueadoras = {k: v for k, v in d.items() | |
| if k.startswith("V") and k != "VEREDITO" and isinstance(v, dict) and v.get("ok") is True} | |
| total_v = sum(1 for k in d if k.startswith("V") and k != "VEREDITO") | |
| res["contagens"]["suite_v_legada"] = f"{len(bloqueadoras)}/{total_v}" | |
| res["gates"]["legada_suite_v"] = len(bloqueadoras) >= 7 | |
| # 3) testes cargo (contagem) | |
| try: | |
| out = subprocess.run(["cargo", "test", "--release"], cwd=pasta, | |
| capture_output=True, text=True, timeout=600, | |
| env={**os.environ, "PATH": os.environ["PATH"] + ":/home/z/.cargo/bin"}) | |
| m = [l for l in out.stdout.splitlines() if "test result: ok" in l] | |
| n = int(m[0].split()[3]) if m else 0 | |
| res["contagens"]["cargo"] = f"{n}/{n}" if n else "FALHOU" | |
| res["gates"]["cargo_54"] = n >= 54 | |
| except Exception as e: | |
| res["contagens"]["cargo"] = f"erro: {e}" | |
| res["gates"]["cargo_54"] = False | |
| # 4) veredito | |
| ok = sum(1 for v in res["gates"].values() if v) | |
| total = len(res["gates"]) | |
| res["veredito"] = { | |
| "gates_totais": total, "gates_ok": ok, | |
| "aprovado": ok == total, | |
| "declaracao": ( | |
| f"v0.6.0 APROVADA: {ok}/{total} gates verdes — verificador NCM calibrado " | |
| "(sem oráculo, soundness V-2), treino conjunto Pensamento↔backbone com " | |
| "acoplador duplex, MoEs redirecionáveis c/ atenção própria (JEPA e SOM), " | |
| "autoajuste por telemetria (A-1..A-5) e seleção de arquitetura UCB1 — " | |
| "tudo com dados reais da Wikipédia PT-BR." | |
| ) if ok == total else f"v0.6.0 REPROVADA: {total - ok} gates falharam", | |
| } | |
| print("=== SUÍTE CONSOLIDADA v0.6.0 ===") | |
| for k, v in sorted(res["contagens"].items()): | |
| print(f" {k}: {v}") | |
| print(f"\n=== VEREDITO: {ok}/{total} gates verdes — " | |
| f"{'APROVADA' if ok == total else 'REPROVADA'} ===") | |
| for g, v in res["gates"].items(): | |
| if not v: | |
| print(f" FALHOU {g}") | |
| with open(os.path.join(pasta, "resultados", "suite_v060_final.json"), "w") as f: | |
| json.dump(res, f, indent=1, ensure_ascii=False) | |
| print("salvo: resultados/suite_v060_final.json") | |
| if not res["veredito"]["aprovado"]: | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() | |