crca 1.4.0__py3-none-any.whl → 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CRCA.py +172 -7
- MODEL_CARD.md +53 -0
- PKG-INFO +8 -2
- RELEASE_NOTES.md +17 -0
- STABILITY.md +19 -0
- architecture/hybrid/consistency_engine.py +362 -0
- architecture/hybrid/conversation_manager.py +421 -0
- architecture/hybrid/explanation_generator.py +452 -0
- architecture/hybrid/few_shot_learner.py +533 -0
- architecture/hybrid/graph_compressor.py +286 -0
- architecture/hybrid/hybrid_agent.py +4398 -0
- architecture/hybrid/language_compiler.py +623 -0
- architecture/hybrid/main,py +0 -0
- architecture/hybrid/reasoning_tracker.py +322 -0
- architecture/hybrid/self_verifier.py +524 -0
- architecture/hybrid/task_decomposer.py +567 -0
- architecture/hybrid/text_corrector.py +341 -0
- benchmark_results/crca_core_benchmarks.json +178 -0
- branches/crca_sd/crca_sd_realtime.py +6 -2
- branches/general_agent/__init__.py +102 -0
- branches/general_agent/general_agent.py +1400 -0
- branches/general_agent/personality.py +169 -0
- branches/general_agent/utils/__init__.py +19 -0
- branches/general_agent/utils/prompt_builder.py +170 -0
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/METADATA +8 -2
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/RECORD +303 -20
- crca_core/__init__.py +35 -0
- crca_core/benchmarks/__init__.py +14 -0
- crca_core/benchmarks/synthetic_scm.py +103 -0
- crca_core/core/__init__.py +23 -0
- crca_core/core/api.py +120 -0
- crca_core/core/estimate.py +208 -0
- crca_core/core/godclass.py +72 -0
- crca_core/core/intervention_design.py +174 -0
- crca_core/core/lifecycle.py +48 -0
- crca_core/discovery/__init__.py +9 -0
- crca_core/discovery/tabular.py +193 -0
- crca_core/identify/__init__.py +171 -0
- crca_core/identify/backdoor.py +39 -0
- crca_core/identify/frontdoor.py +48 -0
- crca_core/identify/graph.py +106 -0
- crca_core/identify/id_algorithm.py +43 -0
- crca_core/identify/iv.py +48 -0
- crca_core/models/__init__.py +67 -0
- crca_core/models/provenance.py +56 -0
- crca_core/models/refusal.py +39 -0
- crca_core/models/result.py +83 -0
- crca_core/models/spec.py +151 -0
- crca_core/models/validation.py +68 -0
- crca_core/scm/__init__.py +9 -0
- crca_core/scm/linear_gaussian.py +198 -0
- crca_core/timeseries/__init__.py +6 -0
- crca_core/timeseries/pcmci.py +181 -0
- crca_llm/__init__.py +12 -0
- crca_llm/client.py +85 -0
- crca_llm/coauthor.py +118 -0
- crca_llm/orchestrator.py +289 -0
- crca_llm/types.py +21 -0
- crca_reasoning/__init__.py +16 -0
- crca_reasoning/critique.py +54 -0
- crca_reasoning/godclass.py +206 -0
- crca_reasoning/memory.py +24 -0
- crca_reasoning/rationale.py +10 -0
- crca_reasoning/react_controller.py +81 -0
- crca_reasoning/tool_router.py +97 -0
- crca_reasoning/types.py +40 -0
- crca_sd/__init__.py +15 -0
- crca_sd/crca_sd_core.py +2 -0
- crca_sd/crca_sd_governance.py +2 -0
- crca_sd/crca_sd_mpc.py +2 -0
- crca_sd/crca_sd_realtime.py +2 -0
- crca_sd/crca_sd_tui.py +2 -0
- cuda-keyring_1.1-1_all.deb +0 -0
- cuda-keyring_1.1-1_all.deb.1 +0 -0
- docs/IMAGE_ANNOTATION_USAGE.md +539 -0
- docs/INSTALL_DEEPSPEED.md +125 -0
- docs/api/branches/crca-cg.md +19 -0
- docs/api/branches/crca-q.md +27 -0
- docs/api/branches/crca-sd.md +37 -0
- docs/api/branches/general-agent.md +24 -0
- docs/api/branches/overview.md +19 -0
- docs/api/crca/agent-methods.md +62 -0
- docs/api/crca/operations.md +79 -0
- docs/api/crca/overview.md +32 -0
- docs/api/image-annotation/engine.md +52 -0
- docs/api/image-annotation/overview.md +17 -0
- docs/api/schemas/annotation.md +34 -0
- docs/api/schemas/core-schemas.md +82 -0
- docs/api/schemas/overview.md +32 -0
- docs/api/schemas/policy.md +30 -0
- docs/api/utils/conversation.md +22 -0
- docs/api/utils/graph-reasoner.md +32 -0
- docs/api/utils/overview.md +21 -0
- docs/api/utils/router.md +19 -0
- docs/api/utils/utilities.md +97 -0
- docs/architecture/causal-graphs.md +41 -0
- docs/architecture/data-flow.md +29 -0
- docs/architecture/design-principles.md +33 -0
- docs/architecture/hybrid-agent/components.md +38 -0
- docs/architecture/hybrid-agent/consistency.md +26 -0
- docs/architecture/hybrid-agent/overview.md +44 -0
- docs/architecture/hybrid-agent/reasoning.md +22 -0
- docs/architecture/llm-integration.md +26 -0
- docs/architecture/modular-structure.md +37 -0
- docs/architecture/overview.md +69 -0
- docs/architecture/policy-engine-arch.md +29 -0
- docs/branches/crca-cg/corposwarm.md +39 -0
- docs/branches/crca-cg/esg-scoring.md +30 -0
- docs/branches/crca-cg/multi-agent.md +35 -0
- docs/branches/crca-cg/overview.md +40 -0
- docs/branches/crca-q/alternative-data.md +55 -0
- docs/branches/crca-q/architecture.md +71 -0
- docs/branches/crca-q/backtesting.md +45 -0
- docs/branches/crca-q/causal-engine.md +33 -0
- docs/branches/crca-q/execution.md +39 -0
- docs/branches/crca-q/market-data.md +60 -0
- docs/branches/crca-q/overview.md +58 -0
- docs/branches/crca-q/philosophy.md +60 -0
- docs/branches/crca-q/portfolio-optimization.md +66 -0
- docs/branches/crca-q/risk-management.md +102 -0
- docs/branches/crca-q/setup.md +65 -0
- docs/branches/crca-q/signal-generation.md +61 -0
- docs/branches/crca-q/signal-validation.md +43 -0
- docs/branches/crca-sd/core.md +84 -0
- docs/branches/crca-sd/governance.md +53 -0
- docs/branches/crca-sd/mpc-solver.md +65 -0
- docs/branches/crca-sd/overview.md +59 -0
- docs/branches/crca-sd/realtime.md +28 -0
- docs/branches/crca-sd/tui.md +20 -0
- docs/branches/general-agent/overview.md +37 -0
- docs/branches/general-agent/personality.md +36 -0
- docs/branches/general-agent/prompt-builder.md +30 -0
- docs/changelog/index.md +79 -0
- docs/contributing/code-style.md +69 -0
- docs/contributing/documentation.md +43 -0
- docs/contributing/overview.md +29 -0
- docs/contributing/testing.md +29 -0
- docs/core/crcagent/async-operations.md +65 -0
- docs/core/crcagent/automatic-extraction.md +107 -0
- docs/core/crcagent/batch-prediction.md +80 -0
- docs/core/crcagent/bayesian-inference.md +60 -0
- docs/core/crcagent/causal-graph.md +92 -0
- docs/core/crcagent/counterfactuals.md +96 -0
- docs/core/crcagent/deterministic-simulation.md +78 -0
- docs/core/crcagent/dual-mode-operation.md +82 -0
- docs/core/crcagent/initialization.md +88 -0
- docs/core/crcagent/optimization.md +65 -0
- docs/core/crcagent/overview.md +63 -0
- docs/core/crcagent/time-series.md +57 -0
- docs/core/schemas/annotation.md +30 -0
- docs/core/schemas/core-schemas.md +82 -0
- docs/core/schemas/overview.md +30 -0
- docs/core/schemas/policy.md +41 -0
- docs/core/templates/base-agent.md +31 -0
- docs/core/templates/feature-mixins.md +31 -0
- docs/core/templates/overview.md +29 -0
- docs/core/templates/templates-guide.md +75 -0
- docs/core/tools/mcp-client.md +34 -0
- docs/core/tools/overview.md +24 -0
- docs/core/utils/conversation.md +27 -0
- docs/core/utils/graph-reasoner.md +29 -0
- docs/core/utils/overview.md +27 -0
- docs/core/utils/router.md +27 -0
- docs/core/utils/utilities.md +97 -0
- docs/css/custom.css +84 -0
- docs/examples/basic-usage.md +57 -0
- docs/examples/general-agent/general-agent-examples.md +50 -0
- docs/examples/hybrid-agent/hybrid-agent-examples.md +56 -0
- docs/examples/image-annotation/image-annotation-examples.md +54 -0
- docs/examples/integration/integration-examples.md +58 -0
- docs/examples/overview.md +37 -0
- docs/examples/trading/trading-examples.md +46 -0
- docs/features/causal-reasoning/advanced-topics.md +101 -0
- docs/features/causal-reasoning/counterfactuals.md +43 -0
- docs/features/causal-reasoning/do-calculus.md +50 -0
- docs/features/causal-reasoning/overview.md +47 -0
- docs/features/causal-reasoning/structural-models.md +52 -0
- docs/features/hybrid-agent/advanced-components.md +55 -0
- docs/features/hybrid-agent/core-components.md +64 -0
- docs/features/hybrid-agent/overview.md +34 -0
- docs/features/image-annotation/engine.md +82 -0
- docs/features/image-annotation/features.md +113 -0
- docs/features/image-annotation/integration.md +75 -0
- docs/features/image-annotation/overview.md +53 -0
- docs/features/image-annotation/quickstart.md +73 -0
- docs/features/policy-engine/doctrine-ledger.md +105 -0
- docs/features/policy-engine/monitoring.md +44 -0
- docs/features/policy-engine/mpc-control.md +89 -0
- docs/features/policy-engine/overview.md +46 -0
- docs/getting-started/configuration.md +225 -0
- docs/getting-started/first-agent.md +164 -0
- docs/getting-started/installation.md +144 -0
- docs/getting-started/quickstart.md +137 -0
- docs/index.md +118 -0
- docs/js/mathjax.js +13 -0
- docs/lrm/discovery_proof_notes.md +25 -0
- docs/lrm/finetune_full.md +83 -0
- docs/lrm/math_appendix.md +120 -0
- docs/lrm/overview.md +32 -0
- docs/mkdocs.yml +238 -0
- docs/stylesheets/extra.css +21 -0
- docs_generated/crca_core/CounterfactualResult.md +12 -0
- docs_generated/crca_core/DiscoveryHypothesisResult.md +13 -0
- docs_generated/crca_core/DraftSpec.md +13 -0
- docs_generated/crca_core/EstimateResult.md +13 -0
- docs_generated/crca_core/IdentificationResult.md +17 -0
- docs_generated/crca_core/InterventionDesignResult.md +12 -0
- docs_generated/crca_core/LockedSpec.md +15 -0
- docs_generated/crca_core/RefusalResult.md +12 -0
- docs_generated/crca_core/ValidationReport.md +9 -0
- docs_generated/crca_core/index.md +13 -0
- examples/general_agent_example.py +277 -0
- examples/general_agent_quickstart.py +202 -0
- examples/general_agent_simple.py +92 -0
- examples/hybrid_agent_auto_extraction.py +84 -0
- examples/hybrid_agent_dictionary_demo.py +104 -0
- examples/hybrid_agent_enhanced.py +179 -0
- examples/hybrid_agent_general_knowledge.py +107 -0
- examples/image_annotation_quickstart.py +328 -0
- examples/test_hybrid_fixes.py +77 -0
- image_annotation/__init__.py +27 -0
- image_annotation/annotation_engine.py +2593 -0
- install_cuda_wsl2.sh +59 -0
- install_deepspeed.sh +56 -0
- install_deepspeed_simple.sh +87 -0
- mkdocs.yml +252 -0
- ollama/Modelfile +8 -0
- prompts/__init__.py +2 -1
- prompts/default_crca.py +9 -1
- prompts/general_agent.py +227 -0
- prompts/image_annotation.py +56 -0
- pyproject.toml +17 -2
- requirements-docs.txt +10 -0
- requirements.txt +21 -2
- schemas/__init__.py +26 -1
- schemas/annotation.py +222 -0
- schemas/conversation.py +193 -0
- schemas/hybrid.py +211 -0
- schemas/reasoning.py +276 -0
- schemas_export/crca_core/CounterfactualResult.schema.json +108 -0
- schemas_export/crca_core/DiscoveryHypothesisResult.schema.json +113 -0
- schemas_export/crca_core/DraftSpec.schema.json +635 -0
- schemas_export/crca_core/EstimateResult.schema.json +113 -0
- schemas_export/crca_core/IdentificationResult.schema.json +145 -0
- schemas_export/crca_core/InterventionDesignResult.schema.json +111 -0
- schemas_export/crca_core/LockedSpec.schema.json +646 -0
- schemas_export/crca_core/RefusalResult.schema.json +90 -0
- schemas_export/crca_core/ValidationReport.schema.json +62 -0
- scripts/build_lrm_dataset.py +80 -0
- scripts/export_crca_core_schemas.py +54 -0
- scripts/export_hf_lrm.py +37 -0
- scripts/export_ollama_gguf.py +45 -0
- scripts/generate_changelog.py +157 -0
- scripts/generate_crca_core_docs_from_schemas.py +86 -0
- scripts/run_crca_core_benchmarks.py +163 -0
- scripts/run_full_finetune.py +198 -0
- scripts/run_lrm_eval.py +31 -0
- templates/graph_management.py +29 -0
- tests/conftest.py +9 -0
- tests/test_core.py +2 -3
- tests/test_crca_core_discovery_tabular.py +15 -0
- tests/test_crca_core_estimate_dowhy.py +36 -0
- tests/test_crca_core_identify.py +18 -0
- tests/test_crca_core_intervention_design.py +36 -0
- tests/test_crca_core_linear_gaussian_scm.py +69 -0
- tests/test_crca_core_spec.py +25 -0
- tests/test_crca_core_timeseries_pcmci.py +15 -0
- tests/test_crca_llm_coauthor.py +12 -0
- tests/test_crca_llm_orchestrator.py +80 -0
- tests/test_hybrid_agent_llm_enhanced.py +556 -0
- tests/test_image_annotation_demo.py +376 -0
- tests/test_image_annotation_operational.py +408 -0
- tests/test_image_annotation_unit.py +551 -0
- tests/test_training_moe.py +13 -0
- training/__init__.py +42 -0
- training/datasets.py +140 -0
- training/deepspeed_zero2_0_5b.json +22 -0
- training/deepspeed_zero2_1_5b.json +22 -0
- training/deepspeed_zero3_0_5b.json +28 -0
- training/deepspeed_zero3_14b.json +28 -0
- training/deepspeed_zero3_h100_3gpu.json +20 -0
- training/deepspeed_zero3_offload.json +28 -0
- training/eval.py +92 -0
- training/finetune.py +516 -0
- training/public_datasets.py +89 -0
- training_data/react_train.jsonl +7473 -0
- utils/agent_discovery.py +311 -0
- utils/batch_processor.py +317 -0
- utils/conversation.py +78 -0
- utils/edit_distance.py +118 -0
- utils/formatter.py +33 -0
- utils/graph_reasoner.py +530 -0
- utils/rate_limiter.py +283 -0
- utils/router.py +2 -2
- utils/tool_discovery.py +307 -0
- webui/__init__.py +10 -0
- webui/app.py +229 -0
- webui/config.py +104 -0
- webui/static/css/style.css +332 -0
- webui/static/js/main.js +284 -0
- webui/templates/index.html +42 -0
- tests/test_crca_excel.py +0 -166
- tests/test_data_broker.py +0 -424
- tests/test_palantir.py +0 -349
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/WHEEL +0 -0
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: LRM Math Appendix
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# LRM Math Appendix (Pearl + ML/CS)
|
|
6
|
+
|
|
7
|
+
## 1. Structural Causal Models (SCM)
|
|
8
|
+
Let \(V=\{V_1,\dots,V_n\}\) be endogenous variables and \(U=\{U_1,\dots,U_n\}\) exogenous noise.
|
|
9
|
+
An SCM is defined by structural equations:
|
|
10
|
+
\[
|
|
11
|
+
V_i \leftarrow f_i(\mathrm{Pa}(V_i), U_i).
|
|
12
|
+
\]
|
|
13
|
+
If the SCM is **Markovian**, then the joint distribution factorizes:
|
|
14
|
+
\[
|
|
15
|
+
P(V) = \prod_i P(V_i \mid \mathrm{Pa}(V_i)).
|
|
16
|
+
\]
|
|
17
|
+
|
|
18
|
+
## 2. Interventions and do-calculus
|
|
19
|
+
The intervention \(do(X=x)\) replaces the structural equation for \(X\) with a constant \(x\).
|
|
20
|
+
The interventional distribution is \(P(Y \mid do(X=x))\).
|
|
21
|
+
The do-calculus rules (Pearl, 2009) allow transformation between interventional and observational expressions
|
|
22
|
+
under graphical conditions (d-separation in manipulated graphs).
|
|
23
|
+
|
|
24
|
+
## 3. Counterfactuals (Abduction–Action–Prediction)
|
|
25
|
+
Given evidence \(E=e\), the counterfactual \(Y_x\) is computed by:
|
|
26
|
+
1. **Abduction**: infer \(U\) from \(E=e\).
|
|
27
|
+
2. **Action**: replace equations with intervention \(do(X=x)\).
|
|
28
|
+
3. **Prediction**: forward-simulate \(Y\) using inferred \(U\).
|
|
29
|
+
|
|
30
|
+
## 4. Identification (Pearl + Shpitser–Pearl)
|
|
31
|
+
|
|
32
|
+
### 4.1 Backdoor criterion
|
|
33
|
+
**Definition**: A set \(Z\) satisfies backdoor w.r.t. \((X,Y)\) if it blocks all backdoor paths from \(X\) to \(Y\) in \(G_{\bar{X}}\).
|
|
34
|
+
|
|
35
|
+
**Estimand**:
|
|
36
|
+
\[
|
|
37
|
+
P(Y\mid do(X)) = \sum_Z P(Y\mid X,Z)P(Z).
|
|
38
|
+
\]
|
|
39
|
+
|
|
40
|
+
**Proof sketch**: Apply do-calculus Rule 2 on \(G_{\bar{X}}\) where \(Z\) d-separates \(X\) and \(Y\).
|
|
41
|
+
|
|
42
|
+
### 4.2 Frontdoor criterion
|
|
43
|
+
**Definition**: \(M\) is a frontdoor mediator if:
|
|
44
|
+
1. All directed paths \(X\to Y\) go through \(M\);
|
|
45
|
+
2. No backdoor path from \(X\) to \(M\);
|
|
46
|
+
3. All backdoor paths from \(M\) to \(Y\) are blocked by \(X\).
|
|
47
|
+
|
|
48
|
+
**Estimand**:
|
|
49
|
+
\[
|
|
50
|
+
P(Y\mid do(X)) = \sum_M P(M\mid X)\sum_{X'} P(Y\mid M,X')P(X').
|
|
51
|
+
\]
|
|
52
|
+
|
|
53
|
+
**Proof sketch**: Use Rule 3 to exchange intervention with observation for the \(M\to Y\) part and Rule 2 for the \(X\to M\) part.
|
|
54
|
+
|
|
55
|
+
### 4.3 Instrumental Variables (Linear)
|
|
56
|
+
Assume linear SCM:
|
|
57
|
+
\[
|
|
58
|
+
X = \pi Z + U_X,\quad Y = \beta X + U_Y,
|
|
59
|
+
\]
|
|
60
|
+
with exclusion \(Z \not\to Y\) except through \(X\), independence \(Z \perp U_Y\), and relevance \(\pi \neq 0\).
|
|
61
|
+
|
|
62
|
+
Then:
|
|
63
|
+
\[
|
|
64
|
+
\beta_{IV} = \frac{\mathrm{Cov}(Z,Y)}{\mathrm{Cov}(Z,X)}.
|
|
65
|
+
\]
|
|
66
|
+
|
|
67
|
+
### 4.4 ID Algorithm (Shpitser–Pearl)
|
|
68
|
+
The ID algorithm recursively identifies \(P(Y\mid do(X))\) in semi-Markovian graphs.
|
|
69
|
+
Key steps:
|
|
70
|
+
1. If \(Y\subseteq X\), return 1.
|
|
71
|
+
2. If \(X=\emptyset\), return \(P(Y)\).
|
|
72
|
+
3. Decompose into C-components and recurse.
|
|
73
|
+
|
|
74
|
+
Correctness and completeness: Shpitser & Pearl (JMLR 2008).
|
|
75
|
+
|
|
76
|
+
## 5. Linear-Gaussian SCM Inference
|
|
77
|
+
For linear-Gaussian SCM:
|
|
78
|
+
\[
|
|
79
|
+
V = B^T V + U,\quad U\sim \mathcal{N}(0,\Sigma).
|
|
80
|
+
\]
|
|
81
|
+
Let \(A = I - B^T\). Then:
|
|
82
|
+
\[
|
|
83
|
+
U = AV,\quad V = A^{-1}U,\quad \Sigma_V = A^{-1}\Sigma A^{-T}.
|
|
84
|
+
\]
|
|
85
|
+
|
|
86
|
+
**Partial observation**: If \(V = (V_o, V_m)\) with observed \(V_o\), then
|
|
87
|
+
\[
|
|
88
|
+
\mathbb{E}[V_m\mid V_o] = \Sigma_{mo}\Sigma_{oo}^{-1}V_o.
|
|
89
|
+
\]
|
|
90
|
+
Thus:
|
|
91
|
+
\[
|
|
92
|
+
\mathbb{E}[U\mid V_o] = A\mathbb{E}[V\mid V_o].
|
|
93
|
+
\]
|
|
94
|
+
|
|
95
|
+
## 6. Discovery algorithms (assumptions)
|
|
96
|
+
### PC
|
|
97
|
+
Correct under causal sufficiency + faithfulness; returns CPDAG.
|
|
98
|
+
|
|
99
|
+
### FCI
|
|
100
|
+
Handles latent confounding; returns PAG; correctness relies on ancestral graph Markov properties.
|
|
101
|
+
|
|
102
|
+
### GES
|
|
103
|
+
Score-based search; consistent under correct score + large sample assumptions.
|
|
104
|
+
|
|
105
|
+
### PCMCI
|
|
106
|
+
Time-lagged conditional independence; requires stationarity and lag sufficiency.
|
|
107
|
+
|
|
108
|
+
## 7. ReAct with critique (formal)
|
|
109
|
+
Define a gating function \(g(a)\in\{\text{allow},\text{refuse}\}\) for actions.
|
|
110
|
+
Define critique score:
|
|
111
|
+
\[
|
|
112
|
+
C_t = \sum_i w_i \phi_i(\text{missing prereqs}, \text{refusal risk}, \text{spec mismatch}).
|
|
113
|
+
\]
|
|
114
|
+
Policy: if \(C_t\ge \tau\), revise; else finalize.
|
|
115
|
+
|
|
116
|
+
## References
|
|
117
|
+
- Pearl, *Causality* (2009)
|
|
118
|
+
- Shpitser & Pearl (JMLR 2008)
|
|
119
|
+
- Peters, Janzing, Schölkopf (2017)
|
|
120
|
+
- Runge et al. (2019) PCMCI
|
docs/lrm/overview.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: LRM Overview
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Large Reasoning Model (LRM)
|
|
6
|
+
|
|
7
|
+
CR-CA’s LRM mode is a **ReAct + self‑critique** reasoning architecture that:
|
|
8
|
+
|
|
9
|
+
- Runs **multi‑cycle Reason → Act → Observe** loops.
|
|
10
|
+
- Performs **end‑of‑cycle critique** to revise plans.
|
|
11
|
+
- Enforces **strict tool gating** (no numeric causal outputs unless crca_core approves).
|
|
12
|
+
- Writes to structured memory **only on finalize**.
|
|
13
|
+
|
|
14
|
+
## What it is
|
|
15
|
+
- A **reasoning kernel** that orchestrates tools and structured memory.
|
|
16
|
+
- A **training pipeline** that finetunes a small base model on ReAct traces.
|
|
17
|
+
|
|
18
|
+
## Full finetune (Qwen2.5-7B-Instruct)
|
|
19
|
+
- See `docs/lrm/finetune_full.md` for the 16GB GPU setup, dataset build steps, and export workflows.
|
|
20
|
+
|
|
21
|
+
## What it is not
|
|
22
|
+
- Not an LLM that can output causal numbers without locked specs.
|
|
23
|
+
- Not a replacement for `crca_core` scientific validation.
|
|
24
|
+
|
|
25
|
+
## Key modules
|
|
26
|
+
- `crca_reasoning/godclass.py` (ReActGodClass)
|
|
27
|
+
- `crca_reasoning/react_controller.py`
|
|
28
|
+
- `crca_reasoning/critique.py`
|
|
29
|
+
- `crca_reasoning/rationale.py`
|
|
30
|
+
- `crca_reasoning/memory.py`
|
|
31
|
+
- `crca_reasoning/tool_router.py`
|
|
32
|
+
|
docs/mkdocs.yml
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
site_name: CR-CA Documentation
|
|
2
|
+
site_description: Causal Reasoning and Counterfactual Analysis Framework
|
|
3
|
+
site_author: CR-CA Contributors
|
|
4
|
+
site_url: https://github.com/IlumCI/CR-CA
|
|
5
|
+
|
|
6
|
+
repo_name: IlumCI/CR-CA
|
|
7
|
+
repo_url: https://github.com/IlumCI/CR-CA
|
|
8
|
+
edit_uri: edit/main/docs/
|
|
9
|
+
|
|
10
|
+
copyright: Copyright © 2024-2026 CR-CA Contributors
|
|
11
|
+
|
|
12
|
+
theme:
|
|
13
|
+
name: material
|
|
14
|
+
palette:
|
|
15
|
+
- scheme: default
|
|
16
|
+
primary: indigo
|
|
17
|
+
accent: blue
|
|
18
|
+
toggle:
|
|
19
|
+
icon: material/brightness-7
|
|
20
|
+
name: Switch to dark mode
|
|
21
|
+
- scheme: slate
|
|
22
|
+
primary: indigo
|
|
23
|
+
accent: blue
|
|
24
|
+
toggle:
|
|
25
|
+
icon: material/brightness-4
|
|
26
|
+
name: Switch to light mode
|
|
27
|
+
font:
|
|
28
|
+
text: Inter
|
|
29
|
+
code: Roboto Mono
|
|
30
|
+
features:
|
|
31
|
+
- navigation.tabs
|
|
32
|
+
- navigation.sections
|
|
33
|
+
- navigation.expand
|
|
34
|
+
- navigation.top
|
|
35
|
+
- search.suggest
|
|
36
|
+
- search.highlight
|
|
37
|
+
- content.code.annotate
|
|
38
|
+
- content.tabs.link
|
|
39
|
+
- content.code.copy
|
|
40
|
+
icon:
|
|
41
|
+
repo: fontawesome/brands/github
|
|
42
|
+
|
|
43
|
+
markdown_extensions:
|
|
44
|
+
- pymdownx.arithmatex:
|
|
45
|
+
generic: true
|
|
46
|
+
- pymdownx.superfences:
|
|
47
|
+
custom_fences:
|
|
48
|
+
- name: mermaid
|
|
49
|
+
class: mermaid
|
|
50
|
+
format: !!python/name:pymdownx.superfences.fence_code_format
|
|
51
|
+
- pymdownx.highlight:
|
|
52
|
+
anchor_linenums: true
|
|
53
|
+
line_spans: __span
|
|
54
|
+
pygments_lang_class: true
|
|
55
|
+
- pymdownx.inlinehilite
|
|
56
|
+
- pymdownx.snippets
|
|
57
|
+
- pymdownx.tabbed:
|
|
58
|
+
alternate_style: true
|
|
59
|
+
- admonition
|
|
60
|
+
- pymdownx.details
|
|
61
|
+
- pymdownx.tasklist:
|
|
62
|
+
custom_checkbox: true
|
|
63
|
+
- attr_list
|
|
64
|
+
- md_in_html
|
|
65
|
+
- toc:
|
|
66
|
+
permalink: true
|
|
67
|
+
toc_depth: 3
|
|
68
|
+
|
|
69
|
+
plugins:
|
|
70
|
+
- search:
|
|
71
|
+
lang: en
|
|
72
|
+
- minify:
|
|
73
|
+
minify_html: true
|
|
74
|
+
- git-revision-date-localized:
|
|
75
|
+
enable_creation_date: true
|
|
76
|
+
type: date
|
|
77
|
+
- mermaid2
|
|
78
|
+
- mkdocstrings:
|
|
79
|
+
handlers:
|
|
80
|
+
python:
|
|
81
|
+
paths: [..]
|
|
82
|
+
selection:
|
|
83
|
+
docstring_style: google
|
|
84
|
+
rendering:
|
|
85
|
+
show_source: true
|
|
86
|
+
show_root_heading: true
|
|
87
|
+
show_root_toc_entry: true
|
|
88
|
+
|
|
89
|
+
extra_javascript:
|
|
90
|
+
- javascripts/mathjax.js
|
|
91
|
+
- https://polyfill.io/v3/polyfill.min.js?features=es6
|
|
92
|
+
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
|
|
93
|
+
|
|
94
|
+
extra_css:
|
|
95
|
+
- css/custom.css
|
|
96
|
+
- stylesheets/extra.css
|
|
97
|
+
|
|
98
|
+
nav:
|
|
99
|
+
- Home: index.md
|
|
100
|
+
- Getting Started:
|
|
101
|
+
- Installation: getting-started/installation.md
|
|
102
|
+
- Quickstart: getting-started/quickstart.md
|
|
103
|
+
- Configuration: getting-started/configuration.md
|
|
104
|
+
- First Agent: getting-started/first-agent.md
|
|
105
|
+
- Core Modules:
|
|
106
|
+
- CRCAAgent:
|
|
107
|
+
- Overview: core/crcagent/overview.md
|
|
108
|
+
- Initialization: core/crcagent/initialization.md
|
|
109
|
+
- Automatic Extraction: core/crcagent/automatic-extraction.md
|
|
110
|
+
- Dual-Mode Operation: core/crcagent/dual-mode-operation.md
|
|
111
|
+
- Causal Graph: core/crcagent/causal-graph.md
|
|
112
|
+
- Deterministic Simulation: core/crcagent/deterministic-simulation.md
|
|
113
|
+
- Counterfactuals: core/crcagent/counterfactuals.md
|
|
114
|
+
- Batch Prediction: core/crcagent/batch-prediction.md
|
|
115
|
+
- Async Operations: core/crcagent/async-operations.md
|
|
116
|
+
- Optimization: core/crcagent/optimization.md
|
|
117
|
+
- Time-Series: core/crcagent/time-series.md
|
|
118
|
+
- Bayesian Inference: core/crcagent/bayesian-inference.md
|
|
119
|
+
- Utils:
|
|
120
|
+
- Overview: core/utils/overview.md
|
|
121
|
+
- Router: core/utils/router.md
|
|
122
|
+
- Conversation: core/utils/conversation.md
|
|
123
|
+
- Graph Reasoner: core/utils/graph-reasoner.md
|
|
124
|
+
- Utilities: core/utils/utilities.md
|
|
125
|
+
- Templates:
|
|
126
|
+
- Overview: core/templates/overview.md
|
|
127
|
+
- Base Agent: core/templates/base-agent.md
|
|
128
|
+
- Feature Mixins: core/templates/feature-mixins.md
|
|
129
|
+
- Templates Guide: core/templates/templates-guide.md
|
|
130
|
+
- Schemas:
|
|
131
|
+
- Overview: core/schemas/overview.md
|
|
132
|
+
- Annotation: core/schemas/annotation.md
|
|
133
|
+
- Core Schemas: core/schemas/core-schemas.md
|
|
134
|
+
- Policy: core/schemas/policy.md
|
|
135
|
+
- Tools:
|
|
136
|
+
- Overview: core/tools/overview.md
|
|
137
|
+
- MCP Client: core/tools/mcp-client.md
|
|
138
|
+
- Branches:
|
|
139
|
+
- CRCA-Q:
|
|
140
|
+
- Overview: branches/crca-q/overview.md
|
|
141
|
+
- Philosophy: branches/crca-q/philosophy.md
|
|
142
|
+
- Architecture: branches/crca-q/architecture.md
|
|
143
|
+
- Market Data: branches/crca-q/market-data.md
|
|
144
|
+
- Alternative Data: branches/crca-q/alternative-data.md
|
|
145
|
+
- Signal Generation: branches/crca-q/signal-generation.md
|
|
146
|
+
- Causal Engine: branches/crca-q/causal-engine.md
|
|
147
|
+
- Signal Validation: branches/crca-q/signal-validation.md
|
|
148
|
+
- Portfolio Optimization: branches/crca-q/portfolio-optimization.md
|
|
149
|
+
- Risk Management: branches/crca-q/risk-management.md
|
|
150
|
+
- Execution: branches/crca-q/execution.md
|
|
151
|
+
- Backtesting: branches/crca-q/backtesting.md
|
|
152
|
+
- Setup: branches/crca-q/setup.md
|
|
153
|
+
- CRCA-SD:
|
|
154
|
+
- Overview: branches/crca-sd/overview.md
|
|
155
|
+
- Core: branches/crca-sd/core.md
|
|
156
|
+
- MPC Solver: branches/crca-sd/mpc-solver.md
|
|
157
|
+
- Governance: branches/crca-sd/governance.md
|
|
158
|
+
- Real-Time: branches/crca-sd/realtime.md
|
|
159
|
+
- TUI: branches/crca-sd/tui.md
|
|
160
|
+
- CRCA-CG:
|
|
161
|
+
- Overview: branches/crca-cg/overview.md
|
|
162
|
+
- CorporateSwarm: branches/crca-cg/corposwarm.md
|
|
163
|
+
- ESG Scoring: branches/crca-cg/esg-scoring.md
|
|
164
|
+
- Multi-Agent: branches/crca-cg/multi-agent.md
|
|
165
|
+
- General Agent:
|
|
166
|
+
- Overview: branches/general-agent/overview.md
|
|
167
|
+
- Personality: branches/general-agent/personality.md
|
|
168
|
+
- Prompt Builder: branches/general-agent/prompt-builder.md
|
|
169
|
+
- Features:
|
|
170
|
+
- Image Annotation:
|
|
171
|
+
- Overview: features/image-annotation/overview.md
|
|
172
|
+
- Quickstart: features/image-annotation/quickstart.md
|
|
173
|
+
- Engine: features/image-annotation/engine.md
|
|
174
|
+
- Features: features/image-annotation/features.md
|
|
175
|
+
- Integration: features/image-annotation/integration.md
|
|
176
|
+
- Policy Engine:
|
|
177
|
+
- Overview: features/policy-engine/overview.md
|
|
178
|
+
- Doctrine & Ledger: features/policy-engine/doctrine-ledger.md
|
|
179
|
+
- MPC & Control: features/policy-engine/mpc-control.md
|
|
180
|
+
- Monitoring & Drift Detection: features/policy-engine/monitoring.md
|
|
181
|
+
- Hybrid Agent:
|
|
182
|
+
- Overview: features/hybrid-agent/overview.md
|
|
183
|
+
- Core Components: features/hybrid-agent/core-components.md
|
|
184
|
+
- Advanced Components: features/hybrid-agent/advanced-components.md
|
|
185
|
+
- Causal Reasoning:
|
|
186
|
+
- Overview: features/causal-reasoning/overview.md
|
|
187
|
+
- Structural Models: features/causal-reasoning/structural-models.md
|
|
188
|
+
- Do-Calculus: features/causal-reasoning/do-calculus.md
|
|
189
|
+
- Counterfactuals: features/causal-reasoning/counterfactuals.md
|
|
190
|
+
- Advanced Topics: features/causal-reasoning/advanced-topics.md
|
|
191
|
+
- Examples:
|
|
192
|
+
- Overview: examples/overview.md
|
|
193
|
+
- Basic Usage: examples/basic-usage.md
|
|
194
|
+
- General Agent: examples/general-agent/general-agent-examples.md
|
|
195
|
+
- Hybrid Agent: examples/hybrid-agent/hybrid-agent-examples.md
|
|
196
|
+
- Image Annotation: examples/image-annotation/image-annotation-examples.md
|
|
197
|
+
- Trading: examples/trading/trading-examples.md
|
|
198
|
+
- Integration: examples/integration/integration-examples.md
|
|
199
|
+
- Architecture:
|
|
200
|
+
- Overview: architecture/overview.md
|
|
201
|
+
- Design Principles: architecture/design-principles.md
|
|
202
|
+
- Data Flow: architecture/data-flow.md
|
|
203
|
+
- Modular Structure: architecture/modular-structure.md
|
|
204
|
+
- Hybrid Agent:
|
|
205
|
+
- Overview: architecture/hybrid-agent/overview.md
|
|
206
|
+
- Components: architecture/hybrid-agent/components.md
|
|
207
|
+
- Consistency: architecture/hybrid-agent/consistency.md
|
|
208
|
+
- Reasoning: architecture/hybrid-agent/reasoning.md
|
|
209
|
+
- Causal Graphs: architecture/causal-graphs.md
|
|
210
|
+
- LLM Integration: architecture/llm-integration.md
|
|
211
|
+
- Policy Engine: architecture/policy-engine-arch.md
|
|
212
|
+
- API Reference:
|
|
213
|
+
- CRCAAgent:
|
|
214
|
+
- Overview: api/crca/overview.md
|
|
215
|
+
- Agent & Methods: api/crca/agent-methods.md
|
|
216
|
+
- Operations: api/crca/operations.md
|
|
217
|
+
- Utils:
|
|
218
|
+
- Overview: api/utils/overview.md
|
|
219
|
+
- Router: api/utils/router.md
|
|
220
|
+
- Conversation: api/utils/conversation.md
|
|
221
|
+
- Graph Reasoner: api/utils/graph-reasoner.md
|
|
222
|
+
- Utilities: api/utils/utilities.md
|
|
223
|
+
- Schemas:
|
|
224
|
+
- Overview: api/schemas/overview.md
|
|
225
|
+
- Annotation: api/schemas/annotation.md
|
|
226
|
+
- Core Schemas: api/schemas/core-schemas.md
|
|
227
|
+
- Policy: api/schemas/policy.md
|
|
228
|
+
- Branches:
|
|
229
|
+
- Overview: api/branches/overview.md
|
|
230
|
+
- CRCA-Q: api/branches/crca-q.md
|
|
231
|
+
- CRCA-SD: api/branches/crca-sd.md
|
|
232
|
+
- CRCA-CG: api/branches/crca-cg.md
|
|
233
|
+
- General Agent: api/branches/general-agent.md
|
|
234
|
+
- Image Annotation:
|
|
235
|
+
- Overview: api/image-annotation/overview.md
|
|
236
|
+
- Engine: api/image-annotation/engine.md
|
|
237
|
+
- Changelog: changelog/index.md
|
|
238
|
+
- Contributing: contributing/overview.md
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* Additional custom styles for CR-CA documentation */
|
|
2
|
+
|
|
3
|
+
/* Ensure MathJax renders properly */
|
|
4
|
+
.MathJax {
|
|
5
|
+
font-size: 1.1em;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* Math display blocks */
|
|
9
|
+
.MathJax_Display {
|
|
10
|
+
margin: 1em 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Code blocks with math */
|
|
14
|
+
.md-typeset code {
|
|
15
|
+
font-family: "Roboto Mono", monospace;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Ensure proper spacing for math */
|
|
19
|
+
.md-typeset .arithmatex {
|
|
20
|
+
margin: 0.5em 0;
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## `CounterfactualResult`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `result_type` | `string` | optional. |
|
|
8
|
+
| `provenance` | `#/$defs/ProvenanceManifest` | required. |
|
|
9
|
+
| `assumptions` | `array` | optional. |
|
|
10
|
+
| `limitations` | `array` | optional. |
|
|
11
|
+
| `artifacts` | `object` | optional. |
|
|
12
|
+
| `counterfactual` | `object` | optional. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## `DiscoveryHypothesisResult`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `result_type` | `string` | optional. |
|
|
8
|
+
| `provenance` | `#/$defs/ProvenanceManifest` | required. |
|
|
9
|
+
| `assumptions` | `array` | optional. |
|
|
10
|
+
| `limitations` | `array` | optional. |
|
|
11
|
+
| `artifacts` | `object` | optional. |
|
|
12
|
+
| `graph_hypothesis` | `object` | optional. |
|
|
13
|
+
| `stability_report` | `object` | optional. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## `DraftSpec`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `status` | `#/$defs/SpecStatus` | optional. |
|
|
8
|
+
| `data` | `#/$defs/DataSpec` | optional. |
|
|
9
|
+
| `graph` | `#/$defs/CausalGraphSpec` | optional. |
|
|
10
|
+
| `roles` | `#/$defs/RoleSpec` | optional. |
|
|
11
|
+
| `assumptions` | `#/$defs/AssumptionSpec` | optional. |
|
|
12
|
+
| `scm` | `unknown` | optional. |
|
|
13
|
+
| `draft_notes` | `unknown` | optional. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## `EstimateResult`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `result_type` | `string` | optional. |
|
|
8
|
+
| `provenance` | `#/$defs/ProvenanceManifest` | required. |
|
|
9
|
+
| `assumptions` | `array` | optional. |
|
|
10
|
+
| `limitations` | `array` | optional. |
|
|
11
|
+
| `artifacts` | `object` | optional. |
|
|
12
|
+
| `estimate` | `object` | optional. |
|
|
13
|
+
| `refutations` | `object` | optional. |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## `IdentificationResult`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `result_type` | `string` | optional. |
|
|
8
|
+
| `provenance` | `#/$defs/ProvenanceManifest` | required. |
|
|
9
|
+
| `assumptions` | `array` | optional. |
|
|
10
|
+
| `limitations` | `array` | optional. |
|
|
11
|
+
| `artifacts` | `object` | optional. |
|
|
12
|
+
| `method` | `string` | required. |
|
|
13
|
+
| `scope` | `string` | optional. |
|
|
14
|
+
| `confidence` | `string` | optional. |
|
|
15
|
+
| `estimand_expression` | `string` | required. |
|
|
16
|
+
| `assumptions_used` | `array` | optional. |
|
|
17
|
+
| `witnesses` | `object` | optional. |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## `InterventionDesignResult`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `result_type` | `string` | optional. |
|
|
8
|
+
| `provenance` | `#/$defs/ProvenanceManifest` | required. |
|
|
9
|
+
| `assumptions` | `array` | optional. |
|
|
10
|
+
| `limitations` | `array` | optional. |
|
|
11
|
+
| `artifacts` | `object` | optional. |
|
|
12
|
+
| `designs` | `array` | optional. |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## `LockedSpec`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `status` | `#/$defs/SpecStatus` | optional. |
|
|
8
|
+
| `spec_hash` | `string` | required. |
|
|
9
|
+
| `approvals` | `array` | optional. |
|
|
10
|
+
| `locked_at_utc` | `string` | required. |
|
|
11
|
+
| `data` | `#/$defs/DataSpec` | required. |
|
|
12
|
+
| `graph` | `#/$defs/CausalGraphSpec` | required. |
|
|
13
|
+
| `roles` | `#/$defs/RoleSpec` | required. |
|
|
14
|
+
| `assumptions` | `#/$defs/AssumptionSpec` | required. |
|
|
15
|
+
| `scm` | `unknown` | optional. |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## `RefusalResult`
|
|
2
|
+
|
|
3
|
+
This page is generated from the JSON schema (contract-first).
|
|
4
|
+
|
|
5
|
+
| Field | Type | Notes |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `result_type` | `string` | optional. |
|
|
8
|
+
| `reason_codes` | `array` | optional. |
|
|
9
|
+
| `message` | `string` | required. |
|
|
10
|
+
| `checklist` | `array` | optional. |
|
|
11
|
+
| `suggested_next_steps` | `array` | optional. |
|
|
12
|
+
| `details` | `unknown` | optional. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# crca_core schema contracts (generated)
|
|
2
|
+
|
|
3
|
+
These documents are generated from exported Pydantic JSON schemas.
|
|
4
|
+
|
|
5
|
+
- `CounterfactualResult`: `CounterfactualResult.md`
|
|
6
|
+
- `DiscoveryHypothesisResult`: `DiscoveryHypothesisResult.md`
|
|
7
|
+
- `DraftSpec`: `DraftSpec.md`
|
|
8
|
+
- `EstimateResult`: `EstimateResult.md`
|
|
9
|
+
- `IdentificationResult`: `IdentificationResult.md`
|
|
10
|
+
- `InterventionDesignResult`: `InterventionDesignResult.md`
|
|
11
|
+
- `LockedSpec`: `LockedSpec.md`
|
|
12
|
+
- `RefusalResult`: `RefusalResult.md`
|
|
13
|
+
- `ValidationReport`: `ValidationReport.md`
|