Implementation Protocol
Version: 1.0.0 Type: Conditional Protocol Max Active: 3 protocols (including base)Trigger Conditions
This protocol activates when the task involves:| Trigger | Keywords | Context |
|---|---|---|
| Building | ”implement”, “build”, “create”, “develop” | New functionality |
| Coding | ”code”, “write”, “program” | Software creation |
| Fixing | ”fix”, “bug”, “patch”, “repair” | Issue resolution |
| Enhancement | ”improve”, “enhance”, “optimize” | Existing code |
--protocol implementation flag on task creation.
Requirements (RFC 2119)
MUST
| Requirement | Description |
|---|---|
| IMPL-001 | MUST include tests for new functionality |
| IMPL-002 | MUST follow project code style conventions |
| IMPL-003 | MUST include JSDoc/docstring provenance tags |
| IMPL-004 | MUST verify changes pass existing tests |
| IMPL-005 | MUST document breaking changes |
| IMPL-006 | MUST write implementation summary to manifest |
| IMPL-007 | MUST set agent_type: "implementation" in manifest |
SHOULD
| Requirement | Description |
|---|---|
| IMPL-010 | SHOULD add inline comments for complex logic |
| IMPL-011 | SHOULD refactor duplicated code |
| IMPL-012 | SHOULD update related documentation |
| IMPL-013 | SHOULD consider error handling edge cases |
MAY
| Requirement | Description |
|---|---|
| IMPL-020 | MAY propose architectural improvements |
| IMPL-021 | MAY add performance benchmarks |
| IMPL-022 | MAY suggest follow-up enhancements |
Output Format
Provenance Tags
JavaScript/TypeScript:Test Requirements
| Test Type | When Required | Coverage |
|---|---|---|
| Unit | New functions | MUST cover happy path |
| Integration | New workflows | SHOULD cover end-to-end |
| Edge Case | Complex logic | SHOULD cover boundaries |
| Regression | Bug fixes | MUST reproduce issue |
Code Style Checklist
| Language | Style Guide | Enforcement |
|---|---|---|
| Bash | CLEO style (4 spaces, snake_case) | shellcheck |
| JavaScript | ESLint config | eslint |
| TypeScript | TSConfig strict | tsc --noEmit |
| Python | PEP 8 | flake8, black |
File Output
Manifest Entry
Integration Points
Base Protocol
- Inherits task lifecycle (focus, execute, complete)
- Inherits manifest append requirement
- Inherits error handling patterns
Protocol Interactions
| Combined With | Behavior |
|---|---|
| specification | Spec defines implementation requirements |
| contribution | Implementation triggers contribution record |
| release | Implementation changes tracked for release |
Workflow Sequence
Example
Task: Implement session binding for multi-agent support Manifest Entry:Provenance Validation
Pre-Commit Hook
Location:.git/hooks/commit-msg (installed via git config core.hooksPath .cleo/hooks)
Logic:
- Extract @task tags from commit diff
- Count new functions/classes
- Calculate provenance coverage
- Apply thresholds:
- New code: 100% coverage required
- Existing code: 80% coverage required
- Legacy code: 50% coverage required
- Block commit if thresholds not met
EXIT_PROTOCOL_IMPLEMENTATION (64) on violation
Runtime Validation
Command (planned):cleo provenance validate [--task TASK_ID]
Current State: Validation available via protocol library
- IMPL-003:
@task T####tags in new functions - Git diff analysis for provenance coverage
- Agent type = “implementation” (IMPL-007)
Thresholds
| Code Category | Provenance Requirement | Rationale |
|---|---|---|
| New code | 100% | Fresh code must be attributable |
| Existing code | 80% | Modifications should track origin |
| Legacy code | 50% | Gradual attribution improvement |
- New code: Lines with
^+in git diff, no prior history - Existing code: Modified files with prior commits
- Legacy code: Files >6 months old or >100 commits
Enforcement Points
- Pre-commit: Blocks commits lacking provenance
- Pre-push: Warns on aggregate provenance score
<70% - Runtime:
cleo completevalidates IMPL-003 for implementation tasks - Orchestrator: Validates before spawning implementation agents
Anti-Patterns
| Pattern | Why Avoid |
|---|---|
| Code without tests | Regression risk |
| Missing provenance | Lost attribution |
| Skipping validation | Quality regression |
| Undocumented breaking changes | Surprise failures |
| No error handling | Silent failures |
| Hardcoded values | Maintenance burden |
Protocol Version 1.0.0 - Implementation Protocol
