refactor: route Best fit proposals to personas only

The executor router could propose Claude Code, Codex or Hermes and
dispatch the task as a Waggle Room run through POST /api/tools/run, which
is gone with the collaboration runtime. Confirming such a proposal could
only fail.

- ExecutorRegistry offers the five v1 personas; it no longer detects
  external tools.
- Route proposals dispatch persona chat turns only. The memory brief and
  its egress disclosure existed only for external executors, so
  executor-brief.ts, the egress fields and removeFrameIds go too.
- RouteProposalCard drops the memory disclosure, "Run without memory" and
  the link to an external run in the Room.
This commit is contained in:
shumeiko.it
2026-11-01 11:06:43 +01:00
parent 94ad4446fb
commit 727c756651
11 changed files with 121 additions and 1102 deletions

View File

@@ -1,6 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { AgentPersona } from '@waggle/agent';
import type { DetectedTool } from '@waggle/shared';
import { ExecutorRegistry } from '../../src/local/executor-registry.js';
function persona(id: string, overrides: Partial<AgentPersona> = {}): AgentPersona {
@@ -19,16 +18,6 @@ function persona(id: string, overrides: Partial<AgentPersona> = {}): AgentPerson
};
}
function detectedTool(id: string, installed = true): DetectedTool {
return {
id,
displayName: id,
installed,
installedPath: installed ? `/tools/${id}` : null,
version: installed ? '1.0.0' : null,
};
}
const PERSONAS = [
persona('writer'),
persona('coordinator'),
@@ -39,24 +28,13 @@ const PERSONAS = [
persona('planner', { isReadOnly: true }),
];
const DETECTED_TOOLS = [
detectedTool('claude-code'),
detectedTool('codex', false),
{ ...detectedTool('hermes'), launchable: false, diagnostic: 'Hermes runtime is broken' },
detectedTool('openclaw'),
detectedTool('cursor'),
];
afterEach(() => {
vi.restoreAllMocks();
});
describe('ExecutorRegistry', () => {
it('composes five v1 personas and only release-supported headless executors', async () => {
const registry = new ExecutorRegistry({
detectTools: vi.fn(async () => DETECTED_TOOLS),
personas: () => PERSONAS,
});
it('offers the five v1 personas and no external coding agents', async () => {
const registry = new ExecutorRegistry({ personas: () => PERSONAS });
const candidates = await registry.snapshot(1_000);
@@ -66,9 +44,6 @@ describe('ExecutorRegistry', () => {
'persona:writer',
'persona:researcher',
'persona:analyst',
'external:claude-code',
'external:codex',
'external:hermes',
]);
expect(candidates.find((candidate) => candidate.id === 'persona:coder')).toMatchObject({
kind: 'persona',
@@ -80,68 +55,32 @@ describe('ExecutorRegistry', () => {
egressDestination: 'configured model provider',
taskFit: { coding: 0.85, writing: 0.3 },
});
expect(candidates.find((candidate) => candidate.id === 'external:claude-code')).toMatchObject({
kind: 'external',
displayName: 'Claude Code',
authClass: 'subscription-cli',
installed: true,
healthy: true,
rateLimit: { state: 'unknown' },
supportsHeadless: true,
egressDestination: 'Anthropic',
});
expect(candidates.find((candidate) => candidate.id === 'external:codex')).toMatchObject({
installed: false,
healthy: false,
egressDestination: 'OpenAI',
});
expect(candidates.find((candidate) => candidate.id === 'external:hermes')).toMatchObject({
installed: true,
healthy: false,
egressDestination: 'Nous',
});
expect(candidates.find((candidate) => candidate.id === 'external:openclaw')).toBeUndefined();
});
it('normalizes tool ids and expires rate-limit observations', async () => {
it('expires rate-limit observations', async () => {
vi.spyOn(Date, 'now').mockReturnValue(10_000);
const registry = new ExecutorRegistry({
detectTools: vi.fn(async () => DETECTED_TOOLS),
personas: () => PERSONAS,
});
const registry = new ExecutorRegistry({ personas: () => PERSONAS });
registry.noteRateLimit('codex', null);
registry.noteRateLimit('persona:coder', null);
const exhausted = (await registry.snapshot(10_000))
.find((candidate) => candidate.id === 'external:codex');
.find((candidate) => candidate.id === 'persona:coder');
expect(exhausted?.rateLimit).toEqual({ state: 'observed_exhausted' });
const recovered = (await registry.snapshot(10_000 + 15 * 60_000))
.find((candidate) => candidate.id === 'external:codex');
.find((candidate) => candidate.id === 'persona:coder');
expect(recovered?.rateLimit).toEqual({ state: 'available' });
registry.noteRateLimit('external:codex', 2_000_000);
registry.noteRateLimit('persona:coder', 2_000_000);
const withReset = (await registry.snapshot(1_999_999))
.find((candidate) => candidate.id === 'external:codex');
.find((candidate) => candidate.id === 'persona:coder');
expect(withReset?.rateLimit).toEqual({
state: 'observed_exhausted',
resumeAtMs: 2_000_000,
});
registry.noteHealthy('codex');
registry.noteHealthy('persona:coder');
const healthy = (await registry.snapshot(1_999_999))
.find((candidate) => candidate.id === 'external:codex');
.find((candidate) => candidate.id === 'persona:coder');
expect(healthy?.rateLimit).toEqual({ state: 'available' });
});
it('caches tool detection for thirty seconds', async () => {
const detectTools = vi.fn(async () => DETECTED_TOOLS);
const registry = new ExecutorRegistry({ detectTools, personas: () => PERSONAS });
await registry.snapshot(1_000);
await registry.snapshot(30_999);
expect(detectTools).toHaveBeenCalledTimes(1);
await registry.snapshot(31_000);
expect(detectTools).toHaveBeenCalledTimes(2);
});
});