Skip to content

Commit ab53491

Browse files
authored
refactor(core): remove stale internal exports (#100856)
* refactor(core): remove reintroduced unused helpers * refactor(core): remove test-only production seams
1 parent 90e1ef1 commit ab53491

17 files changed

Lines changed: 14 additions & 262 deletions

src/agents/worktrees/registry.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { closeOpenClawStateDatabaseForTest } from "../../state/openclaw-state-db
66
import {
77
deleteRegistryWorktree,
88
findRegistryWorktreeByPath,
9-
findLiveRegistryWorktree,
9+
findLiveRegistryWorktreeByPath,
1010
getRegistryWorktree,
1111
insertRegistryWorktree,
1212
listRegistryWorktrees,
@@ -54,7 +54,7 @@ describe("managed worktree registry", () => {
5454
});
5555

5656
expect(listRegistryWorktrees(env).map((entry) => entry.id)).toEqual(["second", "first"]);
57-
expect(findLiveRegistryWorktree(env, record.repoFingerprint, record.path)).toMatchObject({
57+
expect(findLiveRegistryWorktreeByPath(env, record.path)).toMatchObject({
5858
id: "first",
5959
ownerKind: "workboard",
6060
ownerId: "card-1",
@@ -70,6 +70,7 @@ describe("managed worktree registry", () => {
7070
removedAt: 40,
7171
snapshotRef: "refs/openclaw/snapshots/first",
7272
});
73+
expect(findLiveRegistryWorktreeByPath(env, record.path)).toBeUndefined();
7374
expect(findRegistryWorktreeByPath(env, record.path)?.id).toBe("first");
7475

7576
deleteRegistryWorktree(env, "first");

src/agents/worktrees/registry.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,6 @@ export function getRegistryWorktree(
7575
return row ? rowToRecord(row) : undefined;
7676
}
7777

78-
export function findLiveRegistryWorktree(
79-
env: NodeJS.ProcessEnv,
80-
repoFingerprint: string,
81-
worktreePath: string,
82-
): ManagedWorktreeRecord | undefined {
83-
const db = dbFor(env);
84-
const query = kyselyFor(db)
85-
.selectFrom("worktrees")
86-
.selectAll()
87-
.where("repo_fingerprint", "=", repoFingerprint)
88-
.where("path", "=", worktreePath)
89-
.where("removed_at", "is", null)
90-
.orderBy("created_at", "desc")
91-
.limit(1);
92-
const row = executeSqliteQuerySync(db, query).rows[0];
93-
return row ? rowToRecord(row) : undefined;
94-
}
95-
9678
export function findLiveRegistryWorktreeByPath(
9779
env: NodeJS.ProcessEnv,
9880
worktreePath: string,

src/config/sessions/session-accessor.test.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
markSessionAbortTarget,
2424
patchSessionEntry,
2525
persistSessionResetLifecycle,
26-
persistSessionRolloverLifecycle,
2726
persistSessionTranscriptTurn,
2827
purgeDeletedAgentSessionEntries,
2928
publishTranscriptUpdate,
@@ -1790,63 +1789,6 @@ describe("session accessor file-backed seam", () => {
17901789
expect(fs.readFileSync(nextTranscript, "utf-8")).toContain('"content":"hello"');
17911790
});
17921791

1793-
it("persists rollover entries and returns archived previous transcript info", async () => {
1794-
const now = Date.now();
1795-
const sessionKey = "agent:main:telegram:dm:user";
1796-
const retiredKey = "agent:main:main";
1797-
const previousTranscript = path.join(tempDir, "previous-rollover.jsonl");
1798-
const previousEntry: SessionEntry = {
1799-
sessionFile: previousTranscript,
1800-
sessionId: "previous-rollover",
1801-
updatedAt: now,
1802-
};
1803-
const nextEntry: SessionEntry = {
1804-
sessionFile: path.join(tempDir, "next-rollover.jsonl"),
1805-
sessionId: "next-rollover",
1806-
updatedAt: now + 1,
1807-
};
1808-
fs.writeFileSync(previousTranscript, '{"type":"session","id":"previous-rollover"}\n', "utf-8");
1809-
await upsertSessionEntry({ sessionKey, storePath }, previousEntry);
1810-
await upsertSessionEntry(
1811-
{ sessionKey: retiredKey, storePath },
1812-
{
1813-
lastChannel: "telegram",
1814-
lastTo: "user",
1815-
sessionId: "legacy-main",
1816-
updatedAt: now,
1817-
},
1818-
);
1819-
1820-
const result = await persistSessionRolloverLifecycle({
1821-
activeSessionKey: sessionKey,
1822-
agentId: "main",
1823-
previousEntry,
1824-
retiredEntry: {
1825-
key: retiredKey,
1826-
entry: {
1827-
sessionId: "legacy-main",
1828-
updatedAt: now,
1829-
},
1830-
},
1831-
sessionEntry: nextEntry,
1832-
sessionKey,
1833-
storePath,
1834-
});
1835-
1836-
expect(result.sessionEntry).toMatchObject(nextEntry);
1837-
expect(result.previousSessionTranscript.transcriptArchived).toBe(true);
1838-
expect(result.previousSessionTranscript.sessionFile).toContain(
1839-
"previous-rollover.jsonl.reset.",
1840-
);
1841-
expect(loadSessionEntry({ sessionKey, storePath })).toMatchObject(nextEntry);
1842-
expect(loadSessionEntry({ sessionKey: retiredKey, storePath })).toEqual({
1843-
sessionId: "legacy-main",
1844-
updatedAt: expect.any(Number),
1845-
});
1846-
expect(fs.existsSync(previousTranscript)).toBe(false);
1847-
expect(fs.existsSync(result.previousSessionTranscript.sessionFile ?? "")).toBe(true);
1848-
});
1849-
18501792
it("appends transcript events through a session scope", async () => {
18511793
const scope = {
18521794
sessionFile: transcriptPath,

src/config/sessions/session-accessor.ts

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,6 @@ export type SessionLifecycleTranscriptInfo = {
408408
transcriptArchived?: boolean;
409409
};
410410

411-
export type SessionLifecycleRolloverResult = {
412-
previousSessionTranscript: SessionLifecycleTranscriptInfo;
413-
sessionEntry: SessionEntry;
414-
};
415-
416411
export type ReplySessionInitializationSnapshot = {
417412
currentEntry?: SessionEntry;
418413
readEntry: (sessionKey: string) => SessionEntry | undefined;
@@ -1761,54 +1756,6 @@ export async function persistSessionResetLifecycle(params: {
17611756
return { replayedMessages };
17621757
}
17631758

1764-
/**
1765-
* Persists a reply session rollover and returns stable previous-transcript
1766-
* data for lifecycle hooks. Non-storage runtime cleanup remains with callers.
1767-
*/
1768-
export async function persistSessionRolloverLifecycle(params: {
1769-
activeSessionKey: string;
1770-
agentId: string;
1771-
maintenanceConfig?: ResolvedSessionMaintenanceConfig;
1772-
onArchiveError?: (error: unknown, sourcePath: string) => void;
1773-
onMaintenanceWarning?: (warning: SessionMaintenanceWarning) => void | Promise<void>;
1774-
previousEntry?: SessionEntry;
1775-
retiredEntry?: SessionEntryRetirement;
1776-
sessionEntry: SessionEntry;
1777-
sessionKey: string;
1778-
storePath: string;
1779-
}): Promise<SessionLifecycleRolloverResult> {
1780-
await updateSessionStore(
1781-
params.storePath,
1782-
(store) => {
1783-
store[params.sessionKey] = {
1784-
...store[params.sessionKey],
1785-
...params.sessionEntry,
1786-
};
1787-
if (params.retiredEntry) {
1788-
store[params.retiredEntry.key] = params.retiredEntry.entry;
1789-
}
1790-
return store[params.sessionKey] ?? params.sessionEntry;
1791-
},
1792-
{
1793-
activeSessionKey: params.activeSessionKey,
1794-
maintenanceConfig: params.maintenanceConfig,
1795-
onWarn: params.onMaintenanceWarning,
1796-
},
1797-
);
1798-
1799-
const previousSessionTranscript = await archivePreviousSessionTranscript({
1800-
agentId: params.agentId,
1801-
onArchiveError: params.onArchiveError,
1802-
previousEntry: params.previousEntry,
1803-
storePath: params.storePath,
1804-
});
1805-
1806-
return {
1807-
previousSessionTranscript,
1808-
sessionEntry: params.sessionEntry,
1809-
};
1810-
}
1811-
18121759
/** Loads the reply-session initialization rows without exposing a mutable store. */
18131760
export function loadReplySessionInitializationSnapshot(params: {
18141761
storePath: string;

src/gateway/gateway-codex-bind.live.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { clearConfigCache, clearRuntimeConfigSnapshot } from "../config/config.j
1111
import type { OpenClawConfig } from "../config/types.openclaw.js";
1212
import { isTruthyEnvValue } from "../infra/env.js";
1313
import { getSessionBindingService } from "../infra/outbound/session-binding-service.js";
14-
import { resolveBundledPluginWorkspaceSourcePath } from "../plugins/bundled-plugin-metadata.js";
14+
import { findBundledPluginMetadataById } from "../plugins/bundled-plugin-metadata.js";
1515
import { pluginCommands } from "../plugins/command-registry-state.js";
1616
import { clearPluginLoaderCache } from "../plugins/loader.js";
1717
import {
@@ -278,14 +278,15 @@ function resolveCodexPluginRoot(): string {
278278
if (command?.pluginRoot) {
279279
return command.pluginRoot;
280280
}
281-
const pluginRoot = resolveBundledPluginWorkspaceSourcePath({
281+
const metadata = findBundledPluginMetadataById("codex", {
282282
rootDir: process.cwd(),
283-
pluginId: "codex",
283+
includeChannelConfigs: false,
284+
includeSyntheticChannelConfigs: false,
284285
});
285-
if (!pluginRoot) {
286+
if (!metadata) {
286287
throw new Error("Codex bundled plugin root was not found");
287288
}
288-
return pluginRoot;
289+
return path.resolve(process.cwd(), "extensions", metadata.dirName);
289290
}
290291

291292
function resolveBoundSessionKey(params: {

src/infra/clawhub.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ export type ClawHubPackageSecurityResponse = {
139139
} | null;
140140
trust: ClawHubPackageSecurityTrust;
141141
};
142-
export type ClawHubPackageReadiness = {
143-
ok?: boolean;
144-
ready?: boolean;
145-
status?: string | null;
146-
reasons?: string[];
147-
checks?: Record<string, unknown>;
148-
} & Record<string, unknown>;
149142
export type ClawHubPackageClawPackSummary = {
150143
available: boolean;
151144
specVersion?: number | null;
@@ -1116,22 +1109,6 @@ export async function fetchClawHubPackageSecurity(params: {
11161109
return parseClawHubPackageSecurityResponse(response);
11171110
}
11181111

1119-
export async function fetchClawHubPackageReadiness(params: {
1120-
name: string;
1121-
baseUrl?: string;
1122-
token?: string;
1123-
timeoutMs?: number;
1124-
fetchImpl?: FetchLike;
1125-
}): Promise<ClawHubPackageReadiness> {
1126-
return await fetchJson<ClawHubPackageReadiness>({
1127-
baseUrl: params.baseUrl,
1128-
path: `/api/v1/packages/${encodeURIComponent(params.name)}/readiness`,
1129-
token: params.token,
1130-
timeoutMs: params.timeoutMs,
1131-
fetchImpl: params.fetchImpl,
1132-
});
1133-
}
1134-
11351112
export async function searchClawHubPackages(params: {
11361113
query: string;
11371114
family?: ClawHubPackageFamily;

src/infra/windows-gateway-firewall-diagnostics.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,15 +1026,3 @@ export function formatWindowsGatewayFirewallGuidance(params: {
10261026
"Windows firewall: if another device cannot connect to the LAN URL, run `openclaw gateway status --deep` from this Windows host.",
10271027
];
10281028
}
1029-
1030-
export function formatWindowsGatewayFirewallDiagnostic(
1031-
diagnostic: WindowsGatewayFirewallDiagnostic,
1032-
): string[] {
1033-
if (!diagnostic.applies || diagnostic.severity !== "warning") {
1034-
return [];
1035-
}
1036-
return [
1037-
`Windows firewall: ${diagnostic.message}`,
1038-
...diagnostic.details.map((line) => ` ${line}`),
1039-
];
1040-
}

src/plugins/bundled-plugin-metadata.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -206,29 +206,6 @@ export function findBundledPluginMetadataById(
206206
return listBundledPluginMetadata(params).find((entry) => entry.manifest.id === pluginId);
207207
}
208208

209-
/** Resolves the source directory for a bundled plugin in the current workspace. */
210-
export function resolveBundledPluginWorkspaceSourcePath(params: {
211-
rootDir: string;
212-
scanDir?: string;
213-
pluginId: string;
214-
}): string | null {
215-
const metadata = findBundledPluginMetadataById(params.pluginId, {
216-
...resolveBundledPluginLookupParams({
217-
rootDir: params.rootDir,
218-
scanDir: params.scanDir,
219-
}),
220-
includeChannelConfigs: false,
221-
includeSyntheticChannelConfigs: false,
222-
});
223-
if (!metadata) {
224-
return null;
225-
}
226-
if (params.scanDir) {
227-
return path.resolve(params.scanDir, metadata.dirName);
228-
}
229-
return path.resolve(params.rootDir, "extensions", metadata.dirName);
230-
}
231-
232209
function listBundledPluginEntryBaseDirs(params: {
233210
rootDir: string;
234211
pluginDirName?: string;

src/plugins/contracts/host-hooks.contract.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {
3636
drainPluginNextTurnInjections,
3737
enqueuePluginNextTurnInjection,
3838
patchPluginSessionExtension,
39-
projectPluginSessionExtensions,
4039
projectPluginSessionExtensionsSync,
4140
} from "../host-hook-state.js";
4241
import { buildPluginAgentTurnPrepareContext, isPluginJsonValue } from "../host-hooks.js";
@@ -1389,9 +1388,6 @@ describe("host-hook fixture plugin contract", () => {
13891388
expect(projectPluginSessionExtensionsSync({ sessionKey: "agent:main:main", entry })).toEqual(
13901389
[],
13911390
);
1392-
await expect(
1393-
projectPluginSessionExtensions({ sessionKey: "agent:main:main", entry }),
1394-
).resolves.toStrictEqual([]);
13951391
});
13961392

13971393
it("skips throwing session extension projectors without losing other projections", () => {

src/plugins/host-hook-state.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,6 @@ function projectSessionExtensionValueForSlot(params: {
416416
return copyJsonValue(projected);
417417
}
418418

419-
export async function projectPluginSessionExtensions(params: {
420-
sessionKey: string;
421-
entry: SessionEntry;
422-
}): Promise<PluginSessionExtensionProjection[]> {
423-
return collectPluginSessionExtensionProjections(params);
424-
}
425-
426419
function collectPluginSessionExtensionProjections(params: {
427420
sessionKey: string;
428421
entry: SessionEntry;

0 commit comments

Comments
 (0)