惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
V
Visual Studio Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
B
Blog
I
InfoQ
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
H
Help Net Security
博客园 - Franky
宝玉的分享
宝玉的分享
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(test): avoid walking plugin boundary invariant scans ...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,8 +1,9 @@

1-

import { readFileSync, readdirSync } from "node:fs";

1+

import { spawnSync } from "node:child_process";

2+

import fs, { readFileSync } from "node:fs";

23

import { dirname, relative, resolve, sep } from "node:path";

34

import { fileURLToPath } from "node:url";

45

import ts from "typescript";

5-

import { describe, expect, it } from "vitest";

6+

import { describe, expect, it, vi } from "vitest";

6778

const SRC_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");

89

const REPO_ROOT = resolve(SRC_ROOT, "..");

@@ -120,14 +121,20 @@ type FileFilter = {

120121

function listTsFiles(rootRelativePath: string, filter: FileFilter = {}): string[] {

121122

const cacheKey = `${rootRelativePath}:${filter.excludeTests ? "exclude-tests" : ""}:${filter.testOnly ? "test-only" : ""}`;

122123

const cached = tsFilesCache.get(cacheKey);

123-

if (cached) {

124+

if (cached !== undefined) {

124125

return cached;

125126

}

127+

const externalFiles = listExternalTsFiles(rootRelativePath, filter);

128+

if (externalFiles) {

129+

tsFilesCache.set(cacheKey, externalFiles);

130+

return externalFiles;

131+

}

132+126133

const root = resolve(REPO_ROOT, rootRelativePath);

127134

const files: string[] = [];

128135129136

function walk(directory: string) {

130-

for (const entry of readdirSync(directory, { withFileTypes: true })) {

137+

for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {

131138

const fullPath = resolve(directory, entry.name);

132139

if (entry.isDirectory()) {

133140

if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") {

@@ -156,6 +163,73 @@ function listTsFiles(rootRelativePath: string, filter: FileFilter = {}): string[

156163

return sorted;

157164

}

158165166+

function listExternalTsFiles(rootRelativePath: string, filter: FileFilter): string[] | null {

167+

return listGitTrackedTsFiles(rootRelativePath, filter) ?? listFindTsFiles(rootRelativePath, filter);

168+

}

169+170+

function listGitTrackedTsFiles(rootRelativePath: string, filter: FileFilter): string[] | null {

171+

if (!rootRelativePath || rootRelativePath.startsWith("..")) {

172+

return null;

173+

}

174+

const result = spawnSync("git", ["ls-files", "--", rootRelativePath], {

175+

cwd: REPO_ROOT,

176+

encoding: "utf8",

177+

maxBuffer: 16 * 1024 * 1024,

178+

stdio: ["ignore", "pipe", "ignore"],

179+

});

180+

if (result.status !== 0) {

181+

return null;

182+

}

183+

return result.stdout

184+

.split("\n")

185+

.map((line) => line.trim().replaceAll("\\", "/"))

186+

.filter((line) => line.endsWith(".ts"))

187+

.filter((line) => !(filter.excludeTests && line.endsWith(".test.ts")))

188+

.filter((line) => !(filter.testOnly && !line.endsWith(".test.ts")))

189+

.toSorted();

190+

}

191+192+

function listFindTsFiles(rootRelativePath: string, filter: FileFilter): string[] | null {

193+

if (!rootRelativePath || rootRelativePath.startsWith("..")) {

194+

return null;

195+

}

196+

const root = resolve(REPO_ROOT, rootRelativePath);

197+

const result = spawnSync(

198+

"find",

199+

[

200+

root,

201+

"-type",

202+

"f",

203+

"-name",

204+

"*.ts",

205+

"-not",

206+

"-path",

207+

"*/node_modules/*",

208+

"-not",

209+

"-path",

210+

"*/dist/*",

211+

],

212+

{

213+

cwd: REPO_ROOT,

214+

encoding: "utf8",

215+

maxBuffer: 16 * 1024 * 1024,

216+

stdio: ["ignore", "pipe", "ignore"],

217+

},

218+

);

219+

if (result.status !== 0) {

220+

return null;

221+

}

222+

return result.stdout

223+

.split("\n")

224+

.map((line) => line.trim())

225+

.filter((line) => line.length > 0)

226+

.map((line) => relative(REPO_ROOT, line).split(sep).join("/"))

227+

.filter((line) => line.endsWith(".ts"))

228+

.filter((line) => !(filter.excludeTests && line.endsWith(".test.ts")))

229+

.filter((line) => !(filter.testOnly && !line.endsWith(".test.ts")))

230+

.toSorted();

231+

}

232+159233

function readRepoSource(file: string): string {

160234

const cached = sourceCache.get(file);

161235

if (cached !== undefined) {

@@ -221,6 +295,22 @@ function collectTypedHookNames(source: string): string[] {

221295

}

222296223297

describe("plugin contract boundary invariants", () => {

298+

it("lists boundary invariant source files without walking roots in-process", () => {

299+

const readDir = vi.spyOn(fs, "readdirSync");

300+

try {

301+

tsFilesCache.clear();

302+

const files = listTsFiles("src", { excludeTests: true });

303+304+

expect(files.length).toBeGreaterThan(0);

305+

expect(files.every((file) => file.startsWith("src/") && file.endsWith(".ts"))).toBe(true);

306+

expect(files.some((file) => file.endsWith(".test.ts"))).toBe(false);

307+

expect(readDir).not.toHaveBeenCalled();

308+

} finally {

309+

readDir.mockRestore();

310+

tsFilesCache.clear();

311+

}

312+

});

313+224314

it("keeps bundled-capability-metadata confined to contract/test inventory", () => {

225315

const files = listTsFiles("src");

226316

const offenders = files.filter((file) => {