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

推荐订阅源

P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
B
Blog
月光博客
月光博客
博客园 - 【当耐特】
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Jina AI
Jina AI
博客园 - Franky
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
B
Blog RSS Feed
H
Help Net Security

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): reduce changed-target import graph IO · opencl...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,3 +1,4 @@

1+

import { spawnSync } from "node:child_process";

12

import fs from "node:fs";

23

import os from "node:os";

34

import path from "node:path";

@@ -741,13 +742,154 @@ function resolveImportSpecifier(importer, specifier, fileSet) {

741742742743

let cachedImportGraph = null;

743744

let cachedImportGraphCwd = null;

745+

let cachedImportGraphFiles = null;

746+

let cachedImportGraphFilesCwd = null;

747+748+

function isImportableGraphFile(relative) {

749+

return IMPORTABLE_FILE_EXTENSIONS.some((ext) => relative.endsWith(ext));

750+

}

751+752+

function listImportGraphFilesFromGit(cwd) {

753+

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

754+

cwd,

755+

encoding: "utf8",

756+

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

757+

});

758+

if (result.status !== 0) {

759+

return null;

760+

}

761+

return result.stdout

762+

.split("\n")

763+

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

764+

.filter((line) => line.length > 0 && isImportableGraphFile(line));

765+

}

766+767+

function listImportGraphFilesForCwd(cwd) {

768+

if (cachedImportGraphFiles && cachedImportGraphFilesCwd === cwd) {

769+

return cachedImportGraphFiles;

770+

}

771+772+

cachedImportGraphFiles =

773+

listImportGraphFilesFromGit(cwd) ??

774+

SOURCE_ROOTS_FOR_IMPORT_GRAPH.flatMap((root) => listImportGraphFiles(cwd, root));

775+

cachedImportGraphFilesCwd = cwd;

776+

return cachedImportGraphFiles;

777+

}

778+779+

function stripImportableGraphExtension(relative) {

780+

for (const ext of IMPORTABLE_FILE_EXTENSIONS) {

781+

if (relative.endsWith(ext)) {

782+

return relative.slice(0, -ext.length);

783+

}

784+

}

785+

return relative;

786+

}

787+788+

function resolveImportGraphSearchTerm(relative) {

789+

const basename = path.posix.basename(stripImportableGraphExtension(relative));

790+

if (basename === "index" || basename.length < 3) {

791+

return null;

792+

}

793+

return basename;

794+

}

795+796+

function listImportGraphGrepMatches(cwd, term) {

797+

const result = spawnSync(

798+

"git",

799+

["grep", "-l", "--fixed-strings", term, "--", ...SOURCE_ROOTS_FOR_IMPORT_GRAPH],

800+

{

801+

cwd,

802+

encoding: "utf8",

803+

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

804+

},

805+

);

806+

if (result.status === 1) {

807+

return [];

808+

}

809+

if (result.status !== 0) {

810+

return null;

811+

}

812+

return result.stdout

813+

.split("\n")

814+

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

815+

.filter((line) => line.length > 0 && isImportableGraphFile(line));

816+

}

817+818+

function findDirectImportersWithGitGrep(cwd, importedFile, fileSet) {

819+

const term = resolveImportGraphSearchTerm(importedFile);

820+

if (!term) {

821+

return null;

822+

}

823+824+

const candidates = listImportGraphGrepMatches(cwd, term);

825+

if (!candidates || candidates.length > 800) {

826+

return null;

827+

}

828+829+

const importers = [];

830+

for (const file of candidates) {

831+

if (file === importedFile || !fileSet.has(file)) {

832+

continue;

833+

}

834+

let source = "";

835+

try {

836+

source = fs.readFileSync(path.join(cwd, file), "utf8");

837+

} catch {

838+

continue;

839+

}

840+

for (const match of source.matchAll(IMPORT_SPECIFIER_PATTERN)) {

841+

const imported = resolveImportSpecifier(file, match[1] ?? match[2] ?? "", fileSet);

842+

if (imported === importedFile) {

843+

importers.push(file);

844+

break;

845+

}

846+

}

847+

}

848+

return importers;

849+

}

850+851+

function resolveAffectedTestsFromTargetedImportScan(changedPath, cwd) {

852+

const normalized = normalizePathPattern(changedPath);

853+

const files = listImportGraphFilesForCwd(cwd);

854+

const fileSet = new Set(files);

855+

if (!fileSet.has(normalized)) {

856+

return [];

857+

}

858+859+

const testFiles = new Set(

860+

files.filter((file) => isTestFileTarget(file) && !file.endsWith(".live.test.ts")),

861+

);

862+

const queue = [normalized];

863+

const seen = new Set(queue);

864+

const targets = [];

865+866+

for (let index = 0; index < queue.length; index += 1) {

867+

const current = queue[index];

868+

const importers = findDirectImportersWithGitGrep(cwd, current, fileSet);

869+

if (importers === null) {

870+

return null;

871+

}

872+

for (const importer of importers) {

873+

if (seen.has(importer)) {

874+

continue;

875+

}

876+

seen.add(importer);

877+

if (testFiles.has(importer)) {

878+

targets.push(importer);

879+

}

880+

queue.push(importer);

881+

}

882+

}

883+884+

return [...new Set(targets)].toSorted((left, right) => left.localeCompare(right));

885+

}

744886745887

function getImportGraph(cwd) {

746888

if (cachedImportGraph && cachedImportGraphCwd === cwd) {

747889

return cachedImportGraph;

748890

}

749891750-

const files = SOURCE_ROOTS_FOR_IMPORT_GRAPH.flatMap((root) => listImportGraphFiles(cwd, root));

892+

const files = listImportGraphFilesForCwd(cwd);

751893

const fileSet = new Set(files);

752894

const reverseImports = new Map();

753895

const testFiles = new Set(

@@ -779,6 +921,11 @@ function getImportGraph(cwd) {

779921780922

function resolveAffectedTestsFromImportGraph(changedPath, cwd) {

781923

const normalized = normalizePathPattern(changedPath);

924+

const targetedTargets = resolveAffectedTestsFromTargetedImportScan(normalized, cwd);

925+

if (targetedTargets !== null) {

926+

return targetedTargets;

927+

}

928+782929

const { reverseImports, testFiles } = getImportGraph(cwd);

783930

const queue = [normalized];

784931

const seen = new Set(queue);