Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
269 lines
8.9 KiB
JavaScript
269 lines
8.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import path from "node:path";
|
|
import ts from "typescript";
|
|
import {
|
|
collectFileViolations,
|
|
resolveRepoRoot,
|
|
resolveSourceRoots,
|
|
runAsScript,
|
|
toLine,
|
|
unwrapExpression,
|
|
} from "./lib/ts-guard-utils.mjs";
|
|
|
|
const legacyTranscriptReaderModules = new Set([
|
|
"../gateway/session-utils.js",
|
|
"../gateway/session-utils.fs.js",
|
|
"../../gateway/session-utils.js",
|
|
"../../gateway/session-utils.fs.js",
|
|
"./session-utils.js",
|
|
"./session-utils.fs.js",
|
|
"../session-utils.js",
|
|
"../session-utils.fs.js",
|
|
]);
|
|
|
|
const transcriptReaderNames = new Set([
|
|
"attachOpenClawTranscriptMeta",
|
|
"capArrayByJsonBytes",
|
|
"readFirstUserMessageFromTranscript",
|
|
"readLatestRecentSessionUsageFromTranscriptAsync",
|
|
"readLatestSessionUsageFromTranscript",
|
|
"readLatestSessionUsageFromTranscriptAsync",
|
|
"readRecentSessionMessages",
|
|
"readRecentSessionMessagesAsync",
|
|
"readRecentSessionMessagesWithStats",
|
|
"readRecentSessionMessagesWithStatsAsync",
|
|
"readRecentSessionTranscriptLines",
|
|
"readRecentSessionUsageFromTranscript",
|
|
"readRecentSessionUsageFromTranscriptAsync",
|
|
"readSessionMessageByIdAsync",
|
|
"readSessionMessageCount",
|
|
"readSessionMessageCountAsync",
|
|
"readSessionMessages",
|
|
"readSessionMessagesAsync",
|
|
"readSessionMessagesWithSourceAsync",
|
|
"readSessionPreviewItemsFromTranscript",
|
|
"readSessionTitleFieldsFromTranscript",
|
|
"readSessionTitleFieldsFromTranscriptAsync",
|
|
"visitSessionMessages",
|
|
"visitSessionMessagesAsync",
|
|
]);
|
|
|
|
const storageSpecificTranscriptReaderAliasNames = new Set(["readSessionMessagesFromFileAsync"]);
|
|
|
|
export const migratedSessionTranscriptReaderFiles = new Set([
|
|
"src/agents/main-session-restart-recovery.ts",
|
|
"src/agents/subagent-announce-output.test.ts",
|
|
"src/agents/subagent-announce-output.ts",
|
|
"src/agents/subagent-announce.runtime.ts",
|
|
"src/agents/subagent-orphan-recovery.test.ts",
|
|
"src/agents/subagent-orphan-recovery.ts",
|
|
"src/agents/tools/embedded-gateway-stub.runtime.ts",
|
|
"src/agents/tools/embedded-gateway-stub.test.ts",
|
|
"src/agents/tools/embedded-gateway-stub.ts",
|
|
"src/agents/tools/sessions-history-tool.ts",
|
|
"src/agents/tools/sessions-list-tool.ts",
|
|
"src/gateway/cli-session-history.claude.ts",
|
|
"src/gateway/gateway-models.profiles.live.test.ts",
|
|
"src/gateway/managed-image-attachments.test.ts",
|
|
"src/gateway/managed-image-attachments.ts",
|
|
"src/gateway/server-methods/artifacts.test.ts",
|
|
"src/gateway/server-methods/artifacts.ts",
|
|
"src/gateway/server-methods/chat.ts",
|
|
"src/gateway/server-methods/sessions-files.test.ts",
|
|
"src/gateway/server-methods/sessions-files.ts",
|
|
"src/gateway/server-methods/sessions.ts",
|
|
"src/gateway/server-session-events.ts",
|
|
"src/gateway/session-history-state.test.ts",
|
|
"src/gateway/session-history-state.ts",
|
|
"src/gateway/session-reset-service.ts",
|
|
"src/gateway/session-utils.ts",
|
|
"src/gateway/sessions-history-http.revocation.test.ts",
|
|
"src/gateway/sessions-history-http.ts",
|
|
"src/status/status-message.ts",
|
|
"src/tui/embedded-backend.test.ts",
|
|
"src/tui/embedded-backend.ts",
|
|
]);
|
|
|
|
function normalizeRelativePath(filePath) {
|
|
return filePath.replaceAll(path.sep, "/");
|
|
}
|
|
|
|
function importedModuleName(node) {
|
|
return node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)
|
|
? node.moduleSpecifier.text
|
|
: null;
|
|
}
|
|
|
|
function bindingName(node) {
|
|
if (node.propertyName && ts.isIdentifier(node.propertyName)) {
|
|
return node.propertyName.text;
|
|
}
|
|
if (ts.isIdentifier(node.name)) {
|
|
return node.name.text;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function destructuresLegacyNamespace(node, legacyNamespaces) {
|
|
const pattern = node.parent;
|
|
const declaration = pattern?.parent;
|
|
if (
|
|
!pattern ||
|
|
!ts.isObjectBindingPattern(pattern) ||
|
|
!declaration ||
|
|
!ts.isVariableDeclaration(declaration) ||
|
|
!declaration.initializer
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
const initializer = unwrapExpression(declaration.initializer);
|
|
return ts.isIdentifier(initializer) && legacyNamespaces.has(initializer.text);
|
|
}
|
|
|
|
export function findSessionTranscriptReaderBoundaryViolations(content, fileName = "source.ts") {
|
|
const sourceFile = ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true);
|
|
const violations = [];
|
|
const legacyNamespaces = new Set();
|
|
|
|
const visit = (node) => {
|
|
if (ts.isIdentifier(node) && storageSpecificTranscriptReaderAliasNames.has(node.text)) {
|
|
violations.push({
|
|
line: toLine(sourceFile, node),
|
|
reason: `uses storage-specific transcript reader alias "${node.text}"`,
|
|
});
|
|
}
|
|
|
|
if (ts.isImportDeclaration(node)) {
|
|
const moduleName = importedModuleName(node);
|
|
const namedBindings = node.importClause?.namedBindings;
|
|
if (moduleName && legacyTranscriptReaderModules.has(moduleName) && namedBindings) {
|
|
if (ts.isNamedImports(namedBindings)) {
|
|
for (const specifier of namedBindings.elements) {
|
|
const importedName = specifier.propertyName?.text ?? specifier.name.text;
|
|
if (transcriptReaderNames.has(importedName)) {
|
|
violations.push({
|
|
line: toLine(sourceFile, specifier),
|
|
reason: `imports transcript reader "${importedName}" from legacy module "${moduleName}"`,
|
|
});
|
|
}
|
|
}
|
|
} else if (ts.isNamespaceImport(namedBindings)) {
|
|
legacyNamespaces.add(namedBindings.name.text);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ts.isExportDeclaration(node)) {
|
|
const moduleName = importedModuleName(node);
|
|
if (moduleName && legacyTranscriptReaderModules.has(moduleName)) {
|
|
const exportClause = node.exportClause;
|
|
if (!exportClause) {
|
|
violations.push({
|
|
line: toLine(sourceFile, node),
|
|
reason: `re-exports transcript readers from legacy module "${moduleName}"`,
|
|
});
|
|
} else if (ts.isNamedExports(exportClause)) {
|
|
for (const specifier of exportClause.elements) {
|
|
const exportedName = specifier.propertyName?.text ?? specifier.name.text;
|
|
if (transcriptReaderNames.has(exportedName)) {
|
|
violations.push({
|
|
line: toLine(sourceFile, specifier),
|
|
reason: `re-exports transcript reader "${exportedName}" from legacy module "${moduleName}"`,
|
|
});
|
|
}
|
|
}
|
|
} else if (ts.isNamespaceExport(exportClause)) {
|
|
violations.push({
|
|
line: toLine(sourceFile, exportClause),
|
|
reason: `re-exports transcript reader namespace from legacy module "${moduleName}"`,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ts.isBindingElement(node)) {
|
|
const name = bindingName(node);
|
|
if (
|
|
name &&
|
|
transcriptReaderNames.has(name) &&
|
|
destructuresLegacyNamespace(node, legacyNamespaces)
|
|
) {
|
|
violations.push({
|
|
line: toLine(sourceFile, node),
|
|
reason: `aliases legacy transcript reader "${name}"`,
|
|
});
|
|
}
|
|
}
|
|
|
|
if (ts.isPropertyAccessExpression(node)) {
|
|
const receiver = unwrapExpression(node.expression);
|
|
if (
|
|
ts.isIdentifier(receiver) &&
|
|
legacyNamespaces.has(receiver.text) &&
|
|
transcriptReaderNames.has(node.name.text)
|
|
) {
|
|
violations.push({
|
|
line: toLine(sourceFile, node.name),
|
|
reason: `references legacy transcript reader "${node.name.text}"`,
|
|
});
|
|
}
|
|
}
|
|
|
|
if (
|
|
ts.isElementAccessExpression(node) &&
|
|
ts.isIdentifier(unwrapExpression(node.expression)) &&
|
|
legacyNamespaces.has(unwrapExpression(node.expression).text) &&
|
|
ts.isStringLiteral(node.argumentExpression) &&
|
|
transcriptReaderNames.has(node.argumentExpression.text)
|
|
) {
|
|
violations.push({
|
|
line: toLine(sourceFile, node.argumentExpression),
|
|
reason: `references legacy transcript reader "${node.argumentExpression.text}"`,
|
|
});
|
|
}
|
|
|
|
ts.forEachChild(node, visit);
|
|
};
|
|
|
|
visit(sourceFile);
|
|
return violations;
|
|
}
|
|
|
|
export async function main() {
|
|
const repoRoot = resolveRepoRoot(import.meta.url);
|
|
const sourceRoots = resolveSourceRoots(repoRoot, [
|
|
"src/agents",
|
|
"src/gateway",
|
|
"src/status",
|
|
"src/tui",
|
|
]);
|
|
const violations = await collectFileViolations({
|
|
repoRoot,
|
|
sourceRoots,
|
|
includeTests: true,
|
|
skipFile: (filePath) =>
|
|
!migratedSessionTranscriptReaderFiles.has(
|
|
normalizeRelativePath(path.relative(repoRoot, filePath)),
|
|
),
|
|
findViolations: findSessionTranscriptReaderBoundaryViolations,
|
|
});
|
|
|
|
if (violations.length === 0) {
|
|
console.log("session transcript reader boundary guard passed.");
|
|
return;
|
|
}
|
|
|
|
console.error("Found legacy transcript reader usage in migrated files:");
|
|
for (const violation of violations) {
|
|
console.error(`- ${violation.path}:${violation.line}: ${violation.reason}`);
|
|
}
|
|
console.error(
|
|
"Use src/gateway/session-transcript-readers.ts for migrated transcript reader paths. Expand this ratchet only after a slice migrates more files.",
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
runAsScript(import.meta.url, main);
|