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: object

Everything the analysis produced, plus the exports.

name: str
source_system: SystemModel
system: SystemModel
failure_model: FailureModel
cycle_report: CycleReport
hazards: List[Hazard]
trees: Dict[str, FaultTree]
raw_trees: Dict[str, FaultTree]

the unreduced trees, one intermediate event per deviation

analyses: Dict[str, TreeAnalysis]
tree(hazard_id)[source]
Return type:

FaultTree

Parameters:

hazard_id (str)

analysis(hazard_id)[source]
Return type:

TreeAnalysis

Parameters:

hazard_id (str)

cut_sets(hazard_id)[source]
Return type:

List[List[str]]

Parameters:

hazard_id (str)

fmea()[source]
Return type:

List[FMEARow]

single_points()[source]
Return type:

List[Dict[str, str]]

mermaid(hazard_id)[source]
Return type:

str

Parameters:

hazard_id (str)

bayesnet(hazard_id='H2')[source]

Equivalent pyAgrum network for one hazard (exact inference, evidence).

Requires pyagrum. See hiphopsllm.bayes.

Return type:

Any

Parameters:

hazard_id (str)

markdown(include_trees=True)[source]
Return type:

str

Parameters:

include_trees (bool)

display(hazard_id='H2')[source]

Render one fault tree in the notebook.

Return type:

Any

Parameters:

hazard_id (str)

display_architecture()[source]
Return type:

Any

summary()[source]
Return type:

str

save(directory, prefix=None)[source]

Write the report and every per-hazard export. Returns the file paths.

Return type:

List[str]

Parameters:
  • directory (str)

  • prefix (str | None)

__init__(name, source_system, system, failure_model, cycle_report, hazards, trees=<factory>, raw_trees=<factory>, analyses=<factory>)
Parameters:
Return type:

None

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 from graph.get_graph(), the mermaid text from draw_mermaid(), a dict specification, or an already-built SystemModel.

  • globals_ns (Optional[Dict[str, Any]]) – Pass globals() 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 as report.raw_trees.

  • run_state (Optional[Dict[str, Any]]) – The state returned by graph.invoke(...). Its uncertainty_summary calibrates the hallucination / non-determinism events from measured semantic entropy instead of placeholders.

  • name (str)

  • node_functions (Dict[str, Callable[[...], Any]] | None)

  • role_overrides (Dict[str, Role | str] | None)

  • resource_overrides (Dict[str, Dict[str, str]] | None)

  • hazards (Sequence[Hazard] | None)

  • uncertainty_summary (Dict[str, Any] | None)

  • entropy_by_component (Dict[str, float] | None)

  • probability_overrides (Dict[str, float] | None)

  • extra_logic (Dict[str, ComponentFailureLogic] | None)

  • max_order (int)

  • max_sets (int)

Return type:

SafetyReport

hiphopsllm.report.display_fault_tree(tree)[source]

Render a synthesised fault tree inline in the notebook.

Return type:

Any

Parameters:

tree (FaultTree)

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.

Return type:

Dict[str, float]

Parameters: