---
name: mandatory-agent-progress-logging
description: Enhance K4000_WORKFLOW_SECTION with mandatory progress logging instructions
status: implementing
parts:
  - src/storage.rs
estimate:
  optimistic: 15 minutes
  normal: 30 minutes
  pessimistic: 1 hour
---

# Implementation Plan

## Feature Sizing Checklist

- [x] Each feature can be described in 2-3 sentences
- [x] Each feature is completable in one context window
- [x] No feature tries to do too much

## Task Summary

| ID | Task | Files |
|----|------|-------|
| T1 | Enhance K4000_WORKFLOW_SECTION with mandatory logging | `src/storage.rs` |

## Tasks

- [x] **T1**: Update the "Progress Logging" subsection within `K4000_WORKFLOW_SECTION` in `src/storage.rs` to include:
  - "MANDATORY" in the header
  - 5 when-to-log examples with `log_progress` syntax
  - Frequency guidance

## Implementation Notes

The `K4000_WORKFLOW_SECTION` constant in `storage.rs` is already appended to every `plan.md` by the `write_plan_md` function. This existing mechanism was enhanced rather than adding duplicate injection logic.

Changes made to `src/storage.rs`:
- Changed header from "### Progress Logging" to "### MANDATORY: Progress Logging"
- Added "You MUST log progress..." statement
- Added 5 specific when-to-log examples with full `log_progress` syntax
- Added frequency guidance (every significant change or 15-20 minutes)

## Testing Considerations

- [x] Build succeeds with `cargo build --release`
- [x] All 43 existing tests pass with `cargo test`
- [ ] Manual verification: new plan.md files contain the enhanced section (requires MCP server restart)

---

## Estimate

**Senior Developer Profile:** 5+ years experience, familiar with Rust and the k4000 codebase.

| Scenario | Time |
|----------|------|
| Optimistic | 15 minutes |
| Normal | 30 minutes |
| Pessimistic | 1 hour |

### Assumptions
- Existing K4000_WORKFLOW_SECTION mechanism works correctly
- Simple string constant update
---

## K4000 Workflow (MANDATORY)

This section defines the required workflow for implementing this task. These steps are automatically enforced by K4000.

### Implementation Flow

1. **Feature-by-Feature Implementation**
   - Implement features in order (F1, F2, F3...)
   - Each feature must be fully complete before moving to the next
   - After completing each feature, call `mark_feature_complete(feature_id)`

2. **Acceptance Criteria Verification (AUTOMATIC)**
   - When `mark_feature_complete` is called, K4000 returns the acceptance criteria
   - You MUST verify each criterion before calling `mark_feature_verified`
   - The feature's `passes` field only becomes `true` after verification

3. **Code Review (AUTOMATIC - After Each Feature)**
   - After marking a feature verified, IMMEDIATELY start a code review
   - Call `set_task_status(status="reviewing", files=[...modified files...])`
   - Then call `create_review_session` with the files
   - Review from all 5 perspectives: bugs, best_practices, security, performance, simplification
   - Submit findings with `submit_findings`

4. **Fix and Re-Review Loop (AUTOMATIC)**
   - Fix all critical and high severity findings
   - Call `complete_iteration(start_next=true)` after fixing
   - Re-review the fixed code
   - Repeat until no critical/high findings remain
   - Call `approve_review` when clean

5. **Task Completion**
   - ALL features must have `passes=true`
   - A review session must exist and be approved
   - Only then can you call `set_task_status(status="done")`

### Review Perspectives Checklist

For each review, examine the code from these angles:

- [ ] **Bugs**: Logic errors, null/undefined handling, edge cases, race conditions
- [ ] **Best Practices**: Code style, naming, documentation, error handling patterns
- [ ] **Security**: Input validation, authentication, authorization, data exposure
- [ ] **Performance**: N+1 queries, unnecessary computation, memory leaks
- [ ] **Simplification**: Dead code, overly complex logic, duplication

### Progress Logging

Log progress frequently using `log_progress(task_name, agent_name, message, feature_id)`:
- When starting a feature
- After significant code changes
- When encountering blockers
- When completing milestones
