@rosenfan/matrix 0.1.2 → 0.1.4

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 (37) hide show
  1. package/.claude/skills/matrix/SKILL.md +59 -62
  2. package/.claude/skills/matrix/scripts/matrix_claude.py +11 -11
  3. package/.claude/skills/matrix/scripts/matrix_state.py +53 -53
  4. package/.claude/skills/matrix-archive/SKILL.md +36 -33
  5. package/.claude/skills/matrix-build/SKILL.md +28 -23
  6. package/.claude/skills/matrix-claude/SKILL.md +13 -11
  7. package/.claude/skills/matrix-design/SKILL.md +32 -26
  8. package/.claude/skills/matrix-hotfix/SKILL.md +1 -1
  9. package/.claude/skills/matrix-open/SKILL.md +27 -15
  10. package/.claude/skills/matrix-status/SKILL.md +5 -5
  11. package/.claude/skills/matrix-tweak/SKILL.md +1 -1
  12. package/.claude/skills/matrix-verify/SKILL.md +35 -17
  13. package/README.md +131 -96
  14. package/README.zh-CN.md +127 -92
  15. package/assets/skills-zh-CN/matrix/SKILL.md +75 -72
  16. package/assets/skills-zh-CN/matrix-archive/SKILL.md +36 -33
  17. package/assets/skills-zh-CN/matrix-build/SKILL.md +41 -37
  18. package/assets/skills-zh-CN/matrix-claude/SKILL.md +33 -31
  19. package/assets/skills-zh-CN/matrix-design/SKILL.md +13 -7
  20. package/assets/skills-zh-CN/matrix-hotfix/SKILL.md +1 -1
  21. package/assets/skills-zh-CN/matrix-open/SKILL.md +18 -6
  22. package/assets/skills-zh-CN/matrix-status/SKILL.md +5 -5
  23. package/assets/skills-zh-CN/matrix-tweak/SKILL.md +1 -1
  24. package/assets/skills-zh-CN/matrix-verify/SKILL.md +27 -9
  25. package/package.json +2 -2
  26. package/src/catalog.js +29 -18
  27. package/src/cli.js +150 -39
  28. package/src/distribution.js +268 -114
  29. package/src/installer.js +10 -10
  30. package/src/matt-catalog.mjs +67 -0
  31. package/src/matt.js +115 -33
  32. package/src/messages.js +18 -14
  33. package/src/runtime-resolver.js +76 -0
  34. package/src/self-update.js +81 -0
  35. package/src/ui.js +1 -1
  36. package/src/workflow-transaction.js +622 -618
  37. package/src/workflow.js +949 -464
@@ -5,26 +5,38 @@ description: Open or resume the Matrix open phase by clarifying a development re
5
5
 
6
6
  # Matrix Open
7
7
 
8
- Run `matrix workflow inspect`, read the active change and its frozen `orchestration`, then produce `artifacts/proposal.md` containing exactly these substantive sections: `## Goal`, `## Scope`, `## Non-goals`, `## Acceptance`, and `## Risks`.
9
-
10
- ## Prim
11
-
12
- Use Matrix's own capability to clarify the request and write the proposal.
13
-
14
- ## Arch
15
-
8
+ Run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect` and follow its `profile` and `evidence_policy`.
9
+
10
+ Use its `artifact_language` for all proposal prose. Keep the required English heading tokens exactly as specified for Runtime guards; only the text beneath them is localized.
11
+
12
+ - **full**: produce `proposal.md` with `## Goal`, `## Scope`, `## Non-goals`, `## Acceptance`, and `## Risks`, then continue to Design.
13
+ - **lightweight**: produce the complete compact Contract before editing project implementation. Include `## Goal`, `## Scope`, `## Non-goals`, `## Approach`, `## Acceptance`, `## Validation`, `## Risks`, and `## Upgrade conditions`.
14
+ - **hotfix evidence**: also include `## Expected behavior`, `## Actual behavior`, and `## Reproduction`.
15
+ - **tweak evidence**: also include `## Current behavior`, `## Preserved behavior`, and `## Diff boundary`.
16
+
17
+ ## Prim
18
+
19
+ Use Matrix's own capability to clarify the request and write the proposal.
20
+
21
+ ## Arch
22
+
16
23
  Invoke `grilling` only when material ambiguity remains or the user asks to stress-test the request. Invoke `domain-modeling` only when domain vocabulary, invariants, or an architectural decision is unclear. Announce the capability and reason before invoking it; selecting Arch already authorizes triggered capabilities.
17
24
 
18
- Companion output is evidence for the Matrix proposal. It must not create another workflow, proposal, confirmation state, or phase transition. If a correctly installed capability fails, perform at most one Matrix-owned fallback for that same capability and record the failure and evidence. Installation-integrity failures require `matrix init --with-mattpocock` and are not eligible for fallback.
25
+ If progress is blocked by facts or decisions owned by another person, explain why `to-questionnaire` fits and ask the user to invoke it. Do not invoke the wrapper yourself.
26
+
27
+ Companion output is evidence for the Matrix proposal. It must not create another workflow, proposal, confirmation state, or phase transition. If a correctly installed capability fails, perform at most one Matrix-owned fallback for that same capability and record the failure and evidence. Installation-integrity failures require `matrix init --with-mattpocock` and are not eligible for fallback.
19
28
 
20
29
  ## Process
21
30
 
22
- 1. Resolve only ambiguities required by the active workflow.
23
- 2. Write the canonical proposal and synchronize material companion conclusions into it.
24
- 3. Ask the user to confirm when scope or risk is material.
25
- 4. Run the guard and transition, then enter `$matrix-design`.
31
+ 1. Resolve only ambiguities required by the active workflow.
32
+ 2. Write the canonical proposal and synchronize material companion conclusions into it.
33
+ 3. For full, ask for confirmation when scope or risk is material, then enter Design.
34
+ 4. For lightweight, always present the compact Contract and wait for explicit confirmation before entering Build.
26
35
 
27
36
  ```powershell
28
- matrix workflow guard open
29
- matrix workflow transition design
37
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard open
38
+ # full
39
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition design
40
+ # hotfix/tweak, only after explicit confirmation
41
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition build --confirmed
30
42
  ```
@@ -8,8 +8,8 @@ description: Inspect the active Matrix workflow and report its disk-backed phase
8
8
  Run the same Matrix state kernel used by the main entry and every phase Skill:
9
9
 
10
10
  ```powershell
11
- matrix workflow inspect
12
- matrix workflow doctor
13
- ```
14
-
15
- Report the returned change id, workflow, frozen `orchestration`, phase, guard result, `next_skill`, Workflow health, unfinished transactions, available strategies, and exact recovery commands. If Arch integrity fails, identify the affected platform/Skill facts and report `matrix init --with-mattpocock`; do not reinterpret the change as Prim. Both commands are read-only. Do not infer status from conversation history, run `--repair`, or modify state. If the guard is failing, name the missing evidence and direct the user to the current phase Skill.
11
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect
12
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor
13
+ ```
14
+
15
+ Report the returned change id, workflow, `profile`, `evidence_policy`, frozen `orchestration`, phase, guard result, `next_skill`, Workflow health, unfinished transactions, available strategies, and exact recovery commands. If Arch integrity fails, identify the affected platform/Skill facts and report `matrix init --with-mattpocock`; do not reinterpret the change as Prim. Both commands are read-only. Do not infer status from conversation history, run `--repair`, or modify state. If the guard is failing, name the missing evidence and direct the user to the current phase Skill.
@@ -5,4 +5,4 @@ description: Run a lightweight Matrix workflow for a bounded small development c
5
5
 
6
6
  # Matrix Tweak
7
7
 
8
- Start through `$matrix` with workflow `tweak` and preserve its frozen Prim or Arch orchestration. Keep proposal and design concise, but still define acceptance criteria and test seams. Arch invokes only capabilities whose normal task-fact triggers are present; shortcut workflows do not gain a fixed companion sequence or weaker evidence requirements. Use controlled Return and upgrade to full Matrix when the change crosses module, API, schema, or architecture boundaries.
8
+ Start through `$matrix` with workflow `tweak`. It uses the shared lightweight lifecycle `open → build → verify → archive`; there is no separate tweak state machine or Design phase. Before editing implementation, define current/preserved behavior, the diff boundary, acceptance, and validation in the compact proposal, present it, and wait for confirmation. Build and Verify must prove scope and diff alignment. Use controlled Return to upgrade to full when the change crosses module, API, schema, or architecture boundaries.
@@ -5,7 +5,9 @@ description: Verify the active Matrix change against its plan and review its dif
5
5
 
6
6
  # Matrix Verify
7
7
 
8
- Run the plan's acceptance commands and record their output summaries under `## Test evidence` in `artifacts/verification.md`.
8
+ Run the approved Contract's acceptance commands and record their output summaries under `## Test evidence` in `artifacts/verification.md`.
9
+
10
+ Write verification prose in `artifact_language` from inspect while preserving the required English evidence headings.
9
11
 
10
12
  ## Input Sources
11
13
 
@@ -27,38 +29,53 @@ Before starting verification, ensure:
27
29
 
28
30
  If these are missing (e.g., Claude Code didn't produce complete evidence), return to `$matrix-build` or ask Claude Code to补充.
29
31
 
30
- ## Orchestration
31
-
32
- Run `matrix workflow inspect` and read the frozen mode.
33
-
32
+ ## Orchestration
33
+
34
+ Run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect` and read the frozen mode.
35
+
34
36
  - **Prim**: Matrix performs the Standards and Spec review itself.
35
37
  - **Arch**: invoke `code-review` to produce both review axes; announce the invocation and reason.
36
38
 
37
39
  Review findings are inputs to Matrix Verify; a companion cannot decide the phase outcome, broaden approved architecture, transition, or archive. Do not invoke post-review architecture wrappers. A correctly installed review capability gets at most one same-capability Matrix fallback; installation-integrity failure stops verification.
40
+
41
+ Under `## Review evidence`, preserve two substantive subsections named `### Standards` and `### Spec`. Arch must then ask the project Runtime to bind those results to the current revision:
42
+
43
+ ```powershell
44
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs review --source code-review --fixed-point <ref> --standards <passed|failed> --spec <passed|failed>
45
+ ```
46
+
47
+ If `code-review` cannot run because the Git baseline is unavailable, the committed HEAD diff is empty, staged/unstaged/untracked candidate files exist, or the capability actually fails, document that limitation and use the single bounded fallback for this revision:
48
+
49
+ ```powershell
50
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs review --source matrix-fallback --reason <git-baseline-unavailable|empty-head-diff|uncommitted-worktree|capability-execution-failed> [--fixed-point <ref-for-empty-head-diff-or-uncommitted-worktree>] --standards <passed|failed> --spec <passed|failed>
51
+ ```
52
+
53
+ Never label fallback output as a successful `code-review` run. `empty-head-diff` requires the fixed point so Runtime can verify the empty three-dot diff. `uncommitted-worktree` requires a fixed point and Runtime binds the staged, unstaged, and untracked candidate content into `candidate_hash`; any later change makes the receipt stale. If a receipt already exists or either axis failed, use a controlled Return before another attempt.
38
54
 
39
55
  ## Failure Handling
40
56
 
41
- If verification or review fails:
42
- - If the issue is in the implementation, run `matrix workflow return build --reason verification-failed`, then enter `$matrix-build` or ask Claude Code to fix.
43
- - If the issue is in the acceptance criteria or design, run `matrix workflow return design --reason acceptance-or-design-gap`, then enter `$matrix-design`.
44
-
45
- Both Return paths rotate the current `verification.md` into revisioned evidence history. Do not copy stale conclusions back into the new current evidence.
57
+ If verification or review fails:
58
+ - If the issue is in the implementation, run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs return build --reason verification-failed`, then enter `$matrix-build` or ask Claude Code to fix.
59
+ - If the issue is in the acceptance criteria or design, run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason acceptance-or-design-gap`, then enter `$matrix-design`.
60
+
61
+ Both Return paths rotate the current `verification.md` and any `review-receipt.json` into revisioned evidence history. Do not copy stale conclusions or receipts back into the new current evidence.
46
62
 
47
63
  If documents or public behavior changed, record the required synchronization work before the guard.
48
64
 
49
65
  ## Process
50
66
 
51
67
  1. Check that `artifacts/verification.md` exists with `## Build evidence`
52
- 2. Run the plan's acceptance commands (from `plan.md` `## Validation` section)
53
- 3. Record test output under `## Test evidence`
68
+ 2. Run the approved validation commands (full plan or lightweight proposal)
69
+ 3. Record test output under `## Test evidence`
54
70
  4. Produce both Standards and Spec review axes through the selected orchestration mode
55
- 6. Record findings under `## Review evidence`
71
+ 5. Record findings under `## Review evidence` with `### Standards` and `### Spec`
72
+ 6. In Arch, record the Runtime review receipt for the current revision
56
73
  7. Run the guard
57
74
  8. If it passes, transition to archive and enter `$matrix-archive`
58
75
 
59
76
  ```powershell
60
- matrix workflow guard verify
61
- matrix workflow transition archive
77
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard verify
78
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition archive
62
79
  ```
63
80
 
64
81
  ## Evidence Requirements
@@ -66,6 +83,7 @@ matrix workflow transition archive
66
83
  The guard checks for:
67
84
 
68
85
  1. **Test evidence** — Output from running the plan's validation commands
69
- 2. **Review evidence** — Findings from the two-axis code review
86
+ 2. **Review evidence** — Separate Standards and Spec findings from the selected review path
87
+ 3. **Arch review receipt** — Runtime-bound identity for the current Contract, evidence, workspace, and normal or fallback source
70
88
 
71
- Both must be present and substantive (>40 chars each) to pass the guard.
89
+ Full requires Test and Review evidence. Hotfix additionally requires `## Regression evidence`; tweak additionally requires `## Scope review evidence`.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Matrix Workflow
2
2
 
3
- An evidence-driven development workflow with Prim and Arch orchestration, inspired by [Comet](https://github.com/rpamis/comet). Matrix can work with its own capabilities or conditionally invoke a verified cohort of [Matt Pocock's agent skills](https://github.com/mattpocock/skills) without giving up lifecycle ownership.
3
+ An evidence-driven development workflow with Prim and Arch orchestration, inspired by [Comet](https://github.com/rpamis/comet). Matrix can work with its own capabilities or conditionally invoke a verified cohort of [Matt Pocock's agent skills](https://github.com/mattpocock/skills) without giving up lifecycle ownership.
4
4
 
5
5
  English | **[中文](./README.zh-CN.md)**
6
6
 
@@ -27,38 +27,39 @@ English | **[中文](./README.zh-CN.md)**
27
27
 
28
28
  ## Why Matrix
29
29
 
30
- [Matt Pocock's skills](https://github.com/mattpocock/skills) provide focused capabilities such as `/grilling`, `/tdd`, and `/code-review`. Using independent tools without a lifecycle owner leads to common problems:
30
+ [Matt Pocock's skills](https://github.com/mattpocock/skills) provide focused capabilities such as `/grilling`, `/tdd`, and `/code-review`. Using independent tools without a lifecycle owner leads to common problems:
31
31
 
32
32
  - **No process memory**: You grill, then implement, but there's no record of what was decided
33
33
  - **Phase confusion**: Did we finish design? Are we in build? Hard to tell after context loss
34
34
  - **Silent scope creep**: Requirements change mid-build without returning to design
35
35
  - **Missing evidence**: "Looks done" without verification proof
36
36
 
37
- Matrix solves this with one deterministic state machine, explicit phases, guard conditions, and artifact tracking — inspired by [Comet](https://github.com/rpamis/comet)'s phase-based approach. Skills can assist a phase, but Matrix always owns the lifecycle.
37
+ Matrix solves this with one deterministic state machine, explicit phases, guard conditions, and artifact tracking — inspired by [Comet](https://github.com/rpamis/comet)'s phase-based approach. Skills can assist a phase, but Matrix always owns the lifecycle.
38
38
 
39
39
  ---
40
40
 
41
41
  ## What It Does
42
42
 
43
- Matrix provides two capability-orchestration modes over the same workflow:
44
-
45
- ```
46
- open → design → build → verify → archive
47
-
48
- Prim: Matrix performs phase work itself
49
- Arch: Matrix invokes verified atomic Skills only when task facts trigger them
50
- ```
51
-
52
- Recovery paths are controlled Runtime intents:
53
-
54
- ```text
55
- build --design-gap--------------------> design
56
- verify --verification-failed-----------> build
57
- verify --acceptance-or-design-gap------> design
58
- any active phase --abort--------------> aborted
59
- ```
60
-
61
- Each phase:
43
+ Matrix provides two capability-orchestration modes over two centrally defined workflow profiles:
44
+
45
+ ```
46
+ full: open → design → build → verify → archive
47
+ hotfix/tweak lightweight: open ─────────→ build → verify → archive
48
+
49
+ Prim: Matrix performs phase work itself
50
+ Arch: Matrix invokes verified atomic Skills only when task facts trigger them
51
+ ```
52
+
53
+ Recovery paths are controlled Runtime intents:
54
+
55
+ ```text
56
+ build --design-gap--------------------> design
57
+ verify --verification-failed-----------> build
58
+ verify --acceptance-or-design-gap------> design
59
+ any active phase --abort--------------> aborted
60
+ ```
61
+
62
+ Each phase:
62
63
  - Has specific deliverables (artifacts)
63
64
  - Has guard conditions that must pass
64
65
  - Logs all transitions
@@ -68,9 +69,10 @@ Each phase:
68
69
 
69
70
  ## Prerequisites
70
71
 
71
- - [Claude Code](https://docs.anthropic.com/claude-code) and/or Codex installed
72
- - Node.js 18+ (for the installer)
73
- - Python is optional during the compatibility window; new installations run the bundled Node workflow runtime.
72
+ - [Claude Code](https://docs.anthropic.com/claude-code) and/or Codex installed as the Skill host
73
+ - Node.js 18+ and `npm` on `PATH` (for the Matrix CLI)
74
+ - Python is optional during the compatibility window; new installations use the bundled Node workflow runtime.
75
+ - Git is only needed when installing from GitHub or contributing to Matrix.
74
76
 
75
77
  ---
76
78
 
@@ -91,29 +93,51 @@ matrix init
91
93
 
92
94
  The interactive setup lets you:
93
95
 
94
- - Choose English or Chinese, project or global scope, and Claude Code, Codex, or both
96
+ - Choose English or Chinese, project or global Matrix discovery scope, and Claude Code, Codex, or both
95
97
  - Copy skills (recommended) or symlink them for local development
96
- - Safely update an existing installation with an automatic backup
97
- - Install Matt Pocock's companion skills in the same flow
98
- - Choose **Prim** or **Arch** as the project default without disabling the other available mode
98
+ - Safely reconfigure an existing installation with an automatic backup
99
+ - Review all 25 official Matt Skills v1.2.3 roles and install the 23 compatible Skills into the target project
100
+ - Choose **Prim** or **Arch** as the project default without disabling the other available mode
99
101
 
100
102
  For automation and CI:
101
103
 
102
104
  ```bash
103
105
  # Safe non-interactive installation for both verified platforms
104
- matrix init --yes --platform claude-code --platform codex --with-mattpocock
105
-
106
+ matrix init --yes --platform claude-code --platform codex --with-mattpocock
107
+
106
108
  # Explicitly select the project default
107
109
  matrix init --yes --with-mattpocock --default-orchestration arch
110
+
111
+ # Replace locally modified Matt Skills only after an explicit backup authorization
112
+ matrix init --yes --with-mattpocock --force-matt
108
113
 
109
114
  # Preview exactly what would change (including backups) without writing
110
115
  matrix init --platform codex --dry-run --json
111
116
 
112
- # Inspect Matrix ownership, Matt Skills inheritance, and the selected platform
113
- matrix doctor --platform codex
117
+ # Inspect Matrix ownership, project-local Matt compatibility, and the selected platform
118
+ matrix doctor --platform codex
119
+ ```
120
+
121
+ Update an initialized project:
122
+
123
+ ```bash
124
+ # Check for a newer Matrix CLI, confirm the plan, then refresh this project's installed assets
125
+ matrix update
126
+
127
+ # Offline or local-development refresh: skip the npm registry and use the current CLI package
128
+ matrix update --skip-self-update
129
+
130
+ # Non-interactive update after CI has explicitly authorized writes
131
+ matrix update --yes
114
132
  ```
115
133
 
116
- Until the npm package is published, install directly from GitHub:
134
+ `matrix update` preserves the installation's scope, platforms, language, mode, and orchestration. It first validates a newer npm package in isolation, then re-runs the new CLI to refresh Matrix assets. It never downloads, installs, repairs, or deletes Matt Skills; after the Matrix update it reports the local Matt compatibility status and, when needed, points to `matrix init . --with-mattpocock`. npm and project assets are separate transactions: if asset refresh fails after a CLI upgrade, run `matrix update --skip-self-update` to retry.
135
+
136
+ Matrix 0.1.4 is bound to Matt Skills v1.2.3 at commit `6acc160e4e0cd062dbbbd7a1b26ae92855edf07e`. `matrix init --with-mattpocock` always uses that exact archive and its reviewed 23-Skill compatible manifest, even if upstream has a newer release. The two official but incompatible Skills, `implement` and raw `resolving-merge-conflicts`, are not Matrix-managed or installed. Matrix scope controls Matrix Skill discovery only: Matt Skills and `.matrix/matt-installation.json` are always project-local. Global Matt copies are preserved but never used to complete project readiness.
137
+
138
+ The language selected by `matrix init` controls the prose in new Matrix artifacts. Markdown headings required by Matrix guards remain stable English tokens; the artifact body is Chinese for `zh-CN` and English for `en`. A change freezes this language at creation time.
139
+
140
+ To install directly from GitHub instead of npm:
117
141
 
118
142
  ```bash
119
143
  npm install --global github:Rosenfan/Matrix
@@ -121,10 +145,10 @@ npm install --global github:Rosenfan/Matrix
121
145
 
122
146
  Matrix installs:
123
147
  - `matrix/` — Entry point and state management
124
- - `matrix-open/` — Open phase and canonical proposal
125
- - `matrix-design/` — Design, plan, and Contract approval
126
- - `matrix-build/` — Bounded implementation and build evidence
127
- - `matrix-verify/` — Test and two-axis review evidence
148
+ - `matrix-open/` — Open phase and canonical proposal
149
+ - `matrix-design/` — Design, plan, and Contract approval
150
+ - `matrix-build/` — Bounded implementation and build evidence
151
+ - `matrix-verify/` — Test and two-axis review evidence
128
152
  - `matrix-archive/` — Archive phase
129
153
  - `matrix-hotfix/` — Shortcut for small bugs
130
154
  - `matrix-tweak/` — Shortcut for bounded changes
@@ -142,9 +166,9 @@ $matrix I want to add user authentication
142
166
  ```
143
167
 
144
168
  Matrix will:
145
- 1. Initialize a change with workflow type `full` and frozen orchestration `prim|arch`
146
- 2. Enter `open`; Prim works directly, while Arch invokes only proven requirement triggers
147
- 3. Create `proposal.md` with Goal, Scope, Non-goals, Acceptance, Risks
169
+ 1. Initialize a change with workflow type `full` and frozen orchestration `prim|arch`
170
+ 2. Enter `open`; Prim works directly, while Arch invokes only proven requirement triggers
171
+ 3. Create `proposal.md` with Goal, Scope, Non-goals, Acceptance, Risks
148
172
  4. Guard check: are all sections substantive?
149
173
  5. If pass → transition to `design`
150
174
 
@@ -152,13 +176,13 @@ Matrix will:
152
176
 
153
177
  ## Workflow Phases
154
178
 
155
- | Phase | Arch capabilities (triggered, not a fixed sequence) | Deliverables | Guard Condition |
156
- |-------|------------------------------------------------------|--------------|-----------------|
157
- | **open** | `/grilling`, `/domain-modeling` | `proposal.md`; optional repository-standard context/ADR evidence | Goal, Scope, Non-goals, Acceptance, Risks present |
158
- | **design** | `/domain-modeling`, `/research`, `/wayfinder`, `/prototype`, `/codebase-design` | `design.md`, `plan.md` | Decisions, Test seams, Steps documented |
159
- | **build** | `/tdd`, `/diagnosing-bugs`, `/resolving-merge-conflicts` | Code, `verification.md` | Exact approved Contract matches; build evidence recorded |
160
- | **verify** | `/code-review` | Test & review evidence | Test and review evidence present |
161
- | **archive** | None; Matrix-owned in both modes | Archive record | Verify guard passed |
179
+ | Phase | Arch capabilities (triggered, not a fixed sequence) | Deliverables | Guard Condition |
180
+ |-------|------------------------------------------------------|--------------|-----------------|
181
+ | **open** | `/grilling`, `/domain-modeling` | `proposal.md`; optional repository-standard context/ADR evidence | Goal, Scope, Non-goals, Acceptance, Risks present |
182
+ | **design** | `/domain-modeling`, `/research`, `/prototype`, `/codebase-design`, conditional `/writing-for-agents` | `design.md`, `plan.md` | Decisions, Test seams, Steps documented |
183
+ | **build** | `/tdd`, `/diagnosing-bugs`, conditional `/writing-for-agents` and generate-only `/wizard` | Code, `verification.md` | Exact approved Contract matches; build evidence recorded |
184
+ | **verify** | `/code-review` | Test evidence, two-axis review, Arch receipt | Evidence is substantive; Arch receipt matches the current Contract, review, and workspace |
185
+ | **archive** | None; Matrix-owned in both modes | Archive record | Verify guard passed |
162
186
 
163
187
  ---
164
188
 
@@ -172,45 +196,50 @@ State is stored in `.matrix/`:
172
196
  ├── config.yaml
173
197
  ├── changes/
174
198
  │ └── <change-id>/
175
- │ ├── matrix.yaml # Canonical workflow, orchestration, phase, status, revision
176
- │ ├── events.jsonl
177
- │ └── artifacts/
178
- │ ├── proposal.md
179
- │ ├── design.md
180
- │ ├── plan.md
181
- │ ├── verification.md
182
- │ └── evidence-history/
183
- └── archive/
184
- ```
199
+ │ ├── matrix.yaml # Canonical workflow, orchestration, phase, status, revision
200
+ │ ├── workspace-baseline.json # Lightweight implementation-order boundary
201
+ │ ├── events.jsonl
202
+ │ └── artifacts/
203
+ │ ├── proposal.md
204
+ │ ├── design.md
205
+ │ ├── plan.md
206
+ │ ├── verification.md
207
+ │ └── evidence-history/
208
+ └── archive/
209
+ ```
185
210
 
186
211
  The state machine enforces transitions:
187
212
 
188
213
  ```bash
189
- # Check guard
190
- matrix workflow guard open
191
-
192
- # Advance (only if guard passes)
193
- matrix workflow transition design
194
-
195
- # Return from verification failure; stale evidence is retained in history
196
- matrix workflow return build --reason verification-failed
197
-
198
- # Abort without deleting artifacts or undoing worktree changes
199
- matrix workflow abort --reason requirement-cancelled
200
-
201
- # Final Archive is a mandatory two-step optimistic commit
202
- matrix workflow archive --dry-run
203
- matrix workflow archive --expect-preflight <sha256-returned-by-dry-run>
204
-
205
- # Diagnose an interrupted Workflow without writing
206
- matrix workflow doctor
207
-
208
- # Repair only the exact transaction or stale lock reported by doctor
209
- matrix workflow doctor --repair --transaction <id> --strategy <continue|rollback>
210
- matrix workflow doctor --repair --lock <id>
211
- ```
212
-
213
- `matrix.yaml` is the only canonical workflow/orchestration/phase/status/revision record, using `matrix/change/v2`. The resolved `prim|arch` value is frozen at initialization. Older schemas are rejected without mutation. The Design -> Build transition records a SHA-256 identity of the exact bytes of `proposal.md`, `design.md`, and `plan.md`; any byte change blocks Build, Verify, Archive, and Claude export until a controlled Return to Design and a new approval. Final Archive requires a read-only dry-run and a hash-bound commit; Runtime recomputes the protected change-directory manifest inside the Archive boundary and rejects drift. Every multi-file Workflow mutation is protected by a durable journal under `.matrix/transactions/`. `matrix workflow doctor` is read-only, and recovery requires the exact transaction/strategy or lock identity it reports. Terminal journals become bounded audit receipts; unresolved or conflicting journals are never automatically deleted.
214
+ # Check guard
215
+ matrix workflow guard open
216
+
217
+ # Advance (only if guard passes)
218
+ matrix workflow transition design
219
+
220
+ # Lightweight: approve the compact proposal and enter Build
221
+ matrix workflow transition build --confirmed
222
+
223
+ # Return from verification failure; stale evidence is retained in history
224
+ matrix workflow return build --reason verification-failed
225
+
226
+ # Abort without deleting artifacts or undoing worktree changes
227
+ matrix workflow abort --reason requirement-cancelled
228
+
229
+ # Final Archive is a mandatory two-step optimistic commit
230
+ matrix workflow archive --dry-run
231
+ matrix workflow archive --expect-preflight <sha256-returned-by-dry-run>
232
+ # hotfix/tweak commit command additionally carries --confirmed
233
+
234
+ # Diagnose an interrupted Workflow without writing
235
+ matrix workflow doctor
236
+
237
+ # Repair only the exact transaction or stale lock reported by doctor
238
+ matrix workflow doctor --repair --transaction <id> --strategy <continue|rollback>
239
+ matrix workflow doctor --repair --lock <id>
240
+ ```
241
+
242
+ `matrix.yaml` is the only canonical workflow/orchestration/phase/status/revision record, using `matrix/change/v2`. Full approval binds the exact bytes of proposal/design/plan. Lightweight approval binds the compact proposal, requires explicit confirmation, and compares the project with its initialization baseline so implementation cannot precede approval. Contract drift blocks later phases. Final Archive uses a read-only dry-run and hash-bound commit; shortcut workflows additionally require explicit confirmation. Multi-file mutations remain protected by durable journals.
214
243
 
215
244
  ---
216
245
 
@@ -222,6 +251,8 @@ matrix workflow doctor --repair --lock <id>
222
251
  | **hotfix** | Reproducible small bugs | Simplified: open → build → verify → archive |
223
252
  | **tweak** | Bounded changes, no API/schema impact | Simplified: open → build → verify → archive |
224
253
 
254
+ Hotfix and tweak reference the same internal `lightweight` transition profile. They differ only in routing and evidence: hotfix requires reproduction/root-cause/regression evidence; tweak requires behavior-boundary, diff, and scope-review evidence.
255
+
225
256
  ---
226
257
 
227
258
  ## Special Feature: matrix-claude
@@ -252,30 +283,34 @@ The sidecar does NOT change Matrix state. It's a pure export — like taking a s
252
283
 
253
284
  ---
254
285
 
255
- ## Integration with Matt Pocock's Skills
256
-
257
- Prim uses Matrix's own capability. Arch uses one initialization-verified cohort of ten atomic capabilities:
258
-
259
- | Phase | Capability | Trigger |
260
- |---|---|---|
261
- | open | `/grilling` | Material ambiguity or explicit stress-test request |
262
- | open/design | `/domain-modeling` | Unclear vocabulary, invariants, or architectural decisions |
263
- | design | `/research` | Required external facts are unavailable in the repository |
264
- | design | `/wayfinder` | Module ownership or dependency seams are unknown |
286
+ ## Integration with Matt Pocock's Skills
287
+
288
+ Prim uses Matrix's own capability. Matrix reviews all 25 official Matt v1.2.3 roles, installs the 23 compatible Skills, and lets Arch automatically invoke only this reviewed ten-capability cohort:
289
+
290
+ | Phase | Capability | Trigger |
291
+ |---|---|---|
292
+ | open | `/grilling` | Material ambiguity or explicit stress-test request |
293
+ | open/design | `/domain-modeling` | Unclear vocabulary, invariants, or architectural decisions |
294
+ | design | `/research` | Required external facts are unavailable in the repository |
265
295
  | design | `/prototype` | A material design question needs disposable evidence |
266
296
  | design | `/codebase-design` | A deep-module, interface, or test-seam decision remains |
297
+ | design/build | `/writing-for-agents` | The Contract changes agent-facing instructions or pointer-reached documents |
267
298
  | build | `/tdd` | Observable behavior changes at a testable seam |
268
299
  | build | `/diagnosing-bugs` | An actual failure exists and root cause is unknown |
269
- | build | `/resolving-merge-conflicts` | A merge or rebase conflict is in progress |
300
+ | build | `/wizard` | The Contract requires generated human-run shell steps; Matrix never runs them end-to-end |
270
301
  | verify | `/code-review` | Standards and Spec review evidence is required |
271
302
 
272
- `grill-with-docs`, `implement`, and `improve-codebase-architecture` are not Matrix-managed or automatically invoked. Existing user-installed copies are preserved as unmanaged extras. A companion never transitions, commits, archives, or writes Matrix state.
303
+ Matrix may recommend but never nest these user-invoked handoffs: `setup-matt-pocock-skills`, `improve-codebase-architecture`, `wayfinder`, `handoff`, and `to-questionnaire`. The user explicitly runs them outside the active phase; selected output may enter a governed Change.
304
+
305
+ Arch records a Runtime-managed review receipt after `code-review`, binding its fixed point and committed HEAD diff to the current Contract, review evidence, and workspace. A normal `code-review` receipt requires a clean candidate worktree outside Matrix-managed assets. When Git has no usable baseline, the committed diff is empty, staged/unstaged/untracked candidate files still exist, or the correctly installed capability fails, Matrix may perform one explicitly labelled same-capability fallback for that revision. The `uncommitted-worktree` fallback binds both the fixed point and a content hash of the complete worktree candidate. Installation-integrity failures never fall back. A heading or self-description without the matching receipt cannot advance Verify.
306
+
307
+ Installed standalone Skills are `ask-matt`, `grill-with-docs`, `triage`, `to-spec`, `to-tickets`, `grill-me`, `teach`, and `wait-what`. `implement` and raw `resolving-merge-conflicts` are incompatible because they can take over TDD/review/staging/commit effects owned by Matrix, so 0.1.4 neither installs nor manages them. Pre-existing copies are preserved and reported as unmanaged extras. Installation never grants automatic invocation, and no companion may transition, commit, archive, recover, or write Matrix state.
273
308
 
274
309
  ---
275
310
 
276
311
  **Key difference**: Matt Pocock's skills are individual tools. Matrix adds:
277
312
  - **State persistence**: Survives context loss
278
- - **Phase enforcement**: Can't skip design and jump to build
313
+ - **Phase enforcement**: Full cannot skip Design; lightweight cannot edit implementation before its confirmed Open Contract
279
314
  - **Evidence requirements**: Guards check for artifacts, not assertions
280
315
  - **Transition logging**: Full audit trail of phase changes
281
316