mapify-cli 3.4.0__tar.gz → 3.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/PKG-INFO +1 -1
  2. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/pyproject.toml +1 -1
  3. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/__init__.py +1 -1
  4. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/actor.md +46 -0
  5. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/task-decomposer.md +6 -0
  6. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-efficient.md +107 -5
  7. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-plan.md +115 -1
  8. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-resume.md +3 -1
  9. mapify_cli-3.5.0/src/mapify_cli/templates/commands/map-task.md +214 -0
  10. mapify_cli-3.5.0/src/mapify_cli/templates/commands/map-tdd.md +299 -0
  11. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/workflow-gate.py +20 -7
  12. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/scripts/map_orchestrator.py +391 -61
  13. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/.claude/skills/README.md +0 -0
  14. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/.gitignore +0 -0
  15. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/README.md +0 -0
  16. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/dependency_graph.py +0 -0
  17. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/intent_detector.py +0 -0
  18. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/ralph_state.py +0 -0
  19. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/repo_insight.py +0 -0
  20. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/schemas.py +0 -0
  21. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/CLAUDE.md +0 -0
  22. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/debate-arbiter.md +0 -0
  23. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/documentation-reviewer.md +0 -0
  24. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/evaluator.md +0 -0
  25. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/final-verifier.md +0 -0
  26. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/monitor.md +0 -0
  27. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/predictor.md +0 -0
  28. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/reflector.md +0 -0
  29. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/research-agent.md +0 -0
  30. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/agents/synthesizer.md +0 -0
  31. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-check.md +0 -0
  32. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-debate.md +0 -0
  33. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-debug.md +0 -0
  34. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-fast.md +0 -0
  35. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-learn.md +0 -0
  36. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-release.md +0 -0
  37. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/commands/map-review.md +0 -0
  38. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/end-of-turn.sh +0 -0
  39. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/post-compact-context.py +0 -0
  40. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/pre-compact-save-transcript.py +0 -0
  41. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/ralph-context-pruner.py +0 -0
  42. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/ralph-iteration-logger.py +0 -0
  43. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/safety-guardrails.py +0 -0
  44. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/hooks/workflow-context-injector.py +0 -0
  45. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/scripts/diagnostics.py +0 -0
  46. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/scripts/map_step_runner.py +0 -0
  47. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/static-analysis/analyze.sh +0 -0
  48. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/static-analysis/handlers/common.sh +0 -0
  49. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/static-analysis/handlers/go.sh +0 -0
  50. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/static-analysis/handlers/python.sh +0 -0
  51. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/static-analysis/handlers/rust.sh +0 -0
  52. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/map/static-analysis/handlers/typescript.sh +0 -0
  53. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/ralph-loop-config.json +0 -0
  54. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/references/bash-guidelines.md +0 -0
  55. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/references/decomposition-examples.md +0 -0
  56. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/references/escalation-matrix.md +0 -0
  57. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/references/mcp-usage-examples.md +0 -0
  58. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/references/step-state-schema.md +0 -0
  59. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/references/workflow-state-schema.md +0 -0
  60. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/settings.json +0 -0
  61. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/README.md +0 -0
  62. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-cli-reference/SKILL.md +0 -0
  63. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-cli-reference/scripts/check-command.sh +0 -0
  64. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/SKILL.md +0 -0
  65. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/scripts/check-complete.sh +0 -0
  66. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/scripts/get-plan-path.sh +0 -0
  67. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/scripts/init-session.sh +0 -0
  68. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/scripts/show-focus.sh +0 -0
  69. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/templates/findings.md +0 -0
  70. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/templates/iteration_history.md +0 -0
  71. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/templates/progress.md +0 -0
  72. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-planning/templates/task_plan.md +0 -0
  73. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/SKILL.md +0 -0
  74. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/resources/agent-architecture.md +0 -0
  75. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/resources/map-debug-deep-dive.md +0 -0
  76. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/resources/map-efficient-deep-dive.md +0 -0
  77. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/resources/map-fast-deep-dive.md +0 -0
  78. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/resources/map-feature-deep-dive.md +0 -0
  79. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/resources/map-refactor-deep-dive.md +0 -0
  80. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/map-workflows-guide/scripts/validate-workflow-choice.py +0 -0
  81. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/skills/skill-rules.json +0 -0
  82. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/templates/workflow-rules.json +0 -0
  83. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/tools/__init__.py +0 -0
  84. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/tools/validate_dependencies.py +0 -0
  85. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/verification_recorder.py +0 -0
  86. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/workflow_finalizer.py +0 -0
  87. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/workflow_logger.py +0 -0
  88. {mapify_cli-3.4.0 → mapify_cli-3.5.0}/src/mapify_cli/workflow_state.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapify-cli
3
- Version: 3.4.0
3
+ Version: 3.5.0
4
4
  Summary: MAP Framework installer - Modular Agentic Planner for Claude Code
5
5
  Project-URL: Homepage, https://github.com/azalio/map-framework
6
6
  Project-URL: Repository, https://github.com/azalio/map-framework.git
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mapify-cli"
3
- version = "3.4.0"
3
+ version = "3.5.0"
4
4
  description = "MAP Framework installer - Modular Agentic Planner for Claude Code"
5
5
  authors = [{ name = "MAP Framework Contributors" }]
6
6
  readme = "README.md"
@@ -23,7 +23,7 @@ Or install globally:
23
23
  mapify check
24
24
  """
25
25
 
26
- __version__ = "3.4.0"
26
+ __version__ = "3.5.0"
27
27
 
28
28
  import copy
29
29
  import os
@@ -227,6 +227,52 @@ UserService -> register(email, password) -> creates user, returns 201 with JWT
227
227
 
228
228
  ---
229
229
 
230
+ ## TDD Mode Support
231
+
232
+ Actor supports two TDD modes, activated by the `<TDD_Mode>` tag in the prompt:
233
+
234
+ ### TDD Mode: `test_writer`
235
+
236
+ When `<TDD_Mode>test_writer</TDD_Mode>` is present:
237
+
238
+ **You write ONLY test files.** No implementation code.
239
+
240
+ Rules:
241
+ 1. Derive tests from the AAG contract, validation_criteria, and test_strategy — NOT from any implementation.
242
+ 2. You have NO knowledge of the implementation. Do not assume internal structure, class names, or method signatures beyond what the contract specifies.
243
+ 3. Test the PUBLIC interface/behavior described in the contract.
244
+ 4. Each `VCn:` validation criterion must have at least one corresponding test.
245
+ 5. Include edge cases from the spec's `## Edge Cases` section if available in the packet.
246
+ 6. Use standard test patterns for the project's language and framework.
247
+ 7. Tests SHOULD fail when run (implementation doesn't exist yet). This is expected.
248
+
249
+ Output:
250
+ - Test files created via Write tool
251
+ - Evidence file: `.map/<branch>/evidence/test_writer_<subtask_id>.json`
252
+
253
+ ### TDD Mode: `code_only`
254
+
255
+ When `<TDD_Mode>code_only</TDD_Mode>` is present:
256
+
257
+ **You write ONLY implementation code.** Test files are READ-ONLY.
258
+
259
+ Rules:
260
+ 1. Read the test files listed in `<TDD_Tests>` FIRST to understand expected behavior.
261
+ 2. Do NOT modify, delete, or rename any test file.
262
+ 3. Implement the minimum code needed to make ALL existing tests pass.
263
+ 4. Follow the AAG contract as your specification.
264
+ 5. If a test seems wrong (testing impossible behavior), flag it in trade-offs but still implement to satisfy it. Monitor will catch true test issues.
265
+
266
+ Output:
267
+ - Implementation files created/modified via Edit/Write tools
268
+ - Standard Actor evidence file
269
+
270
+ ### No TDD Mode (default)
271
+
272
+ When no `<TDD_Mode>` tag is present, Actor operates in standard mode: write both implementation and tests as described in sections 3-7 below.
273
+
274
+ ---
275
+
230
276
  ## 2. Approach
231
277
  Explain solution strategy in 2-3 sentences. Include:
232
278
  - Core idea and why this approach
@@ -244,6 +244,7 @@ Return **ONLY** valid JSON in this exact structure:
244
244
  - `scope`: "function" | "endpoint" | "module"
245
245
  - Include when: security_critical OR complexity_score ≥ 5 OR API contracts
246
246
  - Omit when: simple CRUD, internal helpers, complexity_score < 5
247
+ - **Spec invariant linkage**: If a `spec_<branch>.md` file exists with an `## Invariants` section, each contract MUST trace back to at least one spec invariant. Add `"source": "spec-invariant-N"` to link the contract to the invariant it enforces. This ensures no spec invariant is left unguarded by contracts.
247
248
  **subtasks[].aag_contract**: REQUIRED one-line contract in `Actor -> Action(params) -> Goal` format
248
249
  - This is the primary handoff artifact to the Actor agent
249
250
  - Actor "compiles" this contract into code; Monitor verifies against it
@@ -543,6 +544,11 @@ If circular dependency detected (e.g., A→B→C→A):
543
544
  - [ ] All assumptions documented that could affect implementation
544
545
  - [ ] Open questions flagged that need clarification before proceeding
545
546
 
547
+ **Spec Invariant Coverage** (when spec exists):
548
+ - [ ] Read `spec_<branch>.md` if present — check for `## Invariants` section
549
+ - [ ] Each spec invariant is covered by at least one contract across subtasks
550
+ - [ ] Edge cases from spec's `## Edge Cases` section are reflected in validation_criteria
551
+
546
552
  **MCP Tool Usage Verification**:
547
553
  - [ ] Did you use insights from MCP tools in your decomposition?
548
554
  - [ ] If MCP tools unavailable, documented limitations in analysis
@@ -59,7 +59,32 @@ Both files must stay in sync. The orchestrator updates `step_state.json` on ever
59
59
  └─────────────────────────────────────────────────────────────┘
60
60
  ```
61
61
 
62
- **Task:** $ARGUMENTS
62
+ ## Flag Parsing
63
+
64
+ Parse optional flags from `$ARGUMENTS`:
65
+
66
+ - **`--tdd`**: Enable TDD mode (test-first workflow). Inserts TEST_WRITER and TEST_FAIL_GATE phases before ACTOR. Tests are written from spec before implementation.
67
+
68
+ ```bash
69
+ # Extract flags and clean task description
70
+ TASK_ARGS="$ARGUMENTS"
71
+ TDD_FLAG=false
72
+ if echo "$TASK_ARGS" | grep -q -- '--tdd'; then
73
+ TDD_FLAG=true
74
+ TASK_ARGS=$(echo "$TASK_ARGS" | sed 's/--tdd//g' | xargs)
75
+ fi
76
+ ```
77
+
78
+ **Task:** $TASK_ARGS
79
+
80
+ **IMPORTANT:** Use `$TASK_ARGS` (not `$ARGUMENTS`) in all agent prompts below. The `--tdd` flag has been stripped from `$TASK_ARGS` so it won't leak into task descriptions.
81
+
82
+ If `--tdd` is detected, enable TDD mode after state initialization:
83
+ ```bash
84
+ if [ "$TDD_FLAG" = "true" ]; then
85
+ python3 .map/scripts/map_orchestrator.py set_tdd_mode true
86
+ fi
87
+ ```
63
88
 
64
89
  ## Step 0: Detect Existing Plan from /map-plan
65
90
 
@@ -105,7 +130,7 @@ Task(
105
130
  description="Decompose task into subtasks",
106
131
  prompt=f"""Break down into ≤20 atomic subtasks and RETURN ONLY JSON.
107
132
 
108
- Task: $ARGUMENTS
133
+ Task: $TASK_ARGS
109
134
 
110
135
  Hard requirements:
111
136
  - Use `blueprint.subtasks[].validation_criteria` (2-4 testable outcomes)
@@ -221,11 +246,18 @@ This is not optional — wave computation must run after every INIT_STATE.
221
246
  After INIT_STATE (1.6) completes, compute execution waves from the dependency DAG:
222
247
 
223
248
  ```bash
224
- python3 .map/scripts/map_orchestrator.py set_waves --blueprint .map/${BRANCH}/blueprint.json
249
+ BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -E 's|/|-|g; s|[^a-zA-Z0-9_.-]|-|g; s|-{2,}|-|g; s|^-||; s|-$||')
250
+ if [ -f ".map/${BRANCH}/blueprint.json" ]; then
251
+ python3 .map/scripts/map_orchestrator.py set_waves --blueprint .map/${BRANCH}/blueprint.json
252
+ else
253
+ echo "WARNING: blueprint.json not found. Running subtasks sequentially."
254
+ echo "To enable parallel waves, re-run /map-plan (saves blueprint.json since v3.5)."
255
+ fi
225
256
  ```
226
257
 
227
258
  This reads the blueprint, builds a dependency graph, computes topological waves,
228
259
  and splits waves by file conflicts. The result is stored in `step_state.json`.
260
+ If `blueprint.json` is missing (e.g., plan was created before v3.5), subtasks execute sequentially — this is safe but slower.
229
261
 
230
262
  **Wave execution**: If waves are computed, subtasks within a wave run their Actor
231
263
  and Monitor phases in parallel. Check wave status with:
@@ -255,6 +287,14 @@ loop:
255
287
  for each subtask in WAVE.subtasks:
256
288
  build XML_PACKET, run CONTEXT_SEARCH, optional RESEARCH
257
289
 
290
+ # Phase A.5: TDD phases (if --tdd mode)
291
+ # When TDD is enabled, run TEST_WRITER + TEST_FAIL_GATE per subtask
292
+ # BEFORE launching Actors. These run sequentially per subtask.
293
+ if TDD_FLAG:
294
+ for each subtask in WAVE.subtasks:
295
+ run TEST_WRITER (2.25) → validate_wave_step SUBTASK_ID "2.25"
296
+ run TEST_FAIL_GATE (2.26) → validate_wave_step SUBTASK_ID "2.26"
297
+
258
298
  # Phase B: Parallel Actors
259
299
  # Launch ALL Task(subagent_type="actor") calls in ONE message
260
300
  # Example: Task(actor, "Implement ST-002") + Task(actor, "Implement ST-004")
@@ -322,8 +362,64 @@ This file is the SOLE research artifact passed to Actor and future steps."""
322
362
  )
323
363
  ```
324
364
 
365
+ ### Phase: TEST_WRITER (2.25) — TDD Mode Only
366
+
367
+ Auto-skipped when TDD mode is disabled. When active:
368
+
369
+ ```python
370
+ Task(
371
+ subagent_type="actor",
372
+ description="TDD: Write tests for subtask [ID]",
373
+ prompt=f"""You are in TDD TEST_WRITER mode.
374
+
375
+ <MAP_Packet subtask="[ID]" v="1.0" risk="[risk_level]">
376
+ [paste from .map/<branch>/current_packet.xml]
377
+ </MAP_Packet>
378
+
379
+ <MAP_Contract>
380
+ [AAG contract from decomposition]
381
+ </MAP_Contract>
382
+
383
+ <TDD_Mode>test_writer</TDD_Mode>
384
+
385
+ STRICT RULES:
386
+ 1. Write ONLY test files. Do NOT create or modify implementation files.
387
+ 2. Tests must be derived from the SPECIFICATION (AAG contract + validation_criteria).
388
+ 3. You have NO knowledge of the implementation.
389
+ 4. Each VCn: validation criterion must have at least one corresponding test.
390
+ 5. Tests SHOULD fail when run (implementation doesn't exist yet).
391
+ 6. Test files MUST be lint-clean. Use proper imports at the top of the file
392
+ (not inside type annotations). Run the project linter on test files before finishing.
393
+
394
+ Write evidence: .map/<branch>/evidence/test_writer_<subtask_id>.json"""
395
+ )
396
+ ```
397
+
398
+ ### Phase: TEST_FAIL_GATE (2.26) — TDD Mode Only
399
+
400
+ Auto-skipped when TDD mode is disabled. When active:
401
+
402
+ **First:** lint-check test files (ACTOR cannot fix them later):
403
+ ```bash
404
+ # Lint ONLY the test files from TEST_WRITER evidence
405
+ ruff check <test_files> 2>&1 || true
406
+ # If lint errors → go back to TEST_WRITER with feedback to fix lint
407
+ ```
408
+
409
+ **Then:** run the tests — they MUST fail:
410
+ ```bash
411
+ # Run tests — expect failures (Red phase)
412
+ pytest --tb=short 2>&1 || true
413
+ # If tests PASS → go back to TEST_WRITER (tests are trivial)
414
+ # If tests FAIL with assertion errors → proceed to ACTOR (expected TDD state)
415
+ ```
416
+
417
+ Write evidence: `.map/<branch>/evidence/test_fail_gate_<subtask_id>.json`
418
+
325
419
  ### Phase: ACTOR (2.3)
326
420
 
421
+ When TDD mode is active, Actor receives `<TDD_Mode>code_only</TDD_Mode>` and must NOT modify test files. When TDD is off, standard behavior.
422
+
327
423
  ```python
328
424
  Task(
329
425
  subagent_type="actor",
@@ -527,10 +623,16 @@ Question 2: For EACH subtask, did I:
527
623
  - Run linter gate? [YES/NO per subtask]
528
624
  Answer: [List each subtask and answers]
529
625
 
530
- Question 3: Did I ever write code directly without Actor?
626
+ Question 3: (TDD mode only) For EACH subtask, did I:
627
+ - Call TEST_WRITER before Actor? [YES/NO/N/A per subtask]
628
+ - Verify tests failed at TEST_FAIL_GATE? [YES/NO/N/A per subtask]
629
+ - Use code_only mode for Actor (no test modifications)? [YES/NO/N/A]
630
+ Answer: [List answers, or N/A if TDD mode is not active]
631
+
632
+ Question 4: Did I ever write code directly without Actor?
531
633
  Answer: [YES/NO - if YES, this is a VIOLATION]
532
634
 
533
- Question 4: Did I output CHECKPOINT blocks before agent calls?
635
+ Question 5: Did I output CHECKPOINT blocks before agent calls?
534
636
  Answer: [YES/NO - if NO, add them now]
535
637
 
536
638
  EVALUATION: [PASSED/FAILED]
@@ -106,7 +106,7 @@ Read the user's requirements and decide if deep interview is needed.
106
106
  - Small isolated change (single bug fix, test update)
107
107
  - User explicitly provided a spec or detailed description
108
108
 
109
- If interview is not needed, skip to Step 3.
109
+ If interview is not needed, skip to Step 2a (write spec without interview).
110
110
 
111
111
  ### Step 2: Deep Interview (Spec Discovery)
112
112
 
@@ -169,6 +169,45 @@ AskUserQuestion(questions=[
169
169
  | 1 | Token storage | Server-side (Redis) | Need revocation support |
170
170
  | 2 | Session expiry UX | Silent refresh | Better UX, no data loss |
171
171
 
172
+ ## Invariants
173
+
174
+ Conditions that MUST remain true throughout implementation and after deployment.
175
+ These are hard constraints — violating any invariant is a blocker.
176
+
177
+ - [e.g., "All API endpoints require authentication except /health and /login"]
178
+ - [e.g., "Database migrations must be backward-compatible (no column drops)"]
179
+ - [e.g., "Response time for any endpoint must stay under 500ms p95"]
180
+
181
+ ## Edge Cases
182
+
183
+ Enumerate boundary conditions and unusual inputs that implementation must handle.
184
+
185
+ | # | Edge Case | Expected Behavior | Priority |
186
+ |---|-----------|-------------------|----------|
187
+ | 1 | [e.g., Empty input array] | [Return empty result, not error] | must-handle |
188
+ | 2 | [e.g., Concurrent updates to same resource] | [Last-write-wins with conflict detection] | must-handle |
189
+ | 3 | [e.g., Unicode in usernames] | [Accept, normalize to NFC] | should-handle |
190
+
191
+ Priority levels: `must-handle` (blocks release), `should-handle` (best effort), `won't-handle` (documented limitation).
192
+
193
+ ## Acceptance Criteria
194
+
195
+ Formal, testable conditions that define "done". Each criterion must be verifiable by automated test or manual check.
196
+
197
+ | ID | Criterion | Verification Method |
198
+ |----|-----------|-------------------|
199
+ | AC-1 | [e.g., User can log in with valid credentials] | `pytest tests/test_auth.py::test_login` |
200
+ | AC-2 | [e.g., Invalid token returns 401] | `pytest tests/test_auth.py::test_invalid_token` |
201
+
202
+ ## Security Boundaries
203
+
204
+ *(Include for security-critical tasks; omit for purely internal/cosmetic changes)*
205
+
206
+ - **Trust boundary:** [e.g., "All user input is untrusted; validate at API layer"]
207
+ - **Auth model:** [e.g., "RBAC with role checks at service layer, not just route level"]
208
+ - **Data sensitivity:** [e.g., "PII fields encrypted at rest, never logged"]
209
+ - **Attack surface:** [e.g., "Public API exposed to internet; internal services behind VPN"]
210
+
172
211
  ## Out of Scope
173
212
 
174
213
  - [Explicitly excluded items]
@@ -178,6 +217,54 @@ AskUserQuestion(questions=[
178
217
  - [Anything still unresolved]
179
218
  ```
180
219
 
220
+ ### Step 2a: Write Spec (when interview was skipped)
221
+
222
+ If interview was skipped (task is well-defined), still write `spec_<branch>.md` using the same template as Step 2. Populate it from the user's requirements and discovery findings:
223
+
224
+ - **Decisions Made**: extract from user's request (may be short or N/A)
225
+ - **Invariants**: derive from existing code patterns found in discovery
226
+ - **Edge Cases**: identify from the task description and affected code
227
+ - **Acceptance Criteria**: REQUIRED — must be testable conditions that define "done"
228
+ - **Security Boundaries**: include if task touches auth/validation/user input
229
+ - **Out of Scope**: explicitly state what is NOT being changed
230
+
231
+ This ensures every `/map-plan` run produces a spec, regardless of whether interview happened.
232
+
233
+ ### Step 2b: Devil's Advocate Review (SPEC_REVIEW)
234
+
235
+ **Skip if:** complexity < 5 (simple, well-defined tasks).
236
+
237
+ After writing the spec, invoke Monitor agent to adversarially review it. The goal is to surface gaps, contradictions, and missing edge cases BEFORE decomposition.
238
+
239
+ ```
240
+ Task(
241
+ subagent_type="monitor",
242
+ description="Devil's Advocate spec review",
243
+ prompt=f"""You are reviewing a SPECIFICATION (not code). Act as Devil's Advocate.
244
+
245
+ Read the spec file: .map/<branch>/spec_<branch>.md
246
+
247
+ Check for:
248
+ 1. **Race conditions / concurrency gaps**: Are there shared resources without defined conflict resolution?
249
+ 2. **Ownership ambiguity**: Are responsibilities clearly assigned? Could two components both assume the other handles something?
250
+ 3. **Missing edge cases**: Compare the Edge Cases section against Invariants — are there invariant violations not covered by edge cases?
251
+ 4. **Contradictions**: Do any decisions contradict invariants or acceptance criteria?
252
+ 5. **Security gaps**: Are trust boundaries complete? Are there injection vectors not addressed?
253
+ 6. **Implicit assumptions**: What is assumed but not stated?
254
+
255
+ Output format:
256
+ - For each finding: severity (HIGH/MEDIUM/LOW), category, description, suggested fix
257
+ - If NO high-severity issues found: output "SPEC APPROVED"
258
+ - If HIGH-severity issues found: list them clearly for user resolution
259
+ """
260
+ )
261
+ ```
262
+
263
+ **After Devil's Advocate review:**
264
+ - If **SPEC APPROVED** (no HIGH-severity findings): proceed to Step 3.
265
+ - If **HIGH-severity findings**: present them to the user via AskUserQuestion. Update the spec with resolutions before proceeding. Do NOT silently proceed past HIGH findings.
266
+ - MEDIUM/LOW findings: note them in the spec's Open Questions section but proceed.
267
+
181
268
  ### Step 3: Create Branch Directory
182
269
 
183
270
  ```bash
@@ -238,6 +325,32 @@ Output requirements:
238
325
  )
239
326
  ```
240
327
 
328
+ ### Step 5.5: Save Blueprint JSON
329
+
330
+ Save the raw decomposer output as `.map/<branch>/blueprint.json` using the **Write** tool. This file is required by `/map-efficient` for wave computation (`set_waves`).
331
+
332
+ The blueprint JSON must include at minimum:
333
+ ```json
334
+ {
335
+ "summary": "<goal description>",
336
+ "subtasks": [
337
+ {
338
+ "id": "ST-001",
339
+ "title": "<title>",
340
+ "aag_contract": "Actor -> Action(params) -> Goal",
341
+ "dependencies": [],
342
+ "affected_files": ["path/to/file.py"],
343
+ "complexity_score": 5,
344
+ "risk_level": "medium",
345
+ "validation_criteria": ["VC1: ...", "VC2: ..."],
346
+ "test_strategy": {"unit": ["test description"]}
347
+ }
348
+ ]
349
+ }
350
+ ```
351
+
352
+ If the decomposer returned structured JSON, save it directly. If it returned markdown, construct the JSON from the decomposed subtasks. **This step is mandatory** — without `blueprint.json`, `/map-efficient` cannot compute parallel execution waves.
353
+
241
354
  ### Step 6: Create Human-Readable Plan
242
355
 
243
356
  Write the plan to `.map/<branch>/task_plan_<branch>.md` using the **Write** tool. Wrap content in `<MAP_Plan_v1_0>` semantic brackets for machine-parseable handoff to executors.
@@ -332,6 +445,7 @@ WORKFLOW CHECKPOINT: PLAN PHASE COMPLETE
332
445
  ✅ Deep interview completed (N decisions captured)
333
446
  ✅ Architecture graph written to spec_${BRANCH}.md
334
447
  ✅ Task decomposed into N subtasks with AAG contracts
448
+ ✅ Blueprint saved to .map/${BRANCH}/blueprint.json
335
449
  ✅ workflow_state.json initialized (with aag_contracts map)
336
450
  ✅ Plan written to .map/${BRANCH}/task_plan_${BRANCH}.md
337
451
  ✅ Context distilled (plan files ≤4000 tokens per subtask)
@@ -21,10 +21,12 @@ description: Resume incomplete MAP workflow from checkpoint
21
21
  6. Continues from the last incomplete step via the state machine
22
22
 
23
23
  **State files used:**
24
- - **`step_state.json`** — Orchestrator canonical state. Source of truth for resumption. Tracks current step, retry counts, circuit breaker status.
24
+ - **`step_state.json`** — Orchestrator canonical state. Source of truth for resumption. Tracks current step, retry counts, circuit breaker status. Includes `tdd_mode` field (persisted across sessions).
25
25
  - **`workflow_state.json`** — Enforcement gates. Tracks subtask completion for workflow-gate.py hook.
26
26
  - **`task_plan_<branch>.md`** — Full task decomposition with validation criteria and AAG contracts.
27
27
 
28
+ **TDD mode note:** If the interrupted workflow was using `/map-tdd` or `--tdd` flag, `tdd_mode: true` is preserved in `step_state.json`. The TDD phases (TEST_WRITER, TEST_FAIL_GATE) will be correctly included in the resumed workflow. No manual re-enablement is needed when resuming from `step_state.json`.
29
+
28
30
  ---
29
31
 
30
32
  ## Step 1: Detect Checkpoint
@@ -0,0 +1,214 @@
1
+ ---
2
+ description: Execute a single subtask from an existing plan
3
+ ---
4
+
5
+ # /map-task — Single Subtask Execution
6
+
7
+ **Purpose:** Execute one specific subtask from an existing plan, without running the full workflow.
8
+
9
+ **When to use:**
10
+ - After `/map-plan` has created a decomposition — pick and run one subtask
11
+ - When you want fine-grained control over execution order
12
+ - When resuming work on a specific subtask after context reset
13
+ - When parallelizing subtasks across multiple sessions
14
+
15
+ **Prerequisites:** A plan must exist (`.map/<branch>/task_plan_<branch>.md`). Run `/map-plan` first if needed.
16
+
17
+ **Task:** $ARGUMENTS
18
+
19
+ ---
20
+
21
+ ## Step 0: Parse Arguments
22
+
23
+ Extract the subtask ID from `$ARGUMENTS`:
24
+
25
+ ```bash
26
+ SUBTASK_ID=$(echo "$ARGUMENTS" | grep -oE 'ST-[0-9]+' | head -1)
27
+ if [ -z "$SUBTASK_ID" ]; then
28
+ echo "ERROR: No subtask ID found. Usage: /map-task ST-001"
29
+ exit 1
30
+ fi
31
+ ```
32
+
33
+ ## Step 1: Initialize Single Subtask
34
+
35
+ ```bash
36
+ BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -E 's|/|-|g; s|[^a-zA-Z0-9_.-]|-|g; s|-{2,}|-|g; s|^-||; s|-$||')
37
+
38
+ # Set up state for single subtask execution
39
+ RESULT=$(python3 .map/scripts/map_orchestrator.py resume_single_subtask "$SUBTASK_ID")
40
+ STATUS=$(echo "$RESULT" | jq -r '.status')
41
+
42
+ if [ "$STATUS" = "error" ]; then
43
+ echo "$RESULT" | jq -r '.message'
44
+ exit 1
45
+ fi
46
+ ```
47
+
48
+ **If error mentions "No plan found":** Run `/map-plan` first to create a decomposition.
49
+ **If error mentions "not found in plan":** The output lists available subtask IDs — pick one.
50
+
51
+ ## Step 2: Load Subtask Context
52
+
53
+ Read the plan to get the subtask's details:
54
+
55
+ ```bash
56
+ BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -E 's|/|-|g; s|[^a-zA-Z0-9_.-]|-|g; s|-{2,}|-|g; s|^-||; s|-$||')
57
+ # Read: .map/${BRANCH}/task_plan_${BRANCH}.md — find the ### ${SUBTASK_ID} section
58
+ # Read: .map/${BRANCH}/blueprint.json — get AAG contract, validation_criteria, dependencies
59
+ ```
60
+
61
+ Display a brief summary:
62
+
63
+ ```text
64
+ ═══════════════════════════════════════════════════
65
+ SINGLE SUBTASK EXECUTION
66
+ ═══════════════════════════════════════════════════
67
+ Subtask: ${SUBTASK_ID}
68
+ Title: <from plan>
69
+ AAG Contract: <from blueprint>
70
+ Risk: <from blueprint>
71
+ Dependencies: <from blueprint>
72
+ ═══════════════════════════════════════════════════
73
+ ```
74
+
75
+ ## Step 3: State Machine Loop
76
+
77
+ Follow the same state machine loop as `/map-efficient`. Call `get_next_step` and execute based on the returned phase.
78
+
79
+ ```bash
80
+ NEXT_STEP=$(python3 .map/scripts/map_orchestrator.py get_next_step)
81
+ PHASE=$(echo "$NEXT_STEP" | jq -r '.phase')
82
+ ```
83
+
84
+ Route to the appropriate executor based on `$PHASE`. All phases from `/map-efficient` work identically:
85
+
86
+ - **XML_PACKET (2.0)** — Build XML packet for this subtask
87
+ - **CONTEXT_SEARCH (2.1)** — Search for relevant patterns
88
+ - **RESEARCH (2.2)** — Call research-agent if needed
89
+ - **ACTOR (2.3)** — Implement the subtask
90
+ - **MONITOR (2.4)** — Validate implementation
91
+ - **PREDICTOR (2.6)** — Impact analysis (conditional)
92
+ - **UPDATE_STATE (2.7)** — Mark progress
93
+ - **TESTS_GATE (2.8)** — Run tests
94
+ - **LINTER_GATE (2.9)** — Run linter
95
+ - **VERIFY_ADHERENCE (2.10)** — Self-audit
96
+
97
+ For each step:
98
+ 1. Get next step from orchestrator
99
+ 2. Execute the phase (same handlers as map-efficient)
100
+ 3. Validate: `python3 .map/scripts/map_orchestrator.py validate_step "$STEP_ID"`
101
+ 4. Continue to next step until complete
102
+
103
+ **If Monitor returns `valid: false`:**
104
+ - Retry Actor with feedback (max 5 iterations)
105
+
106
+ ## Step 4: Completion and Progress Report
107
+
108
+ When `get_next_step` returns `is_complete: true`:
109
+
110
+ 1. Update the plan status:
111
+ ```bash
112
+ python3 .map/scripts/map_step_runner.py update_plan_status "${SUBTASK_ID}" "complete"
113
+ ```
114
+
115
+ 2. Get overall plan progress:
116
+ ```bash
117
+ PROGRESS=$(python3 .map/scripts/map_orchestrator.py get_plan_progress)
118
+ TOTAL=$(echo "$PROGRESS" | jq -r '.total')
119
+ DONE=$(echo "$PROGRESS" | jq -r '.completed_count')
120
+ REMAINING=$(echo "$PROGRESS" | jq -r '.pending_count')
121
+ SUGGESTED=$(echo "$PROGRESS" | jq -r '.suggested_next')
122
+ ```
123
+
124
+ 3. Display completion report with remaining subtasks:
125
+
126
+ ```text
127
+ ═══════════════════════════════════════════════════
128
+ SUBTASK COMPLETE
129
+ ═══════════════════════════════════════════════════
130
+ Subtask: ${SUBTASK_ID}
131
+ Title: <title>
132
+ Status: COMPLETE
133
+
134
+ Files Modified:
135
+ - <list of changed files>
136
+
137
+ ───────────────────────────────────────────────────
138
+ PLAN PROGRESS: ${DONE}/${TOTAL} subtasks complete
139
+ ───────────────────────────────────────────────────
140
+
141
+ Completed:
142
+ ✓ ST-001: <title>
143
+ ✓ ST-002: <title> ← just completed
144
+
145
+ Remaining:
146
+ ○ ST-003: <title> (pending)
147
+ ○ ST-004: <title> (pending)
148
+
149
+ ═══════════════════════════════════════════════════
150
+ ```
151
+
152
+ 4. **Suggest next subtask** using AskUserQuestion:
153
+
154
+ ```
155
+ AskUserQuestion(questions=[
156
+ {
157
+ "question": "What would you like to do next?",
158
+ "header": "Next subtask",
159
+ "options": [
160
+ {"label": "/map-task ${SUGGESTED}", "description": "Execute next subtask: <title>"},
161
+ {"label": "/map-tdd ${SUGGESTED}", "description": "TDD for next subtask: <title>"},
162
+ {"label": "Done for now", "description": "Stop here, continue later with /map-task"}
163
+ ],
164
+ "multiSelect": false
165
+ }
166
+ ])
167
+ ```
168
+
169
+ **If all subtasks are complete** (REMAINING == 0), skip the question and show:
170
+
171
+ ```text
172
+ ═══════════════════════════════════════════════════
173
+ ALL SUBTASKS COMPLETE (${TOTAL}/${TOTAL})
174
+ ═══════════════════════════════════════════════════
175
+
176
+ Run /map-check for final verification, or /map-learn to extract patterns.
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Error Handling
182
+
183
+ ### No Plan Exists
184
+
185
+ ```text
186
+ No plan found. Run /map-plan first to create a task decomposition,
187
+ then use /map-task ST-001 to execute individual subtasks.
188
+ ```
189
+
190
+ ### Subtask Not in Plan
191
+
192
+ ```text
193
+ Subtask ST-999 not found in plan.
194
+ Available subtasks: ST-001, ST-002, ST-003
195
+ ```
196
+
197
+ ### Dependencies Not Met
198
+
199
+ Check blueprint for dependencies. If the subtask depends on unfinished work, warn:
200
+
201
+ ```text
202
+ WARNING: ${SUBTASK_ID} depends on ${DEP_ID} which may not be complete.
203
+ Proceed anyway? (The Actor will work with whatever state exists.)
204
+ ```
205
+
206
+ ---
207
+
208
+ ## Related Commands
209
+
210
+ - **/map-plan** — Create task decomposition (prerequisite)
211
+ - **/map-efficient** — Run full workflow (all subtasks)
212
+ - **/map-tdd ST-001** — Write tests for a specific subtask (TDD mode)
213
+ - **/map-resume** — Resume interrupted workflow from checkpoint
214
+ - **/map-check** — Verify all acceptance criteria