P0/v0.5: Causal Engine — PyWhy wrapper + Rust sensemakr + deep_causality + CIVeX upgrade
## Why
Promotes the current CIVeX scaffold (#42, [src/civex.rs](https://github.com/fabio-rovai/open-ontologies/blob/main/src/civex.rs)) from a **structural-dependency proxy** for identifiability to a **real do-calculus engine**. Builds directly on the Dynamics layer (#42_dynamics_predecessor) — every ActionSchema becomes a node in a causal DAG; every action effect can be reasoned about with backdoor/frontdoor/IV identifiability + counterfactuals + sensitivity bounds.
The current CIVeX scaffold issues `assumption = "structural_only"` — explicit acknowledgement of the proxy. This issue upgrades that to actual ID-algorithm-based identifiability while preserving the four-verdict + Wilson LCB scaffold.
## Anchor papers / tools
- **DoWhy / PyWhy** (py-why/dowhy v0.13, Nov 2025, [github.com/py-why/dowhy](https://github.com/py-why/dowhy)) — de-facto production stack. ID algorithm, GCM root-cause analysis, refutation tests, EconML integration. **Wrap as subprocess via the existing `embed_remote.rs` pattern.**
- **Constrained Identifiability of Causal Effects** ([arXiv 2412.02869](https://arxiv.org/abs/2412.02869), UAI/IJCAI 2025) — generalises ID algorithm under SHACL/DL-style constraints. THE causal-ID paper for an ontology-grounded engine.
- **sensemakr / Cinelli-Hazlett OVB framework** ([SSRN 4217915](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4217915)) — sensitivity analysis to unmeasured confounding. Closed-form OLS formulas, ~200 lines. **Port to pure Rust** (no need to wrap R).
- **deep_causality** ([lib.rs/crates/deep_causality](https://lib.rs/crates/deep_causality), LF AI & Data) — production Rust causal library. HAFT extension added 2025. **Use for in-process graph + context data structures**; wrap PyWhy only for the heavy statistical estimators.
- **causal-hub** (alternative for discovery — defer to v0.7+).
- **Long-Term Individual Causal Effect via Identifiable Latent Representation** ([IJCAI 2025](https://www.ijcai.org/proceedings/2025/533)) — relevant for `drift.rs` long-term causal effect of ontology edits.
- **Honest negative**: do NOT port the Shpitser-Pearl ID algorithm to Rust from scratch. 15-year-stable Python implementations exist. Wrap, don't port. Same call as embeddings.
- **Honest negative**: CausalNex is effectively orphaned (last release 2023). Use as reference only.
## Architecture proposal
**Data model:**
- `CausalDAG = (nodes, directed edges, bidirected edges for latent confounders, SHACL-derived constraints)`
- `CausalQuery = (treatment, outcome, query_type ∈ {ATE, ATT, CATE, counterfactual, path-specific}, conditioning_set)`
- `IdentificationResult = (identifiable: bool, formula: do-free expression, strategy ∈ {backdoor, frontdoor, IV, ID-alg, constrained-ID}, confidence_bounds)`
- `SensitivityReport = (robustness_value, R²_thresholds, partial_R²_benchmarks)`
**MCP tools:**
- `onto_causal_dag_from_ontology(ontology, hints)` — extract candidate DAG from ontology + provenance
- `onto_causal_identify(query, dag)` — Shpitser-Pearl ID via PyWhy wrapper
- `onto_causal_identify_constrained(query, dag, shacl)` — constrained-ID
- `onto_causal_estimate(query, dag, data_uri)` — wraps DoWhy + EconML
- `onto_causal_refute(estimate, tests)` — placebo / random-confounder / data-subset refutation
- `onto_causal_sensitivity(estimate, scenario)` — Cinelli-Hazlett OVB (pure Rust port)
- **`onto_causal_certify_action(action_schema, dag)` — *extends* `onto_certify_action` (#42) from structural ID + Wilson LCB to full do-calculus + sensitivity**
## Bounded-scope v0.5.0 (4-6 weeks)
- Backdoor adjustment ONLY (no full ID algorithm yet) — covers ~80% of practical causal queries
- PyWhy worker subprocess via existing remote-worker pattern
- Pure-Rust sensemakr port (~200 lines of OLS-OVB formulas)
- Wire into existing CIVeX so `onto_certify_action` upgrades from `"structural_only"` assumption to a real ID formula in the certificate
## Full vision (post-v0.5)
Full Shpitser-Pearl ID/IDC algorithm via PyWhy, frontdoor, IV, conditional effects, mediation analysis, policy intervention scoring (Markov decision processes over ontology evolution).
## Priority
**P0 / v0.5 flagship.** Depends on Dynamics (#42_dynamics_predecessor) for action-schema inputs. The Planner layer (#44) cannot meaningfully certify steps without this.
0 条评论