@loucompanion/forge-bridge 0.1.4-dev.8901ba056f68 → 0.1.4-dev.91ee995ac965
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 +142 -1
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +11 -0
- package/dist/bridge/bridge-state-io.js +50 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +87 -14
- package/dist/bridge/bridge.service.js +394 -338
- package/dist/bridge/bridge.types.d.ts +16 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +3 -0
- package/dist/bridge/runner-host-capabilities.js +13 -0
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +20 -1
- package/dist/cleanup/cleanup.service.js +154 -153
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
- package/dist/cleanup/host-runtime-ledger.js +109 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +74 -12
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +149 -186
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +32 -4
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +5 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +140 -7
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-load-admission.d.ts +18 -3
- package/dist/runtime/host-load-admission.js +19 -4
- package/dist/runtime/host-load-child-environment.d.ts +11 -6
- package/dist/runtime/host-load-child-environment.js +22 -11
- package/dist/runtime/host-load-governor-config.d.ts +19 -1
- package/dist/runtime/host-load-governor-config.js +37 -0
- package/dist/runtime/host-load-governor.d.ts +14 -0
- package/dist/runtime/host-load-governor.js +139 -26
- package/dist/runtime/host-load-ledger-lock.js +6 -4
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +34 -4
- package/dist/runtime/host-load-sampler.js +73 -7
- package/dist/runtime/host-load-step-class.d.ts +3 -1
- package/dist/runtime/host-load-step-class.js +60 -5
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +26 -0
- package/dist/runtime/host-load-token-ledger.js +93 -61
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +29 -1
- package/dist/runtime/host-runtime-lease.d.ts +59 -3
- package/dist/runtime/host-runtime-lease.js +209 -58
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +36 -0
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/sandbox/host-capacity-broker.d.ts +10 -2
- package/dist/sandbox/host-capacity-broker.js +27 -6
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +36 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.js +2 -6
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +89 -99
- package/dist/session/managed-build-receipt.d.ts +5 -0
- package/dist/session/managed-build-receipt.js +8 -3
- package/dist/session/managed-command-host-load.d.ts +2 -0
- package/dist/session/managed-command-host-load.js +2 -1
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +10 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +5 -0
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +4 -10
- package/dist/session/phase-completion.runtime.js +77 -209
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +208 -231
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +49 -93
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.js +10 -10
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +30 -14
- package/dist/session/pre-publication-validation.js +207 -134
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +39 -430
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +72 -32
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +78 -171
- package/dist/session/provider-cli/provider-cli.types.d.ts +26 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +22 -1
- package/dist/session/sandbox-host-capacity-gate.js +42 -14
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +162 -58
- package/dist/session/session.types.js +4 -4
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +13 -1
- package/dist/shared/process/host-process-supervisor.js +66 -14
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/wip-git.d.ts +33 -0
- package/dist/worktree/wip-git.js +122 -0
- package/dist/worktree/wip-refs.d.ts +62 -0
- package/dist/worktree/wip-refs.js +119 -0
- package/dist/worktree/wip-restore.d.ts +38 -0
- package/dist/worktree/wip-restore.js +190 -0
- package/dist/worktree/wip-snapshot.d.ts +50 -0
- package/dist/worktree/wip-snapshot.js +268 -0
- package/dist/worktree/worktree-wip-events.d.ts +18 -0
- package/dist/worktree/worktree-wip-events.js +98 -0
- package/dist/worktree/worktree-wip.d.ts +49 -0
- package/dist/worktree/worktree-wip.js +182 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +11 -3
- package/dist/worktree/worktree.service.js +54 -21
- package/dist/worktree/worktree.types.d.ts +22 -0
- package/package.json +2 -2
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { GitClient } from "../shared/git/git.js";
|
|
2
2
|
import type { HostLoadStepGate } from "../runtime/host-load-governor.js";
|
|
3
3
|
import type { WorktreeLifecycleCoordinator, WorktreeService } from "./worktree.base.js";
|
|
4
|
-
import type { WorktreeHandle, WorktreePrepareRequest } from "./worktree.types.js";
|
|
4
|
+
import type { WipSessionOutcome, WipSettlement, WorktreeHandle, WorktreePrepareRequest } from "./worktree.types.js";
|
|
5
|
+
export { emitWipRestoreEvent, sessionWipOutcome, settleWorktree } from "./worktree-wip-events.js";
|
|
5
6
|
export declare class GitWorktreeService implements WorktreeService {
|
|
6
7
|
private readonly git;
|
|
7
8
|
private readonly coordinator;
|
|
8
9
|
/** Gates dependency install fallbacks; inert unless the governor is on. */
|
|
9
10
|
private readonly hostLoadGate?;
|
|
11
|
+
/** Holds the host runtime lease ledger; branches of live leases are never swept on release. */
|
|
12
|
+
private readonly leaseStateRoot;
|
|
10
13
|
constructor(git?: GitClient, coordinator?: WorktreeLifecycleCoordinator,
|
|
11
14
|
/** Gates dependency install fallbacks; inert unless the governor is on. */
|
|
12
|
-
hostLoadGate?: HostLoadStepGate | undefined
|
|
15
|
+
hostLoadGate?: HostLoadStepGate | undefined,
|
|
16
|
+
/** Holds the host runtime lease ledger; branches of live leases are never swept on release. */
|
|
17
|
+
leaseStateRoot?: string);
|
|
13
18
|
prepare(request: WorktreePrepareRequest): Promise<WorktreeHandle>;
|
|
19
|
+
private warmDependencies;
|
|
20
|
+
/** Restores the story's saved WIP (still under the repository lock, before the provider starts). */
|
|
21
|
+
private withRestoredWip;
|
|
22
|
+
settleWip(handle: WorktreeHandle, outcome: WipSessionOutcome): Promise<WipSettlement>;
|
|
14
23
|
private trackedForgePaths;
|
|
15
24
|
private registeredManagedWorktreePath;
|
|
16
25
|
private repoCreationCoordinationPath;
|
|
@@ -32,4 +41,3 @@ export declare function renameWorktreeForRelease(source: string, destination: st
|
|
|
32
41
|
export declare function requiresMutableEnvironmentPreparation(request: Pick<WorktreePrepareRequest, "applicationRuntimeRequired">): boolean;
|
|
33
42
|
export declare function clearRunArtifactRoots(worktreePath: string, request: WorktreePrepareRequest): Promise<void>;
|
|
34
43
|
export declare function normalizeBranchName(value: string | null | undefined, fallback: string): string;
|
|
35
|
-
export {};
|
|
@@ -8,17 +8,25 @@ import { filterArtifactsForLane, injectWorktreeArtifacts } from "./artifact-inje
|
|
|
8
8
|
import { hydratePriorPhaseArtifacts } from "./prior-phase-artifact-hydrator.js";
|
|
9
9
|
import { materializeStoryQaReferences } from "./story-qa-reference-hydrator.js";
|
|
10
10
|
import { warmWorktreeDependencies } from "./dependency-warmer.js";
|
|
11
|
+
import { guardBranchReset, guardWorktreeRelease, guardWorktreeReset, restoreWorktreeWip, settleSessionWip, sweepBranchesAfterRelease, worktreeReleased, } from "./worktree-wip.js";
|
|
11
12
|
import { defaultWorktreeCoordinatorStateRoot, managedRepoRoot, resolveManagedWorktreeRoot, } from "./worktree-paths.js";
|
|
13
|
+
export { emitWipRestoreEvent, sessionWipOutcome, settleWorktree } from "./worktree-wip-events.js";
|
|
14
|
+
// Bounds the branch sweep that runs after each release, so one release never holds the repository lock long.
|
|
15
|
+
const releaseSweepLimit = 25;
|
|
12
16
|
export class GitWorktreeService {
|
|
13
17
|
git;
|
|
14
18
|
coordinator;
|
|
15
19
|
hostLoadGate;
|
|
20
|
+
leaseStateRoot;
|
|
16
21
|
constructor(git = new GitClient(), coordinator = new RepositoryCoordinatorLock(defaultWorktreeCoordinatorStateRoot()),
|
|
17
22
|
/** Gates dependency install fallbacks; inert unless the governor is on. */
|
|
18
|
-
hostLoadGate
|
|
23
|
+
hostLoadGate,
|
|
24
|
+
/** Holds the host runtime lease ledger; branches of live leases are never swept on release. */
|
|
25
|
+
leaseStateRoot = defaultWorktreeCoordinatorStateRoot()) {
|
|
19
26
|
this.git = git;
|
|
20
27
|
this.coordinator = coordinator;
|
|
21
28
|
this.hostLoadGate = hostLoadGate;
|
|
29
|
+
this.leaseStateRoot = leaseStateRoot;
|
|
22
30
|
}
|
|
23
31
|
async prepare(request) {
|
|
24
32
|
const allowedRoot = await ensureDirectory(request.allowedRepoRoot);
|
|
@@ -33,7 +41,7 @@ export class GitWorktreeService {
|
|
|
33
41
|
const repoPath = await this.coordinator.withLock(creationCoordinationPath, async () => {
|
|
34
42
|
return await this.resolveRepoPath(request.repo, allowedRoot, baseBranch);
|
|
35
43
|
});
|
|
36
|
-
const resolvedWorktreePath = await this.coordinator.withLock(repoPath, async () => {
|
|
44
|
+
const { worktreePath: resolvedWorktreePath, wipRestore } = await this.coordinator.withLock(repoPath, async () => {
|
|
37
45
|
await this.ensureGitIdentity(repoPath);
|
|
38
46
|
const baseStartPoint = await this.resolveBaseStartPoint(repoPath, baseBranch);
|
|
39
47
|
const worktreeRoot = resolveManagedWorktreeRoot(allowedRoot, repoPath);
|
|
@@ -58,9 +66,10 @@ export class GitWorktreeService {
|
|
|
58
66
|
await this.git.run(repoPath, ["worktree", "add", worktreePath, branchName]);
|
|
59
67
|
}
|
|
60
68
|
else {
|
|
69
|
+
await guardBranchReset(this.git, repoPath, branchName, baseStartPoint);
|
|
61
70
|
await this.git.run(repoPath, ["worktree", "add", "-B", branchName, worktreePath, baseStartPoint]);
|
|
62
71
|
}
|
|
63
|
-
return await resolveExistingDirectoryPath(worktreePath);
|
|
72
|
+
return await this.withRestoredWip(request, repoPath, branchName, await resolveExistingDirectoryPath(worktreePath));
|
|
64
73
|
}
|
|
65
74
|
// The selected checkout can change when a Bridge reconnects or a local
|
|
66
75
|
// runner takes over. Its managed root therefore changes even though the
|
|
@@ -86,9 +95,10 @@ export class GitWorktreeService {
|
|
|
86
95
|
throw new Error(`Existing worktree ${existingWorktreePath} is on branch '${currentBranch}', expected '${branchName}'.`);
|
|
87
96
|
}
|
|
88
97
|
if (!request.preserveExistingState && shouldResetExistingWorktree(request)) {
|
|
98
|
+
await guardWorktreeReset(existingWorktreePath, branchName, request);
|
|
89
99
|
await this.resetWorktreeToBase(existingWorktreePath, baseStartPoint);
|
|
90
100
|
}
|
|
91
|
-
return existingWorktreePath;
|
|
101
|
+
return await this.withRestoredWip(request, repoPath, branchName, existingWorktreePath);
|
|
92
102
|
});
|
|
93
103
|
// Reference inputs and an exact-tree local repair checkpoint must survive output cleanup.
|
|
94
104
|
await materializeStoryQaReferences(resolvedWorktreePath, request, this.git);
|
|
@@ -101,22 +111,7 @@ export class GitWorktreeService {
|
|
|
101
111
|
if (artifacts.length > 0) {
|
|
102
112
|
await injectWorktreeArtifacts(resolvedWorktreePath, artifacts, await this.trackedForgePaths(resolvedWorktreePath));
|
|
103
113
|
}
|
|
104
|
-
const dependencyWarm =
|
|
105
|
-
? await warmWorktreeDependencies({
|
|
106
|
-
baseCheckoutPath: repoPath,
|
|
107
|
-
worktreePath: resolvedWorktreePath,
|
|
108
|
-
allowedRoot,
|
|
109
|
-
warmPathOverrides: request.warmPathOverrides,
|
|
110
|
-
hostLoad: this.hostLoadGate?.enabled
|
|
111
|
-
? {
|
|
112
|
-
gate: this.hostLoadGate,
|
|
113
|
-
dispatchAttemptId: request.hostLoadOwner?.dispatchAttemptId ?? null,
|
|
114
|
-
priority: request.hostLoadOwner?.priority ?? "foreground",
|
|
115
|
-
}
|
|
116
|
-
: undefined,
|
|
117
|
-
signal: request.signal,
|
|
118
|
-
})
|
|
119
|
-
: undefined;
|
|
114
|
+
const dependencyWarm = await this.warmDependencies(request, repoPath, resolvedWorktreePath, allowedRoot);
|
|
120
115
|
return {
|
|
121
116
|
repoPath,
|
|
122
117
|
worktreePath: resolvedWorktreePath,
|
|
@@ -125,9 +120,38 @@ export class GitWorktreeService {
|
|
|
125
120
|
cleanupWorktrees: request.cleanupWorktrees,
|
|
126
121
|
dependencyWarm,
|
|
127
122
|
qaReworkPacketPath,
|
|
128
|
-
hydratedPriorPhaseArtifactCount
|
|
123
|
+
hydratedPriorPhaseArtifactCount,
|
|
124
|
+
sessionId: request.sessionId ?? null,
|
|
125
|
+
lane: request.lane,
|
|
126
|
+
...(wipRestore ? { wipRestore } : {}),
|
|
129
127
|
};
|
|
130
128
|
}
|
|
129
|
+
async warmDependencies(request, repoPath, worktreePath, allowedRoot) {
|
|
130
|
+
if (!requiresMutableEnvironmentPreparation(request))
|
|
131
|
+
return undefined;
|
|
132
|
+
return await warmWorktreeDependencies({
|
|
133
|
+
baseCheckoutPath: repoPath,
|
|
134
|
+
worktreePath,
|
|
135
|
+
allowedRoot,
|
|
136
|
+
warmPathOverrides: request.warmPathOverrides,
|
|
137
|
+
hostLoad: this.hostLoadGate?.enabled
|
|
138
|
+
? {
|
|
139
|
+
gate: this.hostLoadGate,
|
|
140
|
+
dispatchAttemptId: request.hostLoadOwner?.dispatchAttemptId ?? null,
|
|
141
|
+
priority: request.hostLoadOwner?.priority ?? "foreground",
|
|
142
|
+
}
|
|
143
|
+
: undefined,
|
|
144
|
+
signal: request.signal,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** Restores the story's saved WIP (still under the repository lock, before the provider starts). */
|
|
148
|
+
async withRestoredWip(request, repoPath, branchName, worktreePath) {
|
|
149
|
+
const wipRestore = await restoreWorktreeWip({ worktreePath, repoPath, branchName, sessionId: request.sessionId, lane: request.lane });
|
|
150
|
+
return { worktreePath, ...(wipRestore ? { wipRestore } : {}) };
|
|
151
|
+
}
|
|
152
|
+
async settleWip(handle, outcome) {
|
|
153
|
+
return await settleSessionWip(handle, outcome);
|
|
154
|
+
}
|
|
131
155
|
async trackedForgePaths(worktreePath) {
|
|
132
156
|
const output = await this.git.run(worktreePath, ["ls-files", "-z", "--", ".forge"]);
|
|
133
157
|
return new Set(output.split("\0").filter(Boolean).map(value => value.replaceAll("\\", "/")));
|
|
@@ -157,6 +181,8 @@ export class GitWorktreeService {
|
|
|
157
181
|
}
|
|
158
182
|
await this.coordinator.withLock(handle.repoPath, async () => {
|
|
159
183
|
if (await directoryExists(handle.worktreePath)) {
|
|
184
|
+
// Never delete work that could not be saved: this throws and keeps the worktree.
|
|
185
|
+
await guardWorktreeRelease(handle);
|
|
160
186
|
// On Windows, `git worktree remove` can delete the `.git` link and then
|
|
161
187
|
// fail on a locked build output. That leaves a full source tree which is
|
|
162
188
|
// no longer a Git worktree and makes every retry fail during prepare.
|
|
@@ -176,6 +202,12 @@ export class GitWorktreeService {
|
|
|
176
202
|
// directory is fully materialized (or after an external cleanup removes it).
|
|
177
203
|
// Always prune so those missing-directory registrations do not accumulate.
|
|
178
204
|
await this.git.run(handle.repoPath, ["worktree", "prune", "--expire", "now"]).catch(() => undefined);
|
|
205
|
+
worktreeReleased(handle);
|
|
206
|
+
// A readiness probe's branch goes with its worktree. Other Forge branches on this device
|
|
207
|
+
// whose work is already merged into the base go too; branches with unmerged work stay.
|
|
208
|
+
// A lease can be live while its worktree is briefly missing, so its branch is protected
|
|
209
|
+
// even when no worktree has it checked out. If the ledger can't be read, sweep nothing.
|
|
210
|
+
await sweepBranchesAfterRelease(this.git, handle, this.leaseStateRoot, releaseSweepLimit);
|
|
179
211
|
});
|
|
180
212
|
}
|
|
181
213
|
async restoreOrphanedWorktree(input) {
|
|
@@ -187,6 +219,7 @@ export class GitWorktreeService {
|
|
|
187
219
|
if (!isSubPath(input.allowedRoot, quarantinePath)) {
|
|
188
220
|
throw new Error(`Worktree recovery path must stay under ${input.allowedRoot}.`);
|
|
189
221
|
}
|
|
222
|
+
await guardBranchReset(this.git, input.repoPath, input.branchName, input.baseStartPoint);
|
|
190
223
|
await fs.rename(input.worktreePath, quarantinePath);
|
|
191
224
|
try {
|
|
192
225
|
await this.git.run(input.repoPath, ["worktree", "prune", "--expire", "now"]);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { DispatchQaReworkContext, DispatchPriorPhaseArtifact, DispatchRepo, DispatchWorkItem, DispatchResolvedArtifact, DispatchStoryQaContext } from "../session/session.types.js";
|
|
2
2
|
import type { WarmDependenciesResult } from "./dependency-warmer.js";
|
|
3
|
+
import type { WipSnapshotReason } from "./wip-refs.js";
|
|
4
|
+
import type { WipRestoreOutcome } from "./wip-restore.js";
|
|
5
|
+
import type { WipSnapshotResult } from "./wip-snapshot.js";
|
|
3
6
|
export interface WorktreePrepareRequest {
|
|
4
7
|
readonly repo: DispatchRepo;
|
|
5
8
|
readonly workItem: DispatchWorkItem;
|
|
@@ -21,6 +24,8 @@ export interface WorktreePrepareRequest {
|
|
|
21
24
|
readonly warmPathOverrides?: readonly string[];
|
|
22
25
|
readonly applicationRuntimeRequired?: boolean;
|
|
23
26
|
readonly preserveExistingState?: boolean;
|
|
27
|
+
/** The session this worktree is prepared for; names its WIP snapshots and enables restoring one. */
|
|
28
|
+
readonly sessionId?: string | null;
|
|
24
29
|
/** The attempt dependency installs reserve host capacity for (decision 0013). */
|
|
25
30
|
readonly hostLoadOwner?: {
|
|
26
31
|
readonly dispatchAttemptId: string | null;
|
|
@@ -38,4 +43,21 @@ export interface WorktreeHandle {
|
|
|
38
43
|
readonly dependencyWarm?: WarmDependenciesResult;
|
|
39
44
|
readonly qaReworkPacketPath?: string;
|
|
40
45
|
readonly hydratedPriorPhaseArtifactCount?: number;
|
|
46
|
+
readonly sessionId?: string | null;
|
|
47
|
+
readonly lane?: string;
|
|
48
|
+
/** What happened to the story's saved WIP when this worktree was prepared. */
|
|
49
|
+
readonly wipRestore?: WipRestoreOutcome;
|
|
50
|
+
}
|
|
51
|
+
/** How a session ended, for its WIP snapshot: null when it succeeded. */
|
|
52
|
+
export interface WipSessionOutcome {
|
|
53
|
+
readonly reason: WipSnapshotReason | null;
|
|
54
|
+
}
|
|
55
|
+
export interface WipSettlement {
|
|
56
|
+
readonly snapshot?: WipSnapshotResult;
|
|
57
|
+
readonly error?: {
|
|
58
|
+
readonly code: string;
|
|
59
|
+
readonly message: string;
|
|
60
|
+
};
|
|
61
|
+
/** The restored snapshot's ref, deleted because this session's work supersedes it. */
|
|
62
|
+
readonly retiredRef?: string | null;
|
|
41
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.1.4-dev.
|
|
3
|
+
"version": "0.1.4-dev.91ee995ac965",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test:residue": "node scripts/run-owned-residue-gate.mjs",
|
|
44
44
|
"test:watch": "vitest",
|
|
45
45
|
"smoke:package": "tsc -p tsconfig.json && node scripts/smoke-package.mjs",
|
|
46
|
-
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"vitest.setup.ts\""
|
|
46
|
+
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"vitest.setup.ts\" && node ../../scripts/class-design/check-eslint-ratchet.mjs bridge"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@microsoft/signalr": "^8.0.17",
|