the-grid-cc 1.7.14 → 1.7.15

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.
@@ -0,0 +1,283 @@
1
+ # Grid Persistence - Quick Start Guide
2
+
3
+ **Version:** 1.0
4
+ **Status:** Ready for Implementation
5
+
6
+ This guide provides a quick overview of Grid's persistence system.
7
+
8
+ ## What is Grid Persistence?
9
+
10
+ Grid Persistence allows missions to survive session death. When your session ends unexpectedly (context exhaustion, timeout, disconnect), all state is preserved in `.grid/` files. A fresh Master Control can resume exactly where you left off.
11
+
12
+ ## Core Concepts
13
+
14
+ ### State Files
15
+
16
+ | File | Purpose | When Written |
17
+ |------|---------|--------------|
18
+ | `STATE.md` | Central position tracking | Every wave |
19
+ | `WARMTH.md` | Accumulated knowledge | After each block |
20
+ | `CHECKPOINT.md` | Interrupted thread state | On checkpoint/interrupt |
21
+ | `SCRATCHPAD.md` | Live discoveries | During execution |
22
+ | `DECISIONS.md` | User decisions | When user decides |
23
+ | `BLOCKERS.md` | Issues blocking progress | When blocker encountered |
24
+
25
+ ### Directory Structure
26
+
27
+ ```
28
+ .grid/
29
+ ├── STATE.md # Read this first on resume
30
+ ├── WARMTH.md # Knowledge accumulation
31
+ ├── SCRATCHPAD.md # Live discoveries
32
+ ├── DECISIONS.md # User decisions
33
+ ├── BLOCKERS.md # Active blockers
34
+ ├── config.json # Grid configuration
35
+
36
+ ├── plans/ # Execution plans
37
+ ├── phases/ # Completed work
38
+ ├── discs/ # Program Identity Discs
39
+ ├── debug/ # Debug sessions
40
+ └── refinement/ # Refinement outputs
41
+ ```
42
+
43
+ ## Commands
44
+
45
+ ### Initialize State
46
+
47
+ ```bash
48
+ /grid:init
49
+ ```
50
+
51
+ Creates the `.grid/` directory with all state files.
52
+
53
+ ### Resume Mission
54
+
55
+ ```bash
56
+ /grid:resume # Auto-detect and resume
57
+ /grid:resume --validate # Validate state only
58
+ /grid:resume --from block-02 # Resume from specific block
59
+ ```
60
+
61
+ Reconstructs context from `.grid/` files and continues execution.
62
+
63
+ ### Check Status
64
+
65
+ ```bash
66
+ /grid:status
67
+ ```
68
+
69
+ Shows current mission state and progress.
70
+
71
+ ## How It Works
72
+
73
+ ### 1. During Execution
74
+
75
+ - **Master Control** updates STATE.md after each wave
76
+ - **Executors** write to SCRATCHPAD.md during work
77
+ - **Executors** write SUMMARY.md after each block
78
+ - **Master Control** aggregates WARMTH.md after each block
79
+
80
+ ### 2. On Checkpoint
81
+
82
+ When execution hits a checkpoint (human verification, decision point, etc.):
83
+
84
+ 1. Executor writes CHECKPOINT.md with current thread state
85
+ 2. MC updates STATE.md status to "checkpoint"
86
+ 3. System waits for user response
87
+
88
+ ### 3. On Session Death
89
+
90
+ If session dies unexpectedly:
91
+
92
+ 1. Last STATE.md update shows position
93
+ 2. SCRATCHPAD.md shows last activity
94
+ 3. Git history shows last commits
95
+ 4. Resume reconstructs state from these
96
+
97
+ ### 4. On Resume
98
+
99
+ ```
100
+ /grid:resume
101
+
102
+ 1. Read STATE.md
103
+ 2. Validate state consistency
104
+ 3. Load WARMTH.md, DECISIONS.md, CHECKPOINT.md
105
+ 4. Collect all SUMMARY.md files
106
+ 5. Build execution context
107
+ 6. Spawn continuation with full context
108
+ ```
109
+
110
+ ## Resume Scenarios
111
+
112
+ ### Scenario 1: Clean Checkpoint
113
+
114
+ **State:** User approved checkpoint, session ended normally
115
+
116
+ ```
117
+ STATUS: checkpoint
118
+ CHECKPOINT.md: exists with user_response
119
+ ```
120
+
121
+ **Action:** Continue from next thread after checkpoint
122
+
123
+ ### Scenario 2: Session Death
124
+
125
+ **State:** Session died mid-execution
126
+
127
+ ```
128
+ STATUS: active (stale timestamp)
129
+ CHECKPOINT.md: may not exist
130
+ SCRATCHPAD.md: recent entries
131
+ ```
132
+
133
+ **Action:** Reconstruct from scratchpad + git, resume from last known point
134
+
135
+ ### Scenario 3: Failure
136
+
137
+ **State:** Executor failed with error
138
+
139
+ ```
140
+ STATUS: failed
141
+ CHECKPOINT.md: type: failure with details
142
+ ```
143
+
144
+ **Action:** Present failure report, offer rollback/retry/manual options
145
+
146
+ ## Warmth Accumulation
147
+
148
+ Warmth is institutional knowledge that survives across sessions:
149
+
150
+ ```yaml
151
+ # WARMTH.md
152
+ codebase_patterns:
153
+ - "This project uses Astro content collections"
154
+ - "Dark mode uses class strategy with localStorage"
155
+
156
+ gotchas:
157
+ - "Astro config must use .mjs extension for ESM"
158
+ - "Shiki syntax highlighting is build-time only"
159
+
160
+ user_preferences:
161
+ - "User prefers minimal dependencies"
162
+ - "User wants dark mode as default"
163
+
164
+ decisions_made:
165
+ - "Chose serverless adapter for future flexibility"
166
+
167
+ almost_did:
168
+ - "Considered MDX but stuck with plain MD"
169
+ ```
170
+
171
+ When resuming, this warmth is injected into the continuation executor so it:
172
+ - Doesn't repeat mistakes
173
+ - Applies learned patterns
174
+ - Respects user preferences
175
+
176
+ ## State Validation
177
+
178
+ Before resuming, Grid validates:
179
+
180
+ 1. **Commits exist** - All claimed commit hashes are in git
181
+ 2. **Files exist** - All claimed artifacts exist on disk
182
+ 3. **Plans available** - Plans exist for pending blocks
183
+ 4. **Single checkpoint** - No conflicting checkpoint files
184
+ 5. **State parseable** - All YAML frontmatter is valid
185
+
186
+ If validation fails, Grid enters recovery mode and attempts to reconstruct state from git + artifacts.
187
+
188
+ ## Templates
189
+
190
+ All templates are in: `templates/grid-state/`
191
+
192
+ - `STATE.md` - Central state template
193
+ - `WARMTH.md` - Warmth template
194
+ - `SCRATCHPAD.md` - Scratchpad template
195
+ - `DECISIONS.md` - Decisions template
196
+ - `BLOCKERS.md` - Blockers template
197
+ - `CHECKPOINT.md` - Checkpoint template
198
+ - `config.json` - Configuration template
199
+ - `BLOCK-SUMMARY.md` - Block summary template
200
+
201
+ ## Example Flow
202
+
203
+ ```
204
+ 1. User: /grid
205
+ MC: Initializes .grid/, starts mission
206
+
207
+ 2. MC spawns Executor for block 01
208
+ Executor: Works on threads, commits, writes SCRATCHPAD.md
209
+
210
+ 3. Executor completes block 01
211
+ Executor: Writes SUMMARY.md with commits and lessons_learned
212
+ MC: Aggregates WARMTH.md from lessons_learned
213
+ MC: Updates STATE.md (block: 2, wave: 1, progress: 16%)
214
+
215
+ 4. Executor hits checkpoint for human verification
216
+ Executor: Writes CHECKPOINT.md (type: human_verify)
217
+ MC: Updates STATE.md (status: checkpoint)
218
+ MC: Waits for user
219
+
220
+ 5. Session dies (context exhaustion)
221
+ STATE.md: status: checkpoint (last write)
222
+ CHECKPOINT.md: awaiting user response
223
+
224
+ 6. New session
225
+ User: /grid:resume
226
+ MC: Reads STATE.md (status: checkpoint)
227
+ MC: Reads CHECKPOINT.md (type: human_verify)
228
+ MC: Loads WARMTH.md (accumulated knowledge)
229
+ MC: Presents checkpoint to user
230
+
231
+ 7. User approves checkpoint
232
+ MC: Updates CHECKPOINT.md (user_response: approved)
233
+ MC: Spawns continuation executor with:
234
+ - Warmth injected
235
+ - Completed threads table
236
+ - Resume point (next thread after checkpoint)
237
+
238
+ 8. Execution continues
239
+ Executor: Picks up from thread after checkpoint
240
+ Executor: Has full context from warmth
241
+ Executor: Doesn't repeat mistakes from prior attempts
242
+ ```
243
+
244
+ ## Implementation Status
245
+
246
+ ### Completed
247
+
248
+ - [x] Template files created
249
+ - [x] `/grid:resume` added to help
250
+ - [x] resume.md spec complete
251
+ - [x] init.md enhanced with templates
252
+ - [x] PERSISTENCE.md design document
253
+ - [x] Documentation complete
254
+
255
+ ### Next Steps
256
+
257
+ 1. **Implement state updates in mc.md**
258
+ - Wave complete handler
259
+ - Block complete handler
260
+ - Checkpoint handler
261
+
262
+ 2. **Implement summary writes in grid-executor.md**
263
+ - Block complete handler
264
+ - lessons_learned section
265
+
266
+ 3. **Complete /grid:resume implementation**
267
+ - State validation logic
268
+ - Context reconstruction logic
269
+ - Continuation spawning logic
270
+
271
+ 4. **Test end-to-end**
272
+ - Full mission with interruption
273
+ - Verify resume works correctly
274
+
275
+ ## Related Documentation
276
+
277
+ - `/docs/PERSISTENCE.md` - Full technical design
278
+ - `/docs/PERSISTENCE_IMPLEMENTATION.md` - Implementation guide
279
+ - `/templates/grid-state/README.md` - Template documentation
280
+ - `/commands/grid/resume.md` - Resume command spec
281
+ - `/commands/grid/init.md` - Init command spec
282
+
283
+ End of Line.