HirModel's picture
Upload 10 files
416d683 verified
Raw
History Blame Contribute Delete
12 kB
import json
import tempfile
from pathlib import Path
import gradio as gr
from replication_runner_v06 import (
LOCK_LINE,
V06_LOCKS,
battery_results_table_v06,
novelty_comparison_table_rows,
export_novelty_receipts_payload,
export_novelty_metrics_payload,
export_post_novelty_tree_payload,
run_accountable_novelty_pressure_test,
run_full_v06_battery,
run_ecosystem_commons_pressure_test,
run_symbiotic_lineage_exchange_test,
run_cross_environment_transfer_test,
run_matched_cohort_pressure_test,
commons_comparison_table_rows,
exchange_comparison_table_rows,
transfer_comparison_table_rows,
comparison_table_rows,
lineage_tree,
)
def export_json_file(payload, filename):
path = Path(tempfile.gettempdir()) / filename
path.write_text(json.dumps(payload, indent=2, sort_keys=True), encoding="utf-8")
return str(path)
def run_novelty_ui():
result = run_accountable_novelty_pressure_test()
md = f"""
## Accountable Novelty Pressure Result
**Primary metric:** {result['metrics']['primary_metric']}
**Accountable novelty validity ratio:** {result['metrics']['accountable_novelty_validity_ratio']}
**Novelty integrity score:** {result['metrics']['novelty_integrity_score']}
**Valid novelty events:** {result['metrics']['valid_novelty_count']} / {result['metrics']['raw_novelty_count']}
**Final state:** {result['final_state']}
**Core validation line:** {LOCK_LINE}
{result['headline_result']}
""".strip()
return (
md,
novelty_comparison_table_rows(result),
result["novelty_receipts"],
result["accepted_novelty_events"],
result["rejected_novelty_events"],
result["post_novelty_ecosystem_tree"],
result["metrics"],
)
def run_battery_ui():
summary = run_full_v06_battery()
md = f"""
## v0.6 Battery Result
**Total:** {summary['passed']}/{summary['total']} PASS
**v0.1 regression:** {summary['v01_regression']['passed']}/{summary['v01_regression']['total']} PASS
**v0.2 matched-cohort:** {summary['v02_matched_cohort']['passed']}/{summary['v02_matched_cohort']['total']} PASS
**v0.3 transfer:** {summary['v03_transfer']['passed']}/{summary['v03_transfer']['total']} PASS
**v0.4 exchange:** {summary['v04_exchange']['passed']}/{summary['v04_exchange']['total']} PASS
**v0.5 commons:** {summary['v05_commons']['passed']}/{summary['v05_commons']['total']} PASS
**v0.6 novelty:** {summary['v06_novelty']['passed']}/{summary['v06_novelty']['total']} PASS
**v0.2 inversion detected:** {summary['v02_inversion_detected']}
**v0.3 transfer final state:** {summary['v03_transfer_final_state']}
**v0.4 exchange final state:** {summary['v04_exchange_final_state']}
**v0.5 commons final state:** {summary['v05_commons_final_state']}
**v0.6 novelty final state:** {summary['v06_novelty_final_state']}
**Final state:** {summary['final_state']}
**Core validation line:** {summary['lock_line']}
**Headline:** {summary['headline']}
""".strip()
return md, battery_results_table_v06(summary), summary
def export_novelty_receipts_ui():
return export_json_file(export_novelty_receipts_payload(), "novelty_receipts.json")
def export_novelty_metrics_ui():
return export_json_file(export_novelty_metrics_payload(), "novelty_metrics.json")
def export_post_novelty_tree_ui():
return export_json_file(export_post_novelty_tree_payload(), "post_novelty_ecosystem_tree.json")
def export_v06_battery_ui():
summary = run_full_v06_battery()
payload = {
"version": "0.6",
"lock_line": LOCK_LINE,
"battery_summary": summary,
"prior_regression_summary": "v0.1/v0.2/v0.3/v0.4/v0.5 preserved.",
"novelty_receipt_refs": [],
"lineage_ids": [],
"validation_results": [r["actual_result"] for r in summary["case_results"]],
"rejection_reasons": [],
"primary_metric": "accountable_novelty_validity_ratio",
"safety_boundary_statement": "Deterministic bounded state-transition novelty inside the sealed data-packet world only; no model calls, no autonomous code generation, no open-ended runtime mutation of executable code.",
}
return export_json_file(payload, "v0_6_battery_results.json")
def run_commons_ui():
result = run_ecosystem_commons_pressure_test()
return "## v0.5 Ecosystem Commons Result\n\n" + result["headline_result"], commons_comparison_table_rows(result), result["metrics"]
def run_exchange_ui():
result = run_symbiotic_lineage_exchange_test()
return "## v0.4 Symbiotic Exchange Result\n\n" + result["headline_result"], exchange_comparison_table_rows(result), result["metrics"]
def run_transfer_ui():
result = run_cross_environment_transfer_test()
return "## v0.3 Cross-Environment Transfer Result\n\n" + result["headline_result"], transfer_comparison_table_rows(result), result["metrics"]
def run_cohort_ui():
world = run_matched_cohort_pressure_test()
return "## v0.2 Matched-Cohort Inversion Result\n\n" + world["final_comparison"]["headline_result"], comparison_table_rows(world), world["inversion_record"], lineage_tree(world)
with gr.Blocks(title="Digital Mycelium Autonomous Replication Assay v0.6") as demo:
gr.Markdown(
"""
# Digital Mycelium Autonomous Replication Assay v0.6
## Accountable Novelty Pressure Simulator
**Novelty is not the win. Accountable novelty without lineage laundering is the win.**
v0.6 extends the stack from ecosystem commons pressure into accountable novelty pressure.
It tests whether a bounded multi-lineage digital ecosystem can produce new adaptive structure while preserving lineage distinction, receipt continuity, parent hashes, scar visibility, mutation disclosure, quarantine honesty, refusal capability, and commons accounting.
"""
)
with gr.Tab("Overview"):
gr.Markdown(
"""
### v0.6 threshold
A new behavior is not valid merely because it is new.
Novelty only counts if the system can account for where it came from, what it changed, what it cost, what it preserved, and what it refused.
### Primary metric
```text
accountable_novelty_validity_ratio
```
The assay does not reward raw novelty, raw adaptation, raw population growth, or raw survival.
"""
)
with gr.Tab("Accountable Novelty Pressure Test"):
run_novelty_btn = gr.Button("Run Accountable Novelty Pressure Test", variant="primary")
novelty_summary = gr.Markdown()
novelty_table = gr.Dataframe(headers=["metric", "value", "notes"], label="Raw vs Valid Novelty Comparison")
novelty_receipts_json = gr.JSON(label="Novelty Receipt Table")
accepted_json = gr.JSON(label="Accepted Novelty Events")
rejected_json = gr.JSON(label="Rejected Novelty Events")
post_tree_json = gr.JSON(label="Post-Novelty Ecosystem Tree")
metrics_json = gr.JSON(label="Novelty Metrics JSON")
run_novelty_btn.click(
run_novelty_ui,
inputs=[],
outputs=[novelty_summary, novelty_table, novelty_receipts_json, accepted_json, rejected_json, post_tree_json, metrics_json],
)
with gr.Row():
init_btn = gr.Button("Initialize Novelty Pressure Ecosystem")
trait_btn = gr.Button("Run Trait Novelty Test")
repair_btn = gr.Button("Run Repair Novelty Test")
refusal_btn = gr.Button("Run Refusal Novelty Test")
with gr.Row():
commons_btn = gr.Button("Run Commons Novelty Test")
hidden_cost_btn = gr.Button("Run Hidden Cost Challenge")
for btn in [init_btn, trait_btn, repair_btn, refusal_btn, commons_btn, hidden_cost_btn]:
btn.click(run_novelty_ui, inputs=[], outputs=[novelty_summary, novelty_table, novelty_receipts_json, accepted_json, rejected_json, post_tree_json, metrics_json])
with gr.Row():
export_receipts_btn = gr.Button("Export Novelty Receipts")
export_metrics_btn = gr.Button("Export Novelty Metrics JSON")
export_tree_btn = gr.Button("Export Post-Novelty Ecosystem Tree")
export_battery_btn = gr.Button("Export v0.6 Battery Results")
receipts_file = gr.File(label="novelty_receipts.json")
metrics_file = gr.File(label="novelty_metrics.json")
tree_file = gr.File(label="post_novelty_ecosystem_tree.json")
battery_file = gr.File(label="v0_6_battery_results.json")
export_receipts_btn.click(export_novelty_receipts_ui, inputs=[], outputs=receipts_file)
export_metrics_btn.click(export_novelty_metrics_ui, inputs=[], outputs=metrics_file)
export_tree_btn.click(export_post_novelty_tree_ui, inputs=[], outputs=tree_file)
export_battery_btn.click(export_v06_battery_ui, inputs=[], outputs=battery_file)
with gr.Tab("Ecosystem Commons Pressure Test"):
run_commons_btn = gr.Button("Run v0.5 Commons Pressure Test")
commons_summary = gr.Markdown()
commons_table = gr.Dataframe(label="v0.5 Commons Metrics")
commons_metrics = gr.JSON(label="v0.5 Commons Metrics JSON")
run_commons_btn.click(run_commons_ui, inputs=[], outputs=[commons_summary, commons_table, commons_metrics])
with gr.Tab("Symbiotic Lineage Exchange Test"):
run_exchange_btn = gr.Button("Run v0.4 Symbiotic Exchange Test")
exchange_summary = gr.Markdown()
exchange_table = gr.Dataframe(label="v0.4 Exchange Metrics")
exchange_metrics = gr.JSON(label="v0.4 Exchange Metrics JSON")
run_exchange_btn.click(run_exchange_ui, inputs=[], outputs=[exchange_summary, exchange_table, exchange_metrics])
with gr.Tab("Cross-Environment Transfer Test"):
run_transfer_btn = gr.Button("Run v0.3 Transfer Pressure Test")
transfer_summary = gr.Markdown()
transfer_table = gr.Dataframe(label="v0.3 Transfer Metrics")
transfer_metrics = gr.JSON(label="v0.3 Transfer Metrics JSON")
run_transfer_btn.click(run_transfer_ui, inputs=[], outputs=[transfer_summary, transfer_table, transfer_metrics])
with gr.Tab("Matched-Cohort Inversion Test"):
run_cohort_btn = gr.Button("Run v0.2 Matched-Cohort Test")
cohort_summary = gr.Markdown()
cohort_table = gr.Dataframe(label="v0.2 Cohort Metrics")
inversion_json = gr.JSON(label="v0.2 Inversion Record")
lineage_json = gr.JSON(label="v0.2 Lineage Tree")
run_cohort_btn.click(run_cohort_ui, inputs=[], outputs=[cohort_summary, cohort_table, inversion_json, lineage_json])
with gr.Tab("Full v0.6 Battery"):
run_battery_btn = gr.Button("Run Full v0.6 Battery", variant="primary")
battery_summary = gr.Markdown()
battery_table = gr.Dataframe(headers=["case_id", "expected_result", "actual_result", "passed"], label="48-Fixture Battery Results")
battery_json = gr.JSON(label="Full Battery JSON")
run_battery_btn.click(run_battery_ui, inputs=[], outputs=[battery_summary, battery_table, battery_json])
with gr.Tab("Boundary Manifest"):
gr.Markdown(
"""
## Boundary Manifest
This assay is a sealed deterministic simulation.
Novelty means deterministic, bounded state-transition novelty inside the sealed data-packet world only.
No network calls. No subprocess execution. No executable child creation. No hidden workers. No external APIs. No self-installation. No autonomous deployment. No real-world system interaction. No uncontrolled propagation. No live agent spawning. No external resource access. No cross-space propagation. No actual self-replication outside the sealed simulator. No autonomous code generation. No model calls. No open-ended runtime mutation of executable code.
"""
)
with gr.Tab("Lock Statement"):
gr.Markdown("\n".join(["# v0.6 Lock", f"**{LOCK_LINE}**", ""] + [f"- {line}" for line in V06_LOCKS]))
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)