@cat-factory/local-server 0.32.2 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +33 -11
- package/dist/container.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/mothership.d.ts +102 -26
- package/dist/mothership.d.ts.map +1 -1
- package/dist/mothership.js +223 -66
- package/dist/mothership.js.map +1 -1
- package/dist/server.js +4 -2
- package/dist/server.js.map +1 -1
- package/dist/sqlite/workQueue.d.ts +112 -0
- package/dist/sqlite/workQueue.d.ts.map +1 -0
- package/dist/sqlite/workQueue.js +259 -0
- package/dist/sqlite/workQueue.js.map +1 -0
- package/package.json +11 -11
package/dist/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAUpE,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAO7F,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,qBAAqB,CAAA;AAmD5B,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAUpE,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAO7F,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,qBAAqB,CAAA;AAmD5B,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,eAAe,CA8dlF;AAOD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,EAAE,CAc3E"}
|
package/dist/container.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CryptoIdGenerator, DrizzleEnvironmentUserHandlerRepository, DrizzleGitHubInstallationRepository, DrizzleLocalSettingsRepository, DrizzleRunnerPoolConnectionRepository, ProvisioningLogRecorder, SystemClock, buildNodeContainer, buildNodeResolveTransport, createDrizzleRepositories, executionRuntime, loadNodeConfig, withProvisioningLog, } from '@cat-factory/node-server';
|
|
2
|
-
import {
|
|
2
|
+
import { SqliteWorkRunner, composeMothership, isMothershipMode, } from './mothership.js';
|
|
3
3
|
import { ConflictError } from '@cat-factory/kernel';
|
|
4
4
|
import { WorkspaceSettingsService } from '@cat-factory/orchestration';
|
|
5
5
|
import { buildInfrastructureCapabilities, logger, RunnerJobClient } from '@cat-factory/server';
|
|
@@ -338,11 +338,23 @@ export function buildLocalContainer(options) {
|
|
|
338
338
|
active: localTestInfraSupported ? 'local-compose' : 'environment-provider',
|
|
339
339
|
},
|
|
340
340
|
});
|
|
341
|
-
// Mothership mode has no pg-boss: drive runs in-process through the SAME advance/poll loop
|
|
342
|
-
//
|
|
343
|
-
//
|
|
344
|
-
|
|
345
|
-
|
|
341
|
+
// Mothership mode has no pg-boss: drive runs in-process through the SAME advance/poll loop with
|
|
342
|
+
// real timer-backed sleeps, backed by the durable local-sqlite work queue (so a crash/restart
|
|
343
|
+
// re-drives what was in flight — the durability pg-boss gives the Node facade). Bound to the
|
|
344
|
+
// execution service AFTER the container is built (the service doesn't exist yet — chicken-and-egg
|
|
345
|
+
// with createCore). The lease/sweeper timings reuse the same execution-runtime derivation the
|
|
346
|
+
// pg-boss queue/sweeper use, so durable recovery behaves consistently across the two runners.
|
|
347
|
+
const runtime = mothership ? executionRuntime(config, env) : undefined;
|
|
348
|
+
const inProcessRunner = mothership && runtime
|
|
349
|
+
? new SqliteWorkRunner(mothership.workQueue, {
|
|
350
|
+
drive: runtime.drive,
|
|
351
|
+
leaseMs: runtime.queue.expireInSeconds * 1000,
|
|
352
|
+
reArmDelayMs: Math.max(1000, runtime.drive.ciPollIntervalMs),
|
|
353
|
+
errorBackoffMs: Math.max(1000, runtime.drive.ciPollIntervalMs),
|
|
354
|
+
sweepIntervalMs: runtime.sweeper.intervalMs,
|
|
355
|
+
maxAttempts: runtime.queue.retryLimit,
|
|
356
|
+
concurrency: runtime.concurrency,
|
|
357
|
+
}, logger)
|
|
346
358
|
: undefined;
|
|
347
359
|
const container = buildNodeContainer({
|
|
348
360
|
...options,
|
|
@@ -427,8 +439,10 @@ export function buildLocalContainer(options) {
|
|
|
427
439
|
},
|
|
428
440
|
});
|
|
429
441
|
// Bind the in-process work runner to the now-built execution service, so `startRun` /
|
|
430
|
-
// `signalDecision` drive runs in-process (mothership mode; no-op otherwise).
|
|
431
|
-
|
|
442
|
+
// `signalDecision` drive runs in-process (mothership mode; no-op otherwise). The kind-spanning
|
|
443
|
+
// agent-runs reader powers the storage-reconciliation backstop (re-drive a run still `running` in
|
|
444
|
+
// storage that lost its queue row) — the no-pg-boss analogue of the stale-run sweeper.
|
|
445
|
+
inProcessRunner?.bind(container.executionService, container.agentRunRepository);
|
|
432
446
|
// Surface the local-mode settings service so the dedicated local-settings panel can
|
|
433
447
|
// read/write the warm-pool + checkout config (the controller 503s when this is absent,
|
|
434
448
|
// which is the case on every non-local facade). Also expose the PAT-login registry so the
|
|
@@ -437,9 +451,17 @@ export function buildLocalContainer(options) {
|
|
|
437
451
|
...container,
|
|
438
452
|
vcsIdentity,
|
|
439
453
|
...(localSettingsService ? { localSettings: { service: localSettingsService } } : {}),
|
|
440
|
-
//
|
|
441
|
-
//
|
|
442
|
-
|
|
454
|
+
// On shutdown (mothership mode; the boot path calls this from its SIGTERM/SIGINT handler):
|
|
455
|
+
// stop the work runner's recovery poll FIRST so it can't touch the queue mid-close, then
|
|
456
|
+
// release both local SQLite handles (credentials + work queue). No-op otherwise.
|
|
457
|
+
...(mothership
|
|
458
|
+
? {
|
|
459
|
+
onShutdown: () => {
|
|
460
|
+
inProcessRunner?.stop();
|
|
461
|
+
mothership.close();
|
|
462
|
+
},
|
|
463
|
+
}
|
|
464
|
+
: {}),
|
|
443
465
|
};
|
|
444
466
|
}
|
|
445
467
|
/** Values that explicitly DISABLE native mode (so `LOCAL_NATIVE_AGENTS=false` means off). */
|
package/dist/container.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,uCAAuC,EACvC,mCAAmC,EACnC,8BAA8B,EAC9B,qCAAqC,EACrC,uBAAuB,EACvB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EACL,mBAAmB,EAEnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG9F,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,2BAA2B,CAAA;AAMlC,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,GACd,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE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AK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5D,IAAI,KAAK,KAAK,aAAa,IAAI,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;aACpE,IAAI,KAAK,KAAK,OAAO;YAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;aACvC,IAAI,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,WAAW,GAAG,IAAI,CAAA;IAC3D,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC;QAAE,OAAO,CAAC,GAAG,GAAG,CAAC,CAAA;IACjC,wFAAwF;IACxF,4DAA4D;IAC5D,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACpD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { type ContainerRuntimeAdapter, type ContainerExec, type RuntimeId, creat
|
|
|
6
6
|
export { linkRepo, type LinkRepoOptions, type LinkedRepo } from './linkRepo.js';
|
|
7
7
|
export { createLocalGitHubClient, StaticTokenAppRegistry } from './github.js';
|
|
8
8
|
export { createLocalCredentialStore, type LocalCredentialStore } from './sqlite/credentialStore.js';
|
|
9
|
-
export { composeMothership, isMothershipMode,
|
|
9
|
+
export { composeMothership, isMothershipMode, SqliteWorkRunner, type SqliteWorkRunnerOptions, type MothershipComposition, } from './mothership.js';
|
|
10
10
|
export { registerAgentKind, registerAgentKinds, clearRegisteredAgentKinds, type AgentKindDefinition, } from '@cat-factory/agents';
|
|
11
11
|
export { registerPipeline, registerPipelines, clearRegisteredPipelines } from '@cat-factory/kernel';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,EACpC,KAAK,oCAAoC,GAC1C,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAO7E,OAAO,EAAE,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAInG,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,EACpC,KAAK,oCAAoC,GAC1C,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAO7E,OAAO,EAAE,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAInG,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAA;AAIxB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -22,10 +22,10 @@ export { createLocalGitHubClient, StaticTokenAppRegistry } from './github.js';
|
|
|
22
22
|
// public; the raw db opener and the repo classes stay internal until the 1b composition
|
|
23
23
|
// step proves a consumer needs them.
|
|
24
24
|
export { createLocalCredentialStore } from './sqlite/credentialStore.js';
|
|
25
|
-
// Mothership composition: the remote (RPC) + local-sqlite repository set, the
|
|
26
|
-
// runner that replaces pg-boss, and the boot-mode probe. `startLocal()` selects
|
|
27
|
-
// boot automatically when LOCAL_MOTHERSHIP_URL is set.
|
|
28
|
-
export { composeMothership, isMothershipMode,
|
|
25
|
+
// Mothership composition: the remote (RPC) + local-sqlite repository set, the durable
|
|
26
|
+
// SQLite-backed work runner that replaces pg-boss, and the boot-mode probe. `startLocal()` selects
|
|
27
|
+
// the no-Postgres boot automatically when LOCAL_MOTHERSHIP_URL is set.
|
|
28
|
+
export { composeMothership, isMothershipMode, SqliteWorkRunner, } from './mothership.js';
|
|
29
29
|
// Installation-level extension points, re-exported for parity with the Node facade so
|
|
30
30
|
// a local deployment can register custom agent kinds / pipelines before `startLocal()`.
|
|
31
31
|
export { registerAgentKind, registerAgentKinds, clearRegisteredAgentKinds, } from '@cat-factory/agents';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kFAAkF;AAClF,iFAAiF;AACjF,sFAAsF;AACtF,yEAAyE;AACzE,gFAAgF;AAChF,4DAA4D;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,GAErC,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAIL,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAA;AAC5B,qFAAqF;AACrF,gFAAgF;AAChF,sEAAsE;AACtE,OAAO,EAAE,QAAQ,EAAyC,MAAM,eAAe,CAAA;AAC/E,6EAA6E;AAC7E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAE7E,0FAA0F;AAC1F,sFAAsF;AACtF,wFAAwF;AACxF,wFAAwF;AACxF,qCAAqC;AACrC,OAAO,EAAE,0BAA0B,EAA6B,MAAM,6BAA6B,CAAA;AACnG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kFAAkF;AAClF,iFAAiF;AACjF,sFAAsF;AACtF,yEAAyE;AACzE,gFAAgF;AAChF,4DAA4D;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,GAErC,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAIL,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAA;AAC5B,qFAAqF;AACrF,gFAAgF;AAChF,sEAAsE;AACtE,OAAO,EAAE,QAAQ,EAAyC,MAAM,eAAe,CAAA;AAC/E,6EAA6E;AAC7E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAE7E,0FAA0F;AAC1F,sFAAsF;AACtF,wFAAwF;AACxF,wFAAwF;AACxF,qCAAqC;AACrC,OAAO,EAAE,0BAA0B,EAA6B,MAAM,6BAA6B,CAAA;AACnG,sFAAsF;AACtF,mGAAmG;AACnG,uEAAuE;AACvE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GAGjB,MAAM,iBAAiB,CAAA;AAExB,sFAAsF;AACtF,wFAAwF;AACxF,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/mothership.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type CoreRepositories, type DriveConfig, driveExecution } from '@cat-factory/node-server';
|
|
2
2
|
import { type Logger } from '@cat-factory/server';
|
|
3
|
-
import type { WorkRunner } from '@cat-factory/kernel';
|
|
3
|
+
import type { AgentRunRepository, WorkRunner } from '@cat-factory/kernel';
|
|
4
4
|
import { type LocalCredentialStore } from './sqlite/credentialStore.js';
|
|
5
|
+
import { SqliteWorkQueue } from './sqlite/workQueue.js';
|
|
5
6
|
/** True when this local node should boot in mothership mode (a mothership URL is configured). */
|
|
6
7
|
export declare function isMothershipMode(env: NodeJS.ProcessEnv): boolean;
|
|
7
8
|
/** The composed mothership persistence: remote org repos + the local credential store. */
|
|
@@ -13,13 +14,17 @@ export interface MothershipComposition {
|
|
|
13
14
|
* six core domain repos, which is NOT enough for a board load or a run end-to-end — those
|
|
14
15
|
* touch many more repos (mounts, settings, presets, notifications, …) that are still
|
|
15
16
|
* un-allow-listed (and the direct-db repos in `buildNodeContainer` have no db here), so they
|
|
16
|
-
* currently throw.
|
|
17
|
-
*
|
|
17
|
+
* currently throw. Widening that surface is the gating phase tracked in
|
|
18
|
+
* docs/initiatives/mothership-mode.md; until it lands a mothership node cannot yet serve a board
|
|
19
|
+
* load or a run end-to-end (this durable-work-queue slice is the execution substrate it will run
|
|
20
|
+
* on, not the end-to-end enablement itself).
|
|
18
21
|
*/
|
|
19
22
|
repos: CoreRepositories;
|
|
20
23
|
/** The local-sqlite credential store (kept on the laptop, sealed with the local key). */
|
|
21
24
|
credentialStore: LocalCredentialStore;
|
|
22
|
-
/**
|
|
25
|
+
/** The durable local-sqlite execution work queue (the no-pg-boss durability substrate). */
|
|
26
|
+
workQueue: SqliteWorkQueue;
|
|
27
|
+
/** Close the underlying SQLite databases (call on shutdown). */
|
|
23
28
|
close(): void;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
@@ -33,36 +38,107 @@ export interface MothershipComposition {
|
|
|
33
38
|
* cannot authenticate a single call, so fail fast at boot rather than 403 on first read.
|
|
34
39
|
*/
|
|
35
40
|
export declare function composeMothership(env: NodeJS.ProcessEnv): MothershipComposition;
|
|
41
|
+
type ExecutionService = Parameters<typeof driveExecution>[0];
|
|
42
|
+
/** Timing + sizing knobs for the durable work runner, derived from the execution runtime config. */
|
|
43
|
+
export interface SqliteWorkRunnerOptions {
|
|
44
|
+
/** The advance/poll drive config (poll intervals + budgets). */
|
|
45
|
+
drive: DriveConfig;
|
|
46
|
+
/** Lease for an in-flight drive; an `active` row past it is treated as crash-orphaned. */
|
|
47
|
+
leaseMs: number;
|
|
48
|
+
/** Delay before re-polling a re-armed unbounded gate (≈ the gate poll interval). */
|
|
49
|
+
reArmDelayMs: number;
|
|
50
|
+
/** Backoff before retrying a drive that threw. */
|
|
51
|
+
errorBackoffMs: number;
|
|
52
|
+
/** Periodic recovery poll: reclaim queued + lease-expired rows (the crash-recovery backstop). */
|
|
53
|
+
sweepIntervalMs: number;
|
|
54
|
+
/** Max drive attempts before a poison run is evicted (parity with pg-boss `retryLimit`). */
|
|
55
|
+
maxAttempts: number;
|
|
56
|
+
/** How many runs to drive in parallel on this node (parity with pg-boss worker concurrency). */
|
|
57
|
+
concurrency: number;
|
|
58
|
+
}
|
|
36
59
|
/**
|
|
37
|
-
* The
|
|
38
|
-
* mothership-mode node has no pg-boss, so it drives runs in this process
|
|
39
|
-
*
|
|
60
|
+
* The durable SQLite-backed work runner: the no-Postgres analogue of {@link PgBossWorkRunner}. A
|
|
61
|
+
* mothership-mode node has no pg-boss, so it drives runs in this process — but unlike PR 1's
|
|
62
|
+
* best-effort in-memory runner, the intent "this run needs driving" is persisted in a local
|
|
63
|
+
* `node:sqlite` {@link SqliteWorkQueue}, so a crash or restart re-drives what was in flight. It
|
|
64
|
+
* mirrors pg-boss's `exclusive` advance queue:
|
|
40
65
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
66
|
+
* - one row per run (the queue's PRIMARY KEY) = pg-boss's `singletonKey` dedup;
|
|
67
|
+
* - a `startRun` / `signalDecision` (re)queues the run and kicks the drain loop;
|
|
68
|
+
* - the drain loop claims drivable runs up to `concurrency` and drives each via the SAME
|
|
69
|
+
* `driveExecution` advance/poll loop the Node facade uses (real timer-backed sleeps);
|
|
70
|
+
* - a signal arriving mid-drive coalesces into exactly one follow-up via the row's `rerun` flag;
|
|
71
|
+
* - a re-armed unbounded gate (human review) is deferred for `reArmDelayMs` then re-polled — the
|
|
72
|
+
* in-process analogue of the stale-run sweeper re-enqueuing it. A re-arm is a SUCCESSFUL drive,
|
|
73
|
+
* so it resets the retry budget: an unbounded gate re-arms forever without ever being mistaken
|
|
74
|
+
* for a poison pill;
|
|
75
|
+
* - `maxAttempts` bounds CONSECUTIVE drive FAILURES (not total claims): a poison run is evicted
|
|
76
|
+
* AND failed loudly, while a healthy run that re-arms / coalesces keeps its budget;
|
|
77
|
+
* - a periodic recovery poll + a boot-time orphan reset reclaim runs left `active` by a dead
|
|
78
|
+
* process, and a storage-reconciliation pass re-enqueues any run still `running` in storage that
|
|
79
|
+
* lost its queue row (the two legs of the durability pg-boss gets from Postgres, here from the
|
|
80
|
+
* SQLite file + the `agent_runs` source of truth).
|
|
46
81
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
82
|
+
* The execution service is bound after the container is built (it does not exist when the runner is
|
|
83
|
+
* constructed). The `running` set tracks which runs THIS process is driving, so the claim loop and
|
|
84
|
+
* the recovery poll never double-drive an in-flight run.
|
|
50
85
|
*/
|
|
51
|
-
export declare class
|
|
52
|
-
private readonly
|
|
86
|
+
export declare class SqliteWorkRunner implements WorkRunner {
|
|
87
|
+
private readonly queue;
|
|
88
|
+
private readonly opts;
|
|
53
89
|
private readonly log;
|
|
90
|
+
private readonly now;
|
|
54
91
|
private exec?;
|
|
55
|
-
|
|
56
|
-
private readonly
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
92
|
+
private staleRuns?;
|
|
93
|
+
private readonly running;
|
|
94
|
+
private sweepTimer?;
|
|
95
|
+
private stopped;
|
|
96
|
+
constructor(queue: SqliteWorkQueue, opts: SqliteWorkRunnerOptions, log: Logger, now?: () => number);
|
|
97
|
+
/**
|
|
98
|
+
* Bind the execution service once the container is built, recover any runs orphaned by a previous
|
|
99
|
+
* process, drive what's queued, and start the periodic recovery poll. `staleRuns` (the
|
|
100
|
+
* kind-spanning `agent_runs` reader) enables the storage-reconciliation backstop — re-driving a
|
|
101
|
+
* run that storage reports `running` but that has no queue row at all (its row was lost, or never
|
|
102
|
+
* enqueued because a prior process died). Idempotent: a second call clears the previous sweep
|
|
103
|
+
* timer before re-arming, so it never leaks an interval.
|
|
104
|
+
*/
|
|
105
|
+
bind(exec: ExecutionService, staleRuns?: AgentRunRepository): void;
|
|
106
|
+
/** Stop the recovery poll (shutdown). In-flight drives are left to finish or die with the process. */
|
|
107
|
+
stop(): void;
|
|
60
108
|
startRun(workspaceId: string, executionId: string): Promise<void>;
|
|
61
109
|
signalDecision(workspaceId: string, executionId: string): Promise<void>;
|
|
62
110
|
cancelRun(): Promise<void>;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
111
|
+
/**
|
|
112
|
+
* (Re)queue a run and kick the drain loop. If a drive is already in flight for it, flag the row
|
|
113
|
+
* for a coalesced re-drive (the finishing driver re-queues it); otherwise force it claimable now
|
|
114
|
+
* (covers a fresh run, an idle run, and waking a deferred gate re-poll early). The `running` set
|
|
115
|
+
* read is race-free: a drive only reaches `settle` synchronously between awaits, with the run
|
|
116
|
+
* still in `running`, so an in-flight run is never misclassified as idle.
|
|
117
|
+
*/
|
|
118
|
+
private wake;
|
|
119
|
+
/** Claim and launch drives up to the concurrency cap. Synchronous; each drive re-drains on finish. */
|
|
120
|
+
private drain;
|
|
121
|
+
private driveClaimed;
|
|
122
|
+
/** Re-run the drain loop after `delayMs` (a deferred gate re-poll / error backoff). Unref'd. */
|
|
123
|
+
private scheduleKick;
|
|
124
|
+
/**
|
|
125
|
+
* Fail an evicted run loudly. A run is evicted only after `maxAttempts` CONSECUTIVE drive errors —
|
|
126
|
+
* which (because `driveExecution` funnels every recoverable error into `failRun` itself) means
|
|
127
|
+
* the persistence path kept throwing, e.g. the mothership was unreachable. Mark it `evicted` so
|
|
128
|
+
* it leaves the `running` limbo it would otherwise sit in forever; best-effort, since the same
|
|
129
|
+
* broken persistence may make this `failRun` throw too (logged, not rethrown).
|
|
130
|
+
*/
|
|
131
|
+
private failEvicted;
|
|
132
|
+
/**
|
|
133
|
+
* The second leg of pg-boss-style durability (the stale-run sweeper): re-enqueue any run that
|
|
134
|
+
* storage still reports `running` but that has NO queue row — its row was lost, or the enqueue
|
|
135
|
+
* never happened because a prior process died between the storage write and the enqueue. The
|
|
136
|
+
* queue-local recovery (orphan reset + lease reclaim) only covers rows that EXIST; this reconciles
|
|
137
|
+
* the queue against the source of truth. `enqueueIfAbsent` makes it safe: a run already deferred /
|
|
138
|
+
* driving keeps its row untouched. Best-effort — the remote `agentRunRepository` may not yet
|
|
139
|
+
* allow-list `listStale` (mothership gating phase), so a throw is swallowed.
|
|
140
|
+
*/
|
|
141
|
+
private reconcileStorage;
|
|
67
142
|
}
|
|
143
|
+
export {};
|
|
68
144
|
//# sourceMappingURL=mothership.d.ts.map
|
package/dist/mothership.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mothership.d.ts","sourceRoot":"","sources":["../src/mothership.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAClG,OAAO,EAEL,KAAK,MAAM,EAEZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"mothership.d.ts","sourceRoot":"","sources":["../src/mothership.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAClG,OAAO,EAEL,KAAK,MAAM,EAEZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,KAAK,oBAAoB,EAA8B,MAAM,6BAA6B,CAAA;AACnG,OAAO,E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AC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,UAAU,CAAC,CAAgC;IACnD,OAAO,CAAC,OAAO,CAAQ;IAEvB,YACmB,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,uBAAuB,EAC7B,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,MAAiB,EAC3C;IAEJ;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAyBjE;IAED,sGAAsG;IACtG,IAAI,IAAI,IAAI,CAIX;IAEK,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;IAEK,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5E;IAEK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAG/B;IAED;;;;;;OAMG;IACH,OAAO,CAAC,IAAI;IASZ,sGAAsG;IACtG,OAAO,CAAC,KAAK;YAmBC,YAAY;IAyC1B,gGAAgG;IAChG,OAAO,CAAC,YAAY;IAKpB;;;;;;OAMG;YACW,WAAW;IAyBzB;;;;;;;;OAQG;YACW,gBAAgB;CAuB/B"}
|
package/dist/mothership.js
CHANGED
|
@@ -4,6 +4,7 @@ import { mkdirSync } from 'node:fs';
|
|
|
4
4
|
import { driveExecution } from '@cat-factory/node-server';
|
|
5
5
|
import { HttpPersistenceRpcClient, createRemoteRepositoryRegistry, } from '@cat-factory/server';
|
|
6
6
|
import { createLocalCredentialStore } from './sqlite/credentialStore.js';
|
|
7
|
+
import { SqliteWorkQueue, createWorkQueue } from './sqlite/workQueue.js';
|
|
7
8
|
// Mothership mode (docs/initiatives/mothership-mode.md): the local node keeps NO main
|
|
8
9
|
// database. Org/durable state lives on a hosted "mothership" cat-factory (Node or Cloudflare)
|
|
9
10
|
// and is reached over the authenticated `/internal/persistence` machine API; agent/model
|
|
@@ -17,14 +18,24 @@ export function isMothershipMode(env) {
|
|
|
17
18
|
}
|
|
18
19
|
/** Resolve the on-disk path for the local credential SQLite store (`:memory:` honoured for tests). */
|
|
19
20
|
function credentialDbPath(env) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return localDbPath(env.LOCAL_MOTHERSHIP_CREDENTIAL_DB, 'credentials.sqlite');
|
|
22
|
+
}
|
|
23
|
+
/** Resolve the on-disk path for the durable execution work queue (`:memory:` honoured for tests). */
|
|
24
|
+
function workQueueDbPath(env) {
|
|
25
|
+
return localDbPath(env.LOCAL_MOTHERSHIP_WORK_DB, 'work-queue.sqlite');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a local SQLite file path: an explicit override wins (incl. `:memory:` for tests), else a
|
|
29
|
+
* stable per-user file under `~/.cat-factory` so the store survives restarts (the whole point of a
|
|
30
|
+
* durable local store). Ensures the directory exists.
|
|
31
|
+
*/
|
|
32
|
+
function localDbPath(explicit, fileName) {
|
|
33
|
+
const override = explicit?.trim();
|
|
34
|
+
if (override)
|
|
35
|
+
return override;
|
|
25
36
|
const dir = join(homedir(), '.cat-factory');
|
|
26
37
|
mkdirSync(dir, { recursive: true });
|
|
27
|
-
return join(dir,
|
|
38
|
+
return join(dir, fileName);
|
|
28
39
|
}
|
|
29
40
|
/**
|
|
30
41
|
* Compose the mothership persistence from env. Builds the machine-authed RPC client +
|
|
@@ -50,96 +61,242 @@ export function composeMothership(env) {
|
|
|
50
61
|
const client = new HttpPersistenceRpcClient({ baseUrl, token });
|
|
51
62
|
const repos = createRemoteRepositoryRegistry(client);
|
|
52
63
|
const credentialStore = createLocalCredentialStore(credentialDbPath(env));
|
|
53
|
-
|
|
64
|
+
const workQueue = createWorkQueue(workQueueDbPath(env));
|
|
65
|
+
return {
|
|
66
|
+
repos,
|
|
67
|
+
credentialStore,
|
|
68
|
+
workQueue,
|
|
69
|
+
close: () => {
|
|
70
|
+
credentialStore.close();
|
|
71
|
+
workQueue.close();
|
|
72
|
+
},
|
|
73
|
+
};
|
|
54
74
|
}
|
|
55
75
|
/**
|
|
56
|
-
* The
|
|
57
|
-
* mothership-mode node has no pg-boss, so it drives runs in this process
|
|
58
|
-
*
|
|
76
|
+
* The durable SQLite-backed work runner: the no-Postgres analogue of {@link PgBossWorkRunner}. A
|
|
77
|
+
* mothership-mode node has no pg-boss, so it drives runs in this process — but unlike PR 1's
|
|
78
|
+
* best-effort in-memory runner, the intent "this run needs driving" is persisted in a local
|
|
79
|
+
* `node:sqlite` {@link SqliteWorkQueue}, so a crash or restart re-drives what was in flight. It
|
|
80
|
+
* mirrors pg-boss's `exclusive` advance queue:
|
|
59
81
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
82
|
+
* - one row per run (the queue's PRIMARY KEY) = pg-boss's `singletonKey` dedup;
|
|
83
|
+
* - a `startRun` / `signalDecision` (re)queues the run and kicks the drain loop;
|
|
84
|
+
* - the drain loop claims drivable runs up to `concurrency` and drives each via the SAME
|
|
85
|
+
* `driveExecution` advance/poll loop the Node facade uses (real timer-backed sleeps);
|
|
86
|
+
* - a signal arriving mid-drive coalesces into exactly one follow-up via the row's `rerun` flag;
|
|
87
|
+
* - a re-armed unbounded gate (human review) is deferred for `reArmDelayMs` then re-polled — the
|
|
88
|
+
* in-process analogue of the stale-run sweeper re-enqueuing it. A re-arm is a SUCCESSFUL drive,
|
|
89
|
+
* so it resets the retry budget: an unbounded gate re-arms forever without ever being mistaken
|
|
90
|
+
* for a poison pill;
|
|
91
|
+
* - `maxAttempts` bounds CONSECUTIVE drive FAILURES (not total claims): a poison run is evicted
|
|
92
|
+
* AND failed loudly, while a healthy run that re-arms / coalesces keeps its budget;
|
|
93
|
+
* - a periodic recovery poll + a boot-time orphan reset reclaim runs left `active` by a dead
|
|
94
|
+
* process, and a storage-reconciliation pass re-enqueues any run still `running` in storage that
|
|
95
|
+
* lost its queue row (the two legs of the durability pg-boss gets from Postgres, here from the
|
|
96
|
+
* SQLite file + the `agent_runs` source of truth).
|
|
65
97
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
98
|
+
* The execution service is bound after the container is built (it does not exist when the runner is
|
|
99
|
+
* constructed). The `running` set tracks which runs THIS process is driving, so the claim loop and
|
|
100
|
+
* the recovery poll never double-drive an in-flight run.
|
|
69
101
|
*/
|
|
70
|
-
export class
|
|
71
|
-
|
|
102
|
+
export class SqliteWorkRunner {
|
|
103
|
+
queue;
|
|
104
|
+
opts;
|
|
72
105
|
log;
|
|
106
|
+
now;
|
|
73
107
|
exec;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
staleRuns;
|
|
109
|
+
running = new Set();
|
|
110
|
+
sweepTimer;
|
|
111
|
+
stopped = false;
|
|
112
|
+
constructor(queue, opts, log, now = Date.now) {
|
|
113
|
+
this.queue = queue;
|
|
114
|
+
this.opts = opts;
|
|
78
115
|
this.log = log;
|
|
116
|
+
this.now = now;
|
|
79
117
|
}
|
|
80
|
-
/**
|
|
81
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Bind the execution service once the container is built, recover any runs orphaned by a previous
|
|
120
|
+
* process, drive what's queued, and start the periodic recovery poll. `staleRuns` (the
|
|
121
|
+
* kind-spanning `agent_runs` reader) enables the storage-reconciliation backstop — re-driving a
|
|
122
|
+
* run that storage reports `running` but that has no queue row at all (its row was lost, or never
|
|
123
|
+
* enqueued because a prior process died). Idempotent: a second call clears the previous sweep
|
|
124
|
+
* timer before re-arming, so it never leaks an interval.
|
|
125
|
+
*/
|
|
126
|
+
bind(exec, staleRuns) {
|
|
82
127
|
this.exec = exec;
|
|
128
|
+
this.staleRuns = staleRuns;
|
|
129
|
+
// Boot recovery: any row left `active` was orphaned when a previous process died (this process
|
|
130
|
+
// drives nothing yet), so reclaim it for an immediate re-drive.
|
|
131
|
+
const orphans = this.queue.resetOrphans();
|
|
132
|
+
if (orphans > 0) {
|
|
133
|
+
this.log.warn({ orphans }, 'mothership work queue: re-driving runs orphaned by a prior process');
|
|
134
|
+
}
|
|
135
|
+
this.drain();
|
|
136
|
+
// Boot-time storage reconciliation: re-enqueue any run `running` in storage with no queue row
|
|
137
|
+
// (the second leg of pg-boss-style durability — the stale-run sweeper). Best-effort.
|
|
138
|
+
void this.reconcileStorage();
|
|
139
|
+
// Backstop for runs whose deferred re-arm / error-backoff kick was lost, or whose lease lapsed:
|
|
140
|
+
// a periodic drain reclaims every queued + lease-expired row, evicts exhausted runs, and
|
|
141
|
+
// reconciles storage orphans. Unref'd so it never holds the process open on its own.
|
|
142
|
+
if (this.sweepTimer)
|
|
143
|
+
clearInterval(this.sweepTimer);
|
|
144
|
+
this.sweepTimer = setInterval(() => {
|
|
145
|
+
this.drain();
|
|
146
|
+
void this.reconcileStorage();
|
|
147
|
+
}, this.opts.sweepIntervalMs);
|
|
148
|
+
this.sweepTimer.unref?.();
|
|
149
|
+
}
|
|
150
|
+
/** Stop the recovery poll (shutdown). In-flight drives are left to finish or die with the process. */
|
|
151
|
+
stop() {
|
|
152
|
+
this.stopped = true;
|
|
153
|
+
if (this.sweepTimer)
|
|
154
|
+
clearInterval(this.sweepTimer);
|
|
155
|
+
this.sweepTimer = undefined;
|
|
83
156
|
}
|
|
84
157
|
async startRun(workspaceId, executionId) {
|
|
85
|
-
this.
|
|
158
|
+
this.wake(workspaceId, executionId);
|
|
86
159
|
}
|
|
87
160
|
async signalDecision(workspaceId, executionId) {
|
|
88
|
-
// The decision is already persisted (to the mothership); re
|
|
89
|
-
this.
|
|
161
|
+
// The decision is already persisted (to the mothership); (re)queue so the parked run resumes.
|
|
162
|
+
this.wake(workspaceId, executionId);
|
|
90
163
|
}
|
|
91
164
|
async cancelRun() {
|
|
92
165
|
// Best-effort: the run is finalized via ExecutionService.stopRun; an in-flight drive is a
|
|
93
|
-
// no-op once the run is terminal (advanceInstance returns noop).
|
|
166
|
+
// no-op once the run is terminal (advanceInstance returns noop), and its row is settled away.
|
|
94
167
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
168
|
+
/**
|
|
169
|
+
* (Re)queue a run and kick the drain loop. If a drive is already in flight for it, flag the row
|
|
170
|
+
* for a coalesced re-drive (the finishing driver re-queues it); otherwise force it claimable now
|
|
171
|
+
* (covers a fresh run, an idle run, and waking a deferred gate re-poll early). The `running` set
|
|
172
|
+
* read is race-free: a drive only reaches `settle` synchronously between awaits, with the run
|
|
173
|
+
* still in `running`, so an in-flight run is never misclassified as idle.
|
|
174
|
+
*/
|
|
175
|
+
wake(workspaceId, executionId) {
|
|
176
|
+
if (this.running.has(executionId)) {
|
|
177
|
+
this.queue.markRerun(executionId);
|
|
100
178
|
}
|
|
101
|
-
|
|
102
|
-
|
|
179
|
+
else {
|
|
180
|
+
this.queue.enqueue(workspaceId, executionId, this.now());
|
|
181
|
+
}
|
|
182
|
+
this.drain();
|
|
103
183
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.log.error({ executionId }, 'in-process work runner driven before bind()');
|
|
184
|
+
/** Claim and launch drives up to the concurrency cap. Synchronous; each drive re-drains on finish. */
|
|
185
|
+
drain() {
|
|
186
|
+
if (!this.exec || this.stopped)
|
|
108
187
|
return;
|
|
188
|
+
// First reap poison runs (consecutive-failure budget exhausted): delete the row AND fail the
|
|
189
|
+
// run loudly, so it surfaces as a terminal failure instead of silently vanishing from the queue
|
|
190
|
+
// while storage still reports it `running`.
|
|
191
|
+
for (const evicted of this.queue.evictExhausted(this.now(), this.opts.maxAttempts, this.running)) {
|
|
192
|
+
void this.failEvicted(evicted.workspaceId, evicted.executionId, evicted.attempts);
|
|
193
|
+
}
|
|
194
|
+
while (this.running.size < this.opts.concurrency) {
|
|
195
|
+
const job = this.queue.claim(this.now(), this.opts.leaseMs, this.running);
|
|
196
|
+
if (!job)
|
|
197
|
+
break;
|
|
198
|
+
void this.driveClaimed(job.workspaceId, job.executionId);
|
|
109
199
|
}
|
|
200
|
+
}
|
|
201
|
+
async driveClaimed(workspaceId, executionId) {
|
|
202
|
+
const exec = this.exec;
|
|
203
|
+
if (!exec)
|
|
204
|
+
return;
|
|
205
|
+
this.running.add(executionId);
|
|
110
206
|
try {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
207
|
+
const outcome = await driveExecution(exec, workspaceId, executionId, this.opts.drive, {
|
|
208
|
+
log: this.log,
|
|
209
|
+
});
|
|
210
|
+
// Shutting down: don't touch the (closing) queue; the in-memory cleanup below still runs.
|
|
211
|
+
if (this.stopped)
|
|
212
|
+
return;
|
|
213
|
+
if (outcome.rearmedGate) {
|
|
214
|
+
// A re-armed unbounded-wait gate (human review) released without finishing — a SUCCESSFUL
|
|
215
|
+
// drive, so it resets the retry budget and is never evicted as poison no matter how long
|
|
216
|
+
// the human takes. If a signal coalesced mid-drive, deferRearm re-queues it NOW (the
|
|
217
|
+
// trailing drain() picks it up); otherwise it holds the run off the queue until the gate's
|
|
218
|
+
// poll interval, then re-polls — the in-process analogue of the sweeper re-enqueuing it.
|
|
219
|
+
// The future lease doubles as crash recovery.
|
|
220
|
+
const { requeued } = this.queue.deferRearm(executionId, this.now() + this.opts.reArmDelayMs);
|
|
221
|
+
if (!requeued)
|
|
222
|
+
this.scheduleKick(this.opts.reArmDelayMs);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
// Standstill (or a coalesced signal): settle deletes the row, or re-queues it for one more
|
|
226
|
+
// drive — the trailing drain() below picks the re-queued run straight back up.
|
|
227
|
+
this.queue.settle(executionId);
|
|
129
228
|
}
|
|
130
229
|
}
|
|
131
230
|
catch (err) {
|
|
132
|
-
this.
|
|
231
|
+
if (this.stopped)
|
|
232
|
+
return;
|
|
233
|
+
this.log.error({ workspaceId, executionId, err: err instanceof Error ? err.message : String(err) }, 'mothership in-process execution driver failed');
|
|
234
|
+
// Hold the run for a backoff'd retry, bumping the consecutive-failure count; once it reaches
|
|
235
|
+
// the cap the next drain evicts it (and fails it loudly) rather than re-driving forever.
|
|
236
|
+
this.queue.deferFailure(executionId, this.now() + this.opts.errorBackoffMs);
|
|
237
|
+
this.scheduleKick(this.opts.errorBackoffMs);
|
|
133
238
|
}
|
|
134
239
|
finally {
|
|
135
|
-
this.
|
|
240
|
+
this.running.delete(executionId);
|
|
136
241
|
}
|
|
242
|
+
// Pick up a coalesced re-drive of this run plus any other queued run a freed slot now allows.
|
|
243
|
+
this.drain();
|
|
244
|
+
}
|
|
245
|
+
/** Re-run the drain loop after `delayMs` (a deferred gate re-poll / error backoff). Unref'd. */
|
|
246
|
+
scheduleKick(delayMs) {
|
|
247
|
+
const timer = setTimeout(() => this.drain(), Math.max(1, delayMs));
|
|
248
|
+
timer.unref?.();
|
|
137
249
|
}
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
250
|
+
/**
|
|
251
|
+
* Fail an evicted run loudly. A run is evicted only after `maxAttempts` CONSECUTIVE drive errors —
|
|
252
|
+
* which (because `driveExecution` funnels every recoverable error into `failRun` itself) means
|
|
253
|
+
* the persistence path kept throwing, e.g. the mothership was unreachable. Mark it `evicted` so
|
|
254
|
+
* it leaves the `running` limbo it would otherwise sit in forever; best-effort, since the same
|
|
255
|
+
* broken persistence may make this `failRun` throw too (logged, not rethrown).
|
|
256
|
+
*/
|
|
257
|
+
async failEvicted(workspaceId, executionId, attempts) {
|
|
258
|
+
this.log.error({ workspaceId, executionId, attempts }, 'mothership work queue: evicting run after repeated drive failures');
|
|
259
|
+
try {
|
|
260
|
+
await this.exec?.failRun(workspaceId, executionId, `Execution driver failed ${attempts} times in a row; giving up.`, 'evicted', null);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
this.log.error({ workspaceId, executionId, err: err instanceof Error ? err.message : String(err) }, 'mothership work queue: failed to mark an evicted run failed');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The second leg of pg-boss-style durability (the stale-run sweeper): re-enqueue any run that
|
|
268
|
+
* storage still reports `running` but that has NO queue row — its row was lost, or the enqueue
|
|
269
|
+
* never happened because a prior process died between the storage write and the enqueue. The
|
|
270
|
+
* queue-local recovery (orphan reset + lease reclaim) only covers rows that EXIST; this reconciles
|
|
271
|
+
* the queue against the source of truth. `enqueueIfAbsent` makes it safe: a run already deferred /
|
|
272
|
+
* driving keeps its row untouched. Best-effort — the remote `agentRunRepository` may not yet
|
|
273
|
+
* allow-list `listStale` (mothership gating phase), so a throw is swallowed.
|
|
274
|
+
*/
|
|
275
|
+
async reconcileStorage() {
|
|
276
|
+
if (!this.staleRuns || this.stopped)
|
|
277
|
+
return;
|
|
278
|
+
let recovered = 0;
|
|
279
|
+
try {
|
|
280
|
+
const stale = await this.staleRuns.listStale(this.now() - this.opts.leaseMs);
|
|
281
|
+
if (this.stopped)
|
|
282
|
+
return;
|
|
283
|
+
for (const ref of stale) {
|
|
284
|
+
if (ref.kind !== 'execution')
|
|
285
|
+
continue;
|
|
286
|
+
if (this.running.has(ref.id))
|
|
287
|
+
continue;
|
|
288
|
+
if (this.queue.enqueueIfAbsent(ref.workspaceId, ref.id, this.now()))
|
|
289
|
+
recovered++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
// listStale not reachable / not allow-listed yet — the backstop is best-effort.
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (recovered > 0) {
|
|
297
|
+
this.log.warn({ recovered }, 'mothership work queue: re-enqueued runs still running in storage with no queue row');
|
|
298
|
+
this.drain();
|
|
299
|
+
}
|
|
143
300
|
}
|
|
144
301
|
}
|
|
145
302
|
//# sourceMappingURL=mothership.js.map
|
package/dist/mothership.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mothership.js","sourceRoot":"","sources":["../src/mothership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAA2C,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAClG,OAAO,EACL,wBAAwB,EAExB,8BAA8B,GAC/B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAA6B,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"mothership.js","sourceRoot":"","sources":["../src/mothership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAA2C,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAClG,OAAO,EACL,wBAAwB,EAExB,8BAA8B,GAC/B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAA6B,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AACnG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAExE,sFAAsF;AACtF,8FAA8F;AAC9F,yFAAyF;AACzF,4FAA4F;AAC5F,8FAA8F;AAC9F,yFAAyF;AACzF,uFAAuF;AAEvF,iGAAiG;AACjG,MAAM,UAAU,gBAAgB,CAAC,GAAsB;IACrD,OAAO,CAAC,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,CAAA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YACxB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;gBACxB,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW;oBAAE,SAAQ;gBACtC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAAE,SAAQ;gBACtC,IAAI,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;oBAAE,SAAS,EAAE,CAAA;YAClF,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,gFAAgF;YAChF,OAAM;QACR,CAAC;QACD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,EAAE,SAAS,EAAE,EACb,oFAAoF,CACrF,CAAA;YACD,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC;IACH,CAAC;CACF"}
|
package/dist/server.js
CHANGED
|
@@ -75,8 +75,10 @@ export async function startLocal(options = {}) {
|
|
|
75
75
|
*
|
|
76
76
|
* The periodic Postgres-backed sweepers the Node `start()` runs (retention, recurring-pipeline
|
|
77
77
|
* fire, notification escalation, Kaizen) are intentionally NOT started here: they prune/scan
|
|
78
|
-
* stores that live on the mothership (its own cron owns them)
|
|
79
|
-
*
|
|
78
|
+
* stores that live on the mothership (its own cron owns them). Durable execution IS now provided
|
|
79
|
+
* locally — the container's work runner is backed by a file-based `node:sqlite` work queue (the
|
|
80
|
+
* no-pg-boss analogue), so a crash/restart re-drives in-flight runs; telemetry local-first sync
|
|
81
|
+
* remains a later initiative slice (PR 5).
|
|
80
82
|
*/
|
|
81
83
|
async function startLocalMothership(env, host) {
|
|
82
84
|
logger.info({ mothership: env.LOCAL_MOTHERSHIP_URL }, 'local mode: booting in MOTHERSHIP mode (no local Postgres; org state served remotely)');
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1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EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,SAAS,CAAC,UAAU;KAChC,EACD,wCAAwC,CACzC,CAAA;IACD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CACT,oBAAoB,gBAAgB,CAAC,SAAS,CAAC,0CAA0C;YACvF,gFAAgF;YAChF,qFAAqF;YACrF,wDAAwD,CAC3D,CAAA;IACH,CAAC;IACD,IAAI,CAAC;QACH,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IACzE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CACT,EAAE,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EACjF,8BAA8B,OAAO,CAAC,MAAM,2CAA2C;YACrF,kFAAkF;YAClF,2BAA2B,CAC9B,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
/** Open (creating if absent) the work-queue SQLite database and ensure its schema. */
|
|
3
|
+
export declare function openWorkQueueDb(path: string): DatabaseSync;
|
|
4
|
+
/**
|
|
5
|
+
* A run claimed for driving. `attempts` is the run's CONSECUTIVE-failure count at claim time (0 for
|
|
6
|
+
* a healthy run); claiming does not change it — only an errored drive (`deferFailure`) does.
|
|
7
|
+
*/
|
|
8
|
+
export interface ClaimedRun {
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
executionId: string;
|
|
11
|
+
attempts: number;
|
|
12
|
+
}
|
|
13
|
+
/** A run evicted by {@link SqliteWorkQueue.evictExhausted} (its retry budget was exhausted). */
|
|
14
|
+
export interface EvictedRun {
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
executionId: string;
|
|
17
|
+
attempts: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The durable SQLite-backed execution queue. All methods are synchronous (`node:sqlite`); the
|
|
21
|
+
* runner wraps them in the `WorkRunner` async surface. The class is pure persistence — no timers,
|
|
22
|
+
* no driving — so it can be unit-tested against an in-memory database.
|
|
23
|
+
*/
|
|
24
|
+
export declare class SqliteWorkQueue {
|
|
25
|
+
private readonly db;
|
|
26
|
+
constructor(db: DatabaseSync);
|
|
27
|
+
/**
|
|
28
|
+
* (Re)queue a run so it is claimable now. New → a `queued` row; on conflict the row is forced
|
|
29
|
+
* back to `queued` with its lease cleared (so an idle, or a deferred gate-repoll, row becomes
|
|
30
|
+
* immediately drivable). `attempts` is preserved so a run's retry budget survives a re-trigger.
|
|
31
|
+
*
|
|
32
|
+
* The caller (`SqliteWorkRunner`) only calls this for a run it knows is NOT being driven in this
|
|
33
|
+
* process; a signal that arrives mid-drive goes through {@link markRerun} instead, so this never
|
|
34
|
+
* disturbs a genuinely in-flight drive's row.
|
|
35
|
+
*/
|
|
36
|
+
enqueue(workspaceId: string, executionId: string, now: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* Insert a fresh `queued` row ONLY if the run has no row at all (`ON CONFLICT DO NOTHING`), and
|
|
39
|
+
* report whether a row was created. The storage-reconciliation backstop uses this: it re-enqueues
|
|
40
|
+
* a run that storage still reports `running` but that has NO queue entry (its row was lost, or the
|
|
41
|
+
* enqueue never happened because a previous process died between the storage write and the
|
|
42
|
+
* enqueue). Crucially it must NOT disturb a run that already has a row — a genuinely deferred gate
|
|
43
|
+
* re-poll / error backoff is `running` in storage too, and forcing it back to `queued` would yank
|
|
44
|
+
* it out of its wait. Returns true when a row was inserted (a real orphan was recovered).
|
|
45
|
+
*/
|
|
46
|
+
enqueueIfAbsent(workspaceId: string, executionId: string, now: number): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Flag an in-flight drive so the finishing driver re-queues the run exactly once (the coalescing
|
|
49
|
+
* the in-memory runner did with its `rerun` map). Only ever called while the run's row is
|
|
50
|
+
* `active`; returns true if it matched (it always does under that invariant — kept as a guard).
|
|
51
|
+
*/
|
|
52
|
+
markRerun(executionId: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Reset every `active` row to `queued`. Boot recovery: a freshly started process drives nothing
|
|
55
|
+
* yet, so any row left `active` was orphaned when a previous process died — reclaim it for an
|
|
56
|
+
* immediate re-drive (the durable analogue of pg-boss retrying a crashed worker's job). Returns
|
|
57
|
+
* how many runs were recovered.
|
|
58
|
+
*/
|
|
59
|
+
resetOrphans(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Claim the oldest drivable run, or null if none. Drivable = `queued`, or `active` whose lease
|
|
62
|
+
* has expired (a drive orphaned by a crash, recovered once the lease lapses). Runs in `exclude`
|
|
63
|
+
* (being driven in THIS process) are skipped. The claim marks the row `active` with a fresh lease
|
|
64
|
+
* (so it is non-claimable again the instant this returns) but does NOT touch `attempts` — the
|
|
65
|
+
* retry budget tracks consecutive FAILURES, not claims, so eviction is the separate
|
|
66
|
+
* {@link evictExhausted} pass the runner makes before claiming.
|
|
67
|
+
*/
|
|
68
|
+
claim(now: number, leaseMs: number, exclude: ReadonlySet<string>): ClaimedRun | null;
|
|
69
|
+
/**
|
|
70
|
+
* Evict every drivable run whose CONSECUTIVE-failure count has reached `maxAttempts` (a poison
|
|
71
|
+
* pill — repeated drive failures, the analogue of pg-boss dead-lettering after `retryLimit`). The
|
|
72
|
+
* row is deleted and returned so the runner can fail the run loudly (a notification / `failRun`)
|
|
73
|
+
* instead of leaving it silently stuck `running` in storage. Only considers drivable rows
|
|
74
|
+
* (`queued` or lease-expired `active`) and skips `exclude` (a run being driven right now), so it
|
|
75
|
+
* never reaps a healthy in-flight drive. Runs before the claim pass on each drain.
|
|
76
|
+
*/
|
|
77
|
+
evictExhausted(now: number, maxAttempts: number, exclude: ReadonlySet<string>): EvictedRun[];
|
|
78
|
+
/**
|
|
79
|
+
* Settle a SUCCESSFUL drive that reached a standstill: if a signal arrived mid-drive (`rerun`),
|
|
80
|
+
* re-queue the run for one more drive and report `requeued: true`; otherwise delete its row. Both
|
|
81
|
+
* are success outcomes, so `attempts` is reset to 0 — the run cleared its work, so its retry
|
|
82
|
+
* budget starts fresh.
|
|
83
|
+
*/
|
|
84
|
+
settle(executionId: string): {
|
|
85
|
+
requeued: boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Settle a re-armed unbounded gate (human review): the drive SUCCEEDED but the gate needs another
|
|
89
|
+
* poll cycle. If a signal coalesced mid-drive (`rerun`), re-queue the run immediately (drivable
|
|
90
|
+
* now, `requeued: true`) so the new decision is acted on without waiting out the gate interval;
|
|
91
|
+
* otherwise hold it `active` with a future lease until `notBefore`, then re-poll. Either way
|
|
92
|
+
* `attempts` resets to 0 — a re-arm is a healthy drive, NOT a failure, so it never counts toward
|
|
93
|
+
* the poison-pill budget (an unbounded gate re-arms indefinitely). The future lease doubles as
|
|
94
|
+
* crash recovery: if the process dies during the wait, the lease lapses and the run is reclaimed.
|
|
95
|
+
*/
|
|
96
|
+
deferRearm(executionId: string, notBefore: number): {
|
|
97
|
+
requeued: boolean;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Hold a run that ERRORED off the claim queue until `notBefore` (a backoff before retrying),
|
|
101
|
+
* bumping `attempts` so a genuinely poison run is evicted once it reaches the cap. The lease
|
|
102
|
+
* doubles as crash recovery: if the process dies during the backoff, the lease lapses and the run
|
|
103
|
+
* is reclaimed. This is the ONLY method that grows the retry budget.
|
|
104
|
+
*/
|
|
105
|
+
deferFailure(executionId: string, notBefore: number): void;
|
|
106
|
+
/** Count rows, optionally filtered by state (for tests / observability). */
|
|
107
|
+
size(state?: 'queued' | 'active'): number;
|
|
108
|
+
close(): void;
|
|
109
|
+
}
|
|
110
|
+
/** Open the work queue at `path` (a file under the developer's config dir, or `:memory:` in tests). */
|
|
111
|
+
export declare function createWorkQueue(path: string): SqliteWorkQueue;
|
|
112
|
+
//# sourceMappingURL=workQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workQueue.d.ts","sourceRoot":"","sources":["../../src/sqlite/workQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AA4C1C,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAQ1D;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,gGAAgG;AAChG,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAQD;;;;GAIG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,EAAE;IAA/B,YAA6B,EAAE,EAAE,YAAY,EAAI;IAEjD;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAYnE;IAED;;;;;;;;OAQG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAU9E;IAED;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAOtC;IAED;;;;;OAKG;IACH,YAAY,IAAI,MAAM,CAOrB;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,UAAU,GAAG,IAAI,CAwBnF;IAED;;;;;;;OAOG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,UAAU,EAAE,CAqB3F;IAED;;;;;OAKG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAgBjD;IAED;;;;;;;;OAQG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAsBxE;IAED;;;;;OAKG;IACH,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAQzD;IAED,4EAA4E;IAC5E,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAKxC;IAED,KAAK,IAAI,IAAI,CAEZ;CACF;AAED,uGAAuG;AACvG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAE7D"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
// The mothership-mode DURABLE execution work queue.
|
|
3
|
+
//
|
|
4
|
+
// A mothership-mode local node has no Postgres and therefore no pg-boss, so it cannot use the
|
|
5
|
+
// Node facade's `PgBossWorkRunner`. PR 1 shipped a best-effort `InProcessWorkRunner` whose
|
|
6
|
+
// "queue" lived only in memory — a crash or restart lost every in-flight drive, and there was
|
|
7
|
+
// no stale-run recovery (the NOTE that runner carried). This module is the durable replacement
|
|
8
|
+
// (initiative PR 2): a file-based `node:sqlite` queue that persists the intent "this run needs
|
|
9
|
+
// driving", so a restart re-drives what was in flight, mirroring the durability pg-boss gives the
|
|
10
|
+
// Node facade. It belongs to the local-sqlite bucket (docs/initiatives/mothership-mode.md) — a
|
|
11
|
+
// local-facade-only differentiator with no cross-runtime symmetry obligation.
|
|
12
|
+
//
|
|
13
|
+
// `node:sqlite`'s `DatabaseSync` is synchronous and single-process, so every method here runs to
|
|
14
|
+
// completion with no other JavaScript interleaving — a select-then-update is inherently atomic,
|
|
15
|
+
// which is exactly the property pg-boss buys with row locks. The semantics mirror pg-boss's
|
|
16
|
+
// `exclusive` advance queue:
|
|
17
|
+
// - `execution_id` is the PRIMARY KEY, so there is at most one row per run — the equivalent of
|
|
18
|
+
// pg-boss's `singletonKey` dedup (a re-enqueue for a run already queued is a no-op).
|
|
19
|
+
// - a row is `queued` (needs a drive, free to claim) or `active` (being driven; `lease_until`
|
|
20
|
+
// is the crash-detection deadline). `rerun` records that a signal arrived mid-drive so the
|
|
21
|
+
// finishing driver re-queues exactly once (coalescing), like the in-memory runner did.
|
|
22
|
+
// - `attempts` counts CONSECUTIVE FAILED drives (the retry budget) — NOT the number of times a
|
|
23
|
+
// run was driven. A successful drive (a standstill, a coalesced re-queue, or an unbounded-gate
|
|
24
|
+
// re-arm) resets it to 0; only an errored drive bumps it (`deferFailure`). So a run that
|
|
25
|
+
// re-arms or coalesces signals forever is never mistaken for a poison pill — eviction
|
|
26
|
+
// (`evictExhausted`) fires ONLY on genuinely repeated failures, the analogue of pg-boss
|
|
27
|
+
// dead-lettering a job after `retryLimit` consecutive failures (a re-armed gate, which pg-boss
|
|
28
|
+
// completes successfully and re-enqueues fresh, likewise keeps its budget intact here).
|
|
29
|
+
const SCHEMA = `
|
|
30
|
+
CREATE TABLE IF NOT EXISTS execution_work_queue (
|
|
31
|
+
execution_id TEXT PRIMARY KEY,
|
|
32
|
+
workspace_id TEXT NOT NULL,
|
|
33
|
+
state TEXT NOT NULL,
|
|
34
|
+
rerun INTEGER NOT NULL DEFAULT 0,
|
|
35
|
+
lease_until INTEGER NOT NULL DEFAULT 0,
|
|
36
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
37
|
+
enqueued_at INTEGER NOT NULL
|
|
38
|
+
);
|
|
39
|
+
CREATE INDEX IF NOT EXISTS execution_work_queue_claimable
|
|
40
|
+
ON execution_work_queue (state, lease_until, enqueued_at);
|
|
41
|
+
`;
|
|
42
|
+
/** Open (creating if absent) the work-queue SQLite database and ensure its schema. */
|
|
43
|
+
export function openWorkQueueDb(path) {
|
|
44
|
+
const db = new DatabaseSync(path);
|
|
45
|
+
// Mirror the credential store's pragmas: WAL keeps the single writer from blocking readers,
|
|
46
|
+
// and the busy timeout absorbs a brief lock instead of throwing SQLITE_BUSY.
|
|
47
|
+
db.exec('PRAGMA journal_mode = WAL');
|
|
48
|
+
db.exec('PRAGMA busy_timeout = 5000');
|
|
49
|
+
db.exec(SCHEMA);
|
|
50
|
+
return db;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The durable SQLite-backed execution queue. All methods are synchronous (`node:sqlite`); the
|
|
54
|
+
* runner wraps them in the `WorkRunner` async surface. The class is pure persistence — no timers,
|
|
55
|
+
* no driving — so it can be unit-tested against an in-memory database.
|
|
56
|
+
*/
|
|
57
|
+
export class SqliteWorkQueue {
|
|
58
|
+
db;
|
|
59
|
+
constructor(db) {
|
|
60
|
+
this.db = db;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* (Re)queue a run so it is claimable now. New → a `queued` row; on conflict the row is forced
|
|
64
|
+
* back to `queued` with its lease cleared (so an idle, or a deferred gate-repoll, row becomes
|
|
65
|
+
* immediately drivable). `attempts` is preserved so a run's retry budget survives a re-trigger.
|
|
66
|
+
*
|
|
67
|
+
* The caller (`SqliteWorkRunner`) only calls this for a run it knows is NOT being driven in this
|
|
68
|
+
* process; a signal that arrives mid-drive goes through {@link markRerun} instead, so this never
|
|
69
|
+
* disturbs a genuinely in-flight drive's row.
|
|
70
|
+
*/
|
|
71
|
+
enqueue(workspaceId, executionId, now) {
|
|
72
|
+
this.db
|
|
73
|
+
.prepare(`INSERT INTO execution_work_queue
|
|
74
|
+
(execution_id, workspace_id, state, rerun, lease_until, attempts, enqueued_at)
|
|
75
|
+
VALUES (?, ?, 'queued', 0, 0, 0, ?)
|
|
76
|
+
ON CONFLICT(execution_id) DO UPDATE SET
|
|
77
|
+
state = 'queued',
|
|
78
|
+
rerun = 0,
|
|
79
|
+
lease_until = 0`)
|
|
80
|
+
.run(executionId, workspaceId, now);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Insert a fresh `queued` row ONLY if the run has no row at all (`ON CONFLICT DO NOTHING`), and
|
|
84
|
+
* report whether a row was created. The storage-reconciliation backstop uses this: it re-enqueues
|
|
85
|
+
* a run that storage still reports `running` but that has NO queue entry (its row was lost, or the
|
|
86
|
+
* enqueue never happened because a previous process died between the storage write and the
|
|
87
|
+
* enqueue). Crucially it must NOT disturb a run that already has a row — a genuinely deferred gate
|
|
88
|
+
* re-poll / error backoff is `running` in storage too, and forcing it back to `queued` would yank
|
|
89
|
+
* it out of its wait. Returns true when a row was inserted (a real orphan was recovered).
|
|
90
|
+
*/
|
|
91
|
+
enqueueIfAbsent(workspaceId, executionId, now) {
|
|
92
|
+
const res = this.db
|
|
93
|
+
.prepare(`INSERT INTO execution_work_queue
|
|
94
|
+
(execution_id, workspace_id, state, rerun, lease_until, attempts, enqueued_at)
|
|
95
|
+
VALUES (?, ?, 'queued', 0, 0, 0, ?)
|
|
96
|
+
ON CONFLICT(execution_id) DO NOTHING`)
|
|
97
|
+
.run(executionId, workspaceId, now);
|
|
98
|
+
return Number(res.changes) > 0;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Flag an in-flight drive so the finishing driver re-queues the run exactly once (the coalescing
|
|
102
|
+
* the in-memory runner did with its `rerun` map). Only ever called while the run's row is
|
|
103
|
+
* `active`; returns true if it matched (it always does under that invariant — kept as a guard).
|
|
104
|
+
*/
|
|
105
|
+
markRerun(executionId) {
|
|
106
|
+
const res = this.db
|
|
107
|
+
.prepare(`UPDATE execution_work_queue SET rerun = 1 WHERE execution_id = ? AND state = 'active'`)
|
|
108
|
+
.run(executionId);
|
|
109
|
+
return Number(res.changes) > 0;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Reset every `active` row to `queued`. Boot recovery: a freshly started process drives nothing
|
|
113
|
+
* yet, so any row left `active` was orphaned when a previous process died — reclaim it for an
|
|
114
|
+
* immediate re-drive (the durable analogue of pg-boss retrying a crashed worker's job). Returns
|
|
115
|
+
* how many runs were recovered.
|
|
116
|
+
*/
|
|
117
|
+
resetOrphans() {
|
|
118
|
+
const res = this.db
|
|
119
|
+
.prepare(`UPDATE execution_work_queue SET state = 'queued', lease_until = 0 WHERE state = 'active'`)
|
|
120
|
+
.run();
|
|
121
|
+
return Number(res.changes);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Claim the oldest drivable run, or null if none. Drivable = `queued`, or `active` whose lease
|
|
125
|
+
* has expired (a drive orphaned by a crash, recovered once the lease lapses). Runs in `exclude`
|
|
126
|
+
* (being driven in THIS process) are skipped. The claim marks the row `active` with a fresh lease
|
|
127
|
+
* (so it is non-claimable again the instant this returns) but does NOT touch `attempts` — the
|
|
128
|
+
* retry budget tracks consecutive FAILURES, not claims, so eviction is the separate
|
|
129
|
+
* {@link evictExhausted} pass the runner makes before claiming.
|
|
130
|
+
*/
|
|
131
|
+
claim(now, leaseMs, exclude) {
|
|
132
|
+
const rows = this.db
|
|
133
|
+
.prepare(`SELECT execution_id, workspace_id, attempts FROM execution_work_queue
|
|
134
|
+
WHERE state = 'queued' OR (state = 'active' AND lease_until <= ?)
|
|
135
|
+
ORDER BY enqueued_at ASC`)
|
|
136
|
+
.all(now);
|
|
137
|
+
for (const row of rows) {
|
|
138
|
+
if (exclude.has(row.execution_id))
|
|
139
|
+
continue;
|
|
140
|
+
this.db
|
|
141
|
+
.prepare(`UPDATE execution_work_queue
|
|
142
|
+
SET state = 'active', rerun = 0, lease_until = ?
|
|
143
|
+
WHERE execution_id = ?`)
|
|
144
|
+
.run(now + leaseMs, row.execution_id);
|
|
145
|
+
return {
|
|
146
|
+
workspaceId: row.workspace_id,
|
|
147
|
+
executionId: row.execution_id,
|
|
148
|
+
attempts: row.attempts,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Evict every drivable run whose CONSECUTIVE-failure count has reached `maxAttempts` (a poison
|
|
155
|
+
* pill — repeated drive failures, the analogue of pg-boss dead-lettering after `retryLimit`). The
|
|
156
|
+
* row is deleted and returned so the runner can fail the run loudly (a notification / `failRun`)
|
|
157
|
+
* instead of leaving it silently stuck `running` in storage. Only considers drivable rows
|
|
158
|
+
* (`queued` or lease-expired `active`) and skips `exclude` (a run being driven right now), so it
|
|
159
|
+
* never reaps a healthy in-flight drive. Runs before the claim pass on each drain.
|
|
160
|
+
*/
|
|
161
|
+
evictExhausted(now, maxAttempts, exclude) {
|
|
162
|
+
const rows = this.db
|
|
163
|
+
.prepare(`SELECT execution_id, workspace_id, attempts FROM execution_work_queue
|
|
164
|
+
WHERE (state = 'queued' OR (state = 'active' AND lease_until <= ?)) AND attempts >= ?
|
|
165
|
+
ORDER BY enqueued_at ASC`)
|
|
166
|
+
.all(now, maxAttempts);
|
|
167
|
+
const evicted = [];
|
|
168
|
+
for (const row of rows) {
|
|
169
|
+
if (exclude.has(row.execution_id))
|
|
170
|
+
continue;
|
|
171
|
+
this.db
|
|
172
|
+
.prepare('DELETE FROM execution_work_queue WHERE execution_id = ?')
|
|
173
|
+
.run(row.execution_id);
|
|
174
|
+
evicted.push({
|
|
175
|
+
workspaceId: row.workspace_id,
|
|
176
|
+
executionId: row.execution_id,
|
|
177
|
+
attempts: row.attempts,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return evicted;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Settle a SUCCESSFUL drive that reached a standstill: if a signal arrived mid-drive (`rerun`),
|
|
184
|
+
* re-queue the run for one more drive and report `requeued: true`; otherwise delete its row. Both
|
|
185
|
+
* are success outcomes, so `attempts` is reset to 0 — the run cleared its work, so its retry
|
|
186
|
+
* budget starts fresh.
|
|
187
|
+
*/
|
|
188
|
+
settle(executionId) {
|
|
189
|
+
const row = this.db
|
|
190
|
+
.prepare('SELECT rerun FROM execution_work_queue WHERE execution_id = ?')
|
|
191
|
+
.get(executionId);
|
|
192
|
+
if (row && row.rerun) {
|
|
193
|
+
this.db
|
|
194
|
+
.prepare(`UPDATE execution_work_queue
|
|
195
|
+
SET state = 'queued', rerun = 0, lease_until = 0, attempts = 0
|
|
196
|
+
WHERE execution_id = ?`)
|
|
197
|
+
.run(executionId);
|
|
198
|
+
return { requeued: true };
|
|
199
|
+
}
|
|
200
|
+
this.db.prepare('DELETE FROM execution_work_queue WHERE execution_id = ?').run(executionId);
|
|
201
|
+
return { requeued: false };
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Settle a re-armed unbounded gate (human review): the drive SUCCEEDED but the gate needs another
|
|
205
|
+
* poll cycle. If a signal coalesced mid-drive (`rerun`), re-queue the run immediately (drivable
|
|
206
|
+
* now, `requeued: true`) so the new decision is acted on without waiting out the gate interval;
|
|
207
|
+
* otherwise hold it `active` with a future lease until `notBefore`, then re-poll. Either way
|
|
208
|
+
* `attempts` resets to 0 — a re-arm is a healthy drive, NOT a failure, so it never counts toward
|
|
209
|
+
* the poison-pill budget (an unbounded gate re-arms indefinitely). The future lease doubles as
|
|
210
|
+
* crash recovery: if the process dies during the wait, the lease lapses and the run is reclaimed.
|
|
211
|
+
*/
|
|
212
|
+
deferRearm(executionId, notBefore) {
|
|
213
|
+
const row = this.db
|
|
214
|
+
.prepare('SELECT rerun FROM execution_work_queue WHERE execution_id = ?')
|
|
215
|
+
.get(executionId);
|
|
216
|
+
if (row && row.rerun) {
|
|
217
|
+
this.db
|
|
218
|
+
.prepare(`UPDATE execution_work_queue
|
|
219
|
+
SET state = 'queued', rerun = 0, lease_until = 0, attempts = 0
|
|
220
|
+
WHERE execution_id = ?`)
|
|
221
|
+
.run(executionId);
|
|
222
|
+
return { requeued: true };
|
|
223
|
+
}
|
|
224
|
+
this.db
|
|
225
|
+
.prepare(`UPDATE execution_work_queue
|
|
226
|
+
SET state = 'active', rerun = 0, lease_until = ?, attempts = 0
|
|
227
|
+
WHERE execution_id = ?`)
|
|
228
|
+
.run(notBefore, executionId);
|
|
229
|
+
return { requeued: false };
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Hold a run that ERRORED off the claim queue until `notBefore` (a backoff before retrying),
|
|
233
|
+
* bumping `attempts` so a genuinely poison run is evicted once it reaches the cap. The lease
|
|
234
|
+
* doubles as crash recovery: if the process dies during the backoff, the lease lapses and the run
|
|
235
|
+
* is reclaimed. This is the ONLY method that grows the retry budget.
|
|
236
|
+
*/
|
|
237
|
+
deferFailure(executionId, notBefore) {
|
|
238
|
+
this.db
|
|
239
|
+
.prepare(`UPDATE execution_work_queue
|
|
240
|
+
SET state = 'active', rerun = 0, lease_until = ?, attempts = attempts + 1
|
|
241
|
+
WHERE execution_id = ?`)
|
|
242
|
+
.run(notBefore, executionId);
|
|
243
|
+
}
|
|
244
|
+
/** Count rows, optionally filtered by state (for tests / observability). */
|
|
245
|
+
size(state) {
|
|
246
|
+
const row = state
|
|
247
|
+
? this.db.prepare('SELECT COUNT(*) AS n FROM execution_work_queue WHERE state = ?').get(state)
|
|
248
|
+
: this.db.prepare('SELECT COUNT(*) AS n FROM execution_work_queue').get();
|
|
249
|
+
return Number(row.n);
|
|
250
|
+
}
|
|
251
|
+
close() {
|
|
252
|
+
this.db.close();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** Open the work queue at `path` (a file under the developer's config dir, or `:memory:` in tests). */
|
|
256
|
+
export function createWorkQueue(path) {
|
|
257
|
+
return new SqliteWorkQueue(openWorkQueueDb(path));
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=workQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workQueue.js","sourceRoot":"","sources":["../../src/sqlite/workQueue.ts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1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cat-factory/local-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Local-mode runtime facade for the Agent Architecture Board: the @cat-factory/node-server stack with agent jobs run as local Docker/Podman containers and GitHub accessed via a personal access token — a developer can run the whole product on their own machine.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@hono/node-server": "^2.0.6",
|
|
28
28
|
"drizzle-orm": "1.0.0-rc.4",
|
|
29
|
-
"@cat-factory/agents": "0.24.
|
|
30
|
-
"@cat-factory/contracts": "0.70.
|
|
31
|
-
"@cat-factory/gitlab": "0.4.
|
|
32
|
-
"@cat-factory/integrations": "0.48.
|
|
33
|
-
"@cat-factory/kernel": "0.63.
|
|
34
|
-
"@cat-factory/node-server": "0.53.
|
|
35
|
-
"@cat-factory/orchestration": "0.51.
|
|
36
|
-
"@cat-factory/server": "0.59.
|
|
29
|
+
"@cat-factory/agents": "0.24.10",
|
|
30
|
+
"@cat-factory/contracts": "0.70.1",
|
|
31
|
+
"@cat-factory/gitlab": "0.4.21",
|
|
32
|
+
"@cat-factory/integrations": "0.48.2",
|
|
33
|
+
"@cat-factory/kernel": "0.63.2",
|
|
34
|
+
"@cat-factory/node-server": "0.53.3",
|
|
35
|
+
"@cat-factory/orchestration": "0.51.3",
|
|
36
|
+
"@cat-factory/server": "0.59.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26.0.1",
|
|
40
40
|
"typescript": "7.0.1-rc",
|
|
41
41
|
"vitest": "^4.1.9",
|
|
42
|
-
"@cat-factory/conformance": "0.9.
|
|
43
|
-
"@cat-factory/gates": "0.2.
|
|
42
|
+
"@cat-factory/conformance": "0.9.63",
|
|
43
|
+
"@cat-factory/gates": "0.2.51"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsc -b tsconfig.build.json",
|