fix(api): refuse writes whose namespace was released while they waited #380
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 · 394 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.358
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #380"
general
weight: 0.35
yordis
Summary
A write authorizes against the namespace registry before it takes the mutation lock. A branch deletion can release a provisional namespace row in that gap. The write then lands an entity in a namespace that has no row, and the next writer of any owner claims that namespace and its entity.
Example: owner
acmewritesacme-orderson branch@acme:draft, which claims a provisional row. Next,acmestarts a baselinePutEntityintoacme-orders, and the authorization passes. Before the write gets the lock,DeleteBranch @acme:draftreleases the row, because baseline is still empty. Before this change, the write then landed with no row.Change
require_targets_still_registered. It reads the registry under the mutation lock and returnsFAILED_PRECONDITIONwith a retry message when a target row is gone.PutEntity,BatchMutate,RevertChangesetandResolveBranchEntrycall it first after they take the lock.MergeBranch, source runs and artifact uploads already authorize under the lock, so they do not change.DeleteNamespace(#377) relies on this check, because it removes rows under the same lock.Tests
tests/namespace_release_race.rspauses a baseline write after its authorization, deletes the branch, and then expectsFAILED_PRECONDITIONand no stored entity. It fails onmain.namespace_ownership,handler_tests,branching,changesets,branch_namespace_tenure,namespace_scope,dry_run_side_effects,authorization_freshness,message_claims_acceptanceandartifact_namespace_authoritypass. fmt and clippy-D warningspass.<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->