DIDP Compliance Mitigation

Protocol Version: DIDP v2.1
Status: Active
Category: Doctrine


Purpose

This document defines deterministic mitigation and prevention rules for DIDP workflow violations. These rules are:

  • Generic — Not tied to any specific executor or agent system
  • Mechanical — Enforceable without human interpretation
  • Reusable — Applicable to any DIDP-compliant system

Violation Types

TypeMeaning
out_of_iterationWork occurred without an active iteration
out_of_phase_actionWork executed after terminal phase
phase_skipRequired phase was skipped
incomplete_cleanupTemporary or draft artifacts remain

1. Mitigation Actions

1.1 out_of_iteration

Corrective Actions:

  1. Create iteration_state.yaml retroactively with:

    • iteration_id: Generated from date + sequence
    • created: Timestamp of first work artifact
    • phase.name: Set to phase where work was discovered
  2. Attach prior work as retrospective documentation:

    retrospective:
      pre_iteration_work: true
      artifacts_created_before_iteration:
        - <list of files/commits>
      note: "Work performed before iteration created. Non-authoritative until validated."
  3. Log deviation to deviations.log with:

    • Date
    • Identifier: NO-ITER
    • Description of work performed
    • Resolution taken
  4. Continue iteration from current state (do not restart work)


1.2 out_of_phase_action

Corrective Actions:

  1. Identify the terminal phase at which violation occurred

  2. Determine if action was:

    • Substantive (new content, spec changes) → Requires new iteration
    • Mechanical (deployment, cleanup) → May be absorbed with deviation log
  3. If substantive:

    • Abort current state
    • Create new iteration for remaining work
    • Reference prior iteration in handoff_notes
  4. If mechanical:

    • Log deviation
    • Document action in iteration’s outcome section
    • Propose amendment to exit criteria

1.3 phase_skip

Corrective Actions:

  1. Identify skipped phase(s) in the required sequence:

    planning → analysis → spec_lock → implementation → testing → archive → merge → complete
  2. Execute skipped phase retroactively:

    • Create phase artifacts that would have been produced
    • Mark exit criteria as satisfied (or document why N/A)
  3. Block merge until all prior phases complete

  4. Update iteration_state.yaml:

    phase_history:
      - name: <skipped_phase>
        entered: <retroactive_timestamp>
        exit_criteria_met: true
        note: "Executed retroactively after phase_skip deviation"

1.4 incomplete_cleanup

Corrective Actions:

  1. Identify orphaned artifacts:

    • Draft files in pending/, drafts/, or temporary locations
    • Uncommitted changes
    • Stale branch references
  2. For each artifact, determine disposition:

    • Archive: Move to archive/ with timestamp
    • Delete: Remove if no longer needed
    • Promote: If draft should be published, create iteration
  3. Verify cleanup complete before marking iteration complete

  4. Document cleanup actions in iteration outcome:

    outcome:
      cleanup_performed:
        - action: deleted
          path: pending/drafts/old-spec.md
        - action: archived
          path: archive/2025-12-26-orphan.md

2. Prevention Gates

2.1 GATE-001: out_of_iteration

Enforcement Phase: Before any work begins (pre-planning)

RequirementLevelDescription
Iteration existsMUSTiteration_state.yaml MUST exist with valid iteration_id before any work
Branch createdMUSTIteration branch MUST be checked out before file modifications
Phase definedMUSTphase.name MUST be set before work proceeds

On Failure:

  • ABORT: No work permitted
  • ACTION: Create iteration first

Exemption (FTL-014):

Trivial work MAY bypass iteration ceremony if ALL conditions are met:

  1. Human explicitly approves BEFORE work begins
  2. No new content pages (specs, docs)
  3. No spec changes
  4. Configuration/tooling only
  5. < 5 files modified

When exemption applies, log to maintenance.log:

[DATE] APPROVED-TRIVIAL | description | human approval note

2.2 GATE-002: out_of_phase_action

Enforcement Phase: All phases (continuous)

RequirementLevelDescription
Terminal phase immutableMUSTphase: complete is terminal; no further work on that iteration
Work matches phaseMUSTActions MUST be permitted by current phase constraints
Deployment before completeSHOULDDeployment SHOULD occur during archive or merge, not after complete

On Failure:

  • BLOCK TRANSITION: Cannot advance to next phase
  • ACTION: Require new iteration for additional work

Phase Immutability:

PhaseMutablePermitted Actions
planningYesScope changes, exploration
analysisYesValidation, clarification
spec_lockYesFinalization only
implementationYesCode, docs per spec
testingYesDefect fixes only
archiveYesCleanup, versioning
mergeYesMerge to target branch
completeNoNone (terminal)

2.3 GATE-003: phase_skip

Enforcement Phase: archive → merge transition

RequirementLevelDescription
Linear progressionMUSTPhases MUST advance in defined order
Exit criteria satisfiedMUSTAll exit criteria for current phase MUST be met before transition
No phase omissionMUSTEvery phase MUST be entered and exited

On Failure:

  • BLOCK MERGE: Cannot merge to target branch
  • ACTION: Execute skipped phase(s) before proceeding

Legal Transitions:

planning ──► analysis ──► spec_lock ──► implementation ──► testing ──► archive ──► merge ──► complete
     │                         │
     ▼                         ▼
 (replan)                  planning
                         (if replan_required)

Back-transitions:

  • ONLY analysis → planning is permitted (when replan_required: true)
  • All other back-transitions are FORBIDDEN

2.4 GATE-004: incomplete_cleanup

Enforcement Phase: archive (before merge)

RequirementLevelDescription
No orphaned draftsMUSTpending/, drafts/ directories MUST be empty or archived
No uncommitted changesMUSTWorking directory MUST be clean
Temporary files removedSHOULDBuild artifacts, cache files SHOULD be excluded
Version source updatedMUSTCanonical version MUST reflect release

On Failure:

  • BLOCK TRANSITION: Cannot advance from archive to merge
  • ACTION: Complete cleanup before proceeding

Cleanup Checklist:

[ ] Draft directories empty (pending/, drafts/)
[ ] No TODO markers in published content
[ ] Version source updated (VERSION, package.json, or tag)
[ ] Changelog entry added (if required)
[ ] Build artifacts excluded from commit
[ ] Working directory clean (git status)

Summary

Violation TypeGate IDEnforcement PhaseOn Failure
out_of_iterationGATE-001pre-planningAbort
out_of_phase_actionGATE-002all phasesBlock transition
phase_skipGATE-003archive → mergeBlock merge
incomplete_cleanupGATE-004archiveBlock transition

Protocol Invariant

These gates are deterministic and mechanically enforceable. Any DIDP-compliant system MUST implement equivalent checks at the specified enforcement phases.