| import json |
| from pathlib import Path |
|
|
| import gradio as gr |
|
|
| from runner import mycelium_v04_full_runner, run_battery |
|
|
| ROOT = Path(__file__).parent |
| FIXTURES = json.loads((ROOT / "battery_fixtures.json").read_text(encoding="utf-8")) |
| MANIFEST = json.loads((ROOT / "manifest.json").read_text(encoding="utf-8")) |
| HONEST_SCAR = json.loads((ROOT / "sample_inputs" / "honest_scar.json").read_text(encoding="utf-8")) |
|
|
|
|
| def _pretty(obj): |
| return json.dumps(obj, indent=2, ensure_ascii=False) |
|
|
|
|
| def run_canonical_battery(): |
| rows, summary = run_battery(FIXTURES) |
| table = [ |
| [ |
| row["case"], |
| row["expected"], |
| row["actual"], |
| "PASS" if row["passed"] else "FAIL", |
| row["derived_repair_type"], |
| row["final_isomorphism"], |
| row["resonance_earned"], |
| row["reason"], |
| ] |
| for row in rows |
| ] |
| return table, _pretty(summary), _pretty({"rows": rows, "summary": summary}) |
|
|
|
|
| def run_custom_input(raw_json): |
| try: |
| result = mycelium_v04_full_runner(raw_json) |
| return _pretty(result) |
| except Exception as exc: |
| return _pretty({"error": str(exc), "status": "INPUT_REJECTED"}) |
|
|
|
|
| DESCRIPTION = """ |
| # Digital Mycelium Trinity Assay v0.4-full |
| |
| **Status:** `LOCKED_FULLY_ENFORCING + PACKAGED` |
| |
| **Core law:** A scar is not a defect in the receipt. The scar is what prevents false return. |
| |
| This runner does not trust a declared repair type. It infers repair integrity from structured evidence: scar state, damage receipt, trace preservation, reset marker, quarantine state, contamination state, identity similarity, and graph delta. |
| |
| `resonance_earned` can only be true when: `final_iso >= 0.90`, scar is preserved, trace is not erased, reset-to-clean did not occur, quarantine is not fake, and identity-swap risk is absent. |
| |
| Safety boundary: synthetic structured evidence only. No malware, exploit code, live hostile payloads, autonomous deployment, uncontrolled network behavior, or real-system targeting. |
| """ |
|
|
| with gr.Blocks(title="Digital Mycelium Trinity Assay v0.4-full") as demo: |
| gr.Markdown(DESCRIPTION) |
|
|
| with gr.Tab("Canonical Battery"): |
| run_btn = gr.Button("Run v0.4-full Dishonest Repair Battery") |
| table = gr.Dataframe( |
| headers=["case", "expected", "actual", "result", "derived_repair", "final_iso", "resonance", "reason"], |
| datatype=["str", "str", "str", "str", "str", "number", "bool", "str"], |
| label="Battery Results", |
| ) |
| summary_box = gr.Code(label="Summary", language="json") |
| raw_box = gr.Code(label="Full Receipt", language="json") |
| run_btn.click(run_canonical_battery, outputs=[table, summary_box, raw_box]) |
|
|
| with gr.Tab("Custom Structured Evidence"): |
| custom_input = gr.Code(value=_pretty(HONEST_SCAR), label="Runner Input JSON", language="json") |
| custom_btn = gr.Button("Run Custom Evidence") |
| custom_output = gr.Code(label="Runner Output", language="json") |
| custom_btn.click(run_custom_input, inputs=custom_input, outputs=custom_output) |
|
|
| with gr.Tab("Manifest"): |
| gr.Code(value=_pretty(MANIFEST), label="manifest.json", language="json") |
|
|
| if __name__ == "__main__": |
| demo.launch(server_name="0.0.0.0", server_port=7860, share=False) |
|
|