Repository navigation
fix(messaging): remove stopped provider egress on rebuild #10592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
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 303b1fa
test(e2e): verify Google Chat fixture invocation
sandl99 f001468
test(e2e): bound Google Chat fixture subprocess
sandl99 42f62dc
merge: resolve conflicts with main
github-actions[bot] 43cb11c
fix(messaging): remove stopped provider egress on rebuild
sandl99 ad91d5b
merge: synchronize current main
sandl99 5701b73
fix(onboard): report retained rebuild policy
sandl99 97eb20e
fix(onboard): preserve post-create identity checks
sandl99 1c583a8
fix(onboard): revalidate published Hermes identity
sandl99 b09dedd
fix(e2e): restore fake API port publishing
jyaunches 90f082a
fix(onboard): bind published create identity
sandl99 c161be1
Merge branch 'main' into fix/e2e-googlechat-fixture
sandl99 20fd192
fix(e2e): isolate fake API port proxy
jyaunches d44f82d
fix(onboard): harden rebuild policy handoff
sandl99 834f816
fix(onboard): identify retained replacement policy
sandl99 6524423
fix(onboard): tighten rebuild provider authority
sandl99 554adb3
merge: isolate messaging provider fake API
sandl99 8302741
fix(e2e): restore isolated messaging API ports
sandl99 df078b4
test(e2e): cover fake API port proxy fail-closed validation
sandl99 27f9f12
Merge branch 'main' into fix/e2e-googlechat-fixture
sandl99 a392bb0
Merge remote-tracking branch 'origin/fix/e2e-googlechat-fixture' into…
sandl99 d8fa5a0
fix(state): stop treating on-demand OpenClaw plugins as image-managed
sandl99 cb9364d
fix(e2e): discover the WeChat plugin from its npm project cache
sandl99 f64ec06
fix(sandbox): fall back to the overlay2 upper layer for stopped-conta…
sandl99 6d4146e
chore(sandbox): add temporary overlay-fallback diagnostics
sandl99 5fbd60b
fix(sandbox): trust Docker's own bind-mount validation for the overla…
sandl99 33b3917
fix(e2e): pre-pull the stopped-cleanup helper image before offline use
sandl99 1d85bd6
chore(e2e): add temporary diagnostic for the WeChat proxy ECONNREFUSED
sandl99 c135cdc
merge: refresh PR from main
apurvvkumaria 357ee7a
fix(messaging): close rebuild review gaps
apurvvkumaria 56093a5
chore(e2e): add host-reachability diagnostic for the WeChat proxy ECO…
sandl99 aae671e
refactor(e2e): share managed npm discovery
apurvvkumaria 9d4622c
Merge remote-tracking branch 'origin/fix/e2e-googlechat-fixture' into…
sandl99 912d082
test(e2e): register messaging proof helpers
apurvvkumaria 9057d8d
Merge remote-tracking branch 'origin/fix/e2e-googlechat-fixture' into…
sandl99 661a9ee
chore(e2e): register the shared managed-npm-discovery source in mock-…
sandl99 a4286b2
merge: integrate concurrent PR updates
apurvvkumaria 8782b33
merge: refresh PR with current main
apurvvkumaria 49d148e
test(e2e): remove temporary WeChat diagnostic
apurvvkumaria 532c422
fix(onboard): preserve exact policy cleanup authority
apurvvkumaria dfab8e1
test(e2e): restore stopped-cleanup image pin regression coverage
sandl99 fd80401
test(state): execute snapshot cleanup fixtures
apurvvkumaria 20d3962
test(e2e): remove stopped-cleanup source-shape assertion
apurvvkumaria a333521
test(e2e): cover the stopped-cleanup image warm-up as behavior
sandl99 b50f821
test(sandbox): prove stopped overlay cleanup
apurvvkumaria 236da5c
fix(e2e): wait for fake API proxy listener
sandl99 1d5fd68
fix(messaging): remove unsupported stopped cleanup
sandl99 f7936fa
test(e2e): remove duplicate provider cleanup coverage
sandl99 456a98b
merge: resolve conflicts with main
github-actions[bot] 6131dd6
merge: resolve conflicts with main
github-actions[bot] 25c5b54
merge: resolve conflicts with main
github-actions[bot] 38279b5
merge: resolve conflicts with main
github-actions[bot] 0435eef
merge: resolve conflicts with main
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] ?? "")) { | ||
| main().catch((error: unknown) => { | ||
| console.error(error instanceof Error ? error.message : String(error)); | ||
| process.exitCode = 1; | ||
| }); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.