@loucompanion/forge-bridge 0.1.4-dev.bfa11ebe98c6 → 0.1.4-dev.d2d83bc81b6a
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 +1 -1
- package/dist/bridge/bridge.service.d.ts +9 -0
- package/dist/bridge/bridge.service.js +42 -4
- package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
- package/dist/bridge/dispatch-result-outbox.js +31 -6
- package/dist/cli/cli.help.js +2 -2
- package/dist/runtime/attempt-database-broker.d.ts +89 -0
- package/dist/runtime/attempt-database-broker.js +390 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +24 -0
- package/dist/runtime/attempt-process-supervisor.js +77 -3
- package/dist/runtime/host-diagnostics.js +4 -3
- package/dist/runtime/host-runtime-contract.js +69 -10
- package/dist/runtime/host-runtime-lease.d.ts +4 -2
- package/dist/runtime/host-runtime-lease.js +108 -24
- package/dist/runtime/managed-command-teardown.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +607 -0
- package/dist/runtime/node-host-runtime-adapter.js +5 -4
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +11 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +48 -54
- package/dist/sandbox/repository-lock.js +3 -2
- package/dist/sandbox/runtime.js +5 -4
- package/dist/session/managed-attempt-tools.d.ts +25 -0
- package/dist/session/managed-attempt-tools.js +222 -20
- package/dist/session/managed-build-coordinator.d.ts +1 -1
- package/dist/session/managed-build-coordinator.js +8 -4
- package/dist/session/phase-completion.runtime.js +30 -18
- package/dist/session/pre-publication-process.d.ts +20 -0
- package/dist/session/pre-publication-process.js +96 -0
- package/dist/session/pre-publication-validation.js +9 -54
- package/dist/session/provider-cli/provider-cli.process.d.ts +6 -1
- package/dist/session/provider-cli/provider-cli.process.js +198 -16
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +6 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +14 -0
- package/dist/session/provider-cli/provider-cli.service.js +10 -5
- package/dist/session/provider-cli/provider-usage.d.ts +2 -1
- package/dist/shared/process/host-process-recovery.js +3 -2
- package/dist/shared/process/host-process-supervisor.js +5 -4
- package/dist/shared/time/monotonic.d.ts +1 -0
- package/dist/shared/time/monotonic.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.js +74 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Show or change the saved server without editing `bridge.json`:
|
|
|
65
65
|
```bash
|
|
66
66
|
forge-bridge server show
|
|
67
67
|
forge-bridge server set http://localhost:5208
|
|
68
|
-
forge-bridge server set https://
|
|
68
|
+
forge-bridge server set https://forge.example.ts.net:8443
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
`FORGE_URL` overrides the saved server. Changing the saved URL retains runner credentials so aliases for the same deployment keep working; pair again with `--server` when switching to a different Forge deployment.
|
|
@@ -107,6 +107,15 @@ export declare class ForgeBridgeService implements BridgeService {
|
|
|
107
107
|
private sendResultPayloadDirect;
|
|
108
108
|
private flushDispatchResults;
|
|
109
109
|
private flushDispatchResultsCore;
|
|
110
|
+
/**
|
|
111
|
+
* Forge binds each result to the runner instance that ran the attempt. On an
|
|
112
|
+
* authoritative connection it rejects another instance's result with
|
|
113
|
+
* bridge.stale_result_instance; Forge's own recovery handles that attempt,
|
|
114
|
+
* so the record can never be delivered and must not block the replay queue.
|
|
115
|
+
* bridge.stale_runner_instance means this connection is not authoritative
|
|
116
|
+
* and says nothing about the record, so it never quarantines.
|
|
117
|
+
*/
|
|
118
|
+
private isReplacedRunnerInstanceResult;
|
|
110
119
|
private startHeartbeat;
|
|
111
120
|
private heartbeatTick;
|
|
112
121
|
private startLeaseWatchdog;
|
|
@@ -17,6 +17,7 @@ import { assertHostDatabaseCapabilityBoundary, establishHostDatabaseCapabilityBo
|
|
|
17
17
|
import { defaultHostExecutionRoot } from "../runtime/host-execution-root.js";
|
|
18
18
|
import { buildMemoryAdmissionDiagnostics } from "../runtime/memory-capacity.js";
|
|
19
19
|
import { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
|
|
20
|
+
import { createNativeTestClusterDatabaseBroker } from "../runtime/attempt-database-broker.js";
|
|
20
21
|
import { readNativeTestPostgresFallback } from "../runtime/native-test-postgres-fallback.js";
|
|
21
22
|
import { estimateWorkspaceBytesFromRepo } from "../runtime/workspace-resource-estimator.js";
|
|
22
23
|
import { GitWorktreeService } from "../worktree/worktree.service.js";
|
|
@@ -33,7 +34,7 @@ import { assertBridgeChatCallbackPayload, bridgeChatMaxProviderThreadIdChars, br
|
|
|
33
34
|
import { formatBytes } from "../shared/format/format-bytes.js";
|
|
34
35
|
import { emptyRunnerHostCapabilitySnapshot, ProcessRunnerHostCapabilityProbe, } from "./runner-host-capabilities.js";
|
|
35
36
|
import { FileReadinessResultOutbox } from "./readiness-result-outbox.js";
|
|
36
|
-
import { FileDispatchResultOutbox } from "./dispatch-result-outbox.js";
|
|
37
|
+
import { dispatchResultQuarantineDirectory, FileDispatchResultOutbox } from "./dispatch-result-outbox.js";
|
|
37
38
|
/**
|
|
38
39
|
* Protocol-v2 events are acknowledged one at a time before runOnce returns.
|
|
39
40
|
* Sending the complete transcript again in DispatchResult made long QA and CI
|
|
@@ -1467,6 +1468,19 @@ export class ForgeBridgeService {
|
|
|
1467
1468
|
await this.dispatchResultOutbox.acknowledge(pending.payload.leaseId);
|
|
1468
1469
|
continue;
|
|
1469
1470
|
}
|
|
1471
|
+
if (this.isReplacedRunnerInstanceResult(pending.payload, error)) {
|
|
1472
|
+
try {
|
|
1473
|
+
await this.dispatchResultOutbox.quarantine(pending);
|
|
1474
|
+
}
|
|
1475
|
+
catch (quarantineError) {
|
|
1476
|
+
// Keep the record and surface Forge's rejection: replay stays
|
|
1477
|
+
// deferred and a heartbeat tick does not count it as a failure.
|
|
1478
|
+
logBridgeStatus(`Dispatch result ${pending.payload.leaseId} from replaced runner instance ${pending.payload.runnerInstanceId} could not be quarantined: ${errorMessage(quarantineError)}`);
|
|
1479
|
+
throw error;
|
|
1480
|
+
}
|
|
1481
|
+
logBridgeStatus(`Quarantined dispatch result ${pending.payload.leaseId}: Forge rejected it because it belongs to replaced runner instance ${pending.payload.runnerInstanceId}. Forge's own recovery handles that instance's attempt; the redacted result is kept in ${dispatchResultQuarantineDirectory} for reconciliation.`);
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1470
1484
|
throw error;
|
|
1471
1485
|
}
|
|
1472
1486
|
}
|
|
@@ -1477,6 +1491,20 @@ export class ForgeBridgeService {
|
|
|
1477
1491
|
this.dispatchResultFlushedGeneration = startedGeneration;
|
|
1478
1492
|
}
|
|
1479
1493
|
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Forge binds each result to the runner instance that ran the attempt. On an
|
|
1496
|
+
* authoritative connection it rejects another instance's result with
|
|
1497
|
+
* bridge.stale_result_instance; Forge's own recovery handles that attempt,
|
|
1498
|
+
* so the record can never be delivered and must not block the replay queue.
|
|
1499
|
+
* bridge.stale_runner_instance means this connection is not authoritative
|
|
1500
|
+
* and says nothing about the record, so it never quarantines.
|
|
1501
|
+
*/
|
|
1502
|
+
isReplacedRunnerInstanceResult(payload, error) {
|
|
1503
|
+
return error instanceof BridgeCallbackRejectedError
|
|
1504
|
+
&& error.code === "bridge.stale_result_instance"
|
|
1505
|
+
&& typeof payload.runnerInstanceId === "string"
|
|
1506
|
+
&& payload.runnerInstanceId.toLowerCase() !== this.config.runnerInstanceId.toLowerCase();
|
|
1507
|
+
}
|
|
1480
1508
|
startHeartbeat() {
|
|
1481
1509
|
this.stopHeartbeat();
|
|
1482
1510
|
this.consecutiveHeartbeatFailures = 0;
|
|
@@ -1495,8 +1523,11 @@ export class ForgeBridgeService {
|
|
|
1495
1523
|
return;
|
|
1496
1524
|
this.heartbeatInFlight = true;
|
|
1497
1525
|
try {
|
|
1498
|
-
|
|
1499
|
-
|
|
1526
|
+
// A rejected replay is an answer from Forge, so the connection is alive:
|
|
1527
|
+
// an undeliverable record must not count as a heartbeat failure and
|
|
1528
|
+
// force reconnects. Transport failures still do.
|
|
1529
|
+
await this.flushDispatchResults().catch(deferRejectedReplay("Dispatch"));
|
|
1530
|
+
await this.flushReadinessResults().catch(deferRejectedReplay("Readiness"));
|
|
1500
1531
|
await this.sendHeartbeat();
|
|
1501
1532
|
this.consecutiveHeartbeatFailures = 0;
|
|
1502
1533
|
}
|
|
@@ -1879,6 +1910,13 @@ class BridgeCallbackRejectedError extends Error {
|
|
|
1879
1910
|
this.name = "BridgeCallbackRejectedError";
|
|
1880
1911
|
}
|
|
1881
1912
|
}
|
|
1913
|
+
function deferRejectedReplay(kind) {
|
|
1914
|
+
return error => {
|
|
1915
|
+
if (!(error instanceof BridgeCallbackRejectedError))
|
|
1916
|
+
throw error;
|
|
1917
|
+
logBridgeStatus(`${kind} result replay deferred: ${errorMessage(error)}`);
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1882
1920
|
function isDispatchNoLongerPending(error) {
|
|
1883
1921
|
if (error instanceof BridgeCallbackRejectedError) {
|
|
1884
1922
|
return error.code === "bridge.dispatch_not_pending" || error.code === "bridge.stale_dispatch";
|
|
@@ -1901,7 +1939,7 @@ function createDefaultSessionService(sandboxStateRoot, sandboxExecutionRoot, doc
|
|
|
1901
1939
|
const rawProcessRunner = new StreamingProviderProcessRunner();
|
|
1902
1940
|
const processSupervisors = new AttemptProcessSupervisorRegistry();
|
|
1903
1941
|
const coordinatedProcessRunner = new AttemptCoordinatedProviderProcessRunner(processSupervisors, rawProcessRunner);
|
|
1904
|
-
return new BridgeSessionService(new GitWorktreeService(undefined, new RepositoryCoordinatorLock(sandboxStateRoot)), new RoutingProviderCliService(new ProcessBackedProviderCliService(coordinatedProcessRunner, undefined, undefined, undefined, new PrePublicationValidator(undefined, dockerEngineProbe, readNativeTestPostgresFallback))), new HostRuntimeLeaseManager(sandboxStateRoot, undefined, undefined, processSupervisors, rawProcessRunner, undefined, undefined, undefined, undefined, undefined, sandboxExecutionRoot));
|
|
1942
|
+
return new BridgeSessionService(new GitWorktreeService(undefined, new RepositoryCoordinatorLock(sandboxStateRoot)), new RoutingProviderCliService(new ProcessBackedProviderCliService(coordinatedProcessRunner, undefined, undefined, undefined, new PrePublicationValidator(undefined, dockerEngineProbe, readNativeTestPostgresFallback))), new HostRuntimeLeaseManager(sandboxStateRoot, undefined, undefined, processSupervisors, rawProcessRunner, undefined, undefined, undefined, undefined, undefined, sandboxExecutionRoot, createNativeTestClusterDatabaseBroker(readNativeTestPostgresFallback, sandboxStateRoot)));
|
|
1905
1943
|
}
|
|
1906
1944
|
export class SignalRBridgeConnectionFactory {
|
|
1907
1945
|
create(config) {
|
|
@@ -8,7 +8,14 @@ export interface DispatchResultOutbox {
|
|
|
8
8
|
persist(payload: BridgeDispatchResultCallback): Promise<void>;
|
|
9
9
|
pending(): Promise<readonly DurableDispatchResult[]>;
|
|
10
10
|
acknowledge(leaseId: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Moves an undeliverable record out of the replay set. The redacted result
|
|
13
|
+
* is kept, with its original persistedAt, so preserved work can be reconciled.
|
|
14
|
+
*/
|
|
15
|
+
quarantine(record: DurableDispatchResult): Promise<void>;
|
|
11
16
|
}
|
|
17
|
+
export declare const dispatchResultOutboxDirectory = "dispatch-results";
|
|
18
|
+
export declare const dispatchResultQuarantineDirectory = "dispatch-results-quarantine";
|
|
12
19
|
/**
|
|
13
20
|
* Persists the already-redacted terminal result before the Bridge attempts its
|
|
14
21
|
* SignalR callback. A transport or API restart can therefore delay delivery,
|
|
@@ -16,10 +23,13 @@ export interface DispatchResultOutbox {
|
|
|
16
23
|
*/
|
|
17
24
|
export declare class FileDispatchResultOutbox implements DispatchResultOutbox {
|
|
18
25
|
private readonly stateRoot;
|
|
26
|
+
private readonly directory;
|
|
19
27
|
private readonly writes;
|
|
20
|
-
constructor(stateRoot: string);
|
|
28
|
+
constructor(stateRoot: string, directory?: string);
|
|
21
29
|
persist(payload: BridgeDispatchResultCallback): Promise<void>;
|
|
30
|
+
private persistRecord;
|
|
22
31
|
pending(): Promise<readonly DurableDispatchResult[]>;
|
|
23
32
|
acknowledge(leaseId: string): Promise<void>;
|
|
33
|
+
quarantine(record: DurableDispatchResult): Promise<void>;
|
|
24
34
|
private operate;
|
|
25
35
|
}
|
|
@@ -3,6 +3,8 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
3
3
|
import { assertCanonicalDirectory, createCanonicalDirectory } from "../runtime/attempt-private-directory.js";
|
|
4
4
|
import { runPinnedDirectoryProcess } from "../runtime/pinned-directory-process.js";
|
|
5
5
|
import { dispatchResultReceiptWorker } from "./dispatch-result-worker.js";
|
|
6
|
+
export const dispatchResultOutboxDirectory = "dispatch-results";
|
|
7
|
+
export const dispatchResultQuarantineDirectory = "dispatch-results-quarantine";
|
|
6
8
|
/**
|
|
7
9
|
* Persists the already-redacted terminal result before the Bridge attempts its
|
|
8
10
|
* SignalR callback. A transport or API restart can therefore delay delivery,
|
|
@@ -10,11 +12,16 @@ import { dispatchResultReceiptWorker } from "./dispatch-result-worker.js";
|
|
|
10
12
|
*/
|
|
11
13
|
export class FileDispatchResultOutbox {
|
|
12
14
|
stateRoot;
|
|
15
|
+
directory;
|
|
13
16
|
writes = new Map();
|
|
14
|
-
constructor(stateRoot) {
|
|
17
|
+
constructor(stateRoot, directory = dispatchResultOutboxDirectory) {
|
|
15
18
|
this.stateRoot = stateRoot;
|
|
19
|
+
this.directory = directory;
|
|
16
20
|
}
|
|
17
21
|
async persist(payload) {
|
|
22
|
+
await this.persistRecord(payload, new Date().toISOString());
|
|
23
|
+
}
|
|
24
|
+
async persistRecord(payload, persistedAt) {
|
|
18
25
|
const name = recordName(payload.leaseId);
|
|
19
26
|
const value = JSON.parse(JSON.stringify({ payload }));
|
|
20
27
|
const pending = this.writes.get(name);
|
|
@@ -27,7 +34,7 @@ export class FileDispatchResultOutbox {
|
|
|
27
34
|
const write = this.operate({
|
|
28
35
|
kind: "persist",
|
|
29
36
|
name,
|
|
30
|
-
record: { schemaVersion: 1, persistedAt
|
|
37
|
+
record: { schemaVersion: 1, persistedAt, ...value },
|
|
31
38
|
}).then(() => undefined);
|
|
32
39
|
this.writes.set(name, { value, write });
|
|
33
40
|
try {
|
|
@@ -44,8 +51,23 @@ export class FileDispatchResultOutbox {
|
|
|
44
51
|
async acknowledge(leaseId) {
|
|
45
52
|
await this.operate({ kind: "acknowledge", name: recordName(leaseId) });
|
|
46
53
|
}
|
|
54
|
+
async quarantine(record) {
|
|
55
|
+
// One execution lease can carry several dispatch attempts, so quarantine
|
|
56
|
+
// files are grouped per attempt: <quarantine>/<attempt>/<lease>.json.
|
|
57
|
+
// Copy before removal: a crash in between leaves an identical record in
|
|
58
|
+
// both places, and the next replay quarantines it again idempotently.
|
|
59
|
+
// A record without an attempt id has no per-attempt bucket; the caller
|
|
60
|
+
// keeps it deferred rather than grouping unrelated attempts together.
|
|
61
|
+
const { payload } = record;
|
|
62
|
+
if (!payload.dispatchAttemptId) {
|
|
63
|
+
throw new Error("dispatch_result_invalid: only attempt-bound results can be quarantined.");
|
|
64
|
+
}
|
|
65
|
+
const bucket = path.join(dispatchResultQuarantineDirectory, compactUuid(payload.dispatchAttemptId));
|
|
66
|
+
await new FileDispatchResultOutbox(this.stateRoot, bucket).persistRecord(payload, record.persistedAt);
|
|
67
|
+
await this.acknowledge(payload.leaseId);
|
|
68
|
+
}
|
|
47
69
|
async operate(operation) {
|
|
48
|
-
const root = path.resolve(this.stateRoot,
|
|
70
|
+
const root = path.resolve(this.stateRoot, this.directory);
|
|
49
71
|
await createCanonicalDirectory(root);
|
|
50
72
|
const identity = await assertCanonicalDirectory(root);
|
|
51
73
|
if (!identity)
|
|
@@ -54,9 +76,12 @@ export class FileDispatchResultOutbox {
|
|
|
54
76
|
}
|
|
55
77
|
}
|
|
56
78
|
function recordName(leaseId) {
|
|
57
|
-
|
|
79
|
+
return `${compactUuid(leaseId)}.json`;
|
|
80
|
+
}
|
|
81
|
+
function compactUuid(id) {
|
|
82
|
+
const value = id.replaceAll("-", "").toLowerCase();
|
|
58
83
|
if (!/^[0-9a-f]{32}$/u.test(value)) {
|
|
59
|
-
throw new Error("dispatch_result_invalid:
|
|
84
|
+
throw new Error("dispatch_result_invalid: identifiers must be UUIDs.");
|
|
60
85
|
}
|
|
61
|
-
return
|
|
86
|
+
return value;
|
|
62
87
|
}
|
package/dist/cli/cli.help.js
CHANGED
|
@@ -28,7 +28,7 @@ export function helpText() {
|
|
|
28
28
|
"",
|
|
29
29
|
"Examples:",
|
|
30
30
|
" npm install -g @loucompanion/forge-bridge@next",
|
|
31
|
-
" forge-bridge pair 1234-5678 --server https://
|
|
31
|
+
" forge-bridge pair 1234-5678 --server https://forge.example.ts.net:8443 --repo-root \"%USERPROFILE%\\ForgeRepos\"",
|
|
32
32
|
" forge-bridge connect",
|
|
33
33
|
" forge-bridge status --check-updates",
|
|
34
34
|
" forge-bridge server set http://localhost:5208",
|
|
@@ -116,7 +116,7 @@ export function commandHelpText(command) {
|
|
|
116
116
|
"",
|
|
117
117
|
"Examples:",
|
|
118
118
|
" forge-bridge server set http://localhost:5208",
|
|
119
|
-
" forge-bridge server set https://
|
|
119
|
+
" forge-bridge server set https://forge.example.ts.net:8443",
|
|
120
120
|
"",
|
|
121
121
|
].join("\n");
|
|
122
122
|
case "add-repo":
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { NativeTestPostgresFallback } from "./native-test-postgres-fallback.js";
|
|
2
|
+
/**
|
|
3
|
+
* The managed host attempt's database capability. The Bridge keeps the test cluster's
|
|
4
|
+
* administrator credential; an attempt (its agent, its application runtime and its tests)
|
|
5
|
+
* receives only a login for one database created for it. Forge.Api checks that login before it
|
|
6
|
+
* migrates (AttemptScopedDatabasePolicy.AssertBrokeredCapabilityAsync), but that check runs in
|
|
7
|
+
* attempt code: the boundary is what this broker issues and the cluster's pg_hba rules, which
|
|
8
|
+
* let an attempt role log in only to its own database.
|
|
9
|
+
*/
|
|
10
|
+
export declare const attemptDatabaseCapabilityEnvironment = "FORGE_ATTEMPT_DATABASE_CAPABILITY";
|
|
11
|
+
export interface AttemptDatabaseCapability {
|
|
12
|
+
readonly databaseName: string;
|
|
13
|
+
readonly connectionString: string;
|
|
14
|
+
}
|
|
15
|
+
export type AttemptDatabaseReleaseOutcome = "dropped" | "missing" | "retained";
|
|
16
|
+
export interface AttemptDatabaseBroker {
|
|
17
|
+
provision(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal): Promise<AttemptDatabaseCapability>;
|
|
18
|
+
release(dispatchAttemptId: string, fencingToken: string): Promise<AttemptDatabaseReleaseOutcome>;
|
|
19
|
+
/**
|
|
20
|
+
* Drops this broker's databases whose attempt is no longer live, asking `isLive` about each one
|
|
21
|
+
* just before acting on it. Returns the dropped names.
|
|
22
|
+
*/
|
|
23
|
+
reapOrphans(isLive: (dispatchAttemptId: string) => boolean): Promise<readonly string[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare class AttemptDatabaseBrokerError extends Error {
|
|
26
|
+
readonly code: string;
|
|
27
|
+
constructor(code: string, detail: string);
|
|
28
|
+
}
|
|
29
|
+
export interface AttemptDatabaseLogin {
|
|
30
|
+
readonly database: string;
|
|
31
|
+
readonly username: string;
|
|
32
|
+
readonly password: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Runs one psql script and returns its unaligned output: as the cluster administrator against
|
|
36
|
+
* `postgres`, or, given a login, as that login against its database.
|
|
37
|
+
*/
|
|
38
|
+
export type AttemptDatabaseSqlRunner = (sql: string, signal?: AbortSignal, login?: AttemptDatabaseLogin) => Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* The ownership marker on the attempt's role. Only a role with CREATEROLE can change a role's
|
|
41
|
+
* comment, so the attempt cannot forge or erase it (it can rewrite its database's comment, which
|
|
42
|
+
* is therefore informational). Must match AttemptScopedDatabasePolicy.BrokeredRoleMarkerPrefix.
|
|
43
|
+
*/
|
|
44
|
+
export declare function brokeredDatabaseMarker(dispatchAttemptId: string, fencingToken: string, owner: string): string;
|
|
45
|
+
export declare function attemptDatabaseName(dispatchAttemptId: string): string;
|
|
46
|
+
/** Identifies one Bridge's broker on a shared cluster, so it reaps only databases it issued. */
|
|
47
|
+
export declare function attemptDatabaseBrokerOwner(stateRoot: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Brokers attempt databases on the dedicated native test cluster that
|
|
50
|
+
* scripts/setup-native-test-postgres.ps1 provisions. That cluster holds only disposable test
|
|
51
|
+
* databases, so even a leaked attempt capability cannot reach developer data. Each attempt
|
|
52
|
+
* gets a login role and a database it owns, cloned from template1 (which carries pgvector,
|
|
53
|
+
* an extension an unprivileged owner cannot create).
|
|
54
|
+
*/
|
|
55
|
+
export declare class NativeTestClusterDatabaseBroker implements AttemptDatabaseBroker {
|
|
56
|
+
private readonly admin;
|
|
57
|
+
private readonly runSql;
|
|
58
|
+
private readonly owner;
|
|
59
|
+
private readonly delay;
|
|
60
|
+
/** Names being provisioned right now; the reaper leaves them alone. */
|
|
61
|
+
private readonly provisioning;
|
|
62
|
+
constructor(admin: NativeTestClusterAdmin, runSql: AttemptDatabaseSqlRunner, owner: string, delay?: (milliseconds: number) => Promise<void>);
|
|
63
|
+
provision(dispatchAttemptId: string, fencingToken: string, signal?: AbortSignal): Promise<AttemptDatabaseCapability>;
|
|
64
|
+
release(dispatchAttemptId: string, fencingToken: string): Promise<AttemptDatabaseReleaseOutcome>;
|
|
65
|
+
reapOrphans(isLive: (dispatchAttemptId: string) => boolean): Promise<readonly string[]>;
|
|
66
|
+
private state;
|
|
67
|
+
private createDatabase;
|
|
68
|
+
/** Fails closed unless the cluster lets this login reach its own database and nothing else. */
|
|
69
|
+
private assertConfinedToOwnDatabase;
|
|
70
|
+
private drop;
|
|
71
|
+
}
|
|
72
|
+
export interface NativeTestClusterAdmin {
|
|
73
|
+
readonly host: string;
|
|
74
|
+
readonly port: number;
|
|
75
|
+
readonly username: string;
|
|
76
|
+
readonly password: string;
|
|
77
|
+
}
|
|
78
|
+
export declare function nativeTestClusterAdmin(fallback: NativeTestPostgresFallback): NativeTestClusterAdmin;
|
|
79
|
+
/** Runs SQL through the psql that ships with the PostgreSQL install hosting the native test cluster. */
|
|
80
|
+
export declare function psqlSqlRunner(admin: NativeTestClusterAdmin, psqlPath: string, timeoutMs?: number): AttemptDatabaseSqlRunner;
|
|
81
|
+
/** psql beside the cluster's pg_ctl: FORGE_NATIVE_TEST_POSTGRES_PSQL, a Windows install, or PATH. */
|
|
82
|
+
export declare function resolvePsqlPath(): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* The broker for this host, or null when no native test cluster is provisioned. Without a
|
|
85
|
+
* broker, Forge.Api still refuses to start in a managed host attempt; other applications run.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createNativeTestClusterDatabaseBroker(readFallback: () => NativeTestPostgresFallback | null, stateRoot: string): AttemptDatabaseBroker | null;
|
|
88
|
+
/** The exact strings to redact wherever a capability may be printed: the whole value and its password. */
|
|
89
|
+
export declare function attemptDatabaseCapabilitySecrets(capability: string | undefined): readonly string[];
|