ai-devkit
ai-devkit copied to clipboard
fix(devkitd): agent.start allows duplicate names for fallback-registered agents
Symptom
AI_DEVKIT_NO_DAEMON=1 ai-devkit agent start --type claude --name claude-1 # starts OK
ai-devkit agent start --type claude --name claude-1 # ALSO starts OK (should fail name_in_use)
A name already registered via the legacy fallback path could be claimed again through the daemon — no name_in_use error.
Root cause — three holes in the name check
- Boot-only import:
import_legacy_agentsran once at daemon boot. Registrations made via the fallback path afterward were invisible tolookup_name. prune_deaddeleted live registrations:DELETE ... WHERE gone_at IS NOT NULLremoved tombstones without checking pid liveness, pruning live-pid rows before the name check ran.gone_atgate: the check requiredgone_at IS NULL, but imported legacy rows are tombstoned-by-default — a live pid must be sufficient evidence regardless (TSprunesemantics).
Fix (branch fix/agent-start-duplicate-name, commit ec4b22df)
- Re-import legacy registrations inside
start_mutexbefore the name check prune_deadonly deletes tombstones with dead pidsname_in_usedecided bypid_alivealonepid_alivemoved to devkit-core (prune_dead needs it; agent.stop will)- 2 regression tests reproducing both holes