From 9af8d39c4ab21f04cbd65182c121002bc502c197 Mon Sep 17 00:00:00 2001 From: Sandeep Satheesh Date: Sun, 27 Sep 2026 02:27:58 -0500 Subject: [PATCH 1/2] fix(onboard): keep unprovable forward ports occupied instead of failing allocation One indeterminate forward-ownership observation made the dashboard and Hermes API allocators throw before scanning, so a single port NemoClaw could not verify (for example one held by another user's process) blocked every free port in the range. Throw only when an observation failed for a reason other than ownership. A port whose ownership cannot be proven stays occupied, as the allocator's contract already states, and the scan continues. When no port can be verified, the range-exhausted error names each unverified port. Refs #11979 Signed-off-by: Sandeep Satheesh --- src/lib/onboard/dashboard-port.test.ts | 35 ++++++++++++++++++++++--- src/lib/onboard/dashboard-port.ts | 8 +++++- src/lib/onboard/hermes-api-port.test.ts | 6 ++--- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/lib/onboard/dashboard-port.test.ts b/src/lib/onboard/dashboard-port.test.ts index f413b476d04..ce6a73ceb28 100644 --- a/src/lib/onboard/dashboard-port.test.ts +++ b/src/lib/onboard/dashboard-port.test.ts @@ -169,13 +169,42 @@ describe("typed OpenShell dashboard-port observation", () => { ).toBe(18790); }); - it("blocks allocation when ownership is indeterminate", () => { - expect(() => + it("keeps an unprovable port occupied and allocates the next free port (#11979)", () => { + expect( findAvailableDashboardPortFromObservations("cursor", 18789, [ forwardObservation("cursor", 18789, "indeterminate"), forwardObservation("cursor", 18790, "absent"), ]), - ).toThrow(/could not prove OpenShell forward ownership/i); + ).toBe(18790); + }); + + it("names every unprovable port when no dashboard port can be verified (#11979)", () => { + const observations = Array.from({ length: 11 }, (_, index) => + forwardObservation("cursor", 18789 + index, "indeterminate"), + ); + expect(() => findAvailableDashboardPortFromObservations("cursor", 18789, observations)).toThrow( + /All dashboard ports in range 18789-18799 are occupied:\n {2}18789 → unverified OpenShell forward ownership/, + ); + }); + + it("still blocks allocation when a forward observation fails for another reason", () => { + expect(() => + findAvailableDashboardPortFromObservations("cursor", 18789, [ + { + state: "indeterminate", + forward: { + gatewayEndpoint: "https://127.0.0.1:9090", + gatewayName: "nemoclaw-9090", + workspace: "default", + sandboxName: "cursor", + localHost: "127.0.0.1", + port: 18789, + }, + error: { kind: "timeout", message: "The OpenShell forward operation timed out." }, + }, + forwardObservation("cursor", 18790, "absent"), + ]), + ).toThrow(/Cannot allocate dashboard port: The OpenShell forward operation timed out/); }); it("treats missing observations as unverified instead of absent", () => { diff --git a/src/lib/onboard/dashboard-port.ts b/src/lib/onboard/dashboard-port.ts index d7d68ca7c74..6791638c461 100644 --- a/src/lib/onboard/dashboard-port.ts +++ b/src/lib/onboard/dashboard-port.ts @@ -363,7 +363,13 @@ export function findAvailablePortInRangeFromObservations( range: HostPortRange, registryOccupiedPorts: ReadonlyMap = new Map(), ): number { - const indeterminate = observations.find((observation) => observation.state === "indeterminate"); + // An unprovable owner on one port only keeps that port occupied below. Any other + // indeterminate result means the observation itself failed, so stop (#11979). + const indeterminate = observations.find( + (observation) => + observation.state === "indeterminate" && + !("error" in observation && observation.error.kind === "ownership"), + ); if (indeterminate) { const message = "error" in indeterminate ? indeterminate.error.message : "Invalid forward request."; diff --git a/src/lib/onboard/hermes-api-port.test.ts b/src/lib/onboard/hermes-api-port.test.ts index 634f8883fd7..e7076506adf 100644 --- a/src/lib/onboard/hermes-api-port.test.ts +++ b/src/lib/onboard/hermes-api-port.test.ts @@ -137,8 +137,8 @@ describe("findAvailableHermesApiPortFromObservations", () => { ).toBe(8643); }); - it("blocks allocation when ownership is indeterminate", () => { - expect(() => + it("keeps an unprovable port occupied and allocates the next free port (#11979)", () => { + expect( findAvailableHermesApiPortFromObservations( "beta", 8642, @@ -148,7 +148,7 @@ describe("findAvailableHermesApiPortFromObservations", () => { ], new Map(), ), - ).toThrow(/could not prove OpenShell forward ownership/i); + ).toBe(8643); }); }); From 283a0b9a4b266293c3177d54eaa5201cb99d71e2 Mon Sep 17 00:00:00 2001 From: Rebecca Sliter <571084+rsliter@users.noreply.github.com> Date: Wed, 7 Oct 2026 09:22:34 -0700 Subject: [PATCH 2/2] test(onboard): verify every unproven dashboard port Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com> --- src/lib/onboard/dashboard-port.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/onboard/dashboard-port.test.ts b/src/lib/onboard/dashboard-port.test.ts index ce6a73ceb28..c7dc0e04a4b 100644 --- a/src/lib/onboard/dashboard-port.test.ts +++ b/src/lib/onboard/dashboard-port.test.ts @@ -183,7 +183,11 @@ describe("typed OpenShell dashboard-port observation", () => { forwardObservation("cursor", 18789 + index, "indeterminate"), ); expect(() => findAvailableDashboardPortFromObservations("cursor", 18789, observations)).toThrow( - /All dashboard ports in range 18789-18799 are occupied:\n {2}18789 → unverified OpenShell forward ownership/, + "All dashboard ports in range 18789-18799 are occupied:\n" + + Array.from( + { length: 11 }, + (_, index) => ` ${18789 + index} → unverified OpenShell forward ownership`, + ).join("\n"), ); });