Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

Fix causal and explain skill API examples

KaifAhmad174d59802152e
diff --git a/plugins/skills/causal/SKILL.md b/plugins/skills/causal/SKILL.md
index 18e47f2a..0a75eb7d 100644
--- a/plugins/skills/causal/SKILL.md
+++ b/plugins/skills/causal/SKILL.md
@@ -17,13 +17,22 @@ Build and inspect causal chains for a subject or category.
```python
from semantica.context.causal_analyzer import CausalChainAnalyzer
-from semantica.context import ContextGraph
-
-graph = ContextGraph(advanced_analytics=True)
-analyzer = CausalChainAnalyzer(graph=graph)
-
-chain = analyzer.build_causal_chain(subject=subject, depth=depth)
-metrics = analyzer.compute_causal_metrics(chain)
+from semantica.context import AgentContext
+
+# Option 1: Use an existing AgentContext decision backend
+chain = ctx.get_causal_chain(
+ decision_id=decision_id,
+ direction="upstream",
+ max_depth=depth,
+)
+
+# Option 2: Use CausalChainAnalyzer directly
+analyzer = CausalChainAnalyzer(graph_store=ctx.knowledge_graph)
+downstream = analyzer.get_causal_chain(
+ decision_id=decision_id,
+ direction="downstream",
+ max_depth=depth,
+)
```
Output: chain steps, cause strength, effect reach, and summary graph.
@@ -32,22 +41,34 @@ Output: chain steps, cause strength, effect reach, and summary graph.
## `intervene <node> <action> [--scenario <json>]`
-Simulate an intervention on a node and measure downstream effects.
+Analyze decision impact and influenced decisions (current causal API).
```python
-result = analyzer.simulate_intervention(node=node, action=action, scenario=scenario)
+analyzer = CausalChainAnalyzer(graph_store=ctx.knowledge_graph)
+impact_score = analyzer.get_causal_impact_score(decision_id=decision_id)
+influenced = analyzer.get_influenced_decisions(
+ decision_id=decision_id,
+ max_depth=depth,
+)
```
-Return: effect magnitudes, changed outcomes, and intervention recommendations.
+Return: impact score, influenced decisions, and downstream scope.
---
## `counterfactual <fact> [--weight N]`
-Generate counterfactual explanations and alternate outcomes.
+Trace root causes and temporal causal paths.
```python
-counterfactuals = analyzer.generate_counterfactuals(fact=fact)
+analyzer = CausalChainAnalyzer(graph_store=ctx.knowledge_graph)
+roots = analyzer.find_root_causes(decision_id=decision_id, max_depth=depth)
+historical_chain = analyzer.trace_at_time(
+ event_id=decision_id,
+ at_time="2026-01-01T00:00:00Z",
+ direction="upstream",
+ max_depth=depth,
+)
```
-Output: alternate causal paths, likelihood change, and decision impact.
+Output: root decision lineage and time-bounded causal context.
diff --git a/plugins/skills/explain/SKILL.md b/plugins/skills/explain/SKILL.md
index 78e97dd9..77fb7191 100644
--- a/plugins/skills/explain/SKILL.md
+++ b/plugins/skills/explain/SKILL.md
@@ -16,10 +16,14 @@ Produce explanations for decisions, rules, and graph analytics. Usage: `/semanti
Explain why a decision was reached.
```python
-from semantica.explain import Explainer
+from semantica.reasoning.explanation_generator import ExplanationGenerator
-explainer = Explainer()
-explanation = explainer.explain_decision(decision_id=decision_id, detail=detail)
+# For decision explainability in Semantica contexts:
+decision_trace = ctx.trace_decision_explainability(decision_id=decision_id)
+
+# For reasoning/proof explanations:
+generator = ExplanationGenerator(detail_level=detail)
+explanation = generator.generate_explanation(reasoning_result)
```
Output: decision factors, rule traces, confidence, and suggested next steps.
@@ -31,7 +35,10 @@ Output: decision factors, rule traces, confidence, and suggested next steps.
Explain graph relationships and why a node is connected.
```python
-explanation = explainer.explain_graph_connection(node_id=node_id, depth=depth)
+# Use AgentContext explainability + causal tracing for graph-connected decisions
+graph_explanation = ctx.trace_decision_explainability(decision_id=node_id)
+upstream = ctx.get_causal_chain(decision_id=node_id, direction="upstream", max_depth=depth)
+downstream = ctx.get_causal_chain(decision_id=node_id, direction="downstream", max_depth=depth)
```
Return: cause/effect chains, supporting evidence, and relevant metadata.