@@ -1123,42 +1123,57 @@ const char* fossil_jellyfish_reason(fossil_jellyfish_chain_t *chain, const char
11231123void fossil_jellyfish_decay_confidence (fossil_jellyfish_chain_t * chain , float decay_rate ) {
11241124 if (!chain || chain -> count == 0 || decay_rate <= 0.0f ) return ;
11251125
1126- // Per-type minimum confidence thresholds
1127- const float min_conf [5 ] = {
1128- 0.05f , // BASIC
1129- 0.10f , // IMAGINED
1130- 0.10f , // DERIVED
1126+ // Per-type confidence thresholds, matching block_type enum (0 to 10)
1127+ const float min_conf [11 ] = {
1128+ 0.05f , // UNKNOWN
1129+ 0.05f , // OBSERVED
1130+ 0.10f , // INFERRED
1131+ 0.15f , // VALIDATED
1132+ 0.10f , // CORRECTED
1133+ 0.10f , // ASSUMED
1134+ 0.05f , // RETRACTED
11311135 0.20f , // EXPERIMENTAL
1132- 0.02f // VERIFIED
1136+ 0.10f , // GUIDED
1137+ 0.20f , // IMMUTABLE
1138+ 0.02f // ARCHIVED
11331139 };
1134- const float max_conf [5 ] = {
1135- 1.0f , // BASIC
1136- 1.0f , // IMAGINED
1137- 1.0f , // DERIVED
1140+ const float max_conf [11 ] = {
1141+ 1.0f , // UNKNOWN
1142+ 1.0f , // OBSERVED
1143+ 1.0f , // INFERRED
1144+ 1.0f , // VALIDATED
1145+ 1.0f , // CORRECTED
1146+ 1.0f , // ASSUMED
1147+ 1.0f , // RETRACTED
11381148 1.0f , // EXPERIMENTAL
1139- 1.0f // VERIFIED
1149+ 1.0f , // GUIDED
1150+ 1.0f , // IMMUTABLE
1151+ 1.0f // ARCHIVED
11401152 };
11411153
1142- // Clamp half-life
11431154 double half_life_seconds = fmax (1.0 , (double )decay_rate );
11441155 time_t now = time (NULL );
11451156
11461157 for (size_t i = 0 ; i < chain -> count ; ++ i ) {
11471158 fossil_jellyfish_block_t * block = & chain -> memory [i ];
1159+
11481160 if (!block -> attributes .valid || block -> attributes .immutable ) continue ;
11491161
11501162 int t = block -> block_type ;
1151- if (t < 0 || t > 4 ) t = 0 ; // fallback to BASIC
1163+ if (t < 0 || t > 10 ) t = 0 ; // Clamp to UNKNOWN
11521164
11531165 time_t block_time = (time_t )(block -> time .timestamp / 1000 );
11541166 time_t age_seconds = now - block_time ;
11551167 if (age_seconds <= 0 ) continue ;
11561168
11571169 double decay_factor = pow (0.5 , (double )age_seconds / half_life_seconds );
11581170 block -> attributes .confidence *= (float )decay_factor ;
1159- block -> attributes .confidence = fmaxf (0.0f , fminf (block -> attributes .confidence , max_conf [t ]));
1171+
1172+ // Clamp confidence
11601173 if (block -> attributes .confidence < min_conf [t ]) {
11611174 block -> attributes .valid = 0 ;
1175+ } else if (block -> attributes .confidence > max_conf [t ]) {
1176+ block -> attributes .confidence = max_conf [t ];
11621177 }
11631178 }
11641179}
0 commit comments