knowzcode 0.3.7 → 0.4.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.
- package/.claude-plugin/marketplace.json +61 -61
- package/.claude-plugin/plugin.json +8 -8
- package/LICENSE +121 -121
- package/README.md +354 -320
- package/agents/analyst.md +114 -114
- package/agents/architect.md +200 -200
- package/agents/builder.md +104 -104
- package/agents/closer.md +177 -177
- package/agents/context-scout.md +54 -54
- package/agents/knowledge-migrator.md +349 -349
- package/agents/knowz-scout.md +83 -83
- package/agents/knowz-scribe.md +180 -180
- package/agents/microfix-specialist.md +135 -135
- package/agents/project-advisor.md +111 -111
- package/agents/reviewer.md +172 -172
- package/agents/security-officer.md +194 -194
- package/agents/test-advisor.md +162 -162
- package/agents/update-coordinator.md +394 -394
- package/bin/knowzcode.mjs +1199 -956
- package/commands/audit.md +328 -328
- package/commands/connect-mcp.md +549 -549
- package/commands/fix.md +107 -107
- package/commands/init.md +500 -439
- package/commands/learn.md +332 -332
- package/commands/plan.md +272 -272
- package/commands/register.md +733 -733
- package/commands/status.md +309 -309
- package/commands/telemetry-setup.md +368 -368
- package/commands/telemetry.md +188 -188
- package/commands/work.md +1204 -1202
- package/knowzcode/automation_manifest.md +59 -59
- package/knowzcode/claude_code_execution.md +431 -420
- package/knowzcode/copilot_execution.md +231 -231
- package/knowzcode/enterprise/compliance_manifest.md +137 -137
- package/knowzcode/enterprise/compliance_status.md +30 -30
- package/knowzcode/enterprise/guidelines/code-quality.md +67 -67
- package/knowzcode/enterprise/guidelines/security.md +355 -355
- package/knowzcode/enterprise/templates/guideline-template.md +55 -55
- package/knowzcode/gitignore.template +13 -13
- package/knowzcode/knowzcode_architecture.md +51 -51
- package/knowzcode/knowzcode_log.md +142 -142
- package/knowzcode/knowzcode_loop.md +596 -596
- package/knowzcode/knowzcode_orchestration.md +66 -66
- package/knowzcode/knowzcode_project.md +48 -48
- package/knowzcode/knowzcode_tracker.md +40 -40
- package/knowzcode/knowzcode_vaults.md +257 -257
- package/knowzcode/mcp_config.md +191 -191
- package/knowzcode/planning/Readme.md +6 -6
- package/knowzcode/platform_adapters.md +1260 -1047
- package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
- package/knowzcode/prompts/Investigate_Codebase.md +227 -227
- package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
- package/knowzcode/prompts/Refactor_Node.md +72 -72
- package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
- package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
- package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
- package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
- package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
- package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
- package/knowzcode/specs/Readme.md +10 -10
- package/knowzcode/telemetry_config.md +89 -89
- package/knowzcode/user_preferences.md +120 -120
- package/package.json +53 -53
- package/skills/alias-resolver.json +1 -1
- package/skills/architecture-diff.json +1 -1
- package/skills/check-installation-status.json +1 -1
- package/skills/continue.md +126 -126
- package/skills/environment-guard.json +1 -1
- package/skills/generate-workgroup-id.json +1 -1
- package/skills/install-knowzcode.json +1 -1
- package/skills/load-core-context.json +1 -1
- package/skills/log-entry-builder.json +1 -1
- package/skills/spec-quality-check.json +1 -1
- package/skills/spec-template.json +1 -1
- package/skills/spec-validator.json +1 -1
- package/skills/start-work.md +224 -224
- package/skills/tracker-scan.json +1 -1
- package/skills/tracker-update.json +1 -1
- package/skills/validate-installation.json +1 -1
|
@@ -1,596 +1,596 @@
|
|
|
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
|
-
### 3.1 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. In autonomous mode, auto-approve and proceed immediately (see Section 5).
|
|
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
|
-
### 3.2 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. In autonomous mode, auto-approve and proceed immediately (see Section 5).
|
|
119
|
-
|
|
120
|
-
**Pre-Implementation Commit:** After specs are approved, commit `knowzcode/` to create a checkpoint before implementation begins.
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
### 3.3 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
|
-
### 3.4 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. In autonomous mode, auto-approve and proceed immediately unless safety exceptions apply (see Section 5).
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
### 3.5 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
|
-
### Autonomous Mode Override
|
|
262
|
-
|
|
263
|
-
When the user conveys intent for autonomous operation — through natural language (e.g., "approve all", "preapprove", "autonomous mode", "just run through", "I trust your judgement") or the `--autonomous` flag — quality gates above are still **presented** for transparency but **auto-approved** without waiting for user input. The workflow runs from start to finalization uninterrupted.
|
|
264
|
-
|
|
265
|
-
The lead should interpret the **spirit** of the user's instruction, not just exact keyword matches. If the user clearly wants the workflow to proceed without stopping, that constitutes autonomous mode activation.
|
|
266
|
-
|
|
267
|
-
**Safety exceptions** — ALWAYS pause even in autonomous mode:
|
|
268
|
-
* Critical, unresolvable blockers (Section 11)
|
|
269
|
-
* Security vulnerabilities rated HIGH or CRITICAL
|
|
270
|
-
* >3 failures on the same phase
|
|
271
|
-
* Architecture discrepancies too complex to fix autonomously
|
|
272
|
-
* >3 gap-fix iterations per partition without resolution
|
|
273
|
-
|
|
274
|
-
Autonomous mode is per-WorkGroup and does not carry over.
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## 6. MCP Integration (Optional but Recommended)
|
|
279
|
-
|
|
280
|
-
If KnowzCode MCP server is configured (`knowzcode/mcp_config.md` or `knowzcode/knowzcode_vaults.md`), agents can leverage vault queries to enhance every phase.
|
|
281
|
-
|
|
282
|
-
**Before using MCP, read `knowzcode/knowzcode_vaults.md` to resolve vault IDs by type.** Use the vault's description to confirm the query is appropriate for that vault. If a single vault covers all types, use it for everything. Never hardcode vault names — always resolve from config.
|
|
283
|
-
|
|
284
|
-
### Vault Types
|
|
285
|
-
|
|
286
|
-
| Type | Purpose | Example Queries |
|
|
287
|
-
|------|---------|-----------------|
|
|
288
|
-
| **code** | Reference implementations, code snippets, API patterns | `"authentication middleware pattern"`, `"error handling in {framework}"` |
|
|
289
|
-
| **ecosystem** | Business rules, conventions, decisions, integrations, platform knowledge | `"checkout flow rules"`, `"pricing constraints"`, `"Stripe webhook setup"` |
|
|
290
|
-
| **finalizations** | WorkGroup completion summaries, outcome records | `"past decisions about {component}"`, `"similar WorkGroups"` |
|
|
291
|
-
|
|
292
|
-
A project may configure one vault covering all types (common for small teams) or multiple specialized vaults. Knowz-scribe (or direct MCP calls) writes to vaults; knowz-scout has read access only. The scribe is the primary capture agent that routes writes to the correct vault based on content type.
|
|
293
|
-
|
|
294
|
-
### Phase-Specific Usage
|
|
295
|
-
|
|
296
|
-
| Phase | MCP Tool | Purpose |
|
|
297
|
-
|-------|----------|---------|
|
|
298
|
-
| **1A (Analysis)** | `search_knowledge({vault matching "ecosystem" type}, "past decisions about {domain}")` | Find prior decisions affecting components |
|
|
299
|
-
| **1B (Spec)** | `ask_question({vault matching "ecosystem" type}, "conventions for {component_type}?")` | Check team conventions before drafting |
|
|
300
|
-
| **2A (Build)** | `search_knowledge({vault matching "code" type}, "{similar_feature} implementation")` | Find reference implementations |
|
|
301
|
-
| **2B (Audit)** | `ask_question({vault matching "ecosystem" type}, "standards for {domain}", researchMode=true)` | Comprehensive standards check |
|
|
302
|
-
| **3 (Close)** | Delegate to knowz-scribe (or `create_knowledge` directly if no scribe) | Capture patterns, decisions, workarounds |
|
|
303
|
-
|
|
304
|
-
### Knowz-Scribe (Multi-Agent Platforms)
|
|
305
|
-
|
|
306
|
-
On platforms with multi-agent orchestration (e.g., Claude Code Agent Teams), **knowz-scribe** has full read/write access to MCP vaults, and **knowz-scout** has read access to MCP vaults. Both have read/write access to local knowzcode files:
|
|
307
|
-
|
|
308
|
-
- Both spawned at workflow start (persistent agents, Stage 0 through Phase 3)
|
|
309
|
-
- **Knowz-scribe** is the primary capture agent — receives capture messages from teammates at each quality gate (e.g., `"Capture Phase 1A: {wgid}"`), reads the WorkGroup file, extracts learnings, and writes to the appropriate vault. Handles deduplication, formatting, and routing to the correct vault by type.
|
|
310
|
-
- **Knowz-scout** is the primary research agent — queries vaults for business context, conventions, and past decisions.
|
|
311
|
-
- Both stay alive through the entire workflow, shut down after Phase 3 capture
|
|
312
|
-
|
|
313
|
-
On platforms without multi-agent orchestration, the closer handles vault writes directly (see Section 7).
|
|
314
|
-
|
|
315
|
-
### Enterprise: Team Standards
|
|
316
|
-
|
|
317
|
-
At workflow start, if an enterprise-type vault is configured (read `knowzcode/knowzcode_vaults.md` to find vault matching type "enterprise", then check `knowzcode/enterprise/compliance_manifest.md` for `mcp_compliance_enabled: true`):
|
|
318
|
-
- Pull team-wide standards and merge into quality gate criteria
|
|
319
|
-
- Push audit results to the resolved enterprise vault after Phase 2B
|
|
320
|
-
- Push completion records to the resolved enterprise vault after Phase 3
|
|
321
|
-
|
|
322
|
-
### Graceful Degradation
|
|
323
|
-
|
|
324
|
-
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.
|
|
325
|
-
|
|
326
|
-
---
|
|
327
|
-
|
|
328
|
-
## 7. Learning Capture (Optional)
|
|
329
|
-
|
|
330
|
-
> **Vault content must be detailed and self-contained.** Vault entries are retrieved via semantic search — not read directly like local files. Include full reasoning, specific technology names, code examples, and file paths. See `knowzcode/knowzcode_vaults.md` Content Detail Principle.
|
|
331
|
-
|
|
332
|
-
During finalization, scan the WorkGroup for insight-worthy patterns:
|
|
333
|
-
|
|
334
|
-
| Signal Type | Examples |
|
|
335
|
-
|-------------|----------|
|
|
336
|
-
| Pattern | "created utility for", "reusable", "abstracted" |
|
|
337
|
-
| Decision | "chose X over Y", "opted for", "trade-off" |
|
|
338
|
-
| Workaround | "workaround", "limitation", "can't do X so" |
|
|
339
|
-
| Performance | "optimized", "reduced from X to Y", "cache" |
|
|
340
|
-
| Security | "vulnerability", "sanitize", "authentication fix" |
|
|
341
|
-
| Convention | "established convention", "team standard", "naming pattern", "agreed to always" |
|
|
342
|
-
| Integration | "API integration", "upstream API changed", "service dependency", "webhook" |
|
|
343
|
-
| Scope | "included because", "excluded because", "out of scope", "deferred to" |
|
|
344
|
-
|
|
345
|
-
### Auto-Capture Triggers
|
|
346
|
-
|
|
347
|
-
Learning candidates are detected at each quality gate.
|
|
348
|
-
|
|
349
|
-
**Multi-agent platforms (knowz-scribe active):**
|
|
350
|
-
|
|
351
|
-
At each quality gate, send a message to the knowz-scribe with the phase identifier:
|
|
352
|
-
- After Phase 1A approval: `"Capture Phase 1A: {wgid}"`
|
|
353
|
-
- After Phase 2A completion: `"Capture Phase 2A: {wgid}"`
|
|
354
|
-
- After Phase 2B audit: `"Capture Phase 2B: {wgid}"`
|
|
355
|
-
- After Phase 3 finalization: `"Capture Phase 3: {wgid}"`
|
|
356
|
-
|
|
357
|
-
The knowz-scribe reads the WorkGroup file, extracts relevant data, checks for duplicates, and writes to the appropriate vault. No other agent should call `create_knowledge` when the scribe is active.
|
|
358
|
-
|
|
359
|
-
**Ad-hoc captures (any agent, any time):**
|
|
360
|
-
|
|
361
|
-
Any agent can send knowledge to the knowz-scribe outside phase boundaries:
|
|
362
|
-
- `"Log: {description}"` — explicit capture, scribe must write it (decides vault routing)
|
|
363
|
-
- `"Consider: {description}"` — soft capture, scribe evaluates whether to log and where
|
|
364
|
-
|
|
365
|
-
The scribe handles routing, dedup, and formatting for both modes. If MCP is unavailable, captures are queued to `knowzcode/pending_captures.md` for later sync.
|
|
366
|
-
|
|
367
|
-
**Single-agent / no scribe (direct MCP writes):**
|
|
368
|
-
|
|
369
|
-
If MCP is available but no knowz-scribe, resolve vault IDs from `knowzcode/knowzcode_vaults.md` before writing:
|
|
370
|
-
|
|
371
|
-
- After Phase 1A: `create_knowledge({ecosystem_vault}, title="Scope: {descriptive goal summary}", content="[CONTEXT] {problem description, what prompted this work, constraints}\n[INSIGHT] {scope decisions — what's included/excluded and why}\n[RATIONALE] {risk assessment with full reasoning, affected files, mitigation}\n[TAGS] scope, {domain}", tags=["scope", "{domain}"])`
|
|
372
|
-
- After Phase 2A: Capture implementation patterns and workarounds discovered during TDD cycles — include specific file paths, code examples, and the problem each pattern solves
|
|
373
|
-
- After Phase 2B: `create_knowledge({ecosystem_vault}, title="Audit: {wgid} - {score}% — {key finding summary}", content="[CONTEXT] {what was audited, scope of the review}\n[INSIGHT] {specific gaps with file paths and line references, security findings with severity reasoning}\n[RATIONALE] {gap resolution decisions — what was deferred vs fixed and why}\n[TAGS] audit, {domain}", tags=["audit", "{domain}"])`
|
|
374
|
-
- After Phase 2B (enterprise): If enterprise vault configured and compliance enabled, push audit results to enterprise vault
|
|
375
|
-
- After Phase 3: Capture architectural learnings and consolidation decisions (handled by closer agent)
|
|
376
|
-
|
|
377
|
-
### Capture Protocol
|
|
378
|
-
|
|
379
|
-
**When knowz-scribe is active (multi-agent platforms):**
|
|
380
|
-
1. Send capture message to knowz-scribe with phase identifier and WorkGroup ID
|
|
381
|
-
2. The scribe handles: vault ID resolution, duplicate checking, user approval prompting, and writing
|
|
382
|
-
3. No other agent should call `create_knowledge` directly
|
|
383
|
-
|
|
384
|
-
**When no knowz-scribe (single-agent / sequential):**
|
|
385
|
-
1. Read `knowzcode/knowzcode_vaults.md` to resolve vault IDs by type
|
|
386
|
-
2. Detect learning candidates from WorkGroup file content
|
|
387
|
-
3. Check for duplicates via `search_knowledge` — skip if substantially similar exists
|
|
388
|
-
4. Prompt user for approval before saving
|
|
389
|
-
5. Only write if the targeted vault is configured — skip gracefully if not
|
|
390
|
-
6. Create learning via `create_knowledge` with appropriate title prefix
|
|
391
|
-
|
|
392
|
-
### Audit Trail (Enterprise)
|
|
393
|
-
|
|
394
|
-
After Phase 3:
|
|
395
|
-
1. Read `knowzcode/knowzcode_vaults.md` to find vault matching type "enterprise"
|
|
396
|
-
2. Only push if an enterprise vault is configured
|
|
397
|
-
- Push WorkGroup completion record with goal, NodeIDs, audit score, and decisions
|
|
398
|
-
- Push architecture drift findings if any detected during finalization
|
|
399
|
-
|
|
400
|
-
If MCP is not available, skip learning capture and audit trail — all other phases work normally.
|
|
401
|
-
|
|
402
|
-
---
|
|
403
|
-
|
|
404
|
-
## 8. Multi-Agent Execution (Platform-Specific)
|
|
405
|
-
|
|
406
|
-
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.
|
|
407
|
-
|
|
408
|
-
### Agent-to-Phase Mapping
|
|
409
|
-
|
|
410
|
-
| Phase | Specialist Agent | Expertise |
|
|
411
|
-
|-------|-----------------|-----------|
|
|
412
|
-
| 1A | analyst | Impact analysis, Change Set proposals |
|
|
413
|
-
| 1B | architect | Specification drafting, architecture review |
|
|
414
|
-
| 2A | builder | TDD implementation, verification loops |
|
|
415
|
-
| 2B | reviewer | Quality audit, security review |
|
|
416
|
-
| 3 | closer | Finalization, learning capture |
|
|
417
|
-
|
|
418
|
-
### Execution Rules
|
|
419
|
-
|
|
420
|
-
When using multi-agent execution:
|
|
421
|
-
- Each phase maps to a specialist agent
|
|
422
|
-
- Phase dependencies enforce quality gates (1A must complete before 1B, etc.)
|
|
423
|
-
- User approves transitions between phases at quality gates
|
|
424
|
-
- Agents can communicate about gaps and blockers
|
|
425
|
-
- The lead agent coordinates but does not modify code directly
|
|
426
|
-
- Agents read context files independently — do not duplicate context across agents
|
|
427
|
-
|
|
428
|
-
### Single-Agent Execution
|
|
429
|
-
|
|
430
|
-
When a single AI handles all phases sequentially:
|
|
431
|
-
- Follow the same phase sequence and quality gates
|
|
432
|
-
- Pause at each gate for user approval
|
|
433
|
-
- All quality standards apply identically
|
|
434
|
-
|
|
435
|
-
### Parallel Execution (Multi-Agent Platforms)
|
|
436
|
-
|
|
437
|
-
On platforms supporting concurrent agents (Claude Code Agent Teams, future multi-agent runtimes):
|
|
438
|
-
|
|
439
|
-
#### Parallelism Boundaries
|
|
440
|
-
- **Between phases**: Phase 1A must produce Change Set before 1B drafts specs (scope must be approved first)
|
|
441
|
-
- **Within phases**: Independent NodeIDs can be implemented/audited in parallel
|
|
442
|
-
- **Across phases**: Incremental review can start on completed components while other components are still being implemented
|
|
443
|
-
- **Agent persistence**: Agents can stay alive across sub-phases to avoid cold-start overhead (e.g., builder persists through audit gap loop)
|
|
444
|
-
|
|
445
|
-
#### Dependency Map
|
|
446
|
-
The analyst produces a dependency map alongside the Change Set, identifying:
|
|
447
|
-
- Which NodeIDs share affected files (must be implemented sequentially or by same agent)
|
|
448
|
-
- Which NodeIDs are independent (can be implemented in parallel)
|
|
449
|
-
- Sequential dependencies (NodeID-B requires NodeID-A's output)
|
|
450
|
-
|
|
451
|
-
#### Incremental Review
|
|
452
|
-
The reviewer can audit completed NodeIDs before all implementation finishes. Gap findings are routed back to the implementer for targeted fixes, then re-audited. Agents persist through this gap loop — no respawning.
|
|
453
|
-
|
|
454
|
-
#### Context Scouts
|
|
455
|
-
Dedicated context-gathering agents can run in parallel with core analysis:
|
|
456
|
-
- Local context scout: reads project history, specs, workgroups
|
|
457
|
-
- Knowz scout: queries and writes to knowledge management vaults for business context (full read/write access)
|
|
458
|
-
Both broadcast findings to inform analyst and architect work.
|
|
459
|
-
|
|
460
|
-
### Sequential Execution Protocol (for platforms without orchestration)
|
|
461
|
-
|
|
462
|
-
For platforms like Cursor, Copilot, or Windsurf where there is no agent orchestration.
|
|
463
|
-
|
|
464
|
-
**Copilot users:** Instead of manually reading phase prompts, use `#prompt:kc-*` prompt files in VS Code Copilot Chat (e.g., `#prompt:kc-work`, `#prompt:kc-specify`). These prompt files encode the sequential protocol below with `#file:` references for context. See `knowzcode/copilot_execution.md` for the full Copilot execution guide.
|
|
465
|
-
|
|
466
|
-
```
|
|
467
|
-
FOR each phase in [1A, 1B, 2A, 2B, 3]:
|
|
468
|
-
|
|
469
|
-
1. Read the phase prompt: knowzcode/prompts/[LOOP_{phase}]__*.md
|
|
470
|
-
2. Read the WorkGroup file: knowzcode/workgroups/{WorkGroupID}.md
|
|
471
|
-
3. Execute the phase instructions
|
|
472
|
-
4. Write output to the WorkGroup file (prefix entries with "KnowzCode:")
|
|
473
|
-
5. STOP at quality gate — present results to user
|
|
474
|
-
6. Wait for user approval before reading the next phase prompt
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
**Key differences from orchestrated execution:**
|
|
478
|
-
- The user manually triggers each phase transition
|
|
479
|
-
- Context is carried via WorkGroup files, not inter-agent messaging
|
|
480
|
-
- All phase prompts are self-contained — they read context from knowzcode/ files
|
|
481
|
-
- Quality gates work identically (user approval required at each gate)
|
|
482
|
-
|
|
483
|
-
**Minimal viable execution** (no platform adapter needed):
|
|
484
|
-
1. Copy `knowzcode/` directory to your project
|
|
485
|
-
2. Give your AI the Phase 1A prompt with your goal
|
|
486
|
-
3. When the AI pauses, review output and give the next phase prompt
|
|
487
|
-
4. Repeat until Phase 3 completes
|
|
488
|
-
|
|
489
|
-
See your platform's adapter file for agent configuration details.
|
|
490
|
-
|
|
491
|
-
---
|
|
492
|
-
|
|
493
|
-
## 9. Context Handoff Protocol
|
|
494
|
-
|
|
495
|
-
When phases transition (whether via agents or sequentially), the following data MUST be communicated to the next phase:
|
|
496
|
-
|
|
497
|
-
### 1A → 1B Handoff
|
|
498
|
-
- WorkGroupID
|
|
499
|
-
- Approved Change Set (NodeIDs + affected files)
|
|
500
|
-
- Risk assessment and classification
|
|
501
|
-
- Historical context from prior WorkGroups
|
|
502
|
-
- User-approved scope boundaries
|
|
503
|
-
|
|
504
|
-
### 1B → 2A Handoff
|
|
505
|
-
- WorkGroupID
|
|
506
|
-
- Approved specifications (file paths)
|
|
507
|
-
- Tracker state (all NodeIDs marked `[WIP]`)
|
|
508
|
-
- Compliance constraints (if enterprise enabled)
|
|
509
|
-
- Pre-implementation commit hash
|
|
510
|
-
|
|
511
|
-
### 2A → 2B Handoff
|
|
512
|
-
- WorkGroupID
|
|
513
|
-
- Implementation artifacts (changed files list)
|
|
514
|
-
- Test results (pass counts, coverage)
|
|
515
|
-
- Verification iteration count
|
|
516
|
-
- Any `[SPEC_ISSUE]` tags (see below)
|
|
517
|
-
|
|
518
|
-
### 2B → 3 Handoff
|
|
519
|
-
- WorkGroupID
|
|
520
|
-
- Audit report with completion percentage
|
|
521
|
-
- Gap list with severity assessment
|
|
522
|
-
- User decision (proceed / return to 2A / modify specs)
|
|
523
|
-
- Security findings summary
|
|
524
|
-
|
|
525
|
-
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.
|
|
526
|
-
|
|
527
|
-
---
|
|
528
|
-
|
|
529
|
-
## 10. Spec Issues During Implementation
|
|
530
|
-
|
|
531
|
-
If the builder discovers a spec is incorrect or incomplete during Phase 2A:
|
|
532
|
-
|
|
533
|
-
1. **Tag the issue**: Add `[SPEC_ISSUE]` comment in the WorkGroup file with details
|
|
534
|
-
2. **Continue implementing**: Use best judgment for the affected criterion
|
|
535
|
-
3. **Report in completion**: Include spec issues in the Phase 2A completion report
|
|
536
|
-
4. **Phase 2B catches it**: The auditor flags spec-vs-implementation divergences
|
|
537
|
-
5. **User decides**: At the 2B quality gate, the user can update specs or accept the deviation
|
|
538
|
-
|
|
539
|
-
Builders MUST NOT silently deviate from specs. Every deviation must be tagged and reported.
|
|
540
|
-
|
|
541
|
-
---
|
|
542
|
-
|
|
543
|
-
## 11. Blocker Escalation Protocol
|
|
544
|
-
|
|
545
|
-
When the verification loop reaches the maximum iteration count (10 for implementation, 5 for micro-fix):
|
|
546
|
-
|
|
547
|
-
### Blocker Report Format
|
|
548
|
-
|
|
549
|
-
```markdown
|
|
550
|
-
## Blocker Report: {WorkGroupID}
|
|
551
|
-
|
|
552
|
-
**Phase:** 2A Implementation
|
|
553
|
-
**Iteration Count:** 10 (maximum reached)
|
|
554
|
-
**NodeID(s) Affected:** [list]
|
|
555
|
-
|
|
556
|
-
### Root Cause Analysis
|
|
557
|
-
- **Failing Check:** [test name / build error / lint issue]
|
|
558
|
-
- **Error Message:** [exact message]
|
|
559
|
-
- **Attempts Made:** [summary of fix attempts]
|
|
560
|
-
|
|
561
|
-
### Recommended Recovery Options
|
|
562
|
-
1. **Modify spec**: Relax or adjust the criterion that cannot be met
|
|
563
|
-
2. **Change approach**: Use a different implementation strategy
|
|
564
|
-
3. **Split WorkGroup**: Extract the blocked NodeID into a separate WorkGroup
|
|
565
|
-
4. **Accept partial**: Proceed with documented gap (debt item)
|
|
566
|
-
5. **Cancel**: Abandon this WorkGroup
|
|
567
|
-
|
|
568
|
-
### Files Involved
|
|
569
|
-
- [list of files with the issue]
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
The user MUST select a recovery option before work continues.
|
|
573
|
-
|
|
574
|
-
---
|
|
575
|
-
|
|
576
|
-
## 12. Workflow Abandonment Protocol
|
|
577
|
-
|
|
578
|
-
If a WorkGroup needs to be abandoned mid-workflow:
|
|
579
|
-
|
|
580
|
-
1. **Revert uncommitted changes**: If implementation was in progress, revert source code changes (keep knowzcode files)
|
|
581
|
-
2. **Update tracker**: Set all affected NodeIDs back to their pre-WorkGroup status
|
|
582
|
-
3. **Log abandonment**: Create a log entry with type `WorkGroup-Abandoned` including the reason
|
|
583
|
-
4. **Close WorkGroup file**: Mark the WorkGroup file as abandoned with reason
|
|
584
|
-
5. **Preserve learnings**: If any useful patterns were discovered, capture them before closing
|
|
585
|
-
|
|
586
|
-
```markdown
|
|
587
|
-
---
|
|
588
|
-
**Type:** WorkGroup-Abandoned
|
|
589
|
-
**Timestamp:** [timestamp]
|
|
590
|
-
**WorkGroupID:** [ID]
|
|
591
|
-
**Phase At Abandonment:** [1A/1B/2A/2B/3]
|
|
592
|
-
**Reason:** [user decision / blocker / scope change]
|
|
593
|
-
**NodeID(s) Affected:** [list with their reverted statuses]
|
|
594
|
-
**Learnings Preserved:** [any useful insights, or None]
|
|
595
|
-
---
|
|
596
|
-
```
|
|
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
|
+
### 3.1 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. In autonomous mode, auto-approve and proceed immediately (see Section 5).
|
|
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
|
+
### 3.2 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. In autonomous mode, auto-approve and proceed immediately (see Section 5).
|
|
119
|
+
|
|
120
|
+
**Pre-Implementation Commit:** After specs are approved, commit `knowzcode/` to create a checkpoint before implementation begins.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### 3.3 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
|
+
### 3.4 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. In autonomous mode, auto-approve and proceed immediately unless safety exceptions apply (see Section 5).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### 3.5 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
|
+
### Autonomous Mode Override
|
|
262
|
+
|
|
263
|
+
When the user conveys intent for autonomous operation — through natural language (e.g., "approve all", "preapprove", "autonomous mode", "just run through", "I trust your judgement") or the `--autonomous` flag — quality gates above are still **presented** for transparency but **auto-approved** without waiting for user input. The workflow runs from start to finalization uninterrupted.
|
|
264
|
+
|
|
265
|
+
The lead should interpret the **spirit** of the user's instruction, not just exact keyword matches. If the user clearly wants the workflow to proceed without stopping, that constitutes autonomous mode activation.
|
|
266
|
+
|
|
267
|
+
**Safety exceptions** — ALWAYS pause even in autonomous mode:
|
|
268
|
+
* Critical, unresolvable blockers (Section 11)
|
|
269
|
+
* Security vulnerabilities rated HIGH or CRITICAL
|
|
270
|
+
* >3 failures on the same phase
|
|
271
|
+
* Architecture discrepancies too complex to fix autonomously
|
|
272
|
+
* >3 gap-fix iterations per partition without resolution
|
|
273
|
+
|
|
274
|
+
Autonomous mode is per-WorkGroup and does not carry over.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## 6. MCP Integration (Optional but Recommended)
|
|
279
|
+
|
|
280
|
+
If KnowzCode MCP server is configured (`knowzcode/mcp_config.md` or `knowzcode/knowzcode_vaults.md`), agents can leverage vault queries to enhance every phase.
|
|
281
|
+
|
|
282
|
+
**Before using MCP, read `knowzcode/knowzcode_vaults.md` to resolve vault IDs by type.** Use the vault's description to confirm the query is appropriate for that vault. If a single vault covers all types, use it for everything. Never hardcode vault names — always resolve from config.
|
|
283
|
+
|
|
284
|
+
### Vault Types
|
|
285
|
+
|
|
286
|
+
| Type | Purpose | Example Queries |
|
|
287
|
+
|------|---------|-----------------|
|
|
288
|
+
| **code** | Reference implementations, code snippets, API patterns | `"authentication middleware pattern"`, `"error handling in {framework}"` |
|
|
289
|
+
| **ecosystem** | Business rules, conventions, decisions, integrations, platform knowledge | `"checkout flow rules"`, `"pricing constraints"`, `"Stripe webhook setup"` |
|
|
290
|
+
| **finalizations** | WorkGroup completion summaries, outcome records | `"past decisions about {component}"`, `"similar WorkGroups"` |
|
|
291
|
+
|
|
292
|
+
A project may configure one vault covering all types (common for small teams) or multiple specialized vaults. Knowz-scribe (or direct MCP calls) writes to vaults; knowz-scout has read access only. The scribe is the primary capture agent that routes writes to the correct vault based on content type.
|
|
293
|
+
|
|
294
|
+
### Phase-Specific Usage
|
|
295
|
+
|
|
296
|
+
| Phase | MCP Tool | Purpose |
|
|
297
|
+
|-------|----------|---------|
|
|
298
|
+
| **1A (Analysis)** | `search_knowledge({vault matching "ecosystem" type}, "past decisions about {domain}")` | Find prior decisions affecting components |
|
|
299
|
+
| **1B (Spec)** | `ask_question({vault matching "ecosystem" type}, "conventions for {component_type}?")` | Check team conventions before drafting |
|
|
300
|
+
| **2A (Build)** | `search_knowledge({vault matching "code" type}, "{similar_feature} implementation")` | Find reference implementations |
|
|
301
|
+
| **2B (Audit)** | `ask_question({vault matching "ecosystem" type}, "standards for {domain}", researchMode=true)` | Comprehensive standards check |
|
|
302
|
+
| **3 (Close)** | Delegate to knowz-scribe (or `create_knowledge` directly if no scribe) | Capture patterns, decisions, workarounds |
|
|
303
|
+
|
|
304
|
+
### Knowz-Scribe (Multi-Agent Platforms)
|
|
305
|
+
|
|
306
|
+
On platforms with multi-agent orchestration (e.g., Claude Code Agent Teams), **knowz-scribe** has full read/write access to MCP vaults, and **knowz-scout** has read access to MCP vaults. Both have read/write access to local knowzcode files:
|
|
307
|
+
|
|
308
|
+
- Both spawned at workflow start (persistent agents, Stage 0 through Phase 3)
|
|
309
|
+
- **Knowz-scribe** is the primary capture agent — receives capture messages from teammates at each quality gate (e.g., `"Capture Phase 1A: {wgid}"`), reads the WorkGroup file, extracts learnings, and writes to the appropriate vault. Handles deduplication, formatting, and routing to the correct vault by type.
|
|
310
|
+
- **Knowz-scout** is the primary research agent — queries vaults for business context, conventions, and past decisions.
|
|
311
|
+
- Both stay alive through the entire workflow, shut down after Phase 3 capture
|
|
312
|
+
|
|
313
|
+
On platforms without multi-agent orchestration, the closer handles vault writes directly (see Section 7).
|
|
314
|
+
|
|
315
|
+
### Enterprise: Team Standards
|
|
316
|
+
|
|
317
|
+
At workflow start, if an enterprise-type vault is configured (read `knowzcode/knowzcode_vaults.md` to find vault matching type "enterprise", then check `knowzcode/enterprise/compliance_manifest.md` for `mcp_compliance_enabled: true`):
|
|
318
|
+
- Pull team-wide standards and merge into quality gate criteria
|
|
319
|
+
- Push audit results to the resolved enterprise vault after Phase 2B
|
|
320
|
+
- Push completion records to the resolved enterprise vault after Phase 3
|
|
321
|
+
|
|
322
|
+
### Graceful Degradation
|
|
323
|
+
|
|
324
|
+
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.
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 7. Learning Capture (Optional)
|
|
329
|
+
|
|
330
|
+
> **Vault content must be detailed and self-contained.** Vault entries are retrieved via semantic search — not read directly like local files. Include full reasoning, specific technology names, code examples, and file paths. See `knowzcode/knowzcode_vaults.md` Content Detail Principle.
|
|
331
|
+
|
|
332
|
+
During finalization, scan the WorkGroup for insight-worthy patterns:
|
|
333
|
+
|
|
334
|
+
| Signal Type | Examples |
|
|
335
|
+
|-------------|----------|
|
|
336
|
+
| Pattern | "created utility for", "reusable", "abstracted" |
|
|
337
|
+
| Decision | "chose X over Y", "opted for", "trade-off" |
|
|
338
|
+
| Workaround | "workaround", "limitation", "can't do X so" |
|
|
339
|
+
| Performance | "optimized", "reduced from X to Y", "cache" |
|
|
340
|
+
| Security | "vulnerability", "sanitize", "authentication fix" |
|
|
341
|
+
| Convention | "established convention", "team standard", "naming pattern", "agreed to always" |
|
|
342
|
+
| Integration | "API integration", "upstream API changed", "service dependency", "webhook" |
|
|
343
|
+
| Scope | "included because", "excluded because", "out of scope", "deferred to" |
|
|
344
|
+
|
|
345
|
+
### Auto-Capture Triggers
|
|
346
|
+
|
|
347
|
+
Learning candidates are detected at each quality gate. **The lead/outer orchestrator is responsible for triggering capture** — delegating to the knowz-scribe on multi-agent platforms, or ensuring the closer handles it via Direct Write Fallback on single-agent/sequential platforms.
|
|
348
|
+
|
|
349
|
+
**Multi-agent platforms (knowz-scribe active):**
|
|
350
|
+
|
|
351
|
+
At each quality gate, send a message to the knowz-scribe with the phase identifier:
|
|
352
|
+
- After Phase 1A approval: `"Capture Phase 1A: {wgid}"`
|
|
353
|
+
- After Phase 2A completion: `"Capture Phase 2A: {wgid}"`
|
|
354
|
+
- After Phase 2B audit: `"Capture Phase 2B: {wgid}"`
|
|
355
|
+
- After Phase 3 finalization: `"Capture Phase 3: {wgid}"`
|
|
356
|
+
|
|
357
|
+
The knowz-scribe reads the WorkGroup file, extracts relevant data, checks for duplicates, and writes to the appropriate vault. No other agent should call `create_knowledge` when the scribe is active.
|
|
358
|
+
|
|
359
|
+
**Ad-hoc captures (any agent, any time):**
|
|
360
|
+
|
|
361
|
+
Any agent can send knowledge to the knowz-scribe outside phase boundaries:
|
|
362
|
+
- `"Log: {description}"` — explicit capture, scribe must write it (decides vault routing)
|
|
363
|
+
- `"Consider: {description}"` — soft capture, scribe evaluates whether to log and where
|
|
364
|
+
|
|
365
|
+
The scribe handles routing, dedup, and formatting for both modes. If MCP is unavailable, captures are queued to `knowzcode/pending_captures.md` for later sync.
|
|
366
|
+
|
|
367
|
+
**Single-agent / no scribe (direct MCP writes):**
|
|
368
|
+
|
|
369
|
+
If MCP is available but no knowz-scribe, resolve vault IDs from `knowzcode/knowzcode_vaults.md` before writing:
|
|
370
|
+
|
|
371
|
+
- After Phase 1A: `create_knowledge({ecosystem_vault}, title="Scope: {descriptive goal summary}", content="[CONTEXT] {problem description, what prompted this work, constraints}\n[INSIGHT] {scope decisions — what's included/excluded and why}\n[RATIONALE] {risk assessment with full reasoning, affected files, mitigation}\n[TAGS] scope, {domain}", tags=["scope", "{domain}"])`
|
|
372
|
+
- After Phase 2A: Capture implementation patterns and workarounds discovered during TDD cycles — include specific file paths, code examples, and the problem each pattern solves
|
|
373
|
+
- After Phase 2B: `create_knowledge({ecosystem_vault}, title="Audit: {wgid} - {score}% — {key finding summary}", content="[CONTEXT] {what was audited, scope of the review}\n[INSIGHT] {specific gaps with file paths and line references, security findings with severity reasoning}\n[RATIONALE] {gap resolution decisions — what was deferred vs fixed and why}\n[TAGS] audit, {domain}", tags=["audit", "{domain}"])`
|
|
374
|
+
- After Phase 2B (enterprise): If enterprise vault configured and compliance enabled, push audit results to enterprise vault
|
|
375
|
+
- After Phase 3: Capture architectural learnings and consolidation decisions (handled by closer agent)
|
|
376
|
+
|
|
377
|
+
### Capture Protocol
|
|
378
|
+
|
|
379
|
+
**When knowz-scribe is active (multi-agent platforms):**
|
|
380
|
+
1. Send capture message to knowz-scribe with phase identifier and WorkGroup ID
|
|
381
|
+
2. The scribe handles: vault ID resolution, duplicate checking, user approval prompting, and writing
|
|
382
|
+
3. No other agent should call `create_knowledge` directly
|
|
383
|
+
|
|
384
|
+
**When no knowz-scribe (single-agent / sequential):**
|
|
385
|
+
1. Read `knowzcode/knowzcode_vaults.md` to resolve vault IDs by type
|
|
386
|
+
2. Detect learning candidates from WorkGroup file content
|
|
387
|
+
3. Check for duplicates via `search_knowledge` — skip if substantially similar exists
|
|
388
|
+
4. Prompt user for approval before saving
|
|
389
|
+
5. Only write if the targeted vault is configured — skip gracefully if not
|
|
390
|
+
6. Create learning via `create_knowledge` with appropriate title prefix
|
|
391
|
+
|
|
392
|
+
### Audit Trail (Enterprise)
|
|
393
|
+
|
|
394
|
+
After Phase 3:
|
|
395
|
+
1. Read `knowzcode/knowzcode_vaults.md` to find vault matching type "enterprise"
|
|
396
|
+
2. Only push if an enterprise vault is configured
|
|
397
|
+
- Push WorkGroup completion record with goal, NodeIDs, audit score, and decisions
|
|
398
|
+
- Push architecture drift findings if any detected during finalization
|
|
399
|
+
|
|
400
|
+
If MCP is not available, skip learning capture and audit trail — all other phases work normally.
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## 8. Multi-Agent Execution (Platform-Specific)
|
|
405
|
+
|
|
406
|
+
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.
|
|
407
|
+
|
|
408
|
+
### Agent-to-Phase Mapping
|
|
409
|
+
|
|
410
|
+
| Phase | Specialist Agent | Expertise |
|
|
411
|
+
|-------|-----------------|-----------|
|
|
412
|
+
| 1A | analyst | Impact analysis, Change Set proposals |
|
|
413
|
+
| 1B | architect | Specification drafting, architecture review |
|
|
414
|
+
| 2A | builder | TDD implementation, verification loops |
|
|
415
|
+
| 2B | reviewer | Quality audit, security review |
|
|
416
|
+
| 3 | closer | Finalization, learning capture |
|
|
417
|
+
|
|
418
|
+
### Execution Rules
|
|
419
|
+
|
|
420
|
+
When using multi-agent execution:
|
|
421
|
+
- Each phase maps to a specialist agent
|
|
422
|
+
- Phase dependencies enforce quality gates (1A must complete before 1B, etc.)
|
|
423
|
+
- User approves transitions between phases at quality gates
|
|
424
|
+
- Agents can communicate about gaps and blockers
|
|
425
|
+
- The lead agent coordinates but does not modify code directly
|
|
426
|
+
- Agents read context files independently — do not duplicate context across agents
|
|
427
|
+
|
|
428
|
+
### Single-Agent Execution
|
|
429
|
+
|
|
430
|
+
When a single AI handles all phases sequentially:
|
|
431
|
+
- Follow the same phase sequence and quality gates
|
|
432
|
+
- Pause at each gate for user approval
|
|
433
|
+
- All quality standards apply identically
|
|
434
|
+
|
|
435
|
+
### Parallel Execution (Multi-Agent Platforms)
|
|
436
|
+
|
|
437
|
+
On platforms supporting concurrent agents (Claude Code Agent Teams, future multi-agent runtimes):
|
|
438
|
+
|
|
439
|
+
#### Parallelism Boundaries
|
|
440
|
+
- **Between phases**: Phase 1A must produce Change Set before 1B drafts specs (scope must be approved first)
|
|
441
|
+
- **Within phases**: Independent NodeIDs can be implemented/audited in parallel
|
|
442
|
+
- **Across phases**: Incremental review can start on completed components while other components are still being implemented
|
|
443
|
+
- **Agent persistence**: Agents can stay alive across sub-phases to avoid cold-start overhead (e.g., builder persists through audit gap loop)
|
|
444
|
+
|
|
445
|
+
#### Dependency Map
|
|
446
|
+
The analyst produces a dependency map alongside the Change Set, identifying:
|
|
447
|
+
- Which NodeIDs share affected files (must be implemented sequentially or by same agent)
|
|
448
|
+
- Which NodeIDs are independent (can be implemented in parallel)
|
|
449
|
+
- Sequential dependencies (NodeID-B requires NodeID-A's output)
|
|
450
|
+
|
|
451
|
+
#### Incremental Review
|
|
452
|
+
The reviewer can audit completed NodeIDs before all implementation finishes. Gap findings are routed back to the implementer for targeted fixes, then re-audited. Agents persist through this gap loop — no respawning.
|
|
453
|
+
|
|
454
|
+
#### Context Scouts
|
|
455
|
+
Dedicated context-gathering agents can run in parallel with core analysis:
|
|
456
|
+
- Local context scout: reads project history, specs, workgroups
|
|
457
|
+
- Knowz scout: queries and writes to knowledge management vaults for business context (full read/write access)
|
|
458
|
+
Both broadcast findings to inform analyst and architect work.
|
|
459
|
+
|
|
460
|
+
### Sequential Execution Protocol (for platforms without orchestration)
|
|
461
|
+
|
|
462
|
+
For platforms like Cursor, Copilot, or Windsurf where there is no agent orchestration.
|
|
463
|
+
|
|
464
|
+
**Copilot users:** Instead of manually reading phase prompts, use `#prompt:kc-*` prompt files in VS Code Copilot Chat (e.g., `#prompt:kc-work`, `#prompt:kc-specify`). These prompt files encode the sequential protocol below with `#file:` references for context. See `knowzcode/copilot_execution.md` for the full Copilot execution guide.
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
FOR each phase in [1A, 1B, 2A, 2B, 3]:
|
|
468
|
+
|
|
469
|
+
1. Read the phase prompt: knowzcode/prompts/[LOOP_{phase}]__*.md
|
|
470
|
+
2. Read the WorkGroup file: knowzcode/workgroups/{WorkGroupID}.md
|
|
471
|
+
3. Execute the phase instructions
|
|
472
|
+
4. Write output to the WorkGroup file (prefix entries with "KnowzCode:")
|
|
473
|
+
5. STOP at quality gate — present results to user
|
|
474
|
+
6. Wait for user approval before reading the next phase prompt
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**Key differences from orchestrated execution:**
|
|
478
|
+
- The user manually triggers each phase transition
|
|
479
|
+
- Context is carried via WorkGroup files, not inter-agent messaging
|
|
480
|
+
- All phase prompts are self-contained — they read context from knowzcode/ files
|
|
481
|
+
- Quality gates work identically (user approval required at each gate)
|
|
482
|
+
|
|
483
|
+
**Minimal viable execution** (no platform adapter needed):
|
|
484
|
+
1. Copy `knowzcode/` directory to your project
|
|
485
|
+
2. Give your AI the Phase 1A prompt with your goal
|
|
486
|
+
3. When the AI pauses, review output and give the next phase prompt
|
|
487
|
+
4. Repeat until Phase 3 completes
|
|
488
|
+
|
|
489
|
+
See your platform's adapter file for agent configuration details.
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## 9. Context Handoff Protocol
|
|
494
|
+
|
|
495
|
+
When phases transition (whether via agents or sequentially), the following data MUST be communicated to the next phase:
|
|
496
|
+
|
|
497
|
+
### 1A → 1B Handoff
|
|
498
|
+
- WorkGroupID
|
|
499
|
+
- Approved Change Set (NodeIDs + affected files)
|
|
500
|
+
- Risk assessment and classification
|
|
501
|
+
- Historical context from prior WorkGroups
|
|
502
|
+
- User-approved scope boundaries
|
|
503
|
+
|
|
504
|
+
### 1B → 2A Handoff
|
|
505
|
+
- WorkGroupID
|
|
506
|
+
- Approved specifications (file paths)
|
|
507
|
+
- Tracker state (all NodeIDs marked `[WIP]`)
|
|
508
|
+
- Compliance constraints (if enterprise enabled)
|
|
509
|
+
- Pre-implementation commit hash
|
|
510
|
+
|
|
511
|
+
### 2A → 2B Handoff
|
|
512
|
+
- WorkGroupID
|
|
513
|
+
- Implementation artifacts (changed files list)
|
|
514
|
+
- Test results (pass counts, coverage)
|
|
515
|
+
- Verification iteration count
|
|
516
|
+
- Any `[SPEC_ISSUE]` tags (see below)
|
|
517
|
+
|
|
518
|
+
### 2B → 3 Handoff
|
|
519
|
+
- WorkGroupID
|
|
520
|
+
- Audit report with completion percentage
|
|
521
|
+
- Gap list with severity assessment
|
|
522
|
+
- User decision (proceed / return to 2A / modify specs)
|
|
523
|
+
- Security findings summary
|
|
524
|
+
|
|
525
|
+
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.
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## 10. Spec Issues During Implementation
|
|
530
|
+
|
|
531
|
+
If the builder discovers a spec is incorrect or incomplete during Phase 2A:
|
|
532
|
+
|
|
533
|
+
1. **Tag the issue**: Add `[SPEC_ISSUE]` comment in the WorkGroup file with details
|
|
534
|
+
2. **Continue implementing**: Use best judgment for the affected criterion
|
|
535
|
+
3. **Report in completion**: Include spec issues in the Phase 2A completion report
|
|
536
|
+
4. **Phase 2B catches it**: The auditor flags spec-vs-implementation divergences
|
|
537
|
+
5. **User decides**: At the 2B quality gate, the user can update specs or accept the deviation
|
|
538
|
+
|
|
539
|
+
Builders MUST NOT silently deviate from specs. Every deviation must be tagged and reported.
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
## 11. Blocker Escalation Protocol
|
|
544
|
+
|
|
545
|
+
When the verification loop reaches the maximum iteration count (10 for implementation, 5 for micro-fix):
|
|
546
|
+
|
|
547
|
+
### Blocker Report Format
|
|
548
|
+
|
|
549
|
+
```markdown
|
|
550
|
+
## Blocker Report: {WorkGroupID}
|
|
551
|
+
|
|
552
|
+
**Phase:** 2A Implementation
|
|
553
|
+
**Iteration Count:** 10 (maximum reached)
|
|
554
|
+
**NodeID(s) Affected:** [list]
|
|
555
|
+
|
|
556
|
+
### Root Cause Analysis
|
|
557
|
+
- **Failing Check:** [test name / build error / lint issue]
|
|
558
|
+
- **Error Message:** [exact message]
|
|
559
|
+
- **Attempts Made:** [summary of fix attempts]
|
|
560
|
+
|
|
561
|
+
### Recommended Recovery Options
|
|
562
|
+
1. **Modify spec**: Relax or adjust the criterion that cannot be met
|
|
563
|
+
2. **Change approach**: Use a different implementation strategy
|
|
564
|
+
3. **Split WorkGroup**: Extract the blocked NodeID into a separate WorkGroup
|
|
565
|
+
4. **Accept partial**: Proceed with documented gap (debt item)
|
|
566
|
+
5. **Cancel**: Abandon this WorkGroup
|
|
567
|
+
|
|
568
|
+
### Files Involved
|
|
569
|
+
- [list of files with the issue]
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
The user MUST select a recovery option before work continues.
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
## 12. Workflow Abandonment Protocol
|
|
577
|
+
|
|
578
|
+
If a WorkGroup needs to be abandoned mid-workflow:
|
|
579
|
+
|
|
580
|
+
1. **Revert uncommitted changes**: If implementation was in progress, revert source code changes (keep knowzcode files)
|
|
581
|
+
2. **Update tracker**: Set all affected NodeIDs back to their pre-WorkGroup status
|
|
582
|
+
3. **Log abandonment**: Create a log entry with type `WorkGroup-Abandoned` including the reason
|
|
583
|
+
4. **Close WorkGroup file**: Mark the WorkGroup file as abandoned with reason
|
|
584
|
+
5. **Preserve learnings**: If any useful patterns were discovered, capture them before closing
|
|
585
|
+
|
|
586
|
+
```markdown
|
|
587
|
+
---
|
|
588
|
+
**Type:** WorkGroup-Abandoned
|
|
589
|
+
**Timestamp:** [timestamp]
|
|
590
|
+
**WorkGroupID:** [ID]
|
|
591
|
+
**Phase At Abandonment:** [1A/1B/2A/2B/3]
|
|
592
|
+
**Reason:** [user decision / blocker / scope change]
|
|
593
|
+
**NodeID(s) Affected:** [list with their reverted statuses]
|
|
594
|
+
**Learnings Preserved:** [any useful insights, or None]
|
|
595
|
+
---
|
|
596
|
+
```
|