opencode-swarm-plugin 0.44.0 → 0.44.1
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/bin/swarm.serve.test.ts +6 -4
- package/bin/swarm.ts +16 -10
- package/dist/compaction-prompt-scoring.js +139 -0
- package/dist/eval-capture.js +12811 -0
- package/dist/hive.d.ts.map +1 -1
- package/dist/index.js +7644 -62599
- package/dist/plugin.js +23766 -78721
- package/dist/swarm-orchestrate.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-review.d.ts.map +1 -1
- package/package.json +17 -5
- package/.changeset/swarm-insights-data-layer.md +0 -63
- package/.hive/analysis/eval-failure-analysis-2025-12-25.md +0 -331
- package/.hive/analysis/session-data-quality-audit.md +0 -320
- package/.hive/eval-results.json +0 -483
- package/.hive/issues.jsonl +0 -138
- package/.hive/memories.jsonl +0 -729
- package/.opencode/eval-history.jsonl +0 -327
- package/.turbo/turbo-build.log +0 -9
- package/CHANGELOG.md +0 -2286
- package/SCORER-ANALYSIS.md +0 -598
- package/docs/analysis/subagent-coordination-patterns.md +0 -902
- package/docs/analysis-socratic-planner-pattern.md +0 -504
- package/docs/planning/ADR-001-monorepo-structure.md +0 -171
- package/docs/planning/ADR-002-package-extraction.md +0 -393
- package/docs/planning/ADR-003-performance-improvements.md +0 -451
- package/docs/planning/ADR-004-message-queue-features.md +0 -187
- package/docs/planning/ADR-005-devtools-observability.md +0 -202
- package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +0 -168
- package/docs/planning/ADR-008-worker-handoff-protocol.md +0 -293
- package/docs/planning/ADR-009-oh-my-opencode-patterns.md +0 -353
- package/docs/planning/ADR-010-cass-inhousing.md +0 -1215
- package/docs/planning/ROADMAP.md +0 -368
- package/docs/semantic-memory-cli-syntax.md +0 -123
- package/docs/swarm-mail-architecture.md +0 -1147
- package/docs/testing/context-recovery-test.md +0 -470
- package/evals/ARCHITECTURE.md +0 -1189
- package/evals/README.md +0 -768
- package/evals/compaction-prompt.eval.ts +0 -149
- package/evals/compaction-resumption.eval.ts +0 -289
- package/evals/coordinator-behavior.eval.ts +0 -307
- package/evals/coordinator-session.eval.ts +0 -154
- package/evals/evalite.config.ts.bak +0 -15
- package/evals/example.eval.ts +0 -31
- package/evals/fixtures/cass-baseline.ts +0 -217
- package/evals/fixtures/compaction-cases.ts +0 -350
- package/evals/fixtures/compaction-prompt-cases.ts +0 -311
- package/evals/fixtures/coordinator-sessions.ts +0 -328
- package/evals/fixtures/decomposition-cases.ts +0 -105
- package/evals/lib/compaction-loader.test.ts +0 -248
- package/evals/lib/compaction-loader.ts +0 -320
- package/evals/lib/data-loader.evalite-test.ts +0 -289
- package/evals/lib/data-loader.test.ts +0 -345
- package/evals/lib/data-loader.ts +0 -281
- package/evals/lib/llm.ts +0 -115
- package/evals/scorers/compaction-prompt-scorers.ts +0 -145
- package/evals/scorers/compaction-scorers.ts +0 -305
- package/evals/scorers/coordinator-discipline.evalite-test.ts +0 -539
- package/evals/scorers/coordinator-discipline.ts +0 -325
- package/evals/scorers/index.test.ts +0 -146
- package/evals/scorers/index.ts +0 -328
- package/evals/scorers/outcome-scorers.evalite-test.ts +0 -27
- package/evals/scorers/outcome-scorers.ts +0 -349
- package/evals/swarm-decomposition.eval.ts +0 -121
- package/examples/commands/swarm.md +0 -745
- package/examples/plugin-wrapper-template.ts +0 -2515
- package/examples/skills/hive-workflow/SKILL.md +0 -212
- package/examples/skills/skill-creator/SKILL.md +0 -223
- package/examples/skills/swarm-coordination/SKILL.md +0 -292
- package/global-skills/cli-builder/SKILL.md +0 -344
- package/global-skills/cli-builder/references/advanced-patterns.md +0 -244
- package/global-skills/learning-systems/SKILL.md +0 -644
- package/global-skills/skill-creator/LICENSE.txt +0 -202
- package/global-skills/skill-creator/SKILL.md +0 -352
- package/global-skills/skill-creator/references/output-patterns.md +0 -82
- package/global-skills/skill-creator/references/workflows.md +0 -28
- package/global-skills/swarm-coordination/SKILL.md +0 -995
- package/global-skills/swarm-coordination/references/coordinator-patterns.md +0 -235
- package/global-skills/swarm-coordination/references/strategies.md +0 -138
- package/global-skills/system-design/SKILL.md +0 -213
- package/global-skills/testing-patterns/SKILL.md +0 -430
- package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +0 -586
- package/opencode-swarm-plugin-0.30.7.tgz +0 -0
- package/opencode-swarm-plugin-0.31.0.tgz +0 -0
- package/scripts/cleanup-test-memories.ts +0 -346
- package/scripts/init-skill.ts +0 -222
- package/scripts/migrate-unknown-sessions.ts +0 -349
- package/scripts/validate-skill.ts +0 -204
- package/src/agent-mail.ts +0 -1724
- package/src/anti-patterns.test.ts +0 -1167
- package/src/anti-patterns.ts +0 -448
- package/src/compaction-capture.integration.test.ts +0 -257
- package/src/compaction-hook.test.ts +0 -838
- package/src/compaction-hook.ts +0 -1204
- package/src/compaction-observability.integration.test.ts +0 -139
- package/src/compaction-observability.test.ts +0 -187
- package/src/compaction-observability.ts +0 -324
- package/src/compaction-prompt-scorers.test.ts +0 -475
- package/src/compaction-prompt-scoring.ts +0 -300
- package/src/contributor-tools.test.ts +0 -133
- package/src/contributor-tools.ts +0 -201
- package/src/dashboard.test.ts +0 -611
- package/src/dashboard.ts +0 -462
- package/src/error-enrichment.test.ts +0 -403
- package/src/error-enrichment.ts +0 -219
- package/src/eval-capture.test.ts +0 -1015
- package/src/eval-capture.ts +0 -929
- package/src/eval-gates.test.ts +0 -306
- package/src/eval-gates.ts +0 -218
- package/src/eval-history.test.ts +0 -508
- package/src/eval-history.ts +0 -214
- package/src/eval-learning.test.ts +0 -378
- package/src/eval-learning.ts +0 -360
- package/src/eval-runner.test.ts +0 -223
- package/src/eval-runner.ts +0 -402
- package/src/export-tools.test.ts +0 -476
- package/src/export-tools.ts +0 -257
- package/src/hive.integration.test.ts +0 -2241
- package/src/hive.ts +0 -1628
- package/src/index.ts +0 -940
- package/src/learning.integration.test.ts +0 -1815
- package/src/learning.ts +0 -1079
- package/src/logger.test.ts +0 -189
- package/src/logger.ts +0 -135
- package/src/mandate-promotion.test.ts +0 -473
- package/src/mandate-promotion.ts +0 -239
- package/src/mandate-storage.integration.test.ts +0 -601
- package/src/mandate-storage.test.ts +0 -578
- package/src/mandate-storage.ts +0 -794
- package/src/mandates.ts +0 -540
- package/src/memory-tools.test.ts +0 -195
- package/src/memory-tools.ts +0 -344
- package/src/memory.integration.test.ts +0 -334
- package/src/memory.test.ts +0 -158
- package/src/memory.ts +0 -527
- package/src/model-selection.test.ts +0 -188
- package/src/model-selection.ts +0 -68
- package/src/observability-tools.test.ts +0 -359
- package/src/observability-tools.ts +0 -871
- package/src/output-guardrails.test.ts +0 -438
- package/src/output-guardrails.ts +0 -381
- package/src/pattern-maturity.test.ts +0 -1160
- package/src/pattern-maturity.ts +0 -525
- package/src/planning-guardrails.test.ts +0 -491
- package/src/planning-guardrails.ts +0 -438
- package/src/plugin.ts +0 -23
- package/src/post-compaction-tracker.test.ts +0 -251
- package/src/post-compaction-tracker.ts +0 -237
- package/src/query-tools.test.ts +0 -636
- package/src/query-tools.ts +0 -324
- package/src/rate-limiter.integration.test.ts +0 -466
- package/src/rate-limiter.ts +0 -774
- package/src/replay-tools.test.ts +0 -496
- package/src/replay-tools.ts +0 -240
- package/src/repo-crawl.integration.test.ts +0 -441
- package/src/repo-crawl.ts +0 -610
- package/src/schemas/cell-events.test.ts +0 -347
- package/src/schemas/cell-events.ts +0 -807
- package/src/schemas/cell.ts +0 -257
- package/src/schemas/evaluation.ts +0 -166
- package/src/schemas/index.test.ts +0 -199
- package/src/schemas/index.ts +0 -286
- package/src/schemas/mandate.ts +0 -232
- package/src/schemas/swarm-context.ts +0 -115
- package/src/schemas/task.ts +0 -161
- package/src/schemas/worker-handoff.test.ts +0 -302
- package/src/schemas/worker-handoff.ts +0 -131
- package/src/sessions/agent-discovery.test.ts +0 -137
- package/src/sessions/agent-discovery.ts +0 -112
- package/src/sessions/index.ts +0 -15
- package/src/skills.integration.test.ts +0 -1192
- package/src/skills.test.ts +0 -643
- package/src/skills.ts +0 -1549
- package/src/storage.integration.test.ts +0 -341
- package/src/storage.ts +0 -884
- package/src/structured.integration.test.ts +0 -817
- package/src/structured.test.ts +0 -1046
- package/src/structured.ts +0 -762
- package/src/swarm-decompose.test.ts +0 -188
- package/src/swarm-decompose.ts +0 -1302
- package/src/swarm-deferred.integration.test.ts +0 -157
- package/src/swarm-deferred.test.ts +0 -38
- package/src/swarm-insights.test.ts +0 -214
- package/src/swarm-insights.ts +0 -459
- package/src/swarm-mail.integration.test.ts +0 -970
- package/src/swarm-mail.ts +0 -739
- package/src/swarm-orchestrate.integration.test.ts +0 -282
- package/src/swarm-orchestrate.test.ts +0 -548
- package/src/swarm-orchestrate.ts +0 -3084
- package/src/swarm-prompts.test.ts +0 -1270
- package/src/swarm-prompts.ts +0 -2077
- package/src/swarm-research.integration.test.ts +0 -701
- package/src/swarm-research.test.ts +0 -698
- package/src/swarm-research.ts +0 -472
- package/src/swarm-review.integration.test.ts +0 -285
- package/src/swarm-review.test.ts +0 -879
- package/src/swarm-review.ts +0 -709
- package/src/swarm-strategies.ts +0 -407
- package/src/swarm-worktree.test.ts +0 -501
- package/src/swarm-worktree.ts +0 -575
- package/src/swarm.integration.test.ts +0 -2377
- package/src/swarm.ts +0 -38
- package/src/tool-adapter.integration.test.ts +0 -1221
- package/src/tool-availability.ts +0 -461
- package/tsconfig.json +0 -28
|
@@ -1,470 +0,0 @@
|
|
|
1
|
-
# Context Recovery Manual Test Scenario
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This test scenario verifies that the swarm coordination system can survive context death and recover from checkpoints. It proves that work-in-progress state is preserved across session boundaries, enabling agents to resume work after catastrophic context loss.
|
|
6
|
-
|
|
7
|
-
**What this tests:**
|
|
8
|
-
- Automatic checkpoint creation at progress milestones (25%, 50%, 75%)
|
|
9
|
-
- State persistence to swarm-mail event store
|
|
10
|
-
- Recovery mechanism that restores agent state
|
|
11
|
-
- Continuity of work across session boundaries
|
|
12
|
-
|
|
13
|
-
**Success criteria:**
|
|
14
|
-
- Agent can resume work from exact state before context loss
|
|
15
|
-
- All file modifications are tracked
|
|
16
|
-
- Progress percentage is preserved
|
|
17
|
-
- Coordinator context and directives are restored
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Prerequisites
|
|
22
|
-
|
|
23
|
-
### Required Setup
|
|
24
|
-
1. **Project with swarm-mail initialized**
|
|
25
|
-
```bash
|
|
26
|
-
cd /path/to/your/project
|
|
27
|
-
# Ensure swarm-mail database exists
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
2. **OpenCode Swarm Plugin installed**
|
|
31
|
-
```bash
|
|
32
|
-
npm install opencode-swarm-plugin
|
|
33
|
-
# or
|
|
34
|
-
bun add opencode-swarm-plugin
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
3. **Test bead structure**
|
|
38
|
-
- Epic bead with at least one subtask
|
|
39
|
-
- Example:
|
|
40
|
-
```bash
|
|
41
|
-
hive_create_epic(
|
|
42
|
-
epic_title: "Test Context Recovery",
|
|
43
|
-
subtasks: [
|
|
44
|
-
{ title: "Modify test files", files: ["test/file1.ts", "test/file2.ts"] }
|
|
45
|
-
]
|
|
46
|
-
)
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
4. **Two terminal windows/sessions**
|
|
50
|
-
- Session A: For initial work (will be killed)
|
|
51
|
-
- Session B: For recovery
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Test Procedure
|
|
56
|
-
|
|
57
|
-
### Phase 1: Start Initial Work Session
|
|
58
|
-
|
|
59
|
-
**Session A - Terminal 1**
|
|
60
|
-
|
|
61
|
-
1. **Initialize swarm mail**
|
|
62
|
-
```typescript
|
|
63
|
-
swarmmail_init(
|
|
64
|
-
project_path: "/absolute/path/to/project",
|
|
65
|
-
task_description: "bd-123.1: Test context recovery feature"
|
|
66
|
-
)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**Expected result:**
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"success": true,
|
|
73
|
-
"data": {
|
|
74
|
-
"agent_name": "BlueLake", // Random agent name
|
|
75
|
-
"project_key": "/absolute/path/to/project"
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
**Verify:**
|
|
81
|
-
- ✅ Agent name assigned (e.g., "BlueLake")
|
|
82
|
-
- ✅ Project key matches your path
|
|
83
|
-
|
|
84
|
-
2. **Reserve files for work**
|
|
85
|
-
```typescript
|
|
86
|
-
swarmmail_reserve(
|
|
87
|
-
paths: ["test/file1.ts", "test/file2.ts"],
|
|
88
|
-
reason: "bd-123.1: Context recovery test",
|
|
89
|
-
ttl_seconds: 3600
|
|
90
|
-
)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Expected result:**
|
|
94
|
-
```json
|
|
95
|
-
{
|
|
96
|
-
"success": true,
|
|
97
|
-
"data": {
|
|
98
|
-
"reservation_ids": [1, 2],
|
|
99
|
-
"agent_name": "BlueLake",
|
|
100
|
-
"expires_at": 1234567890
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**Verify:**
|
|
106
|
-
- ✅ Reservation IDs returned
|
|
107
|
-
- ✅ Files locked to this agent
|
|
108
|
-
|
|
109
|
-
3. **Make some file modifications**
|
|
110
|
-
```bash
|
|
111
|
-
# Modify test/file1.ts
|
|
112
|
-
echo "// First change" >> test/file1.ts
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**Expected result:**
|
|
116
|
-
- File modified on disk
|
|
117
|
-
|
|
118
|
-
**Verify:**
|
|
119
|
-
- ✅ File contains new content
|
|
120
|
-
|
|
121
|
-
4. **Report 50% progress (triggers auto-checkpoint)**
|
|
122
|
-
```typescript
|
|
123
|
-
swarm_progress(
|
|
124
|
-
project_key: "/absolute/path/to/project",
|
|
125
|
-
agent_name: "BlueLake",
|
|
126
|
-
bead_id: "bd-123.1",
|
|
127
|
-
status: "in_progress",
|
|
128
|
-
progress_percent: 50,
|
|
129
|
-
message: "Completed first file modification",
|
|
130
|
-
files_touched: ["test/file1.ts"]
|
|
131
|
-
)
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**Expected result:**
|
|
135
|
-
```json
|
|
136
|
-
{
|
|
137
|
-
"success": true,
|
|
138
|
-
"data": {
|
|
139
|
-
"checkpoint_created": true,
|
|
140
|
-
"message": "Progress reported and checkpoint saved"
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
**Verify:**
|
|
146
|
-
- ✅ Checkpoint creation confirmed
|
|
147
|
-
- ✅ Progress percentage is 50
|
|
148
|
-
- ✅ Files touched recorded
|
|
149
|
-
|
|
150
|
-
5. **Verify checkpoint was created in swarm-mail**
|
|
151
|
-
```typescript
|
|
152
|
-
// Query the event store directly (if you have access)
|
|
153
|
-
// Or check via beads metadata
|
|
154
|
-
hive_query(status: "in_progress")
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
**Expected result:**
|
|
158
|
-
- Bead shows 50% progress
|
|
159
|
-
- Checkpoint event exists in event store
|
|
160
|
-
|
|
161
|
-
**Verify:**
|
|
162
|
-
- ✅ Checkpoint event type: "swarm_checkpoint_created"
|
|
163
|
-
- ✅ Recovery data includes: epic_id, bead_id, files, progress_percent, files_modified
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
### Phase 2: Simulate Context Death
|
|
168
|
-
|
|
169
|
-
**Session A - Terminal 1**
|
|
170
|
-
|
|
171
|
-
6. **Kill the session abruptly**
|
|
172
|
-
```bash
|
|
173
|
-
# Press Ctrl+C or kill the terminal
|
|
174
|
-
# DO NOT gracefully close - simulate crash
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**Expected result:**
|
|
178
|
-
- Session terminates immediately
|
|
179
|
-
- No cleanup runs
|
|
180
|
-
|
|
181
|
-
**Verify:**
|
|
182
|
-
- ✅ Session ended ungracefully
|
|
183
|
-
- ✅ Agent did NOT release reservations
|
|
184
|
-
- ✅ Work state is "frozen" in event store
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
### Phase 3: Recover State in New Session
|
|
189
|
-
|
|
190
|
-
**Session B - Terminal 2**
|
|
191
|
-
|
|
192
|
-
7. **Start fresh session (simulate new agent)**
|
|
193
|
-
```typescript
|
|
194
|
-
swarmmail_init(
|
|
195
|
-
project_path: "/absolute/path/to/project",
|
|
196
|
-
task_description: "Recovering from context death"
|
|
197
|
-
)
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
**Expected result:**
|
|
201
|
-
```json
|
|
202
|
-
{
|
|
203
|
-
"success": true,
|
|
204
|
-
"data": {
|
|
205
|
-
"agent_name": "CrimsonPeak", // DIFFERENT agent name
|
|
206
|
-
"project_key": "/absolute/path/to/project"
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
**Verify:**
|
|
212
|
-
- ✅ New agent name (different from Session A)
|
|
213
|
-
- ✅ Fresh session started
|
|
214
|
-
|
|
215
|
-
8. **Attempt recovery**
|
|
216
|
-
```typescript
|
|
217
|
-
swarm_recover(
|
|
218
|
-
project_key: "/absolute/path/to/project",
|
|
219
|
-
bead_id: "bd-123.1"
|
|
220
|
-
)
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
**Expected result:**
|
|
224
|
-
```json
|
|
225
|
-
{
|
|
226
|
-
"success": true,
|
|
227
|
-
"data": {
|
|
228
|
-
"recovered": true,
|
|
229
|
-
"checkpoint": {
|
|
230
|
-
"epic_id": "bd-123",
|
|
231
|
-
"bead_id": "bd-123.1",
|
|
232
|
-
"strategy": "file-based",
|
|
233
|
-
"files": ["test/file1.ts", "test/file2.ts"],
|
|
234
|
-
"recovery": {
|
|
235
|
-
"last_checkpoint": 1234567890,
|
|
236
|
-
"files_modified": ["test/file1.ts"],
|
|
237
|
-
"progress_percent": 50,
|
|
238
|
-
"last_message": "Completed first file modification"
|
|
239
|
-
},
|
|
240
|
-
"directives": {
|
|
241
|
-
"shared_context": "Test context recovery feature",
|
|
242
|
-
"coordinator_notes": "Resume from 50% completion"
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
"message": "State recovered from checkpoint at 50%"
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
**Verify:**
|
|
251
|
-
- ✅ Recovery successful
|
|
252
|
-
- ✅ Progress is 50% (matches last checkpoint)
|
|
253
|
-
- ✅ Files modified list is correct
|
|
254
|
-
- ✅ Last message preserved
|
|
255
|
-
- ✅ Strategy and directives restored
|
|
256
|
-
|
|
257
|
-
9. **Verify file reservations were transferred**
|
|
258
|
-
```typescript
|
|
259
|
-
// Check inbox for reservation status
|
|
260
|
-
swarmmail_inbox(limit: 5)
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
**Expected result:**
|
|
264
|
-
- Reservations still exist (orphaned from BlueLake)
|
|
265
|
-
- OR recovery automatically transferred ownership to CrimsonPeak
|
|
266
|
-
|
|
267
|
-
**Verify:**
|
|
268
|
-
- ✅ Files are either still reserved or available for new reservation
|
|
269
|
-
- ✅ No reservation conflicts
|
|
270
|
-
|
|
271
|
-
10. **Resume work with recovered state**
|
|
272
|
-
```bash
|
|
273
|
-
# Modify test/file2.ts (continue where Session A left off)
|
|
274
|
-
echo "// Second change" >> test/file2.ts
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
**Expected result:**
|
|
278
|
-
- File modified successfully
|
|
279
|
-
|
|
280
|
-
**Verify:**
|
|
281
|
-
- ✅ Agent can continue work
|
|
282
|
-
- ✅ File modifications build on previous state
|
|
283
|
-
|
|
284
|
-
11. **Report completion**
|
|
285
|
-
```typescript
|
|
286
|
-
swarm_complete(
|
|
287
|
-
project_key: "/absolute/path/to/project",
|
|
288
|
-
agent_name: "CrimsonPeak",
|
|
289
|
-
bead_id: "bd-123.1",
|
|
290
|
-
summary: "Completed context recovery test - survived session death",
|
|
291
|
-
files_touched: ["test/file1.ts", "test/file2.ts"]
|
|
292
|
-
)
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
**Expected result:**
|
|
296
|
-
```json
|
|
297
|
-
{
|
|
298
|
-
"success": true,
|
|
299
|
-
"data": {
|
|
300
|
-
"bead_closed": true,
|
|
301
|
-
"reservations_released": true,
|
|
302
|
-
"ubs_scan_passed": true
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
**Verify:**
|
|
308
|
-
- ✅ Bead marked complete
|
|
309
|
-
- ✅ Reservations released
|
|
310
|
-
- ✅ All files touched recorded (both sessions combined)
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
## Verification Checklist
|
|
315
|
-
|
|
316
|
-
### Checkpoint Creation
|
|
317
|
-
- [ ] Auto-checkpoint triggered at 50% progress
|
|
318
|
-
- [ ] Checkpoint includes epic_id, bead_id, strategy
|
|
319
|
-
- [ ] Files list preserved
|
|
320
|
-
- [ ] Progress percentage stored
|
|
321
|
-
- [ ] Files modified list accurate
|
|
322
|
-
- [ ] Last message captured
|
|
323
|
-
|
|
324
|
-
### Recovery Mechanism
|
|
325
|
-
- [ ] New session can query checkpoint by bead_id
|
|
326
|
-
- [ ] All checkpoint data restored correctly
|
|
327
|
-
- [ ] Directives and context preserved
|
|
328
|
-
- [ ] Recovery returns actionable state object
|
|
329
|
-
|
|
330
|
-
### State Continuity
|
|
331
|
-
- [ ] Work can resume from exact checkpoint state
|
|
332
|
-
- [ ] File modifications from Session A are visible
|
|
333
|
-
- [ ] Progress percentage matches last checkpoint (50%)
|
|
334
|
-
- [ ] Completion acknowledges full file list (both sessions)
|
|
335
|
-
|
|
336
|
-
### Edge Cases
|
|
337
|
-
- [ ] Recovery fails gracefully if no checkpoint exists
|
|
338
|
-
- [ ] Recovery handles multiple checkpoints (returns latest)
|
|
339
|
-
- [ ] Orphaned reservations don't block recovery
|
|
340
|
-
- [ ] Recovery works across different agent names
|
|
341
|
-
|
|
342
|
-
---
|
|
343
|
-
|
|
344
|
-
## Expected Failure Modes (Negative Testing)
|
|
345
|
-
|
|
346
|
-
### Test 1: Recovery with No Checkpoint
|
|
347
|
-
```typescript
|
|
348
|
-
swarm_recover(
|
|
349
|
-
project_key: "/path/to/project",
|
|
350
|
-
bead_id: "bd-999.1" // Non-existent bead
|
|
351
|
-
)
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
**Expected result:**
|
|
355
|
-
```json
|
|
356
|
-
{
|
|
357
|
-
"success": false,
|
|
358
|
-
"error": "No checkpoint found for bead bd-999.1"
|
|
359
|
-
}
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
### Test 2: Recovery Before Any Progress
|
|
363
|
-
```typescript
|
|
364
|
-
// Create bead but never report progress
|
|
365
|
-
swarm_recover(
|
|
366
|
-
project_key: "/path/to/project",
|
|
367
|
-
bead_id: "bd-123.2"
|
|
368
|
-
)
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
**Expected result:**
|
|
372
|
-
```json
|
|
373
|
-
{
|
|
374
|
-
"success": false,
|
|
375
|
-
"error": "No checkpoint found - agent never reported progress"
|
|
376
|
-
}
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
### Test 3: Manual Checkpoint Creation
|
|
380
|
-
```typescript
|
|
381
|
-
// Agent can force checkpoint at any time
|
|
382
|
-
swarm_checkpoint(
|
|
383
|
-
project_key: "/path/to/project",
|
|
384
|
-
bead_id: "bd-123.1",
|
|
385
|
-
checkpoint_data: {
|
|
386
|
-
progress_percent: 33,
|
|
387
|
-
files_modified: ["test/file1.ts"],
|
|
388
|
-
message: "Manual checkpoint before risky operation"
|
|
389
|
-
}
|
|
390
|
-
)
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
**Expected result:**
|
|
394
|
-
```json
|
|
395
|
-
{
|
|
396
|
-
"success": true,
|
|
397
|
-
"data": {
|
|
398
|
-
"checkpoint_id": 42,
|
|
399
|
-
"message": "Manual checkpoint created"
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
---
|
|
405
|
-
|
|
406
|
-
## Troubleshooting
|
|
407
|
-
|
|
408
|
-
### Issue: Recovery returns empty checkpoint
|
|
409
|
-
**Cause:** Checkpoint event not committed to event store
|
|
410
|
-
**Fix:** Verify `swarm_progress` was called with `progress_percent >= 25`
|
|
411
|
-
|
|
412
|
-
### Issue: Files modified in Session A not visible in Session B
|
|
413
|
-
**Cause:** File changes not committed to git or filesystem
|
|
414
|
-
**Fix:** Ensure file writes are flushed before killing session
|
|
415
|
-
|
|
416
|
-
### Issue: Reservation conflicts after recovery
|
|
417
|
-
**Cause:** Orphaned reservations from dead agent
|
|
418
|
-
**Fix:** Implement TTL-based reservation expiry or manual release by project_key
|
|
419
|
-
|
|
420
|
-
### Issue: Multiple checkpoints confuse recovery
|
|
421
|
-
**Cause:** Recovery not selecting latest checkpoint
|
|
422
|
-
**Fix:** Verify recovery queries `ORDER BY timestamp DESC LIMIT 1`
|
|
423
|
-
|
|
424
|
-
---
|
|
425
|
-
|
|
426
|
-
## Advanced Scenarios
|
|
427
|
-
|
|
428
|
-
### Scenario A: Coordinator Death
|
|
429
|
-
1. Coordinator spawns 5 worker agents
|
|
430
|
-
2. Coordinator dies at 60% overall completion
|
|
431
|
-
3. New coordinator recovers state for all workers
|
|
432
|
-
4. Workers continue reporting to new coordinator
|
|
433
|
-
|
|
434
|
-
### Scenario B: Cascading Recovery
|
|
435
|
-
1. Worker A checkpoints at 50%
|
|
436
|
-
2. Worker A dies
|
|
437
|
-
3. Worker B recovers Worker A's state
|
|
438
|
-
4. Worker B checkpoints at 75%
|
|
439
|
-
5. Worker B dies
|
|
440
|
-
6. Worker C recovers Worker B's state (which includes Worker A's progress)
|
|
441
|
-
|
|
442
|
-
### Scenario C: Partial File Reservation
|
|
443
|
-
1. Agent reserves 10 files
|
|
444
|
-
2. Modifies 3 files
|
|
445
|
-
3. Dies at 30%
|
|
446
|
-
4. Recovery agent only needs to work on remaining 7 files
|
|
447
|
-
|
|
448
|
-
---
|
|
449
|
-
|
|
450
|
-
## Success Metrics
|
|
451
|
-
|
|
452
|
-
| Metric | Target | Actual |
|
|
453
|
-
|--------|--------|--------|
|
|
454
|
-
| Recovery accuracy | 100% state match | _____ |
|
|
455
|
-
| Time to recover | < 5 seconds | _____ |
|
|
456
|
-
| Data loss | 0 bytes | _____ |
|
|
457
|
-
| Checkpoint overhead | < 100ms per checkpoint | _____ |
|
|
458
|
-
| Storage per checkpoint | < 10KB | _____ |
|
|
459
|
-
|
|
460
|
-
---
|
|
461
|
-
|
|
462
|
-
## Conclusion
|
|
463
|
-
|
|
464
|
-
This manual test proves that:
|
|
465
|
-
1. ✅ Agents can survive catastrophic context loss
|
|
466
|
-
2. ✅ Work state is preserved in event-sourced storage
|
|
467
|
-
3. ✅ Recovery is deterministic and accurate
|
|
468
|
-
4. ✅ Multi-session workflows are possible
|
|
469
|
-
|
|
470
|
-
**Sign-off:** If all verification checkboxes are marked and success metrics met, the context recovery feature is production-ready.
|