Repository navigation
ateapi: merge store.OptionalPrecondition into store.Precondition - #4004
Merged
Scott Funkenhauser (sfunkenhauser) merged 4 commits intoNov 20, 2026
Merged
Scott Funkenhauser (sfunkenhauser) merged 4 commits into
Scott Funkenhauser (sfunkenhauser) merged 4 commits into
Conversation
haiyanmeng
requested review from
Julian Gutierrez Oschmann (juli4n),
Luiz Oliveira (laoj2) and
Scott Funkenhauser (sfunkenhauser)
and removed request for
Julian Gutierrez Oschmann (juli4n)
November 19, 2026 20:21
haiyanmeng
force-pushed
the
single-precondition
branch
from
November 19, 2026 23:45
a220975 to
8fd9535
Compare
haiyanmeng
force-pushed
the
single-precondition
branch
from
November 20, 2026 17:02
abb01de to
be4be11
Compare
The two types had the same uid and version fields and differed only in whether a zero field is an error or a skipped check. Keep one Precondition and let the store method pick the rule: CheckRequired for updates, which rejects an unset guard with ErrPreconditionRequired, and CheckOptional for deletes and marks for deletion. Update methods still call Validate before any database work. The shared update helpers now check updates with CheckRequired instead of the optional check, so the rule holds where the guards are compared. Store behavior is unchanged. Signed-off-by: Haiyan Meng <[email protected]>
CheckRequired compares the guards itself instead of calling CheckOptional. The doc comments now say which errors each check returns, and the update helpers say when the guards are optional. Signed-off-by: Haiyan Meng <[email protected]>
Every store method that requires both guards already calls ValidateRequired before it reads the row. After that call, CheckRequired and CheckOptional return the same result, so keep one Check that skips an unset guard. The update helpers no longer take an optionalGuards flag. Each Update, Delete and MarkForDeletion method in store.Interface now says whether its precondition guards are required or optional. Add tests that BindActorToWorker, UpdateActorAndRelease and UpdateAtespaceAccessPolicy return ErrPreconditionRequired when a guard is unset. These were the only required methods without one. Signed-off-by: Haiyan Meng <[email protected]>
Drop the comment in updateActor and updateActorTemplate that repeated the Check doc comment. TestPreconditionCheck now covers a stale uid alone and a matching version alone. Signed-off-by: Haiyan Meng <[email protected]>
haiyanmeng
force-pushed
the
single-precondition
branch
from
November 20, 2026 17:51
32e2524 to
1618a51
Compare
Julian Gutierrez Oschmann (juli4n)
approved these changes
Nov 20, 2026
Scott Funkenhauser (sfunkenhauser)
approved these changes
Nov 20, 2026
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.
store.OptionalPreconditionandstore.Preconditionhave the same uid and version fields. They differ only in whether an unset guard is an error or a skipped check. This keeps onePrecondition.Checkskips unset guards. Update methods callValidateRequiredfirst, so they still require both guards. Deletes and marks for deletion call onlyCheck. Store behavior is unchanged.This reverses the separate optional type, which #3989 renamed from
DeletePreconditions. Custom methods such asSuspendActor(#1773) can callCheckwithoutValidateRequired. The trade-off is that the compiler no longer catches optional guards passed to an update method. That mistake now fails at runtime withErrPreconditionRequired.Addresses #1773
AI use: I used Claude Code to review the diff and draft the commit message and this description. I reviewed both.