knowzcode 0.1.0

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 (73) hide show
  1. package/.claude-plugin/marketplace.json +55 -0
  2. package/.claude-plugin/plugin.json +8 -0
  3. package/LICENSE +121 -0
  4. package/README.md +223 -0
  5. package/agents/analyst.md +121 -0
  6. package/agents/architect.md +121 -0
  7. package/agents/builder.md +155 -0
  8. package/agents/closer.md +148 -0
  9. package/agents/knowledge-migrator.md +349 -0
  10. package/agents/microfix-specialist.md +140 -0
  11. package/agents/reviewer.md +220 -0
  12. package/agents/update-coordinator.md +405 -0
  13. package/bin/knowzcode.mjs +869 -0
  14. package/commands/audit.md +108 -0
  15. package/commands/connect-mcp.md +507 -0
  16. package/commands/fix.md +107 -0
  17. package/commands/init.md +320 -0
  18. package/commands/learn.md +308 -0
  19. package/commands/plan.md +125 -0
  20. package/commands/register.md +724 -0
  21. package/commands/status.md +291 -0
  22. package/commands/telemetry-setup.md +368 -0
  23. package/commands/telemetry.md +188 -0
  24. package/commands/work.md +390 -0
  25. package/knowzcode/automation_manifest.md +59 -0
  26. package/knowzcode/claude_code_execution.md +133 -0
  27. package/knowzcode/enterprise/compliance_manifest.md +132 -0
  28. package/knowzcode/enterprise/compliance_status.md +30 -0
  29. package/knowzcode/enterprise/guidelines/code-quality.md +67 -0
  30. package/knowzcode/enterprise/guidelines/custom/.gitkeep +0 -0
  31. package/knowzcode/enterprise/guidelines/security.md +355 -0
  32. package/knowzcode/enterprise/reports/.gitkeep +0 -0
  33. package/knowzcode/enterprise/templates/guideline-template.md +55 -0
  34. package/knowzcode/gitignore.template +13 -0
  35. package/knowzcode/knowzcode_architecture.md +51 -0
  36. package/knowzcode/knowzcode_log.md +142 -0
  37. package/knowzcode/knowzcode_loop.md +515 -0
  38. package/knowzcode/knowzcode_project.md +233 -0
  39. package/knowzcode/knowzcode_tracker.md +40 -0
  40. package/knowzcode/knowzcode_vaults.md +104 -0
  41. package/knowzcode/mcp_config.md +166 -0
  42. package/knowzcode/planning/Readme.md +6 -0
  43. package/knowzcode/platform_adapters.md +388 -0
  44. package/knowzcode/prompts/Execute_Micro_Fix.md +57 -0
  45. package/knowzcode/prompts/Investigate_Codebase.md +227 -0
  46. package/knowzcode/prompts/Migrate_Knowledge.md +301 -0
  47. package/knowzcode/prompts/Refactor_Node.md +72 -0
  48. package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -0
  49. package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -0
  50. package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -0
  51. package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -0
  52. package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -0
  53. package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -0
  54. package/knowzcode/specs/Readme.md +10 -0
  55. package/knowzcode/telemetry_config.md +89 -0
  56. package/knowzcode/user_preferences.md +120 -0
  57. package/package.json +53 -0
  58. package/skills/alias-resolver.json +15 -0
  59. package/skills/architecture-diff.json +12 -0
  60. package/skills/check-installation-status.json +14 -0
  61. package/skills/continue.md +105 -0
  62. package/skills/environment-guard.json +12 -0
  63. package/skills/generate-workgroup-id.json +25 -0
  64. package/skills/install-knowzcode.json +21 -0
  65. package/skills/load-core-context.json +18 -0
  66. package/skills/log-entry-builder.json +15 -0
  67. package/skills/spec-quality-check.json +14 -0
  68. package/skills/spec-template.json +15 -0
  69. package/skills/spec-validator.json +25 -0
  70. package/skills/start-work.md +224 -0
  71. package/skills/tracker-scan.json +12 -0
  72. package/skills/tracker-update.json +28 -0
  73. package/skills/validate-installation.json +14 -0
@@ -0,0 +1,515 @@
1
+ # KnowzCode - Development Methodology & Operational Protocol
2
+
3
+ **Target Audience:** Any AI coding assistant (Claude Code, Codex, Gemini, Cursor, Copilot, etc.)
4
+ **Purpose:** This is your primary operational guide for structured, test-driven development using KnowzCode. Follow these phases precisely when working on any feature or change.
5
+
6
+ ## 1. Core Principles
7
+
8
+ * **Change Set-Driven Development**: Work is performed on a "Change Set" — a group of NodeIDs (new capabilities) and affected files. This ensures system-wide consistency.
9
+ * **Spec-Driven Development**: `knowzcode/specs/[NodeID].md` files define what to build. They are drafted, approved, implemented against, then finalized to "as-built" state.
10
+ * **Mandatory TDD**: Every feature must follow Red-Green-Refactor. No production code without a failing test first.
11
+ * **Quality Gates**: You MUST pause at defined checkpoints for user approval. Never skip phases.
12
+ * **Integrated Version Control**: Strategic commits mark phase transitions.
13
+ * **Proactive Debt Management**: Technical debt is formally tracked, not ignored.
14
+
15
+ ## 2. Core Files Reference
16
+
17
+ * **`knowzcode/knowzcode_project.md`**: Read-only project context.
18
+ * **`knowzcode/knowzcode_architecture.md`**: Architecture docs. Update for simple consistency changes.
19
+ * **`knowzcode/knowzcode_tracker.md`**: Track NodeID statuses and WorkGroup assignments.
20
+ * **`knowzcode/knowzcode_log.md`**: Prepend log entries. Read reference quality criteria.
21
+ * **`knowzcode/specs/[NodeID].md`**: Create, read, and finalize specifications.
22
+ * **`knowzcode/workgroups/<WorkGroupID>.md`**: Session todo list. Every entry must begin with `KnowzCode:`.
23
+ * **This document (`knowzcode/knowzcode_loop.md`)**: Your primary workflow reference.
24
+
25
+ ## 3. The Main Operational Loop
26
+
27
+ ### Phase 1A: Impact Analysis
28
+
29
+ Receive the goal from the user. Identify the **Change Set** — all components affected by this change.
30
+
31
+ **NodeID Granularity**: Create NodeIDs only for NEW capabilities being built, not for every file touched. Files that integrate a new capability are "affected files" — they don't need separate NodeIDs or specs.
32
+
33
+ **Change Set Format:**
34
+ ```markdown
35
+ ## Change Set for WorkGroup [ID]
36
+
37
+ ### New Capabilities (NodeIDs)
38
+ | NodeID | Description |
39
+ |--------|-------------|
40
+ | LIB_DateTimeFormat | Timezone formatting utility |
41
+
42
+ ### Affected Files (no NodeIDs needed)
43
+ - JobsPage.tsx - integrate formatDateTime
44
+ - IntakeJobsPage.tsx - integrate formatDateTime
45
+
46
+ **Specs Required**: 1
47
+ ```
48
+
49
+ **NodeID Naming Convention:**
50
+ NodeIDs must be **domain concepts**, not tasks.
51
+
52
+ 1. **Domain-Area NodeIDs** (default): PascalCase covering cohesive areas
53
+ - Examples: `Authentication`, `FileManagement`, `Checkout`, `UserProfile`
54
+ - Covers multiple components: `Authentication` = login form + auth endpoint + token service
55
+ - Sub-areas when a domain grows large: `Authentication_OAuth`, `Payments_Stripe`
56
+
57
+ 2. **Utility NodeIDs** (exception): For genuinely isolated utilities
58
+ - `LIB_` prefix: `LIB_DateFormat`, `LIB_Validation`
59
+ - `CONFIG_` prefix: `CONFIG_FeatureFlags`
60
+
61
+ 3. **Use Case NodeIDs** (optional): `UC_` for cross-domain workflows
62
+ - Only when genuinely spanning multiple unrelated domains
63
+
64
+ **Never use task-oriented names**: `FIX-001`, `TASK-X`, `FEATURE-Y`. Tasks belong in WorkGroup files.
65
+
66
+ **Consolidation Rule:** Before creating a new NodeID, check existing specs. If >50% domain overlap exists with an existing spec, UPDATE that spec instead. Target <20 specs per project.
67
+
68
+ **Historical Context:** Before proposing the Change Set, scan `knowzcode/workgroups/` for completed WorkGroups that touched similar components. Reference relevant context in your proposal.
69
+
70
+ #### Quality Gate: Change Set Approval
71
+ Present the proposed Change Set to the user. **PAUSE and await user approval.** Do NOT proceed to Phase 1B until the user explicitly approves.
72
+
73
+ Upon approval, generate a unique WorkGroupID and update `knowzcode_tracker.md` for all nodes to `[WIP]`.
74
+
75
+ **WorkGroupID Format**: `kc-{type}-{slug}-YYYYMMDD-HHMMSS`
76
+ - Valid types: `feat`, `fix`, `refactor`, `issue`
77
+ - Slug: 2-4 word kebab-case descriptor from the goal
78
+ - Example: `kc-feat-user-auth-jwt-20250115-143022`
79
+
80
+ ---
81
+
82
+ ### Phase 1B: Specification
83
+
84
+ Draft or refine `knowzcode/specs/[NodeID].md` for all nodes in the Change Set.
85
+
86
+ **Spec Template (4-section format):**
87
+ ```markdown
88
+ # [NodeID]: [Human-Readable Name]
89
+
90
+ **Updated:** [timestamp]
91
+ **Status:** Draft | Approved | As-Built
92
+
93
+ ## Rules & Decisions
94
+ Key architectural decisions, business rules, constraints, and purpose.
95
+ - Decision: chose X over Y because Z
96
+ - Rule: must always validate before persisting
97
+
98
+ ## Interfaces
99
+ Public contracts: inputs, outputs, API signatures, dependencies, events.
100
+ - POST /api/users -> { id, email }
101
+ - Depends on: AuthService for token validation
102
+
103
+ ## Verification Criteria
104
+ Testable assertions for implementation and auditing.
105
+ - VERIFY: when valid credentials, returns JWT token
106
+ - VERIFY: when email exists, returns 409
107
+
108
+ ## Debt & Gaps
109
+ Known limitations and future work.
110
+ - TODO: add rate limiting
111
+ ```
112
+
113
+ **Minimum valid spec:** 1+ Rules item, 1+ Interface item, 2+ `VERIFY:` statements.
114
+
115
+ **Backward compatibility:** Old numbered-section specs remain valid until naturally touched. When finalizing, rewrite in the new format.
116
+
117
+ #### Quality Gate: Spec Approval
118
+ Present drafted specs to the user. **PAUSE and await user approval.** Log "SpecApproved" events.
119
+
120
+ **Pre-Implementation Commit:** After specs are approved, commit `knowzcode/` to create a checkpoint before implementation begins.
121
+
122
+ ---
123
+
124
+ ### Phase 2A: Implementation (TDD MANDATORY)
125
+
126
+ For each NodeID in the approved Change Set:
127
+
128
+ ```
129
+ FOR each feature/criterion in the spec:
130
+
131
+ # RED Phase
132
+ 1. Write a failing test that defines expected behavior
133
+ 2. Run test → Confirm it FAILS
134
+ - If test passes without code, the test is wrong — fix it
135
+
136
+ # GREEN Phase
137
+ 3. Write MINIMAL code to make the test pass
138
+ 4. Run test → Confirm it PASSES
139
+ - If fails, fix code (not test)
140
+
141
+ # REFACTOR Phase
142
+ 5. Review code for improvements
143
+ 6. If refactoring: make change, run ALL tests, revert if any fail
144
+ ```
145
+
146
+ **Verification Loop (must pass before claiming complete):**
147
+ ```
148
+ WHILE verification not complete:
149
+ 1. Run all tests → If FAIL: fix and restart
150
+ 2. Run static analysis → If issues: fix and restart
151
+ 3. Run build → If FAIL: fix and restart
152
+ 4. Verify all VERIFY: criteria from specs → If unmet: implement and restart
153
+ 5. All checks pass → Report complete
154
+ ```
155
+
156
+ **Maximum iterations**: 10. If exceeded, pause and report blocker.
157
+
158
+ #### Quality Gate: Implementation Complete
159
+ Report implementation results including test counts, verification iterations, and criteria status. **PAUSE — the user or an auditor will verify completeness.**
160
+
161
+ ---
162
+
163
+ ### Phase 2B: Completeness Audit
164
+
165
+ An independent, READ-ONLY audit verifying what percentage of specifications were actually implemented.
166
+
167
+ **Process:**
168
+ - Compare implementation against specifications for all NodeIDs
169
+ - Calculate objective completion percentage
170
+ - Report gaps, orphan code, and risk assessment
171
+ - Do NOT modify any code during this phase
172
+
173
+ **Outcomes** (user decides):
174
+ - Return to Phase 2A to complete missing requirements
175
+ - Accept current implementation and proceed to finalization
176
+ - Modify specs to match implementation
177
+ - Cancel the WorkGroup
178
+
179
+ #### Quality Gate: Audit Approval
180
+ Present audit results to the user. **PAUSE for decision.** Only proceed to Phase 3 when the user approves.
181
+
182
+ ---
183
+
184
+ ### Phase 3: Atomic Finalization
185
+
186
+ Once implementation is verified and approved, execute finalization:
187
+
188
+ **Step 7: Finalize Specifications**
189
+ Update each `knowzcode/specs/[NodeID].md` to match the verified "as-built" implementation. Always use the 4-section format.
190
+
191
+ **Step 8: Architecture Check**
192
+ Review `knowzcode/knowzcode_architecture.md` against the Change Set.
193
+ - Simple discrepancies: fix directly and note in log
194
+ - Complex discrepancies: document for user review
195
+
196
+ **Step 9: Log Entry**
197
+ Prepend a comprehensive `ARC-Completion` entry to `knowzcode/knowzcode_log.md`:
198
+ ```markdown
199
+ ---
200
+ **Type:** ARC-Completion
201
+ **Timestamp:** [timestamp]
202
+ **WorkGroupID:** [ID]
203
+ **NodeID(s):** [list all]
204
+ **Logged By:** AI-Agent
205
+ **Details:**
206
+ Successfully implemented and verified the Change Set for [goal].
207
+ - **Verification Summary:** [key checks]
208
+ - **Architectural Learnings:** [discoveries]
209
+ - **Unforeseen Ripple Effects:** [affected nodes outside this WorkGroup, or None]
210
+ - **Specification Finalization:** All specs updated to "as-built" state.
211
+ - **Architecture Check Outcome:** [outcome]
212
+ ---
213
+ ```
214
+
215
+ **Step 10: Update Tracker & Schedule Debt**
216
+ - Change each NodeID status from `[WIP]` to `[VERIFIED]`, clear WorkGroupID
217
+ - If significant tech debt documented, create `REFACTOR_[NodeID]` tasks
218
+ - Check if changes impact `knowzcode_project.md` (new features, stack changes)
219
+
220
+ **Step 11: Final Commit**
221
+ Stage and commit all changes (source code + knowzcode files).
222
+
223
+ **Step 12: Report & Close**
224
+ Report completion, mention any `REFACTOR_` tasks created. WorkGroup is closed.
225
+
226
+ ---
227
+
228
+ ## 4. Micro-Fix Protocol
229
+
230
+ For single-file, no-ripple-effect changes (results in a single `fix:` commit):
231
+
232
+ 1. Implement the small change
233
+ 2. Quick focused verification
234
+ 3. Log a `MicroFix` entry:
235
+ ```markdown
236
+ ---
237
+ **Type:** MicroFix
238
+ **Timestamp:** [timestamp]
239
+ **NodeID(s)/File:** [target]
240
+ **Logged By:** AI-Agent
241
+ **Details:**
242
+ - **User Request:** [description]
243
+ - **Action Taken:** [change made]
244
+ - **Verification:** [method/outcome]
245
+ ---
246
+ ```
247
+ 4. Commit with `fix: [description]`
248
+
249
+ ---
250
+
251
+ ## 5. When to Pause (Quality Gates)
252
+
253
+ You **MUST** pause and await explicit user approval at:
254
+ * After proposing a Change Set (Phase 1A)
255
+ * After presenting specs for approval (Phase 1B)
256
+ * After reporting implementation complete (Phase 2A) — awaiting audit
257
+ * After audit results — awaiting decision on gaps (Phase 2B)
258
+ * If you encounter a critical, unresolvable issue
259
+ * If an architecture discrepancy is too complex to fix autonomously
260
+
261
+ ---
262
+
263
+ ## 6. MCP Integration (Optional but Recommended)
264
+
265
+ If KnowzCode MCP server is configured (`knowzcode/mcp_config.md` or `knowzcode/knowzcode_vaults.md`), agents can leverage vault queries to enhance every phase.
266
+
267
+ ### Phase-Specific Usage
268
+
269
+ | Phase | MCP Tool | Purpose |
270
+ |-------|----------|---------|
271
+ | **1A (Analysis)** | `search_knowledge(research_vault, "past decisions about {domain}")` | Find prior decisions affecting components |
272
+ | **1B (Spec)** | `ask_question(research_vault, "conventions for {component_type}?")` | Check team conventions before drafting |
273
+ | **2A (Build)** | `search_knowledge(code_vault, "{similar_feature} implementation")` | Find reference implementations |
274
+ | **2B (Audit)** | `ask_question(research_vault, "standards for {domain}", researchMode=true)` | Comprehensive standards check |
275
+ | **3 (Close)** | `create_knowledge(research_vault, ...)` | Capture patterns, decisions, workarounds |
276
+
277
+ ### Enterprise: Team Standards
278
+
279
+ At workflow start, if enterprise vault is configured (`knowzcode/enterprise/compliance_manifest.md` has `mcp_compliance_enabled: true`):
280
+ - Pull team-wide standards and merge into quality gate criteria
281
+ - Push audit results to enterprise vault after Phase 2B
282
+ - Push completion records to enterprise vault after Phase 3
283
+
284
+ ### Graceful Degradation
285
+
286
+ All phases work without MCP. MCP enhances analysis depth and organizational learning but never blocks workflow progression. When MCP is unavailable, agents use standard file search tools (grep, glob) as fallback.
287
+
288
+ ---
289
+
290
+ ## 7. Learning Capture (Optional)
291
+
292
+ During finalization, scan the WorkGroup for insight-worthy patterns:
293
+
294
+ | Signal Type | Examples |
295
+ |-------------|----------|
296
+ | Pattern | "created utility for", "reusable", "abstracted" |
297
+ | Decision | "chose X over Y", "opted for", "trade-off" |
298
+ | Workaround | "workaround", "limitation", "can't do X so" |
299
+ | Performance | "optimized", "reduced from X to Y", "cache" |
300
+ | Security | "vulnerability", "sanitize", "authentication fix" |
301
+
302
+ ### Auto-Capture Triggers
303
+
304
+ Learning candidates are detected at each quality gate. If MCP is available, write concrete knowledge entries:
305
+
306
+ **After Phase 1A approval:**
307
+ ```
308
+ If MCP available:
309
+ create_knowledge(research_vault, title="Scope: {goal}",
310
+ content="[NodeIDs] {list}\n[Risk] {assessment}\n[Decision] {user feedback}",
311
+ tags=["scope", "change-set"])
312
+ ```
313
+
314
+ **After Phase 2A completion:**
315
+ - Capture implementation patterns and workarounds discovered during TDD cycles
316
+
317
+ **After Phase 2B audit:**
318
+ ```
319
+ If MCP available:
320
+ create_knowledge(research_vault, title="Audit: {wgid} - {score}%",
321
+ content="[Findings] {gaps}\n[Security] {issues}\n[Decision] {user choice}",
322
+ tags=["audit", "quality"])
323
+ If MCP available AND enterprise vault configured:
324
+ create_knowledge(enterprise_vault, title="Audit: {wgid} - {score}%",
325
+ content="[Findings] {gaps}\n[Security] {issues}\n[Decision] {user choice}",
326
+ tags=["audit", "enterprise"])
327
+ ```
328
+
329
+ **After Phase 3 finalization:**
330
+ - Capture architectural learnings and consolidation decisions (handled by closer agent)
331
+
332
+ ### Capture Protocol
333
+
334
+ If MCP is available:
335
+ 1. Detect learning candidates from WorkGroup file content
336
+ 2. Check for duplicates via `search_knowledge` — skip if substantially similar exists
337
+ 3. Prompt user for approval before saving
338
+ 4. Create learning via `create_knowledge` with appropriate title prefix
339
+
340
+ ### Audit Trail (Enterprise)
341
+
342
+ After Phase 3, if enterprise vault is configured:
343
+ - Push WorkGroup completion record with goal, NodeIDs, audit score, and decisions
344
+ - Push architecture drift findings if any detected during finalization
345
+
346
+ If MCP is not available, skip learning capture and audit trail — all other phases work normally.
347
+
348
+ ---
349
+
350
+ ## 8. Multi-Agent Execution (Platform-Specific)
351
+
352
+ Phases can be executed by a single AI sequentially or by specialized agents coordinated by a lead. Quality gates and phase sequence remain the same regardless of execution model.
353
+
354
+ ### Agent-to-Phase Mapping
355
+
356
+ | Phase | Specialist Agent | Expertise |
357
+ |-------|-----------------|-----------|
358
+ | 1A | analyst | Impact analysis, Change Set proposals |
359
+ | 1B | architect | Specification drafting, architecture review |
360
+ | 2A | builder | TDD implementation, verification loops |
361
+ | 2B | reviewer | Quality audit, security review |
362
+ | 3 | closer | Finalization, learning capture |
363
+
364
+ ### Execution Rules
365
+
366
+ When using multi-agent execution:
367
+ - Each phase maps to a specialist agent
368
+ - Phase dependencies enforce quality gates (1A must complete before 1B, etc.)
369
+ - User approves transitions between phases at quality gates
370
+ - Agents can communicate about gaps and blockers
371
+ - The lead agent coordinates but does not modify code directly
372
+ - Agents read context files independently — do not duplicate context across agents
373
+
374
+ ### Single-Agent Execution
375
+
376
+ When a single AI handles all phases sequentially:
377
+ - Follow the same phase sequence and quality gates
378
+ - Pause at each gate for user approval
379
+ - All quality standards apply identically
380
+
381
+ ### Sequential Execution Protocol (for platforms without orchestration)
382
+
383
+ For platforms like Cursor, Copilot, or Windsurf where there is no agent orchestration:
384
+
385
+ ```
386
+ FOR each phase in [1A, 1B, 2A, 2B, 3]:
387
+
388
+ 1. Read the phase prompt: knowzcode/prompts/[LOOP_{phase}]__*.md
389
+ 2. Read the WorkGroup file: knowzcode/workgroups/{WorkGroupID}.md
390
+ 3. Execute the phase instructions
391
+ 4. Write output to the WorkGroup file (prefix entries with "KnowzCode:")
392
+ 5. STOP at quality gate — present results to user
393
+ 6. Wait for user approval before reading the next phase prompt
394
+ ```
395
+
396
+ **Key differences from orchestrated execution:**
397
+ - The user manually triggers each phase transition
398
+ - Context is carried via WorkGroup files, not inter-agent messaging
399
+ - All phase prompts are self-contained — they read context from knowzcode/ files
400
+ - Quality gates work identically (user approval required at each gate)
401
+
402
+ **Minimal viable execution** (no platform adapter needed):
403
+ 1. Copy `knowzcode/` directory to your project
404
+ 2. Give your AI the Phase 1A prompt with your goal
405
+ 3. When the AI pauses, review output and give the next phase prompt
406
+ 4. Repeat until Phase 3 completes
407
+
408
+ See your platform's adapter file for agent configuration details.
409
+
410
+ ---
411
+
412
+ ## 9. Context Handoff Protocol
413
+
414
+ When phases transition (whether via agents or sequentially), the following data MUST be communicated to the next phase:
415
+
416
+ ### 1A → 1B Handoff
417
+ - WorkGroupID
418
+ - Approved Change Set (NodeIDs + affected files)
419
+ - Risk assessment and classification
420
+ - Historical context from prior WorkGroups
421
+ - User-approved scope boundaries
422
+
423
+ ### 1B → 2A Handoff
424
+ - WorkGroupID
425
+ - Approved specifications (file paths)
426
+ - Tracker state (all NodeIDs marked `[WIP]`)
427
+ - Compliance constraints (if enterprise enabled)
428
+ - Pre-implementation commit hash
429
+
430
+ ### 2A → 2B Handoff
431
+ - WorkGroupID
432
+ - Implementation artifacts (changed files list)
433
+ - Test results (pass counts, coverage)
434
+ - Verification iteration count
435
+ - Any `[SPEC_ISSUE]` tags (see below)
436
+
437
+ ### 2B → 3 Handoff
438
+ - WorkGroupID
439
+ - Audit report with completion percentage
440
+ - Gap list with severity assessment
441
+ - User decision (proceed / return to 2A / modify specs)
442
+ - Security findings summary
443
+
444
+ On platforms with multi-agent orchestration, the lead agent manages this context. On platforms without orchestration, the user carries context by referencing WorkGroup files between phases.
445
+
446
+ ---
447
+
448
+ ## 10. Spec Issues During Implementation
449
+
450
+ If the builder discovers a spec is incorrect or incomplete during Phase 2A:
451
+
452
+ 1. **Tag the issue**: Add `[SPEC_ISSUE]` comment in the WorkGroup file with details
453
+ 2. **Continue implementing**: Use best judgment for the affected criterion
454
+ 3. **Report in completion**: Include spec issues in the Phase 2A completion report
455
+ 4. **Phase 2B catches it**: The auditor flags spec-vs-implementation divergences
456
+ 5. **User decides**: At the 2B quality gate, the user can update specs or accept the deviation
457
+
458
+ Builders MUST NOT silently deviate from specs. Every deviation must be tagged and reported.
459
+
460
+ ---
461
+
462
+ ## 11. Blocker Escalation Protocol
463
+
464
+ When the verification loop reaches the maximum iteration count (10 for implementation, 5 for micro-fix):
465
+
466
+ ### Blocker Report Format
467
+
468
+ ```markdown
469
+ ## Blocker Report: {WorkGroupID}
470
+
471
+ **Phase:** 2A Implementation
472
+ **Iteration Count:** 10 (maximum reached)
473
+ **NodeID(s) Affected:** [list]
474
+
475
+ ### Root Cause Analysis
476
+ - **Failing Check:** [test name / build error / lint issue]
477
+ - **Error Message:** [exact message]
478
+ - **Attempts Made:** [summary of fix attempts]
479
+
480
+ ### Recommended Recovery Options
481
+ 1. **Modify spec**: Relax or adjust the criterion that cannot be met
482
+ 2. **Change approach**: Use a different implementation strategy
483
+ 3. **Split WorkGroup**: Extract the blocked NodeID into a separate WorkGroup
484
+ 4. **Accept partial**: Proceed with documented gap (debt item)
485
+ 5. **Cancel**: Abandon this WorkGroup
486
+
487
+ ### Files Involved
488
+ - [list of files with the issue]
489
+ ```
490
+
491
+ The user MUST select a recovery option before work continues.
492
+
493
+ ---
494
+
495
+ ## 12. Workflow Abandonment Protocol
496
+
497
+ If a WorkGroup needs to be abandoned mid-workflow:
498
+
499
+ 1. **Revert uncommitted changes**: If implementation was in progress, revert source code changes (keep knowzcode files)
500
+ 2. **Update tracker**: Set all affected NodeIDs back to their pre-WorkGroup status
501
+ 3. **Log abandonment**: Create a log entry with type `WorkGroup-Abandoned` including the reason
502
+ 4. **Close WorkGroup file**: Mark the WorkGroup file as abandoned with reason
503
+ 5. **Preserve learnings**: If any useful patterns were discovered, capture them before closing
504
+
505
+ ```markdown
506
+ ---
507
+ **Type:** WorkGroup-Abandoned
508
+ **Timestamp:** [timestamp]
509
+ **WorkGroupID:** [ID]
510
+ **Phase At Abandonment:** [1A/1B/2A/2B/3]
511
+ **Reason:** [user decision / blocker / scope change]
512
+ **NodeID(s) Affected:** [list with their reverted statuses]
513
+ **Learnings Preserved:** [any useful insights, or None]
514
+ ---
515
+ ```