Repository navigation
fix: no re-verification under the locks in policy mint and registration (TC-2986 F) - #596
Merged
Merged
Conversation
samgbafa
force-pushed
the
feat/tc-2986-mint-no-revalidation
branch
from
November 13, 2026 19:44
092db6a to
46c89c9
Compare
samgbafa
force-pushed
the
feat/tc-2986-verify-before-locks
branch
from
November 13, 2026 20:09
b626aa3 to
95ba3f8
Compare
samgbafa
force-pushed
the
feat/tc-2986-mint-no-revalidation
branch
from
November 13, 2026 20:09
46c89c9 to
710be12
Compare
samgbafa
force-pushed
the
feat/tc-2986-verify-before-locks
branch
from
November 13, 2026 22:11
95ba3f8 to
c109828
Compare
samgbafa
force-pushed
the
feat/tc-2986-mint-no-revalidation
branch
from
November 13, 2026 22:11
710be12 to
8a3558e
Compare
samgbafa
changed the base branch from
feat/tc-2986-verify-before-locks
to
main
November 13, 2026 22:39
samgbafa
force-pushed
the
feat/tc-2986-mint-no-revalidation
branch
from
November 13, 2026 23:05
8a3558e to
520cc64
Compare
samgbafa
marked this pull request as ready for review
November 13, 2026 23:06
This was referenced Nov 13, 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.
Linear: TC-2986 (item F; parent TC-2954). Stacked on #595 (E): it uses E's
PreVerified. Review the top commit; retarget tomainonce #595 merges.Behaviour
POST /policy/v3/delegations(mint) evaluates the request before BEGIN:authorize_roots→validate_persisted_root).Under the locks (sequence locks, then
FOR UPDATEon the challenge, registration and both roots), it used to run all of that again on the same caller JSON. Now:authorize_rootsverified, sovalidate_verified_persisted_rootchecks everything except the signature.now. The two "changed" refusals (credential-evaluation-changed,policy-evaluation-changed) could therefore never fire, and are removed.preverify_delegation) and passed as pre-verified, so the graph registration does not verify it under them.POST /policy/v3/policies(register):preverify_root. It enforces the same rules (UCAN, time window, signature) and the same refusal codes, with the signature checked by the core.Core:
PreVerifiedis public, withunion.SpaceDatabase::preverify_delegationanddelegate_batch_in_transaction_verified.delegate_batch_in_transactionkeeps its behaviour, verifying everything.Tests
New,
tinycloud-node-server/src/policy_v3/mint_locked_inputs_tests.rs(SQLite and PostgreSQL). Each test holds the content space's write order, sends a mint, changes one input of the dropped in-lock evaluations once the mint waits, then releases the order:a_challenge_changed_while_the_mint_waits_is_refused: the challenge's expiry moves later. The checks before the locks accept it, so only the comparison under the locks refuses the mint: 401challenge-invalid, no session stored.a_registration_changed_while_the_mint_waits_is_refused: the attested enforcer binding is rewritten as the same JSON with other whitespace. That's still valid, but the bytes changed: 409policy-registration-changed, no session stored.a_root_revoked_while_the_mint_waits_is_refused: the policy root is revoked after its signature and state were checked, before BEGIN: 403root-revoked, no session stored.a_registration_repointed_while_the_mint_waits_is_refused(from Bobbie's review, M2a): the registration's policy root CID is repointed at another live registered root: 409policy-registration-changed. This covers a gap that predates this PR.root_bytes_replaced_while_the_mint_waits_are_refused(from Bobbie's review, M2b): the root row's bytes are replaced by the same root with a forged signature: 403policy-root-projection-mismatch. With the signature no longer re-checked under the locks, the binding of the stored bytes to the registration's root CID is what refuses them. Without that binding, the existing suite stays green and the forged root is admitted.The core side of the CID binding (a
PreVerifiedfor one delegation doesn't cover another, M4b) is tested in #595:a_pre_verified_delegation_does_not_cover_another.In the first two, a change that landed before the mint's checks would let the mint succeed and fail the test, so they can't pass by timing.
There's no test for the CPU saved under the locks: the node has no seam to observe it without a test-only hook.
register_policy_writesstays as a test-only wrapper that verifies everything.