@@ -904,42 +904,54 @@ int fossil_jellyfish_audit(const fossil_jellyfish_chain_t *chain) {
904904 return issues ;
905905}
906906
907- int fossil_jellyfish_prune (fossil_jellyfish_chain_t * chain , float * min_conf ) {
908- if (!chain || chain -> count == 0 || !min_conf )
909- return 0 ;
910-
907+ int fossil_jellyfish_prune (fossil_jellyfish_chain_t * chain , float min_confidence ) {
908+ if (!chain || chain -> count == 0 ) return 0 ;
911909 int pruned = 0 ;
912- int i = 0 ;
913910
914- while (i < chain -> count ) {
911+ // Per-type minimum confidence thresholds (tunable)
912+ static const float min_conf [11 ] = {
913+ 0.0f , // UNKNOWN
914+ 0.0f , // OBSERVED
915+ 0.05f , // INFERRED
916+ 0.10f , // VALIDATED
917+ 0.05f , // CORRECTED
918+ 0.05f , // ASSUMED
919+ 0.0f , // RETRACTED
920+ 0.10f , // EXPERIMENTAL
921+ 0.05f , // GUIDED
922+ 0.20f , // IMMUTABLE (rarely pruned)
923+ -0.03f // ARCHIVED (slightly lower allowed)
924+ };
925+
926+ for (size_t i = 0 ; i < chain -> count ; ) {
915927 fossil_jellyfish_block_t * block = & chain -> memory [i ];
916- int t = block -> type ;
928+ int t = ( block -> block_type >= 0 && block -> block_type <= 10 ) ? block -> block_type : 0 ;
917929
918- // 1. Skip immutable blocks entirely
930+ // Absolute keep rule: immutable blocks never pruned
919931 if (block -> attributes .immutable ) {
920932 i ++ ;
921933 continue ;
922934 }
923935
924- // 2. If the block is invalid OR below confidence → prune it
925- if (!block -> attributes .valid || block -> attributes .confidence < min_conf [t ]) {
936+ // Compute threshold for this block type
937+ float threshold = min_confidence + min_conf [t ];
938+
939+ // If below confidence or already invalid, prune
940+ if (!block -> attributes .valid || block -> attributes .confidence < threshold ) {
926941 block -> attributes .pruned = 1 ;
927942 block -> attributes .valid = 0 ;
928-
929- // Shift memory down to overwrite the pruned block
943+ // Shift remaining blocks down
930944 if (i < chain -> count - 1 ) {
931945 memmove (& chain -> memory [i ],
932946 & chain -> memory [i + 1 ],
933947 sizeof (fossil_jellyfish_block_t ) * (chain -> count - i - 1 ));
934948 }
935-
936949 chain -> count -- ;
937950 pruned ++ ;
938- // Note: do NOT increment i here, because we need to check the new block at position i
939- } else {
940- // Keep the block → move to the next
941- i ++ ;
951+ continue ; // stay at same index after shift
942952 }
953+
954+ i ++ ;
943955 }
944956
945957 return pruned ;
0 commit comments