Repository navigation
fix(devkitd): stabilize durable adoption after daemon restart - #489
Open
codeaholicguy wants to merge 1 commit into
Open
codeaholicguy wants to merge 1 commit into
codeaholicguy wants to merge 1 commit into
Conversation
Wait for stdin delivery before durable.run returns so providers enter their blocking state before callers can kill the daemon, and make adopted-run reconciliation retry provider identity probes instead of finalizing on a single transient /proc miss under parallel test load.
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.
Root cause
The flake in
stop_and_restart_adoption_do_not_double_launchis a product race indevkitd, not the integration test itself.durable.runreturned to callers as soon as the provider child was spawned, while prompt bytes were still being written on a background thread. Under parallelcargo testload (the same pattern CI uses when it runscargo test --workspace), the test could kill and replacedevkitdbefore the stub provider received the fullblockprompt. The orphaned provider exited on broken stdin instead of sleeping, so startup reconciliation treated the adopted run as dead and moved the agent todegradedrather than keeping itrunning.A secondary issue made this worse when identity was ambiguous: adopted-run reconciliation used a single
identity()probe and immediately finalized the run on any non-match, instead of retrying transient/procmisses as the durable design calls for.On PR #486 commit
f3060f4, both Node 22 and Node 24 CI jobs failed withassertion left: "degraded" right: "running"in this test (see failed Test (Node 22) job).Fix
In
rust/crates/devkitd/src/durable.rs:Launch synchronization — join the stdin writer before
durable.run/durable.sendreturn, so the prompt is fully delivered before callers can tear down the daemon. Stdout parsing still runs concurrently on its own thread.Reconciliation — when an adopted provider is not in the local supervisor set, retry identity probes (with short backoff) before marking a run interrupted; leave the row unchanged when observation is still inconclusive.
Before / after
Repro command:
cargo test -p devkitd --test durable -- --test-threads=8in a loop.Isolated runs of
stop_and_restart_adoption_do_not_double_launchalone did not fail; the bug only appeared when all ninedurable.rstests ran in parallel.Test plan
Executed locally (Node 24):
npm installandnpm run buildat repo rootcargo fmt,cargo clippy --workspace -- -D warningscargo test --workspaceRisks
durable.runnow blocks until stdin write completes. Prompts are capped at 1 MiB and writes are typically small; this mainly removes the race rather than changing semantics for normal callers./procis ambiguous; inconclusive cases are left for the next reconcile pass instead of interrupting immediately.Skills / friction
skills/ordocs/ai/*.node packages/cli/dist/bundle/cli.js installnot re-run (skills already present in repo).