File size: 1,234 Bytes
4c76b0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
 * Regression coverage for depth-derived subagent capabilities.
 * Verifies main/orchestrator/leaf role and control-scope decisions.
 */
import { describe, expect, it } from "vitest";
import { resolveSubagentCapabilities } from "./subagent-capabilities.js";

describe("resolveSubagentCapabilities", () => {
  it("returns normalized depth for non-finite direct inputs", () => {
    expect(
      resolveSubagentCapabilities({
        depth: Number.NaN,
        maxSpawnDepth: Number.POSITIVE_INFINITY,
      }),
    ).toEqual({
      depth: 0,
      role: "main",
      controlScope: "children",
      canSpawn: true,
      canControlChildren: true,
    });
  });

  it("floors finite depth and max depth consistently", () => {
    expect(resolveSubagentCapabilities({ depth: 1.9, maxSpawnDepth: 1.2 })).toEqual({
      depth: 1,
      role: "leaf",
      controlScope: "none",
      canSpawn: false,
      canControlChildren: false,
    });
  });

  it("makes children at the default recursion boundary leaves", () => {
    expect(resolveSubagentCapabilities({ depth: 1_000 })).toEqual({
      depth: 1_000,
      role: "leaf",
      controlScope: "none",
      canSpawn: false,
      canControlChildren: false,
    });
  });
});