rampway 0.3.0 → 0.4.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 +31 -0
- package/build/src/velocious/auth.d.ts +17 -0
- package/build/src/velocious/auth.d.ts.map +1 -0
- package/build/src/velocious/auth.js +30 -0
- package/build/src/velocious/auth.js.map +1 -0
- package/build/src/velocious/control-plane.d.ts +177 -0
- package/build/src/velocious/control-plane.d.ts.map +1 -0
- package/build/src/velocious/control-plane.js +290 -0
- package/build/src/velocious/control-plane.js.map +1 -0
- package/build/src/velocious/controller.d.ts +58 -0
- package/build/src/velocious/controller.d.ts.map +1 -0
- package/build/src/velocious/controller.js +143 -0
- package/build/src/velocious/controller.js.map +1 -0
- package/build/src/velocious/executor.d.ts +55 -0
- package/build/src/velocious/executor.d.ts.map +1 -0
- package/build/src/velocious/executor.js +142 -0
- package/build/src/velocious/executor.js.map +1 -0
- package/build/src/velocious/index.d.ts +31 -0
- package/build/src/velocious/index.d.ts.map +1 -0
- package/build/src/velocious/index.js +144 -0
- package/build/src/velocious/index.js.map +1 -0
- package/build/src/velocious/path-matcher.d.ts +18 -0
- package/build/src/velocious/path-matcher.d.ts.map +1 -0
- package/build/src/velocious/path-matcher.js +48 -0
- package/build/src/velocious/path-matcher.js.map +1 -0
- package/build/src/velocious/registry.d.ts +25 -0
- package/build/src/velocious/registry.d.ts.map +1 -0
- package/build/src/velocious/registry.js +48 -0
- package/build/src/velocious/registry.js.map +1 -0
- package/build/src/velocious/run-store.d.ts +347 -0
- package/build/src/velocious/run-store.d.ts.map +1 -0
- package/build/src/velocious/run-store.js +569 -0
- package/build/src/velocious/run-store.js.map +1 -0
- package/build/src/velocious/sanitize.d.ts +23 -0
- package/build/src/velocious/sanitize.d.ts.map +1 -0
- package/build/src/velocious/sanitize.js +154 -0
- package/build/src/velocious/sanitize.js.map +1 -0
- package/build/src/velocious/worker.d.ts +48 -0
- package/build/src/velocious/worker.d.ts.map +1 -0
- package/build/src/velocious/worker.js +165 -0
- package/build/src/velocious/worker.js.map +1 -0
- package/docs/docker-development-environment.md +103 -0
- package/docs/velocious-deployment-api.md +226 -0
- package/package.json +22 -3
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import TableData from "velocious/build/src/database/table-data/index.js";
|
|
4
|
+
import TableIndex from "velocious/build/src/database/table-data/table-index.js";
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {object} DeploymentRunRow
|
|
7
|
+
* @property {string} id
|
|
8
|
+
* @property {string} mountIdentifier
|
|
9
|
+
* @property {string} project
|
|
10
|
+
* @property {string} stage
|
|
11
|
+
* @property {string} revision
|
|
12
|
+
* @property {string} idempotencyKey
|
|
13
|
+
* @property {string} status
|
|
14
|
+
* @property {any} result
|
|
15
|
+
* @property {any} error
|
|
16
|
+
* @property {number} requestedAtMs
|
|
17
|
+
* @property {number|null} startedAtMs
|
|
18
|
+
* @property {number|null} finishedAtMs
|
|
19
|
+
* @property {string|null} ownerToken
|
|
20
|
+
* @property {number|null} heartbeatAtMs
|
|
21
|
+
* @property {number|null} launchProtectedUntilMs
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {object} DeploymentRunStoreContract
|
|
25
|
+
* @property {(id: string) => Promise<DeploymentRunRow|null>} findRunById
|
|
26
|
+
* @property {(key: string) => Promise<DeploymentRunRow|null>} findRunByKey
|
|
27
|
+
* @property {(args: {idempotencyKey: string, project: string, revision: string, stage: string}) => Promise<{outcome: string, run: DeploymentRunRow|null}>} createRunIfPossible
|
|
28
|
+
* @property {(args: {id: string, startedAtMs: number}) => Promise<void>} markRunning
|
|
29
|
+
* @property {(args: {id: string, startedAtMs: number}) => Promise<DeploymentRunRow>} claimPendingRun
|
|
30
|
+
* @property {(args: {id: string, heartbeatAtMs: number}) => Promise<void>} heartbeat
|
|
31
|
+
* @property {(args: {id: string, ownerToken: string, finishedAtMs: number, error: any}) => Promise<void>} markPendingFailed
|
|
32
|
+
* @property {(args: {id: string, finishedAtMs: number, error: any}) => Promise<void>} failPendingRun
|
|
33
|
+
* @property {(args: {id: string, ownerToken: string, finishedAtMs: number, result: any}) => Promise<void>} markSucceeded
|
|
34
|
+
* @property {(args: {id: string, ownerToken: string, finishedAtMs: number, error: any}) => Promise<void>} markFailed
|
|
35
|
+
* @property {(args: {id: string, ownerToken: string, finishedAtMs: number, error: any}) => Promise<void>} markReconciliationRequired
|
|
36
|
+
* @property {(args: {event: string, payload: any, runId: string|null}) => Promise<void>} addAuditEvent
|
|
37
|
+
*/
|
|
38
|
+
const RUNS_TABLE = "rampway_deployment_runs";
|
|
39
|
+
const AUDIT_TABLE = "rampway_deployment_api_audit_events";
|
|
40
|
+
const BLOCKING_STATUSES = ["pending", "running", "reconciliation_required"];
|
|
41
|
+
const SCHEMA_LOCK = "rampway-deployment-api:schema-v1";
|
|
42
|
+
const MIN_LAUNCH_PROTECTION_MS = 1000;
|
|
43
|
+
const MAX_LAUNCH_PROTECTION_MS = 300000;
|
|
44
|
+
const OWNER_TOKEN = randomUUID();
|
|
45
|
+
const activeRunIds = new Set();
|
|
46
|
+
/**
|
|
47
|
+
* @param {string} id - Run id.
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
export function registerActiveDeploymentRun(id) { activeRunIds.add(id); }
|
|
51
|
+
/**
|
|
52
|
+
* @param {string} id - Run id.
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
export function unregisterActiveDeploymentRun(id) { activeRunIds.delete(id); }
|
|
56
|
+
/**
|
|
57
|
+
* @param {number} staleRunTimeoutMs - Lease duration.
|
|
58
|
+
* @returns {number} Heartbeat interval strictly below the lease.
|
|
59
|
+
*/
|
|
60
|
+
export function heartbeatIntervalMs(staleRunTimeoutMs) {
|
|
61
|
+
if (!Number.isSafeInteger(staleRunTimeoutMs) || staleRunTimeoutMs < 4) {
|
|
62
|
+
throw new Error("staleRunTimeoutMs must be an integer of at least 4 milliseconds");
|
|
63
|
+
}
|
|
64
|
+
return Math.max(1, Math.floor(staleRunTimeoutMs / 4));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @param {{activeRunIds: Set<string>, nowMs: number, run: {heartbeatAtMs: number|null, id: string, launchProtectedUntilMs?: number|null, requestedAtMs: number, status?: string}, staleRunTimeoutMs: number}} args - Lease data.
|
|
68
|
+
* @returns {boolean} Whether ownership expired.
|
|
69
|
+
*/
|
|
70
|
+
export function isRunLeaseExpired({ activeRunIds: localIds, nowMs, run, staleRunTimeoutMs }) {
|
|
71
|
+
if (localIds.has(run.id))
|
|
72
|
+
return false;
|
|
73
|
+
if (run.status === "pending" && run.launchProtectedUntilMs != null && nowMs < run.launchProtectedUntilMs)
|
|
74
|
+
return false;
|
|
75
|
+
return nowMs - (run.heartbeatAtMs ?? run.requestedAtMs) > staleRunTimeoutMs;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @param {{id: string, mountIdentifier: string, ownerToken: string}} args - Fence identifiers.
|
|
79
|
+
* @returns {Record<string, unknown>} Update conditions.
|
|
80
|
+
*/
|
|
81
|
+
export function terminalTransitionConditions({ id, mountIdentifier, ownerToken }) {
|
|
82
|
+
return { id, mount_identifier: mountIdentifier, owner_token: ownerToken, status: "running" };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Includes the observed heartbeat so a concurrent renewal defeats stale reconciliation.
|
|
86
|
+
*
|
|
87
|
+
* @param {{mountIdentifier: string, run: Pick<DeploymentRunRow, 'heartbeatAtMs'|'id'|'ownerToken'|'status'>}} args - Fence data.
|
|
88
|
+
* @returns {Record<string, unknown>} Update conditions.
|
|
89
|
+
*/
|
|
90
|
+
export function reconciliationConditions({ mountIdentifier, run }) {
|
|
91
|
+
return {
|
|
92
|
+
heartbeat_at_ms: run.heartbeatAtMs,
|
|
93
|
+
id: run.id,
|
|
94
|
+
mount_identifier: mountIdentifier,
|
|
95
|
+
owner_token: run.ownerToken,
|
|
96
|
+
status: run.status
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @param {unknown} value - JSON column.
|
|
101
|
+
* @returns {any} Parsed value.
|
|
102
|
+
*/
|
|
103
|
+
function parseJson(value) {
|
|
104
|
+
return typeof value === "string" && value.length > 0 ? JSON.parse(value) : null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gives the package worker a durable bootstrap lease without changing the
|
|
108
|
+
* caller-configured execution lease. The lease is cleared by claim or failure.
|
|
109
|
+
*
|
|
110
|
+
* @param {number} staleRunTimeoutMs - Execution lease.
|
|
111
|
+
* @returns {number} Launch protection duration.
|
|
112
|
+
*/
|
|
113
|
+
function launchProtectionDurationMs(staleRunTimeoutMs) {
|
|
114
|
+
return Math.min(MAX_LAUNCH_PROTECTION_MS, Math.max(MIN_LAUNCH_PROTECTION_MS, staleRunTimeoutMs * 10));
|
|
115
|
+
}
|
|
116
|
+
/** Rampway-owned durable deployment state stored through Velocious's database abstraction. */
|
|
117
|
+
export default class DeploymentRunStore {
|
|
118
|
+
/**
|
|
119
|
+
* @param {object} args - Store options.
|
|
120
|
+
* @param {any} args.configuration - Velocious configuration.
|
|
121
|
+
* @param {string} [args.databaseIdentifier] - Database identifier.
|
|
122
|
+
* @param {string} args.mountIdentifier - Authenticated mount scope.
|
|
123
|
+
* @param {number} args.staleRunTimeoutMs - Lease duration.
|
|
124
|
+
*/
|
|
125
|
+
constructor({ configuration, databaseIdentifier = "default", mountIdentifier, staleRunTimeoutMs }) {
|
|
126
|
+
if (!mountIdentifier)
|
|
127
|
+
throw new Error("DeploymentRunStore requires a mountIdentifier");
|
|
128
|
+
heartbeatIntervalMs(staleRunTimeoutMs);
|
|
129
|
+
this.configuration = configuration;
|
|
130
|
+
this.databaseIdentifier = databaseIdentifier;
|
|
131
|
+
this.mountIdentifier = mountIdentifier;
|
|
132
|
+
this.staleRunTimeoutMs = staleRunTimeoutMs;
|
|
133
|
+
/** @type {Promise<void>|null} */
|
|
134
|
+
this.readyPromise = null;
|
|
135
|
+
}
|
|
136
|
+
/** @returns {Promise<void>} */
|
|
137
|
+
async ensureReady() {
|
|
138
|
+
if (this.readyPromise)
|
|
139
|
+
return await this.readyPromise;
|
|
140
|
+
this.readyPromise = this._withDb(async (db) => {
|
|
141
|
+
const acquired = await db.acquireAdvisoryLock(SCHEMA_LOCK);
|
|
142
|
+
if (!acquired)
|
|
143
|
+
throw new Error("Failed to acquire Rampway deployment API schema lock");
|
|
144
|
+
try {
|
|
145
|
+
db.clearSchemaCache();
|
|
146
|
+
if (!await db.tableExists(RUNS_TABLE)) {
|
|
147
|
+
const table = new TableData(RUNS_TABLE, { ifNotExists: true });
|
|
148
|
+
table.string("id", { null: false, primaryKey: true });
|
|
149
|
+
table.string("mount_identifier", { maxLength: 64, null: false });
|
|
150
|
+
table.string("project", { null: false, index: true });
|
|
151
|
+
table.string("stage", { null: false });
|
|
152
|
+
table.string("revision", { null: false });
|
|
153
|
+
table.string("idempotency_key", { null: false });
|
|
154
|
+
table.string("status", { null: false, index: true });
|
|
155
|
+
table.text("result_json", { null: true });
|
|
156
|
+
table.text("error_json", { null: true });
|
|
157
|
+
table.bigint("requested_at_ms", { null: false });
|
|
158
|
+
table.bigint("started_at_ms", { null: true });
|
|
159
|
+
table.bigint("finished_at_ms", { null: true });
|
|
160
|
+
table.string("owner_token", { null: true });
|
|
161
|
+
table.bigint("heartbeat_at_ms", { null: true });
|
|
162
|
+
table.bigint("launch_protected_until_ms", { null: true });
|
|
163
|
+
table.addIndex(new TableIndex(["mount_identifier", "idempotency_key"], {
|
|
164
|
+
name: "index_rampway_runs_on_mount_and_key",
|
|
165
|
+
unique: true
|
|
166
|
+
}));
|
|
167
|
+
await db.createTable(table);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
await this._ensureLaunchProtectionColumn(db);
|
|
171
|
+
}
|
|
172
|
+
if (!await db.tableExists(AUDIT_TABLE)) {
|
|
173
|
+
const table = new TableData(AUDIT_TABLE, { ifNotExists: true });
|
|
174
|
+
table.string("id", { null: false, primaryKey: true });
|
|
175
|
+
table.string("mount_identifier", { maxLength: 64, null: false });
|
|
176
|
+
table.string("run_id", { null: true, index: true });
|
|
177
|
+
table.string("event", { null: false, index: true });
|
|
178
|
+
table.text("payload_json", { null: true });
|
|
179
|
+
table.bigint("created_at_ms", { null: false });
|
|
180
|
+
await db.createTable(table);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
await db.releaseAdvisoryLock(SCHEMA_LOCK);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
try {
|
|
188
|
+
await this.readyPromise;
|
|
189
|
+
}
|
|
190
|
+
finally {
|
|
191
|
+
this.readyPromise = null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Adds the handoff lease to databases created by the previous API schema.
|
|
196
|
+
*
|
|
197
|
+
* @param {any} db - Open Velocious database connection.
|
|
198
|
+
* @returns {Promise<void>}
|
|
199
|
+
*/
|
|
200
|
+
async _ensureLaunchProtectionColumn(db) {
|
|
201
|
+
const table = await db.getTableByName(RUNS_TABLE, { throwError: false });
|
|
202
|
+
if (await table?.getColumnByName("launch_protected_until_ms"))
|
|
203
|
+
return;
|
|
204
|
+
const alteration = new TableData(RUNS_TABLE);
|
|
205
|
+
alteration.bigint("launch_protected_until_ms", { null: true });
|
|
206
|
+
for (const sql of await db.alterTableSQLs(alteration))
|
|
207
|
+
await db.query(sql);
|
|
208
|
+
db.clearSchemaCache();
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @param {string} id - Run id.
|
|
212
|
+
* @returns {Promise<DeploymentRunRow|null>} Run.
|
|
213
|
+
*/
|
|
214
|
+
async findRunById(id) {
|
|
215
|
+
await this.ensureReady();
|
|
216
|
+
return await this._withDb(async (db) => await this._reconcileExpiredRunIfNeeded(db, await this._findRunById(db, id)));
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @param {string} key - Idempotency key.
|
|
220
|
+
* @returns {Promise<DeploymentRunRow|null>} Run.
|
|
221
|
+
*/
|
|
222
|
+
async findRunByKey(key) {
|
|
223
|
+
await this.ensureReady();
|
|
224
|
+
return await this._withDb(async (db) => await this._reconcileExpiredRunIfNeeded(db, await this._findRunByKey(db, key)));
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Serializes admission by target then by mount-global idempotency key.
|
|
228
|
+
*
|
|
229
|
+
* @param {{idempotencyKey: string, project: string, revision: string, stage: string}} args - Run request.
|
|
230
|
+
* @returns {Promise<{outcome: string, run: DeploymentRunRow|null}>} Admission result.
|
|
231
|
+
*/
|
|
232
|
+
async createRunIfPossible({ idempotencyKey, project, revision, stage }) {
|
|
233
|
+
await this.ensureReady();
|
|
234
|
+
return await this._withDb(async (db) => {
|
|
235
|
+
const deploymentLock = this._lockName("target", `${project}:${stage}`);
|
|
236
|
+
if (!await db.tryAcquireAdvisoryLock(deploymentLock)) {
|
|
237
|
+
return { outcome: "in_progress", run: await this._findBlockingRun(db, { project, stage }) };
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const keyLock = this._lockName("key", idempotencyKey);
|
|
241
|
+
await db.acquireAdvisoryLock(keyLock);
|
|
242
|
+
try {
|
|
243
|
+
const keyed = await this._reconcileExpiredRunIfNeeded(db, await this._findRunByKey(db, idempotencyKey));
|
|
244
|
+
if (keyed) {
|
|
245
|
+
const same = keyed.project === project && keyed.stage === stage && keyed.revision === revision;
|
|
246
|
+
return { outcome: same ? "replay" : "conflict", run: keyed };
|
|
247
|
+
}
|
|
248
|
+
let blocking = await this._findBlockingRun(db, { project, stage });
|
|
249
|
+
if (blocking) {
|
|
250
|
+
if (blocking.status === "reconciliation_required")
|
|
251
|
+
return { outcome: "reconciliation_required", run: blocking };
|
|
252
|
+
if (!isRunLeaseExpired({ activeRunIds, nowMs: Date.now(), run: blocking, staleRunTimeoutMs: this.staleRunTimeoutMs })) {
|
|
253
|
+
return { outcome: "in_progress", run: blocking };
|
|
254
|
+
}
|
|
255
|
+
const reconciled = await this._reconcileExpiredRun(db, blocking);
|
|
256
|
+
if (!reconciled) {
|
|
257
|
+
blocking = await this._findBlockingRun(db, { project, stage });
|
|
258
|
+
return { outcome: blocking?.status === "reconciliation_required" ? "reconciliation_required" : "in_progress", run: blocking };
|
|
259
|
+
}
|
|
260
|
+
if (blocking.status === "running") {
|
|
261
|
+
const run = await this._findRunById(db, blocking.id);
|
|
262
|
+
return { outcome: "reconciliation_required", run };
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const id = randomUUID();
|
|
266
|
+
const requestedAtMs = Date.now();
|
|
267
|
+
await db.insert({
|
|
268
|
+
tableName: RUNS_TABLE,
|
|
269
|
+
data: {
|
|
270
|
+
error_json: null,
|
|
271
|
+
finished_at_ms: null,
|
|
272
|
+
heartbeat_at_ms: null,
|
|
273
|
+
id,
|
|
274
|
+
idempotency_key: idempotencyKey,
|
|
275
|
+
mount_identifier: this.mountIdentifier,
|
|
276
|
+
owner_token: OWNER_TOKEN,
|
|
277
|
+
project,
|
|
278
|
+
launch_protected_until_ms: requestedAtMs + launchProtectionDurationMs(this.staleRunTimeoutMs),
|
|
279
|
+
requested_at_ms: requestedAtMs,
|
|
280
|
+
result_json: null,
|
|
281
|
+
revision,
|
|
282
|
+
stage,
|
|
283
|
+
started_at_ms: null,
|
|
284
|
+
status: "pending"
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
const run = await this._findRunById(db, id);
|
|
288
|
+
if (!run)
|
|
289
|
+
throw new Error(`Rampway deployment run ${id} missing after insertion`);
|
|
290
|
+
return { outcome: "created", run };
|
|
291
|
+
}
|
|
292
|
+
finally {
|
|
293
|
+
await db.releaseAdvisoryLock(keyLock);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
finally {
|
|
297
|
+
await db.releaseAdvisoryLock(deploymentLock);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @param {{id: string, startedAtMs: number}} args - Cross-process worker claim.
|
|
303
|
+
* @returns {Promise<DeploymentRunRow>} Claimed run.
|
|
304
|
+
*/
|
|
305
|
+
async claimPendingRun({ id, startedAtMs }) {
|
|
306
|
+
await this.ensureReady();
|
|
307
|
+
return await this._withDb(async (db) => {
|
|
308
|
+
const affected = await db.affectedRows(db.updateSql({
|
|
309
|
+
tableName: RUNS_TABLE,
|
|
310
|
+
data: { heartbeat_at_ms: startedAtMs, launch_protected_until_ms: null, owner_token: OWNER_TOKEN, started_at_ms: startedAtMs, status: "running" },
|
|
311
|
+
conditions: { id, mount_identifier: this.mountIdentifier, status: "pending" }
|
|
312
|
+
}));
|
|
313
|
+
if (affected !== 1)
|
|
314
|
+
throw new Error(`Expected one claimable pending Rampway deployment run ${id}, updated ${affected}`);
|
|
315
|
+
const run = await this._findRunById(db, id);
|
|
316
|
+
if (!run)
|
|
317
|
+
throw new Error(`Rampway deployment run ${id} missing after worker claim`);
|
|
318
|
+
return run;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/** @param {{id: string, startedAtMs: number}} args - Transition. @returns {Promise<void>} */
|
|
322
|
+
async markRunning({ id, startedAtMs }) {
|
|
323
|
+
await this.ensureReady();
|
|
324
|
+
await this._withDb(async (db) => {
|
|
325
|
+
const affected = await db.affectedRows(db.updateSql({
|
|
326
|
+
tableName: RUNS_TABLE,
|
|
327
|
+
data: { heartbeat_at_ms: startedAtMs, started_at_ms: startedAtMs, status: "running" },
|
|
328
|
+
conditions: { id, mount_identifier: this.mountIdentifier, owner_token: OWNER_TOKEN, status: "pending" }
|
|
329
|
+
}));
|
|
330
|
+
if (affected !== 1)
|
|
331
|
+
throw new Error(`Expected one owner-matching pending Rampway deployment run ${id}, updated ${affected}`);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/** @param {{id: string, ownerToken: string, finishedAtMs: number, error: any}} args - Launch failure. @returns {Promise<void>} */
|
|
335
|
+
async markPendingFailed({ id, ownerToken, finishedAtMs, error }) {
|
|
336
|
+
await this.ensureReady();
|
|
337
|
+
await this._withDb(async (db) => {
|
|
338
|
+
const affected = await db.affectedRows(db.updateSql({
|
|
339
|
+
tableName: RUNS_TABLE,
|
|
340
|
+
data: { error_json: JSON.stringify(error ?? null), finished_at_ms: finishedAtMs, launch_protected_until_ms: null, status: "failed" },
|
|
341
|
+
conditions: { id, mount_identifier: this.mountIdentifier, owner_token: ownerToken, status: "pending" }
|
|
342
|
+
}));
|
|
343
|
+
if (affected !== 1)
|
|
344
|
+
throw new Error(`Expected one owner-matching pending Rampway deployment run ${id}, updated ${affected}`);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/** @param {{id: string, finishedAtMs: number, error: any}} args - Pre-claim worker failure. @returns {Promise<void>} */
|
|
348
|
+
async failPendingRun({ id, finishedAtMs, error }) {
|
|
349
|
+
await this.ensureReady();
|
|
350
|
+
await this._withDb(async (db) => {
|
|
351
|
+
const affected = await db.affectedRows(db.updateSql({
|
|
352
|
+
tableName: RUNS_TABLE,
|
|
353
|
+
data: { error_json: JSON.stringify(error ?? null), finished_at_ms: finishedAtMs, launch_protected_until_ms: null, status: "failed" },
|
|
354
|
+
conditions: { id, mount_identifier: this.mountIdentifier, status: "pending" }
|
|
355
|
+
}));
|
|
356
|
+
if (affected !== 1)
|
|
357
|
+
throw new Error(`Expected one pending Rampway deployment run ${id}, updated ${affected}`);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/** @param {{id: string, heartbeatAtMs: number}} args - Heartbeat. @returns {Promise<void>} */
|
|
361
|
+
async heartbeat({ id, heartbeatAtMs }) {
|
|
362
|
+
await this.ensureReady();
|
|
363
|
+
await this._withDb(async (db) => {
|
|
364
|
+
await db.affectedRows(db.updateSql({
|
|
365
|
+
tableName: RUNS_TABLE,
|
|
366
|
+
data: { heartbeat_at_ms: heartbeatAtMs },
|
|
367
|
+
conditions: { id, mount_identifier: this.mountIdentifier, owner_token: OWNER_TOKEN, status: "running" }
|
|
368
|
+
}));
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
/** @param {{id: string, ownerToken: string, finishedAtMs: number, result: any}} args - Transition. @returns {Promise<void>} */
|
|
372
|
+
async markSucceeded({ id, ownerToken, finishedAtMs, result }) {
|
|
373
|
+
await this._transition({ data: { finished_at_ms: finishedAtMs, result_json: JSON.stringify(result ?? null), status: "succeeded" }, id, ownerToken });
|
|
374
|
+
}
|
|
375
|
+
/** @param {{id: string, ownerToken: string, finishedAtMs: number, error: any}} args - Transition. @returns {Promise<void>} */
|
|
376
|
+
async markFailed({ id, ownerToken, finishedAtMs, error }) {
|
|
377
|
+
await this._transition({ data: { error_json: JSON.stringify(error ?? null), finished_at_ms: finishedAtMs, status: "failed" }, id, ownerToken });
|
|
378
|
+
}
|
|
379
|
+
/** @param {{id: string, ownerToken: string, finishedAtMs: number, error: any}} args - Transition. @returns {Promise<void>} */
|
|
380
|
+
async markReconciliationRequired({ id, ownerToken, finishedAtMs, error }) {
|
|
381
|
+
await this._transition({ data: { error_json: JSON.stringify(error ?? null), finished_at_ms: finishedAtMs, status: "reconciliation_required" }, id, ownerToken });
|
|
382
|
+
}
|
|
383
|
+
/** @param {{event: string, payload: any, runId: string|null}} args - Audit event. @returns {Promise<void>} */
|
|
384
|
+
async addAuditEvent({ event, payload, runId }) {
|
|
385
|
+
await this.ensureReady();
|
|
386
|
+
await this._withDb(async (db) => await db.insert({
|
|
387
|
+
tableName: AUDIT_TABLE,
|
|
388
|
+
data: {
|
|
389
|
+
created_at_ms: Date.now(),
|
|
390
|
+
event,
|
|
391
|
+
id: randomUUID(),
|
|
392
|
+
mount_identifier: this.mountIdentifier,
|
|
393
|
+
payload_json: payload === undefined ? null : JSON.stringify(payload ?? null),
|
|
394
|
+
run_id: runId
|
|
395
|
+
}
|
|
396
|
+
}));
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* @param {{runId: string}} args - Query.
|
|
400
|
+
* @returns {Promise<Array<Record<string, any>>>} Events.
|
|
401
|
+
*/
|
|
402
|
+
async listAuditEvents({ runId }) {
|
|
403
|
+
await this.ensureReady();
|
|
404
|
+
return await this._withDb(async (db) => {
|
|
405
|
+
const rows = await db.newQuery().from(AUDIT_TABLE).where({ mount_identifier: this.mountIdentifier, run_id: runId }).order("created_at_ms ASC").results();
|
|
406
|
+
return rows.map((/** @type {Record<string, any>} */ row) => ({
|
|
407
|
+
createdAtMs: Number(row.created_at_ms),
|
|
408
|
+
event: row.event,
|
|
409
|
+
id: row.id,
|
|
410
|
+
payload: parseJson(row.payload_json),
|
|
411
|
+
runId: row.run_id ?? null
|
|
412
|
+
}));
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* @param {any} db - Open Velocious database connection.
|
|
417
|
+
* @param {DeploymentRunRow} run - Observed stale run.
|
|
418
|
+
* @returns {Promise<boolean>} Whether this reconciler won.
|
|
419
|
+
*/
|
|
420
|
+
async _reconcileExpiredRun(db, run) {
|
|
421
|
+
const running = run.status === "running";
|
|
422
|
+
const status = running ? "reconciliation_required" : "interrupted";
|
|
423
|
+
const event = running ? "run_reconciliation_required" : "run_interrupted";
|
|
424
|
+
const error = running
|
|
425
|
+
? { message: "Deployment outcome requires operator reconciliation after the execution owner lease expired" }
|
|
426
|
+
: { message: "Deployment run was interrupted before execution began (ownership lease expired)" };
|
|
427
|
+
const affected = await db.affectedRows(db.updateSql({
|
|
428
|
+
tableName: RUNS_TABLE,
|
|
429
|
+
data: { error_json: JSON.stringify(error), finished_at_ms: Date.now(), launch_protected_until_ms: null, status },
|
|
430
|
+
conditions: reconciliationConditions({ mountIdentifier: this.mountIdentifier, run })
|
|
431
|
+
}));
|
|
432
|
+
if (affected === 0)
|
|
433
|
+
return false;
|
|
434
|
+
if (affected !== 1)
|
|
435
|
+
throw new Error(`Expected at most one expired Rampway deployment run ${run.id}, updated ${affected}`);
|
|
436
|
+
try {
|
|
437
|
+
await db.insert({
|
|
438
|
+
tableName: AUDIT_TABLE,
|
|
439
|
+
data: {
|
|
440
|
+
created_at_ms: Date.now(),
|
|
441
|
+
event,
|
|
442
|
+
id: randomUUID(),
|
|
443
|
+
mount_identifier: this.mountIdentifier,
|
|
444
|
+
payload_json: JSON.stringify({ project: run.project, revision: run.revision, stage: run.stage }),
|
|
445
|
+
run_id: run.id
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
catch (auditError) {
|
|
450
|
+
this._emitFrameworkError("rampway-deployment-api-reconciliation-audit", auditError);
|
|
451
|
+
}
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Reconciles an expired pending/running owner before returning durable state.
|
|
456
|
+
*
|
|
457
|
+
* @param {any} db - Open Velocious database connection.
|
|
458
|
+
* @param {DeploymentRunRow|null} run - Observed run.
|
|
459
|
+
* @returns {Promise<DeploymentRunRow|null>} Current durable run.
|
|
460
|
+
*/
|
|
461
|
+
async _reconcileExpiredRunIfNeeded(db, run) {
|
|
462
|
+
if (!run || !["pending", "running"].includes(run.status))
|
|
463
|
+
return run;
|
|
464
|
+
if (!isRunLeaseExpired({ activeRunIds, nowMs: Date.now(), run, staleRunTimeoutMs: this.staleRunTimeoutMs }))
|
|
465
|
+
return run;
|
|
466
|
+
await this._reconcileExpiredRun(db, run);
|
|
467
|
+
const current = await this._findRunById(db, run.id);
|
|
468
|
+
if (!current)
|
|
469
|
+
throw new Error(`Rampway deployment run ${run.id} missing after lease reconciliation`);
|
|
470
|
+
return current;
|
|
471
|
+
}
|
|
472
|
+
/** @param {{data: Record<string, any>, id: string, ownerToken: string}} args - Transition. @returns {Promise<void>} */
|
|
473
|
+
async _transition({ data, id, ownerToken }) {
|
|
474
|
+
await this.ensureReady();
|
|
475
|
+
await this._withDb(async (db) => {
|
|
476
|
+
const affected = await db.affectedRows(db.updateSql({
|
|
477
|
+
tableName: RUNS_TABLE,
|
|
478
|
+
data,
|
|
479
|
+
conditions: terminalTransitionConditions({ id, mountIdentifier: this.mountIdentifier, ownerToken })
|
|
480
|
+
}));
|
|
481
|
+
if (affected !== 1)
|
|
482
|
+
throw new Error(`Expected one owner-matching running Rampway deployment run ${id}, updated ${affected}`);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* @param {string} kind - Lock kind.
|
|
487
|
+
* @param {string} value - Scoped value.
|
|
488
|
+
* @returns {string} Lock name.
|
|
489
|
+
*/
|
|
490
|
+
_lockName(kind, value) {
|
|
491
|
+
const hash = createHash("sha256").update(`${this.mountIdentifier}:${value}`).digest("hex").slice(0, 32);
|
|
492
|
+
return `rampway-deployment:${kind}:${hash}`;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* @param {any} db - Connection.
|
|
496
|
+
* @param {string} id - Run id.
|
|
497
|
+
* @returns {Promise<DeploymentRunRow|null>} Run.
|
|
498
|
+
*/
|
|
499
|
+
async _findRunById(db, id) {
|
|
500
|
+
const rows = await db.newQuery().from(RUNS_TABLE).where({ id, mount_identifier: this.mountIdentifier }).limit(1).results();
|
|
501
|
+
return rows[0] ? this._row(rows[0]) : null;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* @param {any} db - Connection.
|
|
505
|
+
* @param {string} key - Idempotency key.
|
|
506
|
+
* @returns {Promise<DeploymentRunRow|null>} Run.
|
|
507
|
+
*/
|
|
508
|
+
async _findRunByKey(db, key) {
|
|
509
|
+
const rows = await db.newQuery().from(RUNS_TABLE).where({ idempotency_key: key, mount_identifier: this.mountIdentifier }).limit(1).results();
|
|
510
|
+
return rows[0] ? this._row(rows[0]) : null;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* @param {any} db - Connection.
|
|
514
|
+
* @param {{project: string, stage: string}} args - Target.
|
|
515
|
+
* @returns {Promise<DeploymentRunRow|null>} Run.
|
|
516
|
+
*/
|
|
517
|
+
async _findBlockingRun(db, { project, stage }) {
|
|
518
|
+
const rows = await db.newQuery().from(RUNS_TABLE).where({ mount_identifier: this.mountIdentifier, project, stage, status: BLOCKING_STATUSES }).order("requested_at_ms ASC").limit(1).results();
|
|
519
|
+
return rows[0] ? this._row(rows[0]) : null;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* @param {Record<string, any>} row - Database row.
|
|
523
|
+
* @returns {DeploymentRunRow} Run.
|
|
524
|
+
*/
|
|
525
|
+
_row(row) {
|
|
526
|
+
return {
|
|
527
|
+
error: parseJson(row.error_json),
|
|
528
|
+
finishedAtMs: row.finished_at_ms == null ? null : Number(row.finished_at_ms),
|
|
529
|
+
heartbeatAtMs: row.heartbeat_at_ms == null ? null : Number(row.heartbeat_at_ms),
|
|
530
|
+
id: row.id,
|
|
531
|
+
idempotencyKey: row.idempotency_key,
|
|
532
|
+
launchProtectedUntilMs: row.launch_protected_until_ms == null ? null : Number(row.launch_protected_until_ms),
|
|
533
|
+
mountIdentifier: row.mount_identifier,
|
|
534
|
+
ownerToken: row.owner_token ?? null,
|
|
535
|
+
project: row.project,
|
|
536
|
+
requestedAtMs: Number(row.requested_at_ms),
|
|
537
|
+
result: parseJson(row.result_json),
|
|
538
|
+
revision: row.revision,
|
|
539
|
+
stage: row.stage,
|
|
540
|
+
startedAtMs: row.started_at_ms == null ? null : Number(row.started_at_ms),
|
|
541
|
+
status: row.status
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* @param {string} context - Context.
|
|
546
|
+
* @param {unknown} error - Failure.
|
|
547
|
+
* @returns {void}
|
|
548
|
+
*/
|
|
549
|
+
_emitFrameworkError(context, error) {
|
|
550
|
+
const events = this.configuration.getErrorEvents();
|
|
551
|
+
const payload = { context, error };
|
|
552
|
+
events.emit("framework-error", payload);
|
|
553
|
+
events.emit("all-error", { ...payload, errorType: "framework-error" });
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* @template T
|
|
557
|
+
* @param {(db: any) => Promise<T>} callback - Work.
|
|
558
|
+
* @returns {Promise<T>} Result.
|
|
559
|
+
*/
|
|
560
|
+
async _withDb(callback) {
|
|
561
|
+
const pool = this.configuration.getDatabasePool(this.databaseIdentifier);
|
|
562
|
+
/** @type {T|undefined} */
|
|
563
|
+
let result;
|
|
564
|
+
await pool.withConnection({ name: "Rampway deployment run store" }, async (/** @type {any} */ db) => { result = await callback(db); });
|
|
565
|
+
return /** @type {T} */ (result);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
export { AUDIT_TABLE, RUNS_TABLE };
|
|
569
|
+
//# sourceMappingURL=run-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-store.js","sourceRoot":"","sources":["../../../src/velocious/run-store.js"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,aAAa,CAAA;AAClD,OAAO,SAAS,MAAM,kDAAkD,CAAA;AACxE,OAAO,UAAU,MAAM,wDAAwD,CAAA;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,MAAM,UAAU,GAAG,yBAAyB,CAAA;AAC5C,MAAM,WAAW,GAAG,qCAAqC,CAAA;AACzD,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,yBAAyB,CAAC,CAAA;AAC3E,MAAM,WAAW,GAAG,kCAAkC,CAAA;AACtD,MAAM,wBAAwB,GAAG,IAAI,CAAA;AACrC,MAAM,wBAAwB,GAAG,MAAM,CAAA;AACvC,MAAM,WAAW,GAAG,UAAU,EAAE,CAAA;AAChC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAE,CAAA;AAE9B;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAM,UAAU,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AS,EAAE,iBAAiB,EAAC,CAAC,CAAA;IACtE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,QAAQ;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QACxE,0BAA0B;QAC1B,IAAI,MAAM,CAAA;QACV,MAAM,IAAI,CAAC,cAAc,CAAC,EAAC,IAAI,EAAE,8BAA8B,EAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;QACnI,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;CACF;AAED,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an integration value to bounded JSON data while redacting secrets
|
|
3
|
+
* in values and keys. Colliding redacted keys are retained with stable suffixes.
|
|
4
|
+
*
|
|
5
|
+
* @param {unknown} value - Integration value.
|
|
6
|
+
* @param {string[]} secrets - Secrets to remove.
|
|
7
|
+
* @param {number} [depth] - Current depth.
|
|
8
|
+
* @returns {any} JSON-safe value or undefined.
|
|
9
|
+
*/
|
|
10
|
+
export function sanitizeAdapterValue(value: unknown, secrets: string[], depth?: number): any;
|
|
11
|
+
/**
|
|
12
|
+
* @param {unknown} error - Deployment failure.
|
|
13
|
+
* @param {string[]} secrets - Secrets to remove.
|
|
14
|
+
* @returns {{message: string, recovery: any}} Safe failure payload.
|
|
15
|
+
*/
|
|
16
|
+
export function sanitizeErrorPayload(error: unknown, secrets: string[]): {
|
|
17
|
+
message: string;
|
|
18
|
+
recovery: any;
|
|
19
|
+
};
|
|
20
|
+
export type SanitizerState = {
|
|
21
|
+
visited: number;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/velocious/sanitize.js"],"names":[],"mappings":"AA6BA;;;;;;;;GAQG;AACH,4CALW,OAAO,WACP,MAAM,EAAE,UACR,MAAM,GACJ,GAAG,CAef;AAiGD;;;;GAIG;AACH,4CAJW,OAAO,WACP,MAAM,EAAE,GACN;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAC,CAY5C;6BAvJa;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC"}
|