Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Swarm routing: plug-ins, one place where pieces 3 to 6 change the ranking (#2420)

0xken1547cc7dc8c94f
diff --git a/cli/src/superTabs/__snapshots__/route.answers.json b/cli/src/superTabs/__snapshots__/route.answers.json
new file mode 100644
index 000000000..5b2f7faf2
--- /dev/null
+++ b/cli/src/superTabs/__snapshots__/route.answers.json
@@ -0,0 +1,3320 @@
+[
+ {
+ "name": "mixed members and new agents",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.78,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (80% left, resets in 3h); weekly 6% of 90% · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "member",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "idle",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "agentId": "m1",
+ "name": "Multiply",
+ "repo": "same",
+ "frame": {
+ "title": "Fix the dial",
+ "project": "openharness",
+ "cwd": "/r",
+ "root": "/r",
+ "remote": "github.com/o/r",
+ "branch": "fix/dial",
+ "updatedAt": 998800000
+ },
+ "earlier": [
+ {
+ "group": "Dial fix",
+ "outcome": "merged"
+ }
+ ],
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a"
+ },
+ "id": "c1",
+ "title": "Multiply · Claude sonnet medium · a",
+ "label": "Member Multiply · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · a · idle · same repo · on \"Fix the dial\" · in openharness, branch fix/dial · last active 20m ago · earlier here: Dial fix merged · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 60,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 60,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 2,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a"
+ },
+ "id": "c2",
+ "title": "New agent · Claude sonnet medium · a",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (60% left, resets in 3h); weekly 4% of 90% · a · new · quota 5-hour 60% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "b"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "b"
+ },
+ "id": "c3",
+ "title": "New agent · Claude sonnet medium · b",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · b · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "member",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "b"
+ },
+ "activity": "idle",
+ "known": true,
+ "refusals": [],
+ "notes": [
+ "It works in another repository, so it would build this in that repository's worktree. A new agent starts in this one."
+ ],
+ "agentId": "m2",
+ "name": "Elsewhere",
+ "repo": "different",
+ "frame": null,
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "b"
+ },
+ "id": "c4",
+ "title": "Elsewhere · Claude sonnet medium · b",
+ "label": "Member Elsewhere · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · It works in another repository, so it would build this in that repository's worktree. A new agent starts in this one. · b · idle · different repo · activity unknown · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.78,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (80% left, resets in 3h); weekly 6% of 90% · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "medium",
+ "risk": "low",
+ "why": "API change.",
+ "size": "medium"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (80% left, resets in 3h); weekly 6% of 90% · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.78,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "a"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "member",
+ "agentId": "m1",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "Multiply · Claude sonnet medium · a",
+ "label": "Member Multiply · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · a · idle · same repo · on \"Fix the dial\" · in openharness, branch fix/dial · last active 20m ago · earlier here: Dial fix merged · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a"
+ }
+ },
+ {
+ "id": "c2",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · a",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (60% left, resets in 3h); weekly 4% of 90% · a · new · quota 5-hour 60% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a"
+ }
+ },
+ {
+ "id": "c3",
+ "kind": "new",
+ "machineId": "b",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · b",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · b · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "b"
+ }
+ },
+ {
+ "id": "c4",
+ "kind": "member",
+ "agentId": "m2",
+ "machineId": "b",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "Elsewhere · Claude sonnet medium · b",
+ "label": "Member Elsewhere · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · It works in another repository, so it would build this in that repository's worktree. A new agent starts in this one. · b · idle · different repo · activity unknown · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "b"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "high, large: strong pick short, weaker one fits",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 5,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 5,
+ "resetsAt": 1014400000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 60,
+ "resetsAt": 1259200000
+ }
+ ],
+ "account": "B"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "short",
+ "coverage": 0.1,
+ "effectiveCost": 1.8,
+ "expiring": 0.1,
+ "spend": {
+ "5-hour": 50,
+ "weekly": 8
+ },
+ "account": "B"
+ },
+ "id": "c0",
+ "title": "New agent · Codex default default · b",
+ "label": "New agent · Codex default default · strength 3, cost 2 · short: needs about 50% of the 5-hour window (5% left, resets in 4h, otherwise unused); weekly 8% of 60% · b · new · quota 5-hour 5% left (resets in 4h), weekly 60% left (resets in 3 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 20,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 20,
+ "resetsAt": 1014400000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 50,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "A"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "short",
+ "coverage": 0.27,
+ "effectiveCost": 2.2,
+ "expiring": 0.27,
+ "spend": {
+ "5-hour": 75,
+ "weekly": 12
+ },
+ "account": "A"
+ },
+ "id": "c1",
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 75% of the 5-hour window (20% left, resets in 4h, otherwise unused); weekly 12% of 50% · a · new · quota 5-hour 20% left (resets in 4h), weekly 50% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "c",
+ "machineName": "c",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 90,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 90,
+ "resetsAt": 1014400000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1518400000
+ }
+ ],
+ "account": "C"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.8,
+ "effectiveCost": 0,
+ "expiring": 1,
+ "spend": {
+ "5-hour": 50,
+ "weekly": 8
+ },
+ "account": "C"
+ },
+ "id": "c2",
+ "title": "New agent · Claude sonnet medium · c",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 50% of the 5-hour window (90% left, resets in 4h, otherwise unused); weekly 8% of 90% · c · new · quota 5-hour 90% left (resets in 4h), weekly 90% left (resets in 6 days)"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false,
+ "short": "The first candidate's 5-hour quota is expected to run out partway and resets in 4h; New agent · Claude sonnet medium · c fits."
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 5,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 5,
+ "resetsAt": 1014400000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 60,
+ "resetsAt": 1259200000
+ }
+ ],
+ "account": "B"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "short",
+ "coverage": 0.1,
+ "effectiveCost": 1.8,
+ "expiring": 0.1,
+ "spend": {
+ "5-hour": 50,
+ "weekly": 8
+ },
+ "account": "B"
+ },
+ "id": "c0",
+ "title": "New agent · Codex default default · b",
+ "label": "New agent · Codex default default · strength 3, cost 2 · short: needs about 50% of the 5-hour window (5% left, resets in 4h, otherwise unused); weekly 8% of 60% · b · new · quota 5-hour 5% left (resets in 4h), weekly 60% left (resets in 3 days)"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "high",
+ "risk": "low",
+ "why": "API change.",
+ "size": "large"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "b",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "title": "New agent · Codex default default · b",
+ "label": "New agent · Codex default default · strength 3, cost 2 · short: needs about 50% of the 5-hour window (5% left, resets in 4h, otherwise unused); weekly 8% of 60% · b · new · quota 5-hour 5% left (resets in 4h), weekly 60% left (resets in 3 days)",
+ "fit": {
+ "status": "short",
+ "coverage": 0.1,
+ "effectiveCost": 1.8,
+ "expiring": 0.1,
+ "spend": {
+ "5-hour": 50,
+ "weekly": 8
+ },
+ "account": "B"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 75% of the 5-hour window (20% left, resets in 4h, otherwise unused); weekly 12% of 50% · a · new · quota 5-hour 20% left (resets in 4h), weekly 50% left (resets in 5 days)",
+ "fit": {
+ "status": "short",
+ "coverage": 0.27,
+ "effectiveCost": 2.2,
+ "expiring": 0.27,
+ "spend": {
+ "5-hour": 75,
+ "weekly": 12
+ },
+ "account": "A"
+ }
+ },
+ {
+ "id": "c2",
+ "kind": "new",
+ "machineId": "c",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · c",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 50% of the 5-hour window (90% left, resets in 4h, otherwise unused); weekly 8% of 90% · c · new · quota 5-hour 90% left (resets in 4h), weekly 90% left (resets in 6 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.8,
+ "effectiveCost": 0,
+ "expiring": 1,
+ "spend": {
+ "5-hour": 50,
+ "weekly": 8
+ },
+ "account": "C"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "low, small: weekly day budget and an expiring window",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 10,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 70,
+ "resetsAt": 1001200000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 10,
+ "resetsAt": 1518400000
+ }
+ ],
+ "account": "A"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 4.67,
+ "effectiveCost": 0,
+ "expiring": 1,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 1.5
+ },
+ "account": "A"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 15% of the 5-hour window (70% left, resets in 20m, otherwise unused); weekly 2% of 10% · a · new · quota 5-hour 70% left (resets in 20m), weekly 10% left (resets in 6 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "c",
+ "machineName": "c",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 30,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "weekly",
+ "leftPercent": 30,
+ "resetsAt": 1518400000
+ }
+ ],
+ "account": "C"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 30,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 10,
+ "weekly": 1
+ },
+ "account": "C"
+ },
+ "id": "c1",
+ "title": "New agent · Codex default default · c",
+ "label": "New agent · Codex default default · strength 3, cost 2 · fits: 5-hour window unknown; weekly 1% of 30% · c · new · quota weekly 30% left (resets in 6 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 40,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 40,
+ "resetsAt": 1014400000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 80,
+ "resetsAt": 1172800000
+ }
+ ],
+ "account": "B"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 1.5
+ },
+ "account": "B"
+ },
+ "id": "c2",
+ "title": "New agent · Claude opus high · b",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 15% of the 5-hour window (40% left, resets in 4h); weekly 2% of 80% · b · new · quota 5-hour 40% left (resets in 4h), weekly 80% left (resets in 2 days)"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 10,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 70,
+ "resetsAt": 1001200000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 10,
+ "resetsAt": 1518400000
+ }
+ ],
+ "account": "A"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 4.67,
+ "effectiveCost": 0,
+ "expiring": 1,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 1.5
+ },
+ "account": "A"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 15% of the 5-hour window (70% left, resets in 20m, otherwise unused); weekly 2% of 10% · a · new · quota 5-hour 70% left (resets in 20m), weekly 10% left (resets in 6 days)"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "low",
+ "risk": "low",
+ "why": "API change.",
+ "size": "small",
+ "kind": "docs"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 15% of the 5-hour window (70% left, resets in 20m, otherwise unused); weekly 2% of 10% · a · new · quota 5-hour 70% left (resets in 20m), weekly 10% left (resets in 6 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 4.67,
+ "effectiveCost": 0,
+ "expiring": 1,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 1.5
+ },
+ "account": "A"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "c",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "title": "New agent · Codex default default · c",
+ "label": "New agent · Codex default default · strength 3, cost 2 · fits: 5-hour window unknown; weekly 1% of 30% · c · new · quota weekly 30% left (resets in 6 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 30,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 10,
+ "weekly": 1
+ },
+ "account": "C"
+ }
+ },
+ {
+ "id": "c2",
+ "kind": "new",
+ "machineId": "b",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · b",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 15% of the 5-hour window (40% left, resets in 4h); weekly 2% of 80% · b · new · quota 5-hour 40% left (resets in 4h), weekly 80% left (resets in 2 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 1.5
+ },
+ "account": "B"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "picks still at work hold their quota",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 45,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 45,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 50,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "B"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "B"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · b",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (45% left, resets in 3h); weekly 6% of 50% · b · new · quota 5-hour 45% left (resets in 3h), weekly 50% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 50,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 50,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 50,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "A"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "short",
+ "coverage": 0.56,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "A"
+ },
+ "id": "c1",
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 45% of the 5-hour window (25% left, resets in 3h); weekly 6% of 47% · a · new · quota 5-hour 50% left (resets in 3h), weekly 50% left (resets in 5 days)"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 45,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 45,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 50,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "B"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "B"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · b",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (45% left, resets in 3h); weekly 6% of 50% · b · new · quota 5-hour 45% left (resets in 3h), weekly 50% left (resets in 5 days)"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "high",
+ "risk": "low",
+ "why": "API change.",
+ "size": "medium"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "b",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · b",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (45% left, resets in 3h); weekly 6% of 50% · b · new · quota 5-hour 45% left (resets in 3h), weekly 50% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "B"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · a",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 45% of the 5-hour window (25% left, resets in 3h); weekly 6% of 47% · a · new · quota 5-hour 50% left (resets in 3h), weekly 50% left (resets in 5 days)",
+ "fit": {
+ "status": "short",
+ "coverage": 0.56,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "A"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "metered, unknown and unreadable quota",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": null,
+ "resetsAt": null,
+ "metered": true
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a:codex"
+ },
+ "id": "c0",
+ "title": "New agent · Codex default default · a",
+ "label": "New agent · Codex default default · strength 3, cost 2 · fits: metered, no usage window to run out · a · new · quota metered"
+ },
+ {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": false,
+ "leftPercent": null,
+ "resetsAt": null,
+ "why": "signed out of usage"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "unknown",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "b:codex"
+ },
+ "id": "c1",
+ "title": "New agent · Codex default default · b",
+ "label": "New agent · Codex default default · strength 3, cost 2 · unknown: 5-hour window unknown; weekly unknown · b · new · quota unknown (signed out of usage)"
+ },
+ {
+ "kind": "new",
+ "machineId": "c",
+ "machineName": "c",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 40,
+ "resetsAt": 1007200000
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "unknown",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "c:codex"
+ },
+ "id": "c2",
+ "title": "New agent · Codex default default · c",
+ "label": "New agent · Codex default default · strength 3, cost 2 · unknown: 5-hour window unknown; weekly unknown · c · new · quota 40% left, resets in 2h"
+ },
+ {
+ "kind": "new",
+ "machineId": "d",
+ "machineName": "d",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 40,
+ "resetsAt": null,
+ "from": "Team Mac"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "unknown",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "d:codex"
+ },
+ "id": "c3",
+ "title": "New agent · Codex default default · d",
+ "label": "New agent · Codex default default · strength 3, cost 2 · unknown: 5-hour window unknown; weekly unknown · d · new · quota read on Team Mac, whose subscription this account spends: 40% left"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": null,
+ "resetsAt": null,
+ "metered": true
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a:codex"
+ },
+ "id": "c0",
+ "title": "New agent · Codex default default · a",
+ "label": "New agent · Codex default default · strength 3, cost 2 · fits: metered, no usage window to run out · a · new · quota metered"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "medium",
+ "risk": "low",
+ "why": "API change.",
+ "size": "medium"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "title": "New agent · Codex default default · a",
+ "label": "New agent · Codex default default · strength 3, cost 2 · fits: metered, no usage window to run out · a · new · quota metered",
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a:codex"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "b",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "title": "New agent · Codex default default · b",
+ "label": "New agent · Codex default default · strength 3, cost 2 · unknown: 5-hour window unknown; weekly unknown · b · new · quota unknown (signed out of usage)",
+ "fit": {
+ "status": "unknown",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "b:codex"
+ }
+ },
+ {
+ "id": "c2",
+ "kind": "new",
+ "machineId": "c",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "title": "New agent · Codex default default · c",
+ "label": "New agent · Codex default default · strength 3, cost 2 · unknown: 5-hour window unknown; weekly unknown · c · new · quota 40% left, resets in 2h",
+ "fit": {
+ "status": "unknown",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "c:codex"
+ }
+ },
+ {
+ "id": "c3",
+ "kind": "new",
+ "machineId": "d",
+ "engine": "codex",
+ "model": "default",
+ "effort": "default",
+ "quality": 3,
+ "cost": 2,
+ "title": "New agent · Codex default default · d",
+ "label": "New agent · Codex default default · strength 3, cost 2 · unknown: 5-hour window unknown; weekly unknown · d · new · quota read on Team Mac, whose subscription this account spends: 40% left",
+ "fit": {
+ "status": "unknown",
+ "coverage": null,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "d:codex"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "more machines than rows shown",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "m05",
+ "machineName": "m05",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 50,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 50,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct5"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.11,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct5"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · m05",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (50% left, resets in 3h); weekly 6% of 90% · m05 · new · quota 5-hour 50% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m07",
+ "machineName": "m07",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 58,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 58,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct7"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.29,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct7"
+ },
+ "id": "c1",
+ "title": "New agent · Claude opus high · m07",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (58% left, resets in 3h); weekly 6% of 90% · m07 · new · quota 5-hour 58% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m09",
+ "machineName": "m09",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 66,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 66,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct9"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.47,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct9"
+ },
+ "id": "c2",
+ "title": "New agent · Claude opus high · m09",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (66% left, resets in 3h); weekly 6% of 90% · m09 · new · quota 5-hour 66% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m11",
+ "machineName": "m11",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 74,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 74,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct11"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.64,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct11"
+ },
+ "id": "c3",
+ "title": "New agent · Claude opus high · m11",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (74% left, resets in 3h); weekly 6% of 90% · m11 · new · quota 5-hour 74% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m13",
+ "machineName": "m13",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 82,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 82,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct13"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.82,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct13"
+ },
+ "id": "c4",
+ "title": "New agent · Claude opus high · m13",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (82% left, resets in 3h); weekly 6% of 90% · m13 · new · quota 5-hour 82% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m01",
+ "machineName": "m01",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 34,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 34,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct1"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "short",
+ "coverage": 0.76,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct1"
+ },
+ "id": "c5",
+ "title": "New agent · Claude opus high · m01",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 45% of the 5-hour window (34% left, resets in 3h); weekly 6% of 90% · m01 · new · quota 5-hour 34% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m03",
+ "machineName": "m03",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 42,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 42,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct3"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "short",
+ "coverage": 0.93,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct3"
+ },
+ "id": "c6",
+ "title": "New agent · Claude opus high · m03",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 45% of the 5-hour window (42% left, resets in 3h); weekly 6% of 90% · m03 · new · quota 5-hour 42% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m00",
+ "machineName": "m00",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 30,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 30,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct0"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct0"
+ },
+ "id": "c7",
+ "title": "New agent · Claude sonnet medium · m00",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (30% left, resets in 3h); weekly 4% of 90% · m00 · new · quota 5-hour 30% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m02",
+ "machineName": "m02",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 38,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 38,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct2"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.27,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct2"
+ },
+ "id": "c8",
+ "title": "New agent · Claude sonnet medium · m02",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (38% left, resets in 3h); weekly 4% of 90% · m02 · new · quota 5-hour 38% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m04",
+ "machineName": "m04",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 46,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 46,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct4"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.53,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct4"
+ },
+ "id": "c9",
+ "title": "New agent · Claude sonnet medium · m04",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (46% left, resets in 3h); weekly 4% of 90% · m04 · new · quota 5-hour 46% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m06",
+ "machineName": "m06",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 54,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 54,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct6"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.8,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct6"
+ },
+ "id": "c10",
+ "title": "New agent · Claude sonnet medium · m06",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (54% left, resets in 3h); weekly 4% of 90% · m06 · new · quota 5-hour 54% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "m08",
+ "machineName": "m08",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 62,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 62,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct8"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 2.07,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct8"
+ },
+ "id": "c11",
+ "title": "New agent · Claude sonnet medium · m08",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (62% left, resets in 3h); weekly 4% of 90% · m08 · new · quota 5-hour 62% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "m05",
+ "machineName": "m05",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "quota": {
+ "known": true,
+ "leftPercent": 50,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 50,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "acct5"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 1.11,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct5"
+ },
+ "id": "c0",
+ "title": "New agent · Claude opus high · m05",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (50% left, resets in 3h); weekly 6% of 90% · m05 · new · quota 5-hour 50% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "medium",
+ "risk": "low",
+ "why": "API change.",
+ "size": "medium"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "m05",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · m05",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (50% left, resets in 3h); weekly 6% of 90% · m05 · new · quota 5-hour 50% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.11,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct5"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "m07",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · m07",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (58% left, resets in 3h); weekly 6% of 90% · m07 · new · quota 5-hour 58% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.29,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct7"
+ }
+ },
+ {
+ "id": "c2",
+ "kind": "new",
+ "machineId": "m09",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · m09",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (66% left, resets in 3h); weekly 6% of 90% · m09 · new · quota 5-hour 66% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.47,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct9"
+ }
+ },
+ {
+ "id": "c3",
+ "kind": "new",
+ "machineId": "m11",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · m11",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (74% left, resets in 3h); weekly 6% of 90% · m11 · new · quota 5-hour 74% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.64,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct11"
+ }
+ },
+ {
+ "id": "c4",
+ "kind": "new",
+ "machineId": "m13",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · m13",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · fits: needs about 45% of the 5-hour window (82% left, resets in 3h); weekly 6% of 90% · m13 · new · quota 5-hour 82% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.82,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct13"
+ }
+ },
+ {
+ "id": "c5",
+ "kind": "new",
+ "machineId": "m01",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · m01",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 45% of the 5-hour window (34% left, resets in 3h); weekly 6% of 90% · m01 · new · quota 5-hour 34% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "short",
+ "coverage": 0.76,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct1"
+ }
+ },
+ {
+ "id": "c6",
+ "kind": "new",
+ "machineId": "m03",
+ "engine": "claude",
+ "model": "opus",
+ "effort": "high",
+ "quality": 3,
+ "cost": 3,
+ "title": "New agent · Claude opus high · m03",
+ "label": "New agent · Claude opus high · strength 3, cost 3 · short: needs about 45% of the 5-hour window (42% left, resets in 3h); weekly 6% of 90% · m03 · new · quota 5-hour 42% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "short",
+ "coverage": 0.93,
+ "effectiveCost": 3,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 45,
+ "weekly": 6
+ },
+ "account": "acct3"
+ }
+ },
+ {
+ "id": "c7",
+ "kind": "new",
+ "machineId": "m00",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · m00",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (30% left, resets in 3h); weekly 4% of 90% · m00 · new · quota 5-hour 30% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct0"
+ }
+ },
+ {
+ "id": "c8",
+ "kind": "new",
+ "machineId": "m02",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · m02",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (38% left, resets in 3h); weekly 4% of 90% · m02 · new · quota 5-hour 38% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.27,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct2"
+ }
+ },
+ {
+ "id": "c9",
+ "kind": "new",
+ "machineId": "m04",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · m04",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (46% left, resets in 3h); weekly 4% of 90% · m04 · new · quota 5-hour 46% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.53,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct4"
+ }
+ },
+ {
+ "id": "c10",
+ "kind": "new",
+ "machineId": "m06",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · m06",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (54% left, resets in 3h); weekly 4% of 90% · m06 · new · quota 5-hour 54% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 1.8,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct6"
+ }
+ },
+ {
+ "id": "c11",
+ "kind": "new",
+ "machineId": "m08",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · m08",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (62% left, resets in 3h); weekly 4% of 90% · m08 · new · quota 5-hour 62% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2.07,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "acct8"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "a task naming a repository leaves out a member in another",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "New agent · Claude sonnet medium · a",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "d",
+ "machineName": "d",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "d"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [
+ "Its last task here was lost."
+ ],
+ "load": {
+ "agents": 2,
+ "freeMemoryBytes": 8000000000,
+ "hasFolder": true
+ },
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "d"
+ },
+ "id": "c1",
+ "title": "New agent · Claude sonnet medium · d",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · Its last task here was lost. · d · new · has the task folder · 2 agents running · 8.0 GB memory free · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ }
+ ],
+ "excluded": [
+ {
+ "title": "Zed · Claude sonnet medium · b",
+ "reason": "It works in another repository, so it would build this in that repository's worktree. A new agent starts in this one.",
+ "machine": "b"
+ },
+ {
+ "title": "New agent · Claude sonnet medium · c",
+ "reason": "Machine is offline.",
+ "machine": "c"
+ }
+ ],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "New agent · Claude sonnet medium · a",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "medium",
+ "risk": "low",
+ "why": "API change.",
+ "size": "medium"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · a",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "a"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "d",
+ "engine": "claude",
+ "model": "sonnet",
+ "effort": "medium",
+ "quality": 2,
+ "cost": 2,
+ "title": "New agent · Claude sonnet medium · d",
+ "label": "New agent · Claude sonnet medium · strength 2, cost 2 · fits: needs about 30% of the 5-hour window (80% left, resets in 3h); weekly 4% of 90% · Its last task here was lost. · d · new · has the task folder · 2 agents running · 8.0 GB memory free · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 2.67,
+ "effectiveCost": 2,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 30,
+ "weekly": 4
+ },
+ "account": "d"
+ }
+ }
+ ],
+ "excluded": [
+ {
+ "title": "Zed · Claude sonnet medium · b",
+ "reason": "It works in another repository, so it would build this in that repository's worktree. A new agent starts in this one."
+ },
+ {
+ "title": "New agent · Claude sonnet medium · c",
+ "reason": "Machine is offline."
+ }
+ ],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "a person asked for a local model",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "claude",
+ "model": "default",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": false,
+ "leftPercent": null,
+ "resetsAt": null
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "gridModel": "kimi-k3",
+ "gridName": "swarm-0123456789ab",
+ "gridLabel": "Kimi K3",
+ "gridKind": "api",
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 0,
+ "weekly": 0
+ },
+ "account": "local:swarm-0123456789ab:kimi-k3"
+ },
+ "id": "c0",
+ "title": "New agent · Claude on Kimi K3 (API) · b",
+ "label": "New agent · Claude on Kimi K3 (API) · strength 1, cost 1 · fits: a local model on the Swarm's grid uses no subscription · b · new · quota unknown"
+ },
+ {
+ "kind": "new",
+ "machineId": "m1",
+ "machineName": "remote-1",
+ "engine": "claude",
+ "model": "default",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": false,
+ "leftPercent": null,
+ "resetsAt": null
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "gridModel": "qwen3",
+ "gridName": "swarm-0123456789ab",
+ "gridLabel": "Qwen 3",
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 0,
+ "weekly": 0
+ },
+ "account": "local:swarm-0123456789ab:qwen3"
+ },
+ "id": "c1",
+ "title": "New agent · Claude on Qwen 3 (local) · remote-1",
+ "label": "New agent · Claude on Qwen 3 (local) · strength 1, cost 1 · fits: a local model on the Swarm's grid uses no subscription · remote-1 · new · quota unknown"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "b",
+ "machineName": "b",
+ "engine": "claude",
+ "model": "default",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": false,
+ "leftPercent": null,
+ "resetsAt": null
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "gridModel": "kimi-k3",
+ "gridName": "swarm-0123456789ab",
+ "gridLabel": "Kimi K3",
+ "gridKind": "api",
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 0,
+ "weekly": 0
+ },
+ "account": "local:swarm-0123456789ab:kimi-k3"
+ },
+ "id": "c0",
+ "title": "New agent · Claude on Kimi K3 (API) · b",
+ "label": "New agent · Claude on Kimi K3 (API) · strength 1, cost 1 · fits: a local model on the Swarm's grid uses no subscription · b · new · quota unknown"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "low",
+ "risk": "low",
+ "why": "API change.",
+ "size": "medium",
+ "kind": "docs",
+ "local": true
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "b",
+ "engine": "claude",
+ "model": "default",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "title": "New agent · Claude on Kimi K3 (API) · b",
+ "label": "New agent · Claude on Kimi K3 (API) · strength 1, cost 1 · fits: a local model on the Swarm's grid uses no subscription · b · new · quota unknown",
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 0,
+ "weekly": 0
+ },
+ "account": "local:swarm-0123456789ab:kimi-k3"
+ },
+ "gridModel": "kimi-k3",
+ "gridName": "swarm-0123456789ab"
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "m1",
+ "engine": "claude",
+ "model": "default",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "title": "New agent · Claude on Qwen 3 (local) · remote-1",
+ "label": "New agent · Claude on Qwen 3 (local) · strength 1, cost 1 · fits: a local model on the Swarm's grid uses no subscription · remote-1 · new · quota unknown",
+ "fit": {
+ "status": "fits",
+ "coverage": null,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 0,
+ "weekly": 0
+ },
+ "account": "local:swarm-0123456789ab:qwen3"
+ },
+ "gridModel": "qwen3",
+ "gridName": "swarm-0123456789ab"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "a named model the catalog does not list",
+ "choice": {
+ "shown": [
+ {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "claude-opus-6",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [
+ "The catalog does not rate this model."
+ ],
+ "unrated": true,
+ "fit": {
+ "status": "fits",
+ "coverage": 5.33,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 2
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "New agent · Claude claude-opus-6 default · a",
+ "label": "New agent · Claude claude-opus-6 default · unrated, cost 1 · fits: needs about 15% of the 5-hour window (80% left, resets in 3h); weekly 2% of 90% · The catalog does not rate this model. · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ {
+ "kind": "new",
+ "machineId": "c",
+ "machineName": "c",
+ "engine": "claude",
+ "model": "claude-opus-6",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "c"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [
+ "The catalog does not rate this model."
+ ],
+ "unrated": true,
+ "fit": {
+ "status": "fits",
+ "coverage": 5.33,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 2
+ },
+ "account": "c"
+ },
+ "id": "c1",
+ "title": "New agent · Claude claude-opus-6 default · c",
+ "label": "New agent · Claude claude-opus-6 default · unrated, cost 1 · fits: needs about 15% of the 5-hour window (80% left, resets in 3h); weekly 2% of 90% · The catalog does not rate this model. · c · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "new",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "claude-opus-6",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "new",
+ "known": true,
+ "refusals": [],
+ "notes": [
+ "The catalog does not rate this model."
+ ],
+ "unrated": true,
+ "fit": {
+ "status": "fits",
+ "coverage": 5.33,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 2
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "New agent · Claude claude-opus-6 default · a",
+ "label": "New agent · Claude claude-opus-6 default · unrated, cost 1 · fits: needs about 15% of the 5-hour window (80% left, resets in 3h); weekly 2% of 90% · The catalog does not rate this model. · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ "via": "order",
+ "p": null,
+ "why": "First by strength, then price and quota fit."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "medium",
+ "risk": "low",
+ "why": "API change.",
+ "size": "medium",
+ "model": "claude-opus-6"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "new",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "claude-opus-6",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "title": "New agent · Claude claude-opus-6 default · a",
+ "label": "New agent · Claude claude-opus-6 default · unrated, cost 1 · fits: needs about 15% of the 5-hour window (80% left, resets in 3h); weekly 2% of 90% · The catalog does not rate this model. · a · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 5.33,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 2
+ },
+ "account": "a"
+ }
+ },
+ {
+ "id": "c1",
+ "kind": "new",
+ "machineId": "c",
+ "engine": "claude",
+ "model": "claude-opus-6",
+ "effort": "default",
+ "quality": 1,
+ "cost": 1,
+ "title": "New agent · Claude claude-opus-6 default · c",
+ "label": "New agent · Claude claude-opus-6 default · unrated, cost 1 · fits: needs about 15% of the 5-hour window (80% left, resets in 3h); weekly 2% of 90% · The catalog does not rate this model. · c · new · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 5.33,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 15,
+ "weekly": 2
+ },
+ "account": "c"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "order",
+ "p": null,
+ "belowFloor": false,
+ "why": "First by strength, then price and quota fit."
+ }
+ },
+ {
+ "name": "a named model somebody holds",
+ "choice": {
+ "error": "NO_CANDIDATE",
+ "excluded": [
+ {
+ "title": "Named model",
+ "reason": "\"DeepSeek v4.1\" is shared with the Swarm, but Wren and Ada are on it: an API model takes 4 agents at a time. Assign the work to one of them once it is free, or stop one to free the model."
+ }
+ ]
+ }
+ },
+ {
+ "name": "a named model served by a host now offline",
+ "choice": {
+ "error": "NO_CANDIDATE",
+ "excluded": [
+ {
+ "title": "Named model",
+ "reason": "No candidate runs \"qwen coder\". Share it with the Swarm (Your models), or check its name."
+ }
+ ]
+ }
+ },
+ {
+ "name": "nothing can run",
+ "choice": {
+ "error": "NO_CANDIDATE",
+ "excluded": [
+ {
+ "title": "New agent · Claude sonnet medium · a",
+ "reason": "Machine is offline.",
+ "machine": "a"
+ },
+ {
+ "title": "New agent · Codex default default · b",
+ "reason": "Codex is signed out.",
+ "machine": "b"
+ }
+ ]
+ }
+ },
+ {
+ "name": "an unrated member and a single candidate",
+ "choice": {
+ "shown": [
+ {
+ "kind": "member",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "gpt-x",
+ "effort": "medium",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "working",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "agentId": "m3",
+ "unrated": true,
+ "terminalUnverified": true,
+ "frame": {
+ "title": null,
+ "project": null,
+ "cwd": "/r",
+ "root": "/r",
+ "remote": "github.com/o/r",
+ "branch": null,
+ "updatedAt": null
+ },
+ "fit": {
+ "status": "fits",
+ "coverage": 16,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 5,
+ "weekly": 0.5
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "Member · Claude gpt-x medium · a",
+ "label": "Member · Claude gpt-x medium · unrated, cost 1 · fits: needs about 5% of the 5-hour window (80% left, resets in 3h); weekly 1% of 90% · a · working · last active unknown · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "belowFloor": false
+ },
+ "verdict": {
+ "pick": {
+ "kind": "member",
+ "machineId": "a",
+ "machineName": "a",
+ "engine": "claude",
+ "model": "gpt-x",
+ "effort": "medium",
+ "quality": 1,
+ "cost": 1,
+ "quota": {
+ "known": true,
+ "leftPercent": 80,
+ "resetsAt": null,
+ "windows": [
+ {
+ "name": "5-hour",
+ "leftPercent": 80,
+ "resetsAt": 1010800000
+ },
+ {
+ "name": "weekly",
+ "leftPercent": 90,
+ "resetsAt": 1432000000
+ }
+ ],
+ "account": "a"
+ },
+ "activity": "working",
+ "known": true,
+ "refusals": [],
+ "notes": [],
+ "agentId": "m3",
+ "unrated": true,
+ "terminalUnverified": true,
+ "frame": {
+ "title": null,
+ "project": null,
+ "cwd": "/r",
+ "root": "/r",
+ "remote": "github.com/o/r",
+ "branch": null,
+ "updatedAt": null
+ },
+ "fit": {
+ "status": "fits",
+ "coverage": 16,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 5,
+ "weekly": 0.5
+ },
+ "account": "a"
+ },
+ "id": "c0",
+ "title": "Member · Claude gpt-x medium · a",
+ "label": "Member · Claude gpt-x medium · unrated, cost 1 · fits: needs about 5% of the 5-hour window (80% left, resets in 3h); weekly 1% of 90% · a · working · last active unknown · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)"
+ },
+ "via": "only",
+ "p": null,
+ "why": "Only candidate that can run this task."
+ },
+ "record": {
+ "assessment": {
+ "difficulty": "medium",
+ "risk": "low",
+ "why": "API change.",
+ "size": "small"
+ },
+ "candidates": [
+ {
+ "id": "c0",
+ "kind": "member",
+ "agentId": "m3",
+ "machineId": "a",
+ "engine": "claude",
+ "model": "gpt-x",
+ "effort": "medium",
+ "quality": 1,
+ "cost": 1,
+ "title": "Member · Claude gpt-x medium · a",
+ "label": "Member · Claude gpt-x medium · unrated, cost 1 · fits: needs about 5% of the 5-hour window (80% left, resets in 3h); weekly 1% of 90% · a · working · last active unknown · quota 5-hour 80% left (resets in 3h), weekly 90% left (resets in 5 days)",
+ "fit": {
+ "status": "fits",
+ "coverage": 16,
+ "effectiveCost": 1,
+ "expiring": 0,
+ "spend": {
+ "5-hour": 5,
+ "weekly": 0.5
+ },
+ "account": "a"
+ }
+ }
+ ],
+ "excluded": [],
+ "floor": 1,
+ "notes": false,
+ "pick": "c0",
+ "via": "only",
+ "p": null,
+ "belowFloor": false,
+ "why": "Only candidate that can run this task."
+ }
+ }
+]
diff --git a/cli/src/superTabs/route.spec.ts b/cli/src/superTabs/route.spec.ts
index f39bf5c1d..29109c69c 100644
--- a/cli/src/superTabs/route.spec.ts
+++ b/cli/src/superTabs/route.spec.ts
@@ -1,7 +1,7 @@
// cli/src/superTabs/route.spec.ts
-import { describe, expect, it } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
import { API_BUILDERS, catalogFrom, catalogRow, choose, decide, gridStrength, LOCAL_NONE, OTHER_REPOSITORY, parseAssessment, quotaOf2, recordOf, repoMatch, repositoryKey, strengthOf,
- type Assessment, type Catalog, type Commitment, type MemberFrame, type Probe, type TaskFolder } from './route.js'
+ type Assessment, type Catalog, type Commitment, type MemberFrame, type Probe, type RoutePlugin, type TaskFolder } from './route.js'
const object = (v: unknown) => v as Record<string, unknown>
@@ -699,6 +699,8 @@ describe('ranking by facts', () => {
grid: { strength: 1, models: [{ model: 'kimi k3', strength: 2 }] } })
// Nothing readable is an empty catalog, not a throw.
expect(catalogFrom({})).toEqual({ models: [], grid: { strength: 1, models: [] } })
+ // A served grid with no strength of its own counts as 1; a grid row without a strength is dropped.
+ expect(catalogFrom({ catalog: { models: [], grid: { models: [{ model: 'kimi k3' }, { strength: 2 }] } } }).grid).toEqual({ strength: 1, models: [] })
})
it('rates a model by its exact row, its other effort, the engine\'s default row when launched on it, else unrated', () => {
@@ -712,3 +714,213 @@ describe('ranking by facts', () => {
expect(gridStrength(catalog, 'qwen3:4b', 'Qwen 3 4B')).toBe(1)
})
})
+
+/** Scholes's goals, pieces 3 to 6, each change the ranking; they plug into choose() rather than edit it. These are today's
+ * answers for a fixed set of tasks and machines, captured before the hook existed: with no plug-ins every answer, label and
+ * record must stay byte for byte the same. */
+describe('route answers without plug-ins', () => {
+ const OPUS = { model: 'opus', effort: 'high', quality: 3, cost: 3 } as const
+ const CODEX = { engine: 'codex', model: 'default', effort: 'default', quality: 3, cost: 2 } as const
+ const on = (machine: string, row: Partial<Probe>, quota: Probe['quota'] = windows([80, 3 * H], [90, 5 * D], machine)) =>
+ probe({ machineId: machine, machineName: machine, ...row, quota })
+ const frame: MemberFrame = { title: 'Fix the dial', project: 'openharness', cwd: '/r', root: '/r', remote: 'github.com/o/r', branch: 'fix/dial', updatedAt: NOW - 20 * M }
+ const grid = (patch: Partial<Probe> = {}) => probe({ model: 'default', effort: 'default', quality: 1, cost: 1, quota: { known: false, leftPercent: null, resetsAt: null },
+ gridModel: 'qwen3', gridName: 'swarm-0123456789ab', gridLabel: 'Qwen 3', ...patch })
+ type Args = Parameters<typeof choose>
+ const SCENARIOS: Array<[string, Args]> = [
+ ['mixed members and new agents', [[on('a', OPUS), on('b', {}), on('a', {}, windows([60, 3 * H], [90, 5 * D], 'a')),
+ on('a', { kind: 'member', agentId: 'm1', name: 'Multiply', activity: 'idle', repo: 'same', frame, earlier: [{ group: 'Dial fix', outcome: 'merged' }] }),
+ on('b', { kind: 'member', agentId: 'm2', name: 'Elsewhere', activity: 'idle', repo: 'different', frame: null }),
+ on('a', { model: 'haiku', effort: 'auto', quality: 1, cost: 1 })], policy, a(), NOW]],
+ ['high, large: strong pick short, weaker one fits', [[on('a', OPUS, windows([20, 4 * H], [50, 5 * D], 'A')), on('b', CODEX, windows([5, 4 * H], [60, 3 * D], 'B')),
+ on('c', {}, windows([90, 4 * H], [90, 6 * D], 'C'))], policy, a({ difficulty: 'high', size: 'large' }), NOW]],
+ ['low, small: weekly day budget and an expiring window', [[on('a', OPUS, windows([70, 20 * M], [10, 6 * D], 'A')), on('b', OPUS, windows([40, 4 * H], [80, 2 * D], 'B')),
+ on('c', CODEX, windows(null, [30, 6 * D], 'C'))], policy, a({ difficulty: 'low', size: 'small', kind: 'docs' }), NOW]],
+ ['picks still at work hold their quota', [[on('a', OPUS, windows([50, 3 * H], [50, 5 * D], 'A')), on('b', OPUS, windows([45, 3 * H], [50, 5 * D], 'B'))],
+ policy, a({ difficulty: 'high' }), NOW, [{ account: 'A', spend: { '5-hour': 30, weekly: 4 }, size: 'medium', createdAt: NOW - 10 * M }]]],
+ ['metered, unknown and unreadable quota', [[on('a', CODEX, { known: true, leftPercent: null, resetsAt: null, metered: true }),
+ on('b', CODEX, { known: false, leftPercent: null, resetsAt: null, why: 'signed out of usage' }), on('c', CODEX, { known: true, leftPercent: 40, resetsAt: NOW + 2 * H }),
+ on('d', CODEX, { known: true, leftPercent: 40, resetsAt: null, from: 'Team Mac' })], policy, a(), NOW]],
+ ['more machines than rows shown', [Array.from({ length: 15 }, (_, i) => on(`m${String(i).padStart(2, '0')}`, i % 2 ? OPUS : {},
+ windows([30 + i * 4, 3 * H], [90, 5 * D], `acct${i}`))), policy, a(), NOW]],
+ ['a task naming a repository leaves out a member in another', [[on('a', {}), on('b', { kind: 'member', agentId: 'm2', name: 'Zed', activity: 'idle', repo: 'different' }),
+ on('c', { refusals: ['Machine is offline.'] }), on('d', { load: { agents: 2, freeMemoryBytes: 8e9, hasFolder: true }, notes: ['Its last task here was lost.'] })],
+ policy, a({ needs: { tools: ['git'], devices: [], cwd: '/repo' } }), NOW]],
+ ['a person asked for a local model', [[on('a', OPUS), grid(), grid({ machineId: 'b', machineName: 'b', gridModel: 'kimi-k3', gridLabel: 'Kimi K3', gridKind: 'api' })],
+ { ...policy, grid: { strength: 1, models: [{ model: 'kimi k3', strength: 2 }] } }, a({ local: true, difficulty: 'low', kind: 'docs' }), NOW]],
+ ['a named model the catalog does not list', [[on('a', OPUS), on('b', CODEX), on('c', {})], policy, a({ model: 'claude-opus-6' }), NOW]],
+ ['a named model somebody holds', [[on('a', OPUS)], policy, a({ model: 'deepseek 4.1' }), NOW,
+ [], [{ model: 'deepseek/deepseek-v4.1', label: 'DeepSeek v4.1', kind: 'api', holders: ['Wren', 'Ada'] }]]],
+ ['a named model served by a host now offline', [[on('a', OPUS)], policy, a({ model: 'qwen coder' }), NOW, [], [],
+ [{ title: 'Qwen Coder 32B', reason: 'Its host Rig is offline, so an agent on it would never start.' }]]],
+ ['nothing can run', [[on('a', { refusals: ['Machine is offline.'] }), on('b', CODEX, undefined)].map((p, i) => i ? { ...p, refusals: ['Codex is signed out.'] } : p),
+ policy, a(), NOW]],
+ ['an unrated member and a single candidate', [[on('a', { kind: 'member', agentId: 'm3', model: 'gpt-x', unrated: true, quality: 1, cost: 1, activity: 'working',
+ terminalUnverified: true, frame: { ...frame, title: null, project: null, branch: null, updatedAt: null } })], policy, a({ size: 'small' }), NOW]],
+ ]
+ const answer = ([name, args]: [string, Args]) => {
+ const choice = choose(...args)
+ if ('error' in choice) return { name, choice }
+ const verdict = decide(choice)
+ return { name, choice, verdict, record: recordOf(choice, verdict, args[2]) }
+ }
+
+ it('answers every scenario exactly as before the hook', async () => {
+ await expect(`${JSON.stringify(SCENARIOS.map(answer), null, 1)}\n`).toMatchFileSnapshot('./__snapshots__/route.answers.json')
+ })
+ it('answers the same with an empty plug-in list, and with plug-ins that have nothing to say', () => {
+ const before = JSON.stringify(SCENARIOS.map(answer))
+ const silent: RoutePlugin[] = [{ name: 'Quiet' }, { name: 'Nothing to add', candidates: () => [], adjust: () => null }]
+ for (const plugins of [[], silent]) {
+ const full = ([probes, catalog, task, now, open = [], held = [], offline = []]: Args): Args => [probes, catalog, task, now, open, held, offline, plugins]
+ expect(JSON.stringify(SCENARIOS.map(([name, args]) => answer([name, full(args)])))).toBe(before)
+ }
+ })
+})
+
+/** The hook pieces 3 to 6 plug into: an ordered list of plug-ins, each able to add candidates and to adjust a candidate's place
+ * with a reason people read. */
+describe('routing plug-ins', () => {
+ const OPUS = { model: 'opus', effort: 'high', quality: 3, cost: 3 } as const
+ const on = (machine: string, row: Partial<Probe> = {}) => probe({ machineId: machine, machineName: machine, ...OPUS, quota: windows([80, 3 * H], [90, 5 * D], machine), ...row })
+ const route = (probes: Probe[], plugins: RoutePlugin[], task: Partial<Assessment> = {}) => choose(probes, policy, a(task), NOW, [], [], [], plugins)
+ const titles = (r: ReturnType<typeof choose>) => ok(r).shown.map(s => s.machineName)
+
+ it('a plug-in\'s cost adjustment changes the order, and its reason shows on the candidate, in the label and in the record', () => {
+ expect(titles(route([on('a'), on('b')], []))).toEqual(['a', 'b'])
+ const measured: RoutePlugin = { name: 'Measured cost', adjust: c => c.machineId === 'b' ? { cost: -1, reason: 'its last 5 builds here cost half the catalog price' } : null }
+ const r = ok(route([on('a'), on('b')], [measured]))
+ expect(titles(r)).toEqual(['b', 'a'])
+ const reason = 'Measured cost: its last 5 builds here cost half the catalog price'
+ expect(r.shown[0]!.notes).toEqual([reason])
+ expect(r.shown[0]!.label).toContain(reason)
+ expect(r.shown[1]!.notes).toEqual([])
+ const verdict = decide(r)
+ expect(verdict.why).toBe('First by strength, then price and quota fit, with the plug-ins\' adjustments in each candidate\'s notes.')
+ const record = recordOf(r, verdict, a()) as { candidates: Array<{ label: string; fit: { effectiveCost: number }; quality: number; cost: number }> }
+ // What the candidate is and what its quota costs are recorded as measured; only the order and the reason change.
+ expect(record.candidates[0]).toMatchObject({ quality: 3, cost: 3, fit: { effectiveCost: ok(route([on('b')], [])).shown[0]!.fit.effectiveCost } })
+ expect(record.candidates[0]!.label).toContain(reason)
+ })
+ it('a strength adjustment ranks before price; adjustments of several plug-ins add up in their order', () => {
+ const weaker = on('s', { model: 'sonnet', effort: 'medium', quality: 2, cost: 2 })
+ const results: RoutePlugin = { name: 'Results', adjust: c => c.model === 'sonnet' ? { strength: 0.75, reason: 'merged 9 of its last 10 docs tasks' } : null }
+ const fit: RoutePlugin = { name: 'Machine fit', adjust: c => c.model === 'sonnet' ? { strength: 0.5, reason: 'has the task folder' } : null }
+ expect(titles(route([on('a'), weaker], [results]))).toEqual(['a', 's'])
+ const r = ok(route([on('a'), weaker], [results, fit]))
+ expect(titles(r)).toEqual(['s', 'a'])
+ expect(r.shown[0]!.notes).toEqual(['Results: merged 9 of its last 10 docs tasks', 'Machine fit: has the task folder'])
+ expect(r.shown[0]!.quality).toBe(2)
+ })
+ it('a refusal leaves a candidate out with the plug-in\'s reason; refusing every one is no candidate', () => {
+ const tooSmall: RoutePlugin = { name: 'Machine fit', adjust: c => c.machineId === 'a' ? { refuse: true, reason: 'has 1 GB free, the task needs 4 GB' } : null }
+ const r = ok(route([on('a'), on('b')], [tooSmall]))
+ expect(titles(r)).toEqual(['b'])
+ expect(r.excluded).toEqual([{ title: 'New agent · Claude opus high · a', reason: 'Machine fit: has 1 GB free, the task needs 4 GB', machine: 'a' }])
+ expect(decide(r).via).toBe('only')
+ const none = route([on('a')], [tooSmall])
+ expect(none).toEqual({ error: 'NO_CANDIDATE', excluded: [{ title: 'New agent · Claude opus high · a', reason: 'Machine fit: has 1 GB free, the task needs 4 GB', machine: 'a' }] })
+ })
+ // Lead, 10-31: a plug-in can never bring back a choice the route rules out. The route's filters are facts of a machine and
+ // engine (offline, engine signed out, tools, devices, a stalled machine), carried as refusals on its probes, and choose()'s own
+ // rules (catalog rows offered, a named or local model, the repository); the owner's rules and review limits are no longer the
+ // route's (project instructions, phase 4).
+ it('a plug-in cannot bring back a choice the route rules out: an added candidate stands on a machine and engine the route probed, with their refusals and notes', () => {
+ const given = [on('a', { notes: ['Its last task here was lost.'] }), on('b', { refusals: ['Machine is offline.'] }),
+ on('k', { kind: 'member', agentId: 'k1', name: 'Kai', activity: 'idle' })]
+ const sonnet = { model: 'sonnet', effort: 'medium', quality: 2, cost: 2 } as const
+ const sneaky: RoutePlugin = { name: 'More models', candidates: () => [
+ on('a', { ...sonnet, quota: windows([100, 3 * H], [100, 5 * D], 'fresh') }),
+ on('b', sonnet),
+ on('a', { engine: 'codex', model: 'default', effort: 'default', cost: 2 }),
+ on('k', sonnet),
+ on('z', sonnet),
+ on('a', { kind: 'member', agentId: 'ghost', name: 'Ghost', activity: 'idle' }),
+ on('a', { model: 'haiku', effort: 'auto', quality: 1, cost: 1 }),
+ ] }
+ const r = ok(choose(given, policy, a(), NOW, [], [], [], [sneaky]))
+ // An idle member before a new agent at equal strength and price, as without plug-ins.
+ expect(r.shown.map(s => s.title)).toEqual(['Kai · Claude opus high · k', 'New agent · Claude opus high · a', 'New agent · Claude sonnet medium · a'])
+ // The added Sonnet on a keeps a's note and quota reading, not its own.
+ expect(r.shown[2]).toMatchObject({ notes: ['Its last task here was lost.'], quota: given[0]!.quota })
+ expect(r.excluded).toEqual([
+ { title: 'New agent · Claude opus high · b', reason: 'Machine is offline.', machine: 'b' },
+ { title: 'New agent · Claude sonnet medium · b', reason: 'Machine is offline.', machine: 'b' },
+ { title: 'New agent · Codex default default · a', reason: 'More models: this route offers no new agent on Codex on a, so one added there is left out.', machine: 'a' },
+ { title: 'New agent · Claude sonnet medium · k', reason: 'More models: this route offers no new agent on Claude on k, so one added there is left out.', machine: 'k' },
+ { title: 'New agent · Claude sonnet medium · z', reason: 'More models: this route offers no new agent on Claude on z, so one added there is left out.', machine: 'z' },
+ { title: 'Ghost · Claude opus high · a', reason: 'More models: a plug-in adds new agents only; it adjusts the agents the route found.', machine: 'a' },
+ ].sort((x, y) => (x.reason === 'Machine is offline.' ? 0 : 1) - (y.reason === 'Machine is offline.' ? 0 : 1)))
+ // Not offered by default, so left out as any Haiku row is, unless a person names it.
+ expect(r.shown.some(s => s.model === 'haiku')).toBe(false)
+ // Its own refusals and notes add to the machine's, once each; the machine's load goes with it; a model on the grid keeps its
+ // own quota, as a local probe does (routeCommand.ts localProbes).
+ const load = { agents: 1, freeMemoryBytes: 8e9, hasFolder: true }
+ const own: RoutePlugin = { name: 'Own', candidates: () => [
+ on('c', { ...sonnet, refusals: ['No room.'], notes: ['Base note.', 'Own note.'] }),
+ on('c', { ...sonnet, model: 'default', effort: 'default', quality: 1, cost: 1, gridModel: 'qwen3', gridName: 'swarm-1', quota: { known: false, leftPercent: null, resetsAt: null } }),
+ ] }
+ const withOwn = ok(choose([on('c', { notes: ['Base note.'], load })], policy, a(), NOW, [], [], [], [own]))
+ expect(withOwn.excluded).toEqual([{ title: 'New agent · Claude sonnet medium · c', reason: 'No room.', machine: 'c' }])
+ expect(withOwn.shown.map(s => [s.gridModel ?? s.model, s.notes, s.load, s.quota.known])).toEqual([
+ ['opus', ['Base note.'], load, true], ['qwen3', ['Base note.'], load, false]])
+ })
+ it('a plug-in adds candidates, which every rule then treats like the others; a later plug-in sees an earlier one\'s', () => {
+ const seen: string[][] = []
+ const given = [on('a'), on('x', { model: 'sonnet', effort: 'medium', quality: 2, cost: 2 })]
+ const extra: RoutePlugin = { name: 'More models', candidates: probes => [on('x', {}),
+ // A catalog row not offered by default stays out unless a person names it, as for any candidate.
+ on('x', { model: 'haiku', effort: 'auto', quality: 1, cost: 1 })].filter(() => probes.length > 0) }
+ const watch: RoutePlugin = { name: 'Watch', candidates: probes => { seen.push(probes.map(p => `${p.model} on ${p.machineId}`)); return [] } }
+ const r = ok(route(given, [extra, watch]))
+ expect(r.shown.map(s => `${s.model} on ${s.machineName}`)).toEqual(['opus on a', 'opus on x', 'sonnet on x'])
+ expect(seen).toEqual([['opus on a', 'sonnet on x', 'opus on x', 'haiku on x']])
+ // A person naming a model still considers that model alone.
+ expect(titles(route(given, [extra], { model: 'haiku' }))).toEqual(['x'])
+ })
+ it('a plug-in sees the task, the time, the catalog, the picks at work and each candidate\'s fit', () => {
+ const contexts: unknown[] = [], fits: string[] = []
+ const look: RoutePlugin = { name: 'Look', candidates: (_p, context) => { contexts.push(context); return [] }, adjust: (c, context) => { contexts.push(context); fits.push(c.fit.status); return null } }
+ const open: Commitment[] = [{ account: 'z', spend: { weekly: 1 }, size: 'small', createdAt: NOW }]
+ choose([on('a')], policy, a({ kind: 'docs' }), NOW, open, [], [], [look])
+ expect(contexts).toEqual([{ assessment: a({ kind: 'docs' }), now: NOW, catalog: policy, open }, { assessment: a({ kind: 'docs' }), now: NOW, catalog: policy, open }])
+ expect(fits).toEqual(['fits'])
+ })
+ afterEach(() => { vi.restoreAllMocks() })
+ it('a plug-in that runs too long is skipped whole: the route answers as without it and says so', () => {
+ let clock = 0
+ vi.spyOn(performance, 'now').mockImplementation(() => clock)
+ const plain = ok(route([on('a'), on('b')], []))
+ const slowAdjust: RoutePlugin = { name: 'Slow', adjust: c => { clock += 150; return { cost: -5, reason: `looked at ${c.machineId}` } } }
+ const slowAdd: RoutePlugin = { name: 'Slow add', candidates: () => { clock += 201; return [on('a', { model: 'sonnet', effort: 'medium', quality: 2, cost: 2 })] } }
+ const quick: RoutePlugin = { name: 'Quick', adjust: () => { clock += 10; return null } }
+ const { warnings, ...rest } = ok(route([on('a'), on('b')], [slowAdd, slowAdjust, quick]))
+ expect(rest).toEqual(plain)
+ expect(warnings).toEqual(['Slow add', 'Slow'].map(n => `The routing plug-in "${n}" was skipped: it took longer than 200 ms. The route is ranked without it.`))
+ })
+ it('plug-ins run in their list\'s fixed order, and the same route answers the same every time', () => {
+ const one: RoutePlugin = { name: 'One', adjust: () => ({ cost: 0.5, reason: 'first' }) }
+ const two: RoutePlugin = { name: 'Two', adjust: () => ({ cost: -0.5, reason: 'second' }) }
+ const r = ok(route([on('a'), on('b')], [one, two]))
+ expect(r.shown[0]!.notes).toEqual(['One: first', 'Two: second'])
+ expect(ok(route([on('a'), on('b')], [two, one])).shown[0]!.notes).toEqual(['Two: second', 'One: first'])
+ expect(JSON.stringify(route([on('a'), on('b')], [one, two]))).toBe(JSON.stringify(r))
+ })
+ it('a plug-in that throws or answers what cannot be ranked is skipped whole and named in a warning, never with its error', () => {
+ const plain = ok(route([on('a'), on('b')], []))
+ const half: RoutePlugin = { name: 'Half', adjust: c => { if (c.machineId === 'b') throw new Error('token=secret at /Users/x'); return { cost: -5, reason: 'x' } } }
+ const nan: RoutePlugin = { name: 'NaN', adjust: () => ({ cost: Number.NaN, reason: 'x' }) }
+ const blank: RoutePlugin = { name: 'Blank', adjust: () => ({ strength: 1, reason: ' ' }) }
+ const broken: RoutePlugin = { name: 'Broken', candidates: () => { throw new Error('secret') } }
+ const junk: RoutePlugin = { name: 'Junk', candidates: () => [{ machineId: 'q' } as Probe] }
+ const notList: RoutePlugin = { name: 'Not a list', candidates: () => null as unknown as Probe[] }
+ const r = ok(route([on('a'), on('b')], [half, nan, blank, broken, junk, notList]))
+ const { warnings, ...rest } = r
+ expect(rest).toEqual(plain)
+ // Candidates are gathered before any is judged, so those plug-ins are named first.
+ expect(warnings).toEqual(['Broken', 'Junk', 'Not a list', 'Half', 'NaN', 'Blank'].map(n => `The routing plug-in "${n}" was skipped: it failed. The route is ranked without it.`))
+ expect(JSON.stringify(r)).not.toContain('secret')
+ // Nothing can run: the warning still goes with the answer.
+ expect(route([on('a', { refusals: ['Machine is offline.'] })], [broken])).toMatchObject({ error: 'NO_CANDIDATE', warnings: [expect.stringContaining('"Broken"')] })
+ })
+})
diff --git a/cli/src/superTabs/route.ts b/cli/src/superTabs/route.ts
index 20e56ad60..ac2038013 100644
--- a/cli/src/superTabs/route.ts
+++ b/cli/src/superTabs/route.ts
@@ -72,8 +72,101 @@ export interface Shown extends Probe { id: string; title: string; label: string;
/** A candidate left out and why; [machine] names its machine, absent for a model that is not offered anywhere. */
export interface Excluded { title: string; reason: string; machine?: string }
/** `floor` and `belowFloor` are what the decision log still takes (backend routeRecord.ts): there is no floor, so 1 and false.
- * `short` says when the pick is not expected to cover the task on its quota. */
-export interface Choice { shown: Shown[]; excluded: Excluded[]; floor: 1; belowFloor: false; short?: string }
+ * `short` says when the pick is not expected to cover the task on its quota. `adjusted`: a plug-in moved a candidate or left
+ * one out ([RoutePlugin]). `warnings`: the plug-ins that failed and were left out of this route. */
+export interface Choice { shown: Shown[]; excluded: Excluded[]; floor: 1; belowFloor: false; short?: string; adjusted?: true; warnings?: string[] }
+export type NoCandidate = { error: 'NO_CANDIDATE'; excluded: Excluded[]; warnings?: string[] }
+
+/** What a plug-in sees of the route it ranks: the task, the time, the catalog, and the picks still at work. */
+export interface RouteContext { readonly assessment: Assessment; readonly now: number; readonly catalog: Catalog; readonly open: readonly Commitment[] }
+/** A plug-in's word on one candidate. `strength` and `cost` shift the two terms the order ranks by (stronger first, then
+ * cheaper in effect), in the catalog's units: +0.5 strength or -1 cost moves it up. Neither changes what the candidate is
+ * shown and recorded as (its strength, cost and fit stay as measured). `refuse` leaves it out, only for a fact that it cannot
+ * run there. `reason` is what people read, on the candidate's notes as "name: reason", so it holds only what every reader of
+ * the Swarm's route log may see: never one member's raw usage or anything private to a person or chat. */
+export interface Adjustment { reason: string; strength?: number; cost?: number; refuse?: true }
+/** One piece of the ranking that is not the route's own (Scholes's goals, pieces 3 to 6: measured cost and results, more model
+ * candidates, machine fit, window pull). Plug-ins run in their list's order: each `candidates` call sees the probes so far,
+ * earlier plug-ins' among them, and returns more, which every rule of [choose] then treats like the others; `adjust` judges
+ * each candidate that can run, after its quota fit is known. A plug-in must be pure and synchronous: what it needs from
+ * outside is read before the route and given to it when it is made. One that throws, or answers what cannot be ranked, is
+ * left out of the whole route, so it never judges some candidates and not others, and the answer names it. */
+export interface RoutePlugin {
+ readonly name: string
+ candidates?(probes: readonly Probe[], context: RouteContext): Probe[]
+ adjust?(candidate: Readonly<Probe & { fit: Fit }>, context: RouteContext): Adjustment | null
+}
+/** The order's two adjustable terms for one candidate ([compare]); with no plug-in they are its strength and effective cost. */
+interface Ranked { strength: number; cost: number }
+/** How long one plug-in may take over a route's candidates, per step. Plug-ins are pure and synchronous, so a route of a few
+ * dozen candidates takes them well under a millisecond; one over this is doing work it should have done before the route
+ * (Lead, 10-31: a plug-in that runs too long is skipped). A plug-in that never returns cannot be stopped from inside: that is
+ * why they must be synchronous and read nothing. */
+export const PLUGIN_BUDGET_MS = 200
+export const pluginSkipped = (name: string, why: string) => `The routing plug-in "${cut(name, 80)}" was skipped: ${why}. The route is ranked without it.`
+const FAILED = 'it failed', SLOW = `it took longer than ${PLUGIN_BUDGET_MS} ms`
+/** Runs [step] for one plug-in, timed: its answer, or why it is skipped. Its error text is never kept, since it may hold
+ * anything (a path, a token). */
+function timed<T>(step: () => T, valid: (answer: T) => boolean): { answer: T } | { why: string } {
+ const started = performance.now()
+ try {
+ const answer = step()
+ if (performance.now() - started > PLUGIN_BUDGET_MS) return { why: SLOW }
+ return valid(answer) ? { answer } : { why: FAILED }
+ } catch { return { why: FAILED } }
+}
+const isProbe = (p: unknown): p is Probe => {
+ const v = object(p)
+ return typeof v.machineId === 'string' && typeof v.machineName === 'string' && ENGINES.includes(String(v.engine)) && typeof v.model === 'string'
+ && typeof v.effort === 'string' && finite(v.quality) && finite(v.cost) && Array.isArray(v.refusals) && Array.isArray(v.notes) && !!v.quota
+}
+const baseKey = (p: Pick<Probe, 'machineId' | 'engine'>) => `${p.machineId}\0${p.engine}`
+/** A plug-in's candidate as the route may consider it: a new agent standing on a machine and engine the route probed itself
+ * ([bases]), with that probe's refusals, notes, load and quota reading (a model on the grid keeps its own quota, as
+ * routeCommand.ts localProbes does), so it can never bring back a choice the route rules out. Otherwise why it is left out. */
+function anchored(added: Probe, bases: Map<string, Probe>, name: string): Probe | Excluded {
+ const out = (reason: string): Excluded => ({ title: titleOf(added), reason: `${cut(name, 80)}: ${reason}`, machine: added.machineName })
+ if (added.kind !== 'new') return out('a plug-in adds new agents only; it adjusts the agents the route found.')
+ const base = bases.get(baseKey(added))
+ if (!base) return out(`this route offers no new agent on ${ENGINE[added.engine]} on ${added.machineName}, so one added there is left out.`)
+ const { agentId: _a, name: _n, frame: _f, repo: _r, earlier: _e, terminalUnverified: _t, ...own } = added
+ const more = (theirs: string[], ours: string[]) => [...theirs, ...ours.filter(x => !theirs.includes(x))]
+ return { ...own, kind: 'new', machineName: base.machineName, activity: base.activity, known: base.known, ...(base.load ? { load: base.load } : {}),
+ quota: added.gridModel ? added.quota : base.quota, refusals: more(base.refusals, added.refusals), notes: more(base.notes, added.notes) }
+}
+/** The probes with each plug-in's added candidates ([anchored]), in the plug-ins' order, and those left out. A plug-in whose
+ * answer is not a list of probes, or that runs too long, adds nothing and is named in [warnings]. */
+function withPluginCandidates(given: Probe[], plugins: readonly RoutePlugin[], context: RouteContext, warnings: string[]): { probes: Probe[]; out: Excluded[] } {
+ const bases = new Map<string, Probe>()
+ for (const p of given) if (p.kind === 'new' && !p.gridModel && !bases.has(baseKey(p))) bases.set(baseKey(p), p)
+ let probes = given
+ const out: Excluded[] = []
+ for (const plugin of plugins) {
+ if (!plugin.candidates) continue
+ const run = timed(() => plugin.candidates!(probes, context) as unknown, added => Array.isArray(added) && added.every(isProbe))
+ if ('why' in run) { warnings.push(pluginSkipped(plugin.name, run.why)); continue }
+ const placed = (run.answer as Probe[]).map(p => anchored(p, bases, plugin.name))
+ probes = [...probes, ...placed.filter((p): p is Probe => 'engine' in p)]
+ out.push(...placed.filter((p): p is Excluded => !('engine' in p)))
+ }
+ return { probes, out }
+}
+const validAdjustment = (x: Adjustment | null): x is Adjustment | null => x === null || (typeof x === 'object' && typeof x.reason === 'string'
+ && !!x.reason.trim() && (x.strength === undefined || finite(x.strength)) && (x.cost === undefined || finite(x.cost))
+ && (x.refuse === undefined || x.refuse === true))
+/** Every plug-in's adjustments of [ranked], plug-in by plug-in in the list's order: one that throws, runs too long or answers
+ * what cannot be ranked for any candidate is dropped for all of them and named in [warnings]. */
+function pluginAdjustments<T extends Probe & { fit: Fit }>(ranked: T[], plugins: readonly RoutePlugin[], context: RouteContext,
+ warnings: string[]): Array<Array<{ name: string; adjustment: Adjustment }>> {
+ const each = ranked.map(() => [] as Array<{ name: string; adjustment: Adjustment }>)
+ for (const plugin of plugins) {
+ if (!plugin.adjust) continue
+ const run = timed(() => ranked.map(p => plugin.adjust!(p, context)), answers => answers.every(validAdjustment))
+ if ('why' in run) { warnings.push(pluginSkipped(plugin.name, run.why)); continue }
+ run.answer.forEach((adjustment, i) => { if (adjustment) each[i]!.push({ name: plugin.name, adjustment }) })
+ }
+ return each
+}
export interface Verdict { pick: Shown; via: 'order' | 'only'; p: null; why: string }
const LEVELS: Level[] = ['low', 'medium', 'high']
@@ -347,15 +440,15 @@ const FIT_ORDER = { fits: 0, unknown: 1, short: 2 } as const
/** The order: a member in another repository last; then stronger, cheaper in effect (price, less with a 5-hour window that
* would otherwise go unused), a better quota fit, an idle member in the task's repository before a new agent, then by title
* (project instructions, phase 4). */
-function compare(x: Probe & Sized, y: Probe & Sized): number {
+function compare(x: Probe & Sized & { rank: Ranked }, y: Probe & Sized & { rank: Ranked }): number {
// A member in another repository tied a new agent and its name decided whether it took the task (Diego, 2026-10-30, #2377);
// ranked only after a new agent, a cheaper model or more quota still won it. The route no longer tells a build from a
// review, which needs no worktree, so it is shown last with OTHER_REPOSITORY as a note (choose), never left out.
const elsewhere = (p: Probe) => p.kind === 'member' && p.repo === 'different' ? 1 : 0
const placed = (p: Probe) => p.kind === 'member' && (p.repo ?? 'same') === 'same' ? 0 : 1
return elsewhere(x) - elsewhere(y)
- || y.quality - x.quality
- || x.fit.effectiveCost - y.fit.effectiveCost
+ || y.rank.strength - x.rank.strength
+ || x.rank.cost - y.rank.cost
|| FIT_ORDER[x.fit.status] - FIT_ORDER[y.fit.status]
|| placed(x) - placed(y)
|| titleOf(x).localeCompare(titleOf(y))
@@ -383,10 +476,14 @@ function unratedProbes(probes: Probe[], named: string): Probe[] {
/** The candidates that can run the task, ranked ([compare]), and those that cannot, with why. A catalog row not offered by
* default (Sonnet, Haiku) is offered when a person names it; its note goes with it, and with a member already on it.
* `held`: models served for the Swarm that take no more agents, to say who holds a named or local model none offers.
- * `offline`: models a host now offline served (routeCommand.ts offlineModels), by name. */
-export function choose(probes: Probe[], catalog: Catalog, a: Assessment, now: number = Date.now(), open: Commitment[] = [], held: HeldModel[] = [],
- offline: Array<{ title: string; reason: string }> = []): Choice | { error: 'NO_CANDIDATE'; excluded: Excluded[] } {
+ * `offline`: models a host now offline served (routeCommand.ts offlineModels), by name. `plugins`: [RoutePlugin]; with none
+ * the answer is exactly what it was before plug-ins existed (route.spec.ts, route answers without plug-ins). */
+export function choose(given: Probe[], catalog: Catalog, a: Assessment, now: number = Date.now(), open: Commitment[] = [], held: HeldModel[] = [],
+ offline: Array<{ title: string; reason: string }> = [], plugins: readonly RoutePlugin[] = []): Choice | NoCandidate {
const named = a.model
+ const context: RouteContext = { assessment: a, now, catalog, open }, warnings: string[] = []
+ const { probes, out: addedOut } = withPluginCandidates(given, plugins, context, warnings)
+ const warned = () => warnings.length ? { warnings } : {}
const noted = probes.flatMap(p => {
const row = p.gridModel ? null : p.kind === 'new' ? catalog.models.find(m => m.engine === p.engine && m.model === p.model && m.effort === p.effort) ?? null
: catalogRow(catalog, p.engine, p.model, p.effort)
@@ -407,7 +504,7 @@ export function choose(probes: Probe[], catalog: Catalog, a: Assessment, now: nu
// serves it now, which the answer says, rather than "Codex kimi-k3" unrated (final review).
const ofGrid = !!named && (catalog.grid.models.some(row => names(row.model, named)) || offline.some(m => names(m.title, named)))
if (named && !considered.length && !heldNamed.length && !a.local && !ofGrid) considered = unratedProbes(probes, named)
- const excluded: Excluded[] = considered.filter(p => p.refusals.length).map(p => ({ title: titleOf(p), reason: p.refusals.join(' '), machine: p.machineName }))
+ const excluded: Excluded[] = [...considered.filter(p => p.refusals.length).map(p => ({ title: titleOf(p), reason: p.refusals.join(' '), machine: p.machineName })), ...addedOut]
const viable = considered.filter(p => !p.refusals.length)
// Nothing offered: a model that is served but taken says who has it, rather than reading as unshared.
if (named && !considered.length) {
@@ -417,11 +514,26 @@ export function choose(probes: Probe[], catalog: Catalog, a: Assessment, now: nu
if (held.length) excluded.push(...held.map(m => ({ title: 'Local models', reason: heldReason(m) })))
else excluded.push({ title: 'Local models', reason: LOCAL_NONE })
}
- if (!viable.length) return { error: 'NO_CANDIDATE', excluded }
- const ranked = viable.map(p => ({ ...p, ...sizeUp(p, a, now, open) })).sort(compare)
- const shown = withEveryMachine(ranked).map(({ tight, text, ...p }, i) => ({ ...p, id: `c${i}`, title: titleOf(p), label: labelOf({ ...p, tight, text }, now) }))
+ if (!viable.length) return { error: 'NO_CANDIDATE', excluded, ...warned() }
+ const sized = viable.map(p => ({ ...p, ...sizeUp(p, a, now, open) }))
+ const adjustments = pluginAdjustments(sized, plugins, context, warnings)
+ const adjusted = adjustments.some(list => list.length)
+ const ranked = sized.flatMap((p, i) => {
+ const mine = adjustments[i]!, rank = { strength: p.quality, cost: p.fit.effectiveCost }
+ if (!mine.length) return [{ ...p, rank }]
+ const reasons = mine.map(({ name, adjustment }) => `${name}: ${adjustment.reason.trim()}`)
+ if (mine.some(m => m.adjustment.refuse)) {
+ excluded.push({ title: titleOf(p), reason: reasons.filter((_, j) => mine[j]!.adjustment.refuse).join(' '), machine: p.machineName })
+ return []
+ }
+ for (const { adjustment } of mine) { rank.strength += adjustment.strength ?? 0; rank.cost += adjustment.cost ?? 0 }
+ return [{ ...p, notes: [...p.notes, ...reasons], rank }]
+ }).sort(compare)
+ if (!ranked.length) return { error: 'NO_CANDIDATE', excluded, ...warned() }
+ const shown = withEveryMachine(ranked).map(({ tight, text, rank: _rank, ...p }, i) => ({ ...p, id: `c${i}`, title: titleOf(p), label: labelOf({ ...p, tight, text }, now) }))
const first = ranked[0]!
- return { shown, excluded, floor: 1, belowFloor: false, ...(first.fit.status === 'short' ? { short: shortOf(first, ranked) } : {}) }
+ return { shown, excluded, floor: 1, belowFloor: false, ...(first.fit.status === 'short' ? { short: shortOf(first, ranked) } : {}),
+ ...(adjusted ? { adjusted: true as const } : {}), ...warned() }
}
/** What the agent choosing is told when the pick is not expected to cover the task on its quota: a candidate further down
@@ -436,7 +548,8 @@ function shortOf(first: Probe & Sized, ranked: Array<Probe & Sized>): string {
export function decide(choice: Choice): Verdict {
const pick = choice.shown[0]!
return choice.shown.length === 1 ? { pick, via: 'only', p: null, why: 'Only candidate that can run this task.' }
- : { pick, via: 'order', p: null, why: 'First by strength, then price and quota fit.' }
+ : { pick, via: 'order', p: null, why: choice.adjusted ? 'First by strength, then price and quota fit, with the plug-ins\' adjustments in each candidate\'s notes.'
+ : 'First by strength, then price and quota fit.' }
}
/** The record in the shape a backend takes: `current` with the job's kind (what attempts are compared by, backend costs/read.ts),
diff --git a/cli/src/superTabs/routeCommand.spec.ts b/cli/src/superTabs/routeCommand.spec.ts
index c25c1ac22..62b4605dd 100644
--- a/cli/src/superTabs/routeCommand.spec.ts
+++ b/cli/src/superTabs/routeCommand.spec.ts
@@ -3,10 +3,11 @@ import type { openDaemon } from '../agentClient/daemon.js'
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
-import { ELSEWHERE, heldLocalModels, localProbes, NO_SWARM_AGENTS_ON, offlineModels, routeTask, servedModels, STALL_RETRY_MS, stalled } from './routeCommand.js'
+import { ELSEWHERE, heldLocalModels, leftOut, localProbes, NO_SWARM_AGENTS_ON, offlineModels, routeTask, servedModels, STALL_RETRY_MS, stalled } from './routeCommand.js'
import type { describeScmProject } from '../scm/scmProjects.js'
import { admission, quotaOf, RELAYED_QUOTA, USED_UP_WINDOW } from './capacity.js'
-import { OTHER_REPOSITORY, type Catalog, type Probe } from './route.js'
+import { OTHER_REPOSITORY, type Catalog, type Probe, type RoutePlugin } from './route.js'
+import { MAKER_TIMEOUT_MS, type PluginInput, type PluginMaker } from './routePlugins.js'
// Sonnet rated 3, as an owner who wants Sonnet Builders rates it (a build needs 3: route.ts buildRefusals), so the member these
// specs probe can build; the specs of the floor itself use a table of their own ([floorPolicy]).
@@ -114,6 +115,64 @@ describe('routeTask', () => {
expect(titles).toContain('Multiply · Claude sonnet medium · remote-1')
expect((result.alternatives as unknown[]).length).toBeLessThanOrEqual(2)
})
+ it('ranks with the plug-ins its makers make: their reasons in the answer and the record, a failed one named in the warnings', async () => {
+ const s = scoped()
+ const plugins: RoutePlugin[] = [{ name: 'Machine fit', adjust: c => c.kind === 'new' ? { strength: 5, reason: 'a fresh worktree here' } : null },
+ { name: 'Broken', adjust: () => { throw new Error('secret') } }]
+ const inputs: PluginInput[] = []
+ const result = await routeTask(input, s, where as never, opener(), () => 'op', undefined, plugins.map(p => ({ name: p.name, make: async (i: PluginInput) => { inputs.push(i); return p } })))
+ expect(result).toMatchObject({ ok: true, pick: { kind: 'new', notes: expect.arrayContaining(['Machine fit: a fresh worktree here']) },
+ why: expect.stringContaining('plug-ins'), warnings: ['w', 'The routing plug-in "Broken" was skipped: it failed. The route is ranked without it.'] })
+ expect(labels(s)[0]).toContain('Machine fit: a fresh worktree here')
+ expect(JSON.stringify(result)).not.toContain('secret')
+ // Each maker gets the task, the route's backend read, the group's history (read once, shared) and the agent's request.
+ expect(inputs[0]).toMatchObject({ conversationId: 'g1', assessment: { why: 'Endpoint.' }, read: { agentId: 'lead' }, catalog: { models: expect.any(Array) } })
+ expect(await inputs[0]!.history).toEqual({ ok: true, value: { decisions: [], attempts: [] } })
+ expect(s.mock.calls.filter(c => c[0].action === 'routeHistory')).toHaveLength(1)
+ expect(await inputs[0]!.request({ action: 'instructions' })).toMatchObject({ ok: true })
+ // Nothing can run: the answer still names the failed plug-in and the failed maker.
+ const none = await routeTask(input, scoped(), where as never, opener(), () => 'op', undefined, [
+ { name: 'Nobody', make: async () => ({ name: 'Nobody', adjust: () => ({ refuse: true, reason: 'no room' }) }) },
+ { name: 'Broken', make: async () => ({ name: 'Broken', candidates: () => { throw new Error('secret') } }) },
+ { name: 'Maker fails', make: async () => { throw new Error('secret') } }])
+ expect(none).toMatchObject({ error: 'NO_CANDIDATE', warnings: ['The routing plug-in "Maker fails" was skipped: its maker failed. The route is ranked without it.',
+ 'The routing plug-in "Broken" was skipped: it failed. The route is ranked without it.'],
+ leftOut: expect.arrayContaining([{ machine: 'remote-1', reasons: expect.arrayContaining(['Nobody: no room']) }]) })
+ })
+ it('reads instructions without notes as none, and cuts a long reason a machine is left out for', async () => {
+ const s = scoped({ instructions: { ok: true, value: { projectId: 'p1', revision: 1, text: 'Work by this.' } } })
+ expect(await routeTask(input, s, where as never, opener(), () => 'op')).toMatchObject({ instructions: { revision: 1, notes: [] } })
+ expect(leftOut([{ title: 't', reason: 'x'.repeat(301), machine: 'm' }], [])).toEqual([{ machine: 'm', reasons: [`${'x'.repeat(299)}…`] }])
+ })
+ it('answers exactly as before with no makers, and with makers that have nothing to say', async () => {
+ vi.useFakeTimers({ toFake: ['Date'] })
+ try {
+ vi.setSystemTime(Date.parse('2026-10-31T04:00:00Z'))
+ const answer = async (makers?: PluginMaker[]) => { const s = scoped(); return { answer: await routeTask(input, s, where as never, opener(), () => 'op', undefined, makers), record: recorded(s) } }
+ const before = JSON.stringify(await answer())
+ expect(JSON.stringify(await answer([]))).toBe(before)
+ expect(JSON.stringify(await answer([{ name: 'Idle', make: async () => null }]))).toBe(before)
+ } finally { vi.useRealTimers() }
+ })
+ it('a slow or failing maker is left out with a warning, and the route answers as it would without it', async () => {
+ vi.useFakeTimers({ toFake: ['Date'] })
+ vi.setSystemTime(Date.parse('2026-10-31T04:00:00Z'))
+ let plain: Answer
+ try { plain = await routeTask(input, scoped(), where as never, opener(), () => 'op') } finally { vi.useRealTimers() }
+ vi.useFakeTimers({ toFake: ['Date', 'setTimeout', 'clearTimeout'] })
+ try {
+ vi.setSystemTime(Date.parse('2026-10-31T04:00:00Z'))
+ const pending = routeTask(input, scoped(), where as never, opener(), () => 'op', undefined, [
+ { name: 'Slow', make: () => new Promise(() => {}) }, { name: 'Fails', make: async () => { throw new Error('secret') } }])
+ await vi.advanceTimersByTimeAsync(MAKER_TIMEOUT_MS + 1)
+ vi.setSystemTime(Date.parse('2026-10-31T04:00:00Z'))
+ const { warnings, ...rest } = await pending as Answer
+ const { warnings: plainWarnings, ...plainRest } = plain
+ expect(rest).toEqual(plainRest)
+ expect(warnings).toEqual([...(plainWarnings as string[]), 'The routing plug-in "Slow" was skipped: its maker took longer than 3 s. The route is ranked without it.',
+ 'The routing plug-in "Fails" was skipped: its maker failed. The route is ranked without it.'])
+ } finally { vi.useRealTimers() }
+ })
// A member at work is not offered; one whose task was lost is, with a note ('a member whose last task was lost').
it('does not offer a member whose task is working', async () => {
const state = tab({ id: 'x', agentId: 'a1', status: 'working' })
diff --git a/cli/src/superTabs/routeCommand.ts b/cli/src/superTabs/routeCommand.ts
index 2f480f347..294b3a9b3 100644
--- a/cli/src/superTabs/routeCommand.ts
+++ b/cli/src/superTabs/routeCommand.ts
@@ -8,6 +8,7 @@ import { RELAYED_QUOTA, requiredToolReason, startRequirements, USED_UP_WINDOW }
import { inspectCapacity, type ScopedRequest } from './start.js'
import { ENDED_WORK, object, within } from './wire.js'
import { accountOf, API_BUILDERS, catalogFrom, catalogRow, choose, decide, gridStrength, parseAssessment, quotaOf2, recordOf, repoMatch, repositoryKey, type Assessment, type Catalog, type CatalogModel, type RecordShape, type Commitment, type Excluded, type HeldModel, type MemberFrame, type Probe, type TaskFolder } from './route.js'
+import { makePlugins, ROUTE_PLUGIN_MAKERS, type PluginMaker } from './routePlugins.js'
import { stat } from 'node:fs/promises'
import { describeScmProject } from '../scm/scmProjects.js'
@@ -199,8 +200,10 @@ function frameOf(frame: Json): MemberFrame {
branch: text(object(object(frame.gitContext).current).branch) ?? text(project.branch), updatedAt: Number.isFinite(updatedAt) ? updatedAt : null }
}
+/** `makers`: what makes the routing plug-ins this route ranks with (routePlugins.ts), in their order. */
export async function routeTask(input: { tabId: string; conversationId: string; assessment: unknown }, request: ScopedRequest, where: Where,
- open: typeof openDaemon = openDaemon, newId: () => string = randomUUID, reader: FolderReader = FOLDER_READER): Promise<Json> {
+ open: typeof openDaemon = openDaemon, newId: () => string = randomUUID, reader: FolderReader = FOLDER_READER,
+ makers: readonly PluginMaker[] = ROUTE_PLUGIN_MAKERS): Promise<Json> {
// A lost connection is an answer here, never a throw: the agent must still get a decision or a reason.
const scoped: ScopedRequest = async payload => {
try { return await request(payload) } catch (error) {
@@ -280,13 +283,16 @@ export async function routeTask(input: { tabId: string; conversationId: string;
// The probes do not wait for the context reads: the machines, the task's folder and the group's talk and log are read
// together, and each read that is only context gives up after three seconds. What needs several of them (whether a
// member is in the task's repository, what it did before) is joined afterwards.
- const [probed, read, history, instructed] = await Promise.all([
+ // The plug-ins' makers start here too: each piece's outside read runs beside the probes, and they share the history read.
+ const historyRead = within(scoped({ action: 'routeHistory', conversationId: input.conversationId }))
+ const [probed, read, history, instructed, made] = await Promise.all([
Promise.all([...machines].map(([machineId, machine]) =>
probeMachine(machineId, machine, members.filter(m => m.machineId === machineId), rows, catalog, assessment, where, open))),
cwd ? within(readFolder(cwd, reader)) : null,
- within(scoped({ action: 'routeHistory', conversationId: input.conversationId })),
+ historyRead,
// The project's instructions ride on the answer: the agent routes by them. A backend without them is an unreadable read.
within(scoped({ action: 'instructions', projectId })),
+ makePlugins(makers, { conversationId: input.conversationId, assessment, read: value, catalog, history: historyRead, request: scoped }),
])
const written = object(instructed?.ok === true ? instructed.value : {})
const instructions = typeof written.text === 'string' ? { revision: written.revision, text: written.text, notes: Array.isArray(written.notes) ? written.notes : [] } : null
@@ -341,10 +347,11 @@ export async function routeTask(input: { tabId: string; conversationId: string;
.map(d => ({ account: d.account, spend: object(d.spend), size: d.size, createdAt: Date.parse(String(d.createdAt)) }) as Commitment)
// A model a host now offline served is left out with that reason, and a person naming it gets no stand-in (route.ts choose).
const offline = offlineModels(state)
- const choice = choose(probes, catalog, assessment, Date.now(), working, heldLocalModels(state), offline)
+ const choice = choose(probes, catalog, assessment, Date.now(), working, heldLocalModels(state), offline, made.plugins)
+ const skipped = [...made.warnings, ...(choice.warnings ?? [])]
choice.excluded.push(...offline, ...(catalog.models.length ? [] : [{ title: 'New agents', reason: CATALOG_UNREADABLE }]))
// The task stays in the agent's queue rather than going where it cannot be done.
- if ('error' in choice) return { ...choice, leftOut: leftOut(choice.excluded, []), ...required.machines || required.devices.length ? { waiting: true, detail: WAITING } : {} }
+ if ('error' in choice) return { ...choice, ...(skipped.length ? { warnings: skipped } : {}), leftOut: leftOut(choice.excluded, []), ...required.machines || required.devices.length ? { waiting: true, detail: WAITING } : {} }
const verdict = decide(choice)
const operationId = `route-${newId()}`
const record = (shape: RecordShape) => scoped({ action: 'command', operationId,
@@ -370,7 +377,7 @@ export async function routeTask(input: { tabId: string; conversationId: string;
warnings: [...(Array.isArray(effective.warnings) ? effective.warnings : []), ...(value.machinesUnreadable === true ? [MACHINES_UNREADABLE] : []),
...(catalog.models.length ? [] : [CATALOG_UNREADABLE]),
...(choice.shown.some(p => p.kind === 'member' && p.terminalUnverified) ? ["A member's terminal could not be verified from its machine's snapshot. Check it before assignment."] : []),
- ...(choice.short ? [choice.short] : [])],
+ ...(choice.short ? [choice.short] : []), ...skipped],
next: verdict.pick.kind === 'member'
? `Assign with: command OPERATION_ID {"type":"work.assign","conversationId":"${input.conversationId}","agentId":"${verdict.pick.agentId}"${decision}}`
// No fixed role name: NAME and ROLE are the agent's to fill from the project's instructions. A backend without
diff --git a/cli/src/superTabs/routePlugins.spec.ts b/cli/src/superTabs/routePlugins.spec.ts
new file mode 100644
index 000000000..1fa499927
--- /dev/null
+++ b/cli/src/superTabs/routePlugins.spec.ts
@@ -0,0 +1,59 @@
+// cli/src/superTabs/routePlugins.spec.ts
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import type { RoutePlugin } from './route.js'
+import { makePlugins, MAKER_TIMEOUT_MS, ROUTE_PLUGIN_MAKERS, type PluginInput, type PluginMaker } from './routePlugins.js'
+
+const input: PluginInput = { conversationId: 'g1', assessment: { difficulty: 'low', risk: 'low', size: 'small', why: 'x', needs: { tools: [], devices: [] } },
+ read: { tab: {} }, catalog: { models: [], grid: { strength: 1, models: [] } }, history: Promise.resolve(null), request: async () => ({ ok: true }) }
+const plugin = (name: string): RoutePlugin => ({ name, adjust: () => null })
+const maker = (name: string, make: PluginMaker['make']): PluginMaker => ({ name, make })
+const skipped = (name: string, why: string) => `The routing plug-in "${name}" was skipped: ${why}. The route is ranked without it.`
+
+afterEach(() => { vi.useRealTimers() })
+
+describe('makePlugins', () => {
+ it('has no makers yet, and an empty list makes no plug-ins and no warnings', async () => {
+ expect(ROUTE_PLUGIN_MAKERS).toEqual([])
+ expect(await makePlugins([], input)).toEqual({ plugins: [], warnings: [] })
+ })
+ it('gives each maker the task, the backend read, the shared history and the request, and keeps the makers\' order whatever order they finish in', async () => {
+ const seen: PluginInput[] = []
+ const slowFirst = maker('First', async i => { seen.push(i); await new Promise(r => setTimeout(r, 20)); return plugin('first') })
+ const fastSecond = maker('Second', async i => { seen.push(i); return plugin('second') })
+ const made = await makePlugins([slowFirst, fastSecond], input)
+ expect(made.plugins.map(p => p.name)).toEqual(['first', 'second'])
+ expect(made.warnings).toEqual([])
+ expect(seen).toEqual([input, input])
+ })
+ it('a maker with nothing to say this time adds no plug-in and no warning', async () => {
+ expect(await makePlugins([maker('Idle', async () => null)], input)).toEqual({ plugins: [], warnings: [] })
+ })
+ it('a maker that throws, rejects or answers what is not a plug-in is left out with a warning, never with its error', async () => {
+ const made = await makePlugins([
+ maker('Throws', () => { throw new Error('token=secret') }),
+ maker('Rejects', async () => { throw new Error('secret') }),
+ maker('Junk', async () => ({ name: '' }) as RoutePlugin),
+ maker('Bad adjust', async () => ({ name: 'x', adjust: 'no' }) as unknown as RoutePlugin),
+ maker('Bad candidates', async () => ({ name: 'x', candidates: 1 }) as unknown as RoutePlugin),
+ maker('Not an object', async () => 7 as unknown as RoutePlugin),
+ maker('Fine', async () => plugin('fine')),
+ ], input)
+ expect(made.plugins.map(p => p.name)).toEqual(['fine'])
+ expect(made.warnings).toEqual(['Throws', 'Rejects', 'Junk', 'Bad adjust', 'Bad candidates', 'Not an object'].map(n => skipped(n, 'its maker failed')))
+ expect(JSON.stringify(made)).not.toContain('secret')
+ })
+ it('a maker that has not answered in time is left out with a warning, and what it answers later is dropped', async () => {
+ vi.useFakeTimers()
+ let finish: (p: RoutePlugin) => void = () => {}, fail: (e: Error) => void = () => {}
+ const pending = makePlugins([maker('Slow', () => new Promise(r => { finish = r })), maker('Slow fail', () => new Promise((_, j) => { fail = j })),
+ maker('Quick', async () => plugin('quick'))], input)
+ await vi.advanceTimersByTimeAsync(MAKER_TIMEOUT_MS + 1)
+ const made = await pending
+ expect(made).toEqual({ plugins: [expect.objectContaining({ name: 'quick' })], warnings: ['Slow', 'Slow fail'].map(n => skipped(n, 'its maker took longer than 3 s')) })
+ // Late answers change nothing, and a late failure is not an unhandled rejection.
+ finish(plugin('late')); fail(new Error('late'))
+ await vi.advanceTimersByTimeAsync(1)
+ expect(made.plugins.map(p => p.name)).toEqual(['quick'])
+ expect(vi.getTimerCount()).toBe(0)
+ })
+})
diff --git a/cli/src/superTabs/routePlugins.ts b/cli/src/superTabs/routePlugins.ts
new file mode 100644
index 000000000..09b5e0b81
--- /dev/null
+++ b/cli/src/superTabs/routePlugins.ts
@@ -0,0 +1,54 @@
+/** The routing plug-ins' makers (route.ts RoutePlugin). Scholes's goals, pieces 3 to 6 (measured cost and results, more model
+ * candidates, machine fit, window pull), each add one line to [ROUTE_PLUGIN_MAKERS] rather than all four editing the route's
+ * call (piece 3's builder, 10-31). A maker does its piece's outside read and returns a pure plug-in holding what it read;
+ * routeTask starts every maker together with the machine probes, so a maker's read costs no time of its own. */
+import { pluginSkipped, type Assessment, type Catalog, type RoutePlugin } from './route.js'
+import type { ScopedRequest } from './start.js'
+
+type Json = Record<string, unknown>
+
+/** What a maker gets. `read`: the route's backend read (the Super Tab state this agent may read, the policy and catalog, the
+ * machines). `history`: the group's route history (`decisions`, `attempts`) once read, null when it could not be, shared so no
+ * maker reads it again. `request`: this agent's own backend request, for a read the route does not make; it carries the
+ * agent's access, never more. */
+export interface PluginInput {
+ readonly conversationId: string
+ readonly assessment: Assessment
+ readonly read: Json
+ readonly catalog: Catalog
+ readonly history: Promise<Json | null>
+ readonly request: ScopedRequest
+}
+/** Makes one plug-in for one route, or null when it has nothing to say this time (no data yet). */
+export interface PluginMaker { readonly name: string; make(input: PluginInput): Promise<RoutePlugin | null> }
+
+/** The makers, in the order their plug-ins run. One line per piece. */
+export const ROUTE_PLUGIN_MAKERS: readonly PluginMaker[] = []
+
+/** As long as the route's other context reads wait (wire.ts within): a maker's read is context too, never worth holding the
+ * route for. */
+export const MAKER_TIMEOUT_MS = 3000
+
+const isPlugin = (p: unknown): p is RoutePlugin => {
+ const v = (p && typeof p === 'object' ? p : {}) as Json
+ return typeof v.name === 'string' && !!v.name && (v.candidates === undefined || typeof v.candidates === 'function')
+ && (v.adjust === undefined || typeof v.adjust === 'function')
+}
+
+/** Every maker's plug-in, in the makers' order whatever order they finish in. A maker that throws, rejects, answers what is not
+ * a plug-in, or has not answered in [ms] is left out and named in `warnings`, with no error text; what it answers later is
+ * dropped, so a route already ranked never changes. */
+export async function makePlugins(makers: readonly PluginMaker[], input: PluginInput, ms = MAKER_TIMEOUT_MS): Promise<{ plugins: RoutePlugin[]; warnings: string[] }> {
+ const made = await Promise.all(makers.map(async maker => {
+ let timer: NodeJS.Timeout | undefined
+ const late = new Promise<'late'>(resolve => { timer = setTimeout(resolve, ms, 'late') })
+ try {
+ const answer = await Promise.race([Promise.resolve().then(() => maker.make(input)), late])
+ if (answer === 'late') return { why: `its maker took longer than ${ms / 1000} s`, name: maker.name }
+ if (answer === null) return {}
+ return isPlugin(answer) ? { plugin: answer } : { why: 'its maker failed', name: maker.name }
+ } catch { return { why: 'its maker failed', name: maker.name } } finally { clearTimeout(timer) }
+ }))
+ return { plugins: made.flatMap(m => 'plugin' in m && m.plugin ? [m.plugin] : []),
+ warnings: made.flatMap(m => 'why' in m && m.why ? [pluginSkipped(m.name!, m.why)] : []) }
+}
diff --git a/cli/vitest.super-tabs.config.ts b/cli/vitest.super-tabs.config.ts
index be5575949..1dc84741d 100644
--- a/cli/vitest.super-tabs.config.ts
+++ b/cli/vitest.super-tabs.config.ts
@@ -6,7 +6,7 @@ import base from './vitest.config.js'
* the core and services, which no other gate covers, held to 100% in every file. And the Swarm's side of the core's
* process (superTabs/inCore/), which left the core's own 100% gate when the Swarm became a switch. */
const IN_CORE = ['adoption', 'agents', 'attention', 'cards', 'deliveries', 'launch', 'role', 'teamApps', 'teamPurge', 'terminal'].map(name => `src/superTabs/inCore/${name}.ts`)
-const FILES = ['src/superTabs/route.ts', 'src/superTabs/routeCommand.ts', 'src/superTabs/shortCommand.ts', ...IN_CORE]
+const FILES = ['src/superTabs/route.ts', 'src/superTabs/routeCommand.ts', 'src/superTabs/routePlugins.ts', 'src/superTabs/shortCommand.ts', ...IN_CORE]
export default defineConfig({
test: {
...base.test,