Core Framework
Decision Runtime
dir_core.runtime
DecisionRuntime — facade wiring StorageBundle to kernel services (DIR DX).
Single entry point for AgentRegistry, ContextStore, EscalationManager, AuditStore, plus orchestrated DIM validation with optional decision-audit rows.
DecisionRuntime
Wire :class:~dir_core.storage.StorageBundle to kernel services.
Source code in src/dir_core/runtime.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
Decision Integrity Module (DIM)
dir_core.dim
Decision Integrity Module (DIM): schema + RBAC + state consistency.
DIR §6. Validates PolicyProposal; returns ValidationVerdict with a reason (str or DimReasonCode).
Ensures that only authorized agents can execute specific policies within safe bounds.
validate_proposal(proposal, context, allowed_agents=None, now=None, retry_governor=None, contract=None, custom_validators=None)
Validate a PolicyProposal against schema, RBAC, TTL, generic contract boundaries, and custom domain-specific validators.
Source code in src/dir_core/dim.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
Lifecycle
dir_core.lifecycle
DecisionFlow lifecycle: CREATED -> ACTIVE -> VALIDATING -> ACCEPTED|ABORTED|ESCALATED -> EXECUTING -> CLOSED.
DIR §4.3, §9. Persists transitions; resets IntentRetryGovernor on terminal states.
transition(dfid, from_status, to_status, retry_governor=None, db_path=None, *, storage=None)
Record a flow status transition.
On CLOSED/ABORTED, resets the retry governor for dfid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dfid
|
str
|
DecisionFlow identifier. |
required |
from_status
|
FlowStatus
|
Current status. |
required |
to_status
|
FlowStatus
|
Target status. |
required |
retry_governor
|
Optional[IntentRetryGovernor]
|
Optional governor to reset on terminal transitions. |
None
|
db_path
|
Optional[str]
|
SQLite path for persistence (legacy kwarg). When |
None
|
storage
|
Optional[LifecycleStorage]
|
Custom :class: |
None
|
Source code in src/dir_core/lifecycle.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
DFID
dir_core.dfid
DecisionFlow ID (DFID) – correlation identifier for the full decision lifecycle.
See DIR Architectural Pattern §4. All operations (observation, reasoning, validation, execution) are tagged with the same DFID for audit and traceability.
new_dfid()
Generate a new DecisionFlow ID (UUID v4).
Source code in src/dir_core/dfid.py
14 15 16 | |
new_dfid_with_parent(parent_dfid)
Generate a child DFID for hierarchical flows.
Parent is not encoded in the ID; relationship is stored in context/ledger. Parent DFID is logged for traceability.
Source code in src/dir_core/dfid.py
19 20 21 22 23 24 25 26 27 | |
Models
dir_core.models
Shared Pydantic models: ResponsibilityContract, PolicyProposal, ExecutionIntent, etc.
Aligned with ROA Manifesto §3 and DIR Architectural Pattern §5.
Extended with: - ExplainResult (§4.1): Structured reasoning output from context interpretation - Policy (§4.2): Structured recommendation with justification and confidence - SelfCheckResult (§4.3): Introspection result for boundary validation - AgentState (§3.4): Long-lived state with decision trajectory and memory - EscalationRequest (§5.3): Structure for authority escalation
AgentState
Bases: BaseModel
ROA: Long-lived agent state with memory (Manifesto §3.4).
Provides continuity, self-awareness, and trajectory for reasoning.
Source code in src/dir_core/models.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
CompensationAction
Bases: StrEnum
Deterministic Compensation Menu (DIR Topologies §6.4).
Source code in src/dir_core/models.py
29 30 31 32 33 34 35 | |
ContextSnapshot
Bases: BaseModel
Frozen state of relevant context at a point in time (DIR Topologies §2.2).
ContextSnapshotID is the hash binding, ensuring every PolicyProposal is linked to the exact version of the world the agent 'saw'.
Source code in src/dir_core/models.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
create(dfid, data, source='context_store')
classmethod
Factory method that generates snapshot_id from content hash.
Source code in src/dir_core/models.py
272 273 274 275 276 277 278 279 | |
DecisionAtom
Bases: BaseModel
Decision Atom for Topology B (SDS) — snapshot-bound decision.
DIR Topologies §3.1.2: The DecisionAtom MUST include snapshot_id hash-binding so the JIT Validator can verify state has not drifted since the snapshot.
Source code in src/dir_core/models.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
DecisionFlow
Bases: BaseModel
DIR: Container for the entire decision lifecycle (Manifesto §5.4).
A DecisionFlow aggregates: - Initial context (ContextSnapshot) - All policy proposals - Validation results - Escalations - Execution events - Final outcomes
DFID allows auditability, debugging, compliance reporting, causal reasoning, replaying decisions, and clean separation of concurrent decision processes.
Source code in src/dir_core/models.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
abort(reason)
Mark flow as aborted.
Source code in src/dir_core/models.py
423 424 425 426 427 428 | |
add_event(event_type, summary, agent_id=None, details=None)
Add an event to the timeline.
Source code in src/dir_core/models.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
complete(summary)
Mark flow as completed.
Source code in src/dir_core/models.py
416 417 418 419 420 421 | |
create_child_flow(child_dfid)
Record creation of a child flow.
Source code in src/dir_core/models.py
430 431 432 433 434 435 436 437 | |
get_timeline_report()
Generate human-readable timeline report.
Source code in src/dir_core/models.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
record_escalation(escalation)
Record an escalation event.
Source code in src/dir_core/models.py
396 397 398 399 400 401 402 403 404 405 | |
record_execution(intent)
Record an execution intent.
Source code in src/dir_core/models.py
407 408 409 410 411 412 413 414 | |
record_explain(result)
Record an Explain stage result.
Source code in src/dir_core/models.py
362 363 364 365 366 367 368 369 370 371 372 373 374 | |
record_policy(policy)
Record a Policy formation.
Source code in src/dir_core/models.py
376 377 378 379 380 381 382 383 384 | |
record_proposal(proposal)
Record a PolicyProposal emission.
Source code in src/dir_core/models.py
386 387 388 389 390 391 392 393 394 | |
set_context(snapshot)
Bind context snapshot to this flow.
Source code in src/dir_core/models.py
353 354 355 356 357 358 359 360 | |
DecisionRecord
Bases: BaseModel
Single decision in agent's trajectory history.
Source code in src/dir_core/models.py
126 127 128 129 130 131 132 133 134 135 | |
EscalationRequest
Bases: BaseModel
ROA: Request for escalation to higher-level agent (Manifesto §5.3).
Escalation is not failure - it's essential for bounded responsibility.
Source code in src/dir_core/models.py
160 161 162 163 164 165 166 167 168 169 170 171 172 | |
ExecutionIntent
Bases: BaseModel
Validated proposal; only this type is authorized to trigger side effects (DIR §7).
Source code in src/dir_core/models.py
201 202 203 204 205 206 207 | |
ExplainResult
Bases: BaseModel
ROA: Output of Explain stage - context interpretation (Manifesto §4.1).
Answers: 'What is happening, and why does it matter for my mission?'
Source code in src/dir_core/models.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
FlowEvent
Bases: BaseModel
Single event in a DecisionFlow timeline.
Source code in src/dir_core/models.py
282 283 284 285 286 287 288 289 | |
Policy
Bases: BaseModel
ROA: Structured recommendation from Policy stage (Manifesto §4.2).
A Policy is NOT an action - it's an interpretable recommendation with justification.
Source code in src/dir_core/models.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
PolicyProposal
Bases: BaseModel
Structured intent from agent; validated by DIM before execution (DIR §5).
Source code in src/dir_core/models.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
ProofCarryingIntent
Bases: BaseModel
Proof-Carrying Intent (PCI) for Topology C (DL+PCI).
The agent submits this to the DIM. The evidence_hash is a CLAIM; the DIM independently recalculates it using authoritative Context and Contract. Mismatch = reject (Zero Trust).
intent_payload: Domain-specific proposal as dict for flexibility. Sample 33 uses policy_proposal.model_dump(); DIM uses PolicyProposal.model_validate().
Source code in src/dir_core/models.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
ResponsibilityContract
Bases: BaseModel
ROA: scope, authority, mission, escalation (Manifesto §3.1).
Source code in src/dir_core/models.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
SelfCheckResult
Bases: BaseModel
ROA: Result of agent self-check before emitting proposal (Manifesto §4.3).
Self-Check is a cost-optimization heuristic - it has no security value. Catches obvious issues before reaching the Runtime.
Source code in src/dir_core/models.py
108 109 110 111 112 113 114 115 116 117 118 | |
Data Types
dir_core.data_types
Shared data types: validation verdicts, DIM reasons, models, registry, event bus.
AgentRegistryStatus
Bases: StrEnum
Agent row status in registry storage.
Source code in src/dir_core/data_types.py
87 88 89 90 | |
ContractRole
Bases: StrEnum
ROA responsibility role (Manifesto §3.1).
Source code in src/dir_core/data_types.py
27 28 29 30 31 32 | |
DecisionFlowStatus
Bases: StrEnum
High-level status on DecisionFlow aggregate (distinct from lifecycle.FlowStatus).
Source code in src/dir_core/data_types.py
70 71 72 73 74 75 76 | |
DecisionRecordOutcome
Bases: StrEnum
Outcome of a single decision in agent trajectory.
Source code in src/dir_core/data_types.py
35 36 37 38 39 40 41 | |
DimReasonCode
Bases: StrEnum
Stable machine-readable DIM reasons (subset; dynamic detail remains plain str).
Source code in src/dir_core/data_types.py
15 16 17 18 19 20 | |
EscalationSeverity
Bases: StrEnum
Severity on EscalationRequest (Manifesto §5.3).
Source code in src/dir_core/data_types.py
44 45 46 47 48 49 50 | |
EventBusBackend
Bases: StrEnum
Pluggable event bus implementation (factory).
Source code in src/dir_core/data_types.py
99 100 101 102 103 104 | |
EventType
Bases: StrEnum
Canonical event types for EOAM (DIR Topologies §2.4).
Source code in src/dir_core/data_types.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
FlowTimelineEventType
Bases: StrEnum
Event type on DecisionFlow.timeline (DIR §5.4).
Source code in src/dir_core/data_types.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
HandshakeRejectionReason
Bases: StrEnum
Handshake failure codes (DIR §2.3).
Source code in src/dir_core/data_types.py
93 94 95 96 | |
HumanDecision
Bases: StrEnum
Human resolution of an escalation (DIR §9).
Source code in src/dir_core/data_types.py
79 80 81 82 83 84 | |
ValidationVerdict
Bases: StrEnum
Outcome of deterministic validation (DIM, JIT, domain gates).
Source code in src/dir_core/data_types.py
7 8 9 10 11 12 | |