control-plane: centralize spec-fetch authorization as Snapshot::spec_fetch_authorization (5/7) - #3349
Open
bbartman wants to merge 1 commit into
Open
Conversation
…fetch_authorization The spec-fetch policy shared by get_live_specs and evolutions-style named fetches is centralized as Snapshot::spec_fetch_authorization so enforcement points cannot drift: staleness anchors on the operation's durable queued instant when the caller has one, and otherwise on the spec's own last publication. Authoritative denials drop the spec (pre-existing behavior); provisional denials surface as the retryable AuthorizationSnapshotStale error. The connected-spec expansion path deliberately does NOT adopt this policy: expansion widens validation with specs the caller never named, so a denial there remains a final omission with an unanchored check. Per-module test Snapshot helpers consolidate into a shared test_support module, and the dead ExpandedRow struct is removed from db_complete.
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.
Description:
Part 5 of the snapshot-authorization stack (follows #3344). Decomposed from #3300, which this PR and its two successors replace.
Centralizes the policy for authorizing fetches of explicitly-named live specs as
Snapshot::spec_fetch_authorization, so the enforcement points cannot drift:started_at) when the caller has one, and otherwise on the spec's own last publication time, which bounds the window in which grants could have been committed alongside the spec.AuthorizationSnapshotStaleerror instead of a silent omission.get_live_specsnow routes through this shared policy.The connected-spec expansion path (
get_connected_live_specs) deliberately does not adopt the anchored policy: expansion widens validation with specs the caller never named, so a denial there remains a final omission with an unanchored check. The worst case of a not-yet-observed grant is only a narrower validation, while an anchored check would defer nearly every publication touching a connected spec its user can't edit. This is documented in a code comment at the call site.Also in this PR:
Snapshothelpers consolidate into a shared#[cfg(test)] test_supportmodule (used bylive_specsandpublications::specstests).ExpandedRowstruct is removed frompublications/db_complete.rs.Verified locally:
cargo nextest run -p control-plane-api -p agent— 292/292 passing at this branch tip.Workflow steps:
No user-facing workflow change: authorization outcomes for named-spec fetches are unchanged except that a denial under a provably-stale snapshot is now retried rather than silently omitting the spec.
Documentation links affected:
None.
Notes for reviewers:
spec_fetch_authorizationincrates/control-plane-api/src/server/snapshot.rs— the anchor-selection rule (startedvs.last_pub_id.timestamp()) is the heart of the change.crates/control-plane-api/src/live_specs/mod.rs: the named-fetch path adopts the policy; the expansion path intentionally diverges, with the rationale in the comment. Confirm you agree with the omission-vs-stale split.publications/specs.rsis mostly test migration onto the sharedtest_supporthelpers plus staleness-assertion coverage;test_support.rsis new test-only code.