Repository navigation
fix(hub): check a document changed during approval on the hub's clock - #185
Closed
TheGreatAxios wants to merge 2 commits into
Closed
TheGreatAxios wants to merge 2 commits into
TheGreatAxios wants to merge 2 commits into
Conversation
Contributor
Author
|
Closing for now while today's merges are stabilised. |
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.
The check that refuses an approval when a document changed while the person was deciding compared the version's write time, stamped by the hub, with the approval's creation time, stamped by the database. When the two clocks disagreed, an approval of an unchanged document could be refused, and a document revised during the approval could be accepted. The hub now reads how long ago the approval was asked on the database's clock and subtracts that from the hub's time read just before the transaction, so both sides of the comparison are on the hub's clock and any doubt errs toward refusing.
A new end-to-end test,
test/e2e/approval-clock.test.ts, callsrecordApprovalin-process against an isolated Postgres with the hub's clock set five minutes ahead of and behind the database's. With each skew it checks that a document written before the ask is approved, that a document revised after the ask is refused withartifact_changed_during_approval, and that an approval already recorded records nothing more. The hub exports its artifact service for this test, and the e2e harness shares its database setup throughcreateTestDatabase.Lint, format check, typecheck,
bun run test(289 pass), pins:verify, vendor:verify and the full end-to-end suite (15 pass) pass. Against the service on main, three tests failed in each of three runs: approval of an unchanged document with the hub ahead, the already-recorded case with the hub ahead, and the refusal with the hub behind. With the sign of the clock correction flipped, both refusal tests failed in each of three runs.Closes CL-12141