agent: publications executor defers on stale authorization snapshots (3/7) - #3343
Open
bbartman wants to merge 2 commits into
Open
agent: publications executor defers on stale authorization snapshots (3/7)#3343bbartman wants to merge 2 commits into
bbartman wants to merge 2 commits into
Conversation
This was referenced Aug 11, 2026
Open
The publications executor stops failing publications whose authorization was denied under a stale Snapshot, and instead defers them until an authoritative Snapshot can decide: - Staleness is anchored to the queued publication row (started_at = row.updated_at) rather than each spec's last_pub_id, correctly handling the common shape of an old spec whose authorization changed just before the publication was queued. - On AuthorizationSnapshotStale the executor records awaiting_snapshot_after in the task's persisted PublicationState (activating the state carried for deploy compatibility), cancels the Snapshot's revoke token to request an early background refresh, and reschedules with STALE_RETRY_WAKE. Re-polls defer cheaply — without loading or building the draft — until the local Snapshot postdates the anchor, including on another agent instance. - Harness: observed/unobserved grant helpers, authoritative/stale Snapshot stamping, age_live_spec, and queue_publication / poll_publication_once for tests that drive individual polls. Also adds the specs.rs staleness-anchoring tests (data-plane and storage-mapping freshness, request-relative anchoring, grant attenuation via the new attenuated_grants fixture) which exercise resolve_live_specs behavior that this deferral makes reachable end to end. Split 3 of 4 from #3155.
bbartman
force-pushed
the
bmb/2781-stack-3-publications-staleness
branch
from
August 11, 2026 18:23
b6388d1 to
e0b475d
Compare
…-publications-staleness
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.
What
Split 3 of 4 of #3155 (issue #2781): the publications executor stops failing
publications whose authorization was denied under a stale Snapshot, and
instead defers them until an authoritative Snapshot can decide.
started_at: Some(row.updated_at)— the instant the publication enteredqueued— so a denial is provisional exactly when the Snapshot predatesthe request. Previously (split 2) the anchor was each spec's own
last_pub_id, which misclassifies the common shape of an old spec whoseauthorization changed now.
AuthorizationSnapshotStalethe executor recordsawaiting_snapshot_afterin the task's persistedPublicationState(activating the state carried since the prior deploy-compat change),
cancels the Snapshot's
revoketoken to request an early backgroundrefresh, and returns
Action::Sleep(STALE_RETRY_WAKE). Re-polls defercheaply — without loading or building the draft — until the local Snapshot
postdates the anchor, including on a different agent instance.
_unobservedvariants(modelling the window between a grant landing in Postgres and the next
Snapshot refresh),
refresh_snapshot_authoritative/_stalecontrol theSnapshot's
takenstamp relative to skew,age_live_specdistinguishesspec-relative from request-relative anchors under compressed test time, and
async_publicationbecomesqueue_publication+ a boundedre-poll-after-refresh loop mirroring production.
Tests
user_publications(new integration tests):test_publication_reschedules_on_stale_data_plane_authztest_publication_defers_polls_until_authoritative_snapshot— persistedawaiting_snapshot_after, cross-instance handoff, revoke-token canceltest_old_spec_publication_succeeds_after_late_grant— request-relativeanchoring guard
test_publication_stale_then_authoritative_denial— terminal denialonce authoritative, with snapshotted
flow://unauthorized/errorstest_publication_requests_snapshot_refreshtest_publication_uses_one_snapshot_across_phases— grants revokedmid-publication don't flip decisions within one operation
publications::specs::resolve_testsstaleness additions: data-plane-nameand storage-mapping freshness relative to
started, request-relativeanchoring for old specs, and grant attenuation
(
test_attenuated_data_plane_grant_is_not_visible, newattenuated_grantsfixture).Stack