@loucompanion/forge-bridge 0.1.3-dev.8687c5099dce → 0.1.3-dev.88e93f53db5b

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.
Files changed (75) hide show
  1. package/README.md +18 -1
  2. package/dist/bridge/bridge.base.d.ts +2 -0
  3. package/dist/bridge/bridge.service.d.ts +25 -1
  4. package/dist/bridge/bridge.service.js +341 -74
  5. package/dist/bridge/bridge.types.d.ts +4 -0
  6. package/dist/cleanup/cleanup.service.d.ts +1 -0
  7. package/dist/cleanup/cleanup.service.js +70 -9
  8. package/dist/cli/cli.service.js +9 -4
  9. package/dist/runtime/aspnet-runtime-prebuild.d.ts +36 -0
  10. package/dist/runtime/aspnet-runtime-prebuild.js +340 -0
  11. package/dist/runtime/attempt-node-runtime-launcher.js +5 -1
  12. package/dist/runtime/attempt-process-supervisor.d.ts +11 -0
  13. package/dist/runtime/attempt-process-supervisor.js +36 -2
  14. package/dist/runtime/host-listener-inspector.d.ts +2 -0
  15. package/dist/runtime/host-listener-inspector.js +25 -0
  16. package/dist/runtime/host-runtime-lease.d.ts +66 -5
  17. package/dist/runtime/host-runtime-lease.js +714 -38
  18. package/dist/runtime/memory-capacity.d.ts +68 -0
  19. package/dist/runtime/memory-capacity.js +121 -0
  20. package/dist/runtime/node-host-runtime-adapter.d.ts +3 -0
  21. package/dist/runtime/node-host-runtime-adapter.js +24 -8
  22. package/dist/runtime/playwright-host-runtime-adapter.d.ts +1 -0
  23. package/dist/runtime/playwright-host-runtime-adapter.js +5 -0
  24. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  25. package/dist/runtime/workspace-resource-estimator.js +174 -0
  26. package/dist/sandbox/preflight.d.ts +31 -1
  27. package/dist/sandbox/preflight.js +237 -51
  28. package/dist/sandbox/repository-lock.js +4 -2
  29. package/dist/sandbox/sandbox.types.d.ts +7 -0
  30. package/dist/session/managed-attempt-tools.d.ts +7 -1
  31. package/dist/session/managed-attempt-tools.js +257 -13
  32. package/dist/session/managed-build-coordinator.d.ts +5 -0
  33. package/dist/session/managed-build-coordinator.js +105 -0
  34. package/dist/session/managed-build-receipt.d.ts +21 -0
  35. package/dist/session/managed-build-receipt.js +335 -0
  36. package/dist/session/phase-completion.artifacts.d.ts +17 -0
  37. package/dist/session/phase-completion.artifacts.js +224 -22
  38. package/dist/session/phase-completion.prompts.js +2 -2
  39. package/dist/session/phase-completion.runtime.js +10 -3
  40. package/dist/session/phase-completion.schemas.js +1 -1
  41. package/dist/session/phase-completion.validation.js +7 -3
  42. package/dist/session/provider-cli/ci-repair-readiness.d.ts +6 -0
  43. package/dist/session/provider-cli/ci-repair-readiness.js +12 -2
  44. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
  45. package/dist/session/provider-cli/provider-cli.artifacts.js +37 -3
  46. package/dist/session/provider-cli/provider-cli.process.d.ts +7 -0
  47. package/dist/session/provider-cli/provider-cli.process.js +218 -17
  48. package/dist/session/provider-cli/provider-cli.prompts.js +17 -4
  49. package/dist/session/provider-cli/provider-cli.runtime.js +3 -1
  50. package/dist/session/provider-cli/provider-cli.service.d.ts +5 -2
  51. package/dist/session/provider-cli/provider-cli.service.js +83 -34
  52. package/dist/session/provider-cli/provider-output-state.js +61 -14
  53. package/dist/session/provider-cli/provider-usage.d.ts +7 -0
  54. package/dist/session/provider-cli/provider-usage.js +28 -5
  55. package/dist/session/session-redaction.js +16 -1
  56. package/dist/session/session.service.js +81 -9
  57. package/dist/session/session.types.d.ts +15 -0
  58. package/dist/session/session.types.js +3 -1
  59. package/dist/shared/format/format-bytes.d.ts +1 -0
  60. package/dist/shared/format/format-bytes.js +9 -0
  61. package/dist/shared/path/path.d.ts +1 -0
  62. package/dist/shared/path/path.js +18 -0
  63. package/dist/shared/process/host-process-supervisor.d.ts +2 -0
  64. package/dist/shared/process/host-process-supervisor.js +57 -9
  65. package/dist/shared/redaction/redaction.js +6 -1
  66. package/dist/version.d.ts +1 -1
  67. package/dist/version.js +1 -1
  68. package/dist/worktree/dependency-warmer.d.ts +18 -0
  69. package/dist/worktree/dependency-warmer.js +218 -8
  70. package/dist/worktree/index.d.ts +1 -1
  71. package/dist/worktree/worktree.service.d.ts +2 -0
  72. package/dist/worktree/worktree.service.js +158 -17
  73. package/dist/worktree/worktree.types.d.ts +2 -0
  74. package/package.json +3 -2
  75. package/runtime/windows-job-supervisor.ps1 +89 -1
package/README.md CHANGED
@@ -101,7 +101,9 @@ Production shared runners require a Linux rootless Docker daemon. Docker Desktop
101
101
  - `FORGE_DOCKER_CONTEXT` / `FORGE_DOCKER_EXECUTABLE` — dedicated daemon selection.
102
102
  - `FORGE_SANDBOX_STATE_ROOT` — fsync'd attempt ledgers, restricted diagnostics, and build state.
103
103
  - `FORGE_DISK_HIGH_WATERMARK_PERCENT` / `FORGE_DISK_LOW_WATERMARK_PERCENT` / `FORGE_MINIMUM_WORKSPACE_BYTES` — admission watermarks with high/low hysteresis.
104
- - `FORGE_SANDBOX_HOST_MEMORY_RESERVE_BYTES` — host memory withheld from sandbox admission. The default is 2 GiB, or 1 GiB when Docker Desktop developer mode is explicitly enabled; production Linux/rootless runners retain 2 GiB unless an operator supplies a measured override.
104
+ - Per-attempt workspace reservations are calculated from the repository source footprint, detected Node/.NET/browser toolchains, the execution role, and immutable sandbox app services. The API uses that request for local and Bridge placement; a Bridge rechecks its authoritative checkout and Docker contract before acceptance. Shared Docker images and package caches remain runner-level capacity, while `FORGE_MINIMUM_WORKSPACE_BYTES` remains a separate host safety reserve rather than a per-lane charge.
105
+ - `FORGE_SANDBOX_HOST_MEMORY_RESERVE_BYTES` — explicit host-memory safety-reserve override for sandbox admission. Without an override, Forge derives a bounded reserve from the sampled capacity domain (Linux: 12.5%, 1–4 GiB; Docker Desktop development: 6.25%, 1–2 GiB). The floor, ceiling, and percentage are configurable with `FORGE_SANDBOX_HOST_MEMORY_RESERVE_FLOOR_BYTES`, `FORGE_SANDBOX_HOST_MEMORY_RESERVE_CEILING_BYTES`, and `FORGE_SANDBOX_HOST_MEMORY_RESERVE_PERCENT`.
106
+ - Managed-host admission uses the same bounded 12.5% physical-memory policy through `FORGE_HOST_MEMORY_RESERVE_BYTES` or its `_FLOOR_BYTES`, `_CEILING_BYTES`, and `_PERCENT` controls. Pressure is applied immediately; recovery requires two samples one second apart by default (`FORGE_HOST_MEMORY_RECOVERY_SAMPLES` and `FORGE_HOST_MEMORY_RECOVERY_SAMPLE_INTERVAL_MS`). `FORGE_HOST_DEFAULT_WORKER_MEMORY_LIMIT_BYTES` configures only the conservative cold-start fallback for legacy packets that omit an exact worker request; current packets remain governed by their explicit role request.
105
107
  - `FORGE_SANDBOX_MEMORY_SAMPLE_INTERVAL_MS` — interval for sampled Docker peak-memory telemetry (default `1000` ms, clamped to `250`–`30000` ms). Sampling is diagnostic and never changes an attempt outcome.
106
108
  - `FORGE_SANDBOX_DEDICATED_DISK=true` — operator assertion that sandbox storage is on a dedicated, conservatively watermarked disk when the Docker storage driver cannot enforce per-volume quotas. `sandbox_required` fails placement unless either quota support or this assertion is advertised.
107
109
  - `FORGE_SANDBOX_IMAGE_RETENTION_COUNT` / `FORGE_SANDBOX_IMAGE_RETENTION_TTL_MS` — per-project image-cache retention (defaults: 3 images and 7 days).
@@ -131,6 +133,21 @@ In `bridge_push` mode, the start packet carries only an attempt/fence/branch-bou
131
133
 
132
134
  Failed project, tooling, and agent image stages preserve only a redacted, capped, mode-0600 diagnostic at `FORGE_SANDBOX_STATE_ROOT/build-logs/<image-key>/<stage>.log`. The event stream carries its digest, byte count, and truncation flag, never the log contents. Treat this directory as restricted source-bearing audit data and apply local retention controls.
133
135
 
136
+ ## Owned test evidence
137
+
138
+ `npm test` closes a manifest over the complete Bridge source, test, runtime, configuration, workflow,
139
+ and imported fixture set before compilation. It records the Git commit and exact Node, npm, Git, .NET,
140
+ TypeScript, Vitest, OS, and temporary-root identities, compiles into an owned temporary root, runs
141
+ Vitest through the Windows process-tree supervisor, revalidates the source and toolchain, independently
142
+ rehashes the compiled output, and removes the exact owner root before reporting success.
143
+
144
+ Set `FORGE_BRIDGE_SUITE_RECEIPT_PATH` to an absolute path for a nonexistent output file to retain the
145
+ verified execution receipt. On Windows evidence runs, `TEMP`, `TMP`, `TMPDIR`, and `FORGE_TMPDIR` may
146
+ point to the same short, empty, high-capacity root. This changes only owned temporary-file placement; it
147
+ does not weaken disk, memory, cleanup, or Docker preflight policy. A Bridge receipt remains
148
+ `fullGateAttested=false` until the suite is registered with the live residue auditor and the required
149
+ source/toolchain-identical repeat evidence is complete.
150
+
134
151
  ## Package smoke check
135
152
 
136
153
  From this package directory:
@@ -8,6 +8,8 @@ export interface BridgeConnection {
8
8
  start(): Promise<void>;
9
9
  stop(): Promise<void>;
10
10
  onClose(handler: (error?: Error) => void): void;
11
+ onReconnecting?(handler: (error?: Error) => void): void;
12
+ onReconnected?(handler: (connectionId?: string) => void | Promise<void>): void;
11
13
  onDispatch(handler: BridgeDispatchHandler): void;
12
14
  onOffer?(handler: BridgeOfferHandler): void;
13
15
  onStart?(handler: BridgeStartHandler): void;
@@ -1,5 +1,5 @@
1
1
  import type { SessionService } from "../session/session.base.js";
2
- import { type DispatchSandboxResourceRequest, type RunOnceDispatchPacket } from "../session/session.types.js";
2
+ import { type DispatchSandboxResourceRequest, type RunOnceDispatchPacket, type RunOnceResultPacket } from "../session/session.types.js";
3
3
  import { DockerPreflight } from "../sandbox/preflight.js";
4
4
  import type { SandboxPreflightResult } from "../sandbox/sandbox.types.js";
5
5
  import { type SandboxRuntime } from "../sandbox/runtime.js";
@@ -10,6 +10,15 @@ export interface ResolvedSandboxResourceProfile {
10
10
  readonly resources: DispatchSandboxResourceRequest;
11
11
  readonly sandboxConfigCommitSha: string;
12
12
  }
13
+ /**
14
+ * Protocol-v2 events are acknowledged one at a time before runOnce returns.
15
+ * Sending the complete transcript again in DispatchResult made long QA and CI
16
+ * sessions exceed SignalR's receive limit, disconnecting the bridge after the
17
+ * provider had already completed. The API combines its acknowledged streamed
18
+ * events with the terminal result, so the callback only needs the outcome and
19
+ * artifacts. Protocol v1 retains the transcript for legacy servers.
20
+ */
21
+ export declare function compactTerminalResult(dispatch: RunOnceDispatchPacket, result: RunOnceResultPacket): RunOnceResultPacket;
13
22
  export declare class ForgeBridgeService implements BridgeService {
14
23
  private readonly config;
15
24
  private readonly connections;
@@ -22,6 +31,8 @@ export declare class ForgeBridgeService implements BridgeService {
22
31
  private sandboxMaintenanceTimer;
23
32
  private sandboxMaintenanceRunning;
24
33
  private closed;
34
+ private transportRecovery;
35
+ private transportRecoveryGeneration;
25
36
  private stopped;
26
37
  private readonly activeSessions;
27
38
  private readonly reservations;
@@ -30,12 +41,15 @@ export declare class ForgeBridgeService implements BridgeService {
30
41
  private readonly sandboxRuntime;
31
42
  private readonly sandboxResourceResolver;
32
43
  private readonly sessions;
44
+ private sandboxAmbientMemoryCommitmentBytes;
33
45
  constructor(config: BridgeServiceConfig, sessions?: SessionService | undefined, connections?: BridgeConnectionFactory, preflight?: DockerPreflight, sandboxRuntime?: SandboxRuntime, sandboxResourceResolver?: SandboxResourceResolver);
34
46
  connectOnce(): Promise<void>;
47
+ private registerConnection;
35
48
  run(signal?: AbortSignal): Promise<void>;
36
49
  stop(): Promise<void>;
37
50
  private handleDispatch;
38
51
  private handleOffer;
52
+ private commitOfferReservation;
39
53
  private handleStart;
40
54
  private redeemSecretGrant;
41
55
  private redeemPublishGrant;
@@ -56,6 +70,7 @@ export declare class ForgeBridgeService implements BridgeService {
56
70
  private startLeaseWatchdog;
57
71
  private stopLeaseWatchdog;
58
72
  private expireLeases;
73
+ private expireReservations;
59
74
  private stopHeartbeat;
60
75
  private startSandboxMaintenance;
61
76
  private stopSandboxMaintenance;
@@ -68,6 +83,9 @@ export declare class ForgeBridgeService implements BridgeService {
68
83
  private activeSandboxResources;
69
84
  private sandboxResourceCapacity;
70
85
  private invokeAck;
86
+ private beginTransportRecovery;
87
+ private completeTransportRecovery;
88
+ private waitForTransportRecovery;
71
89
  private waitForClose;
72
90
  private stopConnection;
73
91
  }
@@ -81,6 +99,8 @@ export declare class SignalRBridgeConnection implements BridgeConnection {
81
99
  start(): Promise<void>;
82
100
  stop(): Promise<void>;
83
101
  onClose(handler: (error?: Error) => void): void;
102
+ onReconnecting(handler: (error?: Error) => void): void;
103
+ onReconnected(handler: (connectionId?: string) => void | Promise<void>): void;
84
104
  onDispatch(handler: BridgeDispatchHandler): void;
85
105
  onOffer(handler: BridgeDispatchHandler): void;
86
106
  onStart(handler: BridgeDispatchHandler): void;
@@ -92,12 +112,16 @@ export declare class SignalRBridgeConnection implements BridgeConnection {
92
112
  }
93
113
  export declare function defaultBridgeServiceConfig(overrides?: Partial<BridgeServiceConfig>): BridgeServiceConfig;
94
114
  export declare function resolveBridgeRunnerHubUrl(serverUrl: string): URL;
115
+ export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
116
+ export declare function waitForPromiseOrAbort(promise: Promise<unknown>, signal?: AbortSignal): Promise<void>;
95
117
  export declare function canReapManagedSandboxes(preflight: {
96
118
  readonly healthy: boolean;
97
119
  readonly unavailableCode?: string | null;
98
120
  }): boolean;
121
+ export declare function infrastructureFailureEventType(summary: string): string | null;
99
122
  export type SandboxResourceVector = DispatchSandboxResourceRequest;
100
123
  export declare function canReserveSandboxResources(used: SandboxResourceVector, requested: SandboxResourceVector, capacity: SandboxResourceVector): boolean;
124
+ export declare function sandboxMemoryCommitmentCapacity(preflight: Pick<SandboxPreflightResult, "totalMemoryBytes" | "availableMemoryBytes" | "hostReserveBytes">, activeMemoryBytes: number, ambientMemoryCommitmentBytes?: number): number;
101
125
  export declare function sandboxCapacityFailureMessage(used: SandboxResourceVector, requested: SandboxResourceVector, capacity: SandboxResourceVector, preflight: SandboxPreflightResult | null, config: BridgeServiceConfig): string;
102
126
  export declare function resolveDynamicSandboxResources(requested: DispatchSandboxResourceRequest, serviceCount: number, networkMode: "offline" | "public_allowlist" | "open_public", baseRuntimeOverheadBytes?: number): DispatchSandboxResourceRequest;
103
127
  export declare function resolveSandboxResourcesFromRepo(dispatch: RunOnceDispatchPacket, baseRuntimeOverheadBytes?: number): Promise<ResolvedSandboxResourceProfile>;