symfonic.agent.middleware.confidence¶
confidence ¶
Deterministic confidence heuristic and sensitive-tag detection.
Pure functions — no side effects, no I/O, fully unit-testable.
compute_confidence ¶
Deterministic heuristic in [0.0, 1.0]. Returns 0.5 on empty input.
Formula
confidence = clamp01( 0.4 * seed_strength + 0.3 * path_coverage + 0.3 * edge_weight_factor )
Where
seed_strength = avg score of activated_nodes (>= 1.0 if seeded) path_coverage = min(1.0, len(inference_paths) / 3) edge_weight_factor = avg edge weight of traversed_edges / 5.0, capped at 1.0
Public so tests can exercise edge cases without spinning up a full agent.
Source code in src/symfonic/agent/middleware/confidence.py
detect_sensitive_hit ¶
detect_sensitive_hit(
activation_log: dict[str, Any],
sensitive_tags: frozenset[str],
) -> str | None
Return the first matching tag when any activated_node carries one of sensitive_tags in properties['tags'], else None.