[STF] exception_policy: an lvalue erased sink is viewed, not cloned, and an unhooked success passes unboxed #12000
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 210 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.320
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #12000"
general
weight: 0.35
caugonnet
Description
Stacked on #11967 (itself on #11889 and #11888; only the last commit here is new).
Behind
exception_sink(type_erase), every guard cost about 18 ns per call on the success path, ten times the typed sink, and none of it was the virtual dispatch that erasure asks for. Two causes in the shell, both invisible to users of the API:1. The sink was cloned on every call.
__normalizereturned every sink-tagged policy by value, so the erased sink handed toon_throwwas copied, andexception_sink's copy constructor clones the boxed policy: one heap allocation and one deallocation per guarded call, however the sink was passed. An lvalueexception_sinknow normalizes to a by-reference view (__erased_ref_t) that forwards the hook, the success channel and the entry gate. An rvalue is still moved in, so a sink built on every call keeps its one allocation, which is what building it costs.2. The result was boxed for a hook that did not exist. The callable's result was put into
std::any, passed through the virtualon_success(std::any)and unboxed with a type check, although the wrapped policy had no success hook.sink_basenow records at erasure time whether the policy has one (has_success_hook, conservativelytruefor hand-written models), and the shell returns the value unboxed when it does not.Behaviour is unchanged on every path. The remaining 2 to 3 ns over hand-written code is the virtual entry gate and the view.
Checklist
🤖 Generated with Claude Code