Skip to content

[Bug]: Swarm activation control races terminal cleanup #1046

Description

@dennisonbertram

Summary

TestAgentSwarmDeniedForMemberRuns starts its unrestricted control run with a provider that has already exhausted its scripted turns. The run can complete and cleanup deferred activations between Activations.Activate and filteredToolsForRun, so hosted fast CI intermittently reports agent_swarm missing. This is a test-fixture lifecycle race and currently blocks the cron/callback GUI merge chain.

Acceptance criteria

  • The unrestricted control run remains live until after its activated tool definitions are inspected.
  • The test still proves agent_swarm is hidden for a denied member run and visible for an unrestricted run after activation.
  • The control run is released and reaches a terminal state without leaking a goroutine.
  • Focused normal/race stress, internal/harness normal/race, full regression, and GitHub checks pass.

In scope

  • Test-local provider lifecycle synchronization for TestAgentSwarmDeniedForMemberRuns.
  • Engineering log, plan, impact map, and plans index.

Out of scope

  • Production activation cleanup, Runner lifecycle, agent_swarm permissions, deferred-tool behavior, or provider dispatch.

Current architecture and search evidence

  • Runner.completeRun and failure/cancellation paths call Activations.Cleanup(runID).
  • The test reuses a capturingProvider whose scripted turns were consumed by the member run; its unrestricted control can therefore complete immediately.
  • The test activates run2 and then calls filteredToolsForRun, racing terminal cleanup.
  • Adjacent swarm tests do not use this exhausted-provider control pattern.

Impact analysis

  • Harness/API/TUI/macOS GUI runtime behavior: none; test-only repair.
  • Config/schema/persistence/providers/security: none after repository search.
  • Concurrency/reliability: a test-local release channel holds the control provider in its first completion until definitions are inspected.
  • Compatibility/deployment/observability: no runtime deployment; CI becomes repeatable. Rollback by reverting if the control no longer exercises a live unrestricted run.
  • Documentation: engineering/long-term logs, plan, impact map, plans index only.

Test-first plan

  1. Red: hosted go test ./internal/... ./cmd/... failed at runner_swarm_test.go:242 because terminal cleanup won the activation/read race.
  2. Green: give the unrestricted control a dedicated blocking provider and release it only after the definition assertion.
  3. Stress: focused normal/race at count=100 and internal/harness normal/race.
  4. Full: ./scripts/test-regression.sh and hosted required checks.

Rollout and rollback

Test-only closing PR, exact-head automated review, required checks, then merge. Revert if the control no longer proves both denied and unrestricted behavior.

Dependencies

Related to epic #1000 and blocks PRs #1045, #1043, #1041, #1033 plus the callback/GUI merge chain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions