@cluesmith/codev 3.1.9 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/agent-farm/cli.d.ts.map +1 -1
  2. package/dist/agent-farm/cli.js +12 -5
  3. package/dist/agent-farm/cli.js.map +1 -1
  4. package/dist/agent-farm/commands/spawn-roles.d.ts +6 -1
  5. package/dist/agent-farm/commands/spawn-roles.d.ts.map +1 -1
  6. package/dist/agent-farm/commands/spawn-roles.js +49 -45
  7. package/dist/agent-farm/commands/spawn-roles.js.map +1 -1
  8. package/dist/agent-farm/commands/status.d.ts +14 -1
  9. package/dist/agent-farm/commands/status.d.ts.map +1 -1
  10. package/dist/agent-farm/commands/status.js +151 -34
  11. package/dist/agent-farm/commands/status.js.map +1 -1
  12. package/dist/agent-farm/commands/tower.d.ts +1 -0
  13. package/dist/agent-farm/commands/tower.d.ts.map +1 -1
  14. package/dist/agent-farm/commands/tower.js +6 -2
  15. package/dist/agent-farm/commands/tower.js.map +1 -1
  16. package/dist/agent-farm/servers/overview.d.ts.map +1 -1
  17. package/dist/agent-farm/servers/overview.js +2 -0
  18. package/dist/agent-farm/servers/overview.js.map +1 -1
  19. package/dist/agent-farm/servers/tower-instances.d.ts +18 -0
  20. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -1
  21. package/dist/agent-farm/servers/tower-instances.js +9 -1
  22. package/dist/agent-farm/servers/tower-instances.js.map +1 -1
  23. package/dist/agent-farm/servers/tower-server.js +34 -0
  24. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  25. package/dist/agent-farm/servers/tower-websocket.d.ts.map +1 -1
  26. package/dist/agent-farm/servers/tower-websocket.js +7 -1
  27. package/dist/agent-farm/servers/tower-websocket.js.map +1 -1
  28. package/dist/agent-farm/utils/architect-name.d.ts +13 -0
  29. package/dist/agent-farm/utils/architect-name.d.ts.map +1 -1
  30. package/dist/agent-farm/utils/architect-name.js +16 -0
  31. package/dist/agent-farm/utils/architect-name.js.map +1 -1
  32. package/dist/commands/adopt.d.ts.map +1 -1
  33. package/dist/commands/adopt.js +15 -1
  34. package/dist/commands/adopt.js.map +1 -1
  35. package/dist/commands/doctor.d.ts.map +1 -1
  36. package/dist/commands/doctor.js +26 -0
  37. package/dist/commands/doctor.js.map +1 -1
  38. package/dist/commands/init.d.ts.map +1 -1
  39. package/dist/commands/init.js +19 -1
  40. package/dist/commands/init.js.map +1 -1
  41. package/dist/commands/porch/prompts.d.ts +12 -0
  42. package/dist/commands/porch/prompts.d.ts.map +1 -1
  43. package/dist/commands/porch/prompts.js +33 -5
  44. package/dist/commands/porch/prompts.js.map +1 -1
  45. package/dist/commands/update.d.ts.map +1 -1
  46. package/dist/commands/update.js +37 -1
  47. package/dist/commands/update.js.map +1 -1
  48. package/dist/lib/forge-contracts.d.ts +9 -0
  49. package/dist/lib/forge-contracts.d.ts.map +1 -1
  50. package/dist/lib/forge-contracts.js.map +1 -1
  51. package/dist/lib/framework-ref-audit.d.ts +23 -0
  52. package/dist/lib/framework-ref-audit.d.ts.map +1 -0
  53. package/dist/lib/framework-ref-audit.js +84 -0
  54. package/dist/lib/framework-ref-audit.js.map +1 -0
  55. package/dist/lib/managed-block.d.ts +31 -0
  56. package/dist/lib/managed-block.d.ts.map +1 -0
  57. package/dist/lib/managed-block.js +114 -0
  58. package/dist/lib/managed-block.js.map +1 -0
  59. package/dist/lib/scaffold.d.ts +42 -0
  60. package/dist/lib/scaffold.d.ts.map +1 -1
  61. package/dist/lib/scaffold.js +81 -0
  62. package/dist/lib/scaffold.js.map +1 -1
  63. package/dist/lib/skeleton.d.ts +12 -0
  64. package/dist/lib/skeleton.d.ts.map +1 -1
  65. package/dist/lib/skeleton.js +21 -0
  66. package/dist/lib/skeleton.js.map +1 -1
  67. package/dist/lib/templates.d.ts.map +1 -1
  68. package/dist/lib/templates.js +3 -0
  69. package/dist/lib/templates.js.map +1 -1
  70. package/dist/terminal/pty-manager.d.ts +18 -2
  71. package/dist/terminal/pty-manager.d.ts.map +1 -1
  72. package/dist/terminal/pty-manager.js +27 -2
  73. package/dist/terminal/pty-manager.js.map +1 -1
  74. package/dist/terminal/pty-session.d.ts +2 -0
  75. package/dist/terminal/pty-session.d.ts.map +1 -1
  76. package/dist/terminal/pty-session.js +13 -0
  77. package/dist/terminal/pty-session.js.map +1 -1
  78. package/dist/terminal/ring-buffer.d.ts +25 -1
  79. package/dist/terminal/ring-buffer.d.ts.map +1 -1
  80. package/dist/terminal/ring-buffer.js +40 -12
  81. package/dist/terminal/ring-buffer.js.map +1 -1
  82. package/dist/terminal/session-manager.d.ts +4 -0
  83. package/dist/terminal/session-manager.d.ts.map +1 -1
  84. package/dist/terminal/session-manager.js +74 -9
  85. package/dist/terminal/session-manager.js.map +1 -1
  86. package/dist/terminal/shellper-process.d.ts +1 -0
  87. package/dist/terminal/shellper-process.d.ts.map +1 -1
  88. package/dist/terminal/shellper-process.js +17 -2
  89. package/dist/terminal/shellper-process.js.map +1 -1
  90. package/package.json +3 -3
  91. package/scripts/forge/gitea/pr-list.sh +14 -1
  92. package/scripts/forge/github/pr-list.sh +9 -2
  93. package/scripts/forge/gitlab/pr-list.sh +11 -1
  94. package/skeleton/.claude/skills/update-arch-docs/SKILL.md +38 -13
  95. package/skeleton/porch/prompts/review.md +19 -11
  96. package/skeleton/protocols/air/builder-prompt.md +7 -1
  97. package/skeleton/protocols/aspir/builder-prompt.md +7 -2
  98. package/skeleton/protocols/aspir/prompts/plan.md +2 -34
  99. package/skeleton/protocols/aspir/prompts/review.md +19 -11
  100. package/skeleton/protocols/aspir/templates/review.md +4 -4
  101. package/skeleton/protocols/bugfix/builder-prompt.md +7 -1
  102. package/skeleton/protocols/bugfix/protocol.md +78 -0
  103. package/skeleton/protocols/experiment/builder-prompt.md +7 -1
  104. package/skeleton/protocols/experiment/protocol.md +7 -28
  105. package/skeleton/protocols/maintain/builder-prompt.md +7 -1
  106. package/skeleton/protocols/maintain/prompts/maintain.md +5 -4
  107. package/skeleton/protocols/maintain/prompts/review.md +1 -1
  108. package/skeleton/protocols/maintain/protocol.md +30 -22
  109. package/skeleton/protocols/maintain/templates/maintenance-run.md +2 -2
  110. package/skeleton/protocols/pir/builder-prompt.md +8 -3
  111. package/skeleton/protocols/pir/prompts/review.md +9 -7
  112. package/skeleton/protocols/pir/protocol.md +1 -1
  113. package/skeleton/protocols/research/builder-prompt.md +7 -1
  114. package/skeleton/protocols/spike/builder-prompt.md +7 -1
  115. package/skeleton/protocols/spike/protocol.md +7 -1
  116. package/skeleton/protocols/spir/builder-prompt.md +7 -2
  117. package/skeleton/protocols/spir/prompts/plan.md +2 -34
  118. package/skeleton/protocols/spir/prompts/review.md +19 -11
  119. package/skeleton/protocols/spir/protocol.md +5 -6
  120. package/skeleton/protocols/spir/templates/review.md +4 -4
  121. package/skeleton/resources/arch-critical.md +17 -0
  122. package/skeleton/resources/lessons-critical.md +17 -0
  123. package/skeleton/roles/builder.md +2 -2
  124. package/skeleton/templates/arch-critical.md +17 -0
  125. package/skeleton/templates/arch.starter.md +9 -0
  126. package/skeleton/templates/lessons-critical.md +17 -0
  127. package/skeleton/templates/lessons-learned.starter.md +9 -0
@@ -99,16 +99,16 @@ Iterations that could have been prevented with better builder behavior:
99
99
 
100
100
  ## Architecture Updates
101
101
 
102
- [What was added/changed in `codev/resources/arch.md`, or why no changes were needed.]
102
+ [What you routed where — HOT `codev/resources/arch-critical.md` (tiny, capped, always-injected) vs COLD `codev/resources/arch.md` (reference) — or why no changes were needed.]
103
103
 
104
- - Updated: [section name] — [what was added/changed]
104
+ - Routed: [hot | cold] — [fact/section] — [what was added/changed; note any demotion if the hot file was full]
105
105
  - Or: "No architecture updates needed — [brief reason]"
106
106
 
107
107
  ## Lessons Learned Updates
108
108
 
109
- [What was added/changed in `codev/resources/lessons-learned.md`, or why no changes were needed.]
109
+ [What you routed where — HOT `codev/resources/lessons-critical.md` (capped) vs COLD `codev/resources/lessons-learned.md` (reference) — or why no changes were needed.]
110
110
 
111
- - Added: [category] — [lesson summary]
111
+ - Routed: [hot | cold] — [category] — [lesson summary]
112
112
  - Or: "No lessons learned updates needed — [brief reason]"
113
113
 
114
114
  ## Technical Debt
@@ -25,7 +25,7 @@ You are running in STRICT mode. This means:
25
25
  {{/if}}
26
26
 
27
27
  ## Protocol
28
- Follow the BUGFIX protocol: `codev/protocols/bugfix/protocol.md`
28
+ Follow the BUGFIX protocol. Read and internalize the protocol before starting any work. The full protocol text is included below under **## Protocol Reference (full text)**.
29
29
 
30
30
  {{#if issue}}
31
31
  ## Issue #{{issue.number}}
@@ -67,3 +67,9 @@ If you encounter **pre-existing flaky tests** (intermittent failures unrelated t
67
67
  1. Read the BUGFIX protocol
68
68
  2. Review the issue details
69
69
  3. Reproduce the bug before fixing
70
+
71
+ ---
72
+
73
+ ## Protocol Reference (full text)
74
+
75
+ {{protocol_reference}}
@@ -0,0 +1,78 @@
1
+ # BUGFIX Protocol
2
+
3
+ > Lightweight, issue-driven protocol for minor bug fixes. **Investigate → Fix → PR**, with a single `pr` gate before merge. No spec or plan artifacts: the GitHub issue is the spec, and the review goes in the PR body.
4
+
5
+ ## When to Use
6
+
7
+ Use BUGFIX when a bug is reported as a GitHub Issue and:
8
+
9
+ - The reproduction is clear (or inferable) and the root cause is isolated
10
+ - The fix is small (guideline: < 300 LOC net diff) and contained to one area
11
+ - No architectural changes or new design decisions are needed
12
+
13
+ Escalate to **SPIR** (or another heavier protocol) instead when:
14
+
15
+ - It is actually a feature request, not a bug
16
+ - The root cause reveals a deeper architectural issue
17
+ - The fix needs design review, spans multiple components, or clearly exceeds ~300 LOC
18
+
19
+ ## Phases
20
+
21
+ ```
22
+ investigate → fix → pr
23
+ ```
24
+
25
+ ### Investigate
26
+
27
+ Read the issue, reproduce the bug, and identify the root cause. Confirm the fix fits BUGFIX scope. If it does not, signal `BLOCKED` and recommend escalation to the architect (`afx send architect "..."`). No code in this phase.
28
+
29
+ ### Fix
30
+
31
+ Apply the minimal change that resolves the root cause, and add a regression test that fails without the fix and passes with it. Keep it focused: do not refactor surrounding code, do not fix unrelated bugs (file separate issues), do not add features. Run the build and tests (porch's `checks` block runs `npm run build` and `npm test`).
32
+
33
+ Commit with the issue-driven format:
34
+
35
+ ```
36
+ [Bugfix #<N>] Fix: <what was fixed>
37
+ [Bugfix #<N>] Test: <regression test added>
38
+ ```
39
+
40
+ ### PR (gated by `pr`)
41
+
42
+ 1. Push the branch and open a PR with `gh pr create`. The body includes Summary, Root Cause, Fix, and Test Plan, plus `Fixes #<N>` so the issue auto-closes on merge.
43
+ 2. Run a multi-agent CMAP review on the PR (Gemini, Codex, Claude) and record each verdict. Address or rebut any `REQUEST_CHANGES`; add a regression test if a real defect surfaced.
44
+ 3. Notify the architect: `afx send architect "PR #<M> ready for review (fixes #<N>). CMAP: gemini=..., codex=..., claude=..."`.
45
+ 4. Run `porch done <id>` to request the `pr` gate, then wait. **The merge is gated by porch state, never by typed prose in your pane.**
46
+ 5. The human reviews the PR and the CMAP results on GitHub, then approves the gate: `porch approve <id> pr --a-human-explicitly-approved-this`.
47
+ 6. porch wakes the builder with a merge task. Merge with `gh pr merge --merge` (do **not** pass `--delete-branch`: the builder is checked out on this branch in a worktree), then run `porch done <id>` and notify the architect that it is merged and ready for cleanup.
48
+
49
+ ## Gate
50
+
51
+ BUGFIX has one human gate, `pr`, on the merge step. It exists so the merge trigger is structured porch state (approved or not), not free-text typed into the builder's pane. This eliminates the self-merge bug class: a builder cannot infer authorization from ambiguous input.
52
+
53
+ ## Multi-Agent Consultation
54
+
55
+ A single CMAP pass at the PR (Gemini, Codex, Claude). There is no per-phase consultation: the issue is the spec and the fix is small, so review effort concentrates on the final PR.
56
+
57
+ ## Scope
58
+
59
+ The < 300 LOC threshold is a **guideline**, measured as net diff (additions + deletions) anchored at the merge-base with the default branch. A well-contained 350-LOC fix is fine; a 200-LOC fix smeared across ten files may warrant escalation.
60
+
61
+ ## Escalation
62
+
63
+ If, mid-fix, the change outgrows BUGFIX (architectural impact, multiple components, unclear root cause after investigation, or more than ~300 LOC), notify the architect with specifics and recommend escalating to SPIR. Do not silently expand scope.
64
+
65
+ ## Branch Naming
66
+
67
+ ```
68
+ builder/bugfix-<issue-number>-<slug>
69
+ ```
70
+
71
+ ## Edge Cases
72
+
73
+ | Scenario | Action |
74
+ |---|---|
75
+ | Cannot reproduce | Document the attempts in an issue comment, ask the reporter for detail, notify the architect |
76
+ | Fix outgrows scope (architectural / multi-component / > ~300 LOC) | Notify the architect, recommend escalation; do not proceed |
77
+ | Unrelated test failures | Out of scope: note them for the architect, do not fix them here |
78
+ | Multiple bugs in one issue | Fix only the primary bug; file separate issues for the rest |
@@ -24,7 +24,7 @@ You are running in STRICT mode. This means:
24
24
  {{/if}}
25
25
 
26
26
  ## Protocol
27
- Follow the EXPERIMENT protocol: `codev/protocols/experiment/protocol.md`
27
+ Follow the EXPERIMENT protocol. Read and internalize the protocol before starting any work. The full protocol text is included below under **## Protocol Reference (full text)**.
28
28
 
29
29
  ## EXPERIMENT Overview
30
30
  The EXPERIMENT protocol ensures disciplined experimentation:
@@ -74,3 +74,9 @@ If you encounter **pre-existing flaky tests** (intermittent failures unrelated t
74
74
  1. Read the EXPERIMENT protocol document
75
75
  2. Define your hypothesis clearly
76
76
  3. Follow the phases in order
77
+
78
+ ---
79
+
80
+ ## Protocol Reference (full text)
81
+
82
+ {{protocol_reference}}
@@ -37,7 +37,7 @@ mkdir -p experiments/1_experiment_name
37
37
  cd experiments/1_experiment_name
38
38
 
39
39
  # Initialize notes.md from template
40
- cp codev/protocols/experiment/templates/notes.md notes.md
40
+ touch notes.md # then fill it from the embedded template at the end of this protocol
41
41
  ```
42
42
 
43
43
  Or ask your AI assistant: "Create a new experiment for [goal]"
@@ -85,33 +85,6 @@ git add experiments/1_experiment_name/
85
85
  git commit -m "[Experiment 1] Brief description of findings"
86
86
  ```
87
87
 
88
- ## notes.md Template
89
-
90
- See `templates/notes.md` for the full template. Key sections:
91
-
92
- ```markdown
93
- # Experiment ####: Name
94
-
95
- **Status**: In Progress | Complete | Disproved | Aborted
96
-
97
- **Date**: YYYY-MM-DD
98
-
99
- ## Goal
100
- What are you trying to learn?
101
-
102
- ## Time Investment
103
- Wall clock time vs active developer time
104
-
105
- ## Code
106
- - [experiment.py](experiment.py) - Brief description
107
-
108
- ## Results
109
- What happened? What did you learn?
110
-
111
- ## Next Steps
112
- What should be done based on findings?
113
- ```
114
-
115
88
  ## Best Practices
116
89
 
117
90
  ### Keep It Simple
@@ -222,3 +195,9 @@ Determine if Redis caching improves API response times for repeated queries.
222
195
  ## Next Steps
223
196
  Create SPIR spec for production caching implementation.
224
197
  ```
198
+
199
+ ## Template: notes.md
200
+
201
+ Create `notes.md` with the following content:
202
+
203
+ {{> protocols/experiment/templates/notes.md}}
@@ -23,7 +23,7 @@ You are running in STRICT mode. This means:
23
23
  {{/if}}
24
24
 
25
25
  ## Protocol
26
- Follow the MAINTAIN protocol: `codev/protocols/maintain/protocol.md`
26
+ Follow the MAINTAIN protocol. Read and internalize the protocol before starting any work. The full protocol text is included below under **## Protocol Reference (full text)**.
27
27
 
28
28
  ## MAINTAIN Overview
29
29
 
@@ -54,3 +54,9 @@ If you encounter **pre-existing flaky tests** (intermittent failures unrelated t
54
54
  2. Run `porch next` to get your first task
55
55
  3. Work through audit → clean → sync → verify in a single pass
56
56
  4. Document everything in the maintenance run file
57
+
58
+ ---
59
+
60
+ ## Protocol Reference (full text)
61
+
62
+ {{protocol_reference}}
@@ -51,9 +51,9 @@ One removal at a time. Verify after each. Never use `git add -A`.
51
51
 
52
52
  ## Step 4: Sync Documentation
53
53
 
54
- **arch.md**: Read `codev/resources/arch.md`, compare with actual codebase. Update directory structure, component descriptions, key files. Remove references to deleted code. Add new components. Explain HOW things work, not just WHAT.
54
+ **arch.md / arch-critical.md** (Spec 987 two-tier): Read both, compare with actual codebase. Route behavior-changing invariants to the HOT `arch-critical.md` (respect its cap + keep its cold-doc map accurate); reference detail to the COLD `arch.md` (directory structure, component descriptions, key files, removals). Explain HOW things work, not just WHAT.
55
55
 
56
- **lessons-learned.md**: Scan `codev/reviews/` for new reviews since the base commit. Extract actionable, durable, general lessons.
56
+ **lessons-learned.md / lessons-critical.md** (two-tier): Scan `codev/reviews/` for new reviews since the base commit. **Route** each lesson — behavior-changing + cross-cutting → HOT `lessons-critical.md` (cap + displacement); reference recipe → COLD `lessons-learned.md`. Audit the hot caps + maps via the `update-arch-docs` skill.
57
57
 
58
58
  **CLAUDE.md / AGENTS.md**: `diff CLAUDE.md AGENTS.md` — they must be identical. Update the stale one.
59
59
 
@@ -61,8 +61,9 @@ One removal at a time. Verify after each. Never use `git add -A`.
61
61
 
62
62
  Commit documentation changes:
63
63
  ```bash
64
- git add codev/resources/arch.md codev/resources/lessons-learned.md
65
- git commit -m "[Maintain] Update arch.md and lessons-learned.md"
64
+ git add codev/resources/arch.md codev/resources/arch-critical.md
65
+ git add codev/resources/lessons-learned.md codev/resources/lessons-critical.md
66
+ git commit -m "[Maintain] Update governance docs (hot + cold tiers)"
66
67
  ```
67
68
 
68
69
  ## Step 5: Final Checks
@@ -57,7 +57,7 @@ Closes #<N> <!-- Only if this run was triggered by a GitHub issue. Use "Refs #<
57
57
 
58
58
  - Dead code removed: X items
59
59
  - Dependencies cleaned: Y packages
60
- - Documentation updated: arch.md, lessons-learned.md
60
+ - Documentation updated: arch.md / arch-critical.md, lessons-learned.md / lessons-critical.md (hot + cold tiers; hot caps + cold-doc maps policed)
61
61
  - Tests: all passing
62
62
 
63
63
  ## Test plan
@@ -7,8 +7,8 @@ MAINTAIN is a single-pass maintenance protocol for keeping codebases healthy. Th
7
7
  **Core Principle**: Do the work in one pass. Don't over-ceremonialize housekeeping.
8
8
 
9
9
  **Key Documents** MAINTAIN keeps current:
10
- - `codev/resources/arch.md` - Architecture documentation
11
- - `codev/resources/lessons-learned.md` - Extracted wisdom from reviews
10
+ - `codev/resources/arch.md` (COLD reference) + `codev/resources/arch-critical.md` (HOT, always-injected) — Architecture, two tiers (Spec 987)
11
+ - `codev/resources/lessons-learned.md` (COLD reference) + `codev/resources/lessons-critical.md` (HOT, always-injected) — Engineering wisdom, two tiers
12
12
 
13
13
  The two governance docs are siblings with **different purposes**: `arch.md` owns system shape (services, transports, mental models, verified-wrong assumptions about *this* system); `lessons-learned.md` owns durable engineering wisdom that applies *across* specs. Use the routing matrix below to decide where each fact belongs.
14
14
 
@@ -18,8 +18,10 @@ The two governance docs are siblings with **different purposes**: `arch.md` owns
18
18
  |---|---|
19
19
  | Current system shape (services, transports, key mental models) | `codev/resources/arch.md` |
20
20
  | Mechanism for a unique subsystem | `codev/resources/arch.md` (subsystem section) OR a meta-spec under `codev/architecture/<domain>.md` if the mechanism is large enough to warrant its own doc |
21
- | A durable engineering pattern that applies across multiple specs | `codev/resources/lessons-learned.md` |
22
- | A spec-narrow fix recipe (only relevant inside the originating feature) | Spec review only — does NOT belong in `lessons-learned.md` |
21
+ | A durable engineering pattern that applies across multiple specs | `codev/resources/lessons-learned.md` (COLD reference) |
22
+ | A **behavior-changing, cross-cutting** rule (should change how the next project is built) | `codev/resources/lessons-critical.md` (HOT, capped) — demote to `lessons-learned.md` if full |
23
+ | A **behavior-changing, cross-cutting** architecture invariant (a future builder must know up front) | `codev/resources/arch-critical.md` (HOT, capped) — demote to `arch.md` if full |
24
+ | A spec-narrow fix recipe (reference detail) | `codev/resources/lessons-learned.md` (COLD) — kept as reference; **never** the hot file |
23
25
  | A system-shape surprise verified-wrong in production ("looks like X but isn't") | `codev/resources/arch.md` § "Verified-Wrong Assumptions" |
24
26
  | Aspirational architectural direction (where we want to go) | The relevant meta-spec or roadmap doc, NOT `arch.md` body |
25
27
  | A changelog entry ("we shipped X in spec Y on date Z") | `git log` + the spec/review document — NOT `arch.md`, NOT `lessons-learned.md` |
@@ -113,7 +115,7 @@ The `update-arch-docs` skill (at `.claude/skills/update-arch-docs/SKILL.md`) is
113
115
 
114
116
  #### Step 3a: Audit documentation
115
117
 
116
- Invoke the `update-arch-docs` skill in **audit-mode**. The skill reads `codev/resources/arch.md` and `codev/resources/lessons-learned.md` end-to-end against the discipline below and produces a candidate-cuts list (with reasons) recorded in the run file (`codev/maintain/NNNN.md`) under a new `## Audit Findings` section before any edits land.
118
+ Invoke the `update-arch-docs` skill in **audit-mode**. The skill reads all four governance files — `codev/resources/arch.md` / `arch-critical.md` and `codev/resources/lessons-learned.md` / `lessons-critical.md` — end-to-end against the discipline below, applies the cuts via the Edit tool, and records each cut's reason in the run file (`codev/maintain/NNNN.md`) under a `## Audit Findings` section. The diff plus the recorded reasons **is** the proposal; the architect's PR review is the human-confirmation step (consistent with the skill's audit-mode).
117
119
 
118
120
  **Per-arch.md-section pruning checklist** — for each section in `arch.md`, ask:
119
121
  - Does it describe **current state**? If aspirational, the section moves to a meta-spec; `arch.md` keeps a 1-paragraph summary + pointer (or nothing, if the meta-spec stands on its own).
@@ -122,21 +124,27 @@ Invoke the `update-arch-docs` skill in **audit-mode**. The skill reads `codev/re
122
124
  - Is it a changelog/narrative section ("Spec 0042 added X")? If yes, absorb the architecturally-relevant facts and remove the spec-numbered framing.
123
125
  - Is the component still alive? If retired, delete the section entirely.
124
126
 
125
- **Per-lessons-learned.md-entry pruning checklist** — for each entry, ask:
126
- - Is it cross-applicable beyond the spec that produced it? If no, remove (the lesson belongs in the spec's review).
127
+ **Per-COLD-`lessons-learned.md`-entry pruning checklist** — for each entry, ask:
127
128
  - Is it terse (1–3 sentences)? If multi-paragraph, split or compress.
128
129
  - Is the topic section the right home? If filed under "Architecture (continued)" or a spec-numbered section, move it to the right topical home.
129
130
  - Is it a duplicate of an adjacent entry? If yes, fold them.
131
+ - (Spec-narrow recipes are **kept** as reference — do not cut them just for being spec-narrow. Anti-accretion now lives in the hot cap, not the cold archive.)
132
+
133
+ **Per-HOT-file checklist** (`arch-critical.md`, `lessons-critical.md`) — audit the cap and map:
134
+ - Within the cap (≈10 entries + a ≈12-topic map, ≤35 lines)? If over, **demote** the weakest entries into the cold doc.
135
+ - Does every map topic name a real top-level cold-doc section, and is any new/renamed section reflected? Fix drift; keep the map top-level only.
136
+ - Is every entry still behavior-changing? Demote reference detail into the cold archive.
130
137
 
131
138
  **Sample audit prompt** (paste into the skill invocation if you want a baseline checklist run):
132
139
 
133
140
  ```
134
- Audit codev/resources/arch.md and codev/resources/lessons-learned.md against the
135
- discipline in the update-arch-docs skill. For each section/entry, run the per-
136
- arch.md-section and per-lessons-learned.md-entry pruning checklists from the
137
- MAINTAIN protocol (Step 3a). Produce a candidate-cuts list with one-line reasons.
138
- Bias toward fewer, higher-confidence cuts ("when in doubt, KEEP"). Record the
139
- findings in the current run file's ## Audit Findings section before applying.
141
+ Audit all four governance files — codev/resources/arch.md + arch-critical.md and
142
+ lessons-learned.md + lessons-critical.md — against the discipline in the
143
+ update-arch-docs skill. For each cold section/entry run the cold pruning checklists,
144
+ and for each hot file check the cap, displacement, and map accuracy (Step 3a).
145
+ Apply the cuts with one-line reasons. Bias toward fewer, higher-confidence
146
+ cuts ("when in doubt, KEEP"). Record each cut's reason in the current run
147
+ file's ## Audit Findings section as you go — the diff plus those reasons is the proposal.
140
148
  ```
141
149
 
142
150
  **When in doubt, KEEP.** This rule is preserved from the older Step 3. A confident cut is better than three speculative ones. The audit pass is a *proposal*; the architect's PR review confirms it.
@@ -145,14 +153,14 @@ findings in the current run file's ## Audit Findings section before applying.
145
153
 
146
154
  Apply the audit decisions from Step 3a, plus any additive content needed.
147
155
 
148
- **arch.md**: Compare documented structure with actual codebase. Update:
156
+ **arch.md / arch-critical.md**: Compare documented structure with actual codebase. Route behavior-changing invariants to `arch-critical.md` (HOT — respect the cap + keep its map accurate); reference detail to `arch.md` (COLD). Update:
149
157
  - Directory structure
150
158
  - Component descriptions (explain HOW things work, not just WHAT)
151
159
  - Key files and their purposes
152
160
  - Remove references to deleted code (per Step 3a audit findings)
153
161
  - Add new components/utilities
154
162
 
155
- **lessons-learned.md**: Scan `codev/reviews/` for new reviews since last run. Extract lessons that are actionable, durable, and general. Apply Step 3a's per-entry cuts.
163
+ **lessons-learned.md / lessons-critical.md**: Scan `codev/reviews/` for new reviews since last run. **Route** each new lesson by tier — behavior-changing + cross-cutting → `lessons-critical.md` (HOT; respect the cap, demote a weaker entry to cold if full); reference recipe / spec-narrow → `lessons-learned.md` (COLD). Apply Step 3a's per-entry cuts and keep each hot file's cold-doc map accurate.
156
164
 
157
165
  For specific additive changes, invoke `update-arch-docs` in **diff-mode** — it applies the smallest section update needed.
158
166
 
@@ -192,13 +200,13 @@ Each run creates `codev/maintain/NNNN.md`:
192
200
 
193
201
  ## Audit Findings
194
202
 
195
- Recorded by Step 3a (Audit documentation) before any edits land. One line per candidate cut.
203
+ Recorded by Step 3a (Audit documentation) as the cuts are applied — one line per cut, with its reason. The diff plus these reasons is the proposal; the architect's PR review is the gate.
196
204
 
197
- ### arch.md
198
- - <section-name>: <reason for proposed cut/compression>
205
+ ### arch.md (cold) / arch-critical.md (hot)
206
+ - <section or hot entry>: <reason for cut / compression / demotion>
199
207
 
200
- ### lessons-learned.md
201
- - <entry>: <reason>
208
+ ### lessons-learned.md (cold) / lessons-critical.md (hot)
209
+ - <entry>: <reason; note hot→cold demotions and any cold-doc-map fixes>
202
210
 
203
211
  ## What Was Done
204
212
 
@@ -207,8 +215,8 @@ Recorded by Step 3a (Audit documentation) before any edits land. One line per ca
207
215
  - Removed `some-package` dependency — zero imports
208
216
 
209
217
  ### Documentation Updated
210
- - arch.md: Added VS Code extension section, removed old dashboard-server refs
211
- - lessons-learned.md: Extracted 3 lessons from reviews 653, 672
218
+ - arch.md / arch-critical.md: Added VS Code extension section + removed old dashboard-server refs (cold); routed 1 invariant to the hot tier, demoted 1 stale entry to cold
219
+ - lessons-learned.md / lessons-critical.md: Extracted 3 lessons from reviews 653, 672 (cold); promoted 1 behavior-changer to the hot tier, refreshed its cold-doc map
212
220
 
213
221
  ### Documentation Changes Log
214
222
  | Document | Section | Action | Reason |
@@ -17,8 +17,8 @@
17
17
  - <package> — <reason>
18
18
 
19
19
  ### Documentation Updated
20
- - arch.md: <what changed>
21
- - lessons-learned.md: <what changed>
20
+ - arch.md (cold) / arch-critical.md (hot): <what changed; note any demotions + map fixes>
21
+ - lessons-learned.md (cold) / lessons-critical.md (hot): <what changed; note any demotions + map fixes>
22
22
 
23
23
  ### Documentation Changes Log
24
24
  | Document | Section | Action | Reason |
@@ -27,8 +27,7 @@ You are running in STRICT mode. This means:
27
27
  {{/if}}
28
28
 
29
29
  ## Protocol
30
- Follow the PIR protocol: `codev/protocols/pir/protocol.md`
31
- Read and internalize the protocol before starting any work.
30
+ Follow the PIR protocol. Read and internalize the protocol before starting any work. The full protocol text is included below under **## Protocol Reference (full text)**.
32
31
 
33
32
  PIR has three phases:
34
33
  1. **plan** (gated by `plan-approval`) — write `codev/plans/{{artifact_name}}.md`, await human review
@@ -87,6 +86,12 @@ If your Claude session crashes mid-flow, Tower's `while true` loop will relaunch
87
86
 
88
87
  ## Getting Started
89
88
 
90
- 1. Read the PIR protocol document (`codev/protocols/pir/protocol.md`)
89
+ 1. Read the PIR protocol (provided inline in this prompt).
91
90
  2. Run `porch next {{project_id}}` to see what to do next
92
91
  3. Begin work
92
+
93
+ ---
94
+
95
+ ## Protocol Reference (full text)
96
+
97
+ {{protocol_reference}}
@@ -58,13 +58,13 @@ Output of `git log main..HEAD --oneline`:
58
58
 
59
59
  ## Architecture Updates
60
60
 
61
- What changed in `codev/resources/arch.md` (or why no changes were needed). If this PR introduced or modified an architectural pattern, document it here AND update `arch.md` in this same commit. If no architectural updates are needed (typical for small fixes), write a single line explaining why: "No arch changes — this PR fixes a typo without affecting module boundaries."
61
+ What you routed where, across the **two tiers** (Spec 987): **HOT** = `codev/resources/arch-critical.md` (tiny, hard-capped, always-injected) for a behavior-changing cross-cutting fact (demote a weaker entry into `arch.md` if the hot file is full); **COLD** = `codev/resources/arch.md` for reference detail. Update the file(s) you routed to in this same commit. If nothing qualifies, write a single line explaining why: "No arch changes — this PR fixes a typo without affecting module boundaries."
62
62
 
63
- Use the `update-arch-docs` skill if available (`.claude/skills/update-arch-docs/SKILL.md`) — it encodes the discipline for what NOT to include in arch docs.
63
+ Use the `update-arch-docs` skill if available (`.claude/skills/update-arch-docs/SKILL.md`) — it encodes the discipline for what NOT to include in arch docs and how the hot/cold tiers relate.
64
64
 
65
65
  ## Lessons Learned Updates
66
66
 
67
- What durable engineering wisdom emerged from this PR (or why no lessons were captured). Same pattern as Architecture Updates: if something is worth recording in `codev/resources/lessons-learned.md`, update both files in this commit. If not, explain why: "No lessons captured — change was mechanical."
67
+ What durable wisdom emerged, routed by tier: **HOT** `codev/resources/lessons-critical.md` for a behavior-changing cross-cutting rule (cap + displacement); **COLD** `codev/resources/lessons-learned.md` for a spec-narrow recipe/reference tip. Update the file(s) you routed to in this commit. If nothing qualifies: "No lessons captured — change was mechanical."
68
68
 
69
69
  ## Things to Look At During PR Review
70
70
 
@@ -85,7 +85,7 @@ List any tests you skipped due to pre-existing flakiness, with file:line refs an
85
85
 
86
86
  ### 2. Update Architecture / Lessons Docs (if applicable)
87
87
 
88
- If your "Architecture Updates" or "Lessons Learned Updates" section calls out real changes, update `codev/resources/arch.md` and/or `codev/resources/lessons-learned.md` accordingly. Use the `update-arch-docs` skill if it's available.
88
+ If your "Architecture Updates" or "Lessons Learned Updates" section routed real changes, update the tier you chose — `arch-critical.md` / `lessons-critical.md` (hot, capped) or `arch.md` / `lessons-learned.md` (cold) — accordingly. Use the `update-arch-docs` skill if it's available.
89
89
 
90
90
  If neither doc needs updating, your review file's sections still need to explain why — the porch `checks` block enforces section presence.
91
91
 
@@ -93,9 +93,11 @@ If neither doc needs updating, your review file's sections still need to explain
93
93
 
94
94
  ```bash
95
95
  git add codev/reviews/{{artifact_name}}.md
96
- # Add arch.md / lessons-learned.md only if you changed them
97
- git add codev/resources/arch.md # only if changed
98
- git add codev/resources/lessons-learned.md # only if changed
96
+ # Add the governance file(s) you routed to, only if changed
97
+ git add codev/resources/arch-critical.md # hot — only if changed
98
+ git add codev/resources/lessons-critical.md # hot — only if changed
99
+ git add codev/resources/arch.md # cold — only if changed
100
+ git add codev/resources/lessons-learned.md # cold — only if changed
99
101
  git commit -m "[PIR #{{issue.number}}] Review + retrospective"
100
102
  git push
101
103
  ```
@@ -98,7 +98,7 @@ porch approve <id> dev-approval --a-human-explicitly-approved-this
98
98
 
99
99
  The builder:
100
100
  1. Writes `codev/reviews/<id>-<slug>.md` with **Summary**, **Architecture Updates**, **Lessons Learned Updates**, plus the supporting sections (Files Changed, Commits, Test Results, Things to Look At, How to Test Locally).
101
- 2. Updates `codev/resources/arch.md` and/or `codev/resources/lessons-learned.md` if real changes need recording. If not, the review file's sections state "no changes needed" with a one-line explanation (the porch `checks` block enforces section presence, not content).
101
+ 2. Routes new facts/wisdom by tier (Spec 987) — HOT `codev/resources/arch-critical.md` / `lessons-critical.md` (capped) or COLD `codev/resources/arch.md` / `lessons-learned.md` (reference) — if real changes need recording. If not, the review file's sections state "no changes needed" with a one-line explanation (the porch `checks` block enforces section presence, not content).
102
102
  3. Commits the review file (and arch / lessons updates if any) and pushes
103
103
  4. Opens a PR with `gh pr create`; PR body is the review file content + `Fixes #<N>`. Records the PR with `porch done <id> --pr <M> --branch <name>`.
104
104
  5. Runs `porch done <id>` — porch's `verify` block runs 3-way consultation (Gemini, Codex, Claude; type=impl) as a **single advisory pass** (`max_iterations: 1`); consultation outputs land in `codev/projects/<id>-*/`. There is no iterate-until-APPROVE loop: whatever the verdicts, porch records them and advances to the `pr` gate. A `REQUEST_CHANGES` is not auto-re-reviewed — the builder addresses or rebuts it, adds a regression test if it's a real defect, and escalates it in the architect notification so the human verifies it at the `pr` gate. Outcomes are not auto-appended to the PR body; reviewers with the worktree read them from the projects dir.
@@ -24,7 +24,7 @@ You are running in STRICT mode. This means:
24
24
  {{/if}}
25
25
 
26
26
  ## Protocol
27
- Follow the RESEARCH protocol: `codev/protocols/research/protocol.md`
27
+ Follow the RESEARCH protocol. Read and internalize the protocol before starting any work. The full protocol text is included below under **## Protocol Reference (full text)**.
28
28
 
29
29
  ## RESEARCH Overview
30
30
 
@@ -83,3 +83,9 @@ wait
83
83
  2. Understand the research question from the architect
84
84
  3. Write the research brief (Phase 1)
85
85
  4. Wait for scope-approval before proceeding to investigation
86
+
87
+ ---
88
+
89
+ ## Protocol Reference (full text)
90
+
91
+ {{protocol_reference}}
@@ -11,7 +11,7 @@ You are running in SOFT mode. This means:
11
11
  {{/if}}
12
12
 
13
13
  ## Protocol
14
- Follow the SPIKE protocol: `codev/protocols/spike/protocol.md`
14
+ Follow the SPIKE protocol. Read and internalize the protocol before starting any work. The full protocol text is included below under **## Protocol Reference (full text)**.
15
15
 
16
16
  {{#if task}}
17
17
  ## Spike Question
@@ -60,3 +60,9 @@ If you encounter **pre-existing flaky tests** (intermittent failures unrelated t
60
60
  1. Read the SPIKE protocol document
61
61
  2. Understand the question you're investigating
62
62
  3. Start with research — don't jump straight to code
63
+
64
+ ---
65
+
66
+ ## Protocol Reference (full text)
67
+
68
+ {{protocol_reference}}
@@ -52,7 +52,7 @@ The following 3-step workflow is **guidance only** — not enforced by porch. Fo
52
52
  ### Step 3: Findings
53
53
 
54
54
  - Write the findings document at `codev/spikes/<id>-<name>.md`
55
- - Use the template: `codev/protocols/spike/templates/findings.md`
55
+ - Use the embedded template at the end of this protocol
56
56
  - Provide a clear feasibility verdict
57
57
  - Commit and notify the architect
58
58
 
@@ -120,3 +120,9 @@ When a spike finds something is not feasible:
120
120
  1. Document clearly in findings
121
121
  2. Close the related GitHub issue with a link to findings
122
122
  3. The findings become institutional knowledge
123
+
124
+ ## Template: findings.md
125
+
126
+ Write the findings document using the following template:
127
+
128
+ {{> protocols/spike/templates/findings.md}}
@@ -27,8 +27,7 @@ You are running in STRICT mode. This means:
27
27
  {{/if}}
28
28
 
29
29
  ## Protocol
30
- Follow the SPIR protocol: `codev/protocols/spir/protocol.md`
31
- Read and internalize the protocol before starting any work.
30
+ Follow the SPIR protocol. Read and internalize the protocol before starting any work. The full protocol text is included below under **## Protocol Reference (full text)**.
32
31
 
33
32
  ## Baked Decisions
34
33
 
@@ -112,3 +111,9 @@ If you encounter **pre-existing flaky tests** (intermittent failures unrelated t
112
111
  1. Read the protocol document thoroughly
113
112
  2. Review the spec and plan (if available)
114
113
  3. Begin implementation following the protocol phases
114
+
115
+ ---
116
+
117
+ ## Protocol Reference (full text)
118
+
119
+ {{protocol_reference}}
@@ -74,41 +74,9 @@ After completing the plan draft, signal completion. Porch will run 3-way consult
74
74
 
75
75
  ## Output
76
76
 
77
- Create the plan file at `codev/plans/{{artifact_name}}.md`.
77
+ Create the plan file at `codev/plans/{{artifact_name}}.md`, following the template below:
78
78
 
79
- Use the plan template from `codev/protocols/spir/templates/plan.md` if available.
80
-
81
- ### Plan Structure
82
-
83
- ```markdown
84
- # Implementation Plan: {{title}}
85
-
86
- ## Overview
87
- Brief summary of what will be implemented.
88
-
89
- ## Phases
90
-
91
- ### Phase 1: [Name]
92
- - **Objective**: [Single clear goal]
93
- - **Files**: [List of files to create/modify]
94
- - **Dependencies**: None
95
- - **Success Criteria**: [How to verify completion]
96
- - **Tests**: [What tests will be written]
97
-
98
- ### Phase 2: [Name]
99
- - **Objective**: [Single clear goal]
100
- - **Files**: [List of files]
101
- - **Dependencies**: Phase 1
102
- - **Success Criteria**: [Verification method]
103
- - **Tests**: [Test approach]
104
-
105
- [Continue for all phases...]
106
-
107
- ## Risk Assessment
108
- - [Risk 1]: [Mitigation]
109
- - [Risk 2]: [Mitigation]
110
-
111
- ```
79
+ {{> protocols/spir/templates/plan.md}}
112
80
 
113
81
  ## Signals
114
82
 
@@ -148,17 +148,25 @@ Read the consultation output files from the project directory (`codev/projects/{
148
148
 
149
149
  **MANDATORY**: The review document MUST include `## Architecture Updates` and `## Lessons Learned Updates` sections. Porch will block advancement if these are missing.
150
150
 
151
- **Architecture Updates** (`codev/resources/arch.md`):
152
- 1. Read the current `codev/resources/arch.md`
153
- 2. Determine if this project introduced architectural changes worth documenting (new subsystems, data flows, design decisions, invariants, file locations)
154
- 3. If yes: make the updates to arch.md and describe what you changed in the `## Architecture Updates` section of the review
155
- 4. If no: write "No architecture updates needed" in the section with a brief explanation (e.g., "This was a template-only change with no new subsystems or data flows")
156
-
157
- **Lessons Learned Updates** (`codev/resources/lessons-learned.md`):
158
- 1. Read the current `codev/resources/lessons-learned.md`
159
- 2. Determine if this project produced generalizable lessons (patterns, anti-patterns, debugging insights, process improvements)
160
- 3. If yes: add entries to lessons-learned.md and describe what you added in the `## Lessons Learned Updates` section of the review
161
- 4. If no: write "No lessons learned updates needed" in the section with a brief explanation (e.g., "Straightforward implementation with no novel insights beyond existing entries")
151
+ Each governance doc has **two tiers** (Spec 987) — **route** each new fact/lesson to the right tier; do **not** just append to the cold archive:
152
+ - **HOT** — `codev/resources/arch-critical.md` / `lessons-critical.md`: tiny, **hard-capped**, **always injected** into every prompt and into CLAUDE.md/AGENTS.md. The behavior-changer.
153
+ - **COLD** — `codev/resources/arch.md` / `lessons-learned.md`: full, on-demand reference.
154
+
155
+ **Architecture Updates**:
156
+ 1. Read `arch-critical.md` (hot) and skim `arch.md` (cold).
157
+ 2. If this project produced a system-shape fact, route it:
158
+ - **Behavior-changing + cross-cutting** (an invariant/decision a future builder must know up front) → add to **`arch-critical.md`**. Respect the cap: if the hot file is full, **demote** a weaker entry into `arch.md` to make room. If you add/rename a top-level `arch.md` section, keep the hot file's cold-doc map accurate.
159
+ - **Reference detail** (subsystem mechanism, file location, one-off) → add to **`arch.md`** (cold).
160
+ 3. Describe what you routed where in the `## Architecture Updates` section. If nothing qualifies: write "No architecture updates needed" with a brief reason.
161
+
162
+ **Lessons Learned Updates**:
163
+ 1. Read `lessons-critical.md` (hot) and skim `lessons-learned.md` (cold).
164
+ 2. If this project produced a durable lesson, route it:
165
+ - **Behavior-changing + cross-cutting** (a rule that should change how the next project is built) → add to **`lessons-critical.md`**, respecting the cap (demote a weaker entry into `lessons-learned.md` if full).
166
+ - **Spec-narrow recipe / reference tip** → add to **`lessons-learned.md`** (cold). Spec-narrow recipes belong in the cold archive, never the always-on hot file.
167
+ 3. Describe what you routed where in the `## Lessons Learned Updates` section. If nothing qualifies: write "No lessons learned updates needed" with a brief reason.
168
+
169
+ **Never** grow a hot file past its cap by appending — route to cold or displace. The cap is what keeps the hot tier cheap enough to always inject.
162
170
 
163
171
  ### 4b. Update Other Documentation
164
172