knowzcode 0.2.1 → 0.3.3

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 (36) hide show
  1. package/.claude-plugin/marketplace.json +6 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +43 -5
  4. package/agents/analyst.md +31 -0
  5. package/agents/architect.md +93 -5
  6. package/agents/context-scout.md +1 -1
  7. package/agents/project-advisor.md +110 -0
  8. package/agents/security-officer.md +194 -0
  9. package/agents/test-advisor.md +162 -0
  10. package/commands/audit.md +101 -12
  11. package/commands/connect-mcp.md +24 -0
  12. package/commands/init.md +116 -1
  13. package/commands/plan.md +23 -10
  14. package/commands/work.md +363 -58
  15. package/knowzcode/claude_code_execution.md +91 -10
  16. package/knowzcode/copilot_execution.md +231 -0
  17. package/knowzcode/enterprise/compliance_manifest.md +3 -0
  18. package/knowzcode/knowzcode_loop.md +3 -1
  19. package/knowzcode/knowzcode_orchestration.md +66 -0
  20. package/knowzcode/platform_adapters.md +621 -27
  21. package/package.json +1 -1
  22. package/skills/alias-resolver.json +1 -1
  23. package/skills/architecture-diff.json +1 -1
  24. package/skills/check-installation-status.json +1 -1
  25. package/skills/continue.md +2 -1
  26. package/skills/environment-guard.json +1 -1
  27. package/skills/generate-workgroup-id.json +1 -1
  28. package/skills/install-knowzcode.json +1 -1
  29. package/skills/load-core-context.json +1 -1
  30. package/skills/log-entry-builder.json +1 -1
  31. package/skills/spec-quality-check.json +1 -1
  32. package/skills/spec-template.json +1 -1
  33. package/skills/spec-validator.json +1 -1
  34. package/skills/tracker-scan.json +1 -1
  35. package/skills/tracker-update.json +1 -1
  36. package/skills/validate-installation.json +1 -1
package/commands/work.md CHANGED
@@ -58,6 +58,26 @@ The user MUST see the execution mode announcement before any phase work begins.
58
58
 
59
59
  > **Note:** Agent Teams is experimental and the API may change.
60
60
 
61
+ ## Step 2.4: Load Orchestration Config (Optional)
62
+
63
+ If `knowzcode/knowzcode_orchestration.md` exists, parse its YAML blocks:
64
+
65
+ 1. `MAX_BUILDERS` = `max_builders` value (default: 5, clamp to 1-5)
66
+ 2. `SCOUT_MODE` = `scout_mode` value (default: "full")
67
+ 3. `DEFAULT_SPECIALISTS` = `default_specialists` value (default: [])
68
+ 4. `MCP_AGENTS_ENABLED` = `mcp_agents_enabled` value (default: true)
69
+ 5. `CODEBASE_SCANNER_ENABLED` = `codebase_scanner_enabled` value (default: true)
70
+ 6. `PARALLEL_SPEC_THRESHOLD` = `parallel_spec_threshold` value (default: 3, clamp to 2-10)
71
+
72
+ Apply flag overrides (flags win over config):
73
+ - `--max-builders=N` in `$ARGUMENTS` → override `MAX_BUILDERS`
74
+ - `--no-scouts` in `$ARGUMENTS` → override `SCOUT_MODE = "none"`
75
+ - `--no-mcp` in `$ARGUMENTS` → override `MCP_AGENTS_ENABLED = false`
76
+ - `--no-scanners` in `$ARGUMENTS` → override `CODEBASE_SCANNER_ENABLED = false`
77
+ - `--no-parallel-specs` in `$ARGUMENTS` → override `PARALLEL_SPEC_THRESHOLD = 999` (effectively disabled)
78
+
79
+ If the file doesn't exist, use hardcoded defaults (current behavior).
80
+
61
81
  ## Step 2.5: Autonomous Mode Detection
62
82
 
63
83
  Set `AUTONOMOUS_MODE = true` if ANY of these match:
@@ -78,6 +98,37 @@ If `AUTONOMOUS_MODE = true`, announce after the execution mode announcement:
78
98
  > **Autonomous Mode: ACTIVE** — Gates presented for transparency but auto-approved.
79
99
  > Safety exceptions still pause: critical blockers, HIGH/CRITICAL security findings, >3 same-phase failures, complex architecture discrepancies, >3 gap-fix iterations per partition.
80
100
 
101
+ ## Step 2.6: Specialist Detection
102
+
103
+ Set `SPECIALISTS_ENABLED = []` (empty list).
104
+
105
+ If `DEFAULT_SPECIALISTS` is non-empty (from Step 2.4), initialize:
106
+ `SPECIALISTS_ENABLED = DEFAULT_SPECIALISTS`
107
+
108
+ Determine which specialists to activate (flags and natural language add to or override the baseline):
109
+ - `--specialists` → enable all 3: `[security-officer, test-advisor, project-advisor]`
110
+ - `--specialists=csv` → enable specific subset (comma-separated, e.g., `--specialists=security,test`):
111
+ - `security` → `security-officer`
112
+ - `test` → `test-advisor`
113
+ - `project` → `project-advisor`
114
+ - `--no-specialists` → explicit opt-out, `SPECIALISTS_ENABLED = []`
115
+
116
+ **Natural language detection** (case-insensitive match in `$ARGUMENTS` OR the user's preceding conversation message):
117
+ - All specialists: "with specialists", "with officers", "full specialist panel"
118
+ - security-officer: "security review", "threat model", "vulnerability scan", "pentest"
119
+ - test-advisor: "test quality", "TDD enforcement", "test coverage", "test rigor"
120
+ - project-advisor: "backlog", "future work", "brainstorm", "ideas"
121
+
122
+ **Mode constraints:**
123
+ - Tier 3 Parallel Teams: Full support (Group C)
124
+ - Tier 3 Subagent Delegation: Supported via parallel `Task()` calls
125
+ - Sequential Teams / Tier 2: Not supported — if specialists were detected, announce: `> **Specialists: SKIPPED** — not supported in {Sequential Teams / Tier 2} mode.`
126
+
127
+ Default: `SPECIALISTS_ENABLED = []` (specialists are opt-in).
128
+
129
+ If `SPECIALISTS_ENABLED` is non-empty, announce after the autonomous mode announcement (or after the execution mode announcement if autonomous is not active):
130
+ > **Specialists: ACTIVE** — {comma-separated list of enabled specialists}
131
+
81
132
  ## Step 3: Load Context Files (ONCE)
82
133
 
83
134
  Read these files ONCE (do NOT re-read between phases):
@@ -136,6 +187,9 @@ Assess the goal against the codebase to determine the appropriate workflow tier.
136
187
  - Single file, <50 lines, no ripple effects
137
188
 
138
189
  ### Tier 2: Light (2-phase workflow)
190
+
191
+ > **Note:** Light mode does not use orchestration config — single builder, no scouts, no specialists.
192
+
139
193
  ALL must be true:
140
194
  - ≤3 files touched
141
195
  - Single NodeID (1 new capability)
@@ -293,55 +347,99 @@ When Parallel Teams mode is active, follow these 4 stages instead of spawning on
293
347
  - `MCP_ACTIVE = true` (MCP works regardless of vault creation outcome)
294
348
  - `VAULTS_CONFIGURED = true` if at least 1 vault now has a valid ID, else `false`
295
349
  - Announce: `**MCP Status: Connected — N vault(s) available**` or `**MCP Status: Connected — no vaults configured (knowledge capture disabled)**`
296
- 4. **Spawn Group A** (always — 5 agents):
350
+ 4. **Spawn Group A**:
297
351
  Create tasks first, pre-assign, then spawn with task IDs:
298
- - `TaskCreate("Scout: specs context")` → `TaskUpdate(owner: "context-scout-specs")`
299
- - `TaskCreate("Scout: workgroups context")` → `TaskUpdate(owner: "context-scout-workgroups")`
300
- - `TaskCreate("Scout: backlog context")` → `TaskUpdate(owner: "context-scout-backlog")`
301
- - `TaskCreate("Phase 1A: Impact analysis for {goal}")` → `TaskUpdate(owner: "analyst")`
302
- - `TaskCreate("Pre-load architecture context")` `TaskUpdate(owner: "architect")`
303
- Spawn all 5 agents with their `{task-id}` in the spawn prompt (use spawn prompts from Phase Prompt Reference below).
304
- 5. **Spawn Group B** (MCP agents same turn as Group A): If `VAULTS_CONFIGURED = true`:
352
+ - If `SCOUT_MODE = "full"` (default): spawn 3 context scouts (specs, workgroups, backlog) + analyst + architect (5 agents):
353
+ - `TaskCreate("Scout: specs context")` → `TaskUpdate(owner: "context-scout-specs")`
354
+ - `TaskCreate("Scout: workgroups context")` → `TaskUpdate(owner: "context-scout-workgroups")`
355
+ - `TaskCreate("Scout: backlog context")` → `TaskUpdate(owner: "context-scout-backlog")`
356
+ - If `SCOUT_MODE = "minimal"`: spawn 1 context-scout (combined scan) + analyst + architect (3 agents):
357
+ - `TaskCreate("Scout: combined context")` `TaskUpdate(owner: "context-scout")`
358
+ - If `SCOUT_MODE = "none"`: spawn analyst + architect only (2 agents). Analyst and architect scan the codebase independently without pre-loaded scout context.
359
+ - Always:
360
+ - `TaskCreate("Phase 1A: Impact analysis for {goal}")` → `TaskUpdate(owner: "analyst")`
361
+ - `TaskCreate("Pre-load architecture context and speculative research")` → `TaskUpdate(owner: "architect")`
362
+ - If `CODEBASE_SCANNER_ENABLED = true` (default):
363
+ - Derive two search focuses from the goal:
364
+ - **Scanner-Direct**: source code search — grep for goal keywords, read affected code paths
365
+ - **Scanner-Tests**: test discovery — search test directories for tests covering the goal area
366
+ - `TaskCreate("Scanner: direct codebase scan for {goal}")` → `TaskUpdate(owner: "scanner-direct")`
367
+ - `TaskCreate("Scanner: test coverage scan for {goal}")` → `TaskUpdate(owner: "scanner-tests")`
368
+ Spawn all Group A agents with their `{task-id}` in the spawn prompt (use spawn prompts from Phase Prompt Reference below).
369
+ 5. **Spawn Group B** (MCP agents — same turn as Group A): If `VAULTS_CONFIGURED = true` AND `MCP_AGENTS_ENABLED = true`:
305
370
  Create tasks first, pre-assign, then spawn with task IDs:
306
371
  - `TaskCreate("Knowz-scout: vault queries")` → `TaskUpdate(owner: "knowz-scout")`
307
372
  - `TaskCreate("Knowz-scribe: listen")` → `TaskUpdate(owner: "knowz-scribe")`
308
373
  Spawn both agents with their `{task-id}` in the spawn prompt.
309
- If `VAULTS_CONFIGURED = false`, skip Group B and log: `Vault agents skipped — no vaults configured.`
310
- 6. **Roster confirmation** lead lists every spawned agent by name to the user. If `VAULTS_CONFIGURED` was true but knowz-scout or knowz-scribe is missing from the roster, STOP and re-spawn the missing agent(s) before continuing.
311
- 7. All 5-7 agents work immediately in parallel (3 context scouts are cheap Sonnet read-only agents; knowz-scribe is a cheap Haiku agent)
312
- 8. Scouts broadcast findings analyst and architect consume as messages
374
+ If `VAULTS_CONFIGURED = false` or `MCP_AGENTS_ENABLED = false`, skip Group B and log: `Vault agents skipped — no vaults configured` or `Vault agents skipped — MCP agents disabled in orchestration config.`
375
+ 6. **Spawn Group C** (specialist agents same turn as Groups A and B): If `SPECIALISTS_ENABLED` is non-empty:
376
+ Create tasks first, pre-assign, then spawn with task IDs:
377
+ - If `security-officer` in list: `TaskCreate("Security officer: initial threat scan")` → `TaskUpdate(owner: "security-officer")`
378
+ - If `test-advisor` in list: `TaskCreate("Test advisor: coverage baseline")` → `TaskUpdate(owner: "test-advisor")`
379
+ - If `project-advisor` in list: `TaskCreate("Project advisor: backlog context")` → `TaskUpdate(owner: "project-advisor")`
380
+ Spawn each enabled specialist with its `{task-id}` in the spawn prompt (use spawn prompts from Specialist Spawn Prompts section below).
381
+ If `SPECIALISTS_ENABLED` is empty, skip Group C.
382
+ 7. **Roster confirmation** — lead lists every spawned agent by name to the user. Include scanners and Group C specialists if active. If `VAULTS_CONFIGURED` was true but knowz-scout or knowz-scribe is missing from the roster, STOP and re-spawn the missing agent(s) before continuing.
383
+ 8. All spawned agents work immediately in parallel (context scouts are cheap Sonnet read-only agents; scanners are lightweight general-purpose agents; knowz-scribe is a cheap Haiku agent; specialists are Sonnet read-only agents). Agent count depends on orchestration config: 2-12 agents at Stage 0.
384
+ 9. Scouts broadcast findings → analyst and architect consume as messages. Specialists work independently on their Stage 0 tasks.
313
385
 
314
- **Key**: The analyst does NOT wait for scouts to finish. It starts scanning the codebase immediately. Scout findings arrive as messages and enrich the analyst's work as they arrive.
386
+ **Key**: The analyst does NOT wait for scouts, scanners, or specialists to finish. It starts scanning the codebase immediately. Scout and scanner findings arrive as messages and enrich the analyst's work as they arrive. The analyst also streams `[PRELIMINARY]` NodeID findings to the architect as it discovers them (see Preliminary Findings Protocol). Specialist findings are consumed by the lead at gates.
315
387
 
316
388
  ### Stage 1: Analysis + Specification
317
389
 
318
390
  1. Analyst completes Change Set (includes dependency map — see `agents/analyst.md`)
319
391
  2. Lead reads analyst's task summary
320
- 3. Lead presents **Quality Gate #1** to user:
392
+ 3. Shut down scanners (scanner-direct, scanner-tests) if they were spawned — no longer needed after analysis
393
+ 3. **Specialist Change Set reviews** (if `SPECIALISTS_ENABLED` non-empty): Create review tasks blocked on analysis:
394
+ - If `security-officer` active: `TaskCreate("Security officer: Change Set review", addBlockedBy: [analysis-task-id])` → `TaskUpdate(owner: "security-officer")`. DM security-officer: `"**New Task**: #{task-id} — Review Change Set for security risk. Rate each NodeID."`
395
+ - If `test-advisor` active: `TaskCreate("Test advisor: Change Set test strategy", addBlockedBy: [analysis-task-id])` → `TaskUpdate(owner: "test-advisor")`. DM test-advisor: `"**New Task**: #{task-id} — Recommend test types per NodeID."`
396
+ 4. Lead presents **Quality Gate #1** to user:
321
397
  - Change Set with NodeIDs, descriptions, affected files
322
398
  - Dependency map showing which NodeIDs can be implemented in parallel
323
399
  - Risk assessment
324
- 4. User approves (or rejects re-run analyst with feedback)
325
- 5. Lead sends DM to architect with the approved Change Set
326
- 6. Lead creates spec-drafting tasks for architect (1 task per NodeID, `addBlockedBy: [analysis-task-id]`):
327
- - `TaskCreate("Spec: NodeID-X")` `TaskUpdate(taskId, owner: "architect")`
328
- - DM architect with task IDs: `"**New Tasks**: #{id-1} Spec: NodeID-A, #{id-2} Spec: NodeID-B. Approved Change Set: {summary}"`
329
- - Architect is already warm (pre-loaded during Stage 0) → specs drafted FAST
400
+ - Specialist Reports (if active see gate template below)
401
+ 5. User approves (or rejects re-run analyst with feedback)
402
+ 6. Lead sends DM to architect with the approved Change Set
403
+ 7. **Spec Drafting** — choose path based on NodeID count and `PARALLEL_SPEC_THRESHOLD`:
404
+
405
+ **Path A: Standard (fewer than PARALLEL_SPEC_THRESHOLD NodeIDs)**
406
+ - Lead creates spec-drafting tasks for architect (1 task per NodeID, `addBlockedBy: [analysis-task-id]`):
407
+ - `TaskCreate("Spec: NodeID-X")` → `TaskUpdate(taskId, owner: "architect")`
408
+ - DM architect with task IDs: `"**New Tasks**: #{id-1} Spec: NodeID-A, #{id-2} Spec: NodeID-B. Approved Change Set: {summary}"`
409
+ - Architect is already warm (pre-loaded + speculative research during Stage 0) → specs drafted FAST
330
410
  - If Gate #1 rejected: shut down architect, re-run analyst with feedback, re-spawn architect after
331
- 7. Architect completes specs
332
- 8. Lead presents **Quality Gate #2** to user:
333
- - Spec summaries with VERIFY criteria
334
- 9. User approves (or rejects architect revises)
335
- 10. Pre-implementation commit: `git add knowzcode/ && git commit -m "KnowzCode: Specs approved for {wgid}"`
336
- 11. Shut down context-scouts (no longer needed after specs approved). Keep knowz-scout alive for vault queries during implementation.
337
- 12. Keep analyst alive briefly (available for scope questions during early implementation)
338
- 13. Keep architect alive through Stage 2 (consultative role — spec clarifications for builders, no code or spec edits)
411
+
412
+ **Path B: Parallel Spec Drafting (PARALLEL_SPEC_THRESHOLD or more NodeIDs)**
413
+ - Lead DMs architect the full approved Change Set and asks for a partition plan (see `agents/architect.md` — Parallel Spec Coordination)
414
+ - Architect proposes NodeID partitions (1-2 NodeIDs each, max 3 partitions, respecting same-spec and interface constraints)
415
+ - Lead spawns spec-drafter agents one per partition:
416
+ - Spec-drafters use the `architect` agent definition with a scoped spawn prompt
417
+ - Each drafter gets: its NodeID partition, architect's research findings, cross-NodeID interface constraints, consolidation instructions
418
+ - `TaskCreate("Spec draft: NodeID-A, NodeID-B")` `TaskUpdate(owner: "spec-drafter-1")`
419
+ - Max 3 spec-drafters: `ceil(NodeID_count / 2)`, capped at 3
420
+ - Spec-drafters draft specs in parallel
421
+ - After all spec-drafters complete: architect runs consistency review (cross-spec alignment, naming, VERIFY coverage)
422
+ - Shut down spec-drafters after consistency review
423
+ - If Gate #1 rejected: shut down architect and any spec-drafters, re-run analyst with feedback, re-spawn architect after
424
+
425
+ 8. Architect completes specs (Path A) or architect completes consistency review (Path B)
426
+ 9. **Test-advisor spec review** (if `test-advisor` in `SPECIALISTS_ENABLED`): After specs drafted, create spec testability review task:
427
+ - `TaskCreate("Test advisor: spec testability review", addBlockedBy: [spec-task-id])` → `TaskUpdate(owner: "test-advisor")`
428
+ - DM test-advisor: `"**New Task**: #{task-id} — Review specs for testability. Check VERIFY criteria are automatable."`
429
+ 10. Lead presents **Quality Gate #2** to user:
430
+ - Spec summaries with VERIFY criteria
431
+ - Specialist Reports (if active — see gate template below)
432
+ 11. User approves (or rejects → architect revises)
433
+ 12. Pre-implementation commit: `git add knowzcode/ && git commit -m "KnowzCode: Specs approved for {wgid}"`
434
+ 13. Shut down context-scouts (no longer needed after specs approved). Keep knowz-scout alive for vault queries during implementation.
435
+ 14. Keep analyst alive briefly (available for scope questions during early implementation)
436
+ 15. Keep architect alive through Stage 2 (consultative role — spec clarifications for builders, no code or spec edits)
339
437
 
340
438
  ### Stage 2: Parallel Implementation + Incremental Review
341
439
 
342
440
  1. Lead examines dependency map from analyst:
343
441
  - Group NodeIDs into independent partitions (no shared files between groups)
344
- - Determine builder count: 1 builder per independent group, max 5
442
+ - Determine builder count: 1 builder per independent group, max `MAX_BUILDERS` (default 5, configurable in `knowzcode_orchestration.md`)
345
443
 
346
444
  2. Create builder tasks and spawn:
347
445
  - `TaskCreate("Implement NodeIDs [A, B]", addBlockedBy: [spec-task-id])` → `TaskUpdate(owner: "builder-1")`
@@ -367,7 +465,20 @@ When Parallel Teams mode is active, follow these 4 stages instead of spawning on
367
465
  Reviewer stays idle until its paired builder marks first NodeID implementation complete.
368
466
  Each reviewer audits incrementally within its partition.
369
467
 
370
- 6. Gap flow (per-partition, parallel persistent agents, DM messaging):
468
+ 6. **Specialist implementation reviews** (if `SPECIALISTS_ENABLED` non-empty): Create specialist review tasks alongside reviewer audit tasks, same `addBlockedBy`:
469
+ - If `security-officer` active — one task per partition (runs parallel to reviewer):
470
+ `TaskCreate("Security officer: review partition {N}", addBlockedBy: [implement-X-task-id])` → `TaskUpdate(owner: "security-officer")`
471
+ DM security-officer: `"**New Task**: #{task-id} — Vulnerability scan for partition {N}. NodeIDs: {list}."`
472
+ - If `test-advisor` active — one task per partition:
473
+ `TaskCreate("Test advisor: review partition {N} tests", addBlockedBy: [implement-X-task-id])` → `TaskUpdate(owner: "test-advisor")`
474
+ DM test-advisor: `"**New Task**: #{task-id} — Test quality review for partition {N}. NodeIDs: {list}."`
475
+ - If `project-advisor` active — one observation task (not per-partition):
476
+ `TaskCreate("Project advisor: observe implementation")` → `TaskUpdate(owner: "project-advisor")`
477
+ DM project-advisor: `"**New Task**: #{task-id} — Observe builder progress, note patterns and ideas. Deliver backlog proposals before gap loop."`
478
+ **Gate #3 is NOT blocked by specialists.** If a specialist hasn't finished, gate shows `[Pending: {specialist}]`. Lead proceeds.
479
+ **Project-advisor early shutdown**: After project-advisor delivers backlog proposals, shut it down (before the gap loop begins).
480
+
481
+ 7. Gap flow (per-partition, parallel — persistent agents, DM messaging):
371
482
  a. Each reviewer marks audit task complete with structured gap report in summary
372
483
  b. Lead creates fix task and pre-assigns:
373
484
  `TaskCreate("Fix gaps: NodeID-A", addBlockedBy: [audit-task-id])` → `TaskUpdate(owner: "builder-N")`
@@ -382,12 +493,12 @@ When Parallel Teams mode is active, follow these 4 stages instead of spawning on
382
493
  g. Each builder-reviewer pair repeats independently until clean — no cross-partition blocking
383
494
  — All builders and reviewers stay alive through the entire gap loop (no respawning)
384
495
 
385
- 7. Enterprise compliance (if enabled):
496
+ 8. Enterprise compliance (if enabled):
386
497
  - Lead creates parallel compliance task for each reviewer (scoped to their partition)
387
498
  - Reviewer checks compliance requirements from knowz-scout findings
388
499
  - Runs alongside ARC audits
389
500
 
390
- 8. Inter-agent communication during Stage 2:
501
+ 9. Inter-agent communication during Stage 2:
391
502
  - builder → architect: Spec clarification requests (direct messages)
392
503
  - architect → builder: Design guidance and spec intent responses (direct messages)
393
504
  - builder ↔ builder: Dependency coordination (direct messages — "I changed the User interface, FYI")
@@ -395,23 +506,31 @@ When Parallel Teams mode is active, follow these 4 stages instead of spawning on
395
506
  - reviewer → lead: Gap reports per partition (structured format via task summaries)
396
507
  - lead → builder: Fix tasks (via task creation + DM)
397
508
  - lead → reviewer: Re-audit requests (via task creation + DM)
398
-
399
- 9. After all NodeIDs implemented + audited across all partitions:
400
- - Lead consolidates audit results from all reviewers
401
- - Lead presents **Quality Gate #3**:
402
- - Per-NodeID ARC completion % (from each partition's reviewer)
403
- - Combined security posture
404
- - Combined integration health
405
- - Enterprise compliance (if applicable)
406
- - User decides: proceed / fix gaps / modify specs / cancel
407
-
408
- 10. Shut down analyst, architect, all builders, and all reviewers
509
+ - security-officer → builder-N: Security guidance for sensitive partitions (max 2 DMs per builder)
510
+ - test-advisor builder-N: Test improvement feedback (max 2 DMs per builder)
511
+ - security-officer test-advisor: Cross-cutting test gaps in security paths (max 2 inter-specialist DMs)
512
+ - project-advisor knowz-scribe: Idea captures for vault storage
513
+ - project-advisor lead: Backlog proposals (before gap loop)
514
+
515
+ 10. After all NodeIDs implemented + audited across all partitions:
516
+ - Lead consolidates audit results from all reviewers
517
+ - Lead consolidates specialist reports (if `SPECIALISTS_ENABLED` non-empty include even if some specialist tasks are still pending, noting `[Pending: {specialist}]`)
518
+ - Lead presents **Quality Gate #3**:
519
+ - Per-NodeID ARC completion % (from each partition's reviewer)
520
+ - Combined security posture
521
+ - Combined integration health
522
+ - Enterprise compliance (if applicable)
523
+ - Specialist Reports (if active — see gate template below)
524
+ - User decides: proceed / fix gaps / modify specs / cancel
525
+
526
+ 11. Shut down analyst, architect, all builders, and all reviewers
409
527
 
410
528
  ### Stage 3: Finalization
411
529
 
412
- 1. `TaskCreate("Phase 3: Finalize {wgid}", addBlockedBy: [last-audit-task-id])` `TaskUpdate(owner: "closer")`
530
+ 1. Shut down remaining specialists (security-officer, test-advisor) if still active. Project-advisor should already be shut down from mid-Stage 2.
531
+ 2. `TaskCreate("Phase 3: Finalize {wgid}", addBlockedBy: [last-audit-task-id])` → `TaskUpdate(owner: "closer")`
413
532
  Spawn `closer` with `{task-id}` in spawn prompt.
414
- 2. Closer tasks (can be parallel subtasks):
533
+ 3. Closer tasks (can be parallel subtasks):
415
534
  - Update all specs to FINAL as-built
416
535
  - Update `knowzcode_tracker.md`: all NodeIDs `[WIP]` → `[VERIFIED]`
417
536
  - Write ARC-Completion log entry
@@ -419,9 +538,9 @@ When Parallel Teams mode is active, follow these 4 stages instead of spawning on
419
538
  - Schedule REFACTOR tasks for tech debt
420
539
  - Send learnings to knowz-scribe (if active): `"Capture Phase 3: {wgid}"`. Knowz-scout remains available for vault queries during finalization.
421
540
  - Create final atomic commit
422
- 3. Lead presents completion summary
423
- 4. Shut down knowz-scout, knowz-scribe (after Phase 3 capture completes), closer, and all remaining agents
424
- 5. Delete team
541
+ 4. Lead presents completion summary
542
+ 5. Shut down knowz-scout, knowz-scribe (after Phase 3 capture completes), closer, and all remaining agents
543
+ 6. Delete team
425
544
 
426
545
  ### WorkGroup File Format (Parallel Mode)
427
546
 
@@ -453,11 +572,23 @@ When creating tasks, model the dependency chain with `addBlockedBy` and pre-assi
453
572
  | Scout: backlog context | (none) | context-scout-backlog |
454
573
  | Knowz-scout: vault queries | (none — persistent) | knowz-scout |
455
574
  | Knowz-scribe: listen | (none — persistent) | knowz-scribe |
456
- | Phase 1A analysis | (none — scouts enrich via broadcast) | analyst |
457
- | Architect pre-load | (none) | architect |
458
- | Spec: NodeID-X | Phase 1A (gate approval) | architect |
575
+ | Scanner: direct codebase scan | (none) | scanner-direct |
576
+ | Scanner: test coverage scan | (none) | scanner-tests |
577
+ | Phase 1A analysis | (none scouts + scanners enrich via broadcast) | analyst |
578
+ | Architect pre-load + speculative research | (none — receives [PRELIMINARY] DMs from analyst) | architect |
579
+ | Security officer: initial threat scan | (none — Group C) | security-officer |
580
+ | Test advisor: coverage baseline | (none — Group C) | test-advisor |
581
+ | Project advisor: backlog context | (none — Group C) | project-advisor |
582
+ | Security officer: Change Set review | Phase 1A analysis | security-officer |
583
+ | Test advisor: Change Set test strategy | Phase 1A analysis | test-advisor |
584
+ | Spec: NodeID-X | Phase 1A (gate approval) | architect (Path A) or spec-drafter-N (Path B) |
585
+ | Spec consistency review | All spec drafts complete (Path B only) | architect |
586
+ | Test advisor: spec testability review | Spec: NodeID-X | test-advisor |
459
587
  | Implement: NodeID-X | Spec: NodeID-X | builder-N |
460
588
  | Audit: NodeID-X | Implement: NodeID-X | reviewer-N |
589
+ | Security officer: review partition N | Implement: NodeID-X | security-officer |
590
+ | Test advisor: review partition N tests | Implement: NodeID-X | test-advisor |
591
+ | Project advisor: observe implementation | (none) | project-advisor |
461
592
  | Fix gaps: NodeID-X round N | Audit: NodeID-X (or re-audit N-1) | builder-N |
462
593
  | Re-audit: NodeID-X round N | Fix gaps round N | reviewer-N |
463
594
  | Phase 3 finalization | All audits approved | closer |
@@ -466,6 +597,8 @@ When creating tasks, model the dependency chain with `addBlockedBy` and pre-assi
466
597
 
467
598
  ## Sequential Teams / Subagent Flow (Tier 3 Fallback)
468
599
 
600
+ > **Note:** Sequential Teams does not use orchestration config settings except `MCP_AGENTS_ENABLED`.
601
+
469
602
  When using Sequential Teams (`--sequential`) or Subagent Delegation, follow the traditional one-agent-per-phase flow. For each phase below: spawn the agent, create a task, wait for completion, present quality gate, shut down agent, proceed to next phase.
470
603
 
471
604
  ---
@@ -507,10 +640,70 @@ Three instances of the same agent, each focused on a different local folder grou
507
640
  > **READ-ONLY.** Do NOT modify any files.
508
641
  > **Deliverable**: Broadcast active WIP, REFACTOR tasks, architecture summary, and recent log patterns relevant to goal.
509
642
 
643
+ **context-scout (combined) spawn prompt** (used when `SCOUT_MODE = "minimal"`):
644
+ > You are `context-scout` for WorkGroup `{wgid}`.
645
+ > Read `agents/context-scout.md` for your full role definition.
646
+ > **Your Task**: #{task-id} — claim immediately. Mark completed with summary when done.
647
+ > **Focus area**: ALL local context — `knowzcode/specs/*.md`, `knowzcode/workgroups/*.md`, `knowzcode/knowzcode_tracker.md`, `knowzcode/knowzcode_log.md`, `knowzcode/knowzcode_architecture.md`, `knowzcode/knowzcode_project.md`
648
+ > **Goal**: {goal}
649
+ > **READ-ONLY.** Do NOT modify any files.
650
+ > **Deliverable**: Broadcast consolidated findings covering specs, prior workgroups, active WIP, REFACTOR tasks, and architecture context.
651
+
510
652
  **Dispatch**:
511
- - *Parallel Teams*: All 3 context scouts spawned at Stage 0, no blockedBy. Shut down after Gate #2 (specs approved).
653
+ - *Parallel Teams*:
654
+ - `SCOUT_MODE = "full"`: 3 context scouts spawned at Stage 0. Shut down after Gate #2.
655
+ - `SCOUT_MODE = "minimal"`: 1 context-scout (combined) spawned at Stage 0. Shut down after Gate #2.
656
+ - `SCOUT_MODE = "none"`: No scouts spawned.
512
657
  - *Sequential Teams*: Not applicable (scouts are Parallel Teams only).
513
- - *Subagent*: `Task(subagent_type="context-scout", name="context-scout-specs", ...)`, `Task(subagent_type="context-scout", name="context-scout-workgroups", ...)`, `Task(subagent_type="context-scout", name="context-scout-backlog", ...)`
658
+ - *Subagent*:
659
+ - `SCOUT_MODE = "full"`: 3 parallel `Task()` calls (specs, workgroups, backlog).
660
+ - `SCOUT_MODE = "minimal"`: 1 `Task()` call with combined prompt.
661
+ - `SCOUT_MODE = "none"`: Skip scout tasks.
662
+
663
+ ---
664
+
665
+ ## Stage 0: Codebase Scanners (2 instances — conditional)
666
+
667
+ **Agent**: `general-purpose` (x2) | Lightweight codebase searchers (no agent definition file)
668
+
669
+ Two temporary agents that scan the codebase in parallel with the analyst, broadcasting findings to accelerate impact analysis. Only spawned when `CODEBASE_SCANNER_ENABLED = true` (default).
670
+
671
+ **scanner-direct spawn prompt**:
672
+ > You are `scanner-direct` for WorkGroup `{wgid}`.
673
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
674
+ > **Goal**: {goal}
675
+ > **Focus**: Search source code for goal-related keywords and patterns.
676
+ >
677
+ > **Steps**:
678
+ > 1. Grep for goal keywords across source files (exclude node_modules, dist, build, .git)
679
+ > 2. Read the top 5-8 matching files to understand affected code paths
680
+ > 3. Identify module boundaries and cross-module dependencies
681
+ > 4. Note public APIs and interfaces that may need changes
682
+ >
683
+ > **READ-ONLY.** Do NOT modify any files.
684
+ > **Deliverable**: Broadcast findings to all teammates — affected files, code paths, module boundaries, and interface patterns.
685
+ > **Budget**: Complete within ~12 turns. Focus on breadth over depth.
686
+
687
+ **scanner-tests spawn prompt**:
688
+ > You are `scanner-tests` for WorkGroup `{wgid}`.
689
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
690
+ > **Goal**: {goal}
691
+ > **Focus**: Discover tests covering the goal area to understand test patterns and coverage shape.
692
+ >
693
+ > **Steps**:
694
+ > 1. Glob for test files: `**/*.test.*`, `**/*.spec.*`, `**/test_*`, `**/tests/**`
695
+ > 2. Grep test files for goal-related keywords
696
+ > 3. Read 3-5 matching test files to understand testing patterns (test framework, mocking strategy, fixture patterns)
697
+ > 4. Check for integration/e2e tests related to the goal area
698
+ >
699
+ > **READ-ONLY.** Do NOT modify any files.
700
+ > **Deliverable**: Broadcast findings to all teammates — test file locations, testing patterns, coverage gaps, and fixture/mock patterns.
701
+ > **Budget**: Complete within ~12 turns. Focus on breadth over depth.
702
+
703
+ **Dispatch**:
704
+ - *Parallel Teams*: Spawned at Stage 0 if `CODEBASE_SCANNER_ENABLED = true`. Use `subagent_type: "general-purpose"`, `maxTurns: 12`. Shut down after Stage 1 (analyst completes Change Set).
705
+ - *Sequential Teams*: Not applicable (scanners are Parallel Teams only).
706
+ - *Subagent*: `Task(subagent_type="general-purpose", description="Scan codebase for {focus}", maxTurns=12, prompt=<above>)` if `CODEBASE_SCANNER_ENABLED = true`.
514
707
 
515
708
  ---
516
709
 
@@ -554,6 +747,61 @@ Three instances of the same agent, each focused on a different local folder grou
554
747
 
555
748
  ---
556
749
 
750
+ ## Specialist Spawn Prompts (Group C — opt-in via `--specialists`)
751
+
752
+ The spawn prompts below are used when `SPECIALISTS_ENABLED` is non-empty. Specialists are spawned at Stage 0 alongside Groups A and B.
753
+
754
+ **Dispatch** (all specialists):
755
+ - *Parallel Teams*: Group C — spawned at Stage 0 if `SPECIALISTS_ENABLED` non-empty, no blockedBy. Security-officer and test-advisor persist through Gate #3. Project-advisor shuts down mid-Stage 2.
756
+ - *Sequential Teams*: Not supported — announce skip reason.
757
+ - *Subagent*: `Task()` calls with spawn prompts below.
758
+
759
+ ### Security Officer
760
+
761
+ **Agent**: `security-officer` | Officer — CRITICAL/HIGH findings block gates
762
+
763
+ **Spawn prompt**:
764
+ > You are the **security-officer** for WorkGroup `{wgid}`.
765
+ > Read `agents/security-officer.md` for your full role definition.
766
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
767
+ > **Goal**: {goal}
768
+ > **READ-ONLY.** Do NOT modify any files. Bash is for read-only security scanning only.
769
+ > **Stage 0 Deliverable**: Build STRIDE-lite threat model. Scan for auth/PII/crypto/session patterns. Broadcast initial threat assessment.
770
+ > **Authority**: CRITICAL/HIGH findings use `[SECURITY-BLOCK]` tag — lead MUST pause autonomous mode.
771
+ > **Communication**: DM lead at gates. DM architect with security VERIFY criteria needs. DM builders in security-sensitive partitions (max 2 per builder). DM test-advisor for cross-cutting test gaps (max 2).
772
+ > **Enterprise Compliance**: If `knowzcode/enterprise/compliance_manifest.md` exists and `compliance_enabled: true`, read active security guidelines and cross-reference findings with enterprise guideline IDs.
773
+
774
+ ### Test Advisor
775
+
776
+ **Agent**: `test-advisor` | Advisor — informational only
777
+
778
+ **Spawn prompt**:
779
+ > You are the **test-advisor** for WorkGroup `{wgid}`.
780
+ > Read `agents/test-advisor.md` for your full role definition.
781
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
782
+ > **Goal**: {goal}
783
+ > **READ-ONLY.** Do NOT modify any files. Bash is for read-only operations only (git log, coverage reports).
784
+ > **Stage 0 Deliverable**: Establish test coverage baseline. Glob test files, run coverage if available. Broadcast baseline.
785
+ > **Communication**: DM lead at gates. DM architect if VERIFY criteria aren't testable. DM builders with test improvement feedback (max 2 per builder). DM security-officer for cross-cutting security test gaps (max 2).
786
+ > **Enterprise Compliance**: If `knowzcode/enterprise/compliance_manifest.md` exists and `compliance_enabled: true`, check enterprise ARC criteria for test coverage gaps.
787
+
788
+ ### Project Advisor
789
+
790
+ **Agent**: `project-advisor` | Advisor — informational only
791
+
792
+ **Spawn prompt**:
793
+ > You are the **project-advisor** for WorkGroup `{wgid}`.
794
+ > Read `agents/project-advisor.md` for your full role definition.
795
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
796
+ > **Goal**: {goal}
797
+ > **READ-ONLY.** Do NOT modify any files.
798
+ > **Stage 0 Deliverable**: Read tracker for existing REFACTOR tasks and backlog context. DM lead with context summary.
799
+ > **Lifecycle**: You shut down mid-Stage 2 after delivering backlog proposals — before the gap loop.
800
+ > **Communication**: DM lead with backlog context and proposals. DM knowz-scribe with idea captures (if active). Do NOT DM builders or other specialists.
801
+ > **Enterprise Compliance**: If `knowzcode/enterprise/compliance_manifest.md` exists, note compliance configuration gaps in backlog proposals.
802
+
803
+ ---
804
+
557
805
  ## Phase 1A: Impact Analysis
558
806
 
559
807
  **Agent**: `analyst` | **Loop.md**: Section 3.1
@@ -568,10 +816,12 @@ Three instances of the same agent, each focused on a different local folder grou
568
816
  >
569
817
  > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
570
818
  > **Conventions**: Update WorkGroup file with results (prefix entries with `KnowzCode:`). If blocked, report blocker and notify lead.
819
+ > **Codebase scanners**: Scanner agents are running in parallel — their findings will arrive as broadcast messages. Incorporate them into your analysis but do NOT wait for them.
820
+ > **Preliminary Findings Protocol**: As you discover high-confidence NodeIDs, DM the architect with `[PRELIMINARY]` messages (max 3 — see `agents/analyst.md` for format). This lets the architect start speculative research early.
571
821
  > **Deliverable**: Change Set proposal written to the WorkGroup file. Include NodeIDs, descriptions, affected files, risk assessment, and dependency map (for Parallel Teams mode).
572
822
 
573
823
  **Dispatch**:
574
- - *Parallel Teams*: Spawned at Stage 0 alongside scouts and architect. Starts immediately (no blockedBy).
824
+ - *Parallel Teams*: Spawned at Stage 0 alongside scouts, scanners, and architect. Starts immediately (no blockedBy).
575
825
  - *Sequential Teams*: Spawn teammate `analyst`, create task `Phase 1A: Impact analysis for "{goal}"`, wait for completion.
576
826
  - *Subagent*: `Task(subagent_type="analyst", description="Phase 1A impact analysis", prompt=<above>)`
577
827
 
@@ -591,6 +841,11 @@ Present the Change Set for user approval:
591
841
 
592
842
  **Risk Assessment**: {Low/Medium/High}
593
843
 
844
+ ### Specialist Reports [only when SPECIALISTS_ENABLED non-empty]
845
+ **Security Officer**: {risk assessment per NodeID, attack surface changes, threat model}
846
+ **Architect**: {architecture impact, layer touch points, pattern alignment}
847
+ **Test Advisor**: {coverage baseline, test strategy recommendations per NodeID}
848
+
594
849
  Approve this Change Set to proceed to specification?
595
850
  ```
596
851
 
@@ -606,11 +861,34 @@ If MCP is configured and knowz-scribe is active, after Change Set approval:
606
861
 
607
862
  ---
608
863
 
864
+ ## Stage 0: Architect Pre-load (Parallel Teams)
865
+
866
+ **Agent**: `architect` | Spawned at Stage 0 for context pre-loading and speculative research
867
+
868
+ In Parallel Teams mode, the architect is spawned at Stage 0 (not at Phase 1B). It pre-loads architecture context and performs speculative research on `[PRELIMINARY]` NodeIDs from the analyst.
869
+
870
+ **Stage 0 spawn prompt** (Parallel Teams only):
871
+ > You are the **architect** for WorkGroup `{wgid}`.
872
+ > Read `agents/architect.md` for your full role definition.
873
+ >
874
+ > **Goal**: {goal}
875
+ > **Context files**: Read sections 1-2 and 3.2 of `knowzcode/knowzcode_loop.md` (skip other phases), `knowzcode/knowzcode_project.md`, `knowzcode/knowzcode_architecture.md`
876
+ > **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
877
+ > **Specs directory**: `knowzcode/specs/`
878
+ >
879
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
880
+ > **Stage 0 Role**: Pre-load architecture context, then perform speculative research on any `[PRELIMINARY]` NodeID messages from the analyst (see Speculative Research Protocol in `agents/architect.md`). READ-ONLY research — do NOT write specs yet.
881
+ > **Lifecycle**: You persist through the entire workflow. After Gate #1, you will receive spec-drafting tasks via DM. After Gate #2, you shift to consultative role for builders.
882
+
883
+ After Gate #1, the lead sends the approved Change Set via DM and creates spec-drafting tasks. For spec-drafting prompts, see Phase 1B below.
884
+
885
+ ---
886
+
609
887
  ## Phase 1B: Specification
610
888
 
611
889
  **Agent**: `architect` | **Loop.md**: Section 3.2
612
890
 
613
- **Spawn prompt**:
891
+ **Spec-drafting prompt** (sent via DM to already-warm architect in Parallel Teams, or as spawn prompt in Sequential/Subagent):
614
892
  > You are the **architect** for WorkGroup `{wgid}`.
615
893
  > Read `agents/architect.md` for your full role definition.
616
894
  >
@@ -624,12 +902,29 @@ If MCP is configured and knowz-scribe is active, after Change Set approval:
624
902
  > **Conventions**: Update WorkGroup file with results (prefix entries with `KnowzCode:`). If blocked, report blocker and notify lead.
625
903
  > **Deliverable**: Finalized specs for all NodeIDs written to `knowzcode/specs/`.
626
904
 
905
+ **Spec-drafter spawn prompt** (Path B — 3+ NodeIDs, Parallel Teams only):
906
+ > You are `spec-drafter-{N}` for WorkGroup `{wgid}`.
907
+ > Read `agents/architect.md` for your full role definition — you follow the same Spec Philosophy, Spec Format, and Consolidation Mandate.
908
+ >
909
+ > **Goal**: {goal}
910
+ > **Your NodeIDs**: {partition — 1-2 NodeIDs assigned to this drafter}
911
+ > **Architect Research**: {research findings from architect's speculative research for these NodeIDs}
912
+ > **Cross-NodeID Constraints**: {interface dependencies, shared specs, naming conventions from architect}
913
+ > **Context files**: Read sections 1-2 and 3.2 of `knowzcode/knowzcode_loop.md`, `knowzcode/knowzcode_project.md`, `knowzcode/knowzcode_architecture.md`
914
+ > **WorkGroup file**: `knowzcode/workgroups/{wgid}.md`
915
+ > **Specs directory**: `knowzcode/specs/`
916
+ >
917
+ > **Your Task**: #{task-id} — claim immediately (`TaskUpdate(status: "in_progress")`). Mark completed with summary when done.
918
+ > **Deliverable**: Draft specs for your assigned NodeIDs written to `knowzcode/specs/`. The architect will review for consistency after all drafters finish.
919
+
627
920
  **Dispatch**:
628
- - *Parallel Teams*: Architect is already warm from Stage 0 pre-load. Lead sends DM with approved Change Set, then creates spec-drafting tasks. **Plan approval enabled** — add to prompt: `Present your spec design for lead review BEFORE writing final specs. Wait for approval.` If `AUTONOMOUS_MODE = true`: auto-approve `plan_approval_request` immediately. Log `[AUTO-APPROVED] Architect plan`.
921
+ - *Parallel Teams*:
922
+ - **Path A** (< PARALLEL_SPEC_THRESHOLD NodeIDs): Architect is already warm from Stage 0 pre-load + speculative research. Lead sends DM with approved Change Set, then creates spec-drafting tasks. **Plan approval enabled** — add to prompt: `Present your spec design for lead review BEFORE writing final specs. Wait for approval.` If `AUTONOMOUS_MODE = true`: auto-approve `plan_approval_request` immediately. Log `[AUTO-APPROVED] Architect plan`.
923
+ - **Path B** (>= PARALLEL_SPEC_THRESHOLD NodeIDs): Lead asks architect for partition plan. Architect proposes partitions. Lead spawns spec-drafters (`subagent_type: "architect"`, `permissionMode: "acceptEdits"`, `maxTurns: 15`) with partition-scoped prompts. After all drafters complete, architect runs consistency review and reports to lead.
629
924
  - *Sequential Teams*: Spawn teammate `architect`, create task `Phase 1B: Draft specifications for {N} NodeIDs`. **Plan approval enabled** — add to prompt: `Present your spec design for lead review BEFORE writing final specs. Wait for approval.` Wait for `plan_approval_request`, review, respond with `plan_approval_response`. If `AUTONOMOUS_MODE = true`: auto-approve immediately. Log `[AUTO-APPROVED] Architect plan`.
630
925
  - *Subagent*: `Task(subagent_type="architect", description="Phase 1B specification drafting", prompt=<above> + "Present your spec design in your output for lead review.")`
631
926
 
632
- > **Note:** Plan approval (agent pauses for lead review) only works in Agent Teams mode via `permissionMode: plan`. In subagent mode, the architect presents its design in the output for post-hoc review.
927
+ > **Note:** Plan approval (agent pauses for lead review) only works in Agent Teams mode via `permissionMode: plan`. In subagent mode, the architect presents its design in the output for post-hoc review. Spec-drafters (Path B) do NOT use plan approval — they follow the architect's partition briefing directly.
633
928
 
634
929
  ### Quality Gate #2
635
930
 
@@ -643,6 +938,10 @@ Present specs for batch approval:
643
938
  |--------|------|---------------------|
644
939
  | ... | ... | ... |
645
940
 
941
+ ### Specialist Reports [only when SPECIALISTS_ENABLED non-empty]
942
+ **Architect**: {specs align with component map, drift concerns, pattern consistency}
943
+ **Test Advisor**: {spec testability assessment, recommended test types per NodeID}
944
+
646
945
  Review specs and approve to proceed to implementation?
647
946
  ```
648
947
 
@@ -728,13 +1027,19 @@ Present audit results:
728
1027
  **Security Posture**: {status}
729
1028
  **Gaps Found**: {count}
730
1029
 
1030
+ ### Specialist Reports [only when SPECIALISTS_ENABLED non-empty]
1031
+ **Security Officer**: Findings: {N} | Critical: {N} | High: {N} | {details or [Pending]}
1032
+ **Architect**: Drift: {Yes/No} | Pattern Violations: {N} | {details}
1033
+ **Test Advisor**: TDD Compliance: {%} | Missing Edge Cases: {N} | Quality: {Good/Adequate/Poor} | {details or [Pending]}
1034
+ **Project Advisor**: New REFACTOR tasks: {N} | Ideas captured to vault: {N}
1035
+
731
1036
  **Recommendation**: {proceed / return to implementation}
732
1037
 
733
1038
  How would you like to proceed?
734
1039
  ```
735
1040
 
736
1041
  **Autonomous Mode**: If `AUTONOMOUS_MODE = true`:
737
- - **Safety check**: If any security finding rated HIGH or CRITICAL → **PAUSE** autonomous mode for this gate. Announce: `> **Autonomous Mode Paused** — HIGH/CRITICAL security finding requires manual review.`
1042
+ - **Safety check**: If any security finding rated HIGH or CRITICAL (from reviewer OR security-officer `[SECURITY-BLOCK]`) → **PAUSE** autonomous mode for this gate. Announce: `> **Autonomous Mode Paused** — HIGH/CRITICAL security finding requires manual review.`
738
1043
  - **Safety check**: If ARC completion < 50% → **PAUSE** autonomous mode for this gate. Announce: `> **Autonomous Mode Paused** — ARC completion below 50% requires manual review.`
739
1044
  - If safety checks pass and gaps found → log `[AUTO-APPROVED] Gate #3 — proceeding to gap loop`, auto-proceed to gap loop.
740
1045
  - If safety checks pass and no gaps → log `[AUTO-APPROVED] Gate #3`, auto-proceed to Phase 3.