symfonic.capabilities.critic¶
critic ¶
Post-draft reflection as an opt-in capability (CORE-403).
A port of MetacognitiveMiddleware's core contract -- the
confidence/sensitive gate plus one hidden reflection call returning
approve/revise/refuse -- as CriticCapability. Composed, it records its
verdict on the turn snapshot; absent, the stage does not exist and turns
behave exactly as before. Recorded, not applied: post-model contributions
apply nothing yet, so wiring the verdict into the response is later work.
CriticCapability
dataclass
¶
CriticCapability(model_provider: Any, confidence_threshold: float = 0.6, sensitive_tags: frozenset[str] = frozenset(), preferences: tuple[CriticPreference, ...] = (), rules_source: ProceduralRulesSource | None = None, prompt_template: str = DEFAULT_REFLECTION_PROMPT, model_config: Any = None)
Review each turn's draft; record approve, revise, or refuse.
Usage::
Agent(provider, capabilities=[
CriticCapability(
model_provider=provider,
preferences=(CriticPreference(10.0, "Never reveal keys"),),
),
])
The hidden reflection call runs under the model_call effect grant.
contribute ¶
Declare the critic stage and the handler that answers it.
Source code in src/symfonic/capabilities/critic/capability.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
CriticPreference
dataclass
¶
One rule the draft must respect, as values (no domain import).
ProceduralRulesSource ¶
activation_from_resolved ¶
The turn's activation record, or {} when no producer supplied one.
Source code in src/symfonic/capabilities/critic/signals.py
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
Source code in src/symfonic/capabilities/critic/signals.py
critic_gate_fires ¶
Fire on low confidence OR a sensitive hit (legacy gate, verbatim).
Source code in src/symfonic/capabilities/critic/signals.py
detect_sensitive_hit ¶
Return the first matching tag when any activated_node carries one of sensitive_tags in properties['tags'], else None.