Skip to content

Commit dd86655

Browse files
tryeverything24JSONbored
authored andcommitted
chore(miner): migrate batch 4.1 foundational lib modules to TypeScript
Converts claim-adjudication, governor-chokepoint-persisted, sentry, idea-feasibility, rejection-state-machine, attempt-worktree, portfolio-discovery, and process-lifecycle from plain .js + hand-maintained .d.ts to real .ts under the existing in-place tsc emit pipeline from #7299. Extends targeted unit tests to drive every converted file to 100% statement/branch/function/line coverage.
1 parent 32e0998 commit dd86655

28 files changed

Lines changed: 1392 additions & 569 deletions
Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
11
import type { WorktreeExecFn } from "@loopover/engine";
22
import type { RunGitFn } from "./repo-clone.js";
3-
4-
export function createRealWorktreeExec(timeoutMs?: number): WorktreeExecFn;
5-
3+
/**
4+
* Real child_process-backed implementation of the engine's WorktreeExecFn contract. Resolves (never
5+
* rejects) on error/timeout, mirroring coding-agent-construction.js's createRealCliSubprocessSpawn -- a
6+
* failed `git worktree add`'s stderr is the diagnosable signal, not something to lose to an unhandled
7+
* rejection.
8+
*/
9+
export declare function createRealWorktreeExec(timeoutMs?: number): WorktreeExecFn;
610
export type PrepareAttemptWorktreeOptions = {
7-
baseBranch?: string;
8-
cloneBaseDir?: string;
9-
env?: Record<string, string | undefined>;
10-
exec?: WorktreeExecFn;
11-
timeoutMs?: number;
12-
remoteUrl?: string;
13-
runGit?: RunGitFn;
11+
baseBranch?: string;
12+
cloneBaseDir?: string;
13+
env?: Record<string, string | undefined>;
14+
exec?: WorktreeExecFn;
15+
timeoutMs?: number;
16+
remoteUrl?: string;
17+
runGit?: RunGitFn;
1418
};
15-
16-
export type PrepareAttemptWorktreeResult =
17-
| { ok: true; worktreePath: string; branchName: string; repoPath: string }
18-
| { ok: false; repoPath?: string; error: string };
19-
20-
export function prepareAttemptWorktree(
21-
repoFullName: string,
22-
attemptId: string,
23-
options?: PrepareAttemptWorktreeOptions,
24-
): Promise<PrepareAttemptWorktreeResult>;
25-
26-
export function cleanupAttemptWorktree(
27-
repoPath: string,
28-
worktreePath: string,
29-
attemptOk: boolean,
30-
options?: { exec?: WorktreeExecFn; timeoutMs?: number },
31-
): Promise<{ ok: boolean; removed: boolean; error?: string }>;
19+
export type PrepareAttemptWorktreeResult = {
20+
ok: true;
21+
worktreePath: string;
22+
branchName: string;
23+
repoPath: string;
24+
} | {
25+
ok: false;
26+
repoPath?: string;
27+
error: string;
28+
};
29+
/**
30+
* Prepare a real, isolated git worktree for one attempt: ensure the target repo's base clone exists and is
31+
* current, then create a fresh `git worktree` off it on a deterministically-named branch. Fails closed
32+
* (`ok: false`) on any step's failure rather than handing back a half-prepared directory.
33+
*/
34+
export declare function prepareAttemptWorktree(repoFullName: string, attemptId: string, options?: PrepareAttemptWorktreeOptions): Promise<PrepareAttemptWorktreeResult>;
35+
/**
36+
* Tear down an attempt's worktree once the attempt concludes, per the engine's own retention policy: a
37+
* failed attempt's worktree is RETAINED for post-mortem inspection, a succeeded one is removed.
38+
*/
39+
export declare function cleanupAttemptWorktree(repoPath: string, worktreePath: string, attemptOk: boolean, options?: {
40+
exec?: WorktreeExecFn;
41+
timeoutMs?: number;
42+
}): Promise<{
43+
ok: boolean;
44+
removed: boolean;
45+
error?: string;
46+
}>;

packages/loopover-miner/lib/attempt-worktree.js

Lines changed: 48 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)