hiphopsllm.report¶
hiphopsllm.report — the notebook-facing entry point.
One call takes the object the notebook already renders and returns a complete safety analysis:
from hiphopsllm import analyse_langgraph
report = analyse_langgraph(
graph, # the compiled LangGraph
name="Approach 1 — ReAct + calculator",
globals_ns=globals(), # lets shared model snapshots be detected
run_state=final_state_1, # optional: calibrates events from measured entropy
unroll=1,
)
report.display("H2") # fault tree for 'wrong answer delivered'
print(report.summary())
report.save("artifacts/approach1")
- class hiphopsllm.report.SafetyReport[source]¶
Bases:
objectEverything the analysis produced, plus the exports.
-
source_system:
SystemModel¶
-
system:
SystemModel¶
-
failure_model:
FailureModel¶
-
cycle_report:
CycleReport¶
-
analyses:
Dict[str,TreeAnalysis]¶
- bayesnet(hazard_id='H2')[source]¶
Equivalent pyAgrum network for one hazard (exact inference, evidence).
Requires pyagrum. See
hiphopsllm.bayes.
- save(directory, prefix=None)[source]¶
Write the report and every per-hazard export. Returns the file paths.
- __init__(name, source_system, system, failure_model, cycle_report, hazards, trees=<factory>, raw_trees=<factory>, analyses=<factory>)¶
- Parameters:
name (str)
source_system (SystemModel)
system (SystemModel)
failure_model (FailureModel)
cycle_report (CycleReport)
analyses (Dict[str, TreeAnalysis])
- Return type:
None
-
source_system:
- hiphopsllm.report.analyse_langgraph(graph, name='LangGraph workflow', *, globals_ns=None, node_functions=None, role_overrides=None, resource_overrides=None, unroll=1, simplify=True, hazards=None, run_state=None, uncertainty_summary=None, entropy_by_component=None, probability_overrides=None, extra_logic=None, max_order=6, max_sets=20000)[source]¶
Run the whole pipeline on a LangGraph application.
- Parameters:
graph (
Any) – A compiled LangGraph, the drawable graph fromgraph.get_graph(), the mermaid text fromdraw_mermaid(), a dict specification, or an already-builtSystemModel.globals_ns (
Optional[Dict[str,Any]]) – Passglobals()from the notebook. Node functions are then found by name and the actual model objects are interrogated, which is what makes shared-snapshot (common-cause) detection reliable.unroll (
int) – Iterations of each feedback loop represented explicitly (default 1).simplify (
bool) – Reduce each tree to its informative structure — a one-input gate is replaced by its input, nested combination gates are flattened. The Boolean function and the cut sets are unchanged; the unreduced trees stay available asreport.raw_trees.run_state (
Optional[Dict[str,Any]]) – The state returned bygraph.invoke(...). Itsuncertainty_summarycalibrates the hallucination / non-determinism events from measured semantic entropy instead of placeholders.name (str)
extra_logic (Dict[str, ComponentFailureLogic] | None)
max_order (int)
max_sets (int)
- Return type:
- hiphopsllm.report.display_fault_tree(tree)[source]¶
Render a synthesised fault tree inline in the notebook.
- hiphopsllm.report.map_uncertainty(system, uncertainty_summary, metric='mean_cluster_entropy')[source]¶
Match the notebook’s per-agent uncertainty records to graph components.
The uncertainty log is keyed by agent labels chosen by the author (
approach2_react), which are not the LangGraph node ids (react_agent). They are matched on shared, non-generic name tokens; unmatched records are ignored rather than guessed at.