feat: add cheap Message.PKSK() key helper #145
All Vouch review confidence checks passed
Residual risk 0.43 = Change Risk (0.67) × (1 − Review Confidence (0.35)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.67 · 410 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 88% · Reviewer familiarity: 10%
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.360
Shallow Review Depth
shallow_review_depth
0.344
No Reviewer Assigned
no_reviewer_assigned
0.120
Rapid Merge
rapid_merge
0.100
Real PR Conversation Timeline
1 comments
"Review active on #145"
general
weight: 0.35
loganintech
Motivation
Messageonly exposed the fullRecord()for pulling a row's primary key.Record()marshals the proto and builds every column — FTS vectors, search data, pb_data — which is far more work than a caller who just wants thepb$pkskvalue needs.Because there was no cheap key accessor, consumers reached for the Dynamo
PartitionKey()/SortKey()methods instead. That's both a layering violation (Postgres code depending on the Dynamo generator) and wrong for sharded objects: the Dynamo partition key embeds a shard id (…:<tenant>:<shard>) that Postgres does not store (Postgres keeps…:<tenant>), soPartitionKey()|SortKey()never matches thepb$pkskcolumn for a sharded row.Change
Add a generated
PKSK() stringmethod that builds"pb$pk|pb$sk"directly from the key fields:proto.Marshal, no FTS/search computation.Record()uses, so it always equalsRecord()["pb$pk"] + "|" + Record()["pb$sk"]— which is exactly what thepb$pkskgenerated column (pb$pk || '|' || pb$sk) evaluates to. Correct for composite keys,sk_const, and partitioned tables.Record()), so the signature is a plainstring.Nested-only messages don't get it
Rather than live on the
Messageinterface,PKSK()lives on a new optional interface:Nested-only messages are stored inline (JSONB in a parent row) and have no primary key, so the method simply isn't generated for them — they don't implement
PrimaryKeyer. This avoids emitting a uselessPKSK() string { return "" }on every nested-only type. Consumers type-assertMessage→PrimaryKeyerbefore calling.Implementation
pgdb/v1/message.go— newPrimaryKeyeroptional interface (not onMessage).internal/pgdb/pgdb_message.go— surface thepk/skfield contexts to the template (findFieldByDBName).internal/pgdb/templates/message.tmpl— emit the method only when the message has a primary key.*.pb.pgdb.go.example/models/food/v1/pksk_test.go— assertsPKSK() == Record pb$pk|pb$skacross key shapes and both dialects, and that nested-only messages do not implementPrimaryKeyer.Compatibility
PKSK()is additive and on a separate optional interface, so existingMessageimplementers are unaffected. Downstream (c1) will bump this dependency, re-run codegen, and switch itsxpgdb.PKSKhelper to type-assertPrimaryKeyerand callPKSK().🤖 Generated with Claude Code