Skip to content

Commit 1b02289

Browse files
authored
refactor(flows): trim internal export surface (#107420)
1 parent e5e8d87 commit 1b02289

5 files changed

Lines changed: 46 additions & 53 deletions

File tree

‎scripts/deadcode-exports.baseline.mjs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,6 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [
644644
"src/fleet/service.runtime.ts: FleetServiceOptions",
645645
"src/flows/doctor-health-contributions.ts: createDoctorHealthContribution",
646646
"src/flows/doctor-health-contributions.ts: resolveDoctorHealthContributions",
647-
"src/flows/doctor-health-contributions.ts: shouldSkipLegacyUpdateDoctorConfigWrite",
648-
"src/flows/health-check-adapter.ts: defineSplitHealthCheck",
649647
"src/gateway/cli-session-history.claude.ts: ClaudeCliPromptTextCandidate",
650648
"src/gateway/terminal/launch.ts: shellQuote",
651649
"src/hooks/gmail-setup-utils.ts: resetGmailSetupUtilsCachesForTest",

‎src/flows/doctor-health-contributions.test.ts‎

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
createDoctorHealthContribution,
1212
resolveDoctorContributionHealthChecks,
1313
resolveDoctorHealthContributions,
14-
shouldSkipLegacyUpdateDoctorConfigWrite,
1514
} from "./doctor-health-contributions.js";
1615
import { runDoctorLintChecks } from "./doctor-lint-flow.js";
1716
import type { HealthCheck, HealthFinding } from "./health-checks.js";
@@ -2951,43 +2950,6 @@ describe("doctor health contributions", () => {
29512950
},
29522951
);
29532952

2954-
it("skips doctor config writes under legacy update parents", () => {
2955-
expect(
2956-
shouldSkipLegacyUpdateDoctorConfigWrite({
2957-
env: { OPENCLAW_UPDATE_IN_PROGRESS: "1" },
2958-
}),
2959-
).toBe(true);
2960-
});
2961-
2962-
it("keeps doctor writes outside legacy update writable", () => {
2963-
expect(
2964-
shouldSkipLegacyUpdateDoctorConfigWrite({
2965-
env: {},
2966-
}),
2967-
).toBe(false);
2968-
});
2969-
2970-
it("keeps current update parents writable", () => {
2971-
expect(
2972-
shouldSkipLegacyUpdateDoctorConfigWrite({
2973-
env: {
2974-
OPENCLAW_UPDATE_IN_PROGRESS: "1",
2975-
OPENCLAW_UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE: "1",
2976-
},
2977-
}),
2978-
).toBe(false);
2979-
});
2980-
2981-
it("treats falsey update env values as normal writes", () => {
2982-
expect(
2983-
shouldSkipLegacyUpdateDoctorConfigWrite({
2984-
env: {
2985-
OPENCLAW_UPDATE_IN_PROGRESS: "0",
2986-
},
2987-
}),
2988-
).toBe(false);
2989-
});
2990-
29912953
describe("write-config lint findings", () => {
29922954
const writeConfigContribution = requireDoctorContribution("doctor:write-config");
29932955
const check = writeConfigContribution.healthChecks[0] as HealthCheck & {
@@ -3346,6 +3308,41 @@ describe("doctor health contributions", () => {
33463308
(entry) => entry.id === "doctor:write-config",
33473309
)!;
33483310

3311+
it.each([
3312+
{
3313+
name: "legacy update parents",
3314+
env: { OPENCLAW_UPDATE_IN_PROGRESS: "1" },
3315+
shouldWrite: false,
3316+
},
3317+
{ name: "ordinary doctor runs", env: {}, shouldWrite: true },
3318+
{
3319+
name: "current update parents",
3320+
env: {
3321+
OPENCLAW_UPDATE_IN_PROGRESS: "1",
3322+
OPENCLAW_UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE: "1",
3323+
},
3324+
shouldWrite: true,
3325+
},
3326+
{
3327+
name: "falsey update env values",
3328+
env: { OPENCLAW_UPDATE_IN_PROGRESS: "0" },
3329+
shouldWrite: true,
3330+
},
3331+
])("handles config writes for $name", async ({ env, shouldWrite }) => {
3332+
const ctx = buildWriteConfigCtx(env);
3333+
3334+
await writeConfigContribution.run(ctx);
3335+
3336+
if (shouldWrite) {
3337+
expect(mocks.replaceConfigFile).toHaveBeenCalled();
3338+
} else {
3339+
expect(mocks.replaceConfigFile).not.toHaveBeenCalled();
3340+
expect(ctx.runtime.log).toHaveBeenCalledWith(
3341+
"Skipping doctor config write during legacy update handoff.",
3342+
);
3343+
}
3344+
});
3345+
33493346
it("allows config size drops when OPENCLAW_UPDATE_IN_PROGRESS=1", async () => {
33503347
const ctx = buildWriteConfigCtx({
33513348
OPENCLAW_UPDATE_IN_PROGRESS: "1",

‎src/flows/doctor-health-contributions.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ function isTruthyEnvValue(value: string | undefined): boolean {
103103
return normalized !== "" && normalized !== "0" && normalized !== "false" && normalized !== "no";
104104
}
105105

106-
export function shouldSkipLegacyUpdateDoctorConfigWrite(params: {
107-
env: NodeJS.ProcessEnv;
108-
}): boolean {
106+
function shouldSkipLegacyUpdateDoctorConfigWrite(params: { env: NodeJS.ProcessEnv }): boolean {
109107
if (!isTruthyEnvValue(params.env.OPENCLAW_UPDATE_IN_PROGRESS)) {
110108
return false;
111109
}

‎src/flows/doctor-repair-flow.test.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { describe, expect, expectTypeOf, it } from "vitest";
33
import type { OpenClawConfig } from "../config/types.openclaw.js";
44
import { runDoctorHealthRepairs } from "./doctor-repair-flow.js";
5-
import { defineSplitHealthCheck, normalizeHealthCheck } from "./health-check-adapter.js";
5+
import { normalizeHealthCheck } from "./health-check-adapter.js";
66
import type { RunnableHealthCheck, SplitHealthCheckInput } from "./health-check-runner-types.js";
77
import type { HealthCheck, HealthRepairContext } from "./health-checks.js";
88

@@ -68,7 +68,7 @@ describe("runDoctorHealthRepairs", () => {
6868
it("repairs modern checks and threads updated config", async () => {
6969
const scopes: unknown[] = [];
7070
const checks: HealthCheck[] = [
71-
defineSplitHealthCheck({
71+
normalizeHealthCheck({
7272
id: "test/repairable",
7373
kind: "core",
7474
description: "repairable",
@@ -116,7 +116,7 @@ describe("runDoctorHealthRepairs", () => {
116116

117117
it("leaves non-repairable checks for legacy doctor behavior", async () => {
118118
const checks: HealthCheck[] = [
119-
defineSplitHealthCheck({
119+
normalizeHealthCheck({
120120
id: "test/legacy-only",
121121
kind: "core",
122122
description: "legacy only",
@@ -144,7 +144,7 @@ describe("runDoctorHealthRepairs", () => {
144144

145145
it("keeps split check findings when repair throws", async () => {
146146
const checks: HealthCheck[] = [
147-
defineSplitHealthCheck({
147+
normalizeHealthCheck({
148148
id: "test/repair-throws",
149149
kind: "core",
150150
description: "repair throws",
@@ -179,7 +179,7 @@ describe("runDoctorHealthRepairs", () => {
179179

180180
it("reports repair validation findings that remain after repair", async () => {
181181
const checks: HealthCheck[] = [
182-
defineSplitHealthCheck({
182+
normalizeHealthCheck({
183183
id: "test/not-fixed",
184184
kind: "core",
185185
description: "not fixed",
@@ -217,7 +217,7 @@ describe("runDoctorHealthRepairs", () => {
217217
it("validates successful repairs by default", async () => {
218218
let detectCalls = 0;
219219
const checks: HealthCheck[] = [
220-
defineSplitHealthCheck({
220+
normalizeHealthCheck({
221221
id: "test/no-default-validation",
222222
kind: "core",
223223
description: "no default validation",
@@ -256,7 +256,7 @@ describe("runDoctorHealthRepairs", () => {
256256
it("does not validate skipped or failed repair results", async () => {
257257
let validationCalls = 0;
258258
const checks: HealthCheck[] = [
259-
defineSplitHealthCheck({
259+
normalizeHealthCheck({
260260
id: "test/skipped",
261261
kind: "core",
262262
description: "skipped",
@@ -294,7 +294,7 @@ describe("runDoctorHealthRepairs", () => {
294294
const repairContexts: HealthRepairContext[] = [];
295295
let detectCalls = 0;
296296
const checks: HealthCheck[] = [
297-
defineSplitHealthCheck({
297+
normalizeHealthCheck({
298298
id: "test/dry-run",
299299
kind: "core",
300300
description: "dry run",
@@ -356,7 +356,7 @@ describe("runDoctorHealthRepairs", () => {
356356
it("passes diff false and true through the repair API", async () => {
357357
const repairContexts: HealthRepairContext[] = [];
358358
const checks: HealthCheck[] = [
359-
defineSplitHealthCheck({
359+
normalizeHealthCheck({
360360
id: "test/diff-preview",
361361
kind: "core",
362362
description: "diff preview",

‎src/flows/health-check-adapter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { HealthRepairContext } from "./health-checks.js";
99

1010
// Adapts legacy split detect/repair checks and newer runnable checks to one runner contract.
1111
/** Wraps a detect/repair health check in the runnable health-check contract. */
12-
export function defineSplitHealthCheck(check: SplitHealthCheckInput): RegisteredHealthCheck {
12+
function defineSplitHealthCheck(check: SplitHealthCheckInput): RegisteredHealthCheck {
1313
return {
1414
id: check.id,
1515
kind: check.kind,

0 commit comments

Comments
 (0)