.cursor/skills/formula-replacement-protocol/SKILL.md
Enforces the 5-step formula replacement protocol for replacing hardcoded scoring formulas with learned energy functions. Use when working on any formula in the Phase 4.2 replacement schedule, implementing A/B tests, or transitioning from formula to energy function scoring.
npx skillsauth add avra-cadavra/avrai formula-replacement-protocolInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Every hardcoded formula is replaced following the same 5-step protocol. No exceptions. No shortcuts. The protocol protects users from bad model transitions and provides rollback safety.
See docs/MASTER_PLAN.md Phase 4.2 for the complete prioritized list. Key ones:
| Priority | Service | Formula | Current Weights |
|----------|---------|---------|-----------------|
| 4.2.1 | CallingScoreCalculator | Calling Score | 40/30/15/10/5 |
| 4.2.2 | VibeCompatibilityService | Combined compatibility | 50/30/20 |
| 4.2.5 | GroupMatchingService | Group core + modifiers | geometric mean + 40/30/20/10 |
| 4.2.9 | BusinessExpertMatchingService | Expert matching | 50/30/20 |
| 4.2.12 | DiscoveryManager | AI2AI discovery priority | 40/30/20/10 |
/// Run BOTH, log comparison, keep formula as primary
Future<double> score(User user, Entity entity) async {
final formulaScore = _existingFormula(user, entity);
// Energy function runs in parallel but doesn't affect output
final energyScore = await _energyFunction.energy(
await _stateEncoder.encode(user),
await _actionEncoder.encode(entity),
);
// Log for comparison analysis
_comparisonLogger.log(
formula: formulaScore,
energy: energyScore,
userId: user.agentId,
entityId: entity.id,
timestamp: _atomicClock.now(),
);
return formulaScore; // Formula still primary
}
FormulaABTestingService to track both paths/// Feature flag controls the switch
Future<double> score(User user, Entity entity) async {
if (_featureFlags.isEnabled('energy_${_formulaName}')) {
return await _energyFunction.energy(userEmbed, actionEmbed);
}
return _existingFormula(user, entity);
}
/// If outcomes worsen for a specific user, revert them
void monitorTransition(String userId, List<Outcome> recentOutcomes) {
final preFlipAvg = _getPreFlipOutcomeAverage(userId);
final postFlipAvg = _average(recentOutcomes);
if (postFlipAvg < preFlipAvg * 0.8) { // 20% worse
developer.log('Rolling back $userId', name: 'FormulaTransition');
_userOverrides[userId] = FormulaOverride.useFormula;
}
}
During Step 1-2 (blending period):
/// Blend formula and energy scores during transition
final blendedScore = alpha * formulaScore + (1 - alpha) * energyScore;
// alpha starts at 1.0, decreases to 0.0 over transition period
Show "Personalized for you" badge once energy function has sufficient data.
FormulaABTestingService configured, collecting dataFeatureFlagServicedocs/MASTER_PLAN.md Phase 4.2 (Formula Replacement Schedule)docs/MASTER_PLAN.md Phase 4.5 (Transition Period UX)lib/core/services/calling_score_calculator.dart - First formula to replacelib/core/services/calling_score_ab_testing_service.dart - A/B testing templatelib/core/services/calling_score_data_collector.dart - Data collection templatedevelopment
--- name: world-model-development description: Guides world model development patterns: state/action encoders, ONNX inference, feature extraction pipeline, latency budgets. Use when implementing world model components, state encoders, action encoders, feature extractors, or ONNX models. Core skill for Phases 3-6. --- # World Model Development Patterns ## Core Principle All world model components follow LeCun's autonomous machine intelligence framework. State observations flow through a percep
tools
Implements base workflow controller patterns for multi-step processes. Use when creating complex workflows that require orchestration of multiple steps with error handling and rollback.
testing
--- name: widget-test-patterns description: Guides widget test patterns: BLoC testing, user interactions, state changes, material app setup. Use when writing widget tests, testing UI components, or validating widget behavior. --- # Widget Test Patterns ## Core Pattern Widget tests verify UI behavior: user interactions, state changes, and visual display. ## Basic Widget Test Setup ```dart testWidgets('widget displays correctly', (WidgetTester tester) async { // Arrange: Create widget awa
testing
--- name: test-template-generation description: Generates test templates: unit, widget, integration, service tests following project patterns. Use when creating new tests or ensuring tests follow project standards. --- # Test Template Generation ## Available Templates Test templates are located in `test/templates/`: - `unit_test_template.dart` - `widget_test_template.dart` - `integration_test_template.dart` - `service_test_template.dart` ## Unit Test Template ```dart /// SPOTS Component Uni