fix(dsh-plugin-browserskill): enforce the session cap before spawning

The concurrency cap was checked in registry.add() AFTER
`bsk session start` had already created the session, so a rejected
start leaked a live session outside the plugin's tracking (found by the
real-browser e2e: the rejected third session stayed in
`bsk session list` after dispose). Check capacity before spawning;
registry.add() keeps the same check as a backstop.
This commit is contained in:
BB-fat
2026-08-13 15:27:29 +00:00
parent 703fc64399
commit 2de7c5c6ff
3 changed files with 17 additions and 5 deletions
@@ -226,8 +226,8 @@ describe("multi-session behavior", () => {
await expect(snapshot?.execute({}, makeExec())).rejects.toThrow(/browser_session_start/);
});
it("enforces the configured session cap", async () => {
const { tools } = setup(
it("enforces the configured session cap before spawning", async () => {
const { tools, calls } = setup(
{ "session start": seq([START_REPLY("s1"), START_REPLY("s2")]) },
{},
1,
@@ -235,6 +235,8 @@ describe("multi-session behavior", () => {
await startSession(tools);
const start = tools.get("browser_session_start");
await expect(start?.execute({}, makeExec())).rejects.toThrow(/session limit/);
// A rejected start must not spawn another bsk session (no leaked session).
expect(calls.filter((c) => c.args.join(" ").startsWith("session start"))).toHaveLength(1);
});
});