Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
cdc12b2
fix(e2e): restore Google Chat credential fixture
sandl99 Aug 29, 2026
303b1fa
test(e2e): verify Google Chat fixture invocation
sandl99 Aug 29, 2026
f001468
test(e2e): bound Google Chat fixture subprocess
sandl99 Aug 29, 2026
42f62dc
merge: resolve conflicts with main
github-actions[bot] Aug 30, 2026
43cb11c
fix(messaging): remove stopped provider egress on rebuild
sandl99 Aug 31, 2026
ad91d5b
merge: synchronize current main
sandl99 Aug 31, 2026
5701b73
fix(onboard): report retained rebuild policy
sandl99 Aug 31, 2026
97eb20e
fix(onboard): preserve post-create identity checks
sandl99 Aug 31, 2026
1c583a8
fix(onboard): revalidate published Hermes identity
sandl99 Aug 31, 2026
b09dedd
fix(e2e): restore fake API port publishing
jyaunches Aug 31, 2026
90f082a
fix(onboard): bind published create identity
sandl99 Aug 31, 2026
c161be1
Merge branch 'main' into fix/e2e-googlechat-fixture
sandl99 Aug 31, 2026
20fd192
fix(e2e): isolate fake API port proxy
jyaunches Aug 31, 2026
d44f82d
fix(onboard): harden rebuild policy handoff
sandl99 Aug 31, 2026
834f816
fix(onboard): identify retained replacement policy
sandl99 Aug 31, 2026
6524423
fix(onboard): tighten rebuild provider authority
sandl99 Aug 31, 2026
554adb3
merge: isolate messaging provider fake API
sandl99 Aug 31, 2026
8302741
fix(e2e): restore isolated messaging API ports
sandl99 Aug 31, 2026
df078b4
test(e2e): cover fake API port proxy fail-closed validation
sandl99 Aug 31, 2026
27f9f12
Merge branch 'main' into fix/e2e-googlechat-fixture
sandl99 Aug 31, 2026
a392bb0
Merge remote-tracking branch 'origin/fix/e2e-googlechat-fixture' into…
sandl99 Aug 31, 2026
d8fa5a0
fix(state): stop treating on-demand OpenClaw plugins as image-managed
sandl99 Aug 31, 2026
cb9364d
fix(e2e): discover the WeChat plugin from its npm project cache
sandl99 Aug 31, 2026
f64ec06
fix(sandbox): fall back to the overlay2 upper layer for stopped-conta…
sandl99 Aug 31, 2026
6d4146e
chore(sandbox): add temporary overlay-fallback diagnostics
sandl99 Aug 31, 2026
5fbd60b
fix(sandbox): trust Docker's own bind-mount validation for the overla…
sandl99 Aug 31, 2026
33b3917
fix(e2e): pre-pull the stopped-cleanup helper image before offline use
sandl99 Aug 31, 2026
1d85bd6
chore(e2e): add temporary diagnostic for the WeChat proxy ECONNREFUSED
sandl99 Aug 31, 2026
c135cdc
merge: refresh PR from main
apurvvkumaria Aug 31, 2026
357ee7a
fix(messaging): close rebuild review gaps
apurvvkumaria Aug 31, 2026
56093a5
chore(e2e): add host-reachability diagnostic for the WeChat proxy ECO…
sandl99 Aug 31, 2026
aae671e
refactor(e2e): share managed npm discovery
apurvvkumaria Aug 31, 2026
9d4622c
Merge remote-tracking branch 'origin/fix/e2e-googlechat-fixture' into…
sandl99 Aug 31, 2026
912d082
test(e2e): register messaging proof helpers
apurvvkumaria Aug 31, 2026
9057d8d
Merge remote-tracking branch 'origin/fix/e2e-googlechat-fixture' into…
sandl99 Aug 31, 2026
661a9ee
chore(e2e): register the shared managed-npm-discovery source in mock-…
sandl99 Aug 31, 2026
a4286b2
merge: integrate concurrent PR updates
apurvvkumaria Aug 31, 2026
8782b33
merge: refresh PR with current main
apurvvkumaria Aug 31, 2026
49d148e
test(e2e): remove temporary WeChat diagnostic
apurvvkumaria Aug 31, 2026
532c422
fix(onboard): preserve exact policy cleanup authority
apurvvkumaria Aug 31, 2026
dfab8e1
test(e2e): restore stopped-cleanup image pin regression coverage
sandl99 Aug 31, 2026
fd80401
test(state): execute snapshot cleanup fixtures
apurvvkumaria Aug 31, 2026
20d3962
test(e2e): remove stopped-cleanup source-shape assertion
apurvvkumaria Aug 31, 2026
a333521
test(e2e): cover the stopped-cleanup image warm-up as behavior
sandl99 Aug 31, 2026
b50f821
test(sandbox): prove stopped overlay cleanup
apurvvkumaria Aug 31, 2026
236da5c
fix(e2e): wait for fake API proxy listener
sandl99 Aug 31, 2026
1d5fd68
fix(messaging): remove unsupported stopped cleanup
sandl99 Aug 31, 2026
f7936fa
test(e2e): remove duplicate provider cleanup coverage
sandl99 Aug 31, 2026
456a98b
merge: resolve conflicts with main
github-actions[bot] Sep 1, 2026
6131dd6
merge: resolve conflicts with main
github-actions[bot] Sep 2, 2026
25c5b54
merge: resolve conflicts with main
github-actions[bot] Sep 2, 2026
38279b5
merge: resolve conflicts with main
github-actions[bot] Sep 3, 2026
0435eef
merge: resolve conflicts with main
github-actions[bot] Sep 3, 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
281 changes: 281 additions & 0 deletions test/e2e/live/channels-stop-start-googlechat-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import path from "node:path";
import { fileURLToPath } from "node:url";

import type { AddSandboxChannelDependencies } from "../../../src/lib/actions/sandbox/policy-channel.ts";
import * as policyChannelDependenciesModule from "../../../src/lib/actions/sandbox/policy-channel-dependencies.ts";
import * as policyChannelModule from "../../../src/lib/actions/sandbox/policy-channel.ts";
import * as openshellRuntimeModule from "../../../src/lib/adapters/openshell/runtime.ts";
import * as messagingBridgeProviderModule from "../../../src/lib/onboard/messaging-bridge-provider.ts";
import * as onboardProvidersModule from "../../../src/lib/onboard/providers.ts";
import * as statePathsModule from "../../../src/lib/state/paths.ts";
import { assertChannelsStopStartSandboxName } from "./channels-stop-start-safety.ts";
import type { AgentKind } from "./phase6-messaging-helpers.ts";

type PolicyChannelModule = typeof import("../../../src/lib/actions/sandbox/policy-channel.ts");
type PolicyChannelDependenciesModule =
typeof import("../../../src/lib/actions/sandbox/policy-channel-dependencies.ts");
type OpenshellRuntimeModule = typeof import("../../../src/lib/adapters/openshell/runtime.ts");
type MessagingBridgeProviderModule =
typeof import("../../../src/lib/onboard/messaging-bridge-provider.ts");
type StatePathsModule = typeof import("../../../src/lib/state/paths.ts");
type ProviderUpsertOptions = {
readonly replaceExisting?: boolean;
readonly revalidatePolicyRequirements?: (operation: string) => void;
};
type ProviderDependencies = {
upsertMessagingProviders(
tokenDefs: Parameters<typeof policyChannelDependencies.upsertMessagingProviders>[0],
run: typeof runOpenshell,
options?: ProviderUpsertOptions,
): string[];
};

const policyChannel = (
"default" in policyChannelModule ? policyChannelModule.default : policyChannelModule
) as PolicyChannelModule;
const { addSandboxChannel } = policyChannel;
const policyChannelDependenciesNamespace = (
"default" in policyChannelDependenciesModule
? policyChannelDependenciesModule.default
: policyChannelDependenciesModule
) as PolicyChannelDependenciesModule;
const { policyChannelDependencies } = policyChannelDependenciesNamespace;
const openshellRuntime = (
"default" in openshellRuntimeModule ? openshellRuntimeModule.default : openshellRuntimeModule
) as OpenshellRuntimeModule;
const { runOpenshell } = openshellRuntime;
const messagingBridgeProvider = (
"default" in messagingBridgeProviderModule
? messagingBridgeProviderModule.default
: messagingBridgeProviderModule
) as MessagingBridgeProviderModule;
const { ensureMessagingBridgeProfiles } = messagingBridgeProvider;
const onboardProviders = (
"default" in onboardProvidersModule ? onboardProvidersModule.default : onboardProvidersModule
) as ProviderDependencies;
const statePaths = (
"default" in statePathsModule ? statePathsModule.default : statePathsModule
) as StatePathsModule;
const { ROOT } = statePaths;

interface GooglechatLiveE2eComposition {
readonly sandboxName: string;
readonly agent: AgentKind;
readonly audience: string;
}

interface GooglechatLiveE2eDependencies {
readonly addSandboxChannel: (
sandboxName: string,
options: { readonly channel: string },
dependencies: AddSandboxChannelDependencies,
) => Promise<void>;
readonly installCredentialFixture: (sandboxName: string, agent: AgentKind) => () => void;
readonly rebuildSandbox?: (sandboxName: string, args: string[]) => Promise<unknown>;
}

interface GooglechatCredentialFixtureDependencies {
readonly ensureProfiles?: typeof ensureMessagingBridgeProfiles;
readonly providerDependencies?: ProviderDependencies;
readonly root?: string;
readonly run?: typeof runOpenshell;
}

export const GOOGLECHAT_E2E_ACCESS_TOKEN = "e2e-fake-googlechat-access-token";

const PROVIDER_TYPE_BY_AGENT: Readonly<Record<AgentKind, string>> = {
openclaw: "google-chat-bridge",
hermes: "google-chat-hermes-bridge",
};

/**
* Replace Google Chat's asynchronous Google OAuth mint only inside this live-test
* composition root. The fixed value is not a credential. Creating the real
* OpenShell provider with it still exercises provider identity, revision-scoped
* sandbox injection, bound provider egress, and removal without requiring a
* Google service account in CI.
*/
export function installGooglechatCredentialFixture(
sandboxName: string,
agent: AgentKind,
dependencies: GooglechatCredentialFixtureDependencies = {},
): () => void {
assertChannelsStopStartSandboxName(sandboxName, agent);
const ensureProfiles = dependencies.ensureProfiles ?? ensureMessagingBridgeProfiles;
const providerDependencies = dependencies.providerDependencies ?? onboardProviders;
const root = dependencies.root ?? ROOT;
const run = dependencies.run ?? runOpenshell;
const expectedName = `${sandboxName}-googlechat-bridge`;
const expectedType = PROVIDER_TYPE_BY_AGENT[agent];
const original = providerDependencies.upsertMessagingProviders;

providerDependencies.upsertMessagingProviders = (tokenDefs, providerRun, options = {}) => {
const fixtureTokenDefs = tokenDefs.filter(({ name }) => name === expectedName);
const fixtureTokenDef = fixtureTokenDefs[0];
if (
fixtureTokenDefs.length !== 1 ||
fixtureTokenDef?.envKey !== "GOOGLE_CHAT_ACCESS_TOKEN" ||
fixtureTokenDef?.providerType !== expectedType
) {
throw new Error("Google Chat live fixture received an unexpected provider definition");
}

const delegatedTokenDefs = tokenDefs.filter(({ name }) => name !== expectedName);
const delegatedProviderNames =
delegatedTokenDefs.length === 0 ? [] : original(delegatedTokenDefs, providerRun, options);
const baseRun = providerRun ?? run;
const revalidate = () =>
options.revalidatePolicyRequirements?.(
`manage Google Chat live fixture provider '${expectedName}'`,
);
const effectiveRun: typeof runOpenshell = (args, runOptions) => {
revalidate();
return baseRun(args, runOptions);
};
ensureProfiles(fixtureTokenDefs, {
root,
runOpenshell: effectiveRun,
redact: (value) => value.replaceAll(GOOGLECHAT_E2E_ACCESS_TOKEN, "[redacted]"),
});
const existing = effectiveRun(["provider", "get", expectedName], {
ignoreError: true,
stdio: ["ignore", "pipe", "pipe"],
});
if (existing.status === 0 && options.replaceExisting) {
const removed = effectiveRun(["provider", "delete", expectedName], {
ignoreError: true,
stdio: ["ignore", "pipe", "pipe"],
});
if (removed.status !== 0) {
throw new Error(`Google Chat live fixture could not replace provider '${expectedName}'`);
}
}
const action = existing.status === 0 && !options.replaceExisting ? "update" : "create";
const providerArgs =
action === "update"
? ["provider", "update", expectedName, "--credential", "GOOGLE_CHAT_ACCESS_TOKEN"]
: [
"provider",
"create",
"--name",
expectedName,
"--type",
expectedType,
"--credential",
"GOOGLE_CHAT_ACCESS_TOKEN",
];
const mutated = effectiveRun(providerArgs, {
env: { GOOGLE_CHAT_ACCESS_TOKEN: GOOGLECHAT_E2E_ACCESS_TOKEN },
ignoreError: true,
stdio: ["ignore", "pipe", "pipe"],
});
if (mutated.status !== 0) {
throw new Error(`Google Chat live fixture could not ${action} provider '${expectedName}'`);
}
const registered = new Set([...delegatedProviderNames, expectedName]);
return tokenDefs.map(({ name }) => name).filter((name) => registered.has(name));
};

return () => {
providerDependencies.upsertMessagingProviders = original;
};
}

const DEFAULT_DEPENDENCIES: GooglechatLiveE2eDependencies = {
addSandboxChannel,
installCredentialFixture: installGooglechatCredentialFixture,
rebuildSandbox: (sandboxName, args) =>
policyChannelDependencies.rebuildSandbox(sandboxName, args),
};

function requireLiveAudience(input: GooglechatLiveE2eComposition): string {
assertChannelsStopStartSandboxName(input.sandboxName, input.agent);
const audience = input.audience.trim();
if (!audience) {
throw new Error("GOOGLECHAT_AUDIENCE is required for the channels-stop-start live target");
}
return audience;
}

async function addGooglechatWithInstalledFixture(
input: GooglechatLiveE2eComposition,
audience: string,
dependencies: GooglechatLiveE2eDependencies,
): Promise<void> {
await dependencies.addSandboxChannel(
input.sandboxName,
{ channel: "googlechat" },
input.agent === "openclaw"
? {
googlechatNonInteractiveAudienceCapability: Object.freeze({ audience }),
}
: {},
);
}

/** Keep the fake OAuth mint installed across both provider registrations. */
export async function addAndRebuildGooglechatForChannelsStopStartLiveE2e(
input: GooglechatLiveE2eComposition,
dependencies: GooglechatLiveE2eDependencies = DEFAULT_DEPENDENCIES,
): Promise<void> {
const audience = requireLiveAudience(input);
if (!dependencies.rebuildSandbox) {
throw new Error("Google Chat live rebuild dependency is unavailable");
}

const restore = dependencies.installCredentialFixture(input.sandboxName, input.agent);
try {
await addGooglechatWithInstalledFixture(input, audience, dependencies);
await dependencies.rebuildSandbox(input.sandboxName, ["--yes"]);
} finally {
restore();
}
}

/** Keep the fake OAuth mint installed while a later lifecycle rebuild reconciles Google Chat. */
export async function rebuildGooglechatForChannelsStopStartLiveE2e(
input: Pick<GooglechatLiveE2eComposition, "sandboxName" | "agent">,
dependencies: GooglechatLiveE2eDependencies = DEFAULT_DEPENDENCIES,
): Promise<void> {
if (!dependencies.rebuildSandbox) {
throw new Error("Google Chat live rebuild dependency is unavailable");
}

const restore = dependencies.installCredentialFixture(input.sandboxName, input.agent);
try {
await dependencies.rebuildSandbox(input.sandboxName, ["--yes"]);
} finally {
restore();
}
}

async function main(): Promise<void> {
const agent = (process.env.NEMOCLAW_CHANNELS_STOP_START_AGENT ?? process.env.NEMOCLAW_AGENT) as
| AgentKind
| undefined;
if (agent !== "openclaw" && agent !== "hermes") {
throw new Error("NEMOCLAW_CHANNELS_STOP_START_AGENT must be openclaw or hermes");
}
const sandboxName = process.argv[2] ?? "";
const mode = process.argv[3];
if (mode === "--rebuild-only") {
await rebuildGooglechatForChannelsStopStartLiveE2e({ sandboxName, agent });
return;
}
if (mode) throw new Error(`unknown Google Chat live E2E mode '${mode}'`);
await addAndRebuildGooglechatForChannelsStopStartLiveE2e({
sandboxName,
agent,
audience: process.env.GOOGLECHAT_AUDIENCE ?? "",
});
}

if (fileURLToPath(import.meta.url) === path.resolve(process.argv[1] ?? "")) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
main().catch((error: unknown) => {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
});
}
Loading
Loading