feat(guardian): epoch CAS on guardian binding writes - #796
Open
WiktorStarczewski wants to merge 1 commit into
Open
feat(guardian): epoch CAS on guardian binding writes#796WiktorStarczewski wants to merge 1 commit into
WiktorStarczewski wants to merge 1 commit into
Conversation
…ion-vs-repair race
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Guardian binding writes (endpoint + commitment baseline) are now guarded by a per-account
guardianEpochcompare-and-swap, closing the last-write-wins race the #786 review verified and deferred as its top residual risk (F-220): a drift repair that snapshots the account, spends minutes in HTTP probes, then writes could land after a rotation and resurrect the dead operator's endpoint with an in-sync status.Vault.updateGuardianBinding(pk, expectedEpoch | 'force', patch)— the one binding write path; a mismatched epoch returnsstalewith no write, an applied patch bumps the epoch, and endpoint + baseline land in oneencryptAndSaveMany(the torn endpoint-then-baseline sequences and their hand-maintained ordering comments are gone).resolveGuardianDriftandbackfillGuardianEndpointscarry their snapshot's epoch; astaleoutcome discards the repair whole and releases the probe cooldown so the next tick re-derives from fresh state (the rounds-17–20 "fix creates the next wedge" guard — a losing repair cannot re-arm its own delay).applyUserGuardianEndpointgains a fifth outcome,'stale': the URL verified against a commitment that changed mid-verification asks for one retry instead of binding stale evidence; newguardianUrlStaleRetrycopy in all 14 locales.guardianSyncStatus) stay last-write-wins on purpose: advisory, self-correcting, and gating them risks healthy loops starving each other. Only binding writes carry the CAS.Test coverage
stale, endpoint intact); status writes neither consume nor bump the epoch.applyUserGuardianEndpointreturns'stale'with no status write.Part 2 of 4 of the seam plan from #786's review. Stacked on #795 (Seam A).
Reviewers: the force-vs-CAS split is the part worth your time — completion and user-typed applies go through force-with-bump wrappers, snapshot-based repairs through the CAS; a writer on the wrong side of that line either can lose a rotation or can resurrect one.