fix(queue): scan new workspace layout for concurrency counting

countRunningByAgent only scanned one level deep (*/status.json)
but new workspaces are at */*/*/status.json. Concurrency limits
weren't enforced — all agents dispatched as running instead of
queuing. Now scans both old and new layouts.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-22 15:34:43 +00:00
parent e9224b18b8
commit 39255b1766

View file

@ -116,22 +116,18 @@ func (s *PrepSubsystem) delayForAgent(agent string) time.Duration {
}
// countRunningByAgent counts running workspaces for a specific agent type.
// Scans both old (*/status.json) and new (*/*/*/status.json) workspace layouts.
func (s *PrepSubsystem) countRunningByAgent(agent string) int {
wsRoot := WorkspaceRoot()
r := fs.List(wsRoot)
if !r.OK {
return 0
}
entries := r.Value.([]os.DirEntry)
// Scan both old and new workspace layouts
old := core.PathGlob(core.JoinPath(wsRoot, "*", "status.json"))
new := core.PathGlob(core.JoinPath(wsRoot, "*", "*", "*", "status.json"))
paths := append(old, new...)
count := 0
for _, entry := range entries {
if !entry.IsDir() {
continue
}
st, err := readStatus(core.JoinPath(wsRoot, entry.Name()))
for _, statusPath := range paths {
st, err := readStatus(core.PathDir(statusPath))
if err != nil || st.Status != "running" {
continue
}