dir-core 0.2.0__tar.gz → 0.4.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 (78) hide show
  1. {dir_core-0.2.0 → dir_core-0.4.0}/PKG-INFO +80 -64
  2. {dir_core-0.2.0 → dir_core-0.4.0}/README.md +72 -62
  3. {dir_core-0.2.0 → dir_core-0.4.0}/pyproject.toml +4 -3
  4. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/__init__.py +16 -1
  5. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/agent_registry.py +91 -0
  6. dir_core-0.4.0/src/dir_core/amendments.py +137 -0
  7. dir_core-0.4.0/src/dir_core/contract_projection.py +188 -0
  8. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/data_types.py +10 -0
  9. dir_core-0.4.0/src/dir_core/dim.py +163 -0
  10. dir_core-0.4.0/src/dir_core/invariant_compile.py +194 -0
  11. dir_core-0.4.0/src/dir_core/invariants.py +202 -0
  12. dir_core-0.4.0/src/dir_core/ledger.py +70 -0
  13. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/models.py +77 -2
  14. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/runtime.py +73 -4
  15. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/storage/__init__.py +9 -0
  16. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/storage/base.py +43 -11
  17. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/storage/memory.py +52 -0
  18. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/storage/schema.sql +35 -0
  19. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/storage/sqlite.py +93 -0
  20. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/utils/__init__.py +12 -3
  21. dir_core-0.4.0/src/dir_core/utils/logging_utils.py +78 -0
  22. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core.egg-info/PKG-INFO +80 -64
  23. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core.egg-info/SOURCES.txt +16 -0
  24. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core.egg-info/requires.txt +7 -0
  25. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_agent_registry.py +25 -0
  26. dir_core-0.4.0/tests/test_contract_env.py +111 -0
  27. dir_core-0.4.0/tests/test_contract_studio.py +325 -0
  28. dir_core-0.4.0/tests/test_contract_tool.py +445 -0
  29. dir_core-0.4.0/tests/test_decision_ledger_storage.py +73 -0
  30. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_dim_ttl.py +49 -3
  31. dir_core-0.4.0/tests/test_governance_context.py +49 -0
  32. dir_core-0.4.0/tests/test_governance_validation.py +132 -0
  33. dir_core-0.4.0/tests/test_insurance_agent.py +33 -0
  34. dir_core-0.4.0/tests/test_insurance_invariants.py +127 -0
  35. dir_core-0.4.0/tests/test_insurance_report.py +157 -0
  36. dir_core-0.4.0/tests/test_invariants.py +205 -0
  37. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_ledger.py +26 -6
  38. dir_core-0.4.0/tests/test_llm_json_parse.py +31 -0
  39. dir_core-0.4.0/tests/test_logging_utils.py +49 -0
  40. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_pg_repo.py +19 -4
  41. dir_core-0.4.0/tests/test_runtime.py +226 -0
  42. dir_core-0.2.0/src/dir_core/dim.py +0 -112
  43. dir_core-0.2.0/src/dir_core/ledger.py +0 -44
  44. dir_core-0.2.0/src/dir_core/utils/logging_utils.py +0 -27
  45. dir_core-0.2.0/tests/test_runtime.py +0 -85
  46. {dir_core-0.2.0 → dir_core-0.4.0}/LICENSE +0 -0
  47. {dir_core-0.2.0 → dir_core-0.4.0}/setup.cfg +0 -0
  48. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/arbitration.py +0 -0
  49. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/context_store.py +0 -0
  50. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/dfid.py +0 -0
  51. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/escalation.py +0 -0
  52. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/event_bus.py +0 -0
  53. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/idempotency.py +0 -0
  54. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/intent_retry.py +0 -0
  55. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/jit.py +0 -0
  56. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/lifecycle.py +0 -0
  57. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/pci.py +0 -0
  58. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/resource_lock.py +0 -0
  59. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/saga.py +0 -0
  60. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/storage/json_util.py +0 -0
  61. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/utils/llm_client.py +0 -0
  62. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core/wakeup.py +0 -0
  63. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core.egg-info/dependency_links.txt +0 -0
  64. {dir_core-0.2.0 → dir_core-0.4.0}/src/dir_core.egg-info/top_level.txt +0 -0
  65. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_arbitration.py +0 -0
  66. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_context_store.py +0 -0
  67. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_dfid.py +0 -0
  68. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_escalation.py +0 -0
  69. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_event_bus.py +0 -0
  70. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_idempotency.py +0 -0
  71. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_intent_retry.py +0 -0
  72. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_jit.py +0 -0
  73. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_lifecycle.py +0 -0
  74. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_ollama.py +0 -0
  75. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_pci.py +0 -0
  76. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_resource_lock.py +0 -0
  77. {dir_core-0.2.0 → dir_core-0.4.0}/tests/test_saga.py +0 -0
  78. {dir_core-0.2.0 → dir_core-0.4.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.4.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
@@ -33,6 +33,12 @@ Provides-Extra: samples
33
33
  Requires-Dist: markdown>=3.5; extra == "samples"
34
34
  Requires-Dist: httpx; extra == "samples"
35
35
  Requires-Dist: plotly; extra == "samples"
36
+ Requires-Dist: google-genai>=1.0.0; extra == "samples"
37
+ Provides-Extra: studio
38
+ Requires-Dist: fastapi>=0.110; extra == "studio"
39
+ Requires-Dist: uvicorn[standard]>=0.27; extra == "studio"
40
+ Requires-Dist: z3-solver>=4.12; extra == "studio"
41
+ Requires-Dist: python-dotenv>=1.0; extra == "studio"
36
42
  Provides-Extra: dev
37
43
  Requires-Dist: pytest>=7; extra == "dev"
38
44
  Requires-Dist: pytest-cov>=4; extra == "dev"
@@ -62,52 +68,53 @@ This repository contains the architectural concepts, formal specifications, and
62
68
 
63
69
  ---
64
70
 
65
- ## Architectural Convergence & Validation
71
+ ## Why Another Agent Runtime?
66
72
 
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.
73
+ The current discussion around Agentic AI is rapidly converging on a common observation: production systems require governance beyond prompt engineering.
68
74
 
69
- The independent convergence is notable:
75
+ Different communities describe different aspects of the problem:
70
76
 
71
- * **Google's "Responsibility Transfer"** ≈ **ROA Responsibility Contracts**
72
- * **Google's "Auditability"** ≈ **DecisionFlow ID (DFID)**
73
- * **Google's "Permission Handling"** ≈ **Decision Integrity Module (DIM)**
77
+ - **Principal Drift** emphasizes authority, delegation, and accountability.
78
+ - **Agent Experience (AX)** focuses on exposing the right context and capabilities to autonomous systems.
79
+ - **Enterprise AI Governance** emphasizes policy enforcement, auditability, and human oversight.
80
+ - **Evaluation frameworks** measure reliability after deployment.
81
+ - **Workflow and orchestration platforms** focus on execution and coordination.
74
82
 
75
- This alignment reinforces that these patterns are not vendor-specific abstractions-they are architectural necessities for production-grade agentic systems.
83
+ 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
84
 
77
- ### Industry Validation: Google DeepMind vs. DIR Implementation
85
+ Decision Intelligence Runtime starts from a core question:
78
86
 
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.**
87
+ > *What are the minimal conditions that must simultaneously hold before an autonomous decision is allowed to execute?*
80
88
 
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 |
89
+ DIR proposes that many of these discussions can be viewed through a common architectural lens called the **Legal Decision State (LDS)**.
87
90
 
91
+ ### The Core Philosophy: Legal Decision State (LDS)
88
92
 
89
- **[Read the full framework comparison: Google DeepMind vs. DIR/ROA](./docs/00-introduction/Intelligent_Delegation_Framework_Mapping.md)**
93
+ 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
94
 
91
- ---
95
+ <p align="center">
96
+ <img src="./assets/images/lds-octagon.jpg" alt="Legal Decision State Invariants" width="60%">
97
+ </p>
92
98
 
93
- ## Quick Start
99
+ 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)**:
94
100
 
95
- The fastest way to see the DIR architecture in action:
101
+ $$LDS = A \wedge C \wedge T \wedge I \wedge E$$
96
102
 
97
- ```bash
98
- pip install -e .
99
- python samples/00_quick_start/run.py
100
- ```
103
+ If any of these components is false ($\neg A \vee \neg C \vee \neg T \vee \neg I \vee \neg E$), the decision is structurally illegal and must be aborted. Every component in the DIR ecosystem exists exclusively to protect one of these invariants:
101
104
 
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).
105
+ - **Authority (A):** Protected by **Responsibility-Oriented Agents (ROA)**. Ensures the agent's proposed action does not exceed its explicitly registered contractual limits.
106
+ - **Context (C):** Protected by the **Context Store** & **Context-as-Code (CaC)**. Ensures the agent is not acting on stale, hallucinated, or mission-drifted data.
107
+ - **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.
108
+ - **Intent (I):** Protected by **SDS Grammars** & **DIM Schema Validation**. Ensures the action is syntactically valid and structurally executable.
109
+ - **Evidence (E):** Protected by the **Evidence Governance Layer**. Detects "Compliant Lies" by ensuring the action is backed by deterministically reproducible reasoning.
103
110
 
104
- ---
111
+ *The Decision Integrity Module (DIM) is the deterministic gatekeeper that mathematically enforces this equation before any side effect occurs.*
105
112
 
106
- ## Start Here
113
+ Rather than embedding these guarantees inside prompts or increasingly capable language models, DIR externalizes them into deterministic runtime infrastructure.
107
114
 
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.
115
+ The goal is not to make language models perfectly intelligent.
109
116
 
110
- **[Read: Beyond Prompt Engineering - Building a Deterministic Runtime for Responsible AI Agents](./docs/00-introduction/DIR-introduction.md)**
117
+ The goal is to make imperfect language models economically and operationally safe to deploy.
111
118
 
112
119
  ## Why use DIR today?
113
120
 
@@ -121,6 +128,8 @@ Big Tech providers are beginning to theorize about "Agent Runtimes" as proprieta
121
128
 
122
129
  ## Core Concepts
123
130
 
131
+ 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:
132
+
124
133
  ### 1. Responsibility-Oriented Agents (ROA)
125
134
  *Current Status: Published*
126
135
 
@@ -163,6 +172,12 @@ An architectural defense against "Day Three" problems, where an agent's individu
163
172
 
164
173
  **[Read Governance & Agent Drift](./docs/04-governance/DIR_Governance.md)**
165
174
 
175
+ ### 5. Machine-Optimized Specification
176
+
177
+ **[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.
178
+
179
+ For short answers to common engineering questions, see the **[FAQ](./FAQ.md)**.
180
+
166
181
  ---
167
182
 
168
183
  # Getting Started
@@ -174,39 +189,58 @@ An architectural defense against "Day Three" problems, where an agent's individu
174
189
 
175
190
  ## Installation
176
191
 
177
- 1. Clone the repository.
178
- 2. Install the package in editable mode:
192
+ Install the published package:
179
193
 
180
194
  ```bash
195
+ pip install dir-core
196
+ ```
197
+
198
+ Or clone this repository if you want to run the samples or work with the source code:
199
+
200
+ ```bash
201
+ git clone https://github.com/huka81/decision-intelligence-runtime.git
202
+ cd decision-intelligence-runtime
181
203
  pip install -e .
182
204
  ```
205
+
183
206
  *This installs the `dir_core` package (source in `src/dir_core`), making it available to all sample implementations.*
184
207
 
208
+ ## Quick Start
209
+
210
+ From the cloned repository, run the Quick Start sample to see the DIR architecture in action:
211
+
212
+ ```bash
213
+ python samples/00_quick_start/run.py
214
+ ```
215
+
216
+ 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).
217
+
185
218
  ## Repository Structure
186
219
 
187
220
  ```text
188
221
  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
222
  ├── docs/ # Architectural documentation
204
223
  │ ├── 00-introduction/ # DIR intro, framework mapping
205
224
  │ ├── 01-roa-manifesto/
206
225
  │ ├── 02-decision-runtime/
207
226
  │ ├── 03-topologies/
227
+ │ ├── 04-governance/
208
228
  │ ├── 07-dir-minified/ # Machine-optimized single-file spec (DIR-minified.md)
209
229
  │ └── 08-conclusion/ # Context as Code concept
230
+ ├── src/
231
+ │ └── dir_core/ # Core DIR/ROA components (per docs spec)
232
+ │ │ # DFID, EventBus, DIM, Context Store, models, arbitration, PCI, etc.
233
+ │ └── utils/ # Supporting utilities for samples
234
+ │ # logging_utils, config_loader, llm_client (synthetic market: samples/31_finance_trading/mocks/)
235
+ ├── samples/ # Reference implementations (01–11 mechanics, 31+ use cases)
236
+ │ ├── README.md # Sample catalog and run instructions
237
+ │ ├── 00_quick_start/ … 08_custom_repo_psql/ … 11_topology_c_dl_pci/
238
+ │ ├── 31_finance_trading/ … 38_drift_environmental_bidding/
239
+ │ └── 88_meta_context_engineering/ # Meta-sample: System Prompt Toolkit
240
+ ├── README.md
241
+ ├── FAQ.md # Frequently asked questions (architecture, adoption, compliance)
242
+ ├── pyproject.toml # pip install -e . installs dir_core (incl. dir_core.utils for samples)
243
+ ├── requirements.txt # Shared dependencies
210
244
  └── assets/ # Images, diagrams
211
245
  ```
212
246
 
@@ -220,24 +254,6 @@ Execute any sample from the repository root: `python samples/<folder>/run.py`
220
254
 
221
255
  **[View the full catalog of Samples & Reference Implementations](samples/README.md)**
222
256
 
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
257
  ---
242
258
 
243
259
  ## License
@@ -20,52 +20,53 @@ 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
+ <p align="center">
48
+ <img src="./assets/images/lds-octagon.jpg" alt="Legal Decision State Invariants" width="60%">
49
+ </p>
50
50
 
51
- ## Quick Start
51
+ 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)**:
52
52
 
53
- The fastest way to see the DIR architecture in action:
53
+ $$LDS = A \wedge C \wedge T \wedge I \wedge E$$
54
54
 
55
- ```bash
56
- pip install -e .
57
- python samples/00_quick_start/run.py
58
- ```
55
+ If any of these components is false ($\neg A \vee \neg C \vee \neg T \vee \neg I \vee \neg E$), the decision is structurally illegal and must be aborted. Every component in the DIR ecosystem exists exclusively to protect one of these invariants:
59
56
 
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).
57
+ - **Authority (A):** Protected by **Responsibility-Oriented Agents (ROA)**. Ensures the agent's proposed action does not exceed its explicitly registered contractual limits.
58
+ - **Context (C):** Protected by the **Context Store** & **Context-as-Code (CaC)**. Ensures the agent is not acting on stale, hallucinated, or mission-drifted data.
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.
60
+ - **Intent (I):** Protected by **SDS Grammars** & **DIM Schema Validation**. Ensures the action is syntactically valid and structurally executable.
61
+ - **Evidence (E):** Protected by the **Evidence Governance Layer**. Detects "Compliant Lies" by ensuring the action is backed by deterministically reproducible reasoning.
61
62
 
62
- ---
63
+ *The Decision Integrity Module (DIM) is the deterministic gatekeeper that mathematically enforces this equation before any side effect occurs.*
63
64
 
64
- ## Start Here
65
+ Rather than embedding these guarantees inside prompts or increasingly capable language models, DIR externalizes them into deterministic runtime infrastructure.
65
66
 
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.
67
+ The goal is not to make language models perfectly intelligent.
67
68
 
68
- **[Read: Beyond Prompt Engineering - Building a Deterministic Runtime for Responsible AI Agents](./docs/00-introduction/DIR-introduction.md)**
69
+ The goal is to make imperfect language models economically and operationally safe to deploy.
69
70
 
70
71
  ## Why use DIR today?
71
72
 
@@ -79,6 +80,8 @@ Big Tech providers are beginning to theorize about "Agent Runtimes" as proprieta
79
80
 
80
81
  ## Core Concepts
81
82
 
83
+ 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:
84
+
82
85
  ### 1. Responsibility-Oriented Agents (ROA)
83
86
  *Current Status: Published*
84
87
 
@@ -121,6 +124,12 @@ An architectural defense against "Day Three" problems, where an agent's individu
121
124
 
122
125
  **[Read Governance & Agent Drift](./docs/04-governance/DIR_Governance.md)**
123
126
 
127
+ ### 5. Machine-Optimized Specification
128
+
129
+ **[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.
130
+
131
+ For short answers to common engineering questions, see the **[FAQ](./FAQ.md)**.
132
+
124
133
  ---
125
134
 
126
135
  # Getting Started
@@ -132,39 +141,58 @@ An architectural defense against "Day Three" problems, where an agent's individu
132
141
 
133
142
  ## Installation
134
143
 
135
- 1. Clone the repository.
136
- 2. Install the package in editable mode:
144
+ Install the published package:
137
145
 
138
146
  ```bash
147
+ pip install dir-core
148
+ ```
149
+
150
+ Or clone this repository if you want to run the samples or work with the source code:
151
+
152
+ ```bash
153
+ git clone https://github.com/huka81/decision-intelligence-runtime.git
154
+ cd decision-intelligence-runtime
139
155
  pip install -e .
140
156
  ```
157
+
141
158
  *This installs the `dir_core` package (source in `src/dir_core`), making it available to all sample implementations.*
142
159
 
160
+ ## Quick Start
161
+
162
+ From the cloned repository, run the Quick Start sample to see the DIR architecture in action:
163
+
164
+ ```bash
165
+ python samples/00_quick_start/run.py
166
+ ```
167
+
168
+ 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).
169
+
143
170
  ## Repository Structure
144
171
 
145
172
  ```text
146
173
  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
174
  ├── docs/ # Architectural documentation
162
175
  │ ├── 00-introduction/ # DIR intro, framework mapping
163
176
  │ ├── 01-roa-manifesto/
164
177
  │ ├── 02-decision-runtime/
165
178
  │ ├── 03-topologies/
179
+ │ ├── 04-governance/
166
180
  │ ├── 07-dir-minified/ # Machine-optimized single-file spec (DIR-minified.md)
167
181
  │ └── 08-conclusion/ # Context as Code concept
182
+ ├── src/
183
+ │ └── dir_core/ # Core DIR/ROA components (per docs spec)
184
+ │ │ # DFID, EventBus, DIM, Context Store, models, arbitration, PCI, etc.
185
+ │ └── utils/ # Supporting utilities for samples
186
+ │ # logging_utils, config_loader, llm_client (synthetic market: samples/31_finance_trading/mocks/)
187
+ ├── samples/ # Reference implementations (01–11 mechanics, 31+ use cases)
188
+ │ ├── README.md # Sample catalog and run instructions
189
+ │ ├── 00_quick_start/ … 08_custom_repo_psql/ … 11_topology_c_dl_pci/
190
+ │ ├── 31_finance_trading/ … 38_drift_environmental_bidding/
191
+ │ └── 88_meta_context_engineering/ # Meta-sample: System Prompt Toolkit
192
+ ├── README.md
193
+ ├── FAQ.md # Frequently asked questions (architecture, adoption, compliance)
194
+ ├── pyproject.toml # pip install -e . installs dir_core (incl. dir_core.utils for samples)
195
+ ├── requirements.txt # Shared dependencies
168
196
  └── assets/ # Images, diagrams
169
197
  ```
170
198
 
@@ -178,24 +206,6 @@ Execute any sample from the repository root: `python samples/<folder>/run.py`
178
206
 
179
207
  **[View the full catalog of Samples & Reference Implementations](samples/README.md)**
180
208
 
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
209
  ---
200
210
 
201
211
  ## 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.4.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"]
@@ -35,7 +35,8 @@ postgres = ["psycopg[binary]>=3.1"]
35
35
  asyncpg = ["asyncpg>=0.29"]
36
36
  # Optional: Boxed Intelligence pattern (wrappers)
37
37
  frameworks = ["langchain-core", "crewai"]
38
- samples = ["markdown>=3.5", "httpx", "plotly"]
38
+ samples = ["markdown>=3.5", "httpx", "plotly", "google-genai>=1.0.0"]
39
+ studio = ["fastapi>=0.110", "uvicorn[standard]>=0.27", "z3-solver>=4.12", "python-dotenv>=1.0"]
39
40
  dev = [
40
41
  "pytest>=7",
41
42
  "pytest-cov>=4",
@@ -21,7 +21,7 @@ Custom storage backend example::
21
21
  registry = AgentRegistry(storage=MyPostgresStorage())
22
22
  """
23
23
 
24
- from .agent_registry import AgentRegistry, HandshakeResult
24
+ from .agent_registry import AgentRegistry, AmendmentResult, HandshakeResult
25
25
  from .arbitration import DEFAULT_PRIORITY_MATRIX, select_winner
26
26
  from .dim import validate_proposal
27
27
  from .data_types import (
@@ -80,6 +80,10 @@ from .models import (
80
80
  PolicyProposal,
81
81
  ProofCarryingIntent,
82
82
  CompensationAction,
83
+ ContractReleaseRef,
84
+ RuntimeContractProjection,
85
+ InvariantSpec,
86
+ ContractParameterAmendment,
83
87
  ResponsibilityContract,
84
88
  SelfCheckResult,
85
89
  )
@@ -90,6 +94,9 @@ from .pci import (
90
94
  hash_content,
91
95
  proposal_params_for_hash,
92
96
  )
97
+ from .contract_projection import project_contract
98
+ from .invariants import evaluate_invariants
99
+ from .amendments import validate_amendment_patch
93
100
  from .wakeup import (
94
101
  WakeupPredicate,
95
102
  is_relevant_instrument,
@@ -214,6 +221,14 @@ __all__ = [
214
221
  "verify_drift",
215
222
  # Core models
216
223
  "ResponsibilityContract",
224
+ "ContractReleaseRef",
225
+ "RuntimeContractProjection",
226
+ "InvariantSpec",
227
+ "ContractParameterAmendment",
228
+ "AmendmentResult",
229
+ "project_contract",
230
+ "evaluate_invariants",
231
+ "validate_amendment_patch",
217
232
  "PolicyProposal",
218
233
  "ExecutionIntent",
219
234
  # ROA Lifecycle models
@@ -14,6 +14,9 @@ from dataclasses import dataclass
14
14
  from typing import Any, Dict, List, Optional
15
15
 
16
16
  from .data_types import AgentRegistryStatus, HandshakeRejectionReason
17
+ from .amendments import validate_amendment_patch, resolve_expires_at
18
+ from .contract_projection import project_contract
19
+ from .models import ContractParameterAmendment, RuntimeContractProjection
17
20
  from .storage.base import AgentRegistryStorage
18
21
  from .storage.sqlite import SqliteAgentRegistryStorage
19
22
 
@@ -31,6 +34,15 @@ class HandshakeResult:
31
34
  reason: Optional[str] = None
32
35
 
33
36
 
37
+ @dataclass
38
+ class AmendmentResult:
39
+ """Result of applying a human-gated parameter amendment."""
40
+
41
+ accepted: bool
42
+ reason: Optional[str] = None
43
+ projection: Optional[RuntimeContractProjection] = None
44
+
45
+
34
46
  def _parse_version(v: str) -> Optional[tuple]:
35
47
  """Parse semver string to (major, minor, patch)."""
36
48
  m = SEMVER_RE.match(v.strip())
@@ -121,6 +133,22 @@ class AgentRegistry:
121
133
  logger.info("Handshake: agent_id=%s ver=%s accepted", agent_id, agent_version)
122
134
  return HandshakeResult(accepted=True, session_token=token)
123
135
 
136
+ def register_projection(
137
+ self,
138
+ projection: RuntimeContractProjection,
139
+ agent_version: str,
140
+ priority: int = 0,
141
+ ) -> HandshakeResult:
142
+ """Register an approved RuntimeContractProjection explicitly."""
143
+ if projection.agent_id == "":
144
+ return HandshakeResult(accepted=False, reason="MISSING_AGENT_ID")
145
+ return self.handshake(
146
+ projection.agent_id,
147
+ projection.model_dump(mode="json"),
148
+ agent_version,
149
+ priority=priority,
150
+ )
151
+
124
152
  def get_schema(
125
153
  self, agent_id: str, schema_kind: Optional[str] = None
126
154
  ) -> Optional[dict]:
@@ -164,6 +192,69 @@ class AgentRegistry:
164
192
  rec = self._storage.get_agent(agent_id)
165
193
  return rec["contract"] if rec else None
166
194
 
195
+ def get_agent_projection(
196
+ self, agent_id: str
197
+ ) -> Optional[RuntimeContractProjection]:
198
+ """Retrieve the registered contract as an execution projection."""
199
+ contract = self.get_agent_contract(agent_id)
200
+ return project_contract(contract) if contract is not None else None
201
+
202
+ def apply_parameter_amendment(
203
+ self,
204
+ amendment: ContractParameterAmendment,
205
+ ) -> AmendmentResult:
206
+ """Apply a human-gated scalar patch to a runtime-amendable invariant."""
207
+ projection = self.get_agent_projection(amendment.agent_id)
208
+ if projection is None:
209
+ return AmendmentResult(accepted=False, reason="AGENT_NOT_FOUND")
210
+
211
+ target = next(
212
+ (spec for spec in projection.invariants if spec.id == amendment.invariant_id),
213
+ None,
214
+ )
215
+ if target is None:
216
+ return AmendmentResult(accepted=False, reason="INVARIANT_NOT_FOUND")
217
+
218
+ reject_reason = validate_amendment_patch(target, amendment.patch)
219
+ if reject_reason is not None:
220
+ return AmendmentResult(accepted=False, reason=reject_reason)
221
+
222
+ stored = dict(self.get_agent_contract(amendment.agent_id) or {})
223
+ if not stored.get("invariants"):
224
+ stored = projection.model_dump(mode="json")
225
+
226
+ amendments = list(stored.get("parameter_amendments") or [])
227
+ payload = amendment.model_dump(mode="json")
228
+ payload["expires_at"] = (
229
+ resolve_expires_at(amendment, target).isoformat()
230
+ if resolve_expires_at(amendment, target) is not None
231
+ else None
232
+ )
233
+ amendments.append(payload)
234
+ stored["parameter_amendments"] = amendments
235
+
236
+ rec = self._storage.get_agent(amendment.agent_id)
237
+ agent_version = rec.get("agent_version") if rec else "1.0.0"
238
+ if not agent_version:
239
+ agent_version = "1.0.0"
240
+
241
+ self._storage.upsert_agent(
242
+ agent_id=amendment.agent_id,
243
+ contract_json=json.dumps(stored),
244
+ priority=rec["priority"] if rec else 0,
245
+ status=AgentRegistryStatus.ACTIVE,
246
+ agent_version=agent_version,
247
+ session_token=rec.get("session_token") if rec else None,
248
+ )
249
+ updated = self.get_agent_projection(amendment.agent_id)
250
+ logger.info(
251
+ "Parameter amendment: agent_id=%s invariant_id=%s actor=%s",
252
+ amendment.agent_id,
253
+ amendment.invariant_id,
254
+ amendment.actor_id,
255
+ )
256
+ return AmendmentResult(accepted=True, projection=updated)
257
+
167
258
  def get_agent_manifest(self, agent_id: str) -> Optional[Dict[str, Any]]:
168
259
  """Retrieve agent capability contract. Deprecated: use get_agent_contract."""
169
260
  return self.get_agent_contract(agent_id)