Critical Bug Fix: Synaptic Contribution Calculation
Date: November 4, 2025
Severity: 🔴 CRITICAL
Status: ✅ FIXED
Impact: Synaptic propagation and sensory injection
Bug Description
During Phase 2 refactoring, I introduced a critical behavioral change in synaptic contribution calculation that broke synaptic propagation.
Root Cause
Incorrect assumption: I assumed synaptic weights were normalized (0.0-1.0 range)
Actual behavior: FEAGI uses direct cast (0-65,025 range)
Impact
Before Fix (WRONG):
// feagi-synapse v1 (BROKEN)
let w = weight as f32 / 255.0; // 255 → 1.0 (NORMALIZED)
let c = conductance as f32 / 255.0; // 255 → 1.0 (NORMALIZED)
contribution = w * c * sign; // 1.0 × 1.0 = 1.0
After Fix (CORRECT):
// feagi-synapse v2 (FIXED)
let w = weight as f32; // 255 → 255.0 (DIRECT CAST)
let c = conductance as f32; // 255 → 255.0 (DIRECT CAST)
contribution = w * c * sign; // 255.0 × 255.0 = 65,025.0
Magnitude Difference: 65,025× smaller with bug!
Why This Broke Everything
Synaptic Propagation
- Synaptic contributions were 65,000× too weak
- Neurons never received enough input to fire
- Network appeared "dead"
Sensory Injection
- Same calculation used for sensory input
- Injected potentials 65,000× too weak
- Sensors had no effect on neurons
Fix Applied
File: feagi-core/crates/feagi-synapse/src/contribution.rs
Changed: Lines 56-58
// WRONG (introduced in Phase 2):
let w = weight as f32 / 255.0; // ❌ Normalization
let c = conductance as f32 / 255.0;
// CORRECT (matches original FEAGI):
let w = weight as f32; // ✅ Direct cast
let c = conductance as f32;
Tests Updated: Lines 120-142 (test expectations corrected)
Canonical Contract (Determinism Across Backends)
To keep FEAGI deterministic across CPU, WGPU, and CUDA backends, synaptic math must follow one canonical contract:
- weight: stored as
u8(0..255), treated as absolute units - postsynaptic potential (PSP / conductance): stored as
u8(0..255), treated as absolute units - contribution:
- (contribution = sign \times weight \times psp)
- Range per synapse: ([-65{,}025, +65{,}025])
- No implicit normalization (
/255.0) or scaling (*255.0) inside synaptic compute loops.- Conversions are allowed only at IO boundaries (genome/API/UI) and must be explicit.
Verification
Test Results
$ cargo test -p feagi-synapse --lib
running 11 tests
...........
test result: ok. 11 passed ✅
Integration Test
$ cargo test -p feagi-burst-engine test_synaptic --lib
running 1 test
test synaptic_propagation::tests::test_synaptic_propagation ... ok ✅
Build Status
$ cd feagi && cargo build --release
Finished `release` profile [optimized] target(s) in 1m 47s ✅
Lesson Learned
Always verify behavioral equivalence when refactoring:
- ✅ Check tests pass
- ✅ Check function signatures match
- ⚠️ Check actual numeric output (this was missed!)
Why tests didn't catch it:
- New tests in
feagi-synapsewere written with wrong assumptions - Integration tests don't verify exact magnitudes
- Need end-to-end validation with real connectomes
Action Items
- ✅ Fixed synaptic contribution formula
- ✅ Updated tests
- ✅ Updated documentation
- ✅ Rebuilt main application
- ⏳ User needs to retest
Status: Bug fixed and verified. Ready for testing again.