{
  "schema_version": "0.1",
  "id": "IMP-002",
  "title": "MCP server implementation plan",
  "status": "complete",
  "source_prd_id": "PRD-002",
  "source_architecture_id": "ARCH-002",
  "source_request_id": "REQ-052",
  "created_at": "2026-07-02",
  "updated_at": "2026-07-13",
  "summary": "TDD build of the server, wiring, and bundled fixes. Complexity: large. Confidence: high (mechanisms grounded; MCP stdio + state shapes verified).",
  "phases": [
    {
      "id": "IMP-PHASE-005",
      "name": "Server core (tools + invariants)",
      "order": 1,
      "tasks": [
        "IMP-TASK-017",
        "IMP-TASK-018",
        "IMP-TASK-019"
      ],
      "exit_criteria": "Node unit tests green for all tools and invariants."
    },
    {
      "id": "IMP-PHASE-006",
      "name": "Wiring (installer, gate, skills, docs)",
      "order": 2,
      "tasks": [
        "IMP-TASK-020",
        "IMP-TASK-021",
        "IMP-TASK-022"
      ],
      "exit_criteria": "prd-install merges .mcp.json; gate points at tools; README documents the tools."
    },
    {
      "id": "IMP-PHASE-007",
      "name": "Bundled fixes + e2e",
      "order": 3,
      "tasks": [
        "IMP-TASK-023",
        "IMP-TASK-024"
      ],
      "exit_criteria": "Stop-guard/status fixes green; full e2e passes; release staged."
    },
    {
      "id": "IMP-PHASE-012",
      "name": "Parallel tracking audit corrections",
      "order": 4,
      "tasks": [
        "IMP-TASK-034",
        "IMP-TASK-035",
        "IMP-TASK-036"
      ],
      "exit_criteria": "Worker enforcement, DBR discovery, default validation, downstream workflow parity, full verification, and repeated CHML audits are all green."
    }
  ],
  "tasks": [
    {
      "id": "IMP-TASK-017",
      "phase": "IMP-PHASE-005",
      "summary": "JSON-RPC stdio loop + tools/list with playbook descriptions.",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-017"
    },
    {
      "id": "IMP-TASK-018",
      "phase": "IMP-PHASE-005",
      "summary": "State store: indent-preserving atomic writes, server-side dates, schema validators, status vocabulary + legacy map.",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-018"
    },
    {
      "id": "IMP-TASK-019",
      "phase": "IMP-PHASE-005",
      "summary": "Registry allocator with exclusive lock + prefix whitelist; write tools (open/update/close goal, file_request, record_evidence, record_decision, log_change).",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-018"
    },
    {
      "id": "IMP-TASK-020",
      "phase": "IMP-PHASE-006",
      "summary": "Python bridge for prd_status/prd_validate parity.",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-019"
    },
    {
      "id": "IMP-TASK-021",
      "phase": "IMP-PHASE-006",
      "summary": "prd-install: copy server to .prd_plugin/mcp/ + idempotent .mcp.json merge; package.json bin + files entries.",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-019"
    },
    {
      "id": "IMP-TASK-022",
      "phase": "IMP-PHASE-006",
      "summary": "Gate/pre-commit messages point at tools; skills reference tools (memory, decision-policy, verification); README section.",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-020"
    },
    {
      "id": "IMP-TASK-023",
      "phase": "IMP-PHASE-007",
      "summary": "Stop-guard CLOSED_STATUSES += deferred/parked; status normalization in status/report code.",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-020"
    },
    {
      "id": "IMP-TASK-024",
      "phase": "IMP-PHASE-007",
      "summary": "End-to-end test: temp repo -> install -> tool conversation -> gate clean.",
      "sources": [
        "PRD-002",
        "ARCH-002"
      ],
      "validation": "IMP-VAL-021"
    },
    {
      "id": "IMP-TASK-034",
      "phase": "IMP-PHASE-012",
      "summary": "Add failing tests and centrally enforce that configured worker sessions can update only their assigned DBR while all canonical state and registry tools remain lead-only.",
      "sources": ["REQ-088", "HLT-009", "PRD-ACC-027", "ARCH-COMP-019", "ARCH-IF-012"],
      "validation": "IMP-VAL-031",
      "status": "complete"
    },
    {
      "id": "IMP-TASK-035",
      "phase": "IMP-PHASE-012",
      "summary": "Expose DBR records through existing status/find/get tools, install state consistency validation by default, fail loudly when it is unavailable, and align all downstream workflows and docs.",
      "sources": ["REQ-088", "HLT-009", "PRD-ACC-028", "ARCH-COMP-017", "ARCH-COMP-019"],
      "validation": "IMP-VAL-032",
      "status": "complete"
    },
    {
      "id": "IMP-TASK-036",
      "phase": "IMP-PHASE-012",
      "summary": "Repeat skills-vs-tools-vs-functionality and CHML audits, fix all findings, run full release verification, and publish the correction.",
      "sources": ["REQ-088", "HLT-009", "TRK-085"],
      "validation": "IMP-VAL-033",
      "status": "complete"
    }
  ],
  "validations": [
    {
      "id": "IMP-VAL-017",
      "method": "Node unit tests (node:test) for framing, tools/list, error paths.",
      "evidence": "EV-026"
    },
    {
      "id": "IMP-VAL-018",
      "method": "Node unit tests: timestamp injection impossible, next_id race-safe, foreign-indent minimal diff, schema rejections actionable, legacy statuses readable.",
      "evidence": "EV-026"
    },
    {
      "id": "IMP-VAL-019",
      "method": "Python unittest: installer merge idempotence + preservation; bridge parity with prd_status.",
      "evidence": "EV-026"
    },
    {
      "id": "IMP-VAL-020",
      "method": "Python unittest: gate messages, guard statuses, skill/doc guards.",
      "evidence": "EV-026"
    },
    {
      "id": "IMP-VAL-021",
      "method": "Python e2e subprocess test speaking JSON-RPC to the real server in a fresh installed repo.",
      "evidence": "EV-026"
    },
    {
      "id": "IMP-VAL-031",
      "method": "Node and installed-runtime tests prove the config toggle, assigned DBR/owner enforcement, canonical-write rejection, and unchanged worker registry bytes.",
      "evidence": "EV-063"
    },
    {
      "id": "IMP-VAL-032",
      "method": "Python installer/status/gate tests prove DBR discovery, required validator delivery, loud missing-validator failure, and invalid-promotion detection.",
      "evidence": "EV-063"
    },
    {
      "id": "IMP-VAL-033",
      "method": "Full suite, workflow/state/release/drift gates, package inspection, and repeated CHML review finish with zero findings.",
      "evidence": "EV-063"
    }
  ],
  "tracking_ids": ["TRK-083", "TRK-084", "TRK-085"],
  "completed_at": "2026-07-13"
}
