State Tracking and Audit Trail
AI-DLC maintains two persistent files that together provide full traceability from intent to production: the state file tracks where you are in the workflow, and the audit trail records every decision, action, and event along the way.
State File (aidlc-state.md)
Each intent has its own state file at aidlc/spaces/<space>/intents/<YYMMDD>-<label>/aidlc-state.md (under the intent's record dir) — the single source of truth for that intent's workflow progress. The engine reads the active intent's state file on every session start to determine what has been completed, what is in progress, and what comes next.
The exact initial description is stored beside it in
project-description.json as one JSON string. aidlc-state.md names that
committed source and keeps only a safe single-line
Project preview, so multiline user input cannot introduce additional state
fields. Pre-2.6.115 records without the source marker continue to use the
existing Project field as their description; a marked new record whose file
is missing or malformed fails source validation instead of silently degrading.
JSON decoding preserves the original description even if Git normalizes the
sidecar's final line ending.
What it contains
| Section | Purpose |
|---|---|
| Project Information | Project description, type (greenfield/brownfield), scope, start date, current phase, active agent |
| Scope Configuration | Stages to execute, stages to skip (with reasons), depth level |
| Workspace State | Project root, detected languages, frameworks, build system |
| Execution Plan Summary | Total stages, completed count, in-progress stage |
| Runtime State | Revision count and optional Construction iteration, Unit ownership, and Unit gate rhythm |
| Stage Progress | Per-stage checkboxes tracking completion status |
| Unit Progress | Team mode only: derived per-Unit Construction stage and gate cells; rewritten by next, never authoritative |
| Current Status | Lifecycle phase, current/next stage, status, last updated timestamp |
| Session Resume Point | Last completed stage, next action, pending artifacts |
Six-state checkboxes
Stage progress uses a six-state checkbox notation:
| Checkbox | Meaning |
|---|---|
[ ] |
Not started |
[-] |
In progress |
[?] |
Awaiting your approval (gate open) |
[R] |
Revising (you rejected the gate, stage is being revised) |
[x] |
Completed |
[S] |
Skipped (scope-excluded, cut via skip, or bypassed via --stage/--phase jump) |
Stages transition through [ ] → [-] → [?] → [x] on the happy path. When you reject at the gate, the stage moves to [R] while it's revised, back to [?] when ready, and finally to [x] on approval. /aidlc --status reads the checkbox and tells you who's blocking — "Awaiting your approval on \<stage>" for [?], "Revising \<stage> (revision N of 3)" for [R].
For the canonical state-machine reference (transition tables, audit-event emitters), see Developer Reference: State Machine.
State transitions
stateDiagram-v2
state "[ ] Not Started" as NotStarted
state "[-] In Progress" as InProgress
state "[?] Awaiting Approval" as Awaiting
state "[R] Revising" as Revising
state "[x] Completed" as Completed
state "[S] Skipped" as Skipped
[*] --> NotStarted
NotStarted --> InProgress : Stage begins
InProgress --> Awaiting : Work done, gate opens
Awaiting --> Completed : You approve
Awaiting --> Revising : You request changes
Revising --> Awaiting : Revision done, re-enter gate
NotStarted --> Skipped : --stage/--phase jump or scope excludes
InProgress --> Skipped : Cut mid-flight
Revising --> Skipped : Abandon after rejection
Completed --> NotStarted : Redo (artifacts deleted)
Normal, revision, skip, redo, and jump flows
- Normal flow:
[ ]->[-]->[?]->[x](stage begins, work completes, gate opens, you approve) - Revision flow:
[?]->[R]->[?]->[x](you reject, stage is revised, gate re-opens, you approve) - Scope skip flow:
[ ]->[S](stage not in scope for this workflow, marked at init) - Redo flow:
[x]or[-]->[ ]->[-](you request redo, artifacts are deleted, stage re-executes) - Jump flow:
[-]at stage A, you request jump to stage B, intervening stages are marked[S]
Audit Trail (audit/)
The audit trail lives in the intent's record dir at aidlc/spaces/<space>/intents/<YYMMDD>-<label>/audit/. It is an append-only event log written as per-clone shards (<host>-<clone>.md): each clone appends only to its own shard, so concurrent appends from sibling worktrees never git-conflict. Readers glob audit/*.md and merge-sort by ISO timestamp to reconstruct the full chronological history of decisions and events.
91-event taxonomy
Events are organized into 22 categories:
| Category | Count | Events |
|---|---|---|
| Workflow Lifecycle | 4 | WORKFLOW_STARTED, WORKFLOW_COMPLETED, WORKFLOW_PARKED, WORKFLOW_UNPARKED |
| Phase Lifecycle | 4 | PHASE_STARTED, PHASE_COMPLETED, PHASE_VERIFIED, PHASE_SKIPPED |
| Stage Lifecycle | 6 | STAGE_STARTED, STAGE_AWAITING_APPROVAL, STAGE_REVISING, STAGE_COMPLETED, STAGE_SKIPPED, STAGE_JUMPED |
| Session | 5 | SESSION_STARTED, SESSION_RESUMED, SESSION_COMPACTED, SESSION_ENDED, HUMAN_TURN (hook-emitted) |
| Initialization | 3 | WORKSPACE_SCAFFOLDED, WORKSPACE_SCANNED, WORKSPACE_INITIALISED |
| Navigation | 7 | SCOPE_CHANGED, SCOPE_DETECTED, DEPTH_CHANGED, TEST_STRATEGY_CHANGED, REVIEW_CLASS_CHANGED, RECOMPOSED, PLUGIN_SELECTION_CHANGED |
| Interaction | 9 | DECISION_RECORDED, GATE_APPROVED, GATE_REJECTED, QUESTION_ANSWERED, SUMMARY_CONFIRMATION_RECORDED, PLAN_APPROVAL_RECORDED, REVIEW_REQUESTED, REVIEW_COMPLETED, PIPELINE_LINK_COMPLETED |
| Unit Configuration and Lifecycle | 7 | UNIT_OWNERSHIP_SET, UNIT_GATE_RHYTHM_SET, UNIT_STARTED, UNIT_PAUSED, UNIT_RESUMED, UNIT_COMPLETED, UNIT_MERGED |
| Artifact | 3 | ARTIFACT_CREATED, ARTIFACT_UPDATED (write-audit-log hook), ARTIFACT_REUSED |
| Subagent | 1 | SUBAGENT_COMPLETED (log-subagent hook) |
| Reviewer Enforcement | 2 | REVIEWER_SCOPE_BLOCKED (reviewer-scope hook), REVIEW_FREEZE_BLOCKED (review-freeze hook) |
| Plan Approval | 1 | PLAN_APPROVAL_BLOCKED (plan-approval-guard hook) |
| Documents | 3 | DOCUMENT_INDEXED, DOCUMENT_UPDATED, DOCUMENT_REMOVED — space-level shard even when intent-scoped |
| Utility | 1 | HEALTH_CHECKED |
| Error/Recovery | 2 | ERROR_LOGGED, RECOVERY_COMPLETED |
| Construction Bolt | 4 | BOLT_STARTED, BOLT_COMPLETED, BOLT_FAILED, AUTONOMY_MODE_SET |
| Worktree | 7 | WORKTREE_CREATED, WORKTREE_MERGED, WORKTREE_DISCARDED, STATE_FORKED, STATE_MERGED, AUDIT_FORKED, AUDIT_MERGED |
| Practices | 4 | PRACTICES_DISCOVERED, PRACTICES_AFFIRMED, PRACTICES_OVERRIDE, PRACTICES_SECTION_EMPTY |
| Merge Dispatch | 3 | MERGE_DISPATCH_INVOKED, MERGE_DISPATCH_RETURNED, MERGE_DISPATCH_FALLBACK |
| Sensors | 5 | SENSOR_FIRED, SENSOR_PASSED, SENSOR_FAILED, SENSOR_BUDGET_OVERRIDE, GUARDRAIL_LOADED |
| Learning Loop | 3 | MEMORY_EMPTY, RULE_LEARNED, SENSOR_PROPOSED |
| Swarm | 7 | SWARM_STARTED, SWARM_UNIT_CONVERGED, SWARM_SOURCE_MERGED, SWARM_UNIT_FAILED, SWARM_BATON_RETURNED, SWARM_COMPLETED, SWARM_DEGRADED |
What gets logged and when
- Every stage start and completion is logged with
STAGE_STARTEDandSTAGE_COMPLETEDevents - Every file write to the intent's record dir (except the
audit/shards themselves) is automatically logged by the write-audit-log hook - Every approval gate decision (approve, request changes, accept-as-is) is logged
- Every question answer you provide is recorded
- Every subagent completion is logged by the log-subagent hook
- Every error and recovery is logged
How to read the audit log
Each entry follows a structured format with these fields:
- Timestamp — ISO 8601 timestamp
- Event - One of the 91 event types
- Details — Event-specific data (stage name, decision, artifact path, etc.)
Entries are appended chronologically. To review the history of a specific stage, search for its STAGE_STARTED and STAGE_COMPLETED entries and everything in between.
Audit event flow
When a stage executes and produces artifacts, the audit trail captures the full sequence:
sequenceDiagram
participant O as Orchestrator
participant E as Engine
participant S as Stage Execution
participant H as Audit Hook
participant A as audit/ shard
O->>E: Request next directive
E->>A: Emit STAGE_STARTED
O->>S: Execute stage work
S->>S: Write artifact to the intent's record dir
S->>H: PostToolUse hook fires
H->>A: Append ARTIFACT_CREATED or ARTIFACT_UPDATED
S->>O: Stage work complete
O->>A: Log approval gate options
O->>O: Present approval gate to user
O->>E: Report approved or rejected
E->>A: Emit gate outcome
E->>A: Emit STAGE_COMPLETED on approval
Source-bound review receipts
Code Generation writes application source outside the intent record, so its
terminal per-unit review receipt binds more than markdown artifacts. The
reviewed unit's strict source-manifest.json lists created, modified, or deleted
source paths; Unit Source Fingerprint binds those claims and manifest bytes.
At completion the engine validates each unit newest-first (a newer reviewed
claim can own an intentional shared-file integration), then compares the union
of fresh claims with the stage-entry source baseline. An uncovered change or a
stale unit blocks all four completion routes and offers that unit's one bounded
stale-receipt recovery.
The workspace-global Source Fingerprint is normally the outer post-review
mutation boundary. One narrow reconciliation makes the documented “revert”
recovery real: after any unclaimed baseline change (addition, modification, or
deletion) is fully reverted, completion can continue
only when the stage baseline is present and valid, every applicable unit still
has a fresh modern binding, and the baseline-to-current delta has zero
unclaimed paths. Ordinary post-review edits, stale or legacy unit evidence, and
any remaining unclaimed path still refuse. Pre-upgrade fieldless receipts or
baselines retain documented migration fail-open behavior; missing or corrupt
modern evidence fails closed. AIDLC_SKIP_SOURCE_FRESHNESS=1 is the
deterministic emergency off-switch and must be present again when consuming a
bypass-marked receipt.
How State and Audit Work Together
The state file and audit trail serve complementary purposes:
| Concern | State File | Audit Trail |
|---|---|---|
| Purpose | Track current position and progress | Record full history of events |
| Read by | Orchestrator (for routing and resume) | Users and auditors (for traceability) |
| Update pattern | Overwritten at each state change | Append-only (never modified) |
| Session resume | Primary source for determining where to continue | Provides the original project description and decision context |
| Git policy | Commit to version control | Commit (per-clone shards under audit/; no merge conflicts) |
The orchestrator uses aidlc-state.md as the durable cursor. Team-owned
Construction additionally derives Unit cells, receipt floors, gates, and merged
rows from the active intent's audit shards; solo routing keeps the state-only
cursor behavior. The audit trail also lets you trace every decision from intent
through to production.
If the state file is corrupted, you can reconstruct it from the audit trail by reviewing STAGE_STARTED and STAGE_COMPLETED events. See Troubleshooting for repair instructions.
Next Steps
- Session Management — How state is used for session resume
- Artifacts Reference — What gets stored in the intent's record dir
- Troubleshooting — State corruption repair
- Glossary — Definitions for state file, audit trail, checkpoint, compaction