慣性聚合 高效追讀感興趣之博客、新聞、科技資訊
閱原文 以慣性聚合開啟

推薦訂閱源

博客园 - 司徒正美
V
V2EX
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
月光博客
月光博客
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311
修 gateway:尊重启引流预算于嵌入式运行 · openclaw/openclaw@6008375
Kaspre · 2026-05-24 · via Recent Commits to openclaw:main

@@ -9,6 +9,9 @@ const acquireGatewayLock = vi.fn(async (_opts?: { port?: number }) => ({

99

const consumeGatewayRestartIntentPayloadSync = vi.fn<

1010

() => { reason?: string; force?: boolean; waitMs?: number } | null

1111

>(() => null);

12+

const consumeGatewaySigusr1RestartIntent = vi.fn<

13+

() => { reason?: string; force?: boolean; waitMs?: number } | null

14+

>(() => null);

1215

const consumeGatewaySigusr1RestartAuthorization = vi.fn(() => true);

1316

const consumeGatewayRestartIntentSync = vi.fn(() => false);

1417

const isGatewaySigusr1RestartExternallyAllowed = vi.fn(() => false);

@@ -81,6 +84,8 @@ const markRestartAbortedMainSessions = vi.fn(async (_params: unknown) => ({

8184

}));

8285

const waitForActiveEmbeddedRuns = vi.fn(async (_timeoutMs?: number) => ({ drained: true }));

8386

const DRAIN_TIMEOUT_LOG = "drain timeout reached; proceeding with restart";

87+

const ACTIVE_RUN_DRAIN_TIMEOUT_LOG =

88+

"active embedded run drain timeout reached; aborting active run(s) before restart";

8489

const DEFAULT_RESTART_DEFERRAL_TIMEOUT_MS = 300_000;

8590

const loadConfig = vi.fn<() => { gateway: { reload: { deferralTimeoutMs?: number } } }>(() => ({

8691

gateway: {

@@ -101,6 +106,7 @@ vi.mock("../../infra/gateway-lock.js", () => ({

101106102107

vi.mock("../../infra/restart.js", () => ({

103108

consumeGatewayRestartIntentPayloadSync: () => consumeGatewayRestartIntentPayloadSync(),

109+

consumeGatewaySigusr1RestartIntent: () => consumeGatewaySigusr1RestartIntent(),

104110

consumeGatewaySigusr1RestartAuthorization: () => consumeGatewaySigusr1RestartAuthorization(),

105111

consumeGatewayRestartIntentSync: () => consumeGatewayRestartIntentSync(),

106112

isGatewaySigusr1RestartExternallyAllowed: () => isGatewaySigusr1RestartExternallyAllowed(),

@@ -430,6 +436,7 @@ describe("runGatewayLoop", () => {

430436

vi.clearAllMocks();

431437

consumeGatewayRestartIntentPayloadSync.mockReturnValueOnce({ waitMs: 2_500 });

432438

getActiveTaskCount.mockReturnValueOnce(1).mockReturnValue(0);

439+

getActiveEmbeddedRunCount.mockReturnValueOnce(1).mockReturnValue(0);

433440434441

await withIsolatedSignals(async ({ captureSignal }) => {

435442

const { start, exited } = await createSignaledLoopHarness();

@@ -441,6 +448,7 @@ describe("runGatewayLoop", () => {

441448

await new Promise<void>((resolve) => setImmediate(resolve));

442449443450

expect(waitForActiveTasks).toHaveBeenCalledWith(2_500);

451+

expect(waitForActiveEmbeddedRuns).toHaveBeenCalledWith(2_500);

444452

expect(start).toHaveBeenCalledTimes(2);

445453446454

sigint();

@@ -469,7 +477,65 @@ describe("runGatewayLoop", () => {

469477

});

470478

});

471479472-

it("aborts active embedded runs after a short restart drain grace", async () => {

480+

it("waits indefinitely for active embedded runs on unbounded restarts", async () => {

481+

vi.clearAllMocks();

482+

consumeGatewayRestartIntentPayloadSync.mockReturnValueOnce({ waitMs: 0 });

483+

getActiveEmbeddedRunCount.mockReturnValueOnce(1).mockReturnValue(0);

484+

waitForActiveEmbeddedRuns.mockResolvedValueOnce({ drained: true });

485+486+

await withIsolatedSignals(async ({ captureSignal }) => {

487+

const { close, start, exited } = await createSignaledLoopHarness();

488+

const sigterm = captureSignal("SIGTERM");

489+

const sigint = captureSignal("SIGINT");

490+491+

sigterm();

492+

await new Promise<void>((resolve) => setImmediate(resolve));

493+

await new Promise<void>((resolve) => setImmediate(resolve));

494+495+

expect(waitForActiveEmbeddedRuns).toHaveBeenCalledWith(undefined);

496+

expect(abortEmbeddedPiRun).toHaveBeenCalledWith(undefined, { mode: "compacting" });

497+

expect(abortEmbeddedPiRun).not.toHaveBeenCalledWith(undefined, { mode: "all" });

498+

expectRestartCloseCall(close, 15_000);

499+

expect(start).toHaveBeenCalledTimes(2);

500+501+

sigint();

502+

await expect(exited).resolves.toBe(0);

503+

});

504+

});

505+506+

it("waits indefinitely for active embedded runs when reload config disables deferral timeout", async () => {

507+

vi.clearAllMocks();

508+

loadConfig.mockReturnValueOnce({

509+

gateway: {

510+

reload: {

511+

deferralTimeoutMs: 0,

512+

},

513+

},

514+

});

515+

getActiveEmbeddedRunCount.mockReturnValueOnce(1).mockReturnValue(0);

516+

waitForActiveEmbeddedRuns.mockResolvedValueOnce({ drained: true });

517+518+

await withIsolatedSignals(async ({ captureSignal }) => {

519+

const { close, start, exited } = await createSignaledLoopHarness();

520+

const sigusr1 = captureSignal("SIGUSR1");

521+

const sigint = captureSignal("SIGINT");

522+523+

sigusr1();

524+

await new Promise<void>((resolve) => setImmediate(resolve));

525+

await new Promise<void>((resolve) => setImmediate(resolve));

526+527+

expect(waitForActiveEmbeddedRuns).toHaveBeenCalledWith(undefined);

528+

expect(abortEmbeddedPiRun).toHaveBeenCalledWith(undefined, { mode: "compacting" });

529+

expect(abortEmbeddedPiRun).not.toHaveBeenCalledWith(undefined, { mode: "all" });

530+

expectRestartCloseCall(close, 15_000);

531+

expect(start).toHaveBeenCalledTimes(2);

532+533+

sigint();

534+

await expect(exited).resolves.toBe(0);

535+

});

536+

});

537+538+

it("uses the restart drain timeout for active embedded runs before aborting", async () => {

473539

vi.clearAllMocks();

474540

consumeGatewayRestartIntentPayloadSync.mockReturnValueOnce({});

475541

getActiveTaskCount.mockReturnValueOnce(1).mockReturnValue(0);

@@ -490,12 +556,10 @@ describe("runGatewayLoop", () => {

490556

await new Promise<void>((resolve) => setImmediate(resolve));

491557492558

expect(waitForActiveTasks).toHaveBeenCalledWith(90_000);

493-

expect(waitForActiveEmbeddedRuns).toHaveBeenCalledWith(30_000);

559+

expect(waitForActiveEmbeddedRuns).toHaveBeenCalledWith(90_000);

494560

expect(abortEmbeddedPiRun).toHaveBeenCalledWith(undefined, { mode: "compacting" });

495561

expect(abortEmbeddedPiRun).toHaveBeenCalledWith(undefined, { mode: "all" });

496-

expect(gatewayLog.warn).toHaveBeenCalledWith(

497-

"active embedded run drain grace reached; aborting active run(s) before restart",

498-

);

562+

expect(gatewayLog.warn).toHaveBeenCalledWith(ACTIVE_RUN_DRAIN_TIMEOUT_LOG);

499563

expect(gatewayLog.warn).toHaveBeenCalledWith(DRAIN_TIMEOUT_LOG);

500564

expect(markRestartAbortedMainSessions).toHaveBeenCalledWith({

501565

cfg: {

@@ -520,6 +584,51 @@ describe("runGatewayLoop", () => {

520584

});

521585

});

522586587+

it("skips a second active-work drain after a SIGUSR1 deferral timeout intent", async () => {

588+

vi.clearAllMocks();

589+

consumeGatewaySigusr1RestartIntent.mockReturnValueOnce({

590+

force: true,

591+

reason: "config reload forced restart",

592+

});

593+

getActiveTaskCount.mockReturnValueOnce(1).mockReturnValue(0);

594+

getActiveEmbeddedRunCount.mockReturnValueOnce(1).mockReturnValue(0);

595+

listActiveEmbeddedRunSessionIds.mockReturnValueOnce(["session-deferral-timeout"]);

596+

listActiveEmbeddedRunSessionKeys.mockReturnValueOnce(["agent:main:deferral-timeout"]);

597+598+

await withIsolatedSignals(async ({ captureSignal }) => {

599+

const { close, start, exited } = await createSignaledLoopHarness();

600+

const sigusr1 = captureSignal("SIGUSR1");

601+

const sigint = captureSignal("SIGINT");

602+603+

sigusr1();

604+

await new Promise<void>((resolve) => setImmediate(resolve));

605+

await new Promise<void>((resolve) => setImmediate(resolve));

606+607+

expect(waitForActiveTasks).not.toHaveBeenCalled();

608+

expect(waitForActiveEmbeddedRuns).not.toHaveBeenCalled();

609+

expect(abortEmbeddedPiRun).toHaveBeenCalledWith(undefined, { mode: "compacting" });

610+

expect(abortEmbeddedPiRun).toHaveBeenCalledWith(undefined, { mode: "all" });

611+

expect(markRestartAbortedMainSessions).toHaveBeenCalledWith({

612+

cfg: {

613+

gateway: {

614+

reload: {

615+

deferralTimeoutMs: 90_000,

616+

},

617+

},

618+

},

619+

sessionIds: new Set(["session-deferral-timeout"]),

620+

sessionKeys: new Set(["agent:main:deferral-timeout"]),

621+

reason: "config reload forced restart",

622+

});

623+

expect(markGatewaySigusr1RestartHandled).toHaveBeenCalledOnce();

624+

expectRestartCloseCall(close, 0);

625+

expect(start).toHaveBeenCalledTimes(2);

626+627+

sigint();

628+

await expect(exited).resolves.toBe(0);

629+

});

630+

});

631+523632

it("forces SIGTERM restarts without waiting for active task drain", async () => {

524633

vi.clearAllMocks();

525634

consumeGatewayRestartIntentPayloadSync.mockReturnValueOnce({ force: true });

@@ -1029,6 +1138,7 @@ describe("runGatewayLoop", () => {

1029113810301139

await withIsolatedSignals(async ({ captureSignal }) => {

10311140

getActiveTaskCount.mockReturnValueOnce(1).mockReturnValue(0);

1141+

getActiveEmbeddedRunCount.mockReturnValueOnce(1).mockReturnValue(0);

1032114210331143

const { start } = await createSignaledLoopHarness();

10341144

const sigusr1 = captureSignal("SIGUSR1");

@@ -1038,6 +1148,7 @@ describe("runGatewayLoop", () => {

10381148

await new Promise<void>((resolve) => setImmediate(resolve));

1039114910401150

expect(waitForActiveTasks).toHaveBeenCalledWith(DEFAULT_RESTART_DEFERRAL_TIMEOUT_MS);

1151+

expect(waitForActiveEmbeddedRuns).toHaveBeenCalledWith(DEFAULT_RESTART_DEFERRAL_TIMEOUT_MS);

10411152

expect(markGatewayDraining).toHaveBeenCalledOnce();

10421153

expect(start).toHaveBeenCalledTimes(2);

10431154

});

@@ -1090,6 +1201,53 @@ describe("runGatewayLoop", () => {

10901201

});

10911202

});

109212031204+

it("clears the in-flight restart token when a file intent handles authorized SIGUSR1", async () => {

1205+

vi.clearAllMocks();

1206+

consumeGatewayRestartIntentPayloadSync.mockReturnValueOnce({

1207+

force: true,

1208+

reason: "file-intent restart",

1209+

});

1210+

loadConfig.mockReturnValueOnce({

1211+

gateway: {

1212+

reload: {

1213+

deferralTimeoutMs: 90_000,

1214+

},

1215+

},

1216+

});

1217+

getActiveEmbeddedRunCount.mockReturnValueOnce(1).mockReturnValue(0);

1218+

listActiveEmbeddedRunSessionIds.mockReturnValueOnce(["session-file-intent"]);

1219+

listActiveEmbeddedRunSessionKeys.mockReturnValueOnce(["agent:main:file-intent"]);

1220+1221+

await withIsolatedSignals(async ({ captureSignal }) => {

1222+

const { start, exited } = await createSignaledLoopHarness();

1223+

const sigusr1 = captureSignal("SIGUSR1");

1224+

const sigint = captureSignal("SIGINT");

1225+1226+

sigusr1();

1227+

await new Promise<void>((resolve) => setImmediate(resolve));

1228+

await new Promise<void>((resolve) => setImmediate(resolve));

1229+1230+

expect(consumeGatewaySigusr1RestartAuthorization).toHaveBeenCalledOnce();

1231+

expect(markGatewaySigusr1RestartHandled).toHaveBeenCalledOnce();

1232+

expect(markRestartAbortedMainSessions).toHaveBeenCalledWith({

1233+

cfg: {

1234+

gateway: {

1235+

reload: {

1236+

deferralTimeoutMs: 90_000,

1237+

},

1238+

},

1239+

},

1240+

sessionIds: new Set(["session-file-intent"]),

1241+

sessionKeys: new Set(["agent:main:file-intent"]),

1242+

reason: "file-intent restart",

1243+

});

1244+

expect(start).toHaveBeenCalledTimes(2);

1245+1246+

sigint();

1247+

await expect(exited).resolves.toBe(0);

1248+

});

1249+

});

1250+10931251

it("releases the lock before exiting on spawned restart", async () => {

10941252

vi.clearAllMocks();

10951253

peekGatewaySigusr1RestartReason.mockReturnValue(undefined);