Repository navigation
fix(devkitd): close duplicate-name holes in agent.start - #418
Open
codeaholicguy wants to merge 2 commits into
Open
codeaholicguy wants to merge 2 commits into
codeaholicguy wants to merge 2 commits into
Conversation
A name registered via the fallback path (AI_DEVKIT_NO_DAEMON or pre-daemon agents) could be claimed again through the daemon: - import_legacy_agents only ran at daemon boot — post-boot legacy registrations were invisible to the name check. Now re-imports inside the start mutex before lookup_name. - prune_dead deleted every tombstoned row without checking pid liveness, pruning live-pid registrations before the check could see them. It now deletes only tombstones whose pids are actually dead. - the name-in-use check required gone_at IS NULL, but imported legacy rows are tombstoned-by-default — a live pid is now sufficient evidence regardless of gone_at (matches TS prune semantics). pid_alive moves to devkit-core (prune_dead needs it; agent.stop will). Regression tests cover both holes; rusqlite added as devkitd dev-dep for the legacy-db fixture.
pid 10 is a live kernel thread on Linux, so prune_dead's new liveness check kept the tombstone and the name reuse hit UNIQUE constraint. i32::MAX is above every pid_max — dead on any platform.
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.
Summary
Fixes a duplicate-name hole in
agent.start: a name registered via the fallback path (AI_DEVKIT_NO_DAEMONor pre-daemon agents) could be claimed again through the daemon.Root cause — three holes:
import_legacy_agentsran once at daemon boot — post-boot legacy registrations were invisible to the name checkprune_deaddeleted every tombstoned row unconditionally (WHERE gone_at IS NOT NULL), pruning live-pid registrations before the check could see themname_in_usecheck requiredgone_at IS NULL, but imported legacy rows are tombstoned-by-default — a live pid is now sufficient evidenceFix:
start_mutexbefore the name checkprune_deadonly deletes tombstones whose pids are actually deadpid_alivealone decidesname_in_use(matches TSprunesemantics)pid_alivemoved todevkit-core(needed byprune_dead;agent.stopwill use it too)Closes #417
Test plan
cargo test --workspace— 135 pass, 0 failcargo clippy --workspace --all-targets -- -D warningscleancargo fmt --checkcleantombstoned_but_live_pid_still_blocks_name,legacy_row_written_after_daemon_boot_blocks_name(reproduces the reported scenario)AI_DEVKIT_NO_DAEMON=1start → daemon start with same name → expectname_in_use