Proposal: Attributes builder #84
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 356 lines diff across 4 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.352
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #84"
general
weight: 0.35
inge4pres
This is an experiment where I tried to go as far as possible with
comptimesyntactic sugar for building attributes lists, and I am looking for feedback on what is useful and what is too much.0. Current state
Before this PR, attributes list can be built manually, with both arbitrary strings as keys and using semconv:
Note that, in the case of semconv keys, there is nothing in place enforcing that the right type of value is used, and one can mistakenly set the request method to
123or"foo"without the compiler catching it.Also note how certain keys are
[...].namewhile others are[...].base.name1.
sdk.attributes.fromPairsThis builder tries to have the same capabilities, but with sugar to reduce the verbosity:
In this case, it is possible to check the type of the value against the expected type the key declares.
It is NOT done today because the semconv module currently only declares
StringAttributesandEnumAttributes(meaningserver_portis currently declared as expecting string) (tracked in #99). But once that gap is addressed we can add the type checks.2.
sdk.attributes.flattenIts main use is for the structured log body (
emitStructured), but it is also usable to build attributes lists by hand.It takes an anonymous struct and evaluates as a list of Attributes, just like above:
It will NOT store & transmit attributes as nested struct (technically allowed by the spec), but instead collapse keys by joining section names with
.:"checkout.cart.items","checkout.cart.currency"and"checkout.coupon.applied"It is done at
comptimeso all resulting strings are static, no allocation is introduced.Moreover static arrays are concatenable, so
fromPairsandflattencan easily be combined into a single attributes list using++.--------
This PR description was written by hand. The code changes were made with the assistance of an LLM.