Skip to main content

Protocol Enforcement Specification

Version: 1.0.0 Status: ACTIVE Created: 2026-01-28 Author: Protocol Specification Agent (T2688)

RFC 2119 Conformance

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Part 1: Preamble

1.1 Purpose

This specification defines the dual-layer enforcement architecture for CLEO protocols: pre-commit hooks (fast feedback) and runtime validation (comprehensive coverage). It addresses the protocol compliance gap identified in Wave 0 research (22% average enforcement across 7 protocols, 100 total requirements).

1.2 Authority

This specification is AUTHORITATIVE for:
  • Enforcement architecture (ENFC-001 to ENFC-010)
  • Validation function signatures (VFUNC-*)
  • Protocol violation exit codes (60-67)
  • Bypass policies and audit trails (BYPS-*)
  • Testing requirements for enforcement (TEST-*)

Part 2: Enforcement Architecture (ENFC-*)

2.1 Dual-Layer Design

IDRequirementRationale
ENFC-001Protocol enforcement MUST use both pre-commit hooks AND runtime validationLayered defense
ENFC-002Enforcement layers MUST share validation logic via lib/protocol-validation.shSingle source of truth
ENFC-003Pre-commit hooks MUST be bypassable via --no-verify flagEmergency escape hatch
ENFC-004Runtime validation MUST be non-bypassable for critical requirementsSafety net
ENFC-007Protocol violations MUST use exit codes 60-67Distinguishable from system errors

2.2 Architecture Diagram

┌─────────────────────────────────────────────────────────────────┐
│                         ENFORCEMENT LAYERS                        │
└─────────────────────────────────────────────────────────────────┘

         ┌──────────────────────┴──────────────────────┐
         │                                             │
         ▼                                             ▼
┌─────────────────────┐                     ┌─────────────────────┐
│   PRE-COMMIT HOOKS  │                     │  RUNTIME VALIDATION │
│   (Fast Feedback)   │                     │  (Comprehensive)    │
├─────────────────────┤                     ├─────────────────────┤
│ • commit-msg        │                     │ • cleo complete     │
│ • pre-commit        │                     │ • scripts/*.sh CLI  │
│ • Bypassable        │                     │ • Non-bypassable    │
└──────────┬──────────┘                     └──────────┬──────────┘
           │                                           │
           └──────────────┬────────────────────────────┘


           ┌───────────────────────────────┐
           │   lib/protocol-validation.sh  │
           │   (Shared Validation Logic)   │
           └───────────────────────────────┘

Part 3: Protocol-Specific Exit Codes

Exit CodeProtocolDescriptionRetryable
60research.mdResearch protocol violationNo
61consensus.mdConsensus protocol violationYes
62specification.mdSpecification protocol violationNo
63decomposition.mdDecomposition protocol violationNo
64implementation.mdImplementation protocol violationNo
65contribution.mdContribution protocol violationNo
66release.mdRelease protocol violationYes
67(reserved)Future protocol additionsTBD
Rationale: Exit codes 60-67 distinct from:
  • 1-22: System/operational errors
  • 100+: Special status codes

Part 4: Protocol Validation Requirements

4.1 Research Protocol Validation

RequirementCheckSeverity
RSCH-001No code changes detectederror
RSCH-006Key findings count between 3-7error
RSCH-007agent_type: "research" in manifesterror

4.2 Implementation Protocol Validation

RequirementCheckSeverity
IMPL-003Provenance tags @task T#### presenterror
IMPL-004Tests passerror
IMPL-007agent_type: "implementation" in manifesterror

4.3 Release Protocol Validation

RequirementCheckSeverity
RLSE-001Version follows semvererror
RLSE-002Changelog entry existserror
RLSE-003All tests passerror

Part 5: Bypass Policy (BYPS-*)

5.1 Bypass Mechanisms

IDRequirementUse Case
BYPS-001Pre-commit hooks MUST be bypassable via --no-verifyEmergency hotfixes
BYPS-002Runtime validation MUST NOT be bypassable for MUST requirementsSafety net
BYPS-003Bypass usage MUST be logged to .cleo/bypass-log.jsonAudit trail

5.2 Bypass Log Format

{
  "timestamp": "2026-01-28T08:45:00Z",
  "commit": "abc123def456",
  "operation": "commit",
  "hook": "commit-msg",
  "user": "keaton",
  "justification": "emergency",
  "violations": [
    {"requirement": "IMPL-003", "severity": "error", "message": "Missing @task tag"}
  ]
}

Part 6: Success Metrics

Baseline (Wave 0):
  • Average enforcement: 22%
  • Orphaned code: 3250 lines
Target (Post-Wave 3):
  • Average enforcement: 40%
  • Orphaned code: 0 lines
Target (Long-term):
  • Average enforcement: 70%
  • Full hook + runtime integration

References