Spaces:
Running
Running
File size: 1,291 Bytes
56a8401 336f8e8 56a8401 336f8e8 56a8401 | 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 | """Example plugin: adds an audit check on every engine validation.
Demonstrates the Component 20 hook contract without changing platform code:
a validation battery check is appended to every engine PASS/FAIL report.
"""
from app.services.plugin_system import BioNexusPlugin
class ValidationBatteryPlugin(BioNexusPlugin):
name = "validation-battery"
version = "1.0.0"
description = "Appends evidence-presence and export-readiness checks to every engine validation."
def before_validate(self, engine_name: str, report: dict, result: object = None) -> list[dict]:
evidence = getattr(result, "evidence", None) if result is not None else None
checks = [
{
"name": f"{engine_name}:evidence_recorded",
"passed": bool(evidence),
"detail": "result carries evidence",
},
{
"name": f"{engine_name}:exportable",
"passed": True,
"detail": "JSON export is always available",
},
]
return checks
def on_event(self, event: str, payload: dict) -> list[dict]:
if event == "pipeline_result":
return [{"plugin": self.name, "event": event, "job_id": payload.get("job_id")}]
return [] |