Repository navigation
fix: count client contact made during a tick slower than tickMs (#6813) - #6823
Merged
Merged
Conversation
stimd copied lastContact when a tick started and tested that copy when the tick ended, so a tick longer than tickMs always counted as idle. The idle check now reads the current lastContact. stimd dials its own CLI socket to list web shares, so that dial must not count as contact. The net.connect handoff now marks its first frame with net: true, and stimd takes no contact from such a connection. While the net thread runs stimd stays up for it anyway, and while it does not the handoff fails.
…unning (#6813) The exit gate awaits an engine check after the idle sample. A client that contacts stimd during that wait, such as stim serve asking for the net thread, does not register as an active command, so stimd shut down under it. The gate now also requires no contact within tickMs.
… stimd running (#6813) The exit gate now also keeps stimd up while the net thread runs, as the tick does, so a listener stim serve started after the idle sample is not closed under it. The gate tests stop their daemon in a finally block, and the slow-tick row uses 1 s slow ticks so the unfixed exit lands well inside its window.
… docs: LLP 0012 names the gate's contact and net thread checks (#6813)
janicduplessis
marked this pull request as ready for review
December 2, 2026 21:56
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
stimd copied
lastContactintocontactSincewhen a tick started and tested that copy when the tick ended. A contact that arrived during the tick was ignored, so a tick longer thantickMsalways counted as idle, and two in a row ended stimd withnothing runs in this Stim homewhile a client was talking to it.Reading the current
lastContactalone is not enough. stimd's own passes callliveShareKeepReason, which dials stimd's CLI socket throughconnectNet, and that self-contact would keep a quiet home up forever (daemon-cadence.test.tsfails). The tick-start copy was what hid it.Solution
lastContact.connectNetmarks its first framenet: true, and stimd takes no contact from a connection that carries it.connectNet(stim share,stop's share cleanup, doctor's server probe): theirnet.connecthandoff no longer counts as contact. Nothing is lost: while the net thread runs, stimd stays up for it anyway ("the net thread serves"), and while it does not, the handoff fails withnet-off. Their other ops still count.stim serve, which registers no active command), now also keeps stimd up: the gate requires no contact withintickMsand no running net thread, like the tick does.I chose this over the issue's suggestion of asking the net thread for live shares in-process, which needs plumbing into every
liveShareKeepReasoncaller, some of them in worker threads.Test plan
stimd.integration.test.tsgets a row "a client hello during ticks longer than tickMs":measureTickwaits 1500 ms withtickMs: 1000while a hello arrives every 30 ms. It fails onmain(expected 'exited' to be 'running') and passes here; the gate's contact clause alone would also pass it. The existing probe and client-hello rows still pass.daemon-cadence.test.ts"a workspace with no activity recorded in its state does not" covers thenet: truehalf: it fails with only the idle-check change and passes with both.daemon-cadence.test.tsgets two rows "... during the engine check before the idle exit does": they hold the gate's engine check open, then send a hello, or start the net thread and let 2 minutes pass, and expect a third tick. Each fails without its gate clause (stimd stops after two ticks).Fixes #6813