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
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
apply_parameter_amendment(amendment, *, record_audit=True)
Apply a human-gated scalar patch to a runtime-amendable invariant.
Source code in src/dir_core/runtime.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
register_projection(projection, agent_version, *, priority=0)
Register an approved RuntimeContractProjection.
Source code in src/dir_core/runtime.py
70 71 72 73 74 75 76 77 78 79 80 81 82 | |
Decision Integrity Module (DIM)
dir_core.dim
Decision Integrity Module (DIM): schema + RBAC + declarative invariant IR.
DIR §6. Validates PolicyProposal; returns ValidationVerdict with a reason.
validate_proposal(proposal, context, allowed_agents=None, now=None, retry_governor=None, contract=None, custom_validators=None)
Validate a PolicyProposal against schema, RBAC, TTL, contract IR, and custom domain-specific validators.
Source code in src/dir_core/dim.py
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 | |
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, root_dfid=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
|
root_dfid
|
Optional[str]
|
Top-level flow id for |
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 62 63 64 65 66 67 68 | |
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
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
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
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
create(dfid, data, source='context_store')
classmethod
Factory method that generates snapshot_id from content hash.
Source code in src/dir_core/models.py
348 349 350 351 352 353 354 355 | |
ContractParameterAmendment
Bases: BaseModel
Human-gated scalar patch to an existing runtime-amendable invariant.
Source code in src/dir_core/models.py
109 110 111 112 113 114 115 116 117 118 119 120 | |
ContractReleaseRef
Bases: BaseModel
Identity of the approved contract release used by the Runtime.
Source code in src/dir_core/models.py
70 71 72 73 74 75 76 | |
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
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
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
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 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
abort(reason)
Mark flow as aborted.
Source code in src/dir_core/models.py
499 500 501 502 503 504 | |
add_event(event_type, summary, agent_id=None, details=None)
Add an event to the timeline.
Source code in src/dir_core/models.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
complete(summary)
Mark flow as completed.
Source code in src/dir_core/models.py
492 493 494 495 496 497 | |
create_child_flow(child_dfid)
Record creation of a child flow.
Source code in src/dir_core/models.py
506 507 508 509 510 511 512 513 | |
get_timeline_report()
Generate human-readable timeline report.
Source code in src/dir_core/models.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
record_escalation(escalation)
Record an escalation event.
Source code in src/dir_core/models.py
472 473 474 475 476 477 478 479 480 481 | |
record_execution(intent)
Record an execution intent.
Source code in src/dir_core/models.py
483 484 485 486 487 488 489 490 | |
record_explain(result)
Record an Explain stage result.
Source code in src/dir_core/models.py
438 439 440 441 442 443 444 445 446 447 448 449 450 | |
record_policy(policy)
Record a Policy formation.
Source code in src/dir_core/models.py
452 453 454 455 456 457 458 459 460 | |
record_proposal(proposal)
Record a PolicyProposal emission.
Source code in src/dir_core/models.py
462 463 464 465 466 467 468 469 470 | |
set_context(snapshot)
Bind context snapshot to this flow.
Source code in src/dir_core/models.py
429 430 431 432 433 434 435 436 | |
DecisionRecord
Bases: BaseModel
Single decision in agent's trajectory history.
Source code in src/dir_core/models.py
202 203 204 205 206 207 208 209 210 211 | |
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
236 237 238 239 240 241 242 243 244 245 246 247 248 | |
ExecutionIntent
Bases: BaseModel
Validated proposal; only this type is authorized to trigger side effects (DIR §7).
Source code in src/dir_core/models.py
277 278 279 280 281 282 283 | |
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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
FlowEvent
Bases: BaseModel
Single event in a DecisionFlow timeline.
Source code in src/dir_core/models.py
358 359 360 361 362 363 364 365 | |
InvariantSpec
Bases: BaseModel
Declarative transaction invariant evaluated by DIM from Runtime projection IR.
Source code in src/dir_core/models.py
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 | |
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
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
PolicyProposal
Bases: BaseModel
Structured intent from agent; validated by DIM before execution (DIR §5).
Source code in src/dir_core/models.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
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
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 | |
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 | |
RuntimeContractProjection
Bases: BaseModel
Small execution-facing projection of a canonical Responsibility Contract.
The full authoring contract belongs to Build-Time tooling. This projection is the stable subset that Registry, DIM, and governance services consume.
Source code in src/dir_core/models.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
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
184 185 186 187 188 189 190 191 192 193 194 | |
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
93 94 95 96 97 98 99 100 | |
ContractRole
Bases: StrEnum
ROA responsibility role (Manifesto §3.1).
Source code in src/dir_core/data_types.py
33 34 35 36 37 38 | |
DecisionFlowStatus
Bases: StrEnum
High-level status on DecisionFlow aggregate (distinct from lifecycle.FlowStatus).
Source code in src/dir_core/data_types.py
76 77 78 79 80 81 82 | |
DecisionRecordOutcome
Bases: StrEnum
Outcome of a single decision in agent trajectory.
Source code in src/dir_core/data_types.py
41 42 43 44 45 46 47 | |
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 21 22 23 24 25 26 | |
EscalationSeverity
Bases: StrEnum
Severity on EscalationRequest (Manifesto §5.3).
Source code in src/dir_core/data_types.py
50 51 52 53 54 55 56 | |
EventBusBackend
Bases: StrEnum
Pluggable event bus implementation (factory).
Source code in src/dir_core/data_types.py
109 110 111 112 113 114 | |
EventType
Bases: StrEnum
Canonical event types for EOAM (DIR Topologies §2.4).
Source code in src/dir_core/data_types.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
FlowTimelineEventType
Bases: StrEnum
Event type on DecisionFlow.timeline (DIR §5.4).
Source code in src/dir_core/data_types.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
HandshakeRejectionReason
Bases: StrEnum
Handshake failure codes (DIR §2.3).
Source code in src/dir_core/data_types.py
103 104 105 106 | |
HumanDecision
Bases: StrEnum
Human resolution of an escalation (DIR §9).
Source code in src/dir_core/data_types.py
85 86 87 88 89 90 | |
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 | |