[200~add CreateResponseCapped conformance cases (#120) #127
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 371 lines diff across 4 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.354
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #127"
general
weight: 0.35
aaronbrethorst
Closes #120. Follow-up to #117.
Why
#117 made
CreateResponseCappedmandatory onsurveys.Repository, so an adapter without it won't compile. Butinternal/store/storetestonly calledCreateResponse, so nothing checked how the cap behaves. A future adapter (e.g. Postgres) could pass conformance and still enforce it wrong.What
New subtests in
RunSurveyRepository(internal/store/storetest/surveytest.go), using only thesurveys.Repositoryinterface:| Subtest | Pins |
|---|---|
|
CreateResponseCappedEnforcesPerRiderCap| A rider atmaxPerRidergetsErrTooManyResponsesand nothing is stored (the rejected public ID isErrNotFound; the rider's count stays at the cap). Another rider on the same survey, and the same rider on another survey, are unaffected. Responses written through plainCreateResponsecount toward the cap. The cap is 2, so "at the cap" isn't confused with "has any response". ||
CreateResponseCappedNonPositiveMeansNoCap| AmaxPerRiderof0or-1lets every create land. ||
CreateResponseCappedUnknownSurvey| An unknown survey isErrNotFoundwith and without a cap, not a raw FK error. ||
CreateResponseCappedConcurrentSameUser| Moved frominternal/store/sqlite/capped_test.go(deleted). WithmaxPerRider=1, exactly one of 8 concurrent creates from one rider succeeds. |Concurrency test: moved and strengthened
It only ever needed the
Repositoryinterface, so it now lives in the suite and any future adapter inherits it. The SQLite conformance run still goes through the productionOpen, so the_txlock=immediateDSN it relies on is unchanged.Mutation testing showed the single-round version was weak. With the cap counted before
BEGIN, the exact race it exists to catch, it failed in only 3 of 50 runs. It now runs 25 rounds, each with a fresh rider on the same survey, and fails in 50 of 50 runs under that mutation. The test takes about 0.2s.Mutation check
Each case was confirmed to fail against a deliberately broken SQLite adapter (source restored after each):
| Mutation | Caught by |
|---|---|
|
n > maxPerRider(off-by-one) | EnforcesPerRiderCap, ConcurrentSameUser ||
maxPerRider >= 0(0 treated as a cap) | NonPositiveMeansNoCap, EnforcesPerRiderCap ||
maxPerRider != 0(-1 treated as a cap) | NonPositiveMeansNoCap || count ignores
user_identifier| EnforcesPerRiderCap || count ignores
survey_id| EnforcesPerRiderCap, NonPositiveMeansNoCap || survey-existence check removed | UnknownSurvey |
| rejected create committed anyway | EnforcesPerRiderCap, ConcurrentSameUser |
| cap counted before
BEGIN| ConcurrentSameUser (50/50 runs) |Verification
make fmt-check vet lint(golangci-lint 2.12.2): 0 issuesmake test test-race web-check: passTestSurveyConformancewith-count=1underTZ=UTCandTZ=Asia/Kathmandu: passmake generate-checknot run locally (sqlc not installed); no.sqlorgen/files touched