Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3e0a633
fix(e2e): stop the OpenShell gateway user service
apurvvkumaria Sep 11, 2026
3ae8424
fix(e2e): preserve gateway service manager failures
apurvvkumaria Sep 11, 2026
9f59074
fix(e2e): validate gateway service ownership
apurvvkumaria Sep 11, 2026
a2136e7
fix(e2e): share gateway service ownership
apurvvkumaria Sep 11, 2026
348915d
fix(e2e): skip absent gateway services
apurvvkumaria Sep 11, 2026
8e2e3a5
fix(e2e): report absent gateway service
apurvvkumaria Sep 11, 2026
40b9d7a
fix(e2e): preserve gateway service recovery
apurvvkumaria Sep 11, 2026
4ef026f
fix(e2e): avoid login shell for gateway service helpers
apurvvkumaria Sep 11, 2026
bca84d0
merge: integrate OpenShell 0.0.116 cutover
apurvvkumaria Sep 11, 2026
8308c91
Merge branch 'main' into codex/10947-openshell-106-gateway-stop
cjagwani Sep 11, 2026
9d3cb98
merge: integrate current main
apurvvkumaria Sep 11, 2026
a2ad140
test(e2e): isolate gateway service fixtures
apurvvkumaria Sep 11, 2026
876d722
fix(e2e): verify gateway service restart
cjagwani Sep 11, 2026
706b49e
merge: integrate current main
cjagwani Sep 11, 2026
ed9eed3
merge: integrate current main
cjagwani Sep 11, 2026
6297efb
merge: integrate current main
cjagwani Sep 11, 2026
60a36a4
merge: integrate current main
apurvvkumaria Sep 11, 2026
6b7de21
fix(e2e): stabilize Hermes resume and DCode state
prekshivyas Sep 11, 2026
50c6be0
Merge remote-tracking branch 'origin/pr-11526' into fix/e2e-hermes-dc…
prekshivyas Sep 11, 2026
7df4f10
Merge remote-tracking branch 'origin/pr-11526' into fix/e2e-hermes-dc…
prekshivyas Sep 11, 2026
b3810d6
fix(e2e): close Hermes and DCode review gaps
jyaunches Sep 11, 2026
403c7bf
fix(e2e): preserve Hermes and DCode ownership
prekshivyas Sep 11, 2026
315a404
merge: preserve concurrent review repair
prekshivyas Sep 11, 2026
7d16fad
test(e2e): align Hermes resume failure evidence
jyaunches Sep 12, 2026
f3d78ff
Merge remote-tracking branch 'origin/main' into codex/pr-11592-shepherd
jyaunches Sep 12, 2026
5c3cebc
fix(e2e): stabilize resume and model selection
jyaunches Sep 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion agents/langchain-deepagents-code/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
strings "$binary" | grep -Fq '/usr/local/lib/nemoclaw/managed-bootstrap-trampoline.sh'

# hadolint ignore=DL3006
FROM ${BASE_IMAGE}

Check warning on line 68 in agents/langchain-deepagents-code/Dockerfile

View workflow job for this annotation

GitHub Actions / PR build and direct managed startup (Deep Agents Code)

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ${BASE_IMAGE} results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

Check warning on line 68 in agents/langchain-deepagents-code/Dockerfile

View workflow job for this annotation

GitHub Actions / PR build and direct managed startup (Deep Agents Code)

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ${BASE_IMAGE} results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

# The supplied base may end as a non-root runtime user. Reset the build user
# explicitly before installing the root-owned managed-startup handoff.
Expand Down Expand Up @@ -319,7 +319,7 @@
&& env -i /usr/local/bin/dcode.real --version \
&& env -i /usr/local/bin/deepagents-code --version

ENV HOME=/sandbox \

Check warning on line 322 in agents/langchain-deepagents-code/Dockerfile

View workflow job for this annotation

GitHub Actions / PR build and direct managed startup (Deep Agents Code)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "DEEPAGENTS_CODE_OPENAI_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 322 in agents/langchain-deepagents-code/Dockerfile

View workflow job for this annotation

GitHub Actions / PR build and direct managed startup (Deep Agents Code)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "DEEPAGENTS_CODE_OPENAI_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
VIRTUAL_ENV=/opt/venv \
PATH="/usr/local/bin:/opt/venv/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin" \
NEMOCLAW_MODEL=${NEMOCLAW_MODEL} \
Expand Down Expand Up @@ -371,7 +371,9 @@
&& mkdir -p /sandbox/.nemoclaw/state /sandbox/.nemoclaw/migration /sandbox/.nemoclaw/snapshots /sandbox/.nemoclaw/staging \
&& chown sandbox:sandbox /sandbox/.nemoclaw/state /sandbox/.nemoclaw/migration /sandbox/.nemoclaw/snapshots /sandbox/.nemoclaw/staging \
&& printf '%s' '{}' > /sandbox/.nemoclaw/config.json \
&& chown sandbox:sandbox /sandbox/.nemoclaw/config.json
&& chown sandbox:sandbox /sandbox/.nemoclaw/config.json \
&& install -d -o sandbox -g sandbox -m 0700 /sandbox/.deepagents/conversation_history \
&& test "$(stat -c '%U:%G:%a' /sandbox/.deepagents/conversation_history)" = 'sandbox:sandbox:700'
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

RUN if [ "$NEMOCLAW_DARWIN_VM_COMPAT" = "1" ]; then \
chmod -R a+rwX /sandbox/.deepagents; \
Expand Down
324 changes: 282 additions & 42 deletions scripts/install.sh

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/lib/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,7 @@ const sandboxCreateOrchestrationRuntime = {
get getDashboardForwardPort() {
return getDashboardForwardPort;
},
ownsForwardServicePort: (name: string, port: number) => ownsForwardServicePort(name, port),
readDcodeSelectionDrift: createDcodeSelectionDriftReader(sandboxExec, () => GATEWAY_NAME),
getDefaultSandboxNameForAgent,
getDockerDriverGatewayStateDir,
Expand Down Expand Up @@ -1595,7 +1596,6 @@ const createSandboxWithBaseImageResolution =
sandboxCreateOrchestration.createSandboxWithBaseImageResolution(
sandboxCreateOrchestrationRuntime,
);

const { createSandbox, createSandboxWithTemporaryManagedRuntime } =
agentOnboard.createHermesApiPortScopedSandboxEntryPoints({
createBaseImageResolutionContext: () =>
Expand All @@ -1610,7 +1610,6 @@ const { createSandbox, createSandboxWithTemporaryManagedRuntime } =
},
resolveComputePlan: dockerDriverPlatform.resolveCurrentOpenShellComputePlan,
});

// ── Step 3: Inference selection ──────────────────────────────────

type ProviderChoice = import("./onboard/provider-menu").ProviderMenuChoice;
Expand Down Expand Up @@ -2515,6 +2514,7 @@ const {
ensureAgentFixedForward,
fetchGatewayAuthTokenFromSandbox,
getDashboardForwardPort,
ownsForwardServicePort,
printDashboard,
stopAllDashboardForwards,
} = onboardDashboard.createOnboardDashboardHelpers({
Expand Down
78 changes: 78 additions & 0 deletions src/lib/onboard/dashboard-port.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
preflightDashboardPortRangeAvailability,
reserveCreateSandboxDashboardPort,
reserveDashboardPort,
reservePortAfterOwnedForwardDelete,
resolveCreateSandboxDashboardPort,
withDashboardPortReservationLock,
withDashboardPortReservationScope,
Expand Down Expand Up @@ -442,6 +443,83 @@ describe("dashboard port reservation", () => {
await result.reservation?.release();
assert.deepEqual(released, [18790]);
});

it("defers a persisted port reservation only for the exact owned forward", async () => {
const findAvailablePort = vi.fn(() => 18790);
const reservePort = vi.fn();
const ownsExistingForward = vi.fn((port: number) => port === 18789);

const result = await reserveCreateSandboxDashboardPort(
{
sandboxName: "cursor",
controlUiPort: null,
chatUiUrlEnv: null,
persistedPort: 18789,
agentForwardPort: null,
forwardListOutput: "",
registryOccupiedPorts: new Map(),
findAvailablePort,
ownsExistingForward,
},
reservePort,
);

expect(result).toMatchObject({
effectivePort: 18789,
preferredPort: 18789,
reservation: null,
});
expect(ownsExistingForward).toHaveBeenCalledExactlyOnceWith(18789);
expect(findAvailablePort).not.toHaveBeenCalled();
expect(reservePort).not.toHaveBeenCalled();
});

it("retries only EADDRINUSE while an owned forward listener retires", async () => {
const release = vi.fn(async () => undefined);
const reservePort = vi
.fn()
.mockRejectedValueOnce(Object.assign(new Error("still bound"), { code: "EADDRINUSE" }))
.mockRejectedValueOnce(Object.assign(new Error("still bound"), { code: "EADDRINUSE" }))
.mockResolvedValueOnce({ port: 18789, release });
const sleep = vi.fn();

const reservation = await reservePortAfterOwnedForwardDelete(18789, {
reservePort,
sleep,
});

expect(reservation.port).toBe(18789);
expect(reservePort.mock.calls).toEqual([[18789], [18789], [18789]]);
expect(sleep.mock.calls).toEqual([[1000], [1000]]);
await reservation.release();
expect(release).toHaveBeenCalledOnce();
});

it("does not retry a non-collision reservation failure", async () => {
const failure = Object.assign(new Error("permission denied"), { code: "EACCES" });
const reservePort = vi.fn().mockRejectedValue(failure);
const sleep = vi.fn();

await expect(reservePortAfterOwnedForwardDelete(18789, { reservePort, sleep })).rejects.toBe(
failure,
);
expect(reservePort).toHaveBeenCalledOnce();
expect(sleep).not.toHaveBeenCalled();
});

it("rebinds only a dashboard port deferred for an owned forward", async () => {
const release = vi.fn(async () => undefined);
const reservePort = vi.fn(async (port: number) => ({ port, release }));

await withDashboardPortReservationScope(async (scope) => {
scope.deferOwnedForwardPort(18789);
await scope.rebindAfterOwnedForwardDelete({ reservePort, sleep: vi.fn() });
expect(scope.current?.port).toBe(18789);
});

expect(reservePort).toHaveBeenCalledExactlyOnceWith(18789);
expect(release).toHaveBeenCalledOnce();
});
});

describe("findAvailableDashboardPort multi-gateway registry occupancy", () => {
Expand Down
64 changes: 63 additions & 1 deletion src/lib/onboard/dashboard-port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ export interface CreateSandboxDashboardPortInput {
// sandbox on a different `NEMOCLAW_GATEWAY_PORT`, which the per-gateway
// forward-list view cannot see.
registryOccupiedPorts?: ReadonlyMap<string, string>;
/** Proves an otherwise-unlisted direct ForwardTcp listener belongs to this sandbox. */
ownsExistingForward?: (port: number) => boolean;
}

export interface CreateSandboxDashboardPortResult {
Expand All @@ -434,6 +436,8 @@ export interface DashboardPortReservation {

export interface DashboardPortReservationScope {
current: DashboardPortReservation | null;
deferOwnedForwardPort(port: number): void;
rebindAfterOwnedForwardDelete(options?: ReservePortAfterOwnedForwardDeleteOptions): Promise<void>;
release(): Promise<void>;
}

Expand Down Expand Up @@ -558,6 +562,45 @@ function isAddressInUse(error: unknown): boolean {
return typeof error === "object" && error !== null && Reflect.get(error, "code") === "EADDRINUSE";
}

const OWNED_FORWARD_RELEASE_ATTEMPTS = 6;
const OWNED_FORWARD_RELEASE_INTERVAL_MS = 1_000;

export interface ReservePortAfterOwnedForwardDeleteOptions {
reservePort?: (port: number) => Promise<DashboardPortReservation>;
sleep?: (milliseconds: number) => void | Promise<void>;
}

function sleepForOwnedForwardRelease(milliseconds: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}

/**
* Rebind a port after deleting the sandbox that owned its direct ForwardTcp
* listener. Sandbox absence and detached-listener exit are separate events, so
* tolerate only the bounded EADDRINUSE convergence window; every other bind
* error remains immediately fatal.
*/
export async function reservePortAfterOwnedForwardDelete(
port: number,
options: ReservePortAfterOwnedForwardDeleteOptions = {},
): Promise<DashboardPortReservation> {
const reservePort = options.reservePort ?? reserveDashboardPort;
const sleep = options.sleep ?? sleepForOwnedForwardRelease;
let lastCollision: unknown;
for (let attempt = 1; attempt <= OWNED_FORWARD_RELEASE_ATTEMPTS; attempt += 1) {
try {
return await reservePort(port);
} catch (error) {
if (!isAddressInUse(error)) throw error;
lastCollision = error;
}
if (attempt < OWNED_FORWARD_RELEASE_ATTEMPTS) {
await sleep(OWNED_FORWARD_RELEASE_INTERVAL_MS);
}
}
throw lastCollision;
}

/**
* Select and bind a dashboard port before sandbox preparation begins. If a
* listener wins the gap between the allocation probe and bind, classify that
Expand All @@ -575,12 +618,21 @@ export async function reserveCreateSandboxDashboardPort(
);
const forwardOwner = getOccupiedPorts(input.forwardListOutput);
while (true) {
let exactOwnedForward = false;
const findAvailablePort = input.findAvailablePort ?? findAvailableDashboardPort;
const result = resolveCreateSandboxDashboardPort({
...input,
registryOccupiedPorts: occupied,
findAvailablePort: (...args) => {
if (input.ownsExistingForward?.(args[1]) === true) {
exactOwnedForward = true;
return args[1];
}
return findAvailablePort(...args);
},
warn: undefined,
});
if (forwardOwner.get(String(result.effectivePort)) === input.sandboxName) {
if (exactOwnedForward || forwardOwner.get(String(result.effectivePort)) === input.sandboxName) {
if (result.effectivePort !== result.preferredPort) {
input.warn?.(
` ! Port ${result.preferredPort} is taken. Using port ${result.effectivePort} instead.`,
Expand All @@ -607,11 +659,21 @@ export async function reserveCreateSandboxDashboardPort(
export async function withDashboardPortReservationScope<T>(
operation: (scope: DashboardPortReservationScope) => Promise<T>,
): Promise<T> {
let deferredOwnedForwardPort: number | null = null;
const scope: DashboardPortReservationScope = {
current: null,
deferOwnedForwardPort: (port) => {
if (scope.current === null) deferredOwnedForwardPort = port;
},
rebindAfterOwnedForwardDelete: async (options) => {
if (scope.current !== null || deferredOwnedForwardPort === null) return;
scope.current = await reservePortAfterOwnedForwardDelete(deferredOwnedForwardPort, options);
deferredOwnedForwardPort = null;
},
release: async () => {
const reservation = scope.current;
scope.current = null;
deferredOwnedForwardPort = null;
await reservation?.release();
},
};
Expand Down
8 changes: 8 additions & 0 deletions src/lib/onboard/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export interface OnboardDashboardHelpers {
chatUiUrl?: string,
options?: Parameters<typeof dashboardAccess.getDashboardForwardTarget>[1],
): string;
ownsForwardServicePort(sandboxName: string, port: number): boolean;
printDashboard(
sandboxName: string,
model: string,
Expand Down Expand Up @@ -288,6 +289,12 @@ export function createOnboardDashboardHelpers(deps: OnboardDashboardDeps): Onboa
);
}

function ownsForwardServicePort(sandboxName: string, port: number): boolean {
const gatewayName = resolveForwardServiceGateway(sandboxName);
if (gatewayName === null) return false;
return ownsDashboardForward(sandboxName, gatewayName, port, `http://127.0.0.1:${String(port)}`);
Comment thread
jyaunches marked this conversation as resolved.
Resolved
}

function getDashboardForwardPort(
chatUiUrl = process.env.CHAT_UI_URL || `http://127.0.0.1:${CONTROL_UI_PORT}`,
options: Parameters<typeof dashboardAccess.getDashboardForwardPort>[1] = {},
Expand Down Expand Up @@ -845,6 +852,7 @@ export function createOnboardDashboardHelpers(deps: OnboardDashboardDeps): Onboa
fetchAgentWebAuthTokenFromSandbox,
getDashboardForwardPort,
getDashboardForwardTarget,
ownsForwardServicePort,
printDashboard,
stopAllDashboardForwards,
};
Expand Down
20 changes: 20 additions & 0 deletions src/lib/onboard/hermes-api-port.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,26 @@ describe("reserveCreateSandboxHermesApiPort", () => {
expect(env[HERMES_API_PORT_ENV]).toBe("8642");
});

it("defers a durable port reservation only for the exact owned forward", async () => {
const reservePort = vi.fn();
const ownsExistingForward = vi.fn((port: number) => port === 8643);

const selection = await reserveCreateSandboxHermesApiPort({
sandboxName: "beta",
env: {},
getSandbox: () => ({ hermesApiPort: 8643 }),
forwardListOutput: "",
isPortBoundCheck: () => true,
registryOccupiedPorts: new Map(),
reservePort,
ownsExistingForward,
});

expect(selection).toEqual({ effectivePort: 8643, reservation: null });
expect(ownsExistingForward).toHaveBeenCalledExactlyOnceWith(8643);
expect(reservePort).not.toHaveBeenCalled();
});

it("releases a held port when sandbox preparation fails", async () => {
const release = vi.fn(async () => undefined);

Expand Down
24 changes: 21 additions & 3 deletions src/lib/onboard/hermes-api-port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
isPortBoundOnHost,
type ListSandboxesFn,
reserveDashboardPort,
reservePortAfterOwnedForwardDelete,
} from "./dashboard-port";

export const HERMES_API_PORT_ENV = "NEMOCLAW_HERMES_API_PORT";
Expand Down Expand Up @@ -51,6 +52,7 @@ export interface HermesApiPortReservationInput {
getSandbox(name: string): HermesApiPortSandboxLookup | null | undefined;
captureForwardList(): string | null;
reservePort?(port: number): Promise<DashboardPortReservation>;
ownsExistingForward?(port: number): boolean;
warn(message: string): void;
}

Expand Down Expand Up @@ -208,6 +210,7 @@ export async function reserveCreateSandboxHermesApiPort(options: {
isPortBoundCheck?: (port: number) => boolean;
registryOccupiedPorts?: ReadonlyMap<string, string>;
reservePort?: (port: number) => Promise<DashboardPortReservation>;
ownsExistingForward?: (port: number) => boolean;
warn?: (message: string) => void;
}): Promise<ReservedCreateSandboxHermesApiPortResult> {
const env = options.env ?? process.env;
Expand All @@ -220,7 +223,10 @@ export async function reserveCreateSandboxHermesApiPort(options: {
const reserveSelectedPort = async (
effectivePort: number,
): Promise<ReservedCreateSandboxHermesApiPortResult> => {
if (forwardOwners.get(String(effectivePort)) === options.sandboxName) {
if (
forwardOwners.get(String(effectivePort)) === options.sandboxName ||
options.ownsExistingForward?.(effectivePort) === true
) {
return { effectivePort, reservation: null };
}
return { effectivePort, reservation: await reservePort(effectivePort) };
Expand Down Expand Up @@ -269,6 +275,7 @@ export async function reserveCreateSandboxHermesApiPort(options: {
}

export function createHermesApiPortReservationScope(): HermesApiPortReservationScope {
let deferredOwnedForwardPort: number | null = null;
return {
current: null,
effectivePort: null,
Expand All @@ -281,21 +288,32 @@ export function createHermesApiPortReservationScope(): HermesApiPortReservationS
allowRegisteredOverride: true,
forwardListOutput: input.captureForwardList(),
reservePort: input.reservePort,
ownsExistingForward: input.ownsExistingForward,
warn: input.warn,
});
this.effectivePort = selection.effectivePort;
this.current = selection.reservation;
deferredOwnedForwardPort = selection.reservation === null ? selection.effectivePort : null;
},
async rebindAfterOwnedForwardDelete(input) {
if (input.agentName !== "hermes" || this.current !== null) return;
await this.selectAndReserve({ ...input, captureForwardList: () => "" });
if (
input.agentName !== "hermes" ||
this.current !== null ||
deferredOwnedForwardPort === null
)
return;
this.current = await reservePortAfterOwnedForwardDelete(deferredOwnedForwardPort, {
reservePort: input.reservePort,
});
deferredOwnedForwardPort = null;
},
async releaseBeforeForward(agentName, port) {
if (agentName === "hermes" && this.current?.port === port) await this.release();
},
async release() {
const reservation = this.current;
this.current = null;
deferredOwnedForwardPort = null;
await reservation?.release();
},
};
Expand Down
Loading
Loading