@dug-21/unimatrix 0.5.8 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dug-21/unimatrix",
3
- "version": "0.5.8",
3
+ "version": "0.6.0",
4
4
  "description": "Unimatrix knowledge engine for multi-agent development",
5
5
  "bin": {
6
6
  "unimatrix": "bin/unimatrix.js"
@@ -9,14 +9,15 @@
9
9
  "postinstall": "node postinstall.js"
10
10
  },
11
11
  "optionalDependencies": {
12
- "@dug-21/unimatrix-linux-x64": "0.5.8",
13
- "@dug-21/unimatrix-linux-arm64": "0.5.8"
12
+ "@dug-21/unimatrix-linux-x64": "0.6.0",
13
+ "@dug-21/unimatrix-linux-arm64": "0.6.0"
14
14
  },
15
15
  "files": [
16
16
  "bin/",
17
17
  "lib/",
18
18
  "skills/",
19
- "postinstall.js"
19
+ "postinstall.js",
20
+ "protocols/"
20
21
  ],
21
22
  "license": "MIT OR Apache-2.0",
22
23
  "repository": {
@@ -0,0 +1,126 @@
1
+ # Unimatrix Protocol Reference
2
+
3
+ This directory contains the reference workflow protocols for Claude Code + Unimatrix
4
+ delivery. Each protocol defines how a coordinator agent orchestrates specialist agents
5
+ through a structured session (design, delivery, or bug fix) while integrating with the
6
+ Unimatrix knowledge engine via the `context_cycle` MCP tool.
7
+
8
+ ---
9
+
10
+ ## What These Protocols Are
11
+
12
+ The four files in this directory describe three session types:
13
+
14
+ | File | Session Type | Triggers On |
15
+ |------|-------------|-------------|
16
+ | `uni-design-protocol.md` | Design (Session 1) | specification, architecture, scope definition |
17
+ | `uni-delivery-protocol.md` | Delivery (Session 2) | implement, build, code, deliver |
18
+ | `uni-bugfix-protocol.md` | Bug Fix (single session) | bug, fix, regression, failing |
19
+ | `uni-agent-routing.md` | Routing reference | agent selection and swarm composition |
20
+
21
+ Each protocol is a coordinator playbook: it defines which specialist agents to spawn,
22
+ in what order, and what validation gates must pass before the session can advance.
23
+
24
+ ---
25
+
26
+ ## How context_cycle Works
27
+
28
+ `context_cycle` is the Unimatrix MCP tool that links workflow execution to
29
+ knowledge delivery. Calling it at phase boundaries does two things:
30
+
31
+ 1. **Sets attribution context** — subsequent knowledge queries and stores are tagged
32
+ against the current feature and phase, so the learning model knows what knowledge
33
+ was used during which workflow moment.
34
+
35
+ 2. **Enables phase-conditioned retrieval** — `context_briefing` uses the phase signal
36
+ to rank knowledge entries that are historically relevant to the current phase.
37
+ Knowledge that proved useful during design phases is surfaced to design agents;
38
+ knowledge useful during delivery is surfaced to delivery agents.
39
+
40
+ ### The Three Call Types
41
+
42
+ | Call | When to Use | Effect |
43
+ |------|------------|--------|
44
+ | `"type": "start"` | Before any agents are spawned | Opens the cycle, sets feature + phase attribution |
45
+ | `"type": "phase-end"` | At each phase transition | Records what was accomplished, advances the phase signal |
46
+ | `"type": "stop"` | After the session ends | Commits all signals to the learning model; closes the cycle |
47
+
48
+ ---
49
+
50
+ ## Two-Phase Example: Design to Delivery
51
+
52
+ The following shows the `context_cycle` calls across a complete two-phase workflow.
53
+ Protocol files contain agent spawn templates and gate logic; this example focuses only
54
+ on the cycle calls.
55
+
56
+ ```
57
+ # --- Session 1: Design ---
58
+
59
+ # Open the cycle before spawning any agents
60
+ mcp__unimatrix__context_cycle({
61
+ "feature": "my-feature-001",
62
+ "type": "start",
63
+ "next_phase": "scope"
64
+ })
65
+
66
+ # ... scope research and SCOPE.md approval ...
67
+
68
+ mcp__unimatrix__context_cycle({
69
+ "feature": "my-feature-001",
70
+ "type": "phase-end",
71
+ "phase": "scope",
72
+ "outcome": "SCOPE.md approved. Scope risk assessment complete.",
73
+ "next_phase": "design"
74
+ })
75
+
76
+ # ... architecture, specification, risk strategy, vision alignment, synthesis ...
77
+
78
+ mcp__unimatrix__context_cycle({
79
+ "feature": "my-feature-001",
80
+ "type": "phase-end",
81
+ "phase": "design",
82
+ "outcome": "Architecture, specification, and risk strategy complete.",
83
+ "next_phase": "design-review"
84
+ })
85
+
86
+ # Session 1 ends here. The cycle remains open for Session 2.
87
+
88
+ # --- Session 2: Delivery ---
89
+
90
+ # Re-declare the cycle at the start of Session 2
91
+ mcp__unimatrix__context_cycle({
92
+ "feature": "my-feature-001",
93
+ "type": "start",
94
+ "next_phase": "spec"
95
+ })
96
+
97
+ # ... pseudocode + test plan design (Stage 3a) ...
98
+ # ... code implementation (Stage 3b) ...
99
+ # ... testing and risk validation (Stage 3c) ...
100
+
101
+ mcp__unimatrix__context_cycle({
102
+ "feature": "my-feature-001",
103
+ "type": "phase-end",
104
+ "phase": "pr-review",
105
+ "outcome": "PR review complete. No blocking findings.",
106
+ "next_phase": "done"
107
+ })
108
+
109
+ # Close the cycle after the PR is merged and the session is complete
110
+ mcp__unimatrix__context_cycle({
111
+ "feature": "my-feature-001",
112
+ "type": "stop",
113
+ "outcome": "Session 2 complete. All gates passed. PR merged."
114
+ })
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Generalizability
120
+
121
+ These protocols are Claude Code + Unimatrix reference implementations. The
122
+ `context_cycle` pattern is not Claude-specific — it applies to any agentic workflow
123
+ tool that can call MCP tools: the three call types (`start`, `phase-end`, `stop`)
124
+ model any workflow with named phases, regardless of domain or tooling. The protocols
125
+ in this directory are examples of how one team wires context_cycle into a software
126
+ delivery workflow; they are a starting point, not a requirement.
@@ -0,0 +1,187 @@
1
+ # Agent Routing and Swarm Composition
2
+
3
+ ## Agent Preference
4
+
5
+ Always use `uni-` agents for Unimatrix product work:
6
+
7
+ | Instead of | Use | Why |
8
+ |------------|-----|-----|
9
+ | generic coder | `uni-rust-dev` | Knows Unimatrix Rust patterns, queries `/uni-query-patterns` before implementing |
10
+ | generic architect | `uni-architect` | ADR authority, stores decisions in Unimatrix |
11
+ | generic tester | `uni-tester` | Risk-based testing, dual-phase role |
12
+ | generic planner | Design Leader (you) | Protocol-driven, reads the right protocol for the session |
13
+ | generic reviewer | `uni-validator` | Three-gate validation model |
14
+ | generic debugger | Bugfix Leader (you) | Reads bugfix protocol, coordinates diagnosis → fix → review |
15
+ | generic security auditor | `uni-security-reviewer` | Fresh-context security review of diffs |
16
+
17
+ ---
18
+
19
+ ## Coordinator Routing
20
+
21
+ One coordinator reads the protocol for the session type:
22
+
23
+ | User intent | Session type | Protocol |
24
+ |-------------|-------------|----------|
25
+ | Design, scope, spec, architecture | `design` | `.claude/protocols/uni/uni-design-protocol.md` |
26
+ | Implement, build, code, deliver | `delivery` | `.claude/protocols/uni/uni-delivery-protocol.md` |
27
+ | Bug fix | `bugfix` | `.claude/protocols/uni/uni-bugfix-protocol.md` |
28
+
29
+ For PR review and retrospective, use skills directly (no coordinator needed):
30
+
31
+ | User intent | Skill |
32
+ |-------------|-------|
33
+ | PR review, merge readiness | `/uni-review-pr` |
34
+ | Retrospective, knowledge extraction | `/uni-retro` |
35
+
36
+ Every swarm also includes `uni-validator` at gates. Non-negotiable.
37
+
38
+ ---
39
+
40
+ ## Complete Agent Roster
41
+
42
+ ### Coordinator (you — the primary agent)
43
+
44
+ You are the coordinator. Read the protocol for the session type, spawn specialist agents, manage gates, update GH Issues. Read `.claude/agents/uni/coordinator (you).md` for role boundaries and behavioral rules.
45
+
46
+ ### Validation (1 agent — spawned at every gate)
47
+
48
+ | Agent | What It Does |
49
+ |-------|-------------|
50
+ | `uni-validator` | Validation gate. Spawned with different check sets per context. Reports PASS / REWORKABLE FAIL / SCOPE FAIL |
51
+
52
+ ### Design Session Specialists (6 agents)
53
+
54
+ | Agent | Type | Phase | What It Produces |
55
+ |-------|------|-------|-----------------|
56
+ | `uni-researcher` | specialist | 1 | Problem space exploration, writes SCOPE.md with human |
57
+ | `uni-architect` | specialist | 2a | `architecture/ARCHITECTURE.md` + ADRs in Unimatrix. ADR authority |
58
+ | `uni-specification` | specialist | 2a | `specification/SPECIFICATION.md` — requirements, ACs, domain models |
59
+ | `uni-risk-strategist` | specialist | 1b + 2a+ | `SCOPE-RISK-ASSESSMENT.md` (1b) + `RISK-TEST-STRATEGY.md` (2a+) |
60
+ | `uni-vision-guardian` | specialist | 2b | `ALIGNMENT-REPORT.md` — checks source docs against product vision |
61
+ | `uni-synthesizer` | synthesizer | 2c | `IMPLEMENTATION-BRIEF.md`, `ACCEPTANCE-MAP.md`, GH Issue (fresh context) |
62
+
63
+ ### Delivery Session Specialists (3 agents)
64
+
65
+ | Agent | Type | Stage | What It Does |
66
+ |-------|------|-------|-------------|
67
+ | `uni-pseudocode` | specialist | 3a | Per-component pseudocode. Queries `/uni-query-patterns` before designing |
68
+ | `uni-tester` | specialist | 3a + 3c | Test plan design (3a) + test execution with RISK-COVERAGE-REPORT.md (3c) |
69
+ | `uni-rust-dev` | developer | 3b | Implements code from validated pseudocode. Queries `/uni-query-patterns` before implementing |
70
+
71
+ ### Bug Fix Specialists (1 agent)
72
+
73
+ | Agent | Type | Phase | What It Does |
74
+ |-------|------|-------|-------------|
75
+ | `uni-bug-investigator` | specialist | 1 | Diagnoses root cause, proposes fix approach, identifies missing tests |
76
+
77
+ ### Shared Specialist (1 agent — used by `/uni-review-pr` skill)
78
+
79
+ | Agent | Type | Phase | What It Does |
80
+ |-------|------|-------|-------------|
81
+ | `uni-security-reviewer` | specialist | review | Fresh-context security review of PR diff, blast radius, OWASP assessment |
82
+
83
+ **Total: 13 specialist agents** (1 validator + 6 design + 3 delivery + 1 bug fix + 1 security + 1 retro-mode architect). You coordinate.
84
+
85
+ ---
86
+
87
+ ## Swarm Composition Templates
88
+
89
+ ### Design Session
90
+
91
+ ```
92
+ Coordinator: you (read uni-design-protocol.md + coordinator (you).md)
93
+ Phase 1: uni-researcher (scope exploration with human)
94
+ ★ HUMAN CHECKPOINT — approve SCOPE.md ★
95
+ Phase 1b: uni-risk-strategist (scope-risk mode)
96
+ Phase 2a: uni-architect + uni-specification (parallel)
97
+ Phase 2a+: uni-risk-strategist (architecture-risk mode)
98
+ Phase 2b: uni-vision-guardian (alignment check)
99
+ Phase 2c: uni-synthesizer (brief + maps + GH Issue) (fresh context)
100
+ Phase 2d: git commit + push + gh pr create --draft
101
+ Return to human — SESSION 1 ENDS
102
+ ```
103
+
104
+ ### Delivery Session
105
+
106
+ ```
107
+ Coordinator: you (read uni-delivery-protocol.md + coordinator (you).md)
108
+ Init: Read IMPLEMENTATION-BRIEF.md, create feature branch
109
+ Stage 3a: uni-pseudocode + uni-tester (test plans) (parallel)
110
+ UPDATE Component Map in IMPLEMENTATION-BRIEF.md
111
+ Gate 3a: uni-validator (design review) — MANDATORY BLOCK
112
+ Stage 3b: uni-rust-dev × N (one per component, MANDATORY) (parallel)
113
+ Gate 3b: uni-validator (code review)
114
+ Stage 3c: uni-tester (test execution)
115
+ Gate 3c: uni-validator (risk validation)
116
+ Phase 4: Commit, push, open PR
117
+ /uni-review-pr — security review + merge readiness
118
+ Return to human — SESSION 2 ENDS
119
+ ```
120
+
121
+ ### Bug Fix Session
122
+
123
+ ```
124
+ Coordinator: you (read uni-bugfix-protocol.md + coordinator (you).md)
125
+ Init: /uni-query-patterns + /uni-knowledge-search — prior knowledge
126
+ Phase 1: uni-bug-investigator (diagnose root cause)
127
+ ★ HUMAN CHECKPOINT — approve diagnosis ★
128
+ Phase 2: git checkout -b bugfix/{issue}-{desc}
129
+ uni-rust-dev (implement fix + tests)
130
+ Phase 3: uni-tester (full test suite verification)
131
+ Gate 3: uni-validator (bugfix check set)
132
+ git commit + push + gh pr create
133
+ Phase 4: /uni-review-pr — security review + merge readiness
134
+ Phase 5: Return PR + review assessment — SESSION ENDS
135
+ ```
136
+
137
+ ### PR Review (standalone)
138
+
139
+ ```
140
+ Human invokes: /uni-review-pr {pr-number}
141
+ Step 1: Verify gate reports
142
+ Step 2: uni-security-reviewer (fresh-context PR review)
143
+ Step 3: Merge readiness assessment
144
+ Step 4: Return to human — REVIEW ENDS
145
+ ```
146
+
147
+ ### Retrospective (standalone)
148
+
149
+ ```
150
+ Human invokes: /uni-retro {feature-id} {pr-number}
151
+ Phase 1: Data gathering (context_cycle_review + artifact review)
152
+ Phase 2: uni-architect (pattern/procedure extraction + ADR validation)
153
+ Phase 3: ADR supersession (if flagged, requires human approval)
154
+ Phase 4: Worktree cleanup
155
+ Phase 5: Summary + outcome recording — RETRO ENDS
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Composition Rules
161
+
162
+ 1. **Every swarm session**: you are the coordinator. Read the protocol and SM definition. No exceptions.
163
+ 2. **Validation gates**: `uni-validator` spawned at each gate by you.
164
+ 3. **Design session**: All six design agents in defined phase order per protocol.
165
+ 4. **Delivery session**: pseudocode + tester + rust-dev + validator at three gates per protocol.
166
+ 5. **Bug fix**: bug-investigator + rust-dev + tester + validator per protocol.
167
+ 6. **PR review**: `/uni-review-pr` skill + security-reviewer.
168
+ 7. **Retrospective**: `/uni-retro` skill + architect (+ tester if testing lessons needed).
169
+ 8. **Skip swarm for**: typos, single-line obvious fixes, config-only changes, docs, exploration.
170
+ 9. **Max workers per stage**: 5. Split into waves if more needed.
171
+
172
+ ---
173
+
174
+ ## Skills Available to Agents
175
+
176
+ | Skill | When | Who |
177
+ |-------|------|-----|
178
+ | `/uni-query-patterns` | BEFORE designing or implementing | uni-architect, uni-pseudocode, uni-rust-dev |
179
+ | `/uni-store-adr` | AFTER each design decision | uni-architect |
180
+ | `/uni-record-outcome` | END of every session | coordinator (you), `/uni-review-pr`, `/uni-retro` |
181
+ | `/uni-store-procedure` | After successful sessions (reusable techniques) | coordinator (you), uni-bug-investigator |
182
+ | `/uni-store-lesson` | After failures | uni-bug-investigator, uni-validator, coordinator (you) |
183
+ | `/uni-knowledge-search` | Exploring what's known | Any agent |
184
+ | `/uni-knowledge-lookup` | Exact-match retrieval | Any agent |
185
+ | `/uni-git` | Git conventions | coordinator (you) |
186
+ | `/uni-review-pr` | After PR creation or standalone | coordinator (you), human |
187
+ | `/uni-retro` | After merge | human |