feat: functional/expression indexes via override_expression #153
All Vouch review confidence checks passed
Residual risk 0.40 = Change Risk (0.66) × (1 − Review Confidence (0.38)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.66 · 162 lines diff across 10 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.305
No Reviewer Assigned
no_reviewer_assigned
0.120
Real PR Conversation Timeline
1 comments
"Review active on #153"
general
weight: 0.35
arreyder
What & why
Adds an
override_expressionfield to thepgdb.v1.MessageOptions.Indexoption so proto authors can declare functional/expression indexes — e.g. a btree over a JSONB path. Today the only way to index a value derived from a JSONB/proto-map field is to denormalize it into a real column (proto field + write-path + backfill migration + Dynamo re-mirror). This exposes a capability the DDL layer already has.Motivating case:
SearchUserOwnershipfilters(role_to_entitlement_id ->> 'primary') IN (...)with no serving index (the only index on that column is GIN/containment). With this, the fix is one index declaration:How
index2sqlalready rendersIndex.OverrideExpressionverbatim (HNSW vector indexes use it). This just threads the new proto field throughextraIndexesinto that existing path. When set,columnsis ignored for DDL (matching the vector precedent);partial_deleted_at_is_nullstill applies.OverrideExpressionunescaped ("{{ .DB.OverrideExpression }}"). Any expression containing a quoted identifier produced invalid Go (missing ',' in composite literal). Now emitted via%q. Vector overrides never tripped this (no quotes); expression indexes do.Author contract
The override body is emitted verbatim, so it carries physical column tokens: proto fields are
pb$-prefixed and quoted, system columns are bare — same convention the vector overrides already use.Validation
TestIndexOverrideExpression) asserts the renderedCREATE INDEX(verbatim body + preserved partial predicate).TestSchemaPetnow exercises the newPetfunctional index against a real Postgres.Index Scan).Diff shape
Core change is ~16 lines (proto field + one passthrough + template escape). The rest is regenerated
.pb.go/ example output.🤖 Generated with Claude Code