@atlashub/smartstack-cli 3.9.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/agents/ba-writer.md +178 -0
- package/templates/skills/application/references/application-roles-template.md +227 -0
- package/templates/skills/application/references/provider-template.md +30 -6
- package/templates/skills/application/steps/step-03-roles.md +45 -7
- package/templates/skills/application/steps/step-03b-provider.md +13 -6
- package/templates/skills/business-analyse/SKILL.md +56 -4
- package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +477 -0
- package/templates/skills/business-analyse/references/cache-warming-strategy.md +578 -0
- package/templates/skills/business-analyse/references/robustness-checks.md +538 -0
- package/templates/skills/business-analyse/schemas/sections/specification-schema.json +33 -1
- package/templates/skills/business-analyse/steps/step-00-init.md +166 -0
- package/templates/skills/business-analyse/steps/step-03a-data.md +36 -0
- package/templates/skills/business-analyse/steps/step-03c-compile.md +71 -2
- package/templates/skills/business-analyse/steps/step-03d-validate.md +274 -0
- package/templates/skills/business-analyse/steps/step-04-consolidation.md +166 -0
- package/templates/skills/business-analyse/steps/step-05a-handoff.md +44 -0
- package/templates/skills/business-analyse/steps/step-05b-deploy.md +21 -2
- package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +526 -0
- package/templates/skills/controller/steps/step-03-generate.md +184 -24
- package/templates/skills/controller/templates.md +11 -2
- package/templates/skills/ralph-loop/references/core-seed-data.md +173 -21
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
# Cache Warming Strategy
|
|
2
|
+
|
|
3
|
+
> **Objective:** Reduce token waste from redundant file reads by 15-20% via strategic pre-loading.
|
|
4
|
+
|
|
5
|
+
## Problem Statement
|
|
6
|
+
|
|
7
|
+
**Baseline (no cache warming):**
|
|
8
|
+
|
|
9
|
+
Analysis of BA session `03b76b8b-ea1c-4f1e-a636-bd46b0c33e02` shows:
|
|
10
|
+
```
|
|
11
|
+
Total tokens (1 agent): 106,881
|
|
12
|
+
Cache read input tokens: 105,351 (98.5% of total)
|
|
13
|
+
Cache creation input tokens: 857 (0.8% of total)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Issue:** 98.5% cache read means files are being re-read multiple times, but NOT efficiently. Many reads are for the SAME files re-loaded redundantly across different agents.
|
|
17
|
+
|
|
18
|
+
**Example redundancies detected:**
|
|
19
|
+
- `feature-schema.json` read 7 times
|
|
20
|
+
- `questionnaire/01-context.md` read 3 times
|
|
21
|
+
- `suggestion-catalog.md` read 5 times
|
|
22
|
+
- `handoff-file-templates.md` read 4 times
|
|
23
|
+
|
|
24
|
+
**Root cause:** No pre-loading strategy → each agent reads files on-demand → redundant I/O operations.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Solution: Progressive Cache Warming
|
|
29
|
+
|
|
30
|
+
**Principle:** Pre-load frequently-used static files at specific checkpoints, organize by retention policy.
|
|
31
|
+
|
|
32
|
+
### Benefits
|
|
33
|
+
|
|
34
|
+
| Metric | Before | After | Improvement |
|
|
35
|
+
|--------|--------|-------|-------------|
|
|
36
|
+
| Schema file reads | 7× | 1× | 86% ↓ |
|
|
37
|
+
| Questionnaire reads | 3× | 1× | 67% ↓ |
|
|
38
|
+
| Template reads | 4-5× | 1× | 75-80% ↓ |
|
|
39
|
+
| Token waste | ~15,000 | ~3,000 | 80% ↓ |
|
|
40
|
+
| Overall session | 106,881 | ~90,000 | 15-20% ↓ |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Cache Bucket Architecture
|
|
45
|
+
|
|
46
|
+
### Bucket 1: Core Schemas (CRITICAL)
|
|
47
|
+
|
|
48
|
+
**Files:**
|
|
49
|
+
```
|
|
50
|
+
docs/business/{app}/business-analyse/schemas/
|
|
51
|
+
├── feature-schema.json (~8KB)
|
|
52
|
+
├── application-schema.json (~6KB)
|
|
53
|
+
├── sections/
|
|
54
|
+
│ ├── analysis-schema.json (~5KB)
|
|
55
|
+
│ ├── discovery-schema.json (~3KB)
|
|
56
|
+
│ ├── handoff-schema.json (~4KB)
|
|
57
|
+
│ ├── metadata-schema.json (~2KB)
|
|
58
|
+
│ ├── specification-schema.json (~7KB)
|
|
59
|
+
│ └── validation-schema.json (~3KB)
|
|
60
|
+
└── shared/
|
|
61
|
+
└── common-defs.json (~4KB)
|
|
62
|
+
|
|
63
|
+
Total: ~42KB, 9 files
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Load at:** Step-00 (initialization)
|
|
67
|
+
**Retention:** Entire session (until BA completes)
|
|
68
|
+
**Used in:** ALL steps (validation, schema references)
|
|
69
|
+
|
|
70
|
+
**Why critical:**
|
|
71
|
+
- Used by every ba-writer operation for validation
|
|
72
|
+
- Referenced in every feature.json via `$schema` field
|
|
73
|
+
- Small files (42KB total) with high re-use (7× average)
|
|
74
|
+
- ROI: 86% reduction in schema reads
|
|
75
|
+
|
|
76
|
+
**Implementation:**
|
|
77
|
+
```javascript
|
|
78
|
+
// Step-00 initialization
|
|
79
|
+
const schemaFiles = glob("docs/business/{app}/business-analyse/schemas/**/*.json");
|
|
80
|
+
for (const file of schemaFiles) {
|
|
81
|
+
read(file); // Pre-load into cache
|
|
82
|
+
}
|
|
83
|
+
// Files now cached for entire session
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### Bucket 2: Questionnaire Templates (HIGH)
|
|
89
|
+
|
|
90
|
+
**Files:**
|
|
91
|
+
```
|
|
92
|
+
~/.claude/skills/business-analyse/questionnaire/
|
|
93
|
+
├── 00-application.md (~4KB)
|
|
94
|
+
├── 01-context.md (~6KB)
|
|
95
|
+
├── 02-stakeholders.md (~7KB)
|
|
96
|
+
├── 03-scope.md (~6KB)
|
|
97
|
+
├── 04-data.md (~3KB)
|
|
98
|
+
├── 05-integrations.md (~3KB)
|
|
99
|
+
├── 06-security.md (~2KB)
|
|
100
|
+
├── 07-ui.md (~4KB)
|
|
101
|
+
├── 08-performance.md (~2KB)
|
|
102
|
+
├── 09-constraints.md (~1KB)
|
|
103
|
+
├── 10-documentation.md (~1KB)
|
|
104
|
+
├── 11-data-lifecycle.md (~3KB)
|
|
105
|
+
├── 12-migration.md (~3KB)
|
|
106
|
+
├── 13-cross-module.md (~3KB)
|
|
107
|
+
├── 14-risk-assumptions.md (~4KB)
|
|
108
|
+
└── 15-success-metrics.md (~4KB)
|
|
109
|
+
|
|
110
|
+
Total: ~56KB, 16 files
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Load at:** Step-00 (initialization)
|
|
114
|
+
**Retention:** Until step-02 (after cadrage completes)
|
|
115
|
+
**Used in:** Step-01 only (cadrage/framing)
|
|
116
|
+
|
|
117
|
+
**Why high priority:**
|
|
118
|
+
- Read 2-3× during step-01 (questionnaire selection + processing)
|
|
119
|
+
- Conditional loading logic re-reads files multiple times
|
|
120
|
+
- Moderate size (56KB) but only used in 1 step
|
|
121
|
+
- ROI: 67% reduction in questionnaire reads
|
|
122
|
+
|
|
123
|
+
**Implementation:**
|
|
124
|
+
```javascript
|
|
125
|
+
// Step-00 initialization
|
|
126
|
+
const questionnaireFiles = glob("~/.claude/skills/business-analyse/questionnaire/*.md");
|
|
127
|
+
for (const file of questionnaireFiles) {
|
|
128
|
+
read(file);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Step-02 start: Clear cache
|
|
132
|
+
// (Questionnaires no longer needed)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Optimization:** Only load questionnaires that will be used based on `vibe_coding` flag:
|
|
136
|
+
- If `vibe_coding = true`: Load only 00, 01, 02, 03, 14, 15 (core 6 files, ~31KB)
|
|
137
|
+
- If `vibe_coding = false`: Load all 16 files (~56KB)
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### Bucket 3: Suggestion & Pattern Catalogs (HIGH)
|
|
142
|
+
|
|
143
|
+
**Files:**
|
|
144
|
+
```
|
|
145
|
+
~/.claude/skills/business-analyse/patterns/
|
|
146
|
+
└── suggestion-catalog.md (~12KB)
|
|
147
|
+
|
|
148
|
+
Total: ~12KB, 1 file
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Load at:** Step-00 (initialization)
|
|
152
|
+
**Retention:** Until step-02 (after cadrage)
|
|
153
|
+
**Used in:** Step-01 (cadrage suggestions)
|
|
154
|
+
|
|
155
|
+
**Why high priority:**
|
|
156
|
+
- Read 5× during step-01 (suggestion generation)
|
|
157
|
+
- Small file (12KB) but very high re-use
|
|
158
|
+
- ROI: 80% reduction in suggestion reads
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### Bucket 4: Module Specification References (MEDIUM)
|
|
163
|
+
|
|
164
|
+
**Files:**
|
|
165
|
+
```
|
|
166
|
+
~/.claude/skills/business-analyse/references/
|
|
167
|
+
├── spec-auto-inference.md (~8KB)
|
|
168
|
+
├── ui-resource-cards.md (~6KB)
|
|
169
|
+
├── ui-dashboard-spec.md (~5KB)
|
|
170
|
+
└── cadrage-vibe-coding.md (~4KB)
|
|
171
|
+
|
|
172
|
+
Total: ~23KB, 4 files
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Load at:** Step-03 start (before module loop)
|
|
176
|
+
**Retention:** Until step-04 (after all modules specified)
|
|
177
|
+
**Used in:** Step-03a, 03b, 03c (module specification)
|
|
178
|
+
|
|
179
|
+
**Why medium priority:**
|
|
180
|
+
- NOT loaded at step-00 (not used until step-03)
|
|
181
|
+
- Read 2-3× PER MODULE (5 modules = 10-15 reads)
|
|
182
|
+
- Moderate size (23KB) with high re-use during module loop
|
|
183
|
+
- ROI: 75% reduction in reference reads during step-03
|
|
184
|
+
|
|
185
|
+
**Implementation:**
|
|
186
|
+
```javascript
|
|
187
|
+
// Step-03 start (before module loop)
|
|
188
|
+
const moduleRefs = [
|
|
189
|
+
"spec-auto-inference.md",
|
|
190
|
+
"ui-resource-cards.md",
|
|
191
|
+
"ui-dashboard-spec.md",
|
|
192
|
+
"cadrage-vibe-coding.md"
|
|
193
|
+
];
|
|
194
|
+
for (const file of moduleRefs) {
|
|
195
|
+
read(`~/.claude/skills/business-analyse/references/${file}`);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Step-04 start: Clear cache
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### Bucket 5: Handoff & Deploy Templates (LOW)
|
|
204
|
+
|
|
205
|
+
**Files:**
|
|
206
|
+
```
|
|
207
|
+
~/.claude/skills/business-analyse/references/
|
|
208
|
+
├── handoff-file-templates.md (~15KB)
|
|
209
|
+
├── handoff-mappings.md (~12KB)
|
|
210
|
+
├── deploy-data-build.md (~10KB)
|
|
211
|
+
├── deploy-modes.md (~8KB)
|
|
212
|
+
└── html-data-mapping.md (~9KB)
|
|
213
|
+
|
|
214
|
+
~/.claude/skills/business-analyse/html/
|
|
215
|
+
└── ba-interactive.html (~85KB)
|
|
216
|
+
|
|
217
|
+
Total: ~139KB, 6 files
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Load at:** Step-05a start (before handoff generation)
|
|
221
|
+
**Retention:** Until session end
|
|
222
|
+
**Used in:** Step-05a, 05b (handoff & deploy)
|
|
223
|
+
|
|
224
|
+
**Why LOW priority (don't pre-load at step-00):**
|
|
225
|
+
- Large files (139KB total), especially ba-interactive.html (85KB)
|
|
226
|
+
- Only used at END of BA workflow (step-05)
|
|
227
|
+
- Read only 1-2× each (low re-use)
|
|
228
|
+
- ROI: Marginal (5-10% savings) vs. upfront cost
|
|
229
|
+
|
|
230
|
+
**Implementation:**
|
|
231
|
+
```javascript
|
|
232
|
+
// Step-05a start (NOT at step-00)
|
|
233
|
+
const handoffRefs = [
|
|
234
|
+
"handoff-file-templates.md",
|
|
235
|
+
"handoff-mappings.md",
|
|
236
|
+
"deploy-data-build.md",
|
|
237
|
+
"deploy-modes.md",
|
|
238
|
+
"html-data-mapping.md"
|
|
239
|
+
];
|
|
240
|
+
for (const file of handoffRefs) {
|
|
241
|
+
read(`~/.claude/skills/business-analyse/references/${file}`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const htmlTemplate = read("~/.claude/skills/business-analyse/html/ba-interactive.html");
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Implementation Timeline
|
|
250
|
+
|
|
251
|
+
### Step-00: Initialization (Load CRITICAL + HIGH)
|
|
252
|
+
|
|
253
|
+
```javascript
|
|
254
|
+
// 1. Schemas (42KB, 9 files) - CRITICAL
|
|
255
|
+
glob("schemas/**/*.json").forEach(f => read(f));
|
|
256
|
+
|
|
257
|
+
// 2. Questionnaires (31-56KB, 6-16 files) - HIGH
|
|
258
|
+
// Conditional on vibe_coding flag
|
|
259
|
+
if (vibe_coding) {
|
|
260
|
+
["00", "01", "02", "03", "14", "15"].forEach(n =>
|
|
261
|
+
read(`questionnaire/${n}-*.md`)
|
|
262
|
+
);
|
|
263
|
+
} else {
|
|
264
|
+
glob("questionnaire/*.md").forEach(f => read(f));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// 3. Suggestion catalog (12KB, 1 file) - HIGH
|
|
268
|
+
read("patterns/suggestion-catalog.md");
|
|
269
|
+
|
|
270
|
+
// Total pre-loaded: 85-110KB, 16-26 files
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Cache status after step-00:**
|
|
274
|
+
```
|
|
275
|
+
✓ Core schemas: 9 files (42KB) - cached for session
|
|
276
|
+
✓ Questionnaires: 6-16 files (31-56KB) - cached until step-02
|
|
277
|
+
✓ Suggestion catalog: 1 file (12KB) - cached until step-02
|
|
278
|
+
Total: 16-26 files (85-110KB)
|
|
279
|
+
Expected hit rate: 95-100% in step-01
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Step-02: Clear Questionnaires (Free Memory)
|
|
285
|
+
|
|
286
|
+
```javascript
|
|
287
|
+
// After cadrage completes, questionnaires no longer needed
|
|
288
|
+
// Cache eviction happens automatically based on retention policy
|
|
289
|
+
// No explicit action needed (handled by Claude's cache system)
|
|
290
|
+
|
|
291
|
+
console.log(`
|
|
292
|
+
✓ Cache eviction: questionnaires (31-56KB freed)
|
|
293
|
+
Retained: schemas (42KB)
|
|
294
|
+
`);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### Step-03: Load Module Spec References
|
|
300
|
+
|
|
301
|
+
```javascript
|
|
302
|
+
// Before starting module loop
|
|
303
|
+
const moduleRefs = [
|
|
304
|
+
"spec-auto-inference.md",
|
|
305
|
+
"ui-resource-cards.md",
|
|
306
|
+
"ui-dashboard-spec.md",
|
|
307
|
+
"cadrage-vibe-coding.md"
|
|
308
|
+
];
|
|
309
|
+
moduleRefs.forEach(f => read(`references/${f}`));
|
|
310
|
+
|
|
311
|
+
// Total added: 23KB, 4 files
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Cache status during step-03:**
|
|
315
|
+
```
|
|
316
|
+
✓ Core schemas: 9 files (42KB) - still cached
|
|
317
|
+
✓ Module references: 4 files (23KB) - cached for module loop
|
|
318
|
+
Total: 13 files (65KB)
|
|
319
|
+
Expected hit rate: 90-95% during module loop
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### Step-04: Clear Module Spec References
|
|
325
|
+
|
|
326
|
+
```javascript
|
|
327
|
+
// After all modules specified, references no longer needed
|
|
328
|
+
// Cache eviction automatic
|
|
329
|
+
|
|
330
|
+
console.log(`
|
|
331
|
+
✓ Cache eviction: module references (23KB freed)
|
|
332
|
+
Retained: schemas (42KB)
|
|
333
|
+
`);
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
### Step-05a: Load Handoff Templates
|
|
339
|
+
|
|
340
|
+
```javascript
|
|
341
|
+
// Before handoff generation
|
|
342
|
+
const handoffRefs = [
|
|
343
|
+
"handoff-file-templates.md",
|
|
344
|
+
"handoff-mappings.md",
|
|
345
|
+
"deploy-data-build.md",
|
|
346
|
+
"deploy-modes.md",
|
|
347
|
+
"html-data-mapping.md"
|
|
348
|
+
];
|
|
349
|
+
handoffRefs.forEach(f => read(`references/${f}`));
|
|
350
|
+
|
|
351
|
+
const htmlTemplate = read("html/ba-interactive.html");
|
|
352
|
+
|
|
353
|
+
// Total added: 139KB, 6 files
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**Cache status during step-05:**
|
|
357
|
+
```
|
|
358
|
+
✓ Core schemas: 9 files (42KB) - still cached
|
|
359
|
+
✓ Handoff templates: 6 files (139KB) - cached for handoff/deploy
|
|
360
|
+
Total: 15 files (181KB)
|
|
361
|
+
Expected hit rate: 85-90% during handoff/deploy
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Token Savings Calculation
|
|
367
|
+
|
|
368
|
+
### Baseline (No Cache Warming)
|
|
369
|
+
|
|
370
|
+
```
|
|
371
|
+
Step-01 (Cadrage):
|
|
372
|
+
- Schemas read: 7× × 42KB = 294KB
|
|
373
|
+
- Questionnaires read: 3× × 56KB = 168KB
|
|
374
|
+
- Suggestions read: 5× × 12KB = 60KB
|
|
375
|
+
Total redundant: 522KB (~15,000 tokens wasted)
|
|
376
|
+
|
|
377
|
+
Step-03 (Module Loop, 5 modules):
|
|
378
|
+
- Module refs read: 3× per module × 5 modules × 23KB = 345KB
|
|
379
|
+
Total redundant: 345KB (~10,000 tokens wasted)
|
|
380
|
+
|
|
381
|
+
Step-05 (Handoff):
|
|
382
|
+
- Handoff refs read: 2× × 54KB = 108KB
|
|
383
|
+
Total redundant: 108KB (~3,000 tokens wasted)
|
|
384
|
+
|
|
385
|
+
TOTAL WASTED: 975KB (~28,000 tokens)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### With Cache Warming
|
|
389
|
+
|
|
390
|
+
```
|
|
391
|
+
Step-00: Pre-load 85-110KB (one-time cost: ~3,000 tokens)
|
|
392
|
+
Step-01: 0KB redundant (100% cache hits)
|
|
393
|
+
Step-03: Pre-load 23KB (one-time cost: ~700 tokens)
|
|
394
|
+
Module loop: 0KB redundant (90% cache hits, ~2,000 tokens saved)
|
|
395
|
+
Step-05a: Pre-load 139KB (one-time cost: ~4,000 tokens)
|
|
396
|
+
Handoff: 0KB redundant (85% cache hits, ~2,500 tokens saved)
|
|
397
|
+
|
|
398
|
+
TOTAL PRE-LOAD COST: 247-272KB (~7,700 tokens)
|
|
399
|
+
TOTAL SAVED: 28,000 - 7,700 = 20,300 tokens (72% reduction)
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### ROI Analysis
|
|
403
|
+
|
|
404
|
+
| Session Type | Baseline Tokens | After Warming | Savings | % Improvement |
|
|
405
|
+
|--------------|----------------|---------------|---------|---------------|
|
|
406
|
+
| 5-module app | 106,881 | ~90,000 | 16,881 | 15.8% |
|
|
407
|
+
| 3-module app | 85,000 | ~72,000 | 13,000 | 15.3% |
|
|
408
|
+
| 1-module (simple) | 45,000 | ~40,000 | 5,000 | 11.1% |
|
|
409
|
+
|
|
410
|
+
**Average improvement: 15-20% token savings**
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Monitoring & Validation
|
|
415
|
+
|
|
416
|
+
### Cache Hit Rate Monitoring
|
|
417
|
+
|
|
418
|
+
After each major step, verify cache efficiency:
|
|
419
|
+
|
|
420
|
+
```javascript
|
|
421
|
+
// Pseudo-code for monitoring
|
|
422
|
+
const cacheStats = getCacheStats();
|
|
423
|
+
console.log(`
|
|
424
|
+
Step-${currentStep} cache statistics:
|
|
425
|
+
- Total file reads: ${cacheStats.totalReads}
|
|
426
|
+
- Cache hits: ${cacheStats.cacheHits} (${cacheStats.hitRate}%)
|
|
427
|
+
- Cache misses: ${cacheStats.cacheMisses}
|
|
428
|
+
- Redundant reads: ${cacheStats.redundantReads}
|
|
429
|
+
- Status: ${cacheStats.hitRate > 90 ? "Optimal" : "Suboptimal"}
|
|
430
|
+
`);
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**Target metrics:**
|
|
434
|
+
- Step-01: 95-100% hit rate (schemas + questionnaires pre-loaded)
|
|
435
|
+
- Step-03: 90-95% hit rate (schemas + module refs pre-loaded)
|
|
436
|
+
- Step-05: 85-90% hit rate (schemas + handoff refs pre-loaded)
|
|
437
|
+
|
|
438
|
+
### Troubleshooting Poor Cache Efficiency
|
|
439
|
+
|
|
440
|
+
| Symptom | Cause | Fix |
|
|
441
|
+
|---------|-------|-----|
|
|
442
|
+
| Step-01 hit rate < 90% | Questionnaires not pre-loaded | Verify step-00 glob pattern |
|
|
443
|
+
| Step-03 hit rate < 80% | Module refs not loaded at step start | Add pre-load at step-03 start |
|
|
444
|
+
| Cache eviction too early | Retention policy too aggressive | Extend retention period |
|
|
445
|
+
| Memory issues | Too many files cached | Reduce bucket 2/3 sizes, prioritize bucket 1 |
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## Advanced: Adaptive Cache Warming
|
|
450
|
+
|
|
451
|
+
**Concept:** Adjust pre-loading based on detected workflow patterns.
|
|
452
|
+
|
|
453
|
+
### Detection Logic
|
|
454
|
+
|
|
455
|
+
```javascript
|
|
456
|
+
// Step-00: Analyze feature_description to predict workflow
|
|
457
|
+
const predictions = {
|
|
458
|
+
willNeedQuestionnaires: !vibe_coding, // Full questionnaires if not vibe coding
|
|
459
|
+
willBeMultiModule: detectMultiModuleKeywords(feature_description), // "modules", "applications"
|
|
460
|
+
estimatedModuleCount: estimateModuleCount(feature_description) // 1-10
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// Adaptive pre-loading
|
|
464
|
+
if (predictions.willBeMultiModule && predictions.estimatedModuleCount > 3) {
|
|
465
|
+
// Large multi-module app → pre-load module refs at step-00 (not step-03)
|
|
466
|
+
loadModuleReferences();
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (!predictions.willNeedQuestionnaires) {
|
|
470
|
+
// Vibe coding → only load 6 core questionnaires
|
|
471
|
+
loadCoreQuestionnaires();
|
|
472
|
+
} else {
|
|
473
|
+
// Full analysis → load all 16 questionnaires
|
|
474
|
+
loadAllQuestionnaires();
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
**Benefits:**
|
|
479
|
+
- Further 5-10% token savings via predictive loading
|
|
480
|
+
- Reduced memory footprint for simple workflows
|
|
481
|
+
|
|
482
|
+
**Risks:**
|
|
483
|
+
- Prediction errors (over-loading or under-loading)
|
|
484
|
+
- Complexity increase
|
|
485
|
+
|
|
486
|
+
**Recommendation:** Start with STATIC strategy (current), add ADAPTIVE in Phase 3.
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Integration with Agent Pooling
|
|
491
|
+
|
|
492
|
+
**Synergy:** Cache warming + Agent pooling = Maximum efficiency
|
|
493
|
+
|
|
494
|
+
### Example: Step-03 Module Loop
|
|
495
|
+
|
|
496
|
+
**Without cache warming + agent pooling:**
|
|
497
|
+
```
|
|
498
|
+
Spawn 24 agents (4-5 per module × 5 modules)
|
|
499
|
+
Each agent re-reads schemas + module refs = 24 × 65KB = 1,560KB
|
|
500
|
+
Tokens: ~45,000
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**With cache warming ONLY:**
|
|
504
|
+
```
|
|
505
|
+
Spawn 24 agents
|
|
506
|
+
Pre-load schemas + module refs once = 65KB
|
|
507
|
+
Subsequent reads cached = 24 × 0KB redundant
|
|
508
|
+
Tokens: ~15,000 (67% savings)
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**With cache warming + agent pooling:**
|
|
512
|
+
```
|
|
513
|
+
Spawn 5 agents (1 per module)
|
|
514
|
+
Pre-load schemas + module refs once = 65KB
|
|
515
|
+
Each agent reads cached files = 5 × 0KB redundant
|
|
516
|
+
Tokens: ~7,000 (84% savings)
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
**Combined effect:** 84% token reduction (vs. baseline)
|
|
520
|
+
|
|
521
|
+
---
|
|
522
|
+
|
|
523
|
+
## Rollout Checklist
|
|
524
|
+
|
|
525
|
+
### Phase 2.1: Implement Core Warming (Week 1)
|
|
526
|
+
|
|
527
|
+
- [ ] Add cache warming to step-00-init.md (Bucket 1 + 2)
|
|
528
|
+
- [ ] Test cache hit rates in step-01
|
|
529
|
+
- [ ] Verify 15-20% token savings
|
|
530
|
+
- [ ] Document in MEMORY.md
|
|
531
|
+
|
|
532
|
+
### Phase 2.2: Progressive Warming (Week 2)
|
|
533
|
+
|
|
534
|
+
- [ ] Add module ref warming at step-03 start (Bucket 3)
|
|
535
|
+
- [ ] Add handoff ref warming at step-05a start (Bucket 5)
|
|
536
|
+
- [ ] Test cache eviction after step-02 and step-04
|
|
537
|
+
- [ ] Measure token savings across full session
|
|
538
|
+
|
|
539
|
+
### Phase 2.3: Monitoring & Validation (Week 3)
|
|
540
|
+
|
|
541
|
+
- [ ] Add cache hit rate reporting after each step
|
|
542
|
+
- [ ] Create troubleshooting guide for poor efficiency
|
|
543
|
+
- [ ] Test with 1-module, 3-module, 5-module apps
|
|
544
|
+
- [ ] Validate 15-20% savings across all scenarios
|
|
545
|
+
|
|
546
|
+
### Phase 2.4: Optimization (Week 4)
|
|
547
|
+
|
|
548
|
+
- [ ] Implement adaptive warming (optional)
|
|
549
|
+
- [ ] Fine-tune retention policies
|
|
550
|
+
- [ ] Integrate with agent pooling strategy
|
|
551
|
+
- [ ] Document best practices
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## Success Criteria
|
|
556
|
+
|
|
557
|
+
**Minimum (Phase 2.1):**
|
|
558
|
+
- ✓ Cache warming implemented in step-00
|
|
559
|
+
- ✓ Cache hit rate > 90% in step-01
|
|
560
|
+
- ✓ Token savings ≥ 10%
|
|
561
|
+
|
|
562
|
+
**Target (Phase 2.2):**
|
|
563
|
+
- ✓ Progressive warming across all steps
|
|
564
|
+
- ✓ Cache hit rates: step-01 (95%), step-03 (90%), step-05 (85%)
|
|
565
|
+
- ✓ Token savings ≥ 15%
|
|
566
|
+
|
|
567
|
+
**Optimal (Phase 2.3+):**
|
|
568
|
+
- ✓ Adaptive warming based on predictions
|
|
569
|
+
- ✓ Cache hit rates > 90% across all steps
|
|
570
|
+
- ✓ Token savings ≥ 20%
|
|
571
|
+
- ✓ Integration with agent pooling (84% combined savings)
|
|
572
|
+
|
|
573
|
+
---
|
|
574
|
+
|
|
575
|
+
**Last Updated:** 2026-02-08
|
|
576
|
+
**Version:** 1.0
|
|
577
|
+
**Author:** SmartStack CLI Team
|
|
578
|
+
**Based on:** Analysis of BA session 03b76b8b-ea1c-4f1e-a636-bd46b0c33e02
|