Repository navigation
fix: requests never wait on the relay settings or session-pin locks - #411
Merged
Merged
Conversation
Read atomically published relay settings and secrets without the writer lock. Stamp every relay update with a shared generation, retry crossed reads briefly, and return a terminal local refusal rather than dispatching an unmatched URL/token pair. Keep legacy unstamped pairs readable and leave all credential-refresh and custody locks unchanged. Make session-pin assignment, removal and legacy seeding nonblocking best-effort bookkeeping. Two existing tests deliberately change contract: pin-seed rename failures and malformed pin files no longer veto an independently authorized request. They still assert no partial publication, preservation of malformed bytes, and successful later seeding. Add lifetime-owned real held-lock coverage on OpenCode 1, OpenCode 2 and Pi, writer serialization and generation-race/refusal tests. Mutation controls catch restored reader locking, missing generation checks, missing writer locking and each blocking pin path.
Decide routes from atomically published pins without a writer lease. Queue session-only merges, touches, clears and legacy imports under the normal background lease; retain failed changes for retry, discard superseded changes after contention, and drain owned publications during Core, OpenCode and Pi disposal. Keep credential-refresh and custody coordination unchanged. Extend the injected non-controlling lock observer, distinguish background-origin and post-dispatch writes, and prove zero foreground acquisitions for healthy local and vault requests on each host, with an expired-token provider-lock control per host. Add the three requested catalogue controls with broad command/report/ID fields and prove each through the strict mutation runner. Preserve existing persistence, ownership and UUID/account assertions by explicitly draining publications before inspecting disk. Legacy recovery contention now serves requests while publication waits, then completes after release instead of being dropped. Root typecheck/build, scoped regressions, catalogue self-test and all nine host lock probes pass. The last broad Core run had two unchanged five-second shared-runner timeouts; detailed failures, mutation evidence and the parent-deferred shared-refresh joining caveat are retained in the delivery audit.
Core's exported NativeLockEvent type gained acquiring. Deliberately include acquiring in both pinned unions of the generated consumer.ts fixture, retaining the closed event-kind contract, older producer compatibility, and rejection of narrow callbacks. Verified with pinned Bun 1.3.14 on linux,4c,net: Core build and test:scripts pass (9 tests, 46 assertions); the fresh consumer typechecks 421 files and passes 18 Node runtime assertions.
The CI byte comparison captured routing before a queued reset finished, then compared it after the deletion. Other repetitions read before live-pin creation or before the background legacy import. Drain the actual routing publishers at those persistence boundaries; no production merger change is needed. Keep every original assertion, add live-retention and legacy-only-removal checks after reset, and join fixture-owned publishers before removing their root. Reproduced 5/5 failures before the fix and 20/20 passing independent Linux runs afterward. A deliberate occupied-key overwrite still reddens the original live-pin equality through the strict mutation runner. Core build and OpenCode typecheck pass; focused OC2/migration coverage passes 65 tests. Ran the full OpenCode suite once with built packed exports and network: all OC2 and real-host cases pass, with three unrelated existing test/hook deadline failures recorded in the delivery audit.
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.
A user request in OpenCode failed with
Timed out acquiring native-relay lock for …/anthropic-auth-vault-settings.jsonunder heavy CPU load: every request read the relay settings under the exclusive lock their writer uses, and a lock-wait timeout failed the request. Rule: a request never waits on or fails from bookkeeping I/O.Mutation rows: lock restored in the relay read, generation check disabled, route decided under a lease, superseded assignment published; all CAUGHT.
Summary by cubic
Fixes user requests that could time out or fail while waiting on relay settings or session-pin bookkeeping locks. Requests now complete without acquiring those locks; any bookkeeping is done in the background.
NativeLockEventtype adds anacquiringevent; tests prove healthy requests take no foreground locks on OpenCode 1, OpenCode 2, and Pi.Written for commit 04eaec3. Summary will update on new commits.