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

推荐订阅源

美团技术团队
Microsoft Azure Blog
Microsoft Azure Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
Y
Y Combinator Blog
博客园_首页
有赞技术团队
有赞技术团队
博客园 - Franky
腾讯CDC
G
Google Developers Blog
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
D
Docker
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
U
Unit 42
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学

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 scanning legacy config ownership · openc...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,6 +1,7 @@

1+

import { spawnSync } from "node:child_process";

12

import fs from "node:fs";

23

import path from "node:path";

3-

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

4+

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

4556

const REPO_ROOT = path.resolve(import.meta.dirname, "../../../..");

67

const SRC_ROOT = path.join(REPO_ROOT, "src");

@@ -14,6 +15,77 @@ const LEGACY_MIGRATION_MODULE_RE =

1415

/legacy-config-migrate(?:\.js)?|legacy-config-migrations(?:\.[\w-]+)?(?:\.js)?/;

15161617

function collectSourceFiles(dir: string, acc: string[] = []): string[] {

18+

const externalFiles = listExternalSourceFiles(dir);

19+

if (externalFiles) {

20+

acc.push(...externalFiles);

21+

return acc;

22+

}

23+

return collectSourceFilesByDirectory(dir, acc);

24+

}

25+26+

function listExternalSourceFiles(dir: string): string[] | null {

27+

return listGitSourceFiles(dir) ?? listFindSourceFiles(dir);

28+

}

29+30+

function listGitSourceFiles(dir: string): string[] | null {

31+

const relativeRoot = path.relative(REPO_ROOT, dir).replaceAll(path.sep, "/");

32+

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

33+

cwd: REPO_ROOT,

34+

encoding: "utf8",

35+

maxBuffer: 1024 * 1024 * 4,

36+

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

37+

});

38+

if (result.status !== 0) {

39+

return null;

40+

}

41+

return result.stdout

42+

.split("\n")

43+

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

44+

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

45+

.map((file) => path.join(REPO_ROOT, file))

46+

.filter(isOwnedSourceFile)

47+

.toSorted();

48+

}

49+50+

function listFindSourceFiles(dir: string): string[] | null {

51+

const result = spawnSync(

52+

"find",

53+

[

54+

dir,

55+

"(",

56+

"-name",

57+

"dist",

58+

"-o",

59+

"-name",

60+

"node_modules",

61+

")",

62+

"-prune",

63+

"-o",

64+

"-type",

65+

"f",

66+

"-name",

67+

"*.ts",

68+

"-print",

69+

],

70+

{

71+

cwd: REPO_ROOT,

72+

encoding: "utf8",

73+

maxBuffer: 1024 * 1024 * 4,

74+

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

75+

},

76+

);

77+

if (result.status !== 0) {

78+

return null;

79+

}

80+

return result.stdout

81+

.split("\n")

82+

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

83+

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

84+

.filter(isOwnedSourceFile)

85+

.toSorted();

86+

}

87+88+

function collectSourceFilesByDirectory(dir: string, acc: string[] = []): string[] {

1789

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

1890

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

1991

continue;

@@ -23,17 +95,26 @@ function collectSourceFiles(dir: string, acc: string[] = []): string[] {

2395

if (fullPath === DOCTOR_ROOT) {

2496

continue;

2597

}

26-

collectSourceFiles(fullPath, acc);

98+

collectSourceFilesByDirectory(fullPath, acc);

2799

continue;

28100

}

29-

if (!entry.isFile() || !entry.name.endsWith(".ts") || entry.name.endsWith(".test.ts")) {

101+

if (!entry.isFile() || !isOwnedSourceFile(fullPath)) {

30102

continue;

31103

}

32104

acc.push(fullPath);

33105

}

34106

return acc;

35107

}

36108109+

function isOwnedSourceFile(file: string): boolean {

110+

return file.endsWith(".ts") && !file.endsWith(".test.ts") && !isUnderDoctorRoot(file);

111+

}

112+113+

function isUnderDoctorRoot(file: string): boolean {

114+

const relativePath = path.relative(DOCTOR_ROOT, file);

115+

return relativePath === "" || (!relativePath.startsWith("..") && !path.isAbsolute(relativePath));

116+

}

117+37118

function collectViolations(files: string[]): string[] {

38119

const violations: string[] = [];

39120

for (const file of files) {

@@ -58,6 +139,19 @@ function collectViolations(files: string[]): string[] {

58139

}

5914060141

describe("legacy config write ownership", () => {

142+

it("lists ownership scan files without scanning source directories in-process", () => {

143+

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

144+

try {

145+

const files = collectSourceFiles(SRC_ROOT);

146+147+

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

148+

expect(files.every(isOwnedSourceFile)).toBe(true);

149+

expect(readDir).not.toHaveBeenCalled();

150+

} finally {

151+

readDir.mockRestore();

152+

}

153+

});

154+61155

it("keeps legacy config repair flags and migration modules under doctor", () => {

62156

const files = collectSourceFiles(SRC_ROOT);

63157

const violations = collectViolations(files);