Skip to content

Commit d115fb4

Browse files
authored
refactor: move task state to shared sqlite
Move task run, delivery, and flow registry persistence onto the shared OpenClaw state SQLite database. Summary: - Store task runs, delivery state, and flow runs in state/openclaw.sqlite via the generated Kysely schema. - Migrate shipped task sidecars into the shared state DB and archive old sidecars, including invalid-config/read-only CLI paths. - Keep startup migration lightweight for read-only status/tasks paths while still detecting known legacy state markers and custom session stores. Verification: - .agents/skills/autoreview/scripts/autoreview --mode local: clean after final fix - pnpm test src/tasks/task-registry.store.test.ts src/tasks/task-flow-registry.store.test.ts src/commands/doctor-state-migrations.test.ts -- --reporter=verbose - pnpm test src/commands/doctor-state-migrations.test.ts src/cli/program/config-guard.test.ts src/cli/route.test.ts src/cli/command-path-policy.test.ts -- --reporter=verbose - pnpm test src/cli/program/config-guard.test.ts src/cli/route.test.ts src/cli/command-startup-policy.test.ts src/cli/command-path-policy.test.ts src/cli/command-execution-startup.test.ts -- --reporter=verbose - pnpm test src/cli/program/config-guard.test.ts src/cli/argv.test.ts src/cli/route.test.ts src/commands/doctor-config-preflight.state-migration.test.ts -- --reporter=verbose - pnpm test src/tasks/task-flow-registry.store.test.ts -- --reporter=verbose - pnpm test test/scripts/lint-suppressions.test.ts -- --reporter=verbose - pnpm db:kysely:check - pnpm lint:kysely - git diff --check HEAD - pnpm test:startup:memory - PR CI green on 2f7d76f
1 parent e9dee8d commit d115fb4

29 files changed

Lines changed: 2449 additions & 1339 deletions

‎src/cli/argv.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,10 @@ describe("argv helpers", () => {
582582
});
583583

584584
it.each([
585-
{ argv: ["node", "openclaw", "status"], expected: false },
585+
{ argv: ["node", "openclaw", "status"], expected: true },
586586
{ argv: ["node", "openclaw", "health"], expected: false },
587587
{ argv: ["node", "openclaw", "sessions"], expected: false },
588-
{ argv: ["node", "openclaw", "--profile", "work", "status"], expected: false },
588+
{ argv: ["node", "openclaw", "--profile", "work", "status"], expected: true },
589589
{ argv: ["node", "openclaw", "--log-level=debug", "models", "list"], expected: false },
590590
{ argv: ["node", "openclaw", "config", "get", "update"], expected: false },
591591
{ argv: ["node", "openclaw", "config", "unset", "update"], expected: false },
@@ -600,7 +600,7 @@ describe("argv helpers", () => {
600600
});
601601

602602
it.each([
603-
{ path: ["status"], expected: false },
603+
{ path: ["status"], expected: true },
604604
{ path: ["update", "status"], expected: false },
605605
{ path: ["config", "get"], expected: false },
606606
{ path: ["models", "status"], expected: false },

‎src/cli/argv.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export function shouldMigrateStateFromPath(path: string[]): boolean {
452452
return true;
453453
}
454454
const [primary, secondary] = path;
455-
if (primary === "health" || primary === "status" || primary === "sessions") {
455+
if (primary === "health" || primary === "sessions") {
456456
return false;
457457
}
458458
if (primary === "update" && secondary === "status") {

‎src/cli/command-catalog.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
124124
policy: {
125125
loadPlugins: "never",
126126
pluginRegistry: { scope: "channels" },
127-
routeConfigGuard: "when-suppressed",
128127
ensureCliPath: false,
129128
networkProxy: "bypass",
130129
},
@@ -180,7 +179,6 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
180179
commandPath: ["commitments"],
181180
policy: {
182181
ensureCliPath: false,
183-
routeConfigGuard: "when-suppressed",
184182
loadPlugins: "never",
185183
networkProxy: "bypass",
186184
},
@@ -225,7 +223,6 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
225223
exact: true,
226224
policy: {
227225
ensureCliPath: false,
228-
routeConfigGuard: "when-suppressed",
229226
loadPlugins: "never",
230227
networkProxy: "bypass",
231228
},
@@ -236,7 +233,6 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
236233
exact: true,
237234
policy: {
238235
ensureCliPath: false,
239-
routeConfigGuard: "when-suppressed",
240236
loadPlugins: "never",
241237
networkProxy: "bypass",
242238
},
@@ -246,7 +242,6 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
246242
commandPath: ["tasks"],
247243
policy: {
248244
ensureCliPath: false,
249-
routeConfigGuard: "when-suppressed",
250245
loadPlugins: "never",
251246
networkProxy: "bypass",
252247
},

‎src/cli/command-execution-startup.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe("command-execution-startup", () => {
4545
startupPolicy: {
4646
suppressDoctorStdout: true,
4747
hideBanner: false,
48-
skipConfigGuard: true,
48+
skipConfigGuard: false,
4949
loadPlugins: false,
5050
pluginRegistry: { scope: "channels" },
5151
},
@@ -168,7 +168,7 @@ describe("command-execution-startup", () => {
168168
startupPolicy: {
169169
suppressDoctorStdout: true,
170170
hideBanner: false,
171-
skipConfigGuard: true,
171+
skipConfigGuard: false,
172172
loadPlugins: false,
173173
pluginRegistry: { scope: "channels" },
174174
},
@@ -181,7 +181,7 @@ describe("command-execution-startup", () => {
181181
allowInvalid: undefined,
182182
loadPlugins: false,
183183
pluginRegistry: { scope: "channels" },
184-
skipConfigGuard: true,
184+
skipConfigGuard: false,
185185
});
186186

187187
const messageRuntime = {} as never;

‎src/cli/command-path-policy.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe("command-path-policy", () => {
5656

5757
it("resolves status policy with shared startup semantics", () => {
5858
expectResolvedPolicy(["status"], {
59-
routeConfigGuard: "when-suppressed",
59+
routeConfigGuard: "never",
6060
loadPlugins: "never",
6161
pluginRegistry: { scope: "channels" },
6262
ensureCliPath: false,
@@ -221,6 +221,13 @@ describe("command-path-policy", () => {
221221
loadPlugins: "never",
222222
networkProxy: "bypass",
223223
});
224+
for (const commandPath of [["tasks"], ["tasks", "list"], ["tasks", "audit"]]) {
225+
expectResolvedPolicy(commandPath, {
226+
ensureCliPath: false,
227+
loadPlugins: "never",
228+
networkProxy: "bypass",
229+
});
230+
}
224231
for (const commandPath of [
225232
["plugins", "install"],
226233
["plugins", "inspect"],

‎src/cli/command-startup-policy.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("command-startup-policy", () => {
2424
commandPath: ["status"],
2525
suppressDoctorStdout: true,
2626
}),
27-
).toBe(true);
27+
).toBe(false);
2828
expect(
2929
shouldSkipRouteConfigGuardForCommandPath({
3030
commandPath: ["gateway", "status"],
@@ -239,7 +239,7 @@ describe("command-startup-policy", () => {
239239
).toEqual({
240240
suppressDoctorStdout: true,
241241
hideBanner: false,
242-
skipConfigGuard: true,
242+
skipConfigGuard: false,
243243
loadPlugins: false,
244244
pluginRegistry: { scope: "channels" },
245245
});

0 commit comments

Comments
 (0)