# Memory Check Confirmation Number System — PRD

> Version: 1.0 | Created: 2026-04-05 | Task: task-1457.1

## 1. Problem Definition

Anu stores feedback in MEMORY.md but agents do not consistently read memory before
starting work, leading to repeated mistakes. There is no mechanism to verify that
memory was read.

## 2. Goals

- Issue MC-XXXX per task dispatch to track memory check status
- Log which MEMORY.md star items and related feedback files exist at dispatch time
- Maintain task_id <-> MC-XXXX mapping in `memory/memory-check-log.json`
- WARNING when task_id exists without MC-XXXX
- Display unchecked tasks in whisper briefing

## 3. Data Structure

### memory-check-log.json

```json
{
  "checks": [
    {
      "mc_id": "MC-0001",
      "task_id": "task-1454.1",
      "timestamp": "2026-04-05T00:15:56",
      "memory_items_read": ["feedback_design_team_routing_v2.md", "feedback_modularity_mindset.md"],
      "star_items_checked": 5
    }
  ]
}
```

Fields:
- `mc_id`: Unique MC identifier (MC-XXXX, zero-padded 4 digits)
- `task_id`: Associated task ID
- `timestamp`: ISO 8601 when MC was issued
- `memory_items_read`: List of feedback filenames that are relevant to the task
- `star_items_checked`: Count of star items in MEMORY.md at issue time

## 4. Implementation

### 4.1 New Module: `utils/memory_check.py`

Functions:
- `parse_star_items(memory_path: Path) -> list[str]`: Extract lines with star markers from MEMORY.md
- `find_feedback_files(feedback_dir: Path) -> list[str]`: List all feedback_*.md files
- `match_feedback_to_task(task_desc: str, feedback_dir: Path) -> list[str]`: Keyword-match feedback files to task description
- `get_next_mc_id(log_path: Path) -> str`: Generate next MC-XXXX
- `issue_mc(task_id: str, task_desc: str, log_path: Path, memory_path: Path, feedback_dir: Path) -> dict`: Full MC issuance
- `get_unchecked_tasks(log_path: Path, timers_path: Path) -> list[dict]`: Find tasks without MC records

### 4.2 Paths

- Memory check log: `{WORKSPACE}/memory/memory-check-log.json`
- Workspace MEMORY.md: `{WORKSPACE}/memory/MEMORY.md`
- Anu Claude MEMORY.md: `~/.claude/projects/-home-jay--cokacdir-workspace-autoset/memory/MEMORY.md`
- Feedback files: `~/.claude/projects/-home-jay--cokacdir-workspace-autoset/memory/feedback_*.md`

The module should scan BOTH workspace MEMORY.md and Anu Claude MEMORY.md for star items.
Feedback dir defaults to Anu Claude auto-memory, configurable via `MEMORY_CHECK_FEEDBACK_DIR` env var.

### 4.3 dispatch.py Integration

After successful dispatch (cokacdir --cron returncode == 0), call `issue_mc()` to:
1. Parse star items from MEMORY.md(s)
2. Find related feedback files
3. Record MC entry in memory-check-log.json
4. Log MC issuance

Use try/except so MC failure does not block dispatch.

### 4.4 whisper-compile.py Integration

Add `[메모리미확인]` section to briefing:
- Compare running tasks in task-timers.json with MC log
- Tasks missing MC entries are flagged
- Format: `[메모리미확인] task-1454.1(1팀) / task-1455.1(2팀)`

### 4.5 File Locking

Use fcntl file lock on `memory/.memory-check-log.lock` for concurrent access safety.

## 5. Verification

- task dispatch -> MC auto-issued: Check log entry created
- dispatch without MC -> WARNING logged
- whisper shows unchecked tasks
- Unit tests cover all functions

## 6. Out of Scope

- Verifying the agent *actually* read the memory (future: agent reports back MC-XXXX)
- Auto-remediation for unchecked tasks
