Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
setLabAutomationDispatchDeps,
startLabAutomationScheduler,
} from "../lab/automation/orchestrator";
import { loadLabAutomationPolicy } from "../lab/automation/persistence";
import { loadLabAutomationConfig } from "../lab/automation/config-persistence";
import { createProductionLabRouteExecutor } from "../lib/lab-live-route-production";
import { runOpenAiTierStartupMigration } from "../providers/openai-tier-startup";
import { runAlibabaRegionStartupMigration } from "../providers/alibaba-region-startup";
Expand Down Expand Up @@ -1744,7 +1744,7 @@ export function startServer(port?: number, deps: StartServerDeps = {}): Server<W
loadConfig: () => config,
routeExecutor: productionLabRouteExecutor,
});
if (loadLabAutomationPolicy(labConfigDir).enabled) {
if (loadLabAutomationConfig(labConfigDir).policy.enabled) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Load automation intent before binding listeners

When automation-config.json is malformed or its lock cannot be acquired, loadLabAutomationConfig throws here after Bun.serve has already bound the public listener and after the startup rollback block has ended. The caller receives no server handle to stop, leaving the listener and associated resources alive so a retry can fail with an address conflict; load the intent before binding or include this post-bind initialization in the existing rollback transaction.

Useful? React with 👍 / 👎.

startLabAutomationScheduler(labConfigDir);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/lab-automation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ describe("CL-08 lab automation", () => {
}
});

test("server startup reads scheduler intent from the committed automation config", () => {
const src = readFileSync(join(process.cwd(), "src/server/index.ts"), "utf8");
expect(src).toContain("loadLabAutomationConfig(labConfigDir).policy.enabled");
expect(src).not.toContain("loadLabAutomationPolicy(labConfigDir).enabled");
Comment on lines +383 to +386

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exercise scheduler restart behavior instead of source text

This test only checks that a particular string appears in the source; it never writes an enabled combined config, starts the server, or verifies that the scheduler is running, so it would still pass if the loader or scheduler became a no-op and the restart regression returned. Add a behavioral test through a startup seam or live server that covers both an enabled committed config and a disabled committed config with stale legacy policy.

AGENTS.md reference: AGENTS.md:L231-L233

Useful? React with 👍 / 👎.

});

test("corrupt scheduler state fails closed on load", () => {
withHome((home) => {
const path = join(home, "lab");
Expand Down
Loading