Files
zero/internal/specialist/exec_proc_unix_test.go
KRATOS 9e800b4ffc fix five concurrency/leak bugs (swarm, specialist, oauth, mcp, cron) (#265)
Surfaced by a full-tree audit; each ships a regression test where the
behavior is deterministically testable.

- swarm: deliver a handoff's mailbox note BEFORE registering the new task,
  so a mailbox failure can't leave a phantom pending task in the coordinator.
- specialist: put a foreground sub-agent child in its own process group and
  group-kill on cancel/timeout (+ WaitDelay backstop), so a build/server it
  forked dies with it instead of orphaning.
- oauth: serialize on-demand token refresh per key (keyed mutex) and re-load
  inside the lock, so parallel callers don't each spend the single-use
  refresh token (all but one would otherwise fail at the token endpoint).
- mcp: treat a "source already gone" rename during legacy-token migration as
  success, so a concurrent migrator doesn't wrongly drop an OAuth MCP server.
- cron: claim a due job atomically (advance NextRunAt under the per-job lock)
  before running it, so two schedulers can't double-fire the same job.
2026-06-20 10:39:55 +05:30

23 lines
482 B
Go

//go:build !windows
package specialist
import (
"os/exec"
"testing"
)
func TestHardenSpecialistChild(t *testing.T) {
cmd := exec.Command("true")
hardenSpecialistChild(cmd)
if cmd.SysProcAttr == nil || !cmd.SysProcAttr.Setpgid {
t.Error("expected Setpgid (own process group) so cancel can group-kill grandchildren (M6)")
}
if cmd.WaitDelay == 0 {
t.Error("expected a WaitDelay backstop")
}
if cmd.Cancel == nil {
t.Error("expected a custom group-kill Cancel")
}
}