ai-devkit icon indicating copy to clipboard operation
ai-devkit copied to clipboard

fix(devkitd): agent.start allows duplicate names for fallback-registered agents

Open codeaholicguy opened this issue 1 month ago • 0 comments

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

  1. Boot-only import: import_legacy_agents ran once at daemon boot. Registrations made via the fallback path afterward were invisible to lookup_name.
  2. prune_dead deleted live registrations: DELETE ... WHERE gone_at IS NOT NULL removed tombstones without checking pid liveness, pruning live-pid rows before the name check ran.
  3. gone_at gate: the check required gone_at IS NULL, but imported legacy rows are tombstoned-by-default — a live pid must be sufficient evidence regardless (TS prune semantics).

Fix (branch fix/agent-start-duplicate-name, commit ec4b22df)

  • Re-import legacy registrations inside start_mutex before the name check
  • prune_dead only deletes tombstones with dead pids
  • name_in_use decided by pid_alive alone
  • pid_alive moved to devkit-core (prune_dead needs it; agent.stop will)
  • 2 regression tests reproducing both holes

codeaholicguy avatar Oct 23 '26 13:10 codeaholicguy