test(perf): cache redact hints and tune guardrail scan concurrency

This commit is contained in:
Peter Steinberger
2026-03-02 16:01:29 +00:00
parent 64c443ac65
commit 19f5d1345c
2 changed files with 4 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import type { ConfigFileSnapshot } from "./types.openclaw.js";
import { OpenClawSchema } from "./zod-schema.js"; import { OpenClawSchema } from "./zod-schema.js";
const { mapSensitivePaths } = __test__; const { mapSensitivePaths } = __test__;
const mainSchemaHints = mapSensitivePaths(OpenClawSchema, "", {});
type TestSnapshot<TConfig extends Record<string, unknown>> = ConfigFileSnapshot & { type TestSnapshot<TConfig extends Record<string, unknown>> = ConfigFileSnapshot & {
parsed: TConfig; parsed: TConfig;
@@ -757,7 +758,7 @@ describe("redactConfigSnapshot", () => {
}); });
it("contract-covers dynamic catchall/record paths for redact+restore", () => { it("contract-covers dynamic catchall/record paths for redact+restore", () => {
const hints = mapSensitivePaths(OpenClawSchema, "", {}); const hints = mainSchemaHints;
const snapshot = makeSnapshot({ const snapshot = makeSnapshot({
env: { env: {
GROQ_API_KEY: "gsk-contract-123", GROQ_API_KEY: "gsk-contract-123",
@@ -1035,7 +1036,7 @@ describe("realredactConfigSnapshot_real", () => {
unrepresentable: "any", unrepresentable: "any",
}); });
schema.title = "OpenClawConfig"; schema.title = "OpenClawConfig";
const hints = mapSensitivePaths(OpenClawSchema, "", {}); const hints = mainSchemaHints;
const snapshot = makeSnapshot({ const snapshot = makeSnapshot({
agents: { agents: {

View File

@@ -22,7 +22,7 @@ const DEFAULT_GUARDRAIL_SKIP_PATTERNS = [
]; ];
const runtimeSourceGuardrailCache = new Map<string, Promise<RuntimeSourceGuardrailFile[]>>(); const runtimeSourceGuardrailCache = new Map<string, Promise<RuntimeSourceGuardrailFile[]>>();
const FILE_READ_CONCURRENCY = 32; const FILE_READ_CONCURRENCY = 16;
export function shouldSkipGuardrailRuntimeSource(relativePath: string): boolean { export function shouldSkipGuardrailRuntimeSource(relativePath: string): boolean {
return DEFAULT_GUARDRAIL_SKIP_PATTERNS.some((pattern) => pattern.test(relativePath)); return DEFAULT_GUARDRAIL_SKIP_PATTERNS.some((pattern) => pattern.test(relativePath));