@loucompanion/forge-bridge 0.1.4-dev.9e8a5b93cbcb → 0.1.4-dev.a5a3a7ab2f02

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 (158) hide show
  1. package/README.md +35 -2
  2. package/dist/bridge/bridge.base.d.ts +9 -0
  3. package/dist/bridge/bridge.service.d.ts +84 -2
  4. package/dist/bridge/bridge.service.js +357 -12
  5. package/dist/bridge/bridge.types.d.ts +22 -0
  6. package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
  7. package/dist/bridge/dispatch-result-outbox.js +31 -6
  8. package/dist/bridge/local-yield-flag.d.ts +6 -0
  9. package/dist/bridge/local-yield-flag.js +34 -0
  10. package/dist/bridge/runner-host-capabilities.d.ts +2 -0
  11. package/dist/bridge/runner-host-capabilities.js +4 -0
  12. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  13. package/dist/bridge/test-postgres-capability.js +120 -0
  14. package/dist/cleanup/cleanup.service.d.ts +9 -0
  15. package/dist/cleanup/cleanup.service.js +72 -109
  16. package/dist/cleanup/cleanup.types.d.ts +4 -0
  17. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  18. package/dist/cleanup/forge-owned-paths.js +53 -0
  19. package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
  20. package/dist/cleanup/host-runtime-ledger.js +109 -0
  21. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  22. package/dist/cleanup/managed-branch-sweep.js +111 -0
  23. package/dist/cli/cli.help.js +18 -0
  24. package/dist/cli/cli.service.d.ts +16 -0
  25. package/dist/cli/cli.service.js +142 -16
  26. package/dist/cli/local-config.d.ts +4 -0
  27. package/dist/cli/local-config.js +26 -4
  28. package/dist/runtime/aspnet-runtime-prebuild.js +94 -6
  29. package/dist/runtime/attempt-process-supervisor.d.ts +19 -0
  30. package/dist/runtime/attempt-process-supervisor.js +50 -0
  31. package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
  32. package/dist/runtime/host-database-capability-boundary.js +1 -0
  33. package/dist/runtime/host-facts.d.ts +35 -0
  34. package/dist/runtime/host-facts.js +95 -0
  35. package/dist/runtime/host-load-admission.d.ts +60 -0
  36. package/dist/runtime/host-load-admission.js +99 -0
  37. package/dist/runtime/host-load-child-environment.d.ts +22 -0
  38. package/dist/runtime/host-load-child-environment.js +67 -0
  39. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  40. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  41. package/dist/runtime/host-load-governor-config.d.ts +43 -0
  42. package/dist/runtime/host-load-governor-config.js +76 -0
  43. package/dist/runtime/host-load-governor.d.ts +174 -0
  44. package/dist/runtime/host-load-governor.js +541 -0
  45. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  46. package/dist/runtime/host-load-ledger-lock.js +185 -0
  47. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  48. package/dist/runtime/host-load-runtime-settings.js +78 -0
  49. package/dist/runtime/host-load-sampler.d.ts +126 -0
  50. package/dist/runtime/host-load-sampler.js +232 -0
  51. package/dist/runtime/host-load-step-class.d.ts +68 -0
  52. package/dist/runtime/host-load-step-class.js +106 -0
  53. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  54. package/dist/runtime/host-load-step-reaper.js +95 -0
  55. package/dist/runtime/host-load-step-run.d.ts +73 -0
  56. package/dist/runtime/host-load-step-run.js +102 -0
  57. package/dist/runtime/host-load-token-ledger.d.ts +174 -0
  58. package/dist/runtime/host-load-token-ledger.js +421 -0
  59. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  60. package/dist/runtime/host-pressure-stall.js +168 -0
  61. package/dist/runtime/host-runtime-contract.d.ts +4 -0
  62. package/dist/runtime/host-runtime-contract.js +6 -1
  63. package/dist/runtime/host-runtime-lease.d.ts +74 -4
  64. package/dist/runtime/host-runtime-lease.js +336 -20
  65. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  66. package/dist/runtime/host-runtime-promotion.js +48 -0
  67. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  68. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  69. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  70. package/dist/runtime/host-runtime-requirements.js +117 -0
  71. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  72. package/dist/runtime/managed-command-teardown.js +607 -0
  73. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  74. package/dist/runtime/playwright-browser-cache.js +227 -0
  75. package/dist/runtime/playwright-host-runtime-adapter.d.ts +18 -0
  76. package/dist/runtime/playwright-host-runtime-adapter.js +61 -55
  77. package/dist/runtime/runner-settings.d.ts +100 -0
  78. package/dist/runtime/runner-settings.js +214 -0
  79. package/dist/sandbox/host-capacity-broker.d.ts +107 -0
  80. package/dist/sandbox/host-capacity-broker.js +315 -0
  81. package/dist/sandbox/runtime.d.ts +10 -1
  82. package/dist/sandbox/runtime.js +45 -2
  83. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  84. package/dist/sandbox/sandbox-cgroups.js +42 -0
  85. package/dist/session/managed-attempt-tools.d.ts +27 -0
  86. package/dist/session/managed-attempt-tools.js +356 -40
  87. package/dist/session/managed-build-coordinator.d.ts +1 -1
  88. package/dist/session/managed-build-coordinator.js +4 -1
  89. package/dist/session/managed-command-host-load.d.ts +45 -0
  90. package/dist/session/managed-command-host-load.js +82 -0
  91. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  92. package/dist/session/mcp-argument-coercion.js +121 -0
  93. package/dist/session/phase-completion.artifacts.d.ts +7 -0
  94. package/dist/session/phase-completion.artifacts.js +98 -25
  95. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  96. package/dist/session/phase-completion.command-validation.js +77 -0
  97. package/dist/session/phase-completion.d.ts +4 -0
  98. package/dist/session/phase-completion.helpers.js +13 -12
  99. package/dist/session/phase-completion.js +4 -0
  100. package/dist/session/phase-completion.prompts.js +6 -1
  101. package/dist/session/phase-completion.runtime.d.ts +5 -3
  102. package/dist/session/phase-completion.runtime.js +70 -35
  103. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  104. package/dist/session/phase-completion.schema-parts.js +188 -0
  105. package/dist/session/phase-completion.schemas.d.ts +3 -3
  106. package/dist/session/phase-completion.schemas.js +184 -209
  107. package/dist/session/phase-completion.validation.d.ts +2 -3
  108. package/dist/session/phase-completion.validation.js +46 -92
  109. package/dist/session/pre-publication-host-load.d.ts +27 -0
  110. package/dist/session/pre-publication-host-load.js +111 -0
  111. package/dist/session/pre-publication-process.d.ts +23 -0
  112. package/dist/session/pre-publication-process.js +109 -0
  113. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  114. package/dist/session/pre-publication-skipped-tests.js +109 -0
  115. package/dist/session/pre-publication-step-execution.d.ts +11 -0
  116. package/dist/session/pre-publication-step-execution.js +49 -0
  117. package/dist/session/pre-publication-validation.d.ts +9 -9
  118. package/dist/session/pre-publication-validation.js +48 -112
  119. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
  120. package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
  121. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  122. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  123. package/dist/session/provider-cli/provider-cli.process.d.ts +35 -1
  124. package/dist/session/provider-cli/provider-cli.process.js +189 -19
  125. package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
  126. package/dist/session/provider-cli/provider-cli.prompts.js +20 -2
  127. package/dist/session/provider-cli/provider-cli.service.d.ts +6 -0
  128. package/dist/session/provider-cli/provider-cli.service.js +244 -36
  129. package/dist/session/provider-cli/provider-cli.types.d.ts +30 -0
  130. package/dist/session/provider-cli/provider-in-flight-work.d.ts +6 -0
  131. package/dist/session/provider-cli/provider-in-flight-work.js +47 -0
  132. package/dist/session/provider-cli/provider-output-state.d.ts +6 -0
  133. package/dist/session/provider-cli/provider-output-state.js +9 -0
  134. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  135. package/dist/session/publishable-worktree-changes.js +193 -0
  136. package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
  137. package/dist/session/sandbox-host-capacity-gate.js +229 -0
  138. package/dist/session/session.base.d.ts +9 -1
  139. package/dist/session/session.service.d.ts +9 -2
  140. package/dist/session/session.service.js +120 -5
  141. package/dist/session/session.types.d.ts +3 -0
  142. package/dist/session/session.types.js +15 -3
  143. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  144. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  145. package/dist/shared/process/host-process-supervisor.d.ts +1 -0
  146. package/dist/shared/process/host-process-supervisor.js +1 -1
  147. package/dist/shared/process/process-tree.d.ts +52 -0
  148. package/dist/shared/process/process-tree.js +144 -0
  149. package/dist/shared/process/process.d.ts +67 -0
  150. package/dist/shared/process/process.js +213 -11
  151. package/dist/version.d.ts +1 -1
  152. package/dist/version.js +1 -1
  153. package/dist/worktree/dependency-warmer.d.ts +25 -0
  154. package/dist/worktree/dependency-warmer.js +46 -10
  155. package/dist/worktree/worktree.service.d.ts +10 -1
  156. package/dist/worktree/worktree.service.js +42 -2
  157. package/dist/worktree/worktree.types.d.ts +7 -0
  158. package/package.json +2 -2
package/README.md CHANGED
@@ -23,6 +23,16 @@ forge-bridge status
23
23
  forge-bridge connect --server <forge-url> --runner-id <runner-id> --device-token <device-token>
24
24
  ```
25
25
 
26
+ To pair, open **Settings → Runners → Connect a bridge** in Forge and run the command it shows:
27
+
28
+ ```bash
29
+ forge-bridge pair <code> --server <forge-url>
30
+ ```
31
+
32
+ The runner name, provider CLIs and repo folder chosen in that dialog come back with the claim
33
+ and are saved to `bridge.json`; `--repo-root` and `--cli-provider` on the command line win over
34
+ them. `bridge.json` holds the device token, so the bridge writes it with mode `0600`.
35
+
26
36
  The bridge can also read connection settings from environment variables:
27
37
 
28
38
  - `FORGE_URL`
@@ -129,6 +139,29 @@ enters a ten-minute cooldown after an unsuccessful attempt. Remote `DOCKER_HOST`
129
139
  restarted. Operators can tune the bounded policy with `FORGE_DOCKER_RECOVERY_FAILURE_THRESHOLD`,
130
140
  `FORGE_DOCKER_RECOVERY_COOLDOWN_MS`, and `FORGE_DOCKER_RECOVERY_STARTUP_TIMEOUT_MS`.
131
141
 
142
+ ## Runner limits and yield
143
+
144
+ Forge owns each runner's limits (Settings → Runners → Limits) and pushes them to the bridge, which
145
+ applies them without a restart and without stopping admitted work: max attempts and the memory reserve
146
+ apply at the next attempt admission, the CPU budget, yield budget and max heavy steps at the next heavy
147
+ step. Host env vars only bound the server's values and are reported back to Forge: a ceiling on
148
+ capacity (`FORGE_HOST_MAX_CONCURRENT_ATTEMPTS`, `FORGE_HOST_CPU_BUDGET_PERCENT`,
149
+ `FORGE_HOST_LOAD_CPU_BUDGET_FRACTION`, `FORGE_HOST_MAX_HEAVY_STEPS`) and a floor on the reserve
150
+ (`FORGE_HOST_MEMORY_RESERVE_BYTES`). Without a server value, the env var or the bridge default applies.
151
+ The CPU budget, yield budget and heavy-step limit take effect only with `FORGE_HOST_LOAD_GOVERNOR=on`.
152
+
153
+ Yield this machine to foreground work (for example while gaming) from the host itself:
154
+
155
+ ```bash
156
+ forge-bridge yield on
157
+ forge-bridge yield status
158
+ forge-bridge yield off
159
+ ```
160
+
161
+ While yielding, the bridge takes no new attempts and heavy steps of running attempts use the yield CPU
162
+ budget. Yield is on when this local flag or the runner's Yield toggle in Forge is on. The flag is stored
163
+ in `bridge.yield.json` next to `bridge.json`, and a running bridge notices it within one heartbeat.
164
+
132
165
  ## Docker sandbox runners
133
166
 
134
167
  Protocol-v2 bridges preflight Docker before advertising the `docker` sandbox runtime. Validate a repository contract and the local runner before enabling a project's `sandbox_required` policy:
@@ -190,9 +223,9 @@ Production shared runners require a Linux rootless Docker daemon. Docker Desktop
190
223
 
191
224
  Before selecting `sandbox_required`, save the full approved 40- or 64-character Git commit SHA in the project's Sandbox policy dialog. The server persists that SHA on the immutable attempt and the bridge reads `.forge/forge.sandbox.yml`, `.forge/Dockerfile`, and the tracked build context only from that commit. API-key dispatches carry an opaque one-time grant handle; the authenticated current runner instance redeems it after reservation, and plaintext stays out of offers, database payloads, Docker metadata, and host-persisted control files.
192
225
 
193
- Temporary host fallback for `sandbox_preferred` requires both sides to opt in: a project owner must save a reason and future expiry (maximum 30 days), and an operator must enable **Host fallback** for the runner in Profile Settings. Either missing or expired authorization fails closed. `sandbox_required` never falls back.
226
+ Temporary host fallback for `sandbox_preferred` requires both sides to opt in: a project owner must save a reason and future expiry (maximum 30 days), and an operator must enable **Host fallback** for the runner in Settings › Runners. Either missing or expired authorization fails closed. `sandbox_required` never falls back.
194
227
 
195
- The bridge reaps exact-labeled orphan resources before connecting and every minute afterward. Connected passes reconcile current-instance ledgers against an authoritative, instance-scoped server attempt snapshot; startup does not adopt old-instance resources and terminates them before advertising capacity. Per-resource removal outcomes are written mode-0600 under `FORGE_SANDBOX_STATE_ROOT/cleanup-reports` before transmission, replayed after reconnect, acknowledged by report ID, and persisted by the API only when attempt, fence, resource runner instance, and current reporting runner match. Fenced dispatch events also persist image/cache status, build/agent-start/import/teardown timestamps, and a validated inventory of created agent/sidecar containers, networks, volumes, and published ports. Selected-session diagnostics expose that lifecycle data and recent cleanup actions while retaining cleanup-pending state after the agent outcome is terminal. Install `forge-bridge sandbox reap` as an independently supervised OS timer with the same `FORGE_RUNNER_ID`, Docker context, and state root so resources are reconciled while the bridge is down; the Docker-context ownership lock makes an overlapping pass fail safely. A non-zero `degradedReservationCount` means teardown has not completed; the affected capacity remains unavailable until a successful reaper pass. Drain a runner from Profile Settings before upgrades or Docker maintenance, wait for active/starting counts to reach zero, then restart the bridge. Profile Settings also exposes a scoped **Reap** action; the API delivers it only to the currently established protocol-v2 runner instance. Image GC runs only while disk pressure is latched, shares the build lock, preserves active image digests, and prunes only expired images beyond the per-project retention count. Lease renewals are HMAC-bound to the attempt and fence and advance an in-container monotonic deadline; lease, hard-wall, and idle expiry produce distinct failure codes.
228
+ The bridge reaps exact-labeled orphan resources before connecting and every minute afterward. Connected passes reconcile current-instance ledgers against an authoritative, instance-scoped server attempt snapshot; startup does not adopt old-instance resources and terminates them before advertising capacity. Per-resource removal outcomes are written mode-0600 under `FORGE_SANDBOX_STATE_ROOT/cleanup-reports` before transmission, replayed after reconnect, acknowledged by report ID, and persisted by the API only when attempt, fence, resource runner instance, and current reporting runner match. Fenced dispatch events also persist image/cache status, build/agent-start/import/teardown timestamps, and a validated inventory of created agent/sidecar containers, networks, volumes, and published ports. Selected-session diagnostics expose that lifecycle data and recent cleanup actions while retaining cleanup-pending state after the agent outcome is terminal. Install `forge-bridge sandbox reap` as an independently supervised OS timer with the same `FORGE_RUNNER_ID`, Docker context, and state root so resources are reconciled while the bridge is down; the Docker-context ownership lock makes an overlapping pass fail safely. A non-zero `degradedReservationCount` means teardown has not completed; the affected capacity remains unavailable until a successful reaper pass. Drain a runner from Settings › Runners before upgrades or Docker maintenance, wait for active/starting counts to reach zero, then restart the bridge. Settings › Runners also exposes a scoped **Reap** action; the API delivers it only to the currently established protocol-v2 runner instance. Image GC runs only while disk pressure is latched, shares the build lock, preserves active image digests, and prunes only expired images beyond the per-project retention count. Lease renewals are HMAC-bound to the attempt and fence and advance an in-container monotonic deadline; lease, hard-wall, and idle expiry produce distinct failure codes.
196
229
 
197
230
  Every attempt-owned container (including short-lived initialization helpers), network, and volume carries `dev.forge.resource-lease-id` equal to the dispatch execution lease. Ledger schema v2 persists the same `resourceLeaseId`; teardown compares the complete expected label set, and orphan reaping fails closed unless the managed, resource-lease, execution-lease, attempt, runner, runner-instance, and fencing identities are all present and consistent.
198
231
 
@@ -18,8 +18,17 @@ export interface BridgeConnection {
18
18
  onCancel(handler: BridgeCancelHandler): void;
19
19
  onReap?(handler: BridgeReapHandler): void;
20
20
  onReadinessProbe?(handler: BridgeReadinessProbeHandler): void;
21
+ /** Decision 0014: the owner removed this runner from Forge; the bridge must stop, not reconnect. */
22
+ onRevoked?(handler: (notice: BridgeRevokedNotice) => void): void;
23
+ /** Decision 0014: the server pushes the runner settings document (`ApplySettings`, schema 8 bridges only). */
24
+ onApplySettings?(handler: (document: unknown) => void | Promise<void>): void;
21
25
  invoke<TResponse>(methodName: string, payload: unknown): Promise<TResponse>;
22
26
  }
27
+ /** The `Revoked` hub message: the runner was removed from Forge and must be paired again. */
28
+ export interface BridgeRevokedNotice {
29
+ runnerId?: string;
30
+ reason?: string;
31
+ }
23
32
  export interface BridgeConnectionFactory {
24
33
  create(config: BridgeServiceConfig): BridgeConnection;
25
34
  }
@@ -1,12 +1,14 @@
1
1
  import type { SessionService } from "../session/session.base.js";
2
2
  import type { ProviderProcessRunner } from "../session/provider-cli/provider-cli.process.js";
3
+ import { type RunnerSettingsReport } from "../runtime/runner-settings.js";
3
4
  import { DockerEngineProbe, type DockerEngineCapabilitySnapshot } from "../runtime/docker-engine-probe.js";
4
5
  import { type DispatchSandboxResourceRequest, type RunOnceDispatchPacket, type RunOnceResultPacket } from "../session/session.types.js";
5
6
  import { DockerPreflight } from "../sandbox/preflight.js";
6
7
  import type { SandboxPreflightResult } from "../sandbox/sandbox.types.js";
7
8
  import { type SandboxRuntime } from "../sandbox/runtime.js";
8
- import type { BridgeConnection, BridgeConnectionFactory, BridgeService } from "./bridge.base.js";
9
+ import type { BridgeConnection, BridgeConnectionFactory, BridgeRevokedNotice, BridgeService } from "./bridge.base.js";
9
10
  import { type RunnerHostCapabilityProbe } from "./runner-host-capabilities.js";
11
+ import { type HostLoadSource } from "../runtime/host-load-sampler.js";
10
12
  import type { BridgeCancelHandler, BridgeChatTurnHandler, BridgeDispatchHandler, BridgeLeaseUpdateRequest, BridgeReapRequest, BridgeServiceConfig } from "./bridge.types.js";
11
13
  import { type ReadinessResultOutbox } from "./readiness-result-outbox.js";
12
14
  import { type DispatchResultOutbox } from "./dispatch-result-outbox.js";
@@ -29,6 +31,7 @@ export declare class ForgeBridgeService implements BridgeService {
29
31
  private readonly connections;
30
32
  private readonly hostCapabilityProbe;
31
33
  private readonly chatProcessRunner;
34
+ private readonly hostLoad;
32
35
  private connection;
33
36
  private heartbeatTimer;
34
37
  private heartbeatInFlight;
@@ -41,6 +44,7 @@ export declare class ForgeBridgeService implements BridgeService {
41
44
  private transportRecovery;
42
45
  private transportRecoveryGeneration;
43
46
  private stopped;
47
+ private revokedReason;
44
48
  private readonly activeSessions;
45
49
  private readonly reservations;
46
50
  private readonly activeReadinessProbes;
@@ -58,14 +62,74 @@ export declare class ForgeBridgeService implements BridgeService {
58
62
  private readonly sessions;
59
63
  private readonly enforceHostDatabaseCapabilityBoundary;
60
64
  private hostCapabilities;
65
+ private dockerAvailable;
66
+ private appliedSettingsDocument;
67
+ private localYield;
68
+ private effectiveSettings;
69
+ private settingsReport;
70
+ /** Applies run one at a time; offers wait for every apply queued before them. */
71
+ private settingsTail;
72
+ private pendingYieldOn;
73
+ private settingsStarted;
74
+ private hostRequirementFacts;
61
75
  private readonly recoveredHostAttempts;
62
76
  private hostCapabilitiesDetected;
63
- constructor(config: BridgeServiceConfig, sessions?: SessionService | undefined, connections?: BridgeConnectionFactory, preflight?: DockerPreflight, sandboxRuntime?: SandboxRuntime, sandboxResourceResolver?: SandboxResourceResolver, dockerEngineProbe?: DockerEngineProbe, hostCapabilityProbe?: RunnerHostCapabilityProbe, readinessResultOutbox?: ReadinessResultOutbox, chatProcessRunner?: ProviderProcessRunner, dispatchResultOutbox?: DispatchResultOutbox);
77
+ constructor(config: BridgeServiceConfig, sessions?: SessionService | undefined, connections?: BridgeConnectionFactory, preflight?: DockerPreflight, sandboxRuntime?: SandboxRuntime, sandboxResourceResolver?: SandboxResourceResolver, dockerEngineProbe?: DockerEngineProbe, hostCapabilityProbe?: RunnerHostCapabilityProbe, readinessResultOutbox?: ReadinessResultOutbox, chatProcessRunner?: ProviderProcessRunner, dispatchResultOutbox?: DispatchResultOutbox, hostLoad?: HostLoadSource);
64
78
  connectOnce(): Promise<void>;
65
79
  private rememberRecoveredHostAttempts;
66
80
  private recoveredHostAttemptsForHello;
67
81
  private registerConnection;
68
82
  run(signal?: AbortSignal): Promise<void>;
83
+ /** The reason Forge gave when it removed this runner, or null while it is paired. */
84
+ get revoked(): string | null;
85
+ /**
86
+ * Decision 0014 §3 "Remove": Forge removed this runner. Stop for good instead of
87
+ * reconnecting; its attempts were already settled on the server, so local work is
88
+ * aborted rather than reported.
89
+ */
90
+ private handleRevoked;
91
+ /** The effective settings and how they were derived, as last reported (decision 0014). */
92
+ get runnerSettings(): RunnerSettingsReport;
93
+ private runnerHostDefaults;
94
+ /**
95
+ * Once per bridge process: drop governor overrides an earlier process left on
96
+ * the state root, then put today's effective settings (env bounds and the local
97
+ * yield flag, no server document yet) in force.
98
+ */
99
+ private startSettings;
100
+ /**
101
+ * Decision 0014 `ApplySettings`. Applies only a document newer than the one
102
+ * applied, one at a time, then acknowledges it with `SettingsApplied`. A replay of
103
+ * the applied version is acknowledged again without applying it; an older one is
104
+ * ignored.
105
+ */
106
+ private handleApplySettings;
107
+ /**
108
+ * Polls the local `forge-bridge yield` flag (every heartbeat and before each
109
+ * offer decision). A change is applied at once and reported again under the
110
+ * same settings version.
111
+ */
112
+ /** Yielding now, or about to: a received yield-on that is still being applied counts. */
113
+ private yieldingOrQueued;
114
+ private refreshLocalYield;
115
+ /**
116
+ * A setting the host couldn't put in force holds placement on the server, so
117
+ * every heartbeat tries the applied document again until it takes.
118
+ */
119
+ private retryFailedSettings;
120
+ private readLocalYield;
121
+ private enqueueSettings;
122
+ private applySettings;
123
+ /**
124
+ * Max attempts and the memory reserve go to host attempt admission; the governor
125
+ * budget (the yield budget while yielding) and the heavy-step limit go to the
126
+ * shared settings file every governor on the state root reads at admission.
127
+ * Neither touches admitted work. Returns the keys the host could not put in
128
+ * force (`apply_failed`); their previous values stay in force.
129
+ */
130
+ private putSettingsInForce;
131
+ /** A failed acknowledgement is not retried here: the next heartbeat carries the same report. */
132
+ private sendSettingsApplied;
69
133
  stop(): Promise<void>;
70
134
  private handleChatTurn;
71
135
  private createChatTurnWorkspace;
@@ -107,6 +171,15 @@ export declare class ForgeBridgeService implements BridgeService {
107
171
  private sendResultPayloadDirect;
108
172
  private flushDispatchResults;
109
173
  private flushDispatchResultsCore;
174
+ /**
175
+ * Forge binds each result to the runner instance that ran the attempt. On an
176
+ * authoritative connection it rejects another instance's result with
177
+ * bridge.stale_result_instance; Forge's own recovery handles that attempt,
178
+ * so the record can never be delivered and must not block the replay queue.
179
+ * bridge.stale_runner_instance means this connection is not authoritative
180
+ * and says nothing about the record, so it never quarantines.
181
+ */
182
+ private isReplacedRunnerInstanceResult;
110
183
  private startHeartbeat;
111
184
  private heartbeatTick;
112
185
  private startLeaseWatchdog;
@@ -133,6 +206,13 @@ export declare class ForgeBridgeService implements BridgeService {
133
206
  private waitForClose;
134
207
  private stopConnection;
135
208
  }
209
+ /** The `run` command's exit code after Forge removed the runner. */
210
+ export declare const bridgeRevokedExitCode = 3;
211
+ export declare const bridgeRevokedMessage = "This bridge was removed from Forge. Pair it again with forge-bridge pair.";
212
+ /** Thrown by `run` after Forge removed the runner, so the CLI exits instead of reconnecting. */
213
+ export declare class BridgeRevokedError extends Error {
214
+ constructor(message?: string);
215
+ }
136
216
  export declare class SignalRBridgeConnectionFactory implements BridgeConnectionFactory {
137
217
  create(config: BridgeServiceConfig): BridgeConnection;
138
218
  }
@@ -140,6 +220,8 @@ export declare class SignalRBridgeConnection implements BridgeConnection {
140
220
  private readonly config;
141
221
  private readonly connection;
142
222
  constructor(config: BridgeServiceConfig);
223
+ onApplySettings(handler: (document: unknown) => void | Promise<void>): void;
224
+ onRevoked(handler: (notice: BridgeRevokedNotice) => void): void;
143
225
  start(): Promise<void>;
144
226
  stop(): Promise<void>;
145
227
  onClose(handler: (error?: Error) => void): void;