Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 4 additions & 0 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ assembles one exact candidate catalog from the workflow's published contracts, u
and sandbox, records the authenticated discovery diagnostics, scans the evidence for fixture
credentials, and must pass.
These are two required acceptance executions, not retries; either failure remains a failed check.
The concurrent-add probe retries only the rejected command after status proves that the other
command committed one coherent bridge. The rejected command must report either the exact portable
host-lock timeout or the reviewed Hermes restart transport failure. The retry runs once, has its own
command artifact, and must reject the committed duplicate as already present.
The workflow records one publication cohort before its PR producer matrix runs. Failed-job reruns
reuse that cohort and replace only the stable run-scoped artifact owned by each retried agent.
Consumers accept one complete cohort from the same run at the current or an earlier attempt. They
Expand Down
14 changes: 10 additions & 4 deletions test/e2e/live/mcp-bridge-reliability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ const HERMES_RESTART_SUCCESS_PREFIX = new RegExp(
].join("\n")}$`,
"u",
);
const PORTABLE_HOST_LOCK_CONTENTION =
/^Error: Failed to acquire lock on \/[^\n]*\/\.nemoclaw-portable-host\.lock after 120 retries$/u;

function normalizeHermesTransportDiagnostic(diagnostic: string): string {
return diagnostic
Expand Down Expand Up @@ -665,19 +667,23 @@ export function isHermesRestartTransportFailure(adapter: string, diagnostic: str
return HERMES_RESTART_SUCCESS_PREFIX.test(normalized.slice(0, -suffix.length));
}

export async function retryAfterHermesRestartTransportFailure<T>(options: {
export async function retryAfterConcurrentAddTransientFailure<T>(options: {
adapter: string;
committedBridgeVerified: boolean;
diagnostic: string;
originalResult: T;
retry: () => Promise<T>;
}): Promise<T> {
if (!options.committedBridgeVerified) {
throw new Error("Hermes restart retry requires a verified committed bridge");
throw new Error("Concurrent add retry requires a verified committed bridge");
}
if (/already exists/iu.test(options.diagnostic)) return options.originalResult;
if (!isHermesRestartTransportFailure(options.adapter, options.diagnostic)) {
throw new Error("rejected concurrent add was not a known Hermes restart transport failure");
const diagnostic = normalizeHermesTransportDiagnostic(options.diagnostic);
if (
!PORTABLE_HOST_LOCK_CONTENTION.test(diagnostic) &&
!isHermesRestartTransportFailure(options.adapter, options.diagnostic)
) {
throw new Error("rejected concurrent add was not a known transient failure");
}
return options.retry();
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/live/mcp-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import {
runOpenClawDeniedToolUpdateProof,
restartBridgeWithoutHostSecret,
retryOpenClawBaselineScopeOnboardFailure,
retryAfterHermesRestartTransportFailure,
retryAfterConcurrentAddTransientFailure,
retryHermesGatewayDraining,
} from "./mcp-bridge-reliability.ts";
import {
Expand Down Expand Up @@ -340,7 +340,7 @@ async function assertConcurrentAddSerialized(
policy: { registryPresent: true, gatewayPresent: true },
});
expect(statusObservation.registered).toBe(true);
const duplicateRejection = await retryAfterHermesRestartTransportFailure({
const duplicateRejection = await retryAfterConcurrentAddTransientFailure({
adapter: options.expectedAdapter,
committedBridgeVerified: true,
diagnostic: resultText(rejected[0]!),
Expand Down
38 changes: 32 additions & 6 deletions test/e2e/support/mcp-bridge-reliability.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
MCP_BRIDGE_TEST_REDACTION_VALUES,
readConcurrentMcpStatusAndConfirmHermesRegistration,
restartBridgeWithoutHostSecret,
retryAfterHermesRestartTransportFailure,
retryAfterConcurrentAddTransientFailure,
retryHermesGatewayDraining,
retryOpenClawBaselineScopeOnboardFailure,
} from "../live/mcp-bridge-reliability.ts";
Expand Down Expand Up @@ -640,7 +640,7 @@ describe("MCP bridge transient classification", () => {
const retry = vi.fn(async () => ({ exitCode: 2 }));

await expect(
retryAfterHermesRestartTransportFailure({
retryAfterConcurrentAddTransientFailure({
adapter: "hermes-config",
committedBridgeVerified: true,
diagnostic: "server already exists",
Expand All @@ -656,7 +656,7 @@ describe("MCP bridge transient classification", () => {
const retry = vi.fn(async () => retryResult);

await expect(
retryAfterHermesRestartTransportFailure({
retryAfterConcurrentAddTransientFailure({
adapter: "hermes-config",
committedBridgeVerified: true,
diagnostic: HERMES_BROKEN_PIPE,
Expand All @@ -667,26 +667,52 @@ describe("MCP bridge transient classification", () => {
expect(retry).toHaveBeenCalledOnce();
});

it("retries the portable host lock loser after the committed bridge is verified", async () => {
const retryResult = { exitCode: 1 };
const retry = vi.fn(async () => retryResult);

await expect(
retryAfterConcurrentAddTransientFailure({
adapter: "mcporter",
committedBridgeVerified: true,
diagnostic:
"Error: Failed to acquire lock on /home/runner/.nemoclaw-portable-host.lock after 120 retries",
originalResult: { exitCode: 1 },
retry,
}),
).resolves.toBe(retryResult);
expect(retry).toHaveBeenCalledOnce();
});

it("fails closed for an unknown rejection", async () => {
const retry = vi.fn(async () => ({ exitCode: 1 }));

await expect(
retryAfterHermesRestartTransportFailure({
retryAfterConcurrentAddTransientFailure({
adapter: "hermes-config",
committedBridgeVerified: true,
diagnostic: "unexpected transport error",
originalResult: { exitCode: 1 },
retry,
}),
).rejects.toThrow("not a known Hermes restart transport failure");
).rejects.toThrow("not a known transient failure");
await expect(
retryAfterConcurrentAddTransientFailure({
adapter: "mcporter",
committedBridgeVerified: true,
diagnostic: "Error: Failed to acquire lock on /tmp/other.lock after 120 retries",
originalResult: { exitCode: 1 },
retry,
}),
).rejects.toThrow("not a known transient failure");
expect(retry).not.toHaveBeenCalled();
});

it("refuses retry before the committed bridge is verified", async () => {
const retry = vi.fn(async () => ({ exitCode: 1 }));

await expect(
retryAfterHermesRestartTransportFailure({
retryAfterConcurrentAddTransientFailure({
adapter: "hermes-config",
committedBridgeVerified: false,
diagnostic: HERMES_BROKEN_PIPE,
Expand Down
Loading