dir-core 0.2.0__tar.gz → 0.3.0__tar.gz

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.
Files changed (60) hide show
  1. {dir_core-0.2.0 → dir_core-0.3.0}/PKG-INFO +72 -64
  2. {dir_core-0.2.0 → dir_core-0.3.0}/README.md +70 -62
  3. {dir_core-0.2.0 → dir_core-0.3.0}/pyproject.toml +2 -2
  4. dir_core-0.3.0/src/dir_core/ledger.py +70 -0
  5. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/storage/__init__.py +9 -0
  6. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/storage/base.py +43 -11
  7. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/storage/memory.py +52 -0
  8. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/storage/schema.sql +35 -0
  9. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/storage/sqlite.py +93 -0
  10. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core.egg-info/PKG-INFO +72 -64
  11. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core.egg-info/SOURCES.txt +1 -0
  12. dir_core-0.3.0/tests/test_decision_ledger_storage.py +73 -0
  13. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_ledger.py +26 -6
  14. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_pg_repo.py +19 -4
  15. dir_core-0.2.0/src/dir_core/ledger.py +0 -44
  16. {dir_core-0.2.0 → dir_core-0.3.0}/LICENSE +0 -0
  17. {dir_core-0.2.0 → dir_core-0.3.0}/setup.cfg +0 -0
  18. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/__init__.py +0 -0
  19. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/agent_registry.py +0 -0
  20. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/arbitration.py +0 -0
  21. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/context_store.py +0 -0
  22. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/data_types.py +0 -0
  23. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/dfid.py +0 -0
  24. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/dim.py +0 -0
  25. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/escalation.py +0 -0
  26. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/event_bus.py +0 -0
  27. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/idempotency.py +0 -0
  28. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/intent_retry.py +0 -0
  29. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/jit.py +0 -0
  30. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/lifecycle.py +0 -0
  31. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/models.py +0 -0
  32. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/pci.py +0 -0
  33. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/resource_lock.py +0 -0
  34. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/runtime.py +0 -0
  35. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/saga.py +0 -0
  36. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/storage/json_util.py +0 -0
  37. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/utils/__init__.py +0 -0
  38. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/utils/llm_client.py +0 -0
  39. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/utils/logging_utils.py +0 -0
  40. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core/wakeup.py +0 -0
  41. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core.egg-info/dependency_links.txt +0 -0
  42. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core.egg-info/requires.txt +0 -0
  43. {dir_core-0.2.0 → dir_core-0.3.0}/src/dir_core.egg-info/top_level.txt +0 -0
  44. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_agent_registry.py +0 -0
  45. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_arbitration.py +0 -0
  46. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_context_store.py +0 -0
  47. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_dfid.py +0 -0
  48. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_dim_ttl.py +0 -0
  49. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_escalation.py +0 -0
  50. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_event_bus.py +0 -0
  51. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_idempotency.py +0 -0
  52. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_intent_retry.py +0 -0
  53. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_jit.py +0 -0
  54. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_lifecycle.py +0 -0
  55. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_ollama.py +0 -0
  56. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_pci.py +0 -0
  57. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_resource_lock.py +0 -0
  58. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_runtime.py +0 -0
  59. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_saga.py +0 -0
  60. {dir_core-0.2.0 → dir_core-0.3.0}/tests/test_wakeup.py +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dir-core
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Decision Intelligence Runtime - deterministic Kernel Space for agentic AI
5
- Author: Artur Huk
5
+ Author-email: Artur Huk <artur.huk.it@gmail.com>
6
6
  License-Expression: Apache-2.0
7
7
  Project-URL: Homepage, https://github.com/huka81/decision-intelligence-runtime
8
8
  Project-URL: Repository, https://github.com/huka81/decision-intelligence-runtime
@@ -62,52 +62,51 @@ This repository contains the architectural concepts, formal specifications, and
62
62
 
63
63
  ---
64
64
 
65
- ## Architectural Convergence & Validation
65
+ ## Why Another Agent Runtime?
66
66
 
67
- The publication of *Intelligent AI Delegation* by Google DeepMind (February 2026, arXiv:2602.11865) confirms the architectural direction we have been developing since early 2025. Their formalization of "Responsibility Transfer," "Auditability," and "Permission Handling" as fundamental requirements for agentic systems aligns with the patterns we have been validating in production environments.
67
+ The current discussion around Agentic AI is rapidly converging on a common observation: production systems require governance beyond prompt engineering.
68
68
 
69
- The independent convergence is notable:
69
+ Different communities describe different aspects of the problem:
70
70
 
71
- * **Google's "Responsibility Transfer"** **ROA Responsibility Contracts**
72
- * **Google's "Auditability"** **DecisionFlow ID (DFID)**
73
- * **Google's "Permission Handling"** **Decision Integrity Module (DIM)**
71
+ - **Principal Drift** emphasizes authority, delegation, and accountability.
72
+ - **Agent Experience (AX)** focuses on exposing the right context and capabilities to autonomous systems.
73
+ - **Enterprise AI Governance** emphasizes policy enforcement, auditability, and human oversight.
74
+ - **Evaluation frameworks** measure reliability after deployment.
75
+ - **Workflow and orchestration platforms** focus on execution and coordination.
74
76
 
75
- This alignment reinforces that these patterns are not vendor-specific abstractions-they are architectural necessities for production-grade agentic systems.
77
+ Notably, this convergence is confirmed by recent research such as Google DeepMind's *Intelligent AI Delegation* (2026), which formalizes "Responsibility Transfer", "Auditability", and "Permission Handling" as core requirements for agentic systems. We have observed that these theoretical requirements map directly to DIR's architectural primitives (ROA Contracts, DFID tracing, and the DIM gate). **[Read the full framework comparison: Google DeepMind vs. DIR/ROA](./docs/00-introduction/Intelligent_Delegation_Framework_Mapping.md)**
76
78
 
77
- ### Industry Validation: Google DeepMind vs. DIR Implementation
79
+ Decision Intelligence Runtime starts from a core question:
78
80
 
79
- While Google's *Intelligent AI Delegation* (2026) outlines the *theoretical* requirements for safe agentic systems, **DIR provides the open-source architectural implementation available today.**
81
+ > *What are the minimal conditions that must simultaneously hold before an autonomous decision is allowed to execute?*
80
82
 
81
- | Requirement (Google DeepMind) | DIR Implementation (This Repo) | Status |
82
- | :--- | :--- | :--- |
83
- | **Verifiable Task Completion** | **Topology C (DL+PCI)** <br> *Cryptographic Proof-Carrying Intents* | ✅ Implemented |
84
- | **Transfer of Authority** | **Responsibility Contracts** <br> *Machine-readable scope definitions* | ✅ Implemented |
85
- | **Permission Handling** | **Kernel Space (DIM)** <br> *Deterministic policy enforcement* | ✅ Implemented |
86
- | **Structural Transparency** | **DecisionFlow ID (DFID)** <br> *End-to-end distributed tracing* | ✅ Implemented |
83
+ DIR proposes that many of these discussions can be viewed through a common architectural lens called the **Legal Decision State (LDS)**.
87
84
 
85
+ ### The Core Philosophy: Legal Decision State (LDS)
88
86
 
89
- **[Read the full framework comparison: Google DeepMind vs. DIR/ROA](./docs/00-introduction/Intelligent_Delegation_Framework_Mapping.md)**
87
+ DIR is built on the formal premise that an AI agent cannot be trusted to maintain system integrity probabilistically. Instead, the runtime ensures that the system never enters an **Illegal Decision State**.
90
88
 
91
- ---
89
+ A decision is considered execution-safe—and allowed to pass through the runtime—only when five independent dimensions are simultaneously satisfied. We call this the **Legal Decision State (LDS)**:
92
90
 
93
- ## Quick Start
91
+ $$LDS = C \wedge A \wedge I \wedge E \wedge T$$
94
92
 
95
- The fastest way to see the DIR architecture in action:
93
+ ![Legal Decision State Invariants](./assets/images/lds-octagon.png)
96
94
 
97
- ```bash
98
- pip install -e .
99
- python samples/00_quick_start/run.py
100
- ```
95
+ If any of these components is false ($\neg C \vee \neg A \vee \neg I \vee \neg E \vee \neg T$), the decision is structurally illegal and must be aborted. Every component in the DIR ecosystem exists exclusively to protect one of these invariants:
101
96
 
102
- This sample demonstrates protection against catastrophic actions (e.g. parsing error turning 15.5 ETH into 15,500 ETH) and prompt injection in external data. High-level overview of the full architecture. See [samples/00_quick_start](samples/00_quick_start/README.md).
97
+ - **Context (C):** Protected by the **Context Store** & **Context-as-Code (CaC)**. Ensures the agent is not acting on stale, hallucinated, or mission-drifted data.
98
+ - **Authority (A):** Protected by **Responsibility-Oriented Agents (ROA)**. Ensures the agent's proposed action does not exceed its explicitly registered contractual limits.
99
+ - **Intent (I):** Protected by **SDS Grammars** & **DIM Schema Validation**. Ensures the action is syntactically valid and structurally executable.
100
+ - **Evidence (E):** Protected by the **Evidence Governance Layer**. Detects "Compliant Lies" by ensuring the action is backed by deterministically reproducible reasoning.
101
+ - **Time (T):** Protected by **JIT State Verification** & **Drift Envelopes**. Prevents Time-of-Check to Time-of-Use (TOCTOU) races by ensuring reality hasn't shifted between LLM reasoning and API execution.
103
102
 
104
- ---
103
+ *The Decision Integrity Module (DIM) is the deterministic gatekeeper that mathematically enforces this equation before any side effect occurs.*
105
104
 
106
- ## Start Here
105
+ Rather than embedding these guarantees inside prompts or increasingly capable language models, DIR externalizes them into deterministic runtime infrastructure.
107
106
 
108
- If you are new to DIR/ROA, begin with the introduction article. It explains the core motivation ("Day Two" failures in production systems), the Kernel Space vs. User Space architectural boundary, and why traditional agentic loops are insufficient for high-stakes environments.
107
+ The goal is not to make language models perfectly intelligent.
109
108
 
110
- **[Read: Beyond Prompt Engineering - Building a Deterministic Runtime for Responsible AI Agents](./docs/00-introduction/DIR-introduction.md)**
109
+ The goal is to make imperfect language models economically and operationally safe to deploy.
111
110
 
112
111
  ## Why use DIR today?
113
112
 
@@ -121,6 +120,8 @@ Big Tech providers are beginning to theorize about "Agent Runtimes" as proprieta
121
120
 
122
121
  ## Core Concepts
123
122
 
123
+ If you are new to DIR/ROA, begin with the **[Introduction Article](./docs/00-introduction/DIR-introduction.md)** to understand the "Day Two" failures in production systems, the Kernel Space vs. User Space architectural boundary, and why traditional agentic loops are insufficient for high-stakes environments. Then, explore the core pillars below:
124
+
124
125
  ### 1. Responsibility-Oriented Agents (ROA)
125
126
  *Current Status: Published*
126
127
 
@@ -163,6 +164,12 @@ An architectural defense against "Day Three" problems, where an agent's individu
163
164
 
164
165
  **[Read Governance & Agent Drift](./docs/04-governance/DIR_Governance.md)**
165
166
 
167
+ ### 5. Machine-Optimized Specification
168
+
169
+ **[DIR-minified.md](./docs/07-dir-minified/DIR-minified.md)** is a **single-file, machine-optimized** version of the framework specification. It is intended **for use as context** by LLMs and code-generation agents (e.g. Cursor, Claude, Devin), not as primary reading for humans. If you are feeding this repo to an AI to implement or extend DIR, attach this file as the main spec; the human-oriented docs remain the narrative and tutorial layer.
170
+
171
+ For short answers to common engineering questions, see the **[FAQ](./FAQ.md)**.
172
+
166
173
  ---
167
174
 
168
175
  # Getting Started
@@ -174,39 +181,58 @@ An architectural defense against "Day Three" problems, where an agent's individu
174
181
 
175
182
  ## Installation
176
183
 
177
- 1. Clone the repository.
178
- 2. Install the package in editable mode:
184
+ Install the published package:
179
185
 
180
186
  ```bash
187
+ pip install dir-core
188
+ ```
189
+
190
+ Or clone this repository if you want to run the samples or work with the source code:
191
+
192
+ ```bash
193
+ git clone https://github.com/huka81/decision-intelligence-runtime.git
194
+ cd decision-intelligence-runtime
181
195
  pip install -e .
182
196
  ```
197
+
183
198
  *This installs the `dir_core` package (source in `src/dir_core`), making it available to all sample implementations.*
184
199
 
200
+ ## Quick Start
201
+
202
+ From the cloned repository, run the Quick Start sample to see the DIR architecture in action:
203
+
204
+ ```bash
205
+ python samples/00_quick_start/run.py
206
+ ```
207
+
208
+ This sample demonstrates protection against catastrophic actions (e.g. parsing error turning 15.5 ETH into 15,500 ETH) and prompt injection in external data. It gives a high-level overview of the full architecture. See [samples/00_quick_start](samples/00_quick_start/README.md).
209
+
185
210
  ## Repository Structure
186
211
 
187
212
  ```text
188
213
  decision-intelligence-runtime/
189
- ├── README.md
190
- ├── FAQ.md # Frequently asked questions (architecture, adoption, compliance)
191
- ├── pyproject.toml # pip install -e . installs dir_core (incl. dir_core.utils for samples)
192
- ├── requirements.txt # Shared dependencies
193
- ├── src/
194
- │ └── dir_core/ # Core DIR/ROA components (per docs spec)
195
- │ # DFID, EventBus, DIM, Context Store, models, arbitration, PCI, etc.
196
- │ └── utils/ # Supporting utilities for samples
197
- │ # logging_utils, config_loader, llm_client (synthetic market: samples/31_finance_trading/mocks/)
198
- ├── samples/ # Reference implementations (01–11 mechanics, 31+ use cases)
199
- │ ├── README.md # Sample catalog and run instructions
200
- │ ├── 00_quick_start/ … 08_custom_repo_psql/ … 11_topology_c_dl_pci/
201
- │ ├── 31_finance_trading/ … 35_crewai_roa_wrapper/ … 36_drift_optimization_discount/ … 37_drift_semantic_refund/ … 38_drift_environmental_bidding/
202
- │ └── 88_meta_context_engineering/ # Meta-sample: System Prompt Toolkit
203
214
  ├── docs/ # Architectural documentation
204
215
  │ ├── 00-introduction/ # DIR intro, framework mapping
205
216
  │ ├── 01-roa-manifesto/
206
217
  │ ├── 02-decision-runtime/
207
218
  │ ├── 03-topologies/
219
+ │ ├── 04-governance/
208
220
  │ ├── 07-dir-minified/ # Machine-optimized single-file spec (DIR-minified.md)
209
221
  │ └── 08-conclusion/ # Context as Code concept
222
+ ├── src/
223
+ │ └── dir_core/ # Core DIR/ROA components (per docs spec)
224
+ │ │ # DFID, EventBus, DIM, Context Store, models, arbitration, PCI, etc.
225
+ │ └── utils/ # Supporting utilities for samples
226
+ │ # logging_utils, config_loader, llm_client (synthetic market: samples/31_finance_trading/mocks/)
227
+ ├── samples/ # Reference implementations (01–11 mechanics, 31+ use cases)
228
+ │ ├── README.md # Sample catalog and run instructions
229
+ │ ├── 00_quick_start/ … 08_custom_repo_psql/ … 11_topology_c_dl_pci/
230
+ │ ├── 31_finance_trading/ … 38_drift_environmental_bidding/
231
+ │ └── 88_meta_context_engineering/ # Meta-sample: System Prompt Toolkit
232
+ ├── README.md
233
+ ├── FAQ.md # Frequently asked questions (architecture, adoption, compliance)
234
+ ├── pyproject.toml # pip install -e . installs dir_core (incl. dir_core.utils for samples)
235
+ ├── requirements.txt # Shared dependencies
210
236
  └── assets/ # Images, diagrams
211
237
  ```
212
238
 
@@ -220,24 +246,6 @@ Execute any sample from the repository root: `python samples/<folder>/run.py`
220
246
 
221
247
  **[View the full catalog of Samples & Reference Implementations](samples/README.md)**
222
248
 
223
- ---
224
- ## Documentation
225
-
226
- - **[DIR Introduction](./docs/00-introduction/DIR-introduction.md)** - Architectural motivation and Kernel Space / User Space boundary.
227
- - **[ROA Manifesto](./docs/01-roa-manifesto/ROA_Manifesto.md)** - Responsibility-oriented agent design.
228
- - **[DIR Architecture](./docs/02-decision-runtime/DIR_Architectural_Pattern.md)** - Runtime components and invariants.
229
- - **[Topologies](./docs/03-topologies/DIR_Topologies.md)** - Operational modes (EOAM, SDS, DL+PCI).
230
- - **[Governance & Drift](./docs/04-governance/DIR_Governance.md)** - Managing aggregate safety and business health over time.
231
- - **[Context as Code](./docs/08-conclusion/Context_as_Code.md)** - Treating documentation as a system prompt.
232
- - **[FAQ](./FAQ.md)** - Answers to common engineering questions about DIR/ROA: "Day Two" failure modes, Kernel vs User Space, comparison with orchestration frameworks, JIT state verification, idempotency, compliance (e.g. EU AI Act and Proof-Carrying Intents), and incremental adoption.
233
-
234
-
235
- ### Machine-optimized specification: DIR-minified.md
236
-
237
- **[DIR-minified](./docs/07-dir-minified/DIR-minified.md)** is a **single-file, machine-optimized** version of the framework specification. It is intended **for use as context** by LLMs and code-generation agents (e.g. Cursor, Claude, Devin), not as primary reading for humans.
238
-
239
- The document is intentionally **radical** (dense, exhaustive) and **redundant** (repeats key constraints and examples in multiple places) so that a model loading it as context has a complete, self-contained picture of ROA, DIR, and the three topologies without chasing links. If you are feeding this repo to an AI to implement or extend DIR, attach **DIR-minified.md** as the main spec; the human-oriented docs in `docs/` remain the narrative and tutorial layer.
240
-
241
249
  ---
242
250
 
243
251
  ## License
@@ -20,52 +20,51 @@ This repository contains the architectural concepts, formal specifications, and
20
20
 
21
21
  ---
22
22
 
23
- ## Architectural Convergence & Validation
23
+ ## Why Another Agent Runtime?
24
24
 
25
- The publication of *Intelligent AI Delegation* by Google DeepMind (February 2026, arXiv:2602.11865) confirms the architectural direction we have been developing since early 2025. Their formalization of "Responsibility Transfer," "Auditability," and "Permission Handling" as fundamental requirements for agentic systems aligns with the patterns we have been validating in production environments.
25
+ The current discussion around Agentic AI is rapidly converging on a common observation: production systems require governance beyond prompt engineering.
26
26
 
27
- The independent convergence is notable:
27
+ Different communities describe different aspects of the problem:
28
28
 
29
- * **Google's "Responsibility Transfer"** **ROA Responsibility Contracts**
30
- * **Google's "Auditability"** **DecisionFlow ID (DFID)**
31
- * **Google's "Permission Handling"** **Decision Integrity Module (DIM)**
29
+ - **Principal Drift** emphasizes authority, delegation, and accountability.
30
+ - **Agent Experience (AX)** focuses on exposing the right context and capabilities to autonomous systems.
31
+ - **Enterprise AI Governance** emphasizes policy enforcement, auditability, and human oversight.
32
+ - **Evaluation frameworks** measure reliability after deployment.
33
+ - **Workflow and orchestration platforms** focus on execution and coordination.
32
34
 
33
- This alignment reinforces that these patterns are not vendor-specific abstractions-they are architectural necessities for production-grade agentic systems.
35
+ Notably, this convergence is confirmed by recent research such as Google DeepMind's *Intelligent AI Delegation* (2026), which formalizes "Responsibility Transfer", "Auditability", and "Permission Handling" as core requirements for agentic systems. We have observed that these theoretical requirements map directly to DIR's architectural primitives (ROA Contracts, DFID tracing, and the DIM gate). **[Read the full framework comparison: Google DeepMind vs. DIR/ROA](./docs/00-introduction/Intelligent_Delegation_Framework_Mapping.md)**
34
36
 
35
- ### Industry Validation: Google DeepMind vs. DIR Implementation
37
+ Decision Intelligence Runtime starts from a core question:
36
38
 
37
- While Google's *Intelligent AI Delegation* (2026) outlines the *theoretical* requirements for safe agentic systems, **DIR provides the open-source architectural implementation available today.**
39
+ > *What are the minimal conditions that must simultaneously hold before an autonomous decision is allowed to execute?*
38
40
 
39
- | Requirement (Google DeepMind) | DIR Implementation (This Repo) | Status |
40
- | :--- | :--- | :--- |
41
- | **Verifiable Task Completion** | **Topology C (DL+PCI)** <br> *Cryptographic Proof-Carrying Intents* | ✅ Implemented |
42
- | **Transfer of Authority** | **Responsibility Contracts** <br> *Machine-readable scope definitions* | ✅ Implemented |
43
- | **Permission Handling** | **Kernel Space (DIM)** <br> *Deterministic policy enforcement* | ✅ Implemented |
44
- | **Structural Transparency** | **DecisionFlow ID (DFID)** <br> *End-to-end distributed tracing* | ✅ Implemented |
41
+ DIR proposes that many of these discussions can be viewed through a common architectural lens called the **Legal Decision State (LDS)**.
45
42
 
43
+ ### The Core Philosophy: Legal Decision State (LDS)
46
44
 
47
- **[Read the full framework comparison: Google DeepMind vs. DIR/ROA](./docs/00-introduction/Intelligent_Delegation_Framework_Mapping.md)**
45
+ DIR is built on the formal premise that an AI agent cannot be trusted to maintain system integrity probabilistically. Instead, the runtime ensures that the system never enters an **Illegal Decision State**.
48
46
 
49
- ---
47
+ A decision is considered execution-safe—and allowed to pass through the runtime—only when five independent dimensions are simultaneously satisfied. We call this the **Legal Decision State (LDS)**:
50
48
 
51
- ## Quick Start
49
+ $$LDS = C \wedge A \wedge I \wedge E \wedge T$$
52
50
 
53
- The fastest way to see the DIR architecture in action:
51
+ ![Legal Decision State Invariants](./assets/images/lds-octagon.png)
54
52
 
55
- ```bash
56
- pip install -e .
57
- python samples/00_quick_start/run.py
58
- ```
53
+ If any of these components is false ($\neg C \vee \neg A \vee \neg I \vee \neg E \vee \neg T$), the decision is structurally illegal and must be aborted. Every component in the DIR ecosystem exists exclusively to protect one of these invariants:
59
54
 
60
- This sample demonstrates protection against catastrophic actions (e.g. parsing error turning 15.5 ETH into 15,500 ETH) and prompt injection in external data. High-level overview of the full architecture. See [samples/00_quick_start](samples/00_quick_start/README.md).
55
+ - **Context (C):** Protected by the **Context Store** & **Context-as-Code (CaC)**. Ensures the agent is not acting on stale, hallucinated, or mission-drifted data.
56
+ - **Authority (A):** Protected by **Responsibility-Oriented Agents (ROA)**. Ensures the agent's proposed action does not exceed its explicitly registered contractual limits.
57
+ - **Intent (I):** Protected by **SDS Grammars** & **DIM Schema Validation**. Ensures the action is syntactically valid and structurally executable.
58
+ - **Evidence (E):** Protected by the **Evidence Governance Layer**. Detects "Compliant Lies" by ensuring the action is backed by deterministically reproducible reasoning.
59
+ - **Time (T):** Protected by **JIT State Verification** & **Drift Envelopes**. Prevents Time-of-Check to Time-of-Use (TOCTOU) races by ensuring reality hasn't shifted between LLM reasoning and API execution.
61
60
 
62
- ---
61
+ *The Decision Integrity Module (DIM) is the deterministic gatekeeper that mathematically enforces this equation before any side effect occurs.*
63
62
 
64
- ## Start Here
63
+ Rather than embedding these guarantees inside prompts or increasingly capable language models, DIR externalizes them into deterministic runtime infrastructure.
65
64
 
66
- If you are new to DIR/ROA, begin with the introduction article. It explains the core motivation ("Day Two" failures in production systems), the Kernel Space vs. User Space architectural boundary, and why traditional agentic loops are insufficient for high-stakes environments.
65
+ The goal is not to make language models perfectly intelligent.
67
66
 
68
- **[Read: Beyond Prompt Engineering - Building a Deterministic Runtime for Responsible AI Agents](./docs/00-introduction/DIR-introduction.md)**
67
+ The goal is to make imperfect language models economically and operationally safe to deploy.
69
68
 
70
69
  ## Why use DIR today?
71
70
 
@@ -79,6 +78,8 @@ Big Tech providers are beginning to theorize about "Agent Runtimes" as proprieta
79
78
 
80
79
  ## Core Concepts
81
80
 
81
+ If you are new to DIR/ROA, begin with the **[Introduction Article](./docs/00-introduction/DIR-introduction.md)** to understand the "Day Two" failures in production systems, the Kernel Space vs. User Space architectural boundary, and why traditional agentic loops are insufficient for high-stakes environments. Then, explore the core pillars below:
82
+
82
83
  ### 1. Responsibility-Oriented Agents (ROA)
83
84
  *Current Status: Published*
84
85
 
@@ -121,6 +122,12 @@ An architectural defense against "Day Three" problems, where an agent's individu
121
122
 
122
123
  **[Read Governance & Agent Drift](./docs/04-governance/DIR_Governance.md)**
123
124
 
125
+ ### 5. Machine-Optimized Specification
126
+
127
+ **[DIR-minified.md](./docs/07-dir-minified/DIR-minified.md)** is a **single-file, machine-optimized** version of the framework specification. It is intended **for use as context** by LLMs and code-generation agents (e.g. Cursor, Claude, Devin), not as primary reading for humans. If you are feeding this repo to an AI to implement or extend DIR, attach this file as the main spec; the human-oriented docs remain the narrative and tutorial layer.
128
+
129
+ For short answers to common engineering questions, see the **[FAQ](./FAQ.md)**.
130
+
124
131
  ---
125
132
 
126
133
  # Getting Started
@@ -132,39 +139,58 @@ An architectural defense against "Day Three" problems, where an agent's individu
132
139
 
133
140
  ## Installation
134
141
 
135
- 1. Clone the repository.
136
- 2. Install the package in editable mode:
142
+ Install the published package:
137
143
 
138
144
  ```bash
145
+ pip install dir-core
146
+ ```
147
+
148
+ Or clone this repository if you want to run the samples or work with the source code:
149
+
150
+ ```bash
151
+ git clone https://github.com/huka81/decision-intelligence-runtime.git
152
+ cd decision-intelligence-runtime
139
153
  pip install -e .
140
154
  ```
155
+
141
156
  *This installs the `dir_core` package (source in `src/dir_core`), making it available to all sample implementations.*
142
157
 
158
+ ## Quick Start
159
+
160
+ From the cloned repository, run the Quick Start sample to see the DIR architecture in action:
161
+
162
+ ```bash
163
+ python samples/00_quick_start/run.py
164
+ ```
165
+
166
+ This sample demonstrates protection against catastrophic actions (e.g. parsing error turning 15.5 ETH into 15,500 ETH) and prompt injection in external data. It gives a high-level overview of the full architecture. See [samples/00_quick_start](samples/00_quick_start/README.md).
167
+
143
168
  ## Repository Structure
144
169
 
145
170
  ```text
146
171
  decision-intelligence-runtime/
147
- ├── README.md
148
- ├── FAQ.md # Frequently asked questions (architecture, adoption, compliance)
149
- ├── pyproject.toml # pip install -e . installs dir_core (incl. dir_core.utils for samples)
150
- ├── requirements.txt # Shared dependencies
151
- ├── src/
152
- │ └── dir_core/ # Core DIR/ROA components (per docs spec)
153
- │ # DFID, EventBus, DIM, Context Store, models, arbitration, PCI, etc.
154
- │ └── utils/ # Supporting utilities for samples
155
- │ # logging_utils, config_loader, llm_client (synthetic market: samples/31_finance_trading/mocks/)
156
- ├── samples/ # Reference implementations (01–11 mechanics, 31+ use cases)
157
- │ ├── README.md # Sample catalog and run instructions
158
- │ ├── 00_quick_start/ … 08_custom_repo_psql/ … 11_topology_c_dl_pci/
159
- │ ├── 31_finance_trading/ … 35_crewai_roa_wrapper/ … 36_drift_optimization_discount/ … 37_drift_semantic_refund/ … 38_drift_environmental_bidding/
160
- │ └── 88_meta_context_engineering/ # Meta-sample: System Prompt Toolkit
161
172
  ├── docs/ # Architectural documentation
162
173
  │ ├── 00-introduction/ # DIR intro, framework mapping
163
174
  │ ├── 01-roa-manifesto/
164
175
  │ ├── 02-decision-runtime/
165
176
  │ ├── 03-topologies/
177
+ │ ├── 04-governance/
166
178
  │ ├── 07-dir-minified/ # Machine-optimized single-file spec (DIR-minified.md)
167
179
  │ └── 08-conclusion/ # Context as Code concept
180
+ ├── src/
181
+ │ └── dir_core/ # Core DIR/ROA components (per docs spec)
182
+ │ │ # DFID, EventBus, DIM, Context Store, models, arbitration, PCI, etc.
183
+ │ └── utils/ # Supporting utilities for samples
184
+ │ # logging_utils, config_loader, llm_client (synthetic market: samples/31_finance_trading/mocks/)
185
+ ├── samples/ # Reference implementations (01–11 mechanics, 31+ use cases)
186
+ │ ├── README.md # Sample catalog and run instructions
187
+ │ ├── 00_quick_start/ … 08_custom_repo_psql/ … 11_topology_c_dl_pci/
188
+ │ ├── 31_finance_trading/ … 38_drift_environmental_bidding/
189
+ │ └── 88_meta_context_engineering/ # Meta-sample: System Prompt Toolkit
190
+ ├── README.md
191
+ ├── FAQ.md # Frequently asked questions (architecture, adoption, compliance)
192
+ ├── pyproject.toml # pip install -e . installs dir_core (incl. dir_core.utils for samples)
193
+ ├── requirements.txt # Shared dependencies
168
194
  └── assets/ # Images, diagrams
169
195
  ```
170
196
 
@@ -178,24 +204,6 @@ Execute any sample from the repository root: `python samples/<folder>/run.py`
178
204
 
179
205
  **[View the full catalog of Samples & Reference Implementations](samples/README.md)**
180
206
 
181
- ---
182
- ## Documentation
183
-
184
- - **[DIR Introduction](./docs/00-introduction/DIR-introduction.md)** - Architectural motivation and Kernel Space / User Space boundary.
185
- - **[ROA Manifesto](./docs/01-roa-manifesto/ROA_Manifesto.md)** - Responsibility-oriented agent design.
186
- - **[DIR Architecture](./docs/02-decision-runtime/DIR_Architectural_Pattern.md)** - Runtime components and invariants.
187
- - **[Topologies](./docs/03-topologies/DIR_Topologies.md)** - Operational modes (EOAM, SDS, DL+PCI).
188
- - **[Governance & Drift](./docs/04-governance/DIR_Governance.md)** - Managing aggregate safety and business health over time.
189
- - **[Context as Code](./docs/08-conclusion/Context_as_Code.md)** - Treating documentation as a system prompt.
190
- - **[FAQ](./FAQ.md)** - Answers to common engineering questions about DIR/ROA: "Day Two" failure modes, Kernel vs User Space, comparison with orchestration frameworks, JIT state verification, idempotency, compliance (e.g. EU AI Act and Proof-Carrying Intents), and incremental adoption.
191
-
192
-
193
- ### Machine-optimized specification: DIR-minified.md
194
-
195
- **[DIR-minified](./docs/07-dir-minified/DIR-minified.md)** is a **single-file, machine-optimized** version of the framework specification. It is intended **for use as context** by LLMs and code-generation agents (e.g. Cursor, Claude, Devin), not as primary reading for humans.
196
-
197
- The document is intentionally **radical** (dense, exhaustive) and **redundant** (repeats key constraints and examples in multiple places) so that a model loading it as context has a complete, self-contained picture of ROA, DIR, and the three topologies without chasing links. If you are feeding this repo to an AI to implement or extend DIR, attach **DIR-minified.md** as the main spec; the human-oriented docs in `docs/` remain the narrative and tutorial layer.
198
-
199
207
  ---
200
208
 
201
209
  ## License
@@ -5,11 +5,11 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  # dir-core keeps pip install name and import path aligned (frictionless adoption).
7
7
  name = "dir-core"
8
- version = "0.2.0"
8
+ version = "0.3.0"
9
9
  description = "Decision Intelligence Runtime - deterministic Kernel Space for agentic AI"
10
10
  readme = "README.md"
11
11
  license = "Apache-2.0"
12
- authors = [{ name = "Artur Huk" }]
12
+ authors = [{ name = "Artur Huk", email = "artur.huk.it@gmail.com" }]
13
13
  # Per LS-1 rule in DIR-minified.md
14
14
  requires-python = ">=3.12"
15
15
  keywords = ["ai", "agents", "decision-intelligence", "roa", "dir", "llm", "governance"]
@@ -0,0 +1,70 @@
1
+ """
2
+ Decision Ledger (Topology C §5.4) — append-only, verified decisions only.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import logging
8
+ from typing import Any, Dict, List, Optional
9
+
10
+ from .models import ProofCarryingIntent
11
+ from .storage.base import DecisionLedgerStorage
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+
16
+ def _entry_from_pci(pci: ProofCarryingIntent) -> Dict[str, Any]:
17
+ return {
18
+ "dfid": pci.dfid,
19
+ "intent_payload": pci.intent_payload,
20
+ "context_ref": pci.context_ref,
21
+ "evidence_hash": pci.evidence_hash,
22
+ "signature": pci.signature or "",
23
+ }
24
+
25
+
26
+ class DecisionLedger:
27
+ """
28
+ Append-only store for verified PCIs only.
29
+
30
+ Unverified decisions must never become binding. The Ledger is the source
31
+ of truth; only DIM-approved entries are appended. This prevents "Day Two"
32
+ failures where hallucinated or forged agent outputs become operational.
33
+
34
+ When *storage* is provided, entries are persisted via
35
+ :class:`~dir_core.storage.base.DecisionLedgerStorage` (e.g.
36
+ ``decision_ledger_entries`` in SQLite). Otherwise entries live in process
37
+ memory only.
38
+ """
39
+
40
+ def __init__(self, storage: Optional[DecisionLedgerStorage] = None) -> None:
41
+ self._storage = storage
42
+ self._memory: List[Dict[str, Any]] = []
43
+
44
+ def append(
45
+ self, pci: ProofCarryingIntent, *, agent_id: str
46
+ ) -> None:
47
+ """Append a verified PCI. Called only by DIM after successful verification."""
48
+ if self._storage is not None:
49
+ self._storage.append(pci, agent_id=agent_id)
50
+ count = len(self._storage.all_entries_chronological())
51
+ else:
52
+ entry = _entry_from_pci(pci)
53
+ self._memory.append(entry)
54
+ count = len(self._memory)
55
+ logger.info(
56
+ "[DFID=%s] Ledger appended entry #%d. Policy Bound.",
57
+ pci.dfid[:8],
58
+ count,
59
+ )
60
+
61
+ def entries(self) -> List[Dict[str, Any]]:
62
+ """Return all ledger entries (read-only copy)."""
63
+ if self._storage is not None:
64
+ return self._storage.all_entries_chronological()
65
+ return list(self._memory)
66
+
67
+ def __len__(self) -> int:
68
+ if self._storage is not None:
69
+ return len(self._storage.all_entries_chronological())
70
+ return len(self._memory)
@@ -35,6 +35,7 @@ from .base import (
35
35
  AuditStore,
36
36
  ContextStorage,
37
37
  DecisionAuditStorage,
38
+ DecisionLedgerStorage,
38
39
  EscalationStorage,
39
40
  IdempotencyStorage,
40
41
  IntentRetryStorage,
@@ -48,6 +49,7 @@ from .memory import (
48
49
  MemoryAgentRegistryStorage,
49
50
  MemoryContextStorage,
50
51
  MemoryDecisionAuditStorage,
52
+ MemoryDecisionLedgerStorage,
51
53
  MemoryEscalationStorage,
52
54
  MemoryIdempotencyStorage,
53
55
  MemoryIntentRetryStorage,
@@ -60,6 +62,7 @@ from .sqlite import (
60
62
  SqliteAgentRegistryStorage,
61
63
  SqliteContextStorage,
62
64
  SqliteDecisionAuditStorage,
65
+ SqliteDecisionLedgerStorage,
63
66
  SqliteEscalationStorage,
64
67
  SqliteIdempotencyStorage,
65
68
  SqliteIntentRetryStorage,
@@ -82,6 +85,7 @@ class StorageBundle:
82
85
  context: ContextStorage
83
86
  idempotency: IdempotencyStorage
84
87
  decision_audit: DecisionAuditStorage
88
+ decision_ledger: DecisionLedgerStorage
85
89
  saga: SagaStorage
86
90
  resource_lock: ResourceLockStorage
87
91
  intent_retry: IntentRetryStorage
@@ -100,6 +104,7 @@ def sqlite_storage(db_path: str) -> StorageBundle:
100
104
  context=SqliteContextStorage(db_path),
101
105
  idempotency=SqliteIdempotencyStorage(db_path),
102
106
  decision_audit=SqliteDecisionAuditStorage(db_path),
107
+ decision_ledger=SqliteDecisionLedgerStorage(db_path),
103
108
  saga=SqliteSagaStorage(db_path),
104
109
  resource_lock=SqliteResourceLockStorage(db_path),
105
110
  intent_retry=SqliteIntentRetryStorage(db_path),
@@ -118,6 +123,7 @@ def memory_storage() -> StorageBundle:
118
123
  context=MemoryContextStorage(),
119
124
  idempotency=MemoryIdempotencyStorage(),
120
125
  decision_audit=MemoryDecisionAuditStorage(),
126
+ decision_ledger=MemoryDecisionLedgerStorage(),
121
127
  saga=MemorySagaStorage(),
122
128
  resource_lock=MemoryResourceLockStorage(),
123
129
  intent_retry=MemoryIntentRetryStorage(),
@@ -132,6 +138,7 @@ __all__ = [
132
138
  "AuditStore",
133
139
  "ContextStorage",
134
140
  "DecisionAuditStorage",
141
+ "DecisionLedgerStorage",
135
142
  "IdempotencyStorage",
136
143
  "SagaStorage",
137
144
  "ResourceLockStorage",
@@ -148,6 +155,7 @@ __all__ = [
148
155
  "SqliteAgentRegistryStorage",
149
156
  "SqliteContextStorage",
150
157
  "SqliteDecisionAuditStorage",
158
+ "SqliteDecisionLedgerStorage",
151
159
  "SqliteIdempotencyStorage",
152
160
  "SqliteSagaStorage",
153
161
  "SqliteResourceLockStorage",
@@ -158,6 +166,7 @@ __all__ = [
158
166
  "MemoryAgentRegistryStorage",
159
167
  "MemoryContextStorage",
160
168
  "MemoryDecisionAuditStorage",
169
+ "MemoryDecisionLedgerStorage",
161
170
  "MemoryIdempotencyStorage",
162
171
  "MemorySagaStorage",
163
172
  "MemoryResourceLockStorage",