From 7e358fc756ff3af743b09b780f4b64e21197d226 Mon Sep 17 00:00:00 2001 From: Will Curran Date: Fri, 23 Oct 2026 13:59:14 -0700 Subject: [PATCH 1/6] fix(telemetry): preserve bounded observed schema values Signed-off-by: Will Curran --- src/lib/actions/telemetry/operation.ts | 8 +- src/lib/actions/telemetry/send.ts | 24 +++--- src/lib/actions/telemetry/snapshot.test.ts | 4 +- src/lib/actions/telemetry/snapshot.ts | 25 +++--- src/lib/adapters/telemetry/gxt.ts | 2 +- src/lib/cli/installer-telemetry-entry.ts | 10 +-- src/lib/domain/telemetry/dimensions.ts | 93 +++++++++++----------- src/lib/domain/telemetry/event.ts | 6 +- src/lib/domain/telemetry/provenance.ts | 33 ++++---- src/lib/domain/telemetry/schema.ts | 49 +++++------- src/lib/domain/telemetry/values.ts | 39 --------- src/lib/sandbox/config-telemetry.ts | 28 +++---- 12 files changed, 124 insertions(+), 197 deletions(-) diff --git a/src/lib/actions/telemetry/operation.ts b/src/lib/actions/telemetry/operation.ts index e4858c482cf..fa6943f37a7 100644 --- a/src/lib/actions/telemetry/operation.ts +++ b/src/lib/actions/telemetry/operation.ts @@ -170,10 +170,11 @@ export function setTelemetryOutcome( export function recordTelemetryVersions(versions: { previous?: string; target?: string; - installed?: string; + installed?: string | null; }): void { appendReceipt({ kind: "versions", ...versions }); } + function readReceipts(current: Context): Record[] { return privateFile(current.directory, "receipts.ndjson", 1_048_576) .split("\n") @@ -288,7 +289,8 @@ function terminalContext(current: Context, exitCode = 0): TelemetryOperationCont else if (receipt.kind === "versions") { if (typeof receipt.previous === "string") metadata.previousVersion = receipt.previous; if (typeof receipt.target === "string") metadata.targetVersion = receipt.target; - if (typeof receipt.installed === "string") metadata.installedVersion = receipt.installed; + if (typeof receipt.installed === "string" || receipt.installed === null) + metadata.installedVersion = receipt.installed; } } metadata.targets = [...targets.values()]; @@ -599,7 +601,7 @@ export async function finishInstallerTelemetry( state: TelemetryState, scope: TelemetryScope, exitCode: number, - versions: { previous?: string; target?: string; installed?: string } = {}, + versions: { previous?: string; target?: string; installed?: string | null } = {}, ): Promise { const inherited = inheritedContext(); if (!inherited || inherited.directory !== directory) return; diff --git a/src/lib/actions/telemetry/send.ts b/src/lib/actions/telemetry/send.ts index d680182f348..9af653a36fd 100644 --- a/src/lib/actions/telemetry/send.ts +++ b/src/lib/actions/telemetry/send.ts @@ -10,7 +10,6 @@ import type { ValueStatus, } from "../../domain/telemetry/event"; import { readTelemetryTestLabel } from "../../domain/telemetry/event"; -import { PUBLIC_VERSION_PATTERN } from "../../domain/telemetry/schema"; import { operationEnvelope } from "../../adapters/telemetry/gxt"; import { allowedTelemetryCollection, @@ -27,10 +26,7 @@ function publicVersion( value: unknown, missing: ValueStatus, ): { value: string; status: ValueStatus } { - return typeof value === "string" && - value !== "unknown" && - value.length <= 128 && - new RegExp(PUBLIC_VERSION_PATTERN).test(value) + return typeof value === "string" && value.length > 0 && value !== "unknown" ? { value, status: "reported" } : { value: "unknown", status: value == null || value === "unknown" ? missing : "unapproved" }; } @@ -54,6 +50,7 @@ function missingObservation(value: unknown): boolean { return Object.entries(value).some( ([key, item]) => ((key === "status" || key.endsWith("Status")) && + !(key === "hostHardwarePlatformStatus" && item === "not_observed") && ["collection_error", "not_observed", "not_persisted", "unavailable"].includes(item)) || missingObservation(item), ); @@ -81,15 +78,10 @@ export async function collectOperationEvent( ? "not_observed" : "not_applicable", ); + const hostPlatform = os.platform(); const hostOS = - process.platform === "darwin" - ? "macos" - : process.platform === "win32" - ? "windows" - : process.platform === "linux" - ? "linux" - : "other"; - const hostArch = ["x64", "arm64", "ia32", "arm"].includes(process.arch) ? process.arch : "other"; + hostPlatform === "darwin" ? "macos" : hostPlatform === "win32" ? "windows" : hostPlatform; + const hostArch = os.arch(); const { targetPositions: _privatePositions, ...publicSnapshot } = snapshot; const event: TelemetryOperationEvent = { name: "nemoclaw_operation_finished", @@ -115,11 +107,13 @@ export async function collectOperationEvent( }, platform: { hostOS, - hostOSStatus: hostOS === "other" ? "unapproved" : "reported", + hostOSStatus: "reported", hostArch, - hostArchStatus: hostArch === "other" ? "unapproved" : "reported", + hostArchStatus: "reported", hostContext: hostOS === "linux" && /microsoft/i.test(os.release()) ? "wsl" : "native", hostContextStatus: "reported", + hostHardwarePlatform: "", + hostHardwarePlatformStatus: "not_observed", }, location: { countryCode: "", diff --git a/src/lib/actions/telemetry/snapshot.test.ts b/src/lib/actions/telemetry/snapshot.test.ts index f96b20a6409..69255b66d62 100644 --- a/src/lib/actions/telemetry/snapshot.test.ts +++ b/src/lib/actions/telemetry/snapshot.test.ts @@ -248,7 +248,7 @@ it("joins a published OpenClaw configuration to its operation target (#12859)", }, ], }); - expect(event.parameters.configurations[0].agents[0].models[0].modelId).toBe("other"); + expect(event.parameters.configurations[0].agents[0].models[0].modelId).toBe("gpt-4o"); expect(event.parameters.configurations[1].agents).toHaveLength(1); expect(event.parameters.configurations[1].agents[0].models[0]).toMatchObject({ modelId: "nvidia/nemotron-3-ultra-550b-a55b", @@ -346,7 +346,7 @@ async function collectNativeConfiguration( it.each([ ["0.1.71", "0.1.71", "reported"], - ["private-build", "other", "unapproved"], + ["private-build", "private-build", "reported"], ])( "reports managed Deep Agents version %s as %s (#12376)", async (agentVersion, managedAgentVersion, managedAgentVersionStatus) => { diff --git a/src/lib/actions/telemetry/snapshot.ts b/src/lib/actions/telemetry/snapshot.ts index 60638678164..50481453191 100644 --- a/src/lib/actions/telemetry/snapshot.ts +++ b/src/lib/actions/telemetry/snapshot.ts @@ -5,12 +5,12 @@ import path from "node:path"; import { createSupervisedSandboxCommandReader } from "./native-reader"; import type { OpenShellInferenceRouteResult } from "../../adapters/openshell/inference-route"; import { - approvedCategory, + observedString, classifyTelemetryAgent, classifyTelemetrySandboxOS, - COMPUTE_DRIVERS, + hasNativeTelemetryParser, + hasTelemetryCollectionError, dataRecord, - MANAGED_AGENT_VERSIONS, MESSAGING_CHANNELS, parseRuntimeRoster, projectRuntimeAgents, @@ -83,10 +83,7 @@ function projectConfiguration( sandboxOSStatus = "reported"; imageOwnership = "managed"; imageOwnershipStatus = "reported"; - const version = approvedCategory( - entry.agentVersion, - MANAGED_AGENT_VERSIONS[harness.agentHarnessId] ?? [], - ); + const version = observedString(entry.agentVersion); managedAgentVersion = version.value; managedAgentVersionStatus = version.status; } else if (workload?.kind === "external-image") { @@ -120,11 +117,11 @@ function projectConfiguration( } catch { sandboxOSStatus = imageOwnershipStatus = managedAgentVersionStatus = "collection_error"; } - const driver = approvedCategory(entry.openshellDriver, COMPUTE_DRIVERS); + const driver = observedString(entry.openshellDriver); const webSearch = booleanSetting(entry.webSearchEnabled); const observability = booleanSetting(entry.observabilityEnabled); if ( - harness.agentHarnessStatus === "reported" && + hasNativeTelemetryParser(harness.agentHarnessId) && !DCODE_OBSERVABILITY_FEATURE.supportsAgent(entry.agent) ) { observability.status = @@ -298,8 +295,8 @@ async function collectRuntime( row.sandboxOSStatus = "collection_error"; }); } - if (row.agentHarnessId === "other" || row.agentHarnessId === "unknown") { - row.agentsStatus = row.defaultAgentModel.status = row.agentHarnessStatus; + if (!hasNativeTelemetryParser(row.agentHarnessId)) { + row.agentsStatus = row.defaultAgentModel.status = "not_observed"; return; } const config = resolveAgentConfig(entry.name, { @@ -467,7 +464,7 @@ export async function collectOperationSnapshot(options: { } snapshot.publishedEnvironmentCount = entries.length; snapshot.configuredRuntimeCount = snapshot.configurations.filter( - (row) => row.agentHarnessId !== "unknown", + (row) => row.agentHarnessStatus === "reported", ).length; snapshot.configuredAgentCount = snapshot.configurations.reduce( (count, row) => count + row.agents.length, @@ -476,7 +473,7 @@ export async function collectOperationSnapshot(options: { const collectionError = inventoryError || observationIncomplete || - snapshot.configurations.some((row) => JSON.stringify(row).includes('"collection_error"')); + snapshot.configurations.some(hasTelemetryCollectionError); if (collectionError) { snapshot.collectionStatus = snapshot.configurations.length > 0 ? "partial" : "collection_error"; } @@ -488,7 +485,7 @@ export async function collectOperationSnapshot(options: { ) ) snapshot.countsStatus = "collection_error"; - else if (snapshot.configurations.some((row) => row.agentHarnessId === "unknown")) + else if (snapshot.configurations.some((row) => row.agentHarnessStatus === "not_persisted")) snapshot.countsStatus = "not_persisted"; else { const unknownRoster = snapshot.configurations.find((row) => row.agentsStatus !== "reported"); diff --git a/src/lib/adapters/telemetry/gxt.ts b/src/lib/adapters/telemetry/gxt.ts index ba4bc250014..bb6bf41d63b 100644 --- a/src/lib/adapters/telemetry/gxt.ts +++ b/src/lib/adapters/telemetry/gxt.ts @@ -51,7 +51,7 @@ export function operationEnvelope( deviceType: "undefined", eventProtocol: "1.6", eventSchemaVer: TELEMETRY_SCHEMA_VERSION, - eventSysVer: "nemoclaw-telemetry/3.0", + eventSysVer: `nemoclaw-telemetry/${TELEMETRY_SCHEMA_VERSION}`, externalUserId: "undefined", gdprBehOptIn: "None", gdprFuncOptIn: "None", diff --git a/src/lib/cli/installer-telemetry-entry.ts b/src/lib/cli/installer-telemetry-entry.ts index e88b2d354b8..98557f22b86 100644 --- a/src/lib/cli/installer-telemetry-entry.ts +++ b/src/lib/cli/installer-telemetry-entry.ts @@ -15,7 +15,6 @@ import { TELEMETRY_CONTEXT_ENV, } from "../actions/telemetry/operation"; -const VERSION_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/; const OUTCOMES: readonly TelemetryOutcome[] = [ "completed", "checked", @@ -35,7 +34,7 @@ const STATES: readonly TelemetryState[] = [ function installedVersion(): string | undefined { const value = process.env.NEMOCLAW_TELEMETRY_INSTALLED_VERSION; - return value && VERSION_PATTERN.test(value) ? value : undefined; + return value || undefined; } function readBuildVersion(identityPath: string): string | undefined { @@ -48,8 +47,7 @@ function readBuildVersion(identityPath: string): string | undefined { file.close(); } const identity = JSON.parse(raw) as { nemoclawVersion?: unknown }; - return typeof identity.nemoclawVersion === "string" && - VERSION_PATTERN.test(identity.nemoclawVersion) + return typeof identity.nemoclawVersion === "string" && identity.nemoclawVersion.length > 0 ? identity.nemoclawVersion : undefined; } catch { @@ -73,7 +71,7 @@ async function main(): Promise { } if (process.env.NEMOCLAW_TELEMETRY_INSTALLER_PHASE === "installed") { const version = installedVersion(); - recordTelemetryVersions({ installed: version ?? "unknown" }); + recordTelemetryVersions({ installed: version ?? null }); recordTelemetryTarget({ scope: "cli", outcome: version ? "completed" : "unverified", @@ -121,7 +119,7 @@ async function main(): Promise { state, args[2] as TelemetryScope, Number(args[1]), - { installed: actual ?? "unknown" }, + { installed: actual ?? null }, ); } diff --git a/src/lib/domain/telemetry/dimensions.ts b/src/lib/domain/telemetry/dimensions.ts index e9775161265..5e1e1b52968 100644 --- a/src/lib/domain/telemetry/dimensions.ts +++ b/src/lib/domain/telemetry/dimensions.ts @@ -17,27 +17,12 @@ import { type ModelSelectionProvenance, } from "./provenance"; -import { - AGENT_HARNESS_IDS, - TELEMETRY_MODEL_IDS, - TELEMETRY_API_FAMILIES, - TELEMETRY_MODEL_KEYS, - dataRecord, - classifyTelemetryProvider, -} from "./values"; +import { dataRecord, classifyTelemetryProvider } from "./values"; export { - AGENT_HARNESS_IDS, - TELEMETRY_MODEL_IDS, TELEMETRY_PROVIDER_PROFILES, - TELEMETRY_API_FAMILIES, MODEL_SELECTION_SOURCES, - COMPUTE_DRIVERS, GPU_STATES, MESSAGING_CHANNELS, - POLICY_TIER_CATEGORIES, - SANDBOX_OPERATING_SYSTEMS, - MANAGED_AGENT_VERSIONS, - TELEMETRY_MODEL_KEYS, dataRecord, classifyTelemetryProvider, } from "./values"; @@ -55,39 +40,51 @@ const NATIVE_PROVIDERS: Readonly> = { custom: "custom", }; -export function approvedCategory( +export function hasTelemetryCollectionError(value: unknown): boolean { + if (Array.isArray(value)) return value.some(hasTelemetryCollectionError); + const record = dataRecord(value); + return ( + record !== null && + Object.entries(record).some( + ([key, item]) => + ((key === "status" || key.endsWith("Status")) && item === "collection_error") || + hasTelemetryCollectionError(item), + ) + ); +} + +export function observedString( value: unknown, - allowed: readonly string[], + missingStatus: ValueStatus = "not_persisted", ): { value: string; status: ValueStatus } { - if (value === undefined || value === null || value === "") - return { value: "unknown", status: "not_persisted" }; - if (typeof value !== "string") return { value: "unknown", status: "collection_error" }; - return allowed.includes(value) && value !== "unknown" && value !== "other" + if (value === undefined || value === null || value === "" || value === "unknown") + return { value: "unknown", status: missingStatus }; + return typeof value === "string" ? { value, status: "reported" } - : { value: "other", status: "unapproved" }; + : { value: "unknown", status: "collection_error" }; } export function classifyTelemetryAgent( value: unknown, ): Pick { - const category = approvedCategory(value, AGENT_HARNESS_IDS); + const category = observedString(value); return { agentHarnessId: category.value, agentHarnessStatus: category.status }; } -export function classifyTelemetryApi(value: unknown): string { - return typeof value === "string" && TELEMETRY_API_FAMILIES.some((item) => item === value) - ? value - : "unknown"; +export function hasNativeTelemetryParser(agentHarnessId: string): boolean { + return ( + agentHarnessId === "openclaw" || + agentHarnessId === "hermes" || + agentHarnessId === "langchain-deepagents-code" + ); } export function classifyTelemetrySandboxOS(raw: string): { value: string; status: ValueStatus } { - const name = raw.trim(); + const name = raw.replace(/[\r\n]+$/, ""); if (name === "Linux") return { value: "linux", status: "reported" }; if (/^(?:Windows_NT|MINGW(?:32|64)_NT|MSYS_NT|CYGWIN_NT)(?:-[0-9]+(?:[.-][0-9]+)*)?$/.test(name)) return { value: "windows", status: "reported" }; - if (["Darwin", "FreeBSD", "OpenBSD", "NetBSD", "SunOS", "AIX"].includes(name)) - return { value: "other", status: "unapproved" }; - return { value: "unknown", status: "collection_error" }; + return observedString(name, "collection_error"); } export interface RuntimeRouteAuthority { @@ -217,7 +214,7 @@ function projectModel( authority: RuntimeRouteAuthority, slot?: { agentId: string; reference: string; inherited: boolean; sources: AssignmentSources }, ): TelemetryModel { - const model = approvedCategory(reference.model, TELEMETRY_MODEL_IDS); + const model = observedString(reference.model); const nativeChoice = reference.nativeConfiguration !== undefined && authority.nativeModelSelectionProvenance !== undefined; @@ -233,7 +230,8 @@ function projectModel( ) !== null : reference.managed && parsed.model === authority.model && - parsed.provider === authority.provider) + parsed.provider === authority.provider && + parsed.apiFamily === reference.api) ? parsed : null; const source = projectAssignmentSource(reference, assignment, authority, bound, slot); @@ -249,13 +247,11 @@ function projectModel( : reference.providerKey ? (NATIVE_PROVIDERS[reference.providerKey] ?? "custom") : "unknown"; - const api = classifyTelemetryApi(reference.api); + const api = observedString(reference.api, "unavailable"); return { assignment, modelId: model.value, modelStatus: model.status, - knownModelKey: TELEMETRY_MODEL_KEYS[model.value] ?? model.value, - knownModelKeyStatus: model.status, modelSource: source.value, modelSourceStatus: source.status, providerProfile: provider, @@ -265,9 +261,8 @@ function projectModel( : reference.managed && authority.provider == null ? "not_persisted" : "collection_error", - apiFamily: api, - apiStatus: - api !== "unknown" ? "reported" : reference.api === undefined ? "unavailable" : "unapproved", + apiFamily: api.value, + apiStatus: api.status, }; } @@ -279,8 +274,6 @@ export function unknownModel( assignment, modelId: "unknown", modelStatus: status, - knownModelKey: "unknown", - knownModelKeyStatus: status, modelSource: "unknown", modelSourceStatus: status, providerProfile: "unknown", @@ -415,6 +408,12 @@ export function projectRuntimeAgents( roster: readonly Record[] | undefined, authority: RuntimeRouteAuthority, ): RuntimeAgentProjection { + if (!hasNativeTelemetryParser(runtime.agentHarnessId)) + return { + agents: [], + agentsStatus: "not_observed", + defaultAgentModel: { agentPosition: -1, modelPosition: -1, status: "not_observed" }, + }; if (runtime.agentHarnessId === "openclaw" && roster?.length === 0) return { agents: [], @@ -497,7 +496,7 @@ export function projectRuntimeAgents( if (invalidSubagent || subagent !== undefined) models.push(readModel(invalidSubagent ? undefined : subagent, "subagent")); const modelsStatus: ValueStatus = - sources.invalid || models.some((model) => Object.values(model).includes("collection_error")) + sources.invalid || models.some(hasTelemetryCollectionError) ? "collection_error" : "reported"; return { @@ -580,17 +579,15 @@ export function projectRuntimeAgents( } else return { agents: [], - agentsStatus: "unapproved", - defaultAgentModel: { agentPosition: -1, modelPosition: -1, status: "unapproved" }, + agentsStatus: "not_observed", + defaultAgentModel: { agentPosition: -1, modelPosition: -1, status: "not_observed" }, }; const model = projectModel(reference, "primary", authority); return { agents: [ { ...runtime, - modelsStatus: Object.values(model).includes("collection_error") - ? "collection_error" - : "reported", + modelsStatus: hasTelemetryCollectionError(model) ? "collection_error" : "reported", models: [model], }, ], diff --git a/src/lib/domain/telemetry/event.ts b/src/lib/domain/telemetry/event.ts index 68c62e9709d..e88e3a13be0 100644 --- a/src/lib/domain/telemetry/event.ts +++ b/src/lib/domain/telemetry/event.ts @@ -79,8 +79,6 @@ export interface TelemetryModel { assignment: TelemetryModelAssignment; modelId: string; modelStatus: ValueStatus; - knownModelKey: string; - knownModelKeyStatus: ValueStatus; modelSource: string; modelSourceStatus: ValueStatus; providerProfile: string; @@ -166,7 +164,7 @@ export interface TelemetryOperationContext { scope: TelemetryScope; previousVersion?: string; targetVersion?: string; - installedVersion?: string; + installedVersion?: string | null; targets: TelemetryTargetReceipt[]; } @@ -195,6 +193,8 @@ export interface OperationEventParameters extends Omit 0 && - record.reference.length <= 1024 && typeof record.assignment === "string" && ["primary", "override", "fallback", "subagent"].includes(record.assignment) && MODEL_SELECTION_SOURCES.some((source) => source === record.modelSource) @@ -66,9 +63,11 @@ export function readModelAssignmentSelection(value: unknown): ModelAssignmentSel } export function readAppliedPolicySelection(value: unknown): AppliedPolicySelection | null { const record = closed(value, ["schemaVersion", "source", "tier"]); - const tier = POLICY_TIER_CATEGORIES.find((item) => item === record?.tier); - return record?.schemaVersion === 1 && record.source === "verified_selection" && tier - ? { schemaVersion: 1, source: "verified_selection", tier } + return record?.schemaVersion === 1 && + record.source === "verified_selection" && + typeof record.tier === "string" && + record.tier.length > 0 + ? { schemaVersion: 1, source: "verified_selection", tier: record.tier } : null; } export function readModelSelectionProvenance(value: unknown): ModelSelectionProvenance | null { @@ -84,24 +83,23 @@ export function readModelSelectionProvenance(value: unknown): ModelSelectionProv (item) => item === record?.providerProfile, ); const modelSource = MODEL_SELECTION_SOURCES.find((item) => item === record?.modelSource); - const apiFamily = TELEMETRY_API_FAMILIES.find((item) => item === record?.apiFamily); return record?.schemaVersion === 1 && typeof record.model === "string" && record.model.length > 0 && - record.model.length <= 1024 && typeof record.provider === "string" && record.provider.length > 0 && record.provider.length <= 1024 && providerProfile && modelSource && - apiFamily + typeof record.apiFamily === "string" && + record.apiFamily.length > 0 ? { schemaVersion: 1, model: record.model, provider: record.provider, providerProfile, modelSource, - apiFamily, + apiFamily: record.apiFamily, } : null; } @@ -123,15 +121,14 @@ export function readHermesModelSelectionTuple( : mode === "codex_responses" ? "openai-responses" : mode; - const apiFamily = TELEMETRY_API_FAMILIES.find((item) => item !== "unknown" && item === api); return typeof model?.default === "string" && model.default.length > 0 && - model.default.length <= 1024 && typeof provider === "string" && provider.length > 0 && provider.length <= 1024 && - apiFamily - ? { model: model.default, provider, apiFamily } + typeof api === "string" && + api.length > 0 + ? { model: model.default, provider, apiFamily: api } : null; } @@ -187,6 +184,8 @@ export function selectedModelProvenance(input: { providerProfile, modelSource: input.modelSource ?? "unknown", apiFamily: - TELEMETRY_API_FAMILIES.find((item) => item === input.preferredInferenceApi) ?? "unknown", + typeof input.preferredInferenceApi === "string" && input.preferredInferenceApi.length > 0 + ? input.preferredInferenceApi + : "unknown", }; } diff --git a/src/lib/domain/telemetry/schema.ts b/src/lib/domain/telemetry/schema.ts index 156e0e2b401..2a3ed8ec477 100644 --- a/src/lib/domain/telemetry/schema.ts +++ b/src/lib/domain/telemetry/schema.ts @@ -4,22 +4,14 @@ import Ajv from "ajv"; import { assertSafeConfigStructure } from "../../security/config-structure"; import { - AGENT_HARNESS_IDS, - COMPUTE_DRIVERS, GPU_STATES, - MANAGED_AGENT_VERSIONS, MESSAGING_CHANNELS, MODEL_SELECTION_SOURCES, - POLICY_TIER_CATEGORIES, - SANDBOX_OPERATING_SYSTEMS, - TELEMETRY_API_FAMILIES, - TELEMETRY_MODEL_IDS, - TELEMETRY_MODEL_KEYS, TELEMETRY_PROVIDER_PROFILES, } from "./dimensions"; import { TELEMETRY_OPERATIONS, type TelemetryOperationEvent } from "./event"; -export const TELEMETRY_SCHEMA_VERSION = "3.0"; +export const TELEMETRY_SCHEMA_VERSION = "4.0"; export const TELEMETRY_CLIENT_ID = "2247027956751513"; export const VALUE_STATUSES = [ "reported", @@ -42,12 +34,11 @@ export const OUTCOMES = [ ]; export const STATES = ["applied", "pending", "partial", "unchanged", "unavailable"]; export const SCOPES = ["cli", "sandbox", "configuration"]; -export const PUBLIC_VERSION_PATTERN = - "^(?:unknown|[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?(?:\\+[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?)$"; -const string = (values?: readonly string[]) => ({ +const string = (values: readonly string[]) => ({ type: "string", - ...(values ? { enum: [...values] } : {}), + enum: [...values], }); +const boundedString = (maxLength: number) => ({ type: "string", maxLength }); const object = (properties: Record) => ({ type: "object", additionalProperties: false, @@ -62,41 +53,35 @@ const timestamp = { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", }; -const version = { type: "string", maxLength: 128, pattern: PUBLIC_VERSION_PATTERN }; +const version = boundedString(128); const model = object({ assignment: string(["primary", "override", "fallback", "subagent"]), - modelId: string(TELEMETRY_MODEL_IDS), + modelId: boundedString(512), modelStatus: status, - knownModelKey: string([...new Set(Object.values(TELEMETRY_MODEL_KEYS)), "other", "unknown"]), - knownModelKeyStatus: status, modelSource: string(MODEL_SELECTION_SOURCES), modelSourceStatus: status, providerProfile: string(TELEMETRY_PROVIDER_PROFILES), providerStatus: status, - apiFamily: string(TELEMETRY_API_FAMILIES), + apiFamily: boundedString(64), apiStatus: status, }); const harnessFields = { - agentHarnessId: string(AGENT_HARNESS_IDS), + agentHarnessId: boundedString(64), agentHarnessStatus: status, - managedAgentVersion: string([ - ...new Set(Object.values(MANAGED_AGENT_VERSIONS).flat()), - "other", - "unknown", - ]), + managedAgentVersion: version, managedAgentVersionStatus: status, }; const configuration = object({ state: string(STATES), status, ...harnessFields, - sandboxOS: string(SANDBOX_OPERATING_SYSTEMS), + sandboxOS: boundedString(64), sandboxOSStatus: status, defaultAgentModel: object({ agentPosition: position, modelPosition: position, status }), currentInferenceRoute: model, currentInferenceRouteStatus: status, settings: object({ - computeDriver: string(COMPUTE_DRIVERS), + computeDriver: boundedString(64), computeDriverStatus: status, gpuState: string(GPU_STATES), gpuStatus: status, @@ -106,7 +91,7 @@ const configuration = object({ observabilityStatus: status, imageOwnership: string(["managed", "custom", "unknown"]), imageOwnershipStatus: status, - policyTier: string([...POLICY_TIER_CATEGORIES, "unknown"]), + policyTier: boundedString(64), policyTierStatus: status, }), messaging: object({ @@ -139,12 +124,14 @@ export const operationParametersSchema = object({ targetStatus: status, }), platform: object({ - hostOS: string(["linux", "macos", "windows", "other", "unknown"]), + hostOS: boundedString(64), hostOSStatus: status, - hostArch: string(["x64", "arm64", "ia32", "arm", "other", "unknown"]), + hostArch: boundedString(64), hostArchStatus: status, hostContext: string(["native", "wsl", "unknown"]), hostContextStatus: status, + hostHardwarePlatform: boundedString(64), + hostHardwarePlatformStatus: status, }), location: object({ countryCode: { type: "string", maxLength: 2, pattern: "^(?:|[A-Z]{2})$" }, @@ -235,7 +222,7 @@ export function proposedSmsSchema(): Record { personalization: "anonymous", }, description: - "One complete terminal NemoClaw operation record with approved categories and explicit collection status. Production disabled.", + "One terminal NemoClaw operation with observed values, reporting categories, and explicit collection status. Production disabled.", oneOf: [{ $ref: "#/definitions/events/nemoclaw_operation_finished" }], definitions: { types: {}, @@ -243,7 +230,7 @@ export function proposedSmsSchema(): Record { nemoclaw_operation_finished: { ...operationParametersSchema, description: - "One complete terminal NemoClaw operation record containing all approved anonymous versions, platform, agent/model/provider associations, settings, messaging, coarse-location status and QA label.", + "One terminal NemoClaw operation containing versions, host hardware and OS, agent/model/provider associations, settings, messaging, location status, and QA label.", eventMeta: { service: "telemetry", gdpr: { diff --git a/src/lib/domain/telemetry/values.ts b/src/lib/domain/telemetry/values.ts index 31c1af1a17a..f7a237d61cd 100644 --- a/src/lib/domain/telemetry/values.ts +++ b/src/lib/domain/telemetry/values.ts @@ -1,23 +1,6 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -export const AGENT_HARNESS_IDS = [ - "openclaw", - "hermes", - "langchain-deepagents-code", - "other", - "unknown", -] as const; -export const TELEMETRY_MODEL_IDS = [ - "Qwen/Qwen3.6-27B-FP8", - "nvidia/nemotron-3-ultra-550b-a55b", - "nvidia/nvidia/nemotron-3-ultra", - "deepseek-ai/DeepSeek-V4-Flash", - "nvidia/qwen/qwen3.6-27b", - "nvidia/deepseek-ai/deepseek-v4-flash", - "other", - "unknown", -] as const; export const TELEMETRY_PROVIDER_PROFILES = [ "nvidia", "openai", @@ -32,12 +15,6 @@ export const TELEMETRY_PROVIDER_PROFILES = [ "custom", "unknown", ] as const; -export const TELEMETRY_API_FAMILIES = [ - "openai-completions", - "openai-responses", - "anthropic-messages", - "unknown", -] as const; export const MODEL_SELECTION_SOURCES = [ "product_catalog", "provider_catalog", @@ -45,7 +22,6 @@ export const MODEL_SELECTION_SOURCES = [ "local", "unknown", ] as const; -export const COMPUTE_DRIVERS = ["docker", "podman", "kubernetes", "other", "unknown"] as const; export const GPU_STATES = [ "not_configured", "configured_unverified", @@ -63,21 +39,6 @@ export const MESSAGING_CHANNELS = [ "googlechat", "other", ] as const; -export const POLICY_TIER_CATEGORIES = ["restricted", "balanced", "open", "personal"] as const; -export const SANDBOX_OPERATING_SYSTEMS = ["linux", "windows", "other", "unknown"] as const; -export const MANAGED_AGENT_VERSIONS: Readonly> = { - openclaw: ["2026.9.2"], - hermes: ["0.21.3"], - "langchain-deepagents-code": ["0.1.71"], -}; -export const TELEMETRY_MODEL_KEYS: Readonly> = { - "Qwen/Qwen3.6-27B-FP8": "qwen3_6_27b_fp8", - "nvidia/nemotron-3-ultra-550b-a55b": "nemotron3_ultra_550b_a55b", - "nvidia/nvidia/nemotron-3-ultra": "nemotron3_ultra", - "deepseek-ai/DeepSeek-V4-Flash": "deepseek_v4_flash", - "nvidia/qwen/qwen3.6-27b": "qwen3_6_27b", - "nvidia/deepseek-ai/deepseek-v4-flash": "deepseek_v4_flash", -}; const PROVIDERS: Readonly> = { "nvidia-prod": "nvidia", "nvidia-nim": "nvidia", diff --git a/src/lib/sandbox/config-telemetry.ts b/src/lib/sandbox/config-telemetry.ts index dbf136aefe0..c2c2fcef3b1 100644 --- a/src/lib/sandbox/config-telemetry.ts +++ b/src/lib/sandbox/config-telemetry.ts @@ -9,6 +9,7 @@ import { import { isTelemetryConfigurationKey } from "../domain/telemetry/event"; import { readModelSelectionProvenance, + readHermesModelSelectionTuple, selectedModelProvenance, } from "../domain/telemetry/provenance"; import { CLI_NAME } from "../cli/branding"; @@ -37,40 +38,31 @@ export function persistConfigurationTelemetry( pending === undefined ? {} : { configurationApplyPending: pending ? true : undefined }; if (config) { const modelConfig = isConfigObject(config.model) ? config.model : {}; - const model = modelConfig.default; const nativeProvider = modelConfig.provider; const upstream = isConfigObject(config._nemoclaw_upstream) ? config._nemoclaw_upstream.provider : undefined; - const provider = nativeProvider === "custom" ? upstream : nativeProvider; - const apiMode = modelConfig.api_mode; - const api = - apiMode === undefined || apiMode === "" - ? "openai-completions" - : apiMode === "anthropic_messages" - ? "anthropic-messages" - : apiMode === "codex_responses" - ? "openai-responses" - : typeof apiMode === "string" - ? apiMode - : null; + const tuple = readHermesModelSelectionTuple(config); const previous = readModelSelectionProvenance(entry.nativeModelSelectionProvenance); const source = key === "model.default" && newModelSelection ? "custom" - : previous && previous.model === model && previous.provider === provider + : previous && + previous.model === tuple?.model && + previous.provider === tuple.provider && + previous.apiFamily === tuple.apiFamily ? previous.modelSource : undefined; updates.nativeModelSelectionProvenance = - typeof model === "string" && typeof provider === "string" && source + tuple && source ? selectedModelProvenance({ - model, - provider, + model: tuple.model, + provider: tuple.provider, endpointUrl: nativeProvider === "custom" && upstream === entry.provider ? entry.endpointUrl : undefined, - preferredInferenceApi: api, + preferredInferenceApi: tuple.apiFamily, modelSource: source, }) : undefined; From b0456f9bf2b7b04d63fba5419d47fea0958d10a7 Mon Sep 17 00:00:00 2001 From: Will Curran Date: Fri, 23 Oct 2026 15:35:00 -0700 Subject: [PATCH 2/6] fix(telemetry): preserve managed provenance across API preferences --- src/lib/domain/telemetry/dimensions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/domain/telemetry/dimensions.ts b/src/lib/domain/telemetry/dimensions.ts index 5e1e1b52968..4e4690dc0cd 100644 --- a/src/lib/domain/telemetry/dimensions.ts +++ b/src/lib/domain/telemetry/dimensions.ts @@ -230,8 +230,7 @@ function projectModel( ) !== null : reference.managed && parsed.model === authority.model && - parsed.provider === authority.provider && - parsed.apiFamily === reference.api) + parsed.provider === authority.provider) ? parsed : null; const source = projectAssignmentSource(reference, assignment, authority, bound, slot); From 3ea2aa2e503a7cb460cd7731f17d00b91c0e8572 Mon Sep 17 00:00:00 2001 From: Will Curran Date: Fri, 23 Oct 2026 19:16:22 -0700 Subject: [PATCH 3/6] fix(telemetry): reserve delivery time for partial inventory (#13689) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Outcome Send available telemetry when inventory reads stall, within the existing five-second budget. Clean up timed-out readers before exit. ## Reason Slow inventory reads could consume the delivery budget and leave reader processes running. ### Related issues Part of #12715. Refs #13575. ## Changes - Reserve time for finalization and delivery. - Bound observations, preserve settled results, and stop owned reader processes. - Reuse routing and TLS checks without synchronous service-discovery probes. Six production files: +111/−29 lines, net +82. No test, fixture, dependency, or configuration files changed. ## Verification - `npm run validate:pr` and 53 focused source checks passed. Local regression changes remain outside the PR. - Omnistation candidate containing all three planned fixes: 596 source tests and 38 compiled checks passed; live cancellation sent one valid TEST event, accepted with HTTP 200. - Process-cleanup audits passed on macOS and Linux. No secrets or credentials in the diff. - Broader test lanes retain failures reproduced on the unchanged dependency. ## Review notes Depends on #13682; retarget to `main` after it merges. OpenClaw live validation is blocked by the existing dependency security audit. Receiver storage readback remains unverified. --- Signed-off-by: Will Curran --- .../sandbox/agents/telemetry-verification.ts | 4 +- .../sandbox/mcp-bridge-provider-inspection.ts | 22 ++++++- src/lib/actions/telemetry/native-reader.ts | 45 +++++++++++--- src/lib/actions/telemetry/operation.ts | 3 +- src/lib/actions/telemetry/send.ts | 8 ++- src/lib/actions/telemetry/snapshot.ts | 58 ++++++++++++++----- 6 files changed, 111 insertions(+), 29 deletions(-) diff --git a/src/lib/actions/sandbox/agents/telemetry-verification.ts b/src/lib/actions/sandbox/agents/telemetry-verification.ts index 10eb0c03fe6..8c3331a1c78 100644 --- a/src/lib/actions/sandbox/agents/telemetry-verification.ts +++ b/src/lib/actions/sandbox/agents/telemetry-verification.ts @@ -42,7 +42,9 @@ export async function readTelemetryAgentCommand( timeoutLimitMs = 1_000, ): Promise { return withTelemetryEvidence(async (remainingMs, signal) => { - const runtimeSelection = resolveSandboxConfigRuntimeSelection(sandboxName); + const runtimeSelection = resolveSandboxConfigRuntimeSelection(sandboxName, { + observationOnly: true, + }); if (target.kind === "named" && target.gatewayName !== runtimeSelection.gatewayName) throw new Error("Native evidence target does not match the recorded sandbox gateway"); const reader = createSupervisedSandboxCommandReader(signal); diff --git a/src/lib/actions/sandbox/mcp-bridge-provider-inspection.ts b/src/lib/actions/sandbox/mcp-bridge-provider-inspection.ts index 86909987f4a..229f35124bc 100644 --- a/src/lib/actions/sandbox/mcp-bridge-provider-inspection.ts +++ b/src/lib/actions/sandbox/mcp-bridge-provider-inspection.ts @@ -19,9 +19,14 @@ import { OPENSHELL_DEFAULT_WORKSPACE } from "../../adapters/openshell/sandbox-ss import { getDockerDriverGatewayLocalTlsDir } from "../../onboard/docker-driver-gateway-local-tls"; import { resolveGatewayStateDirForPort } from "../../onboard/gateway/state-dir"; import { resolveGatewayCredentialMutationAuthority } from "../../onboard/gateway-teardown-authority"; +import { + invalidGatewayManagementDeclarationError, + loadGatewayManagementDeclaration, +} from "../../onboard/gateway-management"; import { evaluateGatewayAttachmentConfiguration, isExternallySupervised, + resolveGatewayOwner, type GatewayOwner, } from "../../onboard/gateway-ownership"; import { replayTrustedPrivateEndpoint } from "../../security/trusted-private-endpoint"; @@ -135,10 +140,22 @@ function providerRuntimeLocalTlsDir( export function getMcpProviderInspectionRuntimeSelection( sandbox: SandboxEntry, + options: { observationOnly?: boolean } = {}, ): McpProviderInspectionRuntimeSelection { const providerRuntimeGateway = getPersistedSandboxTargetGateway(sandbox); const { gatewayName, gatewayPort } = providerRuntimeGateway; - const owner = resolveGatewayCredentialMutationAuthority({ gatewayName, gatewayPort }); + let owner: GatewayOwner; + if (options.observationOnly) { + const loaded = loadGatewayManagementDeclaration(); + if (!loaded.ok) throw invalidGatewayManagementDeclarationError(loaded.reason); + // Observation needs routing and TLS, not service installation or lifecycle authority. + owner = resolveGatewayOwner({ + gatewayName, + gatewayPort, + declaration: loaded.declaration, + hasPackagedService: false, + }); + } else owner = resolveGatewayCredentialMutationAuthority({ gatewayName, gatewayPort }); const localTlsDir = providerRuntimeLocalTlsDir(owner, providerRuntimeGateway.selectedInProcess); return { gatewayName, @@ -149,10 +166,11 @@ export function getMcpProviderInspectionRuntimeSelection( export function resolveSandboxConfigRuntimeSelection( sandboxName: string, + options: { observationOnly?: boolean } = {}, ): OpenShellRuntimeSelection { const sandbox = getKnownSandboxTarget(sandboxName); if (!sandbox) throw new Error(`Sandbox '${sandboxName}' has no recorded runtime target.`); - return getMcpProviderInspectionRuntimeSelection(sandbox); + return getMcpProviderInspectionRuntimeSelection(sandbox, options); } export async function inspectMcpProvider( diff --git a/src/lib/actions/telemetry/native-reader.ts b/src/lib/actions/telemetry/native-reader.ts index 9ffe517dab1..e020541561d 100644 --- a/src/lib/actions/telemetry/native-reader.ts +++ b/src/lib/actions/telemetry/native-reader.ts @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -import { spawn, type SpawnOptions } from "node:child_process"; +import { spawn, type ChildProcess, type SpawnOptions } from "node:child_process"; import { captureOpenshellCommandAsyncResult } from "../../adapters/openshell/command-execution"; import { buildSandboxCommandEnvironment, @@ -32,21 +32,42 @@ export function createSupervisedSandboxCommandReader( ) => Promise; dispose: () => void; } { + const children = new Set(); + // Cleanup must not depend on the caller returning to the event loop. + const killChildren = () => { + for (const child of children) { + try { + if (!foreground && process.platform !== "win32" && child.pid) + process.kill(-child.pid, "SIGKILL"); + else child.kill("SIGKILL"); + } catch { + try { + child.kill("SIGKILL"); + } catch {} + } + } + }; const listeners = { SIGTERM: new Set<() => void>(), SIGINT: new Set<() => void>() }; const forwardTerm = () => { for (const listener of listeners.SIGTERM) listener(); }; const forwardProcessTerm = () => { forwardTerm(); + killChildren(); process.removeListener("SIGTERM", forwardProcessTerm); process.kill(process.pid, "SIGTERM"); }; const forwardInt = () => { for (const listener of listeners.SIGINT) listener(); + killChildren(); process.removeListener("SIGINT", forwardInt); process.kill(process.pid, "SIGINT"); }; - signal.addEventListener("abort", forwardTerm, { once: true }); + const cancel = () => { + forwardTerm(); + killChildren(); + }; + signal.addEventListener("abort", cancel, { once: true }); process.on("SIGTERM", forwardProcessTerm); process.on("SIGINT", forwardInt); const signalSource = { @@ -67,12 +88,17 @@ export function createSupervisedSandboxCommandReader( ...request, killGraceMs: 0, signalSource, - ...(foreground - ? { - spawnImpl: ((binary: string, args: readonly string[] = [], options?: SpawnOptions) => - spawn(binary, [...args], { ...options, detached: false })) as typeof spawn, - } - : {}), + spawnImpl: ((binary: string, args: readonly string[] = [], options?: SpawnOptions) => { + if (signal.aborted) throw new Error("Native evidence cancelled"); + const child = spawn(binary, [...args], { + ...options, + ...(foreground ? { detached: false } : {}), + }); + children.add(child); + child.once("close", () => children.delete(child)); + if (signal.aborted) killChildren(); + return child; + }) as typeof spawn, }); const executor = createCliOpenShellSandboxCommandExecutor({ signalSource, @@ -112,7 +138,8 @@ export function createSupervisedSandboxCommandReader( ).observeInferenceRoute(request); }, dispose: () => { - signal.removeEventListener("abort", forwardTerm); + killChildren(); + signal.removeEventListener("abort", cancel); process.removeListener("SIGTERM", forwardProcessTerm); process.removeListener("SIGINT", forwardInt); }, diff --git a/src/lib/actions/telemetry/operation.ts b/src/lib/actions/telemetry/operation.ts index fa6943f37a7..92e7f21fcc9 100644 --- a/src/lib/actions/telemetry/operation.ts +++ b/src/lib/actions/telemetry/operation.ts @@ -239,7 +239,8 @@ export async function withTelemetryEvidence( const started = performance.now(); let remainingMs: number; try { - remainingMs = TELEMETRY_DEADLINE_MS - usedEvidenceMs(current); + // Leave time for sender startup, terminal collection, delivery, and cleanup. + remainingMs = TELEMETRY_DEADLINE_MS - usedEvidenceMs(current) - 2_000; } catch { return null; } diff --git a/src/lib/actions/telemetry/send.ts b/src/lib/actions/telemetry/send.ts index 9af653a36fd..71688bc0a4f 100644 --- a/src/lib/actions/telemetry/send.ts +++ b/src/lib/actions/telemetry/send.ts @@ -165,7 +165,7 @@ export async function collectOperationEvent( return event; } -/** A single complete record, one attempt, and one collection/delivery deadline. */ +/** One terminal record and one delivery attempt within the remaining operation budget. */ export async function sendOperationTelemetry( context: TelemetryOperationContext, budgetMs: number, @@ -186,7 +186,11 @@ export async function sendOperationTelemetry( controller.signal.addEventListener("abort", () => resolve(null), { once: true }); }); const event = await Promise.race([ - collectOperationEvent(context, { signal: controller.signal, deadlineAt }), + // Reserve transport time even when an inventory observation stalls. + collectOperationEvent(context, { + signal: controller.signal, + deadlineAt: deadlineAt - Math.min(1_000, budgetMs / 2), + }), deadline, ]); if (event === null || controller.signal.aborted) return "failed"; diff --git a/src/lib/actions/telemetry/snapshot.ts b/src/lib/actions/telemetry/snapshot.ts index 50481453191..777eebe8093 100644 --- a/src/lib/actions/telemetry/snapshot.ts +++ b/src/lib/actions/telemetry/snapshot.ts @@ -240,10 +240,24 @@ async function collectRuntime( row.currentInferenceRouteStatus = "not_observed"; return; } + // Only settled observations may update the row after cancellation. + let cancel: () => void = () => {}; + const cancelled = new Promise<{ cancelled: true }>((resolve) => { + cancel = () => resolve({ cancelled: true }); + options.signal.addEventListener("abort", cancel, { once: true }); + if (options.signal.aborted) cancel(); + }); + const observe = async (observation: Promise): Promise => { + const result = await Promise.race([observation.then((value) => ({ value })), cancelled]); + if ("cancelled" in result) throw new Error("Telemetry observation cancelled"); + return result.value; + }; let osObservation: Promise | undefined; let routeObservation: Promise | undefined; try { - const runtimeSelection = getMcpProviderInspectionRuntimeSelection(entry); + const runtimeSelection = getMcpProviderInspectionRuntimeSelection(entry, { + observationOnly: true, + }); const gatewayName = resolveSandboxGatewayName(entry); const routeKey = JSON.stringify([gatewayName, runtimeSelection]); let route = options.routes.get(routeKey); @@ -251,9 +265,11 @@ async function collectRuntime( const remaining = options.deadlineAt - Date.now(); if (options.signal.aborted || remaining <= 0) throw new Error("Telemetry observation deadline reached"); - route = reader.observeInferenceRoute( - { target: { kind: "named", gatewayName }, timeoutMs: remaining }, - runtimeSelection, + route = observe( + reader.observeInferenceRoute( + { target: { kind: "named", gatewayName }, timeoutMs: remaining }, + runtimeSelection, + ), ); options.routes.set(routeKey, route); } @@ -272,16 +288,18 @@ async function collectRuntime( const remaining = options.deadlineAt - Date.now(); if (options.signal.aborted || remaining <= 0) throw new Error("Telemetry observation deadline reached"); - return reader.read( - { - sandboxName: entry.name, - target: { kind: "named", gatewayName }, - command, - timeoutMilliseconds: remaining, - timeoutKillSignal: "SIGKILL", - outputLimitBytes: 16 * 1024 * 1024, - }, - runtimeSelection, + return observe( + reader.read( + { + sandboxName: entry.name, + target: { kind: "named", gatewayName }, + command, + timeoutMilliseconds: remaining, + timeoutKillSignal: "SIGKILL", + outputLimitBytes: 16 * 1024 * 1024, + }, + runtimeSelection, + ), ); }; if (row.sandboxOSStatus !== "reported") { @@ -338,6 +356,7 @@ async function collectRuntime( row.sandboxOSStatus = "collection_error"; } finally { await Promise.all([osObservation, routeObservation]); + options.signal.removeEventListener("abort", cancel); } } @@ -433,6 +452,14 @@ export async function collectOperationSnapshot(options: { snapshot.configurations = entries.map((entry, index) => projectConfiguration(entry, metadataErrors[index]), ); + const controller = new AbortController(); + const parentSignal = options.signal; + const cancel = () => controller.abort(); + parentSignal.addEventListener("abort", cancel, { once: true }); + const remaining = options.deadlineAt - Date.now(); + const timer = setTimeout(cancel, Math.max(0, remaining)); + if (parentSignal.aborted || remaining <= 0) cancel(); + options = { ...options, signal: controller.signal }; const reader = createSupervisedSandboxCommandReader(options.signal, true); const routes = new Map>(); let nextIndex = 0; @@ -460,6 +487,9 @@ export async function collectOperationSnapshot(options: { ), ); } finally { + controller.abort(); + clearTimeout(timer); + parentSignal.removeEventListener("abort", cancel); reader.dispose(); } snapshot.publishedEnvironmentCount = entries.length; From b5a43f57ae5c6083979ca7c2540917e18472705d Mon Sep 17 00:00:00 2001 From: Will Curran Date: Mon, 26 Oct 2026 10:52:25 -0700 Subject: [PATCH 4/6] fix(telemetry): bound observations and retain gateway authority Signed-off-by: Will Curran --- docs/security/best-practices.mdx | 7 ++++-- .../sandbox/mcp-bridge-provider-inspection.ts | 23 +++++-------------- src/lib/actions/telemetry/send.ts | 3 ++- src/lib/actions/telemetry/snapshot.ts | 16 ++++++------- src/lib/domain/telemetry/dimensions.ts | 2 +- src/lib/onboard/gateway-teardown-authority.ts | 22 ++++++++++++++++-- 6 files changed, 41 insertions(+), 32 deletions(-) diff --git a/docs/security/best-practices.mdx b/docs/security/best-practices.mdx index b02ced97405..cf193cc727d 100644 --- a/docs/security/best-practices.mdx +++ b/docs/security/best-practices.mdx @@ -293,7 +293,7 @@ Broader binary access would let unrelated sandbox processes send data to Tavily ## Operation Telemetry -The installer and supported CLI commands attempt to send anonymous operation telemetry to NVIDIA's fixed TEST receiver by default. +The installer and supported CLI commands attempt to send operation telemetry to NVIDIA's fixed TEST receiver by default. Ordinary runs send an empty `testLabel`. QA runs can set `NEMOCLAW_TELEMETRY_TEST_LABEL` to attach a valid label to the same receiver. Use `qa-