Repository navigation
KeyCallers admits through an atomic count (spec 0004, entry 3) - #32
Merged
Merged
Conversation
A call adds itself to an in-flight count, then reads closed; close sets closed, then waits for the count to reach zero. Admission commits no step, so one use of a held key view commits two steps, not three. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Entry 3 of spec 0004,
key-callers-atomic-count. Based onmain; entry 4 (key-material-uses-outside-steps) stacks on it.What changes
KeyCallersno longer admits throughstate.modify. It keeps two JDK atomics, each commented with spec 0004:inFlight, then readsclosed. If closed, it takes the one away and refuses.closed, then polls (10 ms, as before) untilinFlightis zero.Whichever side goes second sees the other, so a call is either refused or waited for. Tickets,
CallerStateand the close stages that existed only for them (FENCEas a commit,REAP) are gone.REVOKE,STOP,OBSERVEand the failure assembly are unchanged.One use of a held key view commits 2 steps where it committed 3.
KeyViewUseCostSuite's ceiling drops to 2; it failed at 3 before the change.Bench
./gradlew :surefold-tenancy-crypto-bench:run, paired runs alternating this branch andmainon the same machine, load average 195 to 210 on 8 cores. p50 is the comparison; p99 and max are noise at this load.New story
a call arriving during close is refused or waited for, never neither(RetainedKeyCallersCloseSuite) races a call against close 200 times. Either the call is refused with nothing entered, or it entered and left before close returned. As the spec's question 2 expects, there is no seam between two atomic operations, so this is the stress story. The two branches are also held deterministically bypendingCaller(a held call keeps close waiting, and a later call is refused).Caller stories: kept, rewritten, removed
Removed:
a committed admission observer throw preserves original and runs no body: admission commits no step, so it has no observer to fault.CallerFenceProbeself-tests:the Solo probe interrupts a real pending Shared commit without changing its value,a fresh commit after the Solo interruption survives its observer failure and owned unwind,an assertion failure while Solo is held releases every gate and joins both workers,pause-only handoffs retain late state and clean up after assertion: false/true. The probe paused the fence and admission commits. Neither commits now, so the probe and its self-tests go.atomic caller fence captures late admission and cleans up after assertion: false/true: replaced by the new story above.a real precommit fence interruption clears before retry and restores at close exit: the fence is now one atomic write, so there is no commit to interrupt. Restoring interruption at close exit is still covered byaccepted callers keep close parked…,normal interrupted pool stop…andclose refuses $mode steps… preserves interruption.Rewritten:
committed terminal reap is not repeated and an empty close has nothing to reap→a second close and a close with no callers return at once. There is no reap stage now.the call guard refuses ordinary nested and forced solo steps before admission: the admission-commit counter is dropped. Kept: refused inside a transaction, the body is not run, and a later call runs.committed fence and reap failures retain received roots for $mode(×4) →close cleanup failures retain received roots for $mode. The two faults now come from owed cleanup actions in the drain phase. The root-assembly assertions are the same.opaque Fail retains its received cleanup root before its owning attempt: same change, faults moved to drain-phase actions.same-owner direct inherited and observer closes refuse before fencing→same-owner direct and inherited closes refuse before fencing. The observer variants closed from the admit and fence commits, which no longer exist.an accepted lease reaching enrolment after close fencing has no loader→an admitted lease…. It paused on the admission commit. It now sets up the same state directly (admitted by open callers, ledger already fenced) and asserts refusal with no loader and no clock sample.Kept unchanged:
atDeliveryCommitstories: they hook ledger steps (registerPrepared,abortPrepared,drain), not caller admission.an admitted view remains owned when admission instrumentation throws(admissionObserverFault): it hooksOwnedKeyMaterial.borrow, which stays a step.pendingCallerstory and the other public-close stories.Verified
spotlessApply, detekt main and test clean. All 255 tests of:surefold-tenancy-cryptoran. Everything except the Postgres-backed suites passed.TenantKeysSuiteandKeyCacheCompatibilitySuitehit their 1-minute watchdog in container and Liquibase setup (the thread dump shows Liquibase finishing a second before the timeout) at load average 100 to 230. They pass when run alone. The same limit was noted on [stack 2/3] Spec 0004: a key view use registers once #30. CI is the judge for these and for Kover.🤖 Generated with Claude Code