From fe7b78b05f9be5a204ccc45697eee0e5e02fcd5a Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 22 Jun 2026 08:47:10 +0800 Subject: [PATCH] chore(deadcode): prune stale test hooks --- extensions/anthropic/stream-wrappers.ts | 2 - .../memory-core/src/short-term-promotion.ts | 12 ------ .../src/runners/contract/scenarios.ts | 12 ------ scripts/bench-gateway-restart.ts | 2 - scripts/bench-gateway-startup.ts | 2 - test/scripts/bench-gateway-restart.test.ts | 40 ++++++++++++++----- 6 files changed, 31 insertions(+), 39 deletions(-) diff --git a/extensions/anthropic/stream-wrappers.ts b/extensions/anthropic/stream-wrappers.ts index 26a65d422a1..275f9019be1 100644 --- a/extensions/anthropic/stream-wrappers.ts +++ b/extensions/anthropic/stream-wrappers.ts @@ -10,7 +10,6 @@ import { composeProviderStreamWrappers, createAnthropicThinkingPrefillPayloadWrapper, resolveAnthropicPayloadPolicy, - stripTrailingAnthropicAssistantPrefillWhenThinking, streamWithPayloadPatch, } from "openclaw/plugin-sdk/provider-stream-shared"; import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env"; @@ -251,6 +250,5 @@ export function wrapAnthropicProviderStream( /** Test-only hooks for Anthropic stream wrapper behavior. */ export const testing = { log, - stripTrailingAssistantPrefillWhenThinking: stripTrailingAnthropicAssistantPrefillWhenThinking, }; export { testing as __testing }; diff --git a/extensions/memory-core/src/short-term-promotion.ts b/extensions/memory-core/src/short-term-promotion.ts index 24fb54d4d6f..1f678ca99df 100644 --- a/extensions/memory-core/src/short-term-promotion.ts +++ b/extensions/memory-core/src/short-term-promotion.ts @@ -834,17 +834,6 @@ function isProcessLikelyAlive(pid: number): boolean { } } -async function canStealStaleLock(lockPath: string): Promise { - const ownerPid = await fs - .readFile(lockPath, "utf-8") - .then((raw) => parseLockOwnerPid(raw)) - .catch(() => null); - if (ownerPid === null) { - return true; - } - return !isProcessLikelyAlive(ownerPid); -} - async function sleep(ms: number): Promise { await new Promise((resolve) => { setTimeout(resolve, ms); @@ -2813,7 +2802,6 @@ export async function removeGroundedShortTermCandidates(params: { export const testing = { parseLockOwnerPid, - canStealStaleLock, isProcessLikelyAlive, readRecallStore: readStore, readPhaseSignalStore, diff --git a/extensions/qa-matrix/src/runners/contract/scenarios.ts b/extensions/qa-matrix/src/runners/contract/scenarios.ts index c37fe3daaf9..8d89241082c 100644 --- a/extensions/qa-matrix/src/runners/contract/scenarios.ts +++ b/extensions/qa-matrix/src/runners/contract/scenarios.ts @@ -1,12 +1,8 @@ // Qa Matrix plugin module implements scenarios behavior. import { - MATRIX_QA_BOT_DM_ROOM_KEY, MATRIX_QA_DRIVER_DM_ROOM_KEY, MATRIX_QA_DRIVER_DM_SHARED_ROOM_KEY, - MATRIX_QA_E2EE_ROOM_KEY, MATRIX_QA_MEDIA_ROOM_KEY, - MATRIX_QA_PROFILE_NAMES, - MATRIX_QA_MEMBERSHIP_ROOM_KEY, MATRIX_QA_SCENARIOS, MATRIX_QA_SECONDARY_ROOM_KEY, MATRIX_QA_STANDARD_SCENARIO_IDS, @@ -20,10 +16,8 @@ import { buildMatrixReplyArtifact, buildMatrixReplyDetails, buildMentionPrompt, - readMatrixQaSyncCursor, runMatrixQaCanary, runMatrixQaScenario, - writeMatrixQaSyncCursor, type MatrixQaScenarioContext, } from "./scenario-runtime.js"; import type { MatrixQaCanaryArtifact, MatrixQaScenarioArtifacts } from "./scenario-types.js"; @@ -41,13 +35,9 @@ export type { MatrixQaCanaryArtifact, MatrixQaScenarioArtifacts }; export type { MatrixQaScenarioContext }; export const testing = { - MATRIX_QA_BOT_DM_ROOM_KEY, MATRIX_QA_DRIVER_DM_ROOM_KEY, MATRIX_QA_DRIVER_DM_SHARED_ROOM_KEY, - MATRIX_QA_E2EE_ROOM_KEY, MATRIX_QA_MEDIA_ROOM_KEY, - MATRIX_QA_MEMBERSHIP_ROOM_KEY, - MATRIX_QA_PROFILE_NAMES, MATRIX_QA_SECONDARY_ROOM_KEY, MATRIX_QA_STANDARD_SCENARIO_IDS, buildMatrixQaE2eeScenarioRoomKey, @@ -58,8 +48,6 @@ export const testing = { findMatrixQaScenarios, getMatrixQaProfileScenarioIds: matrixQaProfileTesting.getMatrixQaProfileScenarioIds, normalizeMatrixQaProfile: matrixQaProfileTesting.normalizeMatrixQaProfile, - readMatrixQaSyncCursor, resolveMatrixQaScenarioRoomId, - writeMatrixQaSyncCursor, }; export { testing as __testing }; diff --git a/scripts/bench-gateway-restart.ts b/scripts/bench-gateway-restart.ts index b1da575bca7..aa429722af6 100644 --- a/scripts/bench-gateway-restart.ts +++ b/scripts/bench-gateway-restart.ts @@ -10,7 +10,6 @@ import { writeGatewayRestartIntentSync } from "../src/infra/restart.js"; import { parseStrictIntegerOption } from "./lib/dev-tooling-safety.ts"; import { delay, stopChild, type StopChildResult } from "./lib/gateway-bench-child.ts"; import { - classifyProbeErrorKind, getFreePort, parseProcessRssKb, readProcessRssMb, @@ -1635,7 +1634,6 @@ async function main() { export const testing = { classifyGatewayReadyLog, - classifyProbeErrorKind, collectOutputLines, collectTraceLine, countLsofFileDescriptors, diff --git a/scripts/bench-gateway-startup.ts b/scripts/bench-gateway-startup.ts index d617dccc9db..e0b342e12de 100644 --- a/scripts/bench-gateway-startup.ts +++ b/scripts/bench-gateway-startup.ts @@ -8,7 +8,6 @@ import { pathToFileURL } from "node:url"; import { parseStrictIntegerOption } from "./lib/dev-tooling-safety.ts"; import { delay, stopChild } from "./lib/gateway-bench-child.ts"; import { - classifyProbeErrorKind, getFreePort, parseProcessRssKb, readProcessRssMb, @@ -984,7 +983,6 @@ async function main() { export const testing = { classifyGatewayReadyLog, - classifyProbeErrorKind, collectResultFailures, collectStartupTrace, parseOptions, diff --git a/test/scripts/bench-gateway-restart.test.ts b/test/scripts/bench-gateway-restart.test.ts index b4ff139466e..75cb0430e1e 100644 --- a/test/scripts/bench-gateway-restart.test.ts +++ b/test/scripts/bench-gateway-restart.test.ts @@ -7,8 +7,31 @@ import path from "node:path"; import { performance } from "node:perf_hooks"; import { beforeAll, describe, expect, it } from "vitest"; import { testing } from "../../scripts/bench-gateway-restart.ts"; +import type { DB as OpenClawStateKyselyDatabase } from "../../src/state/openclaw-state-db.generated.js"; +import { + closeOpenClawStateDatabaseForTest, + openOpenClawStateDatabase, +} from "../../src/state/openclaw-state-db.js"; +import { + executeSqliteQueryTakeFirstSync, + getNodeSqliteKysely, +} from "../../src/infra/kysely-sync.js"; import { registerStopChildBehaviorTests } from "./bench-gateway-child-test-support.js"; +type GatewayRestartIntentDatabase = Pick; + +function readRestartIntentRow(env: NodeJS.ProcessEnv) { + const { db } = openOpenClawStateDatabase({ env }); + const stateDb = getNodeSqliteKysely(db); + return executeSqliteQueryTakeFirstSync( + db, + stateDb + .selectFrom("gateway_restart_intent") + .select(["intent_key", "kind", "pid", "reason"]) + .where("intent_key", "=", "gateway-restart"), + ); +} + describe("gateway restart benchmark script", () => { let helpResult: ReturnType; @@ -673,17 +696,16 @@ node 1234 user 12u IPv4 0t0 TCP localhost:1234 const env = { OPENCLAW_STATE_DIR: path.join(root, "state") }; expect(testing.writeRestartIntent(env, 12345, "gateway-restart-bench")).toBe(true); - const raw = fs.readFileSync(path.join(root, "state", "gateway-restart-intent.json"), "utf8"); - const parsed = JSON.parse(raw) as { - kind?: unknown; - pid?: unknown; - reason?: unknown; - }; + const row = readRestartIntentRow(env); - expect(parsed.kind).toBe("gateway-restart"); - expect(parsed.pid).toBe(12345); - expect(parsed.reason).toBe("gateway-restart-bench"); + expect(row).toMatchObject({ + intent_key: "gateway-restart", + kind: "gateway-restart", + pid: 12345, + reason: "gateway-restart-bench", + }); } finally { + closeOpenClawStateDatabaseForTest(); fs.rmSync(root, { force: true, recursive: true }); } });