Repository navigation
fix(stack): publish scoped observations and drift atomically - #4820
Open
ScriptedAlchemy wants to merge 8 commits into
Open
ScriptedAlchemy wants to merge 8 commits into
ScriptedAlchemy wants to merge 8 commits into
Conversation
|
ScriptedAlchemy
marked this pull request as ready for review
November 9, 2026 23:55
A provider stack read authorized under one registration could publish after the scope was disabled and re-enabled: the policy compared equal again and the completion timestamp passed the fence, so a stale enabled snapshot became the re-enabled scope's current observation. Each policy change now creates a new scope registration identity. authorize_provider_read captures it in a single-use read token before network I/O; observe_provider consumes the token and, under the observation-state lock, refuses a replaced registration as Superseded before touching the snapshot or drift intervals. Policy observations carry the same identity, which replaces the policy-changed flag as the drift-baseline rule. Re-registering an unchanged policy keeps the registration and its in-flight reads. Identities are compared by allocation, so a retired one can never match a successor while held. The review runtime owner is the sole production caller and now passes the token from authorization to completion; should_read_provider_stack and the provider-to-policy fallback are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refresh disabled scopes and superseded provider reads through the current policy authority so prior enabled observations and drift do not remain open. Publish policy-only source bindings through the existing anchor and observability paths; keep stale provider completions refused. Two real HTTP runtime-owner journeys prove disabled publication and settled drift. Both fail when the policy-update calls are removed. Bazel: 585 unit tests and 92 integration tests passed; Clippy and pinned formatting passed.
This branch has not been deployed
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.
Scope
Refs #4436 — eliminate the split ownership of a stack's current observation and open drift intervals. This is a focused correctness/ownership slice, not full scope-lifetime retirement.
Previously
store_observationread the prior snapshot under one mutex, calculated and updated drift under a second mutex, then published the observation after reacquiring the first mutex. Concurrent equivalent provider updates could both calculate drift from the same previous snapshot, emit duplicate transition observations, and race the interval frontier.This change:
observationsanddrift_intervalsmaps with a singleScopeObservationStateentry holding both under the existing coordinator owner.Behavioral regression
concurrent_identical_provider_publications_have_one_drift_transitionstarts 24 real threads behind a barrier, publishes the same changed stack head, and checks exactly one stack-tip transition and one opening BaseAdvanced interval, plus validation of every emitted drift receipt. This targets the prior read/modify/publish race rather than testing source shape.Existing typed provider-state, drift close/restore and preflight tests remain.
Verification and limits
master91c72aba; no generated contracts or unrelated contributor paths changed.3f5a11389c, all 89 tests in the macOS Bazel application integration suite passed. The crate formatting target and Clippy for both the production library and test suite passed.Enabledbefore the fix and now returnsUnavailableuntil a fresh provider observation arrives. Policy registration, snapshot reuse and final publication now check the same scope state. The previous timestamp still fences late responses.No Kev/decision model, release, infrastructure, secret, beta.99 or mixed #4776 changes.