@loucompanion/forge-bridge 0.1.4-dev.a690038a6849 → 0.1.4-dev.bbb61d3d6127

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 (59) hide show
  1. package/README.md +2 -2
  2. package/dist/bridge/bridge.service.d.ts +2 -0
  3. package/dist/bridge/bridge.service.js +22 -3
  4. package/dist/bridge/bridge.types.d.ts +5 -0
  5. package/dist/bridge/runner-host-capabilities.d.ts +2 -0
  6. package/dist/bridge/runner-host-capabilities.js +4 -0
  7. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  8. package/dist/bridge/test-postgres-capability.js +120 -0
  9. package/dist/cli/cli.service.js +3 -1
  10. package/dist/runtime/host-load-admission.d.ts +52 -0
  11. package/dist/runtime/host-load-admission.js +84 -0
  12. package/dist/runtime/host-load-forge-cgroups.d.ts +8 -0
  13. package/dist/runtime/host-load-forge-cgroups.js +51 -0
  14. package/dist/runtime/host-load-governor-config.d.ts +34 -0
  15. package/dist/runtime/host-load-governor-config.js +46 -0
  16. package/dist/runtime/host-load-governor.d.ts +123 -0
  17. package/dist/runtime/host-load-governor.js +415 -0
  18. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  19. package/dist/runtime/host-load-ledger-lock.js +185 -0
  20. package/dist/runtime/host-load-sampler.d.ts +38 -0
  21. package/dist/runtime/host-load-sampler.js +66 -6
  22. package/dist/runtime/host-load-step-class.d.ts +33 -0
  23. package/dist/runtime/host-load-step-class.js +46 -0
  24. package/dist/runtime/host-load-token-ledger.d.ts +135 -0
  25. package/dist/runtime/host-load-token-ledger.js +345 -0
  26. package/dist/runtime/host-pressure-stall.d.ts +21 -1
  27. package/dist/runtime/host-pressure-stall.js +48 -1
  28. package/dist/runtime/host-runtime-contract.d.ts +3 -0
  29. package/dist/runtime/host-runtime-contract.js +4 -1
  30. package/dist/runtime/host-runtime-lease.d.ts +13 -2
  31. package/dist/runtime/host-runtime-lease.js +27 -2
  32. package/dist/runtime/host-runtime-promotion.js +12 -0
  33. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  34. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  35. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  36. package/dist/runtime/host-runtime-requirements.js +117 -0
  37. package/dist/session/pre-publication-host-load.d.ts +27 -0
  38. package/dist/session/pre-publication-host-load.js +96 -0
  39. package/dist/session/pre-publication-step-execution.d.ts +11 -0
  40. package/dist/session/pre-publication-step-execution.js +49 -0
  41. package/dist/session/pre-publication-validation.d.ts +9 -9
  42. package/dist/session/pre-publication-validation.js +17 -55
  43. package/dist/session/provider-cli/provider-cli.artifacts.js +15 -3
  44. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  45. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  46. package/dist/session/provider-cli/provider-cli.process.d.ts +7 -0
  47. package/dist/session/provider-cli/provider-cli.process.js +13 -5
  48. package/dist/session/provider-cli/provider-cli.prompts.js +2 -0
  49. package/dist/session/provider-cli/provider-cli.service.js +28 -5
  50. package/dist/session/publishable-worktree-changes.d.ts +10 -1
  51. package/dist/session/publishable-worktree-changes.js +21 -5
  52. package/dist/session/session.base.d.ts +3 -0
  53. package/dist/session/session.service.d.ts +2 -0
  54. package/dist/session/session.service.js +5 -0
  55. package/dist/session/session.types.d.ts +3 -0
  56. package/dist/session/session.types.js +5 -2
  57. package/dist/version.d.ts +1 -1
  58. package/dist/version.js +1 -1
  59. package/package.json +1 -1
@@ -3,6 +3,7 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { GitClient } from "../shared/git/git.js";
5
5
  import { NodeProcessRunner } from "../shared/process/process.js";
6
+ import { assertNoUnresolvedMergeConflicts, restoreMergeOwnedPaths } from "./provider-cli/provider-cli.merge-integrity.js";
6
7
  /**
7
8
  * Forge runtime output that is never published, whether or not the target repository
8
9
  * tracks other `.forge/` content. Completion artifacts and evidence live here.
@@ -20,7 +21,7 @@ const resetBatchSize = 200;
20
21
  */
21
22
  export function isNonPublishableWorktreeChange(relativePath, status) {
22
23
  const normalized = relativePath.trim().replaceAll("\\", "/");
23
- if (normalized === ".local" || runtimeOnlyPathPrefixes.some(prefix => normalized.startsWith(prefix))) {
24
+ if (isRuntimeOnlyPath(normalized)) {
24
25
  return true;
25
26
  }
26
27
  if (normalized === ".forge" || normalized.startsWith(".forge/")) {
@@ -28,16 +29,31 @@ export function isNonPublishableWorktreeChange(relativePath, status) {
28
29
  }
29
30
  return false;
30
31
  }
31
- /** Stages every publishable worktree change in the real index and returns both sets. */
32
+ /** `.local/`, `.forge/work-items/` and `.forge/stories/`: never published, even during a merge. */
33
+ export function isRuntimeOnlyPath(relativePath) {
34
+ const normalizedPath = normalizeChangedFilePath(relativePath);
35
+ return normalizedPath === ".local" || runtimeOnlyPathPrefixes.some(prefix => normalizedPath.startsWith(prefix));
36
+ }
37
+ /**
38
+ * Stages every publishable worktree change in the real index and returns both sets.
39
+ *
40
+ * During an in-progress merge it first refuses unresolved conflicts, and afterwards
41
+ * restores merge-owned paths that the exclusion unstaged back to HEAD (the story side),
42
+ * such as `.forge/` files the target branch added (#491). Runtime-only paths are never
43
+ * restored.
44
+ */
32
45
  export async function stagePublishableWorktreeChangeSet(git, worktreePath) {
46
+ await assertNoUnresolvedMergeConflicts(git, worktreePath);
33
47
  await git.run(worktreePath, ["add", "-A"]);
34
- const excluded = (await readStagedChanges(git, worktreePath))
48
+ const excludedChanges = (await readStagedChanges(git, worktreePath))
35
49
  .filter(change => isNonPublishableWorktreeChange(change.path, change.status))
36
50
  .map(change => change.path);
37
- for (let index = 0; index < excluded.length; index += resetBatchSize) {
38
- const batch = excluded.slice(index, index + resetBatchSize).map(filePath => `:(literal)${filePath}`);
51
+ for (let index = 0; index < excludedChanges.length; index += resetBatchSize) {
52
+ const batch = excludedChanges.slice(index, index + resetBatchSize).map(filePath => `:(literal)${filePath}`);
39
53
  await git.run(worktreePath, ["reset", "-q", "--", ...batch]);
40
54
  }
55
+ const restored = new Set(await restoreMergeOwnedPaths(git, worktreePath, excludedChanges.filter(filePath => !isRuntimeOnlyPath(filePath))));
56
+ const excluded = excludedChanges.filter(filePath => !restored.has(filePath));
41
57
  const publishable = (await git.run(worktreePath, ["diff", "--cached", "--name-only"]))
42
58
  .split(/\r?\n/)
43
59
  .map(line => line.trim())
@@ -1,3 +1,4 @@
1
+ import type { HostRequirementsCheck } from "../runtime/host-runtime-requirements-check.js";
1
2
  import type { HostRuntimeReadinessProbeRequest, HostRuntimeReadinessProbeResult, RunOnceDispatchPacket, RunOnceResultPacket, RunnerDispatchEvent } from "./session.types.js";
2
3
  import type { HostRuntimeCapacitySnapshot, HostRuntimeReapOptions, HostRuntimeReapReport } from "../runtime/host-runtime-lease.js";
3
4
  export interface SessionEventSink {
@@ -9,4 +10,6 @@ export interface SessionService {
9
10
  reapHostRuntime?(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport | null>;
10
11
  runtimeCapacity?(): HostRuntimeCapacitySnapshot | null;
11
12
  probeHostRuntime?(request: HostRuntimeReadinessProbeRequest, signal?: AbortSignal): Promise<HostRuntimeReadinessProbeResult>;
13
+ /** Decision 0013: host attempts recheck the project's requirements before starting. */
14
+ setHostRequirementsCheck?(check: HostRequirementsCheck | null): void;
12
15
  }
@@ -1,3 +1,4 @@
1
+ import type { HostRequirementsCheck } from "../runtime/host-runtime-requirements-check.js";
1
2
  import type { ProviderCliService } from "./provider-cli/provider-cli.base.js";
2
3
  import type { SessionEventSink, SessionService } from "./session.base.js";
3
4
  import type { HostRuntimeReadinessProbeRequest, HostRuntimeReadinessProbeResult, RunOnceDispatchPacket, RunOnceResultPacket } from "./session.types.js";
@@ -8,6 +9,7 @@ export declare class BridgeSessionService implements SessionService {
8
9
  private readonly providerCli;
9
10
  private readonly hostRuntime?;
10
11
  constructor(worktrees?: WorktreeService, providerCli?: ProviderCliService, hostRuntime?: HostRuntimeLeaseRuntime | undefined);
12
+ setHostRequirementsCheck(check: HostRequirementsCheck | null): void;
11
13
  updateLease(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
12
14
  reapHostRuntime(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport | null>;
13
15
  runtimeCapacity(): HostRuntimeCapacitySnapshot | null;
@@ -18,6 +18,9 @@ export class BridgeSessionService {
18
18
  this.providerCli = providerCli;
19
19
  this.hostRuntime = hostRuntime;
20
20
  }
21
+ setHostRequirementsCheck(check) {
22
+ this.hostRuntime?.setRequirementsCheck?.(check);
23
+ }
21
24
  async updateLease(dispatchAttemptId, fencingToken, expiresAt) {
22
25
  await this.hostRuntime?.updateLease(dispatchAttemptId, fencingToken, expiresAt);
23
26
  }
@@ -71,6 +74,7 @@ export class BridgeSessionService {
71
74
  status: "serialized",
72
75
  runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
73
76
  runtimeContractSource: started.runtimeContract.source,
77
+ runtimeRequirements: started.runtimeContract.contract.requires ?? null,
74
78
  reasonCode: discovery?.reasonCode ?? "host_runtime_contract_serialized",
75
79
  reasonMessage: discovery?.summary ?? "The detected runtime requires serialized host execution.",
76
80
  checkedAt: new Date().toISOString(),
@@ -87,6 +91,7 @@ export class BridgeSessionService {
87
91
  status: "parallel_ready",
88
92
  runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
89
93
  runtimeContractSource: started.runtimeContract.source,
94
+ runtimeRequirements: started.runtimeContract.contract.requires ?? null,
90
95
  reasonCode: null,
91
96
  reasonMessage: null,
92
97
  qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
@@ -1,3 +1,4 @@
1
+ import type { HostRuntimeRequirements } from "../runtime/host-runtime-requirements.js";
1
2
  export interface RunOnceDispatchPacket {
2
3
  readonly schemaVersion: 1 | 2;
3
4
  readonly userId: string;
@@ -546,6 +547,8 @@ export interface HostRuntimeReadinessProbeResult {
546
547
  readonly status: "parallel_ready" | "serialized" | "failed";
547
548
  readonly runtimeContractFingerprint?: string | null;
548
549
  readonly runtimeContractSource?: string | null;
550
+ /** Requirements declared by the probed contract (decision 0013); null when none. */
551
+ readonly runtimeRequirements?: HostRuntimeRequirements | null;
549
552
  readonly reasonCode?: string | null;
550
553
  readonly reasonMessage?: string | null;
551
554
  readonly qaAppLaunchTarget?: HostRuntimeReadinessQaLaunchTarget | null;
@@ -469,13 +469,13 @@ function unvalidatedFailureFactsForCode(code, source) {
469
469
  if (code === "bridge.unavailable") {
470
470
  return facts(code, "transport", "offer", source, "retryable", "retry_dispatch");
471
471
  }
472
- if (["capacity_unavailable", "bridge.runner_draining", "docker_engine_unavailable", "docker_memory_low", "docker_memory_sample_unavailable", "docker_cpu_low", "docker_disk_low", "server_local.resource_pressure", "server_local.capacity_unavailable", "dispatch.preparation_resource_pressure", "sandbox_capacity_profile_unavailable", "host_runtime_admission_expired"].includes(code)) {
472
+ if (["capacity_unavailable", "bridge.runner_draining", "docker_engine_unavailable", "docker_memory_low", "docker_memory_sample_unavailable", "docker_cpu_low", "docker_disk_low", "server_local.resource_pressure", "server_local.capacity_unavailable", "dispatch.preparation_resource_pressure", "sandbox_capacity_profile_unavailable", "host_runtime_admission_expired", "placement_requirements_unmet"].includes(code)) {
473
473
  return facts(code, "resource", "offer", source, "retryable", "retry_dispatch");
474
474
  }
475
475
  if (["bridge.lease_retry_exhausted", "bridge.capacity_wait_exhausted"].includes(code)) {
476
476
  return facts(code, "resource", "offer", source, "non_retryable", "inspect_failure");
477
477
  }
478
- if (["prepublication_infrastructure_failed", "prepublication_capability_unavailable"].includes(code)) {
478
+ if (["prepublication_infrastructure_failed", "prepublication_capability_unavailable", "host_capacity_timeout", "host_capacity_token_fenced", "host_capacity_ledger_unavailable"].includes(code)) {
479
479
  return facts(code, "resource", "validation", source, "retryable", "retry_with_policy");
480
480
  }
481
481
  if (["prepublication_validation_failed", "prepublication_contract_invalid", "prepublication_execution_scope_invalid"].includes(code)) {
@@ -572,6 +572,9 @@ function unvalidatedFailureFactsForCode(code, source) {
572
572
  if (code === "worktree_branch_integration_conflict") {
573
573
  return facts(code, "domain", "agent", source, "non_retryable", "fix_input");
574
574
  }
575
+ if (["merge_resolution_reverts_upstream_changes", "merge_resolution_unresolved_conflict"].includes(code)) {
576
+ return facts(code, "domain", "validation", source, "non_retryable", "inspect_failure");
577
+ }
575
578
  if (stableFailureFamilyCodes.has(code) && code.startsWith("sandbox_")) {
576
579
  return facts(code, "provider", "agent", source, "non_retryable", "inspect_failure");
577
580
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const forgeBridgeVersion = "0.1.4-dev.a690038a6849";
1
+ export declare const forgeBridgeVersion = "0.1.4-dev.bbb61d3d6127";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const forgeBridgeVersion = "0.1.4-dev.a690038a6849";
1
+ export const forgeBridgeVersion = "0.1.4-dev.bbb61d3d6127";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loucompanion/forge-bridge",
3
- "version": "0.1.4-dev.a690038a6849",
3
+ "version": "0.1.4-dev.bbb61d3d6127",
4
4
  "description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",