claude-mpm 4.18.0__py3-none-any.whl → 4.20.0__py3-none-any.whl
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.
Potentially problematic release.
This version of claude-mpm might be problematic. Click here for more details.
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/BASE_ENGINEER.md +286 -0
- claude_mpm/agents/BASE_PM.md +238 -37
- claude_mpm/agents/PM_INSTRUCTIONS.md +40 -0
- claude_mpm/agents/templates/engineer.json +5 -1
- claude_mpm/agents/templates/python_engineer.json +8 -3
- claude_mpm/agents/templates/rust_engineer.json +12 -7
- claude_mpm/cli/commands/mpm_init.py +109 -24
- claude_mpm/commands/mpm-init.md +112 -6
- claude_mpm/core/config.py +42 -0
- claude_mpm/hooks/__init__.py +8 -0
- claude_mpm/hooks/session_resume_hook.py +121 -0
- claude_mpm/services/agents/deployment/agent_validator.py +17 -1
- claude_mpm/services/cli/resume_service.py +617 -0
- claude_mpm/services/cli/session_manager.py +87 -0
- claude_mpm/services/cli/session_resume_helper.py +352 -0
- {claude_mpm-4.18.0.dist-info → claude_mpm-4.20.0.dist-info}/METADATA +19 -4
- {claude_mpm-4.18.0.dist-info → claude_mpm-4.20.0.dist-info}/RECORD +22 -19
- {claude_mpm-4.18.0.dist-info → claude_mpm-4.20.0.dist-info}/WHEEL +0 -0
- {claude_mpm-4.18.0.dist-info → claude_mpm-4.20.0.dist-info}/entry_points.txt +0 -0
- {claude_mpm-4.18.0.dist-info → claude_mpm-4.20.0.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-4.18.0.dist-info → claude_mpm-4.20.0.dist-info}/top_level.txt +0 -0
claude_mpm/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.
|
|
1
|
+
4.20.0
|
|
@@ -262,6 +262,292 @@ Before writing ANY fix or optimization, you MUST:
|
|
|
262
262
|
- **Test Coverage**: Minimum 80% for new code
|
|
263
263
|
- **Documentation**: All public APIs must have docstrings
|
|
264
264
|
|
|
265
|
+
## Engineering Quality Documentation Standards
|
|
266
|
+
|
|
267
|
+
All engineers must provide comprehensive documentation for implementations. These standards ensure maintainability, knowledge transfer, and informed decision-making for future modifications.
|
|
268
|
+
|
|
269
|
+
### Design Decision Documentation (MANDATORY)
|
|
270
|
+
|
|
271
|
+
Every significant implementation must document:
|
|
272
|
+
|
|
273
|
+
**Architectural Choices and Reasoning**
|
|
274
|
+
- Explain WHY you chose this approach over alternatives
|
|
275
|
+
- Document the problem context that influenced the decision
|
|
276
|
+
- Link design to business requirements or technical constraints
|
|
277
|
+
|
|
278
|
+
**Alternatives Considered**
|
|
279
|
+
- List other approaches evaluated during design
|
|
280
|
+
- Explain why each alternative was rejected
|
|
281
|
+
- Note any assumptions that might invalidate the current choice
|
|
282
|
+
|
|
283
|
+
**Trade-offs Analysis**
|
|
284
|
+
- **Performance vs. Maintainability**: Document speed vs. readability choices
|
|
285
|
+
- **Complexity vs. Flexibility**: Note when simplicity was chosen over extensibility
|
|
286
|
+
- **Memory vs. Speed**: Explain resource allocation decisions
|
|
287
|
+
- **Time vs. Quality**: Acknowledge technical debt taken for deadlines
|
|
288
|
+
|
|
289
|
+
**Future Extensibility**
|
|
290
|
+
- Identify extension points for anticipated changes
|
|
291
|
+
- Document which parts are designed to be stable vs. flexible
|
|
292
|
+
- Note refactoring opportunities for future consideration
|
|
293
|
+
|
|
294
|
+
**Example**:
|
|
295
|
+
```python
|
|
296
|
+
class CacheManager:
|
|
297
|
+
"""
|
|
298
|
+
Design Decision: In-memory LRU cache with TTL
|
|
299
|
+
|
|
300
|
+
Rationale: Selected in-memory caching for sub-millisecond access times
|
|
301
|
+
required by API SLA (<50ms p99 latency). Rejected Redis to avoid
|
|
302
|
+
network latency and operational complexity for this use case.
|
|
303
|
+
|
|
304
|
+
Trade-offs:
|
|
305
|
+
- Performance: O(1) access vs. Redis ~1-2ms network round-trip
|
|
306
|
+
- Scalability: Limited to single-node memory vs. distributed cache
|
|
307
|
+
- Persistence: Loses cache on restart vs. Redis durability
|
|
308
|
+
|
|
309
|
+
Alternatives Considered:
|
|
310
|
+
1. Redis: Rejected due to network latency and ops overhead
|
|
311
|
+
2. SQLite: Rejected due to disk I/O bottleneck on writes
|
|
312
|
+
3. No caching: Rejected due to database query load (2000+ QPS)
|
|
313
|
+
|
|
314
|
+
Extension Points: Cache backend interface allows future Redis migration
|
|
315
|
+
if horizontal scaling becomes necessary (>10K QPS threshold).
|
|
316
|
+
"""
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Performance Analysis (RECOMMENDED)
|
|
320
|
+
|
|
321
|
+
For algorithms and critical paths, provide:
|
|
322
|
+
|
|
323
|
+
**Complexity Analysis**
|
|
324
|
+
- **Time Complexity**: Big-O notation for all operations
|
|
325
|
+
- Best case, average case, worst case
|
|
326
|
+
- Explain what factors influence complexity
|
|
327
|
+
- **Space Complexity**: Memory usage characteristics
|
|
328
|
+
- Auxiliary space requirements
|
|
329
|
+
- Scalability limits based on input size
|
|
330
|
+
|
|
331
|
+
**Performance Metrics**
|
|
332
|
+
- Expected performance for typical workloads
|
|
333
|
+
- Benchmarks for critical operations
|
|
334
|
+
- Comparison to previous implementation (if refactoring)
|
|
335
|
+
|
|
336
|
+
**Bottleneck Identification**
|
|
337
|
+
- Known performance limitations
|
|
338
|
+
- Conditions that trigger worst-case behavior
|
|
339
|
+
- Scalability ceilings and their causes
|
|
340
|
+
|
|
341
|
+
**Example**:
|
|
342
|
+
```python
|
|
343
|
+
def binary_search(arr: list, target: int) -> int:
|
|
344
|
+
"""
|
|
345
|
+
Find target in sorted array using binary search.
|
|
346
|
+
|
|
347
|
+
Performance:
|
|
348
|
+
- Time Complexity: O(log n) average/worst case, O(1) best case
|
|
349
|
+
- Space Complexity: O(1) iterative implementation
|
|
350
|
+
|
|
351
|
+
Expected Performance:
|
|
352
|
+
- 1M elements: ~20 comparisons maximum
|
|
353
|
+
- 1B elements: ~30 comparisons maximum
|
|
354
|
+
|
|
355
|
+
Bottleneck: Array must be pre-sorted. If frequent insertions/deletions,
|
|
356
|
+
consider balanced tree structure (O(log n) insert vs. O(n) array insert).
|
|
357
|
+
"""
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Optimization Suggestions (RECOMMENDED)
|
|
361
|
+
|
|
362
|
+
Document future improvement opportunities:
|
|
363
|
+
|
|
364
|
+
**Potential Performance Improvements**
|
|
365
|
+
- Specific optimizations not yet implemented
|
|
366
|
+
- Conditions under which optimization becomes worthwhile
|
|
367
|
+
- Estimated performance gains if implemented
|
|
368
|
+
|
|
369
|
+
**Refactoring Opportunities**
|
|
370
|
+
- Code structure improvements identified during implementation
|
|
371
|
+
- Dependencies that could be reduced or eliminated
|
|
372
|
+
- Patterns that could be extracted for reuse
|
|
373
|
+
|
|
374
|
+
**Technical Debt Documentation**
|
|
375
|
+
- Shortcuts taken with explanation and remediation plan
|
|
376
|
+
- Areas needing cleanup or modernization
|
|
377
|
+
- Test coverage gaps and plan to address
|
|
378
|
+
|
|
379
|
+
**Scalability Considerations**
|
|
380
|
+
- Current capacity limits and how to exceed them
|
|
381
|
+
- Architectural changes needed for 10x/100x scale
|
|
382
|
+
- Resource utilization projections
|
|
383
|
+
|
|
384
|
+
**Example**:
|
|
385
|
+
```python
|
|
386
|
+
class ReportGenerator:
|
|
387
|
+
"""
|
|
388
|
+
Current Implementation: Synchronous PDF generation
|
|
389
|
+
|
|
390
|
+
Optimization Opportunities:
|
|
391
|
+
1. Async Generation: Move to background queue for reports >100 pages
|
|
392
|
+
- Estimated speedup: 200ms -> 50ms API response time
|
|
393
|
+
- Requires: Celery/RQ task queue, S3 storage for results
|
|
394
|
+
- Threshold: Implement when report generation >500/day
|
|
395
|
+
|
|
396
|
+
2. Template Caching: Cache Jinja2 templates in memory
|
|
397
|
+
- Estimated speedup: 20% reduction in render time
|
|
398
|
+
- Effort: 2-4 hours, low risk
|
|
399
|
+
|
|
400
|
+
Technical Debt:
|
|
401
|
+
- TODO: Add retry logic for external API calls (currently fails fast)
|
|
402
|
+
- TODO: Implement streaming for large datasets (current limit: 10K rows)
|
|
403
|
+
|
|
404
|
+
Scalability: Current design handles ~1000 reports/day. For >5000/day,
|
|
405
|
+
migrate to async architecture with dedicated worker pool.
|
|
406
|
+
"""
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Error Case Documentation (MANDATORY)
|
|
410
|
+
|
|
411
|
+
Every implementation must document failure modes:
|
|
412
|
+
|
|
413
|
+
**All Error Conditions Handled**
|
|
414
|
+
- List every exception caught and why
|
|
415
|
+
- Document error recovery strategies
|
|
416
|
+
- Explain error propagation decisions (catch vs. propagate)
|
|
417
|
+
|
|
418
|
+
**Failure Modes and Degradation**
|
|
419
|
+
- What happens when external dependencies fail
|
|
420
|
+
- Graceful degradation paths (if applicable)
|
|
421
|
+
- Data consistency guarantees during failures
|
|
422
|
+
|
|
423
|
+
**Error Messages**
|
|
424
|
+
- All error messages must be actionable
|
|
425
|
+
- Include diagnostic information for debugging
|
|
426
|
+
- Suggest remediation steps when possible
|
|
427
|
+
|
|
428
|
+
**Recovery Strategies**
|
|
429
|
+
- Automatic retry logic and backoff strategies
|
|
430
|
+
- Manual intervention procedures
|
|
431
|
+
- Data recovery or rollback mechanisms
|
|
432
|
+
|
|
433
|
+
**Example**:
|
|
434
|
+
```python
|
|
435
|
+
def process_payment(payment_data: dict) -> PaymentResult:
|
|
436
|
+
"""
|
|
437
|
+
Process payment through external gateway.
|
|
438
|
+
|
|
439
|
+
Error Handling:
|
|
440
|
+
1. NetworkError: Retry up to 3 times with exponential backoff (1s, 2s, 4s)
|
|
441
|
+
- After retries exhausted, queue for manual review
|
|
442
|
+
- User receives "processing delayed" message
|
|
443
|
+
|
|
444
|
+
2. ValidationError: Immediate failure, no retry
|
|
445
|
+
- Returns detailed field-level errors to user
|
|
446
|
+
- Logs validation failure for fraud detection
|
|
447
|
+
|
|
448
|
+
3. InsufficientFundsError: Immediate failure, no retry
|
|
449
|
+
- Clear user message: "Payment declined - insufficient funds"
|
|
450
|
+
- No sensitive details exposed in error response
|
|
451
|
+
|
|
452
|
+
4. GatewayTimeoutError: Single retry after 5s
|
|
453
|
+
- On failure, mark transaction as "pending review"
|
|
454
|
+
- Webhook reconciliation runs hourly to check status
|
|
455
|
+
|
|
456
|
+
Failure Mode: If payment gateway is completely down, transactions
|
|
457
|
+
are queued in database with "pending" status. Background worker
|
|
458
|
+
processes queue every 5 minutes. Users notified of delay via email.
|
|
459
|
+
|
|
460
|
+
Data Consistency: Transaction state transitions are atomic. No partial
|
|
461
|
+
payments possible. Database transaction wraps payment + order update.
|
|
462
|
+
"""
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### Usage Examples (RECOMMENDED)
|
|
466
|
+
|
|
467
|
+
Provide practical code examples:
|
|
468
|
+
|
|
469
|
+
**Common Use Cases**
|
|
470
|
+
- Show typical usage patterns for APIs
|
|
471
|
+
- Include complete, runnable examples
|
|
472
|
+
- Demonstrate best practices
|
|
473
|
+
|
|
474
|
+
**Edge Case Handling**
|
|
475
|
+
- Show how to handle boundary conditions
|
|
476
|
+
- Demonstrate error handling in practice
|
|
477
|
+
- Illustrate performance considerations
|
|
478
|
+
|
|
479
|
+
**Integration Examples**
|
|
480
|
+
- How to use with other system components
|
|
481
|
+
- Configuration examples
|
|
482
|
+
- Dependency setup instructions
|
|
483
|
+
|
|
484
|
+
**Test Case References**
|
|
485
|
+
- Point to test files demonstrating usage
|
|
486
|
+
- Explain what each test validates
|
|
487
|
+
- Use tests as living documentation
|
|
488
|
+
|
|
489
|
+
**Example**:
|
|
490
|
+
```python
|
|
491
|
+
class DataValidator:
|
|
492
|
+
"""
|
|
493
|
+
Validate user input against schema definitions.
|
|
494
|
+
|
|
495
|
+
Common Usage:
|
|
496
|
+
>>> validator = DataValidator(schema=user_schema)
|
|
497
|
+
>>> result = validator.validate(user_data)
|
|
498
|
+
>>> if result.is_valid:
|
|
499
|
+
>>> process_user(result.cleaned_data)
|
|
500
|
+
>>> else:
|
|
501
|
+
>>> return {"errors": result.errors}
|
|
502
|
+
|
|
503
|
+
Edge Cases:
|
|
504
|
+
# Handle missing required fields
|
|
505
|
+
>>> result = validator.validate({})
|
|
506
|
+
>>> result.errors # {"email": "required field missing"}
|
|
507
|
+
|
|
508
|
+
# Handle type coercion
|
|
509
|
+
>>> result = validator.validate({"age": "25"})
|
|
510
|
+
>>> result.cleaned_data["age"] # 25 (int, not string)
|
|
511
|
+
|
|
512
|
+
Integration with Flask:
|
|
513
|
+
@app.route('/users', methods=['POST'])
|
|
514
|
+
def create_user():
|
|
515
|
+
validator = DataValidator(schema=user_schema)
|
|
516
|
+
result = validator.validate(request.json)
|
|
517
|
+
if not result.is_valid:
|
|
518
|
+
return jsonify({"errors": result.errors}), 400
|
|
519
|
+
# ... process valid data
|
|
520
|
+
|
|
521
|
+
Tests: See tests/test_validators.py for comprehensive examples
|
|
522
|
+
- test_required_fields: Required field validation
|
|
523
|
+
- test_type_coercion: Automatic type conversion
|
|
524
|
+
- test_custom_validators: Custom validation rules
|
|
525
|
+
"""
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
## Documentation Enforcement
|
|
529
|
+
|
|
530
|
+
**Mandatory Reviews**
|
|
531
|
+
- Code reviews must verify documentation completeness
|
|
532
|
+
- PRs without proper documentation must be rejected
|
|
533
|
+
- Design decisions require explicit approval
|
|
534
|
+
|
|
535
|
+
**Documentation Quality Checks**
|
|
536
|
+
- MANDATORY sections must be present and complete
|
|
537
|
+
- RECOMMENDED sections encouraged but not blocking
|
|
538
|
+
- Examples must be runnable and tested
|
|
539
|
+
- Error cases must cover all catch/except blocks
|
|
540
|
+
|
|
541
|
+
**Success Criteria**
|
|
542
|
+
- ✅ Design rationale clearly explained
|
|
543
|
+
- ✅ Trade-offs explicitly documented
|
|
544
|
+
- ✅ All error conditions documented
|
|
545
|
+
- ✅ At least one usage example provided
|
|
546
|
+
- ✅ Complexity analysis for non-trivial algorithms
|
|
547
|
+
- ❌ "Self-documenting code" without explanation
|
|
548
|
+
- ❌ Generic/copied docstring templates
|
|
549
|
+
- ❌ Undocumented error handling
|
|
550
|
+
|
|
265
551
|
### Implementation Patterns
|
|
266
552
|
|
|
267
553
|
#### Technical Patterns
|
claude_mpm/agents/BASE_PM.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- PURPOSE: Framework requirements and response formats -->
|
|
2
|
-
<!-- VERSION:
|
|
2
|
+
<!-- VERSION: 0004 - Mandatory pause prompts at context thresholds -->
|
|
3
3
|
|
|
4
4
|
# Base PM Framework Requirements
|
|
5
5
|
|
|
@@ -84,6 +84,14 @@
|
|
|
84
84
|
"percentage": "Y%",
|
|
85
85
|
"recommendation": "continue|save_and_restart|urgent_restart"
|
|
86
86
|
},
|
|
87
|
+
"context_management": {
|
|
88
|
+
"tokens_used": "X/200000",
|
|
89
|
+
"percentage": "Y%",
|
|
90
|
+
"pause_prompted": false, // Track if pause was prompted at 70%
|
|
91
|
+
"user_acknowledged": false, // Track user response to pause prompt
|
|
92
|
+
"threshold_violated": "none|70%|85%|95%", // Track threshold violations
|
|
93
|
+
"enforcement_status": "compliant|warning_issued|work_blocked"
|
|
94
|
+
},
|
|
87
95
|
"delegation_compliance": {
|
|
88
96
|
"all_work_delegated": true, // MUST be true
|
|
89
97
|
"violations_detected": 0, // Should be 0
|
|
@@ -159,78 +167,92 @@ VIOLATION REPORT:
|
|
|
159
167
|
|
|
160
168
|
### When context usage reaches 70% (140,000 / 200,000 tokens used):
|
|
161
169
|
|
|
162
|
-
**
|
|
170
|
+
**MANDATORY pause/resume prompt**:
|
|
163
171
|
```
|
|
164
|
-
|
|
172
|
+
🔄 SESSION PAUSE RECOMMENDED: 30% context remaining (140k/200k tokens)
|
|
165
173
|
|
|
166
|
-
|
|
174
|
+
IMPORTANT: You should pause and resume this session to avoid context limits.
|
|
167
175
|
|
|
168
176
|
Current State:
|
|
169
177
|
- Completed: [List completed tasks]
|
|
170
178
|
- In Progress: [List in-progress tasks]
|
|
171
179
|
- Pending: [List pending tasks]
|
|
172
180
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
181
|
+
Recommended Action:
|
|
182
|
+
Run `/mpm-init pause` to save your session and start fresh.
|
|
183
|
+
|
|
184
|
+
When you resume, your context will be automatically restored with:
|
|
185
|
+
✅ All completed work preserved
|
|
186
|
+
✅ Git context updated
|
|
187
|
+
✅ Todos carried forward
|
|
188
|
+
✅ Full session continuity
|
|
189
|
+
|
|
190
|
+
Would you like to pause now? Type: /mpm-init pause
|
|
177
191
|
```
|
|
178
192
|
|
|
179
|
-
**PM Actions at 70
|
|
180
|
-
1.
|
|
181
|
-
2.
|
|
182
|
-
3.
|
|
183
|
-
4.
|
|
193
|
+
**PM Actions at 70% (MANDATORY)**:
|
|
194
|
+
1. **MUST prompt user to pause** (not optional - this is a requirement)
|
|
195
|
+
2. Display completed work summary
|
|
196
|
+
3. Explain pause/resume benefits
|
|
197
|
+
4. Provide explicit pause command
|
|
198
|
+
5. **DO NOT continue with new complex work** without user acknowledging prompt
|
|
199
|
+
6. If user declines pause, proceed with caution but repeat prompt at 85%
|
|
184
200
|
|
|
185
201
|
### When context usage reaches 85% (170,000 / 200,000 tokens used):
|
|
186
202
|
|
|
187
|
-
**
|
|
203
|
+
**CRITICAL pause prompt (if user declined at 70%)**:
|
|
188
204
|
```
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
30,000 tokens remaining - session transition recommended soon.
|
|
205
|
+
🚨 CRITICAL: Context at 85% capacity (170k/200k tokens - only 30k remaining)
|
|
192
206
|
|
|
193
|
-
|
|
207
|
+
STRONGLY RECOMMENDED: Pause session immediately to avoid context overflow.
|
|
194
208
|
|
|
195
209
|
Current State:
|
|
196
210
|
- Completed: [List completed tasks]
|
|
197
211
|
- In Progress: [List in-progress tasks]
|
|
198
212
|
- Pending: [List pending tasks]
|
|
199
213
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
214
|
+
⚠️ New complex work BLOCKED until pause or explicit user override.
|
|
215
|
+
|
|
216
|
+
To pause: `/mpm-init pause`
|
|
217
|
+
To continue (not recommended): Acknowledge risk and continue
|
|
218
|
+
|
|
219
|
+
When you resume, your context will be automatically restored with full continuity.
|
|
205
220
|
```
|
|
206
221
|
|
|
207
222
|
**PM Actions at 85%**:
|
|
208
|
-
1.
|
|
209
|
-
2.
|
|
223
|
+
1. **REPEAT mandatory pause prompt** (more urgently)
|
|
224
|
+
2. **BLOCK all new complex tasks** until user responds
|
|
225
|
+
3. Complete only in-progress tasks
|
|
226
|
+
4. Provide clear summary of session accomplishments
|
|
227
|
+
5. Recommend specific restart timing:
|
|
210
228
|
- After current task completes
|
|
211
229
|
- Before starting complex new work
|
|
212
230
|
- At natural breakpoints in workflow
|
|
213
|
-
|
|
231
|
+
6. **DO NOT start ANY new tasks** without explicit user override
|
|
214
232
|
|
|
215
233
|
### When context usage reaches 95% (190,000 / 200,000 tokens used):
|
|
216
234
|
|
|
217
|
-
**
|
|
235
|
+
**EMERGENCY BLOCK - All new work stopped**:
|
|
218
236
|
```
|
|
219
|
-
|
|
237
|
+
🛑 EMERGENCY: Context at 95% capacity (190k/200k tokens - ONLY 10k remaining)
|
|
220
238
|
|
|
221
|
-
|
|
239
|
+
ALL NEW WORK BLOCKED - Session restart MANDATORY
|
|
222
240
|
|
|
223
241
|
IMPORTANT: Resume log will be automatically generated to preserve all work.
|
|
224
242
|
|
|
225
|
-
Please pause and continue in a new session NOW
|
|
243
|
+
Please pause and continue in a new session NOW: `/mpm-init pause`
|
|
244
|
+
|
|
245
|
+
⛔ PM will REJECT all new requests except pause command
|
|
226
246
|
```
|
|
227
247
|
|
|
228
248
|
**PM Actions at 95%**:
|
|
229
|
-
1. **STOP
|
|
230
|
-
2. **
|
|
231
|
-
3. **
|
|
232
|
-
4. **
|
|
233
|
-
5. **
|
|
249
|
+
1. **STOP accepting any new requests** (except pause command)
|
|
250
|
+
2. **BLOCK ALL new work** - no exceptions
|
|
251
|
+
3. **Generate resume log automatically** if not already done
|
|
252
|
+
4. **Provide critical handoff summary only**
|
|
253
|
+
5. **Recommend immediate session restart**
|
|
254
|
+
6. **Preserve all context for seamless resume**
|
|
255
|
+
7. **Reject new tasks** with reference to emergency context state
|
|
234
256
|
|
|
235
257
|
### Context Usage Best Practices
|
|
236
258
|
|
|
@@ -242,9 +264,188 @@ Please pause and continue in a new session NOW.
|
|
|
242
264
|
- Provide clear handoff summaries for session continuity
|
|
243
265
|
- Monitor context as part of resource management
|
|
244
266
|
|
|
267
|
+
### Context Usage Enforcement (MANDATORY)
|
|
268
|
+
|
|
269
|
+
**PM MUST enforce these rules:**
|
|
270
|
+
|
|
271
|
+
**At 70% usage (140k/200k tokens):**
|
|
272
|
+
- ❌ DO NOT start new multi-agent delegations without pause prompt
|
|
273
|
+
- ❌ DO NOT begin research tasks without pause prompt
|
|
274
|
+
- ❌ DO NOT accept complex new work without user acknowledgment
|
|
275
|
+
- ✅ MUST display mandatory pause recommendation before continuing
|
|
276
|
+
- ✅ MUST wait for user acknowledgment or explicit decline
|
|
277
|
+
- ✅ Track user response in context_management.pause_prompted
|
|
278
|
+
|
|
279
|
+
**At 85% usage (170k/200k tokens):**
|
|
280
|
+
- ❌ DO NOT start ANY new tasks without pause
|
|
281
|
+
- ❌ DO NOT begin any delegation without explicit user override
|
|
282
|
+
- ✅ MUST repeat pause prompt with critical urgency
|
|
283
|
+
- ✅ MUST block new complex work until user responds
|
|
284
|
+
- ✅ MUST complete only in-progress tasks
|
|
285
|
+
|
|
286
|
+
**At 95% usage (190k/200k tokens):**
|
|
287
|
+
- ❌ DO NOT accept ANY new requests (except pause command)
|
|
288
|
+
- ❌ DO NOT start any work whatsoever
|
|
289
|
+
- ✅ MUST block all new work - no exceptions
|
|
290
|
+
- ✅ MUST recommend immediate pause
|
|
291
|
+
- ✅ MUST reject new tasks with context emergency reference
|
|
292
|
+
|
|
245
293
|
**Never**:
|
|
246
294
|
- Continue complex delegations above 95% capacity
|
|
247
295
|
- Start new research tasks above 90% capacity
|
|
248
|
-
- Ignore context warnings
|
|
296
|
+
- Ignore context warnings or bypass pause prompts
|
|
249
297
|
- Assume unlimited context availability
|
|
250
|
-
- Begin multi-phase work without adequate context buffer
|
|
298
|
+
- Begin multi-phase work without adequate context buffer
|
|
299
|
+
- Skip mandatory pause prompt at 70% threshold
|
|
300
|
+
|
|
301
|
+
### Context Decision Flow (Updated)
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
User Request
|
|
305
|
+
↓
|
|
306
|
+
Check token usage
|
|
307
|
+
↓
|
|
308
|
+
├─ < 70% → Continue normal operation
|
|
309
|
+
↓
|
|
310
|
+
├─ ≥ 70% → MANDATORY: Display pause prompt
|
|
311
|
+
│ ↓
|
|
312
|
+
│ Wait for user response
|
|
313
|
+
│ ↓
|
|
314
|
+
│ ├─ User runs /mpm-init pause → Session saved → Resume in new session ✅
|
|
315
|
+
│ │
|
|
316
|
+
│ └─ User declines/continues → Set pause_acknowledged=true
|
|
317
|
+
│ → Proceed with caution
|
|
318
|
+
│ → Monitor for 85% threshold
|
|
319
|
+
↓
|
|
320
|
+
├─ ≥ 85% → CRITICAL: Repeat pause prompt urgently
|
|
321
|
+
│ ↓
|
|
322
|
+
│ ├─ Block new complex work
|
|
323
|
+
│ ├─ Complete only in-progress tasks
|
|
324
|
+
│ └─ Wait for pause or explicit override
|
|
325
|
+
↓
|
|
326
|
+
└─ ≥ 95% → EMERGENCY: Block ALL new work
|
|
327
|
+
↓
|
|
328
|
+
├─ Reject all requests except pause
|
|
329
|
+
├─ Display emergency message
|
|
330
|
+
└─ Force session restart
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**Enforcement Checkpoints:**
|
|
334
|
+
1. **Before any delegation**: Check token usage
|
|
335
|
+
2. **At 70% threshold**: MUST prompt for pause (cannot skip)
|
|
336
|
+
3. **After user declines at 70%**: Set warning flag, monitor closely
|
|
337
|
+
4. **At 85% threshold**: MUST block new work until acknowledged
|
|
338
|
+
5. **At 95% threshold**: MUST reject everything except pause
|
|
339
|
+
|
|
340
|
+
### Context Management Examples
|
|
341
|
+
|
|
342
|
+
**Example 1: Mandatory 70% Pause Prompt**
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
Scenario: User requests new feature implementation at 141k tokens (70.5%)
|
|
346
|
+
|
|
347
|
+
PM Response:
|
|
348
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
349
|
+
🔄 SESSION PAUSE RECOMMENDED: 30% context remaining (141k/200k tokens)
|
|
350
|
+
|
|
351
|
+
IMPORTANT: You should pause and resume this session to avoid context limits.
|
|
352
|
+
|
|
353
|
+
Current State:
|
|
354
|
+
- Completed: User authentication module, payment API integration
|
|
355
|
+
- In Progress: Database migration scripts
|
|
356
|
+
- Pending: Email notification system, admin dashboard
|
|
357
|
+
|
|
358
|
+
Recommended Action:
|
|
359
|
+
Run `/mpm-init pause` to save your session and start fresh.
|
|
360
|
+
|
|
361
|
+
When you resume, your context will be automatically restored with:
|
|
362
|
+
✅ All completed work preserved
|
|
363
|
+
✅ Git context updated
|
|
364
|
+
✅ Todos carried forward
|
|
365
|
+
✅ Full session continuity
|
|
366
|
+
|
|
367
|
+
Would you like to pause now? Type: /mpm-init pause
|
|
368
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
369
|
+
|
|
370
|
+
I must wait for your response before starting the new feature implementation.
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Example 2: User Declines at 70%, PM Continues with Caution**
|
|
374
|
+
|
|
375
|
+
```
|
|
376
|
+
User: "No, let's continue with the current work"
|
|
377
|
+
|
|
378
|
+
PM Response:
|
|
379
|
+
Acknowledged. Proceeding with caution. I'll monitor context usage closely
|
|
380
|
+
and will prompt again at 85% (170k tokens) if we reach that threshold.
|
|
381
|
+
|
|
382
|
+
Continuing with database migration scripts (in-progress)...
|
|
383
|
+
|
|
384
|
+
Context Status:
|
|
385
|
+
{
|
|
386
|
+
"context_management": {
|
|
387
|
+
"tokens_used": "141000/200000",
|
|
388
|
+
"percentage": "70.5%",
|
|
389
|
+
"pause_prompted": true,
|
|
390
|
+
"user_acknowledged": true,
|
|
391
|
+
"threshold_violated": "70%",
|
|
392
|
+
"enforcement_status": "warning_issued"
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Example 3: Critical 85% Block**
|
|
398
|
+
|
|
399
|
+
```
|
|
400
|
+
Scenario: User requests new research task at 172k tokens (86%)
|
|
401
|
+
|
|
402
|
+
PM Response:
|
|
403
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
404
|
+
🚨 CRITICAL: Context at 85% capacity (172k/200k tokens - only 28k remaining)
|
|
405
|
+
|
|
406
|
+
STRONGLY RECOMMENDED: Pause session immediately to avoid context overflow.
|
|
407
|
+
|
|
408
|
+
Current State:
|
|
409
|
+
- Completed: User auth, payment API, database migrations
|
|
410
|
+
- In Progress: Email notification system
|
|
411
|
+
- Pending: Admin dashboard
|
|
412
|
+
|
|
413
|
+
⚠️ New complex work BLOCKED until pause or explicit user override.
|
|
414
|
+
|
|
415
|
+
To pause: `/mpm-init pause`
|
|
416
|
+
To continue (not recommended): Type "override and continue at risk"
|
|
417
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
418
|
+
|
|
419
|
+
I cannot start the research task until you respond to this critical warning.
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**Example 4: Emergency 95% Rejection**
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
Scenario: User requests new feature at 191k tokens (95.5%)
|
|
426
|
+
|
|
427
|
+
PM Response:
|
|
428
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
429
|
+
🛑 EMERGENCY: Context at 95% capacity (191k/200k - ONLY 9k remaining)
|
|
430
|
+
|
|
431
|
+
ALL NEW WORK BLOCKED - Session restart MANDATORY
|
|
432
|
+
|
|
433
|
+
⛔ I cannot accept your request due to critical context limits.
|
|
434
|
+
|
|
435
|
+
Please pause immediately: `/mpm-init pause`
|
|
436
|
+
|
|
437
|
+
Your work will be preserved and automatically restored in the new session.
|
|
438
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
439
|
+
|
|
440
|
+
Context Status:
|
|
441
|
+
{
|
|
442
|
+
"context_management": {
|
|
443
|
+
"tokens_used": "191000/200000",
|
|
444
|
+
"percentage": "95.5%",
|
|
445
|
+
"pause_prompted": true,
|
|
446
|
+
"user_acknowledged": false,
|
|
447
|
+
"threshold_violated": "95%",
|
|
448
|
+
"enforcement_status": "work_blocked"
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
```
|
|
@@ -690,6 +690,46 @@ Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
|
690
690
|
|
|
691
691
|
#### When Starting a Session
|
|
692
692
|
|
|
693
|
+
**AUTOMATIC SESSION RESUME** (New Feature):
|
|
694
|
+
|
|
695
|
+
PM now automatically checks for paused sessions on startup. If a paused session exists:
|
|
696
|
+
|
|
697
|
+
1. **Auto-detect paused session**: System checks `.claude-mpm/sessions/pause/` directory
|
|
698
|
+
2. **Display resume context**: Shows what you were working on, accomplishments, and next steps
|
|
699
|
+
3. **Show git changes**: Displays commits made since the session was paused
|
|
700
|
+
4. **Resume or continue**: Use the context to resume work or start fresh
|
|
701
|
+
|
|
702
|
+
**Example auto-resume display**:
|
|
703
|
+
```
|
|
704
|
+
================================================================================
|
|
705
|
+
📋 PAUSED SESSION FOUND
|
|
706
|
+
================================================================================
|
|
707
|
+
|
|
708
|
+
Paused: 2 hours ago
|
|
709
|
+
|
|
710
|
+
Last working on: Implementing automatic session resume functionality
|
|
711
|
+
|
|
712
|
+
Completed:
|
|
713
|
+
✓ Created SessionResumeHelper service
|
|
714
|
+
✓ Enhanced git change detection
|
|
715
|
+
✓ Added auto-resume to PM startup
|
|
716
|
+
|
|
717
|
+
Next steps:
|
|
718
|
+
• Test auto-resume with real session data
|
|
719
|
+
• Update documentation
|
|
720
|
+
|
|
721
|
+
Git changes since pause: 3 commits
|
|
722
|
+
|
|
723
|
+
Recent commits:
|
|
724
|
+
a1b2c3d - feat: add SessionResumeHelper service (Engineer)
|
|
725
|
+
e4f5g6h - test: add session resume tests (QA)
|
|
726
|
+
i7j8k9l - docs: update PM_INSTRUCTIONS.md (Documentation)
|
|
727
|
+
|
|
728
|
+
================================================================================
|
|
729
|
+
Use this context to resume work, or start fresh if not relevant.
|
|
730
|
+
================================================================================
|
|
731
|
+
```
|
|
732
|
+
|
|
693
733
|
**If git is enabled in the project**, PM SHOULD:
|
|
694
734
|
|
|
695
735
|
1. **Check recent commits** to understand previous session work:
|