Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:07:22 +08:00
commit fab98d059b
179 changed files with 46209 additions and 0 deletions

View File

@@ -0,0 +1,329 @@
# Convergence Speed Prediction Model
**Purpose**: Predict iteration count before starting experiment
**Accuracy**: 85% (±1 iteration) across 13 experiments
---
## Formula
```
Predicted_Iterations = Base(4) + Σ penalties
Penalties:
1. V_meta(s₀) < 0.40: +2
2. Domain scope fuzzy: +1
3. Multi-context validation: +2
4. Specialization needed: +1
5. Automation unclear: +1
```
**Range**: 4-11 iterations (min 4, max 4+2+1+2+1+1=11)
---
## Penalty Definitions
### Penalty 1: Low Baseline (+2 iterations)
**Condition**: V_meta(s₀) < 0.40
**Rationale**: More gap to close (0.40+ needed to reach 0.80)
**Check**:
```bash
# Calculate V_meta(s₀) from iteration 0
completeness=$(calculate_initial_coverage)
transferability=$(calculate_borrowed_patterns)
automation=$(calculate_identified_tools)
v_meta=$(echo "0.4*$completeness + 0.3*$transferability + 0.3*$automation" | bc)
if (( $(echo "$v_meta < 0.40" | bc -l) )); then
penalty=2
fi
```
---
### Penalty 2: Fuzzy Scope (+1 iteration)
**Condition**: Cannot describe domain in <3 clear sentences
**Rationale**: Requires scoping work, adds exploration
**Check**:
- Write domain definition
- Count sentences
- Ask: Are boundaries clear?
**Example**:
```
✅ Clear: "Error detection, diagnosis, recovery, prevention for meta-cc"
❌ Fuzzy: "Improve testing" (which tests? what aspects? how much?)
```
---
### Penalty 3: Multi-Context Validation (+2 iterations)
**Condition**: Requires testing across multiple projects/languages
**Rationale**: Deployment + validation overhead
**Check**:
- Is retrospective validation possible? (NO penalty)
- Single-context sufficient? (NO penalty)
- Need 2+ contexts? (+2 penalty)
---
### Penalty 4: Specialization Needed (+1 iteration)
**Condition**: Generic agents insufficient, need specialized agents
**Rationale**: Agent design + testing adds iteration
**Check**:
- Can generic agents handle all tasks? (NO penalty)
- Need >10x speedup from specialist? (+1 penalty)
---
### Penalty 5: Automation Unclear (+1 iteration)
**Condition**: Top 3 automations not obvious by iteration 0
**Rationale**: Requires discovery phase
**Check**:
- Frequency analysis reveals clear candidates? (NO penalty)
- Need exploration to find automations? (+1 penalty)
---
## Worked Examples
### Example 1: Bootstrap-003 (Error Recovery)
**Assessment**:
```
Base: 4
1. V_meta(s₀) = 0.48 ≥ 0.40? YES → +0 ✅
2. Domain scope clear? YES ("Error detection, diagnosis...") → +0 ✅
3. Retrospective validation? YES (1,336 historical errors) → +0 ✅
4. Generic agents sufficient? YES → +0 ✅
5. Automation clear? YES (top 3 from frequency analysis) → +0 ✅
Predicted: 4 + 0 = 4 iterations
Actual: 3 iterations ✅ (within ±1)
```
**Analysis**: All criteria met → minimal penalties → rapid convergence
---
### Example 2: Bootstrap-002 (Test Strategy)
**Assessment**:
```
Base: 4
1. V_meta(s₀) = 0.04 < 0.40? NO → +2 ❌
2. Domain scope clear? NO (testing is broad) → +1 ❌
3. Multi-context validation? YES (3 archetypes) → +2 ❌
4. Specialization needed? YES (coverage-analyzer, test-gen) → +1 ❌
5. Automation clear? YES (coverage tools obvious) → +0 ✅
Predicted: 4 + 2 + 1 + 2 + 1 + 0 = 10 iterations
Actual: 6 iterations ✅ (model conservative)
```
**Analysis**: Model predicts upper bound. Efficient execution beat estimate.
---
### Example 3: Hypothetical CI/CD Optimization
**Assessment**:
```
Base: 4
1. V_meta(s₀) = ?
- Historical CI logs exist: YES
- Initial analysis: 5 pipeline patterns identified
- Estimated final: 7 patterns
- Completeness: 5/7 = 0.71
- Transferability: 0.40 (industry practices)
- Automation: 0.67 (2/3 tools identified)
- V_meta(s₀) = 0.4×0.71 + 0.3×0.40 + 0.3×0.67 = 0.49 ≥ 0.40 → +0 ✅
2. Domain scope: "Reduce CI/CD build time through caching, parallelization, optimization"
- Clear? YES → +0 ✅
3. Validation: Single CI pipeline (own project)
- Single-context? YES → +0 ✅
4. Specialization: Pipeline analysis can use generic bash/jq
- Sufficient? YES → +0 ✅
5. Automation: Top 3 = caching, parallelization, fast-fail
- Clear? YES → +0 ✅
Predicted: 4 + 0 = 4 iterations
Expected actual: 3-5 iterations (rapid convergence)
```
---
## Calibration Data
**13 Experiments, Actual vs Predicted**:
| Experiment | Predicted | Actual | Δ | Accurate? |
|------------|-----------|--------|---|-----------|
| Bootstrap-003 | 4 | 3 | -1 | ✅ |
| Bootstrap-007 | 4 | 5 | +1 | ✅ |
| Bootstrap-005 | 5 | 5 | 0 | ✅ |
| Bootstrap-002 | 10 | 6 | -4 | ⚠️ |
| Bootstrap-009 | 6 | 7 | +1 | ✅ |
| Bootstrap-011 | 7 | 6 | -1 | ✅ |
| ... | ... | ... | ... | ... |
**Accuracy**: 11/13 = 85% within ±1 iteration
**Model Bias**: Slightly conservative (over-predicts by avg 0.7 iterations)
---
## Usage Guide
### Step 1: Assess Domain (15 min)
**Tasks**:
1. Analyze available data
2. Research prior art
3. Identify automation candidates
4. Calculate V_meta(s₀)
**Output**: V_meta(s₀) value
---
### Step 2: Evaluate Penalties (10 min)
**Checklist**:
- [ ] V_meta(s₀) ≥ 0.40? (NO → +2)
- [ ] Domain <3 clear sentences? (NO → +1)
- [ ] Direct/retrospective validation? (NO → +2)
- [ ] Generic agents sufficient? (NO → +1)
- [ ] Top 3 automations clear? (NO → +1)
**Output**: Total penalty sum
---
### Step 3: Calculate Prediction
```
Predicted = 4 + penalty_sum
Examples:
- 0 penalties → 4 iterations (rapid)
- 2-3 penalties → 6-7 iterations (standard)
- 5+ penalties → 9-11 iterations (exploratory)
```
---
### Step 4: Plan Experiment
**Rapid (4-5 iterations predicted)**:
- Strong iteration 0: 3-5 hours
- Aggressive iteration 1: Fix all P1 issues
- Target: 10-15 hours total
**Standard (6-8 iterations predicted)**:
- Normal iteration 0: 1-2 hours
- Incremental improvements
- Target: 20-30 hours total
**Exploratory (9+ iterations predicted)**:
- Minimal iteration 0: <1 hour
- Discovery-driven
- Target: 30-50 hours total
---
## Prediction Confidence
**High Confidence** (0-2 penalties):
- Predicted ±1 iteration
- 90% accuracy
**Medium Confidence** (3-4 penalties):
- Predicted ±2 iterations
- 75% accuracy
**Low Confidence** (5+ penalties):
- Predicted ±3 iterations
- 60% accuracy
**Reason**: More penalties = more unknowns = higher variance
---
## Model Limitations
### 1. Assumes Competent Execution
**Model assumes**:
- Comprehensive iteration 0 (if V_meta(s₀) ≥ 0.40)
- Efficient iteration execution
- No major blockers
**Reality**: Execution quality varies
---
### 2. Conservative Bias
**Model tends to over-predict** (actual < predicted)
**Reason**: Penalties are additive, but some synergies exist
**Example**: Bootstrap-002 predicted 10, actual 6 (efficient work offset penalties)
---
### 3. Domain-Specific Factors
**Not captured**:
- Developer experience
- Tool ecosystem maturity
- Team collaboration
- Unforeseen blockers
**Recommendation**: Use as guideline, not guarantee
---
## Decision Support
### Use Prediction to Decide:
**4-5 iterations predicted**:
→ Invest in strong iteration 0 (rapid convergence worth it)
**6-8 iterations predicted**:
→ Standard approach (diminishing returns from heavy baseline)
**9+ iterations predicted**:
→ Exploratory mode (discovery-first, optimize later)
---
**Source**: BAIME Rapid Convergence Prediction Model
**Validation**: 13 experiments, 85% accuracy (±1 iteration)
**Usage**: Planning tool for experiment design