@revisium/orchestrator 0.1.0 → 0.2.0-alpha.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/README.md +78 -0
- package/control-plane/bootstrap.config.json +43 -1
- package/control-plane/default-playbook/catalog/pipelines.json +941 -3
- package/control-plane/default-playbook/catalog/roles.json +54 -0
- package/dist/api/graphql-api/graphql-ws/pubsub.module.js +0 -1
- package/dist/api/graphql-api/graphql-ws/pubsub.module.js.map +1 -1
- package/dist/api/graphql-api/graphql-ws/run-progress-subscription-poller.service.js +0 -1
- package/dist/api/graphql-api/graphql-ws/run-progress-subscription-poller.service.js.map +1 -1
- package/dist/api/graphql-api/graphql-ws/subscription-bridge.service.js +0 -1
- package/dist/api/graphql-api/graphql-ws/subscription-bridge.service.js.map +1 -1
- package/dist/api/graphql-api/pr/model/pr-readiness.model.js +0 -4
- package/dist/api/graphql-api/pr/model/pr-readiness.model.js.map +1 -1
- package/dist/cli/commands/doctor-report.js +0 -18
- package/dist/cli/commands/doctor-report.js.map +1 -1
- package/dist/cli/commands/lifecycle.js +3 -71
- package/dist/cli/commands/lifecycle.js.map +1 -1
- package/dist/cli/commands/mcp.js +0 -14
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/process-tree.js +4 -26
- package/dist/cli/commands/process-tree.js.map +1 -1
- package/dist/cli/commands/revisium-helpers.js +0 -6
- package/dist/cli/commands/revisium-helpers.js.map +1 -1
- package/dist/cli/commands/rogue-reaper.js +0 -34
- package/dist/cli/commands/rogue-reaper.js.map +1 -1
- package/dist/cli/index.js +0 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/program.js +0 -5
- package/dist/cli/program.js.map +1 -1
- package/dist/config.js +0 -25
- package/dist/config.js.map +1 -1
- package/dist/control-plane/bootstrap.js +0 -28
- package/dist/control-plane/bootstrap.js.map +1 -1
- package/dist/control-plane/change-notifications.js +0 -1
- package/dist/control-plane/change-notifications.js.map +1 -1
- package/dist/control-plane/client-transport.js +0 -11
- package/dist/control-plane/client-transport.js.map +1 -1
- package/dist/control-plane/definitions.js +8 -17
- package/dist/control-plane/definitions.js.map +1 -1
- package/dist/control-plane/inbox.js +2 -120
- package/dist/control-plane/inbox.js.map +1 -1
- package/dist/control-plane/resolve-cwd.js +0 -61
- package/dist/control-plane/resolve-cwd.js.map +1 -1
- package/dist/control-plane/schema-migration.js +0 -9
- package/dist/control-plane/schema-migration.js.map +1 -1
- package/dist/control-plane/seed-default-playbook.js +5 -70
- package/dist/control-plane/seed-default-playbook.js.map +1 -1
- package/dist/control-plane/steps.js +0 -15
- package/dist/control-plane/steps.js.map +1 -1
- package/dist/e2e/kit/assertions.js +1 -1
- package/dist/e2e/kit/assertions.js.map +1 -1
- package/dist/engine/dbos.service.js +9 -179
- package/dist/engine/dbos.service.js.map +1 -1
- package/dist/engine/ensure-postgres.js +0 -48
- package/dist/engine/ensure-postgres.js.map +1 -1
- package/dist/host/daemon.js +2 -21
- package/dist/host/daemon.js.map +1 -1
- package/dist/host/dbos-identity.js +0 -31
- package/dist/host/dbos-identity.js.map +1 -1
- package/dist/host/ensure-host.js +1 -37
- package/dist/host/ensure-host.js.map +1 -1
- package/dist/host/ensure-revisium.js +1 -135
- package/dist/host/ensure-revisium.js.map +1 -1
- package/dist/host/host-runtime.js +0 -28
- package/dist/host/host-runtime.js.map +1 -1
- package/dist/host/host.lifecycle.js +0 -27
- package/dist/host/host.lifecycle.js.map +1 -1
- package/dist/host/queue-ownership.js +0 -42
- package/dist/host/queue-ownership.js.map +1 -1
- package/dist/host/queue-poller-census.js +1 -28
- package/dist/host/queue-poller-census.js.map +1 -1
- package/dist/http/graphql-host.module.js +0 -3
- package/dist/http/graphql-host.module.js.map +1 -1
- package/dist/mcp/mcp-capabilities.js +19 -14
- package/dist/mcp/mcp-capabilities.js.map +1 -1
- package/dist/mcp/mcp-facade.service.js +41 -23
- package/dist/mcp/mcp-facade.service.js.map +1 -1
- package/dist/mcp/mcp-http.service.js +0 -18
- package/dist/mcp/mcp-http.service.js.map +1 -1
- package/dist/mcp/mcp-tools.js +18 -40
- package/dist/mcp/mcp-tools.js.map +1 -1
- package/dist/observability/activity-signal.js +0 -4
- package/dist/observability/activity-signal.js.map +1 -1
- package/dist/observability/agent-activity-reporter.js +0 -4
- package/dist/observability/agent-activity-reporter.js.map +1 -1
- package/dist/pipeline/await-human.js +0 -40
- package/dist/pipeline/await-human.js.map +1 -1
- package/dist/pipeline/data-driven-task.workflow.js +106 -236
- package/dist/pipeline/data-driven-task.workflow.js.map +1 -1
- package/dist/pipeline/data-driven-template.js +0 -25
- package/dist/pipeline/data-driven-template.js.map +1 -1
- package/dist/pipeline/pipeline.module.js +0 -12
- package/dist/pipeline/pipeline.module.js.map +1 -1
- package/dist/pipeline/pipeline.service.js +10 -99
- package/dist/pipeline/pipeline.service.js.map +1 -1
- package/dist/pipeline-core/index.js +1 -13
- package/dist/pipeline-core/index.js.map +1 -1
- package/dist/pipeline-core/interpret.js +21 -94
- package/dist/pipeline-core/interpret.js.map +1 -1
- package/dist/pipeline-core/kit/assertions.js +0 -19
- package/dist/pipeline-core/kit/assertions.js.map +1 -1
- package/dist/pipeline-core/kit/builders.js +1 -21
- package/dist/pipeline-core/kit/builders.js.map +1 -1
- package/dist/pipeline-core/kit/drive.js +1 -31
- package/dist/pipeline-core/kit/drive.js.map +1 -1
- package/dist/pipeline-core/kit/fixtures.js +8 -82
- package/dist/pipeline-core/kit/fixtures.js.map +1 -1
- package/dist/pipeline-core/kit/index.js +0 -8
- package/dist/pipeline-core/kit/index.js.map +1 -1
- package/dist/pipeline-core/types.js +13 -52
- package/dist/pipeline-core/types.js.map +1 -1
- package/dist/pipeline-core/validate-capability.js +0 -3
- package/dist/pipeline-core/validate-capability.js.map +1 -1
- package/dist/pipeline-core/validate-conflicts.js +0 -9
- package/dist/pipeline-core/validate-conflicts.js.map +1 -1
- package/dist/pipeline-core/validate-dataflow.js +0 -17
- package/dist/pipeline-core/validate-dataflow.js.map +1 -1
- package/dist/pipeline-core/validate-diff.js +3 -36
- package/dist/pipeline-core/validate-diff.js.map +1 -1
- package/dist/pipeline-core/validate-edges.js +0 -6
- package/dist/pipeline-core/validate-edges.js.map +1 -1
- package/dist/pipeline-core/validate-graph.js +0 -11
- package/dist/pipeline-core/validate-graph.js.map +1 -1
- package/dist/pipeline-core/validate-loops.js +37 -44
- package/dist/pipeline-core/validate-loops.js.map +1 -1
- package/dist/pipeline-core/validate-parallel.js +9 -15
- package/dist/pipeline-core/validate-parallel.js.map +1 -1
- package/dist/pipeline-core/validate-sink.js +0 -7
- package/dist/pipeline-core/validate-sink.js.map +1 -1
- package/dist/pipeline-core/validate-topology.js +1 -20
- package/dist/pipeline-core/validate-topology.js.map +1 -1
- package/dist/pipeline-core/validate-verdict.js +52 -7
- package/dist/pipeline-core/validate-verdict.js.map +1 -1
- package/dist/pipeline-core/validate.js +5 -29
- package/dist/pipeline-core/validate.js.map +1 -1
- package/dist/playbook/catalog-loader.js +8 -3
- package/dist/playbook/catalog-loader.js.map +1 -1
- package/dist/playbook/import-mapper.js +1 -9
- package/dist/playbook/import-mapper.js.map +1 -1
- package/dist/poller/pr-readiness-core.js +0 -74
- package/dist/poller/pr-readiness-core.js.map +1 -1
- package/dist/revisium/inbox.service.js +0 -24
- package/dist/revisium/inbox.service.js.map +1 -1
- package/dist/revisium/playbooks.service.js +2 -4
- package/dist/revisium/playbooks.service.js.map +1 -1
- package/dist/revisium/revisium.module.js +0 -12
- package/dist/revisium/revisium.module.js.map +1 -1
- package/dist/revisium/roles.service.js +0 -6
- package/dist/revisium/roles.service.js.map +1 -1
- package/dist/revisium/run.service.js +1 -75
- package/dist/revisium/run.service.js.map +1 -1
- package/dist/revisium/tokens.js +0 -4
- package/dist/revisium/tokens.js.map +1 -1
- package/dist/run/append-event.js +0 -34
- package/dist/run/append-event.js.map +1 -1
- package/dist/run/block-run.js.map +1 -1
- package/dist/run/cancel-run.js +0 -33
- package/dist/run/cancel-run.js.map +1 -1
- package/dist/run/complete-run.js.map +1 -1
- package/dist/run/create-run.js +0 -7
- package/dist/run/create-run.js.map +1 -1
- package/dist/run/fail-run.js +0 -3
- package/dist/run/fail-run.js.map +1 -1
- package/dist/run/inspect-run.js +0 -26
- package/dist/run/inspect-run.js.map +1 -1
- package/dist/run/run-outputs.js +0 -19
- package/dist/run/run-outputs.js.map +1 -1
- package/dist/run/terminal-run-status.js +0 -12
- package/dist/run/terminal-run-status.js.map +1 -1
- package/dist/runners/claude-code.service.js +0 -11
- package/dist/runners/claude-code.service.js.map +1 -1
- package/dist/runners/codex.service.js +0 -9
- package/dist/runners/codex.service.js.map +1 -1
- package/dist/runners/gh-identity.js +0 -52
- package/dist/runners/gh-identity.js.map +1 -1
- package/dist/runners/integrator-branch-naming.js +3 -11
- package/dist/runners/integrator-branch-naming.js.map +1 -1
- package/dist/runners/integrator-git.js +0 -25
- package/dist/runners/integrator-git.js.map +1 -1
- package/dist/runners/integrator-remote.js +0 -2
- package/dist/runners/integrator-remote.js.map +1 -1
- package/dist/runners/integrator-types.js +0 -7
- package/dist/runners/integrator-types.js.map +1 -1
- package/dist/runners/integrator.js +3 -167
- package/dist/runners/integrator.js.map +1 -1
- package/dist/runners/runner.module.js +0 -6
- package/dist/runners/runner.module.js.map +1 -1
- package/dist/runners/tokens.js +0 -4
- package/dist/runners/tokens.js.map +1 -1
- package/dist/runners/worktree.service.js +1 -17
- package/dist/runners/worktree.service.js.map +1 -1
- package/dist/task-control-plane/run-watch.service.js +49 -173
- package/dist/task-control-plane/run-watch.service.js.map +1 -1
- package/dist/task-control-plane/task-control-plane-api.service.js +15 -17
- package/dist/task-control-plane/task-control-plane-api.service.js.map +1 -1
- package/dist/worker/build-context.js +0 -16
- package/dist/worker/build-context.js.map +1 -1
- package/dist/worker/claude-code-runner.js +9 -42
- package/dist/worker/claude-code-runner.js.map +1 -1
- package/dist/worker/codex-runner.js +88 -22
- package/dist/worker/codex-runner.js.map +1 -1
- package/dist/worker/git-worktree-manager.js +20 -67
- package/dist/worker/git-worktree-manager.js.map +1 -1
- package/dist/worker/process-executor.js +0 -12
- package/dist/worker/process-executor.js.map +1 -1
- package/dist/worker/result-envelope.js +33 -49
- package/dist/worker/result-envelope.js.map +1 -1
- package/dist/worker/runner-dispatch.js +0 -3
- package/dist/worker/runner-dispatch.js.map +1 -1
- package/dist/worker/runner.js.map +1 -1
- package/dist/worker/stub-runner.js +0 -7
- package/dist/worker/stub-runner.js.map +1 -1
- package/package.json +2 -2
|
@@ -36,7 +36,7 @@ export async function assertEventsPresent(api, runId, types) {
|
|
|
36
36
|
}
|
|
37
37
|
// Deterministic fallback for terminal events: under load the run-row status can become visible before
|
|
38
38
|
// the event query sees the terminal event. The run STATUS is the authoritative signal observed by
|
|
39
|
-
//
|
|
39
|
+
// terminal waiters, so accept matching terminal statuses after the event poll.
|
|
40
40
|
let terminalStatus = '';
|
|
41
41
|
const terminalFallbacks = new Map([
|
|
42
42
|
['run_completed', 'completed'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/e2e/kit/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAI7E,8DAA8D;AAC9D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAQ,EAAE,KAAa;IAC3D,oGAAoG;IACpG,qGAAqG;IACrG,qFAAqF;IACrF,IAAI,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,WAAW,EAAE,MAAM,IAAI,GAAG,EAAE,CAAC;QACxF,MAAM,IAAI,OAAO,CA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EAAE,8BAA8B,MAAM,EAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,EAAE,CACP,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAC/E,gDAAgD,CACjD,CAAC;IACF,MAAM,CAAC,EAAE,CACP,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAC7E,4DAA4D,CAC7D,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DbosService — the engine layer owns all @dbos-inc/dbos-sdk imports.
|
|
3
|
-
*
|
|
4
|
-
* This file (`dbos.service.ts`) is the primary importer; `engine/types.ts` re-exports
|
|
5
|
-
* type-only symbols (`WorkflowHandle`) so pipeline callers can annotate return types
|
|
6
|
-
* without importing from @dbos-inc directly. `src/pipeline/*` must import ZERO @dbos-inc.
|
|
7
|
-
*
|
|
8
|
-
* Owns DBOS lifecycle (setConfig / launch / shutdown) and thin verbs
|
|
9
|
-
* (startPingWorkflow / getWorkflowStatus / waitForWorkflow).
|
|
10
|
-
*
|
|
11
|
-
* Seam pattern: `dev:ping` is a two-step workflow registered as instance methods
|
|
12
|
-
* via DBOS.registerWorkflow / DBOS.registerStep (programmatic, decorator-free).
|
|
13
|
-
* Registration happens in the constructor, BEFORE DBOS.launch() — required by DBOS
|
|
14
|
-
* (workflows not registered before launch() are not eligible for recovery).
|
|
15
|
-
*
|
|
16
|
-
* ── Confirmed SDK symbols (Task 0, @dbos-inc/dbos-sdk@4.19.8) ──────────────
|
|
17
|
-
* DBOSConfig.systemDatabaseUrl ✓ (ТЗ expected systemDatabaseUrl — CONFIRMED)
|
|
18
|
-
* DBOS.setConfig(config) ✓
|
|
19
|
-
* DBOS.launch() ✓
|
|
20
|
-
* DBOS.shutdown() ✓
|
|
21
|
-
* DBOS.registerWorkflow(fn, cfg) ✓ returns wrapped fn with same signature
|
|
22
|
-
* DBOS.registerStep(fn, cfg) ✓ returns wrapped fn with same signature
|
|
23
|
-
* DBOS.startWorkflow(fn, params) ✓ params.workflowID ✓; returns fn(args)=>handle
|
|
24
|
-
* DBOS.getWorkflowStatus(id) ✓ returns WorkflowStatus | null
|
|
25
|
-
* DBOS.retrieveWorkflow(id) ✓ returns WorkflowHandle<T>; handle.getResult() ✓
|
|
26
|
-
* DBOS.sleep(ms) ✓
|
|
27
|
-
* ConfiguredInstance ✓ (fallback path — not used; registerWorkflow used instead)
|
|
28
|
-
*
|
|
29
|
-
* ── Recovery seam ───────────────────────────────────────────────────────────
|
|
30
|
-
* On restart, DBOS.launch() auto-recovers in-flight workflows by name+className.
|
|
31
|
-
* registerWorkflow(boundFn, { name, className }) supplies stable names so DBOS
|
|
32
|
-
* can bind back to the freshly-DI-constructed DbosService singleton.
|
|
33
|
-
* If M3 (kill-mid-step test) shows recovery fails to re-bind, switch to
|
|
34
|
-
* ConfiguredInstance (documented fallback; both paths concrete — OQ-1b).
|
|
35
|
-
*/
|
|
36
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
37
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
38
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -47,42 +12,29 @@ import { Injectable } from '@nestjs/common';
|
|
|
47
12
|
import { DBOS, WorkflowQueue } from '@dbos-inc/dbos-sdk';
|
|
48
13
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
49
14
|
import { dirname } from 'node:path';
|
|
50
|
-
|
|
51
|
-
* Far-future absolute deadline (year 2100 epoch ms). Fixed constant ⇒ deterministic on replay (G5).
|
|
52
|
-
* DBOS recv with no timeout/deadline defaults to 60 s; we pass this so human gates wait indefinitely.
|
|
53
|
-
* Never use Date.now()+X — that differs per replay and breaks DBOS replay-safety.
|
|
54
|
-
*/
|
|
55
|
-
export const GATE_DEADLINE_EPOCH_MS = 4102444800000; // 2100-01-01T00:00:00Z
|
|
56
|
-
/**
|
|
57
|
-
* Bound on how long DBOS.shutdown() may block before the host detaches anyway (0008 #3).
|
|
58
|
-
* DBOS.shutdown() drains "pending workflows" — but a workflow PARKED at a human gate
|
|
59
|
-
* (DBOS.recv) never drains, so app.close() hangs forever after `run start --wait` detaches.
|
|
60
|
-
* The durable state lives in Postgres and is recovered on the next launch(), so abandoning
|
|
61
|
-
* the in-memory drain after this bound loses no durability — it only lets the CLI exit 0.
|
|
62
|
-
*/
|
|
15
|
+
export const GATE_DEADLINE_EPOCH_MS = 4102444800000;
|
|
63
16
|
export const SHUTDOWN_DRAIN_TIMEOUT_MS = 8_000;
|
|
17
|
+
export function resolveShutdownDrainTimeoutMs(env = process.env) {
|
|
18
|
+
const value = env['REVO_SHUTDOWN_DRAIN_TIMEOUT_MS']?.trim();
|
|
19
|
+
if (!value)
|
|
20
|
+
return SHUTDOWN_DRAIN_TIMEOUT_MS;
|
|
21
|
+
const raw = Number(value);
|
|
22
|
+
return Number.isFinite(raw) && raw > 0 ? raw : SHUTDOWN_DRAIN_TIMEOUT_MS;
|
|
23
|
+
}
|
|
64
24
|
let DbosService = class DbosService {
|
|
65
25
|
static { DbosService_1 = this; }
|
|
66
26
|
static launched = false;
|
|
67
27
|
static launchPromise = null;
|
|
68
28
|
static configured = null;
|
|
69
|
-
/** Registered WorkflowQueues — guarded map to ensure idempotent registration. */
|
|
70
29
|
static queues = new Map();
|
|
71
30
|
static queueOptions = new Map();
|
|
72
31
|
static steps = new Map();
|
|
73
32
|
static workflows = new Map();
|
|
74
|
-
// Registered DBOS functions — assigned in constructor before launch().
|
|
75
33
|
pingWorkflow;
|
|
76
34
|
markStep;
|
|
77
35
|
sleepStep;
|
|
78
36
|
constructor() {
|
|
79
|
-
// Register steps first (workflows may call them; all must be registered before launch).
|
|
80
37
|
this.markStep = this.registerStep('DbosService.markStep', async function markStepImpl(workflowID, markerFile) {
|
|
81
|
-
// Idempotent marker (F12): write exactly-once per workflowID by using 'wx' (exclusive
|
|
82
|
-
// create). If the file already exists (step re-executed after a crash-before-checkpoint),
|
|
83
|
-
// writeFileSync throws with EEXIST — we catch that and skip the write, ensuring the
|
|
84
|
-
// marker count is always 1 for a given workflow id regardless of how many times the
|
|
85
|
-
// step body runs.
|
|
86
38
|
mkdirSync(dirname(markerFile), { recursive: true });
|
|
87
39
|
try {
|
|
88
40
|
writeFileSync(markerFile, `${workflowID}\t${new Date().toISOString()}\n`, { flag: 'wx' });
|
|
@@ -90,7 +42,6 @@ let DbosService = class DbosService {
|
|
|
90
42
|
catch (err) {
|
|
91
43
|
if (err.code !== 'EEXIST')
|
|
92
44
|
throw err;
|
|
93
|
-
// EEXIST: marker already written by a prior execution — skip (idempotent).
|
|
94
45
|
}
|
|
95
46
|
const content = existsSync(markerFile) ? readFileSync(markerFile, 'utf8') : '';
|
|
96
47
|
return content.split('\n').filter((l) => l.trim() !== '').length;
|
|
@@ -98,9 +49,6 @@ let DbosService = class DbosService {
|
|
|
98
49
|
this.sleepStep = this.registerStep('DbosService.sleepStep', async function sleepStepImpl(ms) {
|
|
99
50
|
await DBOS.sleep(ms);
|
|
100
51
|
});
|
|
101
|
-
// Register the workflow (uses bound steps).
|
|
102
|
-
// Capture step references via .bind(this) so DBOS sees stable registered functions,
|
|
103
|
-
// not closures that close over `this` directly (avoids S7740 "do not assign this to self").
|
|
104
52
|
const markStepBound = this.markStep.bind(this);
|
|
105
53
|
const sleepStepBound = this.sleepStep.bind(this);
|
|
106
54
|
this.pingWorkflow = this.registerWorkflow('DbosService.pingImpl', async function pingImpl(workflowID, sleepMs, markerFile) {
|
|
@@ -109,21 +57,6 @@ let DbosService = class DbosService {
|
|
|
109
57
|
return { workflowID, markerCount };
|
|
110
58
|
});
|
|
111
59
|
}
|
|
112
|
-
// ── Generic engine verbs (M1 — DBOS seal, TASK 0003) ───────────────────────
|
|
113
|
-
//
|
|
114
|
-
// `src/pipeline/*` imports NO `@dbos-inc/dbos-sdk`. These verbs expose the minimal
|
|
115
|
-
// surface needed for the pipeline module: register a step/workflow (returns the
|
|
116
|
-
// DBOS-wrapped fn with the same signature), register a queue (idempotent), and enqueue
|
|
117
|
-
// a workflow by ID + queue name.
|
|
118
|
-
//
|
|
119
|
-
// `name` format: 'ClassName.methodName' — split on the LAST dot to fill DBOS's
|
|
120
|
-
// { name, className } (matching how dev:ping uses { name:'pingImpl', className:'DbosService' }).
|
|
121
|
-
// Stable across releases — the recovery seam binds on name+className.
|
|
122
|
-
/**
|
|
123
|
-
* Register a plain async function as a DBOS step.
|
|
124
|
-
* Returns the DBOS-wrapped function with the same call signature.
|
|
125
|
-
* Call in the consumer's constructor, BEFORE DBOS.launch().
|
|
126
|
-
*/
|
|
127
60
|
registerStep(name, fn) {
|
|
128
61
|
const cached = DbosService_1.steps.get(name);
|
|
129
62
|
if (cached)
|
|
@@ -135,11 +68,6 @@ let DbosService = class DbosService {
|
|
|
135
68
|
DbosService_1.steps.set(name, registered);
|
|
136
69
|
return registered;
|
|
137
70
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Register a plain async function as a DBOS workflow.
|
|
140
|
-
* Returns the DBOS-wrapped function with the same call signature.
|
|
141
|
-
* Call in the consumer's constructor, BEFORE DBOS.launch().
|
|
142
|
-
*/
|
|
143
71
|
registerWorkflow(name, fn) {
|
|
144
72
|
const cached = DbosService_1.workflows.get(name);
|
|
145
73
|
if (cached)
|
|
@@ -151,11 +79,6 @@ let DbosService = class DbosService {
|
|
|
151
79
|
DbosService_1.workflows.set(name, registered);
|
|
152
80
|
return registered;
|
|
153
81
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Construct and register a WorkflowQueue (idempotent — Map-guarded).
|
|
156
|
-
* The ONLY place `new WorkflowQueue(...)` is called, keeping @dbos-inc inside this file.
|
|
157
|
-
* Call before DBOS.launch().
|
|
158
|
-
*/
|
|
159
82
|
registerQueue(name, opts) {
|
|
160
83
|
const existing = DbosService_1.queueOptions.get(name);
|
|
161
84
|
if (existing) {
|
|
@@ -168,40 +91,12 @@ let DbosService = class DbosService {
|
|
|
168
91
|
DbosService_1.queues.set(name, new WorkflowQueue(name, opts));
|
|
169
92
|
DbosService_1.queueOptions.set(name, { ...opts });
|
|
170
93
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Enqueue a registered workflow with a stable workflowID and queue name.
|
|
173
|
-
* Idempotent by workflowID: if a workflow with the same id already exists, DBOS returns
|
|
174
|
-
* a handle to the existing workflow and does NOT start a second run.
|
|
175
|
-
*
|
|
176
|
-
* Generic over the workflow's arg tuple A so it accepts any registered fn signature.
|
|
177
|
-
*
|
|
178
|
-
* @param fn - The DBOS-wrapped workflow function (returned by registerWorkflow).
|
|
179
|
-
* @param workflowID - Stable dedup key (e.g. the runId).
|
|
180
|
-
* @param queueName - Name of the queue to enqueue on.
|
|
181
|
-
* @param args - Arguments forwarded to the workflow (persisted as durable input).
|
|
182
|
-
*/
|
|
183
94
|
startWorkflowOn(fn, workflowID, queueName, ...args) {
|
|
184
95
|
return DBOS.startWorkflow(fn, { workflowID, queueName })(...args);
|
|
185
96
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Signal a parked workflow's awaitDecision. Wraps DBOS.send; exactly-once via idempotencyKey.
|
|
188
|
-
*
|
|
189
|
-
* CANONICAL wrapper arg order: signal(workflowId, topic, payload, idempotencyKey).
|
|
190
|
-
* The wrapper REORDERS to DBOS's raw order INSIDE:
|
|
191
|
-
* wrapper (workflowId, topic, payload) → DBOS.send(workflowId, payload, topic, idempotencyKey).
|
|
192
|
-
* Every call site MUST use the wrapper order (topic BEFORE payload); the raw DBOS swap lives
|
|
193
|
-
* ONLY here so it cannot be reintroduced at a call site (G9).
|
|
194
|
-
*/
|
|
195
97
|
signal(workflowId, topic, payload, idempotencyKey) {
|
|
196
|
-
// REORDER: wrapper (workflowId, topic, payload) → raw send(destinationID, message, topic, idempotencyKey).
|
|
197
98
|
return DBOS.send(workflowId, payload, topic, idempotencyKey);
|
|
198
99
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Durable human wait — MUST be called from inside a registered workflow body.
|
|
201
|
-
* Default DBOS recv timeout is 60 s; pass a far-future deadline so the gate waits indefinitely.
|
|
202
|
-
* The deadline is a fixed constant (GATE_DEADLINE_EPOCH_MS), never Date.now()+X — that would
|
|
203
|
-
* differ per replay and break DBOS replay-safety (G5).
|
|
204
|
-
*/
|
|
205
100
|
awaitDecision(topic, opts) {
|
|
206
101
|
return DBOS.recv(topic, { deadlineEpochMS: opts?.deadlineEpochMS ?? GATE_DEADLINE_EPOCH_MS });
|
|
207
102
|
}
|
|
@@ -214,28 +109,15 @@ let DbosService = class DbosService {
|
|
|
214
109
|
getEvent(workflowID, key, opts) {
|
|
215
110
|
return DBOS.getEvent(workflowID, key, opts);
|
|
216
111
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Write a DBOS stream record. Valid from workflow bodies and DBOS steps; unlike setEvent,
|
|
219
|
-
* this is intentionally safe for the step-side agent observability bridge.
|
|
220
|
-
*/
|
|
221
112
|
writeStream(key, value) {
|
|
222
113
|
return DBOS.writeStream(key, value);
|
|
223
114
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Close a DBOS stream. DBOS 4.19 only permits close from a workflow body, so step-side
|
|
226
|
-
* reporters must not call this after an attempt.
|
|
227
|
-
*/
|
|
228
115
|
closeStream(key) {
|
|
229
116
|
return DBOS.closeStream(key);
|
|
230
117
|
}
|
|
231
118
|
readStream(workflowID, key) {
|
|
232
119
|
return DBOS.readStream(workflowID, key);
|
|
233
120
|
}
|
|
234
|
-
// ── end generic engine verbs ────────────────────────────────────────────────
|
|
235
|
-
/**
|
|
236
|
-
* Configure DBOS with the pid-proven system database URL.
|
|
237
|
-
* Must be called before launch().
|
|
238
|
-
*/
|
|
239
121
|
setConfig(systemDatabaseUrl, options = {}) {
|
|
240
122
|
const nextConfig = { systemDatabaseUrl, logLevel: options.logLevel };
|
|
241
123
|
if (DbosService_1.configured) {
|
|
@@ -247,8 +129,6 @@ let DbosService = class DbosService {
|
|
|
247
129
|
throw new Error('Cannot reconfigure DBOS after launch.');
|
|
248
130
|
}
|
|
249
131
|
}
|
|
250
|
-
// Admin server is unused (cancel patches a Revisium row, not the DBOS admin API); disabling it
|
|
251
|
-
// frees port 3001 so multiple profiles/hosts coexist without an admin-bind collision (ADR 0006).
|
|
252
132
|
DBOS.setConfig({
|
|
253
133
|
name: 'agent-orchestrator',
|
|
254
134
|
systemDatabaseUrl,
|
|
@@ -257,10 +137,6 @@ let DbosService = class DbosService {
|
|
|
257
137
|
});
|
|
258
138
|
DbosService_1.configured = nextConfig;
|
|
259
139
|
}
|
|
260
|
-
/**
|
|
261
|
-
* Launch DBOS (idempotent — guarded by `launched` flag).
|
|
262
|
-
* Auto-recovers in-flight workflows.
|
|
263
|
-
*/
|
|
264
140
|
async launch() {
|
|
265
141
|
if (DbosService_1.launched)
|
|
266
142
|
return;
|
|
@@ -277,29 +153,15 @@ let DbosService = class DbosService {
|
|
|
277
153
|
DbosService_1.launchPromise = null;
|
|
278
154
|
}
|
|
279
155
|
}
|
|
280
|
-
|
|
281
|
-
* Shut down DBOS (no-op if never launched — E9).
|
|
282
|
-
*
|
|
283
|
-
* 0008 #3 (shutdown-hang): DBOS.shutdown() awaits in-flight workflows to drain. A workflow
|
|
284
|
-
* PARKED at a human gate (DBOS.recv) never drains, so after `run start --wait` detaches at a
|
|
285
|
-
* gate, app.close() → this → DBOS.shutdown() blocks indefinitely and the CLI never exits.
|
|
286
|
-
* We race the drain against SHUTDOWN_DRAIN_TIMEOUT_MS: on timeout we stop awaiting and let the
|
|
287
|
-
* host detach. Durability is preserved — the parked workflow's state is checkpointed in
|
|
288
|
-
* Postgres and is recovered on the next launch(); abandoning the in-memory drain loses nothing.
|
|
289
|
-
*
|
|
290
|
-
* @param timeoutMs - drain bound (default SHUTDOWN_DRAIN_TIMEOUT_MS); pass 0/Infinity to disable.
|
|
291
|
-
*/
|
|
292
|
-
async shutdown(timeoutMs = SHUTDOWN_DRAIN_TIMEOUT_MS) {
|
|
156
|
+
async shutdown(timeoutMs = resolveShutdownDrainTimeoutMs()) {
|
|
293
157
|
if (!DbosService_1.launched)
|
|
294
158
|
return;
|
|
295
|
-
// Mark not-launched up front so a timed-out drain cannot leave a re-entrant launch confused.
|
|
296
159
|
DbosService_1.launched = false;
|
|
297
160
|
const drain = DBOS.shutdown();
|
|
298
161
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
299
162
|
await drain;
|
|
300
163
|
return;
|
|
301
164
|
}
|
|
302
|
-
// Swallow a late drain rejection so a post-detach failure never crashes the exiting host.
|
|
303
165
|
void drain.catch(() => undefined);
|
|
304
166
|
let timer;
|
|
305
167
|
const drained = await Promise.race([
|
|
@@ -315,48 +177,16 @@ let DbosService = class DbosService {
|
|
|
315
177
|
'detaching — durable state is preserved and recovered on next launch.');
|
|
316
178
|
}
|
|
317
179
|
}
|
|
318
|
-
/**
|
|
319
|
-
* Start the dev:ping durable workflow.
|
|
320
|
-
*
|
|
321
|
-
* CR3: The effective workflow ID is decided in ONE place (the CLI layer — dev.ts) and
|
|
322
|
-
* must always be non-empty before calling this method. This keeps StartWorkflowParams
|
|
323
|
-
* and the workflow args consistent: both see the same stable, non-empty id, so
|
|
324
|
-
* PingResult.workflowID and marker identity are never empty.
|
|
325
|
-
*
|
|
326
|
-
* @param workflowID - Stable, non-empty id (sanitized by the caller — CR1/CR3).
|
|
327
|
-
* @param sleepMs - Duration of step2 sleep (default 15 000 ms).
|
|
328
|
-
* @param markerFile - Path to the durable marker file written by step1.
|
|
329
|
-
*/
|
|
330
180
|
async startPingWorkflow(workflowID, sleepMs, markerFile) {
|
|
331
181
|
return DBOS.startWorkflow(this.pingWorkflow, { workflowID })(workflowID, sleepMs, markerFile);
|
|
332
182
|
}
|
|
333
|
-
/**
|
|
334
|
-
* Get the current status of a workflow by id.
|
|
335
|
-
*/
|
|
336
183
|
getWorkflowStatus(id) {
|
|
337
184
|
return DBOS.getWorkflowStatus(id);
|
|
338
185
|
}
|
|
339
|
-
/**
|
|
340
|
-
* Recover-and-wait: retrieve an existing workflow handle and await its result.
|
|
341
|
-
* Used by `dev:status <id>` — the resume-test command (E10, F2).
|
|
342
|
-
* `DBOS.retrieveWorkflow()` always returns a handle even if the workflow does not exist yet.
|
|
343
|
-
*
|
|
344
|
-
* @deprecated Use `waitForWorkflowResult<T>` for typed workflows. Kept for ping backward compat.
|
|
345
|
-
*/
|
|
346
186
|
async waitForWorkflow(id) {
|
|
347
187
|
const handle = DBOS.retrieveWorkflow(id);
|
|
348
188
|
return handle.getResult();
|
|
349
189
|
}
|
|
350
|
-
/**
|
|
351
|
-
* Generic recover-and-wait: retrieve a workflow handle by id and await its typed result.
|
|
352
|
-
* Used by `run start` to await workflow completion (C2 fix — so the CLI process does not
|
|
353
|
-
* close before the workflow finishes). Also used for crash-resume: re-running `run start <id>`
|
|
354
|
-
* re-attaches to the existing handle and waits for it to finish — not a double-enqueue.
|
|
355
|
-
*
|
|
356
|
-
* `DBOS.retrieveWorkflow()` always returns a handle (even for a workflow that does not exist yet),
|
|
357
|
-
* so callers should confirm the workflow exists (via `getWorkflowStatus`) before calling this if
|
|
358
|
-
* they want to distinguish "not found" from "in progress".
|
|
359
|
-
*/
|
|
360
190
|
async waitForWorkflowResult(id) {
|
|
361
191
|
const handle = DBOS.retrieveWorkflow(id);
|
|
362
192
|
return handle.getResult();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbos.service.js","sourceRoot":"","sources":["../../src/engine/dbos.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dbos.service.js","sourceRoot":"","sources":["../../src/engine/dbos.service.ts"],"names":[],"mappings":";;;;;;;;;;AAkCA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAOpD,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAQ/C,MAAM,UAAU,6BAA6B,CAC3C,MAA0C,OAAO,CAAC,GAAG;IAErD,MAAM,KAAK,GAAG,GAAG,CAAC,gCAAgC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,yBAAyB,CAAC;IAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,yBAAyB,CAAC;AAC3E,CAAC;AAmBM,IAAM,WAAW,GAAjB,MAAM,WAAW;;IACd,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,MAAM,CAAC,aAAa,GAAyB,IAAI,CAAC;IAClD,MAAM,CAAC,UAAU,GAAmF,IAAI,CAAC;IAGzG,MAAM,CAAU,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC1D,MAAM,CAAU,YAAY,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/D,MAAM,CAAU,KAAK,GAAG,IAAI,GAAG,EAAoD,CAAC;IACpF,MAAM,CAAU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rD,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;IAUD,KAAK,CAAC,qBAAqB,CAAI,EAAU;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAI,EAAE,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;;AArSU,WAAW;IADvB,UAAU,EAAE;;GACA,WAAW,CAsSvB"}
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ensurePostgres() — creates the `dbos` database in Revisium's embedded Postgres if absent.
|
|
3
|
-
*
|
|
4
|
-
* Idempotent: checks pg_database first; only issues CREATE DATABASE when absent.
|
|
5
|
-
* Uses the pid-proven pg port from runtime.json (never hardcodes it — ADR-0001 #4).
|
|
6
|
-
*
|
|
7
|
-
* PG creds default: `revisium`/`password` — confirmed from @revisium/standalone 2.8.2 (F5).
|
|
8
|
-
* Kept parameterized so a future config change is one line.
|
|
9
|
-
*
|
|
10
|
-
* Race safety (F17): Two concurrent first-run hosts may both observe count=0 and both issue
|
|
11
|
-
* CREATE DATABASE. PostgreSQL raises SQLSTATE 42P04 (duplicate_database) for the loser.
|
|
12
|
-
* We catch 42P04 and treat it as success — the database now exists, which is the desired
|
|
13
|
-
* postcondition. All other errors are re-thrown verbatim.
|
|
14
|
-
*
|
|
15
|
-
* Testability (F20): ensurePostgres accepts an optional `deps.createClient` factory so tests
|
|
16
|
-
* can inject a fake client that exercises the real 42P04 catch / SELECT fast-path without a
|
|
17
|
-
* live Postgres. The production default constructs a real `pg.Client`.
|
|
18
|
-
*/
|
|
19
1
|
import pg from 'pg';
|
|
20
2
|
import { PROFILES, resolveProfileName } from '../config.js';
|
|
21
|
-
/**
|
|
22
|
-
* DBOS system-database name. `REVO_DBOS_DB` overrides; otherwise it falls back to the active
|
|
23
|
-
* profile's db (default `dbos`, dev `dbos_dev`) so a profiled host keeps its DBOS progress separate.
|
|
24
|
-
* Validated to a safe identifier because the name is interpolated into a non-parameterizable
|
|
25
|
-
* `CREATE DATABASE` (CREATE DATABASE cannot bind params).
|
|
26
|
-
*/
|
|
27
3
|
export function resolveDbosDbName() {
|
|
28
4
|
const name = process.env['REVO_DBOS_DB'] ?? PROFILES[resolveProfileName()].dbosDb;
|
|
29
5
|
if (!/^[a-z_][a-z0-9_]*$/i.test(name)) {
|
|
@@ -32,25 +8,15 @@ export function resolveDbosDbName() {
|
|
|
32
8
|
return name;
|
|
33
9
|
}
|
|
34
10
|
const MAINTENANCE_DB = 'postgres';
|
|
35
|
-
/** PostgreSQL SQLSTATE for "database already exists" (duplicate_database). */
|
|
36
11
|
const PG_SQLSTATE_DUPLICATE_DATABASE = '42P04';
|
|
37
12
|
const DEFAULT_CREDS = {
|
|
38
13
|
user: 'revisium',
|
|
39
14
|
password: 'password',
|
|
40
15
|
adminDb: MAINTENANCE_DB,
|
|
41
16
|
};
|
|
42
|
-
/**
|
|
43
|
-
* Ensure the `dbos` database exists on the Revisium embedded Postgres.
|
|
44
|
-
* @param pgPort - The pid-proven pg port from runtime.json.
|
|
45
|
-
* @param opts - Optional credential overrides (default: revisium/password).
|
|
46
|
-
* @param deps - Optional injectable dependencies for testing (F20).
|
|
47
|
-
*/
|
|
48
17
|
export async function ensurePostgres(pgPort, opts = {}, deps = {}) {
|
|
49
18
|
const dbosDbName = resolveDbosDbName();
|
|
50
19
|
const { user, password, adminDb } = { ...DEFAULT_CREDS, ...opts };
|
|
51
|
-
// pg.Client.connect() returns Promise<Client> while ClientLike.connect() returns
|
|
52
|
-
// Promise<void>; they are structurally compatible at the call sites used here, but
|
|
53
|
-
// TypeScript requires an explicit cast via unknown to bridge the return-type difference.
|
|
54
20
|
const pgClientFactory = () => new pg.Client({ host: 'localhost', port: pgPort, user, password, database: adminDb });
|
|
55
21
|
const createClient = deps.createClient ?? pgClientFactory;
|
|
56
22
|
const client = createClient();
|
|
@@ -59,16 +25,11 @@ export async function ensurePostgres(pgPort, opts = {}, deps = {}) {
|
|
|
59
25
|
const result = await client.query(`SELECT count(*)::text AS count FROM pg_database WHERE datname = $1`, [dbosDbName]);
|
|
60
26
|
const exists = result.rows[0]?.count !== '0';
|
|
61
27
|
if (!exists) {
|
|
62
|
-
// CREATE DATABASE cannot be parameterized; `dbos` is a fixed literal with no injection surface.
|
|
63
|
-
// Race backstop (F17): if two hosts both observed count=0 and both issue CREATE DATABASE,
|
|
64
|
-
// PostgreSQL raises 42P04 (duplicate_database) for the loser. Treat it as success
|
|
65
|
-
// (idempotent — the database now exists). Re-throw any other error.
|
|
66
28
|
try {
|
|
67
29
|
await client.query(`CREATE DATABASE ${dbosDbName}`);
|
|
68
30
|
}
|
|
69
31
|
catch (err) {
|
|
70
32
|
if (err.code === PG_SQLSTATE_DUPLICATE_DATABASE) {
|
|
71
|
-
// Another concurrent host already created it — this is fine.
|
|
72
33
|
return;
|
|
73
34
|
}
|
|
74
35
|
throw err;
|
|
@@ -79,15 +40,6 @@ export async function ensurePostgres(pgPort, opts = {}, deps = {}) {
|
|
|
79
40
|
await client.end();
|
|
80
41
|
}
|
|
81
42
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Build the DBOS system database URL from the pid-proven pg port.
|
|
84
|
-
* Single place; never hardcodes the port.
|
|
85
|
-
*
|
|
86
|
-
* CR4: user and password are percent-encoded via encodeURIComponent so that
|
|
87
|
-
* reserved characters (e.g. '@', ':', '/', '%') do not break the URI.
|
|
88
|
-
* The default credentials ('revisium'/'password') contain no reserved chars
|
|
89
|
-
* and encode to themselves, so existing behaviour is unchanged.
|
|
90
|
-
*/
|
|
91
43
|
export function dbosSystemDatabaseUrl(pgPort, user = 'revisium', password = 'password') {
|
|
92
44
|
return `postgresql://${encodeURIComponent(user)}:${encodeURIComponent(password)}@localhost:${pgPort}/${resolveDbosDbName()}`;
|
|
93
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-postgres.js","sourceRoot":"","sources":["../../src/engine/ensure-postgres.ts"],"names":[],"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,EAAE,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAC/B,oEAAoE,EACpE,CAAC,UAAU,CAAC,CACb,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,GAAG,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC;YACtD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAK,GAAyB,CAAC,IAAI,KAAK,8BAA8B,EAAE,CAAC;oBACvE,OAAO;gBACT,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;AACH,CAAC;AASD,MAAM,UAAU,qBAAqB,CACnC,MAAc,EACd,IAAI,GAAG,UAAU,EACjB,QAAQ,GAAG,UAAU;IAErB,OAAO,gBAAgB,kBAAkB,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,cAAc,MAAM,IAAI,iBAAiB,EAAE,EAAE,CAAC;AAC/H,CAAC"}
|
package/dist/host/daemon.js
CHANGED
|
@@ -10,21 +10,12 @@ import { TaskControlPlaneApiService } from '../task-control-plane/task-control-p
|
|
|
10
10
|
import { APP_PUB_SUB } from '../api/graphql-api/graphql-ws/constants.js';
|
|
11
11
|
import { hostCodeVersion, removeHostRuntimeIfMatches, writeHostRuntime } from './host-runtime.js';
|
|
12
12
|
import { acquireQueueOwnership } from './queue-ownership.js';
|
|
13
|
-
/** MCP endpoint port: REVO_MCP_PORT, else the GraphQL port + 1 (kept in the profile band). */
|
|
14
13
|
function resolveMcpPort(graphqlPort) {
|
|
15
14
|
const env = process.env['REVO_MCP_PORT'];
|
|
16
15
|
return env && /^\d+$/.test(env.trim()) ? Number(env.trim()) : graphqlPort + 1;
|
|
17
16
|
}
|
|
18
|
-
/** The detached host-daemon entrypoint (spawned by ensureHost): boot the stack, then serve + stay alive. */
|
|
19
17
|
export async function runHostDaemon() {
|
|
20
|
-
// 1. Standalone up first, then 2. all control-plane writes via fresh client scopes — BEFORE the
|
|
21
|
-
// service layer (startGraphqlHost) caches its read scope, so same-boot reads see a ready control-plane.
|
|
22
18
|
const { runtime } = await ensureRevisium();
|
|
23
|
-
// Singleton gate (slice 139): exactly ONE host daemon per profile may own + poll the dev-tasks
|
|
24
|
-
// queue. Acquired here — BEFORE DBOS.launch()/queue polling (startGraphqlHost) — so a daemon that
|
|
25
|
-
// lost a concurrent cold-start race exits cleanly without ever touching the queue; ensureHost then
|
|
26
|
-
// attaches to the winner via host.json. Crash-safe: the connection-scoped advisory lock frees itself
|
|
27
|
-
// if this process dies.
|
|
28
19
|
const ownership = await acquireQueueOwnership(getConfig().profile, runtime.pgPort);
|
|
29
20
|
if (!ownership.owned) {
|
|
30
21
|
console.error(`[host] profile "${getConfig().profile}" is already owned by another daemon — exiting; the owner serves the queue.`);
|
|
@@ -32,20 +23,11 @@ export async function runHostDaemon() {
|
|
|
32
23
|
}
|
|
33
24
|
await bootstrapControlPlane(runtime.httpPort);
|
|
34
25
|
await seedDefaultPlaybookBestEffort(() => seedDefaultPlaybook(createDaemonInstaller(() => listInstalledPlaybooks(runtime.httpPort))));
|
|
35
|
-
// 3. Now bring up the Nest/GraphQL/DBOS layer (HostLifecycle re-ensures Revisium = no-op).
|
|
36
26
|
const started = await startGraphqlHost();
|
|
37
|
-
// 4. MCP front door + 5. host.json. Wrapped so a failure AFTER startGraphqlHost (DBOS already
|
|
38
|
-
// launched) never leaves a live DBOS owner without host.json: on error we close the MCP server +
|
|
39
|
-
// Nest app (→ DBOS.shutdown) and exit non-zero, so ensureHost reports the failure, not a zombie.
|
|
40
27
|
let mcpServer;
|
|
41
28
|
try {
|
|
42
|
-
// Build the MCP facade from the DI-resolved TaskControlPlaneApiService (the surface the GraphQL
|
|
43
|
-
// resolvers use): resolving McpFacadeService itself via app.get left its injected `api` undefined.
|
|
44
29
|
const mcpPort = resolveMcpPort(started.port);
|
|
45
30
|
const api = started.app.get(TaskControlPlaneApiService, { strict: false });
|
|
46
|
-
// Option A (slice 141 D2): give the watch primitive APP_PUB_SUB so a gate/terminal wakes a held
|
|
47
|
-
// long-poll instead of polling. PubSubModule is @Global, so it resolves off the started handle; if
|
|
48
|
-
// it can't, RunWatchService degrades to its internal poll (option B) — same correctness.
|
|
49
31
|
let watchPubSub;
|
|
50
32
|
try {
|
|
51
33
|
watchPubSub = started.app.get(APP_PUB_SUB, { strict: false });
|
|
@@ -57,7 +39,6 @@ export async function runHostDaemon() {
|
|
|
57
39
|
mcpServer = await new McpHttpService(new McpFacadeService(api, runWatch)).start(mcpPort);
|
|
58
40
|
const startedAt = new Date().toISOString();
|
|
59
41
|
const snapshot = { pid: process.pid, startedAt };
|
|
60
|
-
// host.json is written LAST — its presence is the "fully ready" signal ensureHost waits on.
|
|
61
42
|
writeHostRuntime({
|
|
62
43
|
pid: process.pid,
|
|
63
44
|
graphqlPort: started.port,
|
|
@@ -74,11 +55,11 @@ export async function runHostDaemon() {
|
|
|
74
55
|
closing = true;
|
|
75
56
|
runningMcp.close();
|
|
76
57
|
started.app
|
|
77
|
-
.close()
|
|
58
|
+
.close()
|
|
78
59
|
.catch(() => undefined)
|
|
79
60
|
.finally(() => {
|
|
80
61
|
ownership
|
|
81
|
-
.release()
|
|
62
|
+
.release()
|
|
82
63
|
.catch(() => undefined)
|
|
83
64
|
.finally(() => {
|
|
84
65
|
removeHostRuntimeIfMatches(snapshot);
|
package/dist/host/daemon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.js","sourceRoot":"","sources":["../../src/host/daemon.ts"],"names":[],"mappings":"
|
|
1
|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C,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -1,38 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pinned DBOS identity for the host daemon (slice 140, Part A Layer 2).
|
|
3
|
-
*
|
|
4
|
-
* DBOS derives two identifiers from the environment AT IMPORT TIME (dbos-sdk `utils.js` `globalParams`
|
|
5
|
-
* is a module-level literal: `executorID = process.env.DBOS__VMID || 'local'`,
|
|
6
|
-
* `appVersion = process.env.DBOS__APPVERSION || ''`). Left unset, every daemon is `executorID='local'`
|
|
7
|
-
* with a source-MD5 appVersion — indistinguishable in `pg_stat_activity` and brittle across releases.
|
|
8
|
-
* We pin both, so:
|
|
9
|
-
* - executorID = `revo-<profile>` makes each daemon's DBOS connections self-identifying in
|
|
10
|
-
* `pg_stat_activity.application_name` (`dbos_transact_<executorID>_<appVersion>`), which is the
|
|
11
|
-
* ONLY way `revo doctor` can see a rogue/legacy poller that holds no inbound port.
|
|
12
|
-
* - appVersion = a value WE control, decoupled from the npm release version. DBOS recovery keys on
|
|
13
|
-
* a HARD `application_version` equality, so a per-release version would strand in-flight PENDING
|
|
14
|
-
* work on every alpha bump. Pinning a stable workflow version keeps recovery working across a
|
|
15
|
-
* routine upgrade; it is bumped ONLY when the durable workflow/step SOURCE actually changes.
|
|
16
|
-
*
|
|
17
|
-
* Because `globalParams` is read at import time, the pin must be present in the daemon process's
|
|
18
|
-
* environment from the start — it is applied to the detached child's env in `ensure-host.spawnDaemon`,
|
|
19
|
-
* never mutated after the dbos-sdk module has loaded.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Pinned DBOS `appVersion`. NOT the npm package version — bump this ONLY when the durable DBOS
|
|
23
|
-
* workflow/step function SOURCE changes (which moves the recovery/dequeue version boundary). A routine
|
|
24
|
-
* release that does not touch workflow-step code keeps this value so in-flight work recovers cleanly.
|
|
25
|
-
*/
|
|
26
1
|
export const DBOS_WORKFLOW_VERSION = '1';
|
|
27
|
-
/** Stable per-profile DBOS executor id (`revo-<profile>`) — the owner identity the census matches on. */
|
|
28
2
|
export function dbosExecutorId(profile) {
|
|
29
3
|
return `revo-${profile}`;
|
|
30
4
|
}
|
|
31
|
-
/**
|
|
32
|
-
* The `DBOS__VMID` / `DBOS__APPVERSION` env pin for a profile's daemon. An explicitly-SET value in
|
|
33
|
-
* `env` wins (so a custom layout / test can override) — including an explicit empty string, hence `??`
|
|
34
|
-
* not `||`; only an absent (undefined) var falls back to the pinned defaults.
|
|
35
|
-
*/
|
|
36
5
|
export function dbosEnvPin(profile, env = process.env) {
|
|
37
6
|
return {
|
|
38
7
|
DBOS__VMID: env['DBOS__VMID'] ?? dbosExecutorId(profile),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbos-identity.js","sourceRoot":"","sources":["../../src/host/dbos-identity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dbos-identity.js","sourceRoot":"","sources":["../../src/host/dbos-identity.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAGzC,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,QAAQ,OAAO,EAAE,CAAC;AAC3B,CAAC;AAKD,MAAM,UAAU,UAAU,CACxB,OAAe,EACf,MAAyB,OAAO,CAAC,GAAG;IAEpC,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC;QACxD,gBAAgB,EAAE,GAAG,CAAC,kBAAkB,CAAC,IAAI,qBAAqB;KACnE,CAAC;AACJ,CAAC"}
|