Delimit strings in attribute hashing #9508
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9508"
general
weight: 0.35
pellared
Strings were written into the attribute digest without a length, so neighbouring strings had no boundary between them. Different attribute sets could produce the same
Distinct.For example
[]string{"ab", "c"}and[]string{"a", "bc"}hash to the same value, and so do{a="x", bc=1}and{a="xb", c=1}. Insdk/metricthat means measurements with those attributes are aggregated into a single stream.This prefixes every hashed string (keys, string values, string slice elements, byte slices and map keys) with its length, and every slice and map with its element count, so nested collections have a boundary too.
TestHashStringBoundariesandTestHashCollectionBoundariesfail on main and pass with the change. Hash values are not persisted anywhere, so changing them is safe.I ran
go test -racefor the root module,sdkandsdk/metric, and golangci-lint on the root module. The extra framing costs hashing time but no allocations. On my laptop (Apple M1, 10 interleaved runs of main and this branch,-benchtime=300ms) the hash benchmarks are about 8 to 15 ns slower per hashed value, around 40% on the geomean, andNewSetgoes from about 282 ns to 349 ns. Allocations are unchanged everywhere (0 for hashing, 1 forNewSet). The machine was not idle, so the spread is wide; a second run gave the same picture with a +46% geomean.<details>
<summary>benchstat, sec/op</summary>
</details>