@on-par/factory-core 0.9.13 → 0.9.14-next.10
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/dist/config/build-route.d.ts +35 -0
- package/dist/config/build-route.d.ts.map +1 -0
- package/dist/config/build-route.js +47 -0
- package/dist/config/build-route.js.map +1 -0
- package/dist/config/config-schema-lint.d.ts.map +1 -1
- package/dist/config/config-schema-lint.js +20 -25
- package/dist/config/config-schema-lint.js.map +1 -1
- package/dist/config/effort.d.ts.map +1 -1
- package/dist/config/effort.js +0 -1
- package/dist/config/effort.js.map +1 -1
- package/dist/config/index.d.ts +3 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +25 -73
- package/dist/config/index.js.map +1 -1
- package/dist/config/policy.d.ts +4 -6
- package/dist/config/policy.d.ts.map +1 -1
- package/dist/config/policy.js +29 -38
- package/dist/config/policy.js.map +1 -1
- package/dist/config/precedence.d.ts +17 -0
- package/dist/config/precedence.d.ts.map +1 -0
- package/dist/config/precedence.js +13 -0
- package/dist/config/precedence.js.map +1 -0
- package/dist/config/repo-config-file.d.ts +4 -0
- package/dist/config/repo-config-file.d.ts.map +1 -1
- package/dist/config/repo-config-file.js +35 -0
- package/dist/config/repo-config-file.js.map +1 -1
- package/dist/config/repo-harnesses.js +3 -3
- package/dist/config/repo-harnesses.js.map +1 -1
- package/dist/config/repo.d.ts +4 -18
- package/dist/config/repo.d.ts.map +1 -1
- package/dist/config/repo.js +115 -164
- package/dist/config/repo.js.map +1 -1
- package/dist/config/sandbox-schema.d.ts +30 -0
- package/dist/config/sandbox-schema.d.ts.map +1 -0
- package/dist/config/sandbox-schema.js +39 -0
- package/dist/config/sandbox-schema.js.map +1 -0
- package/dist/config/v2.d.ts +1 -0
- package/dist/config/v2.d.ts.map +1 -1
- package/dist/config/v2.js +1 -0
- package/dist/config/v2.js.map +1 -1
- package/dist/harness/catalog.d.ts +17 -0
- package/dist/harness/catalog.d.ts.map +1 -1
- package/dist/harness/catalog.js +35 -8
- package/dist/harness/catalog.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +6 -5
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +5 -4
- package/dist/internal.js.map +1 -1
- package/dist/models/index.d.ts +3 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +7 -15
- package/dist/models/index.js.map +1 -1
- package/dist/phases/build-prompts.d.ts.map +1 -1
- package/dist/phases/build-prompts.js +3 -0
- package/dist/phases/build-prompts.js.map +1 -1
- package/dist/phases/ship.d.ts.map +1 -1
- package/dist/phases/ship.js +24 -16
- package/dist/phases/ship.js.map +1 -1
- package/dist/queue/claim-liveness.d.ts +17 -0
- package/dist/queue/claim-liveness.d.ts.map +1 -0
- package/dist/queue/claim-liveness.js +25 -0
- package/dist/queue/claim-liveness.js.map +1 -0
- package/dist/queue/github-queue.js +13 -12
- package/dist/queue/github-queue.js.map +1 -1
- package/dist/queue/stale-claims.d.ts.map +1 -1
- package/dist/queue/stale-claims.js +6 -18
- package/dist/queue/stale-claims.js.map +1 -1
- package/dist/router/index.d.ts +5 -20
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +29 -310
- package/dist/router/index.js.map +1 -1
- package/dist/run/adopt-pr.d.ts +1 -0
- package/dist/run/adopt-pr.d.ts.map +1 -1
- package/dist/run/adopt-pr.js +21 -30
- package/dist/run/adopt-pr.js.map +1 -1
- package/dist/run/check-verdict.d.ts +13 -0
- package/dist/run/check-verdict.d.ts.map +1 -0
- package/dist/run/check-verdict.js +27 -0
- package/dist/run/check-verdict.js.map +1 -0
- package/dist/run/ci-rework-loop.d.ts +7 -3
- package/dist/run/ci-rework-loop.d.ts.map +1 -1
- package/dist/run/ci-rework-loop.js +4 -11
- package/dist/run/ci-rework-loop.js.map +1 -1
- package/dist/run/lane-file-guard.d.ts +2 -2
- package/dist/run/lane-file-guard.d.ts.map +1 -1
- package/dist/run/lane-file-guard.js +4 -9
- package/dist/run/lane-file-guard.js.map +1 -1
- package/dist/run/max-lines-override.d.ts +11 -0
- package/dist/run/max-lines-override.d.ts.map +1 -0
- package/dist/run/max-lines-override.js +17 -0
- package/dist/run/max-lines-override.js.map +1 -0
- package/dist/run/park-comment.d.ts +20 -1
- package/dist/run/park-comment.d.ts.map +1 -1
- package/dist/run/park-comment.js +25 -5
- package/dist/run/park-comment.js.map +1 -1
- package/dist/run/ports.d.ts +2 -0
- package/dist/run/ports.d.ts.map +1 -1
- package/dist/run/ports.js +1 -0
- package/dist/run/ports.js.map +1 -1
- package/dist/run/pr-lookup.d.ts +56 -0
- package/dist/run/pr-lookup.d.ts.map +1 -0
- package/dist/run/pr-lookup.js +67 -0
- package/dist/run/pr-lookup.js.map +1 -0
- package/dist/run/run-issue.d.ts.map +1 -1
- package/dist/run/run-issue.js +79 -69
- package/dist/run/run-issue.js.map +1 -1
- package/dist/run/terminal-events.d.ts +4 -0
- package/dist/run/terminal-events.d.ts.map +1 -0
- package/dist/run/terminal-events.js +15 -0
- package/dist/run/terminal-events.js.map +1 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +5 -1
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/writable-paths.d.ts +11 -0
- package/dist/sandbox/writable-paths.d.ts.map +1 -0
- package/dist/sandbox/writable-paths.js +45 -0
- package/dist/sandbox/writable-paths.js.map +1 -0
- package/dist/sim/pipeline.js +1 -1
- package/dist/sim/pipeline.js.map +1 -1
- package/dist/usage/index.js +1 -1
- package/dist/usage/index.js.map +1 -1
- package/dist/utils/index.d.ts +8 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +7 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lane-removal.d.ts +15 -0
- package/dist/utils/lane-removal.d.ts.map +1 -0
- package/dist/utils/lane-removal.js +51 -0
- package/dist/utils/lane-removal.js.map +1 -0
- package/dist/utils/worktree-gc.d.ts +1 -171
- package/dist/utils/worktree-gc.d.ts.map +1 -1
- package/dist/utils/worktree-gc.js +2 -739
- package/dist/utils/worktree-gc.js.map +1 -1
- package/dist/utils/worktree-keeps.d.ts +1 -19
- package/dist/utils/worktree-keeps.d.ts.map +1 -1
- package/dist/utils/worktree-keeps.js +2 -64
- package/dist/utils/worktree-keeps.js.map +1 -1
- package/dist/utils/worktree-name.d.ts +1 -9
- package/dist/utils/worktree-name.d.ts.map +1 -1
- package/dist/utils/worktree-name.js +2 -30
- package/dist/utils/worktree-name.js.map +1 -1
- package/dist/worktree/worktree-gc-decide.d.ts +40 -0
- package/dist/worktree/worktree-gc-decide.d.ts.map +1 -0
- package/dist/worktree/worktree-gc-decide.js +117 -0
- package/dist/worktree/worktree-gc-decide.js.map +1 -0
- package/dist/worktree/worktree-gc-evidence.d.ts +87 -0
- package/dist/worktree/worktree-gc-evidence.d.ts.map +1 -0
- package/dist/worktree/worktree-gc-evidence.js +206 -0
- package/dist/worktree/worktree-gc-evidence.js.map +1 -0
- package/dist/worktree/worktree-gc-issues.d.ts +26 -0
- package/dist/worktree/worktree-gc-issues.d.ts.map +1 -0
- package/dist/worktree/worktree-gc-issues.js +51 -0
- package/dist/worktree/worktree-gc-issues.js.map +1 -0
- package/dist/worktree/worktree-gc-scrub.d.ts +10 -0
- package/dist/worktree/worktree-gc-scrub.d.ts.map +1 -0
- package/dist/worktree/worktree-gc-scrub.js +89 -0
- package/dist/worktree/worktree-gc-scrub.js.map +1 -0
- package/dist/worktree/worktree-gc-types.d.ts +142 -0
- package/dist/worktree/worktree-gc-types.d.ts.map +1 -0
- package/dist/worktree/worktree-gc-types.js +33 -0
- package/dist/worktree/worktree-gc-types.js.map +1 -0
- package/dist/worktree/worktree-gc.d.ts +32 -0
- package/dist/worktree/worktree-gc.d.ts.map +1 -0
- package/dist/worktree/worktree-gc.js +313 -0
- package/dist/worktree/worktree-gc.js.map +1 -0
- package/dist/worktree/worktree-keeps.d.ts +20 -0
- package/dist/worktree/worktree-keeps.d.ts.map +1 -0
- package/dist/worktree/worktree-keeps.js +65 -0
- package/dist/worktree/worktree-keeps.js.map +1 -0
- package/dist/worktree/worktree-name.d.ts +10 -0
- package/dist/worktree/worktree-name.d.ts.map +1 -0
- package/dist/worktree/worktree-name.js +31 -0
- package/dist/worktree/worktree-name.js.map +1 -0
- package/package.json +5 -5
- package/dist/utils/worktree-gc-issues.d.ts +0 -22
- package/dist/utils/worktree-gc-issues.d.ts.map +0 -1
- package/dist/utils/worktree-gc-issues.js +0 -80
- package/dist/utils/worktree-gc-issues.js.map +0 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// src/worktree/worktree-gc-evidence.ts — gathers one evidence record per worktree for decideWorktree
|
|
2
|
+
import { exec as execCb } from 'node:child_process';
|
|
3
|
+
import { statSync } from 'node:fs';
|
|
4
|
+
import { basename, join } from 'node:path';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { shellEscape } from '../utils/index.js';
|
|
7
|
+
import { claimOf, dispositionOf, existenceOf, fetchIssueRecord, } from './worktree-gc-issues.js';
|
|
8
|
+
const exec = promisify(execCb);
|
|
9
|
+
export async function defaultRunCommand(cmd, opts) {
|
|
10
|
+
const { stdout } = await exec(cmd, opts);
|
|
11
|
+
return { stdout: stdout.toString() };
|
|
12
|
+
}
|
|
13
|
+
function safeExec(runCommand, cmd, opts) {
|
|
14
|
+
return runCommand(cmd, opts).catch(() => null);
|
|
15
|
+
}
|
|
16
|
+
export async function resolveMainTip(runCommand, repoRoot) {
|
|
17
|
+
const result = await safeExec(runCommand, 'git rev-parse --verify origin/main', { cwd: repoRoot });
|
|
18
|
+
const sha = result?.stdout.trim() ?? '';
|
|
19
|
+
return sha === '' ? null : sha;
|
|
20
|
+
}
|
|
21
|
+
async function hasPriorPushEvidence(runCommand, repoRoot, branch) {
|
|
22
|
+
const trackingRef = await safeExec(runCommand, `git rev-parse --verify --quiet ${shellEscape(`refs/remotes/origin/${branch}`)}`, { cwd: repoRoot });
|
|
23
|
+
if (trackingRef !== null && trackingRef.stdout.trim() !== '')
|
|
24
|
+
return true;
|
|
25
|
+
const reflog = await safeExec(runCommand, `git reflog show --no-abbrev ${shellEscape(`refs/remotes/origin/${branch}`)}`, { cwd: repoRoot });
|
|
26
|
+
if (reflog !== null && reflog.stdout.trim() !== '')
|
|
27
|
+
return true;
|
|
28
|
+
const upstream = await safeExec(runCommand, `git config --get ${shellEscape(`branch.${branch}.merge`)}`, {
|
|
29
|
+
cwd: repoRoot,
|
|
30
|
+
});
|
|
31
|
+
// git sets branch.<name>.merge automatically at worktree-creation time from the start point
|
|
32
|
+
// (e.g. `git worktree add -b <branch> <path> origin/main` sets it to refs/heads/main), so a
|
|
33
|
+
// non-empty value alone is not proof of a push. Only `git push -u origin <branch>` points it at
|
|
34
|
+
// the branch's own ref — require that exact match.
|
|
35
|
+
return upstream !== null && upstream.stdout.trim() === `refs/heads/${branch}`;
|
|
36
|
+
}
|
|
37
|
+
/** GitHub's verdict on the branch's PRs. `null` when no client/repo is available or the query
|
|
38
|
+
* fails — the caller must then fall back to local evidence (fail-safe: keep on doubt). */
|
|
39
|
+
async function resolvePrState(octokit, repo, branch, log) {
|
|
40
|
+
if (!octokit || !repo)
|
|
41
|
+
return null;
|
|
42
|
+
const [owner, repoName] = repo.split('/');
|
|
43
|
+
try {
|
|
44
|
+
const { data } = await octokit.rest.pulls.list({
|
|
45
|
+
owner,
|
|
46
|
+
repo: repoName,
|
|
47
|
+
state: 'all',
|
|
48
|
+
head: `${owner}:${branch}`,
|
|
49
|
+
});
|
|
50
|
+
if (data.some((pr) => pr.state === 'open'))
|
|
51
|
+
return 'open';
|
|
52
|
+
const merged = data.find((pr) => pr.merged_at != null);
|
|
53
|
+
if (merged)
|
|
54
|
+
return 'merged';
|
|
55
|
+
if (data.some((pr) => pr.state === 'closed'))
|
|
56
|
+
return 'closed';
|
|
57
|
+
return 'none';
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
log('warn', `worktree-gc: GitHub PR query failed for ${branch} (${err?.message ?? String(err)}) — using local evidence only`);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** The lane issue number a candidate belongs to: capture group 1 of the lane-branch shape
|
|
65
|
+
* `<prefix>/<n>-*`, falling back to a trailing `-<n>` in the directory basename (covers
|
|
66
|
+
* detached checkouts of factory-named paths). `null` when neither matches. */
|
|
67
|
+
export function laneIssueNumber(entry, lanePattern) {
|
|
68
|
+
const fromBranch = entry.branch?.match(lanePattern);
|
|
69
|
+
if (fromBranch)
|
|
70
|
+
return Number(fromBranch[1]);
|
|
71
|
+
const fromPath = basename(entry.path).match(/-(\d+)$/);
|
|
72
|
+
return fromPath ? Number(fromPath[1]) : null;
|
|
73
|
+
}
|
|
74
|
+
/** A worktree is clean when it has no modified tracked files. `--untracked-files=no` deliberately
|
|
75
|
+
* ignores untracked build residue (node_modules, artifacts) — the "live work" signal is tracked-file
|
|
76
|
+
* modifications. A probe failure (`safeExec` null) ⇒ false ⇒ keep. */
|
|
77
|
+
export async function isWorktreeClean(runCommand, worktreePath) {
|
|
78
|
+
const result = await safeExec(runCommand, 'git status --porcelain --untracked-files=no', { cwd: worktreePath });
|
|
79
|
+
return result !== null && result.stdout.trim() === '';
|
|
80
|
+
}
|
|
81
|
+
/** Commits reachable from `rev` that are on no `origin` ref; null when the probe fails or is unparseable (⇒ keep). */
|
|
82
|
+
export async function countUnpushedCommits(runCommand, repoRoot, rev) {
|
|
83
|
+
const result = await safeExec(runCommand, `git rev-list --count ${shellEscape(rev)} --not --remotes=origin`, {
|
|
84
|
+
cwd: repoRoot,
|
|
85
|
+
});
|
|
86
|
+
const n = result === null ? NaN : Number.parseInt(result.stdout.trim(), 10);
|
|
87
|
+
return Number.isInteger(n) ? n : null;
|
|
88
|
+
}
|
|
89
|
+
/** True only when `head` has exactly 0 commits ahead of origin/main — a lane that has not committed
|
|
90
|
+
* yet (every lane starts at origin/main), never proof of a merge (#2964). Probe failure ⇒ false. */
|
|
91
|
+
export async function isZeroCommitLane(runCommand, repoRoot, head) {
|
|
92
|
+
if (head === null)
|
|
93
|
+
return false;
|
|
94
|
+
const result = await safeExec(runCommand, `git rev-list --count origin/main..${shellEscape(head)}`, {
|
|
95
|
+
cwd: repoRoot,
|
|
96
|
+
});
|
|
97
|
+
return result !== null && result.stdout.trim() === '0';
|
|
98
|
+
}
|
|
99
|
+
export function computeAgeDays(worktreePath, now, log) {
|
|
100
|
+
const gitPath = join(worktreePath, '.git');
|
|
101
|
+
try {
|
|
102
|
+
const mtimeMs = statSync(gitPath).mtimeMs;
|
|
103
|
+
return (now() - mtimeMs) / (24 * 60 * 60 * 1000);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
// An inconclusive probe must never mean "delete" — this directory may hold the only copy of
|
|
107
|
+
// uncommitted work.
|
|
108
|
+
log('warn', `worktree-gc: cannot stat ${gitPath} (${err?.message ?? String(err)}) — treating as age 0 (keeping)`);
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export function createEvidenceContext(opts, deps) {
|
|
113
|
+
return {
|
|
114
|
+
repoRoot: opts.repoRoot,
|
|
115
|
+
repo: opts.repo,
|
|
116
|
+
dryRun: opts.dryRun,
|
|
117
|
+
lanePattern: opts.lanePattern,
|
|
118
|
+
protectedIssues: opts.protectedIssues,
|
|
119
|
+
keeps: opts.keeps,
|
|
120
|
+
mainTip: opts.mainTip,
|
|
121
|
+
runCommand: deps.runCommand,
|
|
122
|
+
now: deps.now,
|
|
123
|
+
log: deps.log,
|
|
124
|
+
octokit: deps.octokit,
|
|
125
|
+
issueWarnDedup: deps.issueWarnDedup,
|
|
126
|
+
issueRecords: new Map(),
|
|
127
|
+
prStates: new Map(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function issueRecordFor(ctx, issue) {
|
|
131
|
+
let record = ctx.issueRecords.get(issue);
|
|
132
|
+
if (!record) {
|
|
133
|
+
record = fetchIssueRecord(ctx.octokit, ctx.repo, issue, ctx.log, ctx.issueWarnDedup);
|
|
134
|
+
ctx.issueRecords.set(issue, record);
|
|
135
|
+
}
|
|
136
|
+
return record;
|
|
137
|
+
}
|
|
138
|
+
function prStateFor(ctx, branch) {
|
|
139
|
+
let state = ctx.prStates.get(branch);
|
|
140
|
+
if (!state) {
|
|
141
|
+
state = resolvePrState(ctx.octokit, ctx.repo, branch, ctx.log);
|
|
142
|
+
ctx.prStates.set(branch, state);
|
|
143
|
+
}
|
|
144
|
+
return state;
|
|
145
|
+
}
|
|
146
|
+
const NO_GIT = {
|
|
147
|
+
clean: false,
|
|
148
|
+
zeroCommit: false,
|
|
149
|
+
priorPush: false,
|
|
150
|
+
remoteBranch: null,
|
|
151
|
+
headIsAncestorOfMain: false,
|
|
152
|
+
mainTip: null,
|
|
153
|
+
unpushedCount: null,
|
|
154
|
+
};
|
|
155
|
+
async function gatherGitEvidence(ctx, entry, prState) {
|
|
156
|
+
const { runCommand, repoRoot } = ctx;
|
|
157
|
+
const { branch, head } = entry;
|
|
158
|
+
const lsRemote = branch
|
|
159
|
+
? await safeExec(runCommand, `git ls-remote --heads origin ${shellEscape(branch)}`, { cwd: repoRoot })
|
|
160
|
+
: null;
|
|
161
|
+
const ancestor = head === null
|
|
162
|
+
? null
|
|
163
|
+
: await safeExec(runCommand, `git merge-base --is-ancestor ${shellEscape(head)} origin/main`, { cwd: repoRoot });
|
|
164
|
+
return {
|
|
165
|
+
clean: await isWorktreeClean(runCommand, entry.path),
|
|
166
|
+
zeroCommit: await isZeroCommitLane(runCommand, repoRoot, head),
|
|
167
|
+
// Only the no-PR-verdict local-evidence rules consult push history.
|
|
168
|
+
priorPush: branch && (prState === null || prState === 'none')
|
|
169
|
+
? await hasPriorPushEvidence(runCommand, repoRoot, branch)
|
|
170
|
+
: false,
|
|
171
|
+
remoteBranch: lsRemote === null ? null : lsRemote.stdout.trim() === '' ? 'absent' : 'present',
|
|
172
|
+
headIsAncestorOfMain: ancestor !== null,
|
|
173
|
+
mainTip: ctx.mainTip,
|
|
174
|
+
unpushedCount: head ? await countUnpushedCommits(runCommand, repoRoot, head) : null,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** Collects every fact decideWorktree may consult. Probes are read-only, so gathering them up
|
|
178
|
+
* front cannot change their answers. A protected entry skips git probes (and, outside dry-run,
|
|
179
|
+
* GitHub lookups: dry-run's diagnostics cover every candidate). */
|
|
180
|
+
export async function gatherWorktreeEvidence(ctx, entry) {
|
|
181
|
+
const issue = laneIssueNumber(entry, ctx.lanePattern);
|
|
182
|
+
const isProtected = issue !== null && ctx.protectedIssues?.has(issue) === true;
|
|
183
|
+
const base = { path: entry.path, branch: entry.branch, head: entry.head, issue, protected: isProtected };
|
|
184
|
+
const lookUp = !isProtected || ctx.dryRun;
|
|
185
|
+
const record = lookUp && issue !== null ? await issueRecordFor(ctx, issue) : { kind: 'not-configured' };
|
|
186
|
+
const prState = lookUp && entry.branch ? await prStateFor(ctx, entry.branch) : null;
|
|
187
|
+
const issueFields = {
|
|
188
|
+
disposition: issue === null ? null : dispositionOf(record, issue),
|
|
189
|
+
existence: existenceOf(record),
|
|
190
|
+
claim: issue === null ? 'unknown' : claimOf(record, issue),
|
|
191
|
+
...(record.kind === 'error' || record.kind === 'not-found' ? { issueError: record.message } : {}),
|
|
192
|
+
};
|
|
193
|
+
if (isProtected) {
|
|
194
|
+
return { ...base, keep: null, ageDays: 0, ...issueFields, prState, git: NO_GIT };
|
|
195
|
+
}
|
|
196
|
+
const keep = issue === null ? undefined : ctx.keeps.get(issue);
|
|
197
|
+
return {
|
|
198
|
+
...base,
|
|
199
|
+
keep: keep ? { issue: keep.issue, reason: keep.reason } : null,
|
|
200
|
+
ageDays: computeAgeDays(entry.path, ctx.now, ctx.log),
|
|
201
|
+
...issueFields,
|
|
202
|
+
prState,
|
|
203
|
+
git: await gatherGitEvidence(ctx, entry, prState),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=worktree-gc-evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc-evidence.js","sourceRoot":"","sources":["../../src/worktree/worktree-gc-evidence.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAErG,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,gBAAgB,GAGjB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAW,EAAE,IAAuB;IAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,QAAQ,CACf,UAAgD,EAChD,GAAW,EACX,IAAuB;IAEvB,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAgD,EAChD,QAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,oCAAoC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;I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AAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClG,CAAC;IAEF,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACnF,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;QAC9D,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;QACrD,GAAG,WAAW;QACd,OAAO;QACP,GAAG,EAAE,MAAM,iBAAiB,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EventKind } from '../events/kinds.js';
|
|
2
|
+
import type { IssueWarnDedup, SweepDeps } from './worktree-gc-types.js';
|
|
3
|
+
/** The owning issue's verdict on a lane worktree. `null` means "no verdict" (no client/repo,
|
|
4
|
+
* or the query failed) and must always fall back to the PR-state/local-evidence rules. */
|
|
5
|
+
export type IssueDisposition = 'reap-closed' | 'reap-parked' | 'reap-decomposed' | 'keep-claimed' | 'keep';
|
|
6
|
+
/** One `issues.get` response (or why there is none), fetched once per issue per sweep; the
|
|
7
|
+
* disposition, existence and claim verdicts are all derived from it. */
|
|
8
|
+
export type IssueRecord = {
|
|
9
|
+
kind: 'ok';
|
|
10
|
+
state: string;
|
|
11
|
+
labels: string[];
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'not-found';
|
|
14
|
+
message: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'error';
|
|
17
|
+
message: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'not-configured';
|
|
20
|
+
};
|
|
21
|
+
export declare function fetchIssueRecord(octokit: SweepDeps['octokit'], repo: string | undefined, issue: number, log: (type: EventKind, msg: string) => void, issueWarnDedup: IssueWarnDedup): Promise<IssueRecord>;
|
|
22
|
+
/** The disposition resolveIssueDisposition computes, from an already-fetched record. */
|
|
23
|
+
export declare function dispositionOf(record: IssueRecord, _issue: number): IssueDisposition | null;
|
|
24
|
+
export declare function existenceOf(record: IssueRecord): 'exists' | 'not-found' | 'error' | 'not-configured';
|
|
25
|
+
export declare function claimOf(record: IssueRecord, _issue: number): 'claimed' | 'unclaimed' | 'unknown';
|
|
26
|
+
//# sourceMappingURL=worktree-gc-issues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc-issues.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-gc-issues.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExE;2FAC2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,GAAG,cAAc,GAAG,MAAM,CAAC;AAE3G;yEACyE;AACzE,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE/B,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,EAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,EAC3C,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAMD,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAQ1F;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,gBAAgB,CAGpG;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAGhG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { claimIsLive, claimLiveness } from '../queue/claim-liveness.js';
|
|
2
|
+
import { DECOMPOSED_LABEL, PARKED_LABEL } from '../queue/github-queue.js';
|
|
3
|
+
export async function fetchIssueRecord(octokit, repo, issue, log, issueWarnDedup) {
|
|
4
|
+
if (!octokit || !repo)
|
|
5
|
+
return { kind: 'not-configured' };
|
|
6
|
+
const [owner, repoName] = repo.split('/');
|
|
7
|
+
try {
|
|
8
|
+
const { data } = await octokit.rest.issues.get({ owner, repo: repoName, issue_number: issue });
|
|
9
|
+
const labels = (data.labels ?? []).map((l) => (typeof l === 'string' ? l : (l?.name ?? '')));
|
|
10
|
+
return { kind: 'ok', state: data.state, labels };
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
const message = err?.message ?? String(err);
|
|
14
|
+
if (issueWarnDedup.record(issue)) {
|
|
15
|
+
log('warn', `worktree-gc: GitHub issue query failed for #${issue} (${message}) — using PR/local evidence only`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
log('warn', `worktree-gc: GitHub issue query failed for #${issue} — suppressed ${issueWarnDedup.suppressedCount(issue)} repeated warning(s) (using PR/local evidence only)`);
|
|
19
|
+
}
|
|
20
|
+
return { kind: err?.status === 404 ? 'not-found' : 'error', message };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function hasLiveClaim(labels) {
|
|
24
|
+
return claimIsLive(claimLiveness(labels, Date.now()));
|
|
25
|
+
}
|
|
26
|
+
/** The disposition resolveIssueDisposition computes, from an already-fetched record. */
|
|
27
|
+
export function dispositionOf(record, _issue) {
|
|
28
|
+
if (record.kind !== 'ok')
|
|
29
|
+
return null;
|
|
30
|
+
if (record.state === 'closed')
|
|
31
|
+
return 'reap-closed';
|
|
32
|
+
// A lapsed lease is expired in the shared claim verdict and does not protect (#2964, #3442).
|
|
33
|
+
if (hasLiveClaim(record.labels))
|
|
34
|
+
return 'keep-claimed';
|
|
35
|
+
if (record.labels.includes(PARKED_LABEL))
|
|
36
|
+
return 'reap-parked';
|
|
37
|
+
if (record.labels.includes(DECOMPOSED_LABEL))
|
|
38
|
+
return 'reap-decomposed';
|
|
39
|
+
return 'keep';
|
|
40
|
+
}
|
|
41
|
+
export function existenceOf(record) {
|
|
42
|
+
if (record.kind === 'ok')
|
|
43
|
+
return 'exists';
|
|
44
|
+
return record.kind;
|
|
45
|
+
}
|
|
46
|
+
export function claimOf(record, _issue) {
|
|
47
|
+
if (record.kind !== 'ok')
|
|
48
|
+
return 'unknown';
|
|
49
|
+
return hasLiveClaim(record.labels) ? 'claimed' : 'unclaimed';
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=worktree-gc-issues.js.map
|
|
@@ -0,0 +1 @@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AAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function findCredentialFiles(worktreePath: string): string[];
|
|
2
|
+
/** Zero a file in place through one fd opened with O_NOFOLLOW. The worktree's agent can swap
|
|
3
|
+
* a credential file for a symlink after `findCredentialFiles` walks it; a path-based
|
|
4
|
+
* stat + write would then zero the link's target (e.g. `~/.ssh/id_*`). Throws ELOOP on a
|
|
5
|
+
* symlink and refuses anything that is not a regular file. */
|
|
6
|
+
export declare function zeroFill(filePath: string): void;
|
|
7
|
+
/** Zero-fill then delete. A symlink is unlinked without zeroing — rm removes the link, never
|
|
8
|
+
* its target. */
|
|
9
|
+
export declare function scrubFile(filePath: string): void;
|
|
10
|
+
//# sourceMappingURL=worktree-gc-scrub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc-scrub.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-gc-scrub.ts"],"names":[],"mappings":"AAQA,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CA0BlE;AA4BD;;;+DAG+D;AAC/D,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAa/C;AAED;kBACkB;AAClB,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAOhD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// src/worktree/worktree-gc-scrub.ts — credential discovery and in-place scrub for reaped worktrees
|
|
2
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readdirSync, rmSync, writeSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
const CREDENTIAL_BASENAMES = new Set(['.git-credentials', '.npmrc']);
|
|
5
|
+
export function findCredentialFiles(worktreePath) {
|
|
6
|
+
const found = [];
|
|
7
|
+
let topLevel;
|
|
8
|
+
try {
|
|
9
|
+
topLevel = readdirSync(worktreePath);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return found;
|
|
13
|
+
}
|
|
14
|
+
for (const name of topLevel) {
|
|
15
|
+
if (name === '.env' || name.startsWith('.env.') || CREDENTIAL_BASENAMES.has(name)) {
|
|
16
|
+
const filePath = join(worktreePath, name);
|
|
17
|
+
try {
|
|
18
|
+
// lstat, not stat: a symlinked `.env` must never lead the scrub outside the worktree.
|
|
19
|
+
if (lstatSync(filePath).isFile())
|
|
20
|
+
found.push(filePath);
|
|
21
|
+
}
|
|
22
|
+
catch { }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const claudeDir = join(worktreePath, '.claude');
|
|
26
|
+
if (isRealDirectory(claudeDir)) {
|
|
27
|
+
walkFiles(claudeDir, found);
|
|
28
|
+
}
|
|
29
|
+
return found;
|
|
30
|
+
}
|
|
31
|
+
function walkFiles(dir, found) {
|
|
32
|
+
let entries;
|
|
33
|
+
try {
|
|
34
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
const full = join(dir, entry.name);
|
|
41
|
+
if (entry.isDirectory()) {
|
|
42
|
+
walkFiles(full, found);
|
|
43
|
+
}
|
|
44
|
+
else if (entry.isFile()) {
|
|
45
|
+
found.push(full);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function isRealDirectory(path) {
|
|
50
|
+
try {
|
|
51
|
+
return lstatSync(path).isDirectory();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Zero a file in place through one fd opened with O_NOFOLLOW. The worktree's agent can swap
|
|
58
|
+
* a credential file for a symlink after `findCredentialFiles` walks it; a path-based
|
|
59
|
+
* stat + write would then zero the link's target (e.g. `~/.ssh/id_*`). Throws ELOOP on a
|
|
60
|
+
* symlink and refuses anything that is not a regular file. */
|
|
61
|
+
export function zeroFill(filePath) {
|
|
62
|
+
const fd = openSync(filePath, constants.O_WRONLY | constants.O_NOFOLLOW);
|
|
63
|
+
try {
|
|
64
|
+
const stat = fstatSync(fd);
|
|
65
|
+
if (!stat.isFile())
|
|
66
|
+
throw new Error(`refusing to zero-fill non-regular file ${filePath}`);
|
|
67
|
+
const zeros = Buffer.alloc(Math.min(stat.size, 64 * 1024));
|
|
68
|
+
let offset = 0;
|
|
69
|
+
while (offset < stat.size) {
|
|
70
|
+
offset += writeSync(fd, zeros, 0, Math.min(zeros.length, stat.size - offset), offset);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
closeSync(fd);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Zero-fill then delete. A symlink is unlinked without zeroing — rm removes the link, never
|
|
78
|
+
* its target. */
|
|
79
|
+
export function scrubFile(filePath) {
|
|
80
|
+
try {
|
|
81
|
+
zeroFill(filePath);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
if (err?.code !== 'ELOOP')
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
rmSync(filePath, { force: true });
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=worktree-gc-scrub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc-scrub.js","sourceRoot":"","sources":["../../src/worktree/worktree-gc-scrub.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAGnG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/G,OAAO,EAAE,IA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AAC,IAAI,GAAG,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC;AAED;kBACkB;AAClB,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,IAAI,CAAC;QACH,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,EAAE,IAAI,KAAK,OAAO;YAAE,MAAM,GAAG,CAAC;IAClE,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Octokit } from '@octokit/rest';
|
|
2
|
+
import type { EventKind } from '../events/kinds.js';
|
|
3
|
+
import type { WorktreeSandbox } from '../utils/microvm.js';
|
|
4
|
+
export type GcReason = 'merged' | 'remote-gone' | 'ttl-expired' | 'issue-closed' | 'issue-parked' | 'issue-decomposed' | 'issue-not-found' | 'no-active-claim';
|
|
5
|
+
/** GitHub's verdict on a candidate branch's PR(s), read via pulls.list (state=all,
|
|
6
|
+
* head=owner:branch). `null` means "no verdict" (no client/repo, or the query failed) —
|
|
7
|
+
* which must always fall back to the #639 local-evidence rules. */
|
|
8
|
+
export type GcHeadPrState = 'open' | 'merged' | 'closed' | 'none';
|
|
9
|
+
export interface WorktreeListEntry {
|
|
10
|
+
path: string;
|
|
11
|
+
head: string | null;
|
|
12
|
+
branch: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface GcCandidate {
|
|
15
|
+
path: string;
|
|
16
|
+
branch: string | null;
|
|
17
|
+
ageDays: number;
|
|
18
|
+
reason: GcReason;
|
|
19
|
+
scrubbedFiles: string[];
|
|
20
|
+
/** True when the candidate's local branch was force-deleted after removal. False when the
|
|
21
|
+
* reason was not branch-reapable, when the candidate was detached, when this was a dry run,
|
|
22
|
+
* or when `git branch -D` failed (a warn is logged in that last case). */
|
|
23
|
+
branchDeleted: boolean;
|
|
24
|
+
/** Set at decision time for the issue-driven reasons (`issue-closed` / `issue-parked`): true
|
|
25
|
+
* only when the branch's content is provably on the remote (a PR ever existed, the remote
|
|
26
|
+
* branch is live, or the tip is an ancestor of origin/main). An unpushed parked attempt's
|
|
27
|
+
* branch stays as its only handle. */
|
|
28
|
+
branchReapable?: boolean;
|
|
29
|
+
/** `'remove'` for every hard-evidence reason (merge/remote/ttl/issue-disposition proof).
|
|
30
|
+
* `'quarantine'` for the two heuristic reasons (`issue-not-found` / `no-active-claim`, #1355)
|
|
31
|
+
* that carry no merge/ancestry proof: the worktree is relocated under the quarantine
|
|
32
|
+
* directory instead of deleted, and its branch is never force-deleted (see ADR, this PR). */
|
|
33
|
+
action: 'remove' | 'quarantine';
|
|
34
|
+
/** Set only in real mode, only for a `'quarantine'` action, only once the move succeeds — the
|
|
35
|
+
* path the worktree was relocated to. Absent for `'remove'`, for dry-run, and when the move
|
|
36
|
+
* itself failed (the worktree is then left in place; see the `warn` log for the failure). */
|
|
37
|
+
quarantinedTo?: string;
|
|
38
|
+
}
|
|
39
|
+
/** A factory-owned worktree whose lane-branch issue number could not be confirmed to exist on
|
|
40
|
+
* GitHub. Dry-run surfaces every such candidate here regardless of its other GcReason evidence
|
|
41
|
+
* (see ADR-0088); real mode instead quarantines it via `removed`/`GcReason.issue-not-found`
|
|
42
|
+
* (only when no hard-evidence reason already claimed it — see ADR, this PR). */
|
|
43
|
+
export interface Issue404Candidate {
|
|
44
|
+
path: string;
|
|
45
|
+
branch: string | null;
|
|
46
|
+
issue: number;
|
|
47
|
+
}
|
|
48
|
+
/** A factory-owned worktree whose branch's PR is merged or closed but whose owning issue has no
|
|
49
|
+
* active `factory:claimed-by:*` label. Dry-run surfaces every such candidate here regardless of
|
|
50
|
+
* its other GcReason evidence; real mode instead quarantines it via
|
|
51
|
+
* `removed`/`GcReason.no-active-claim` (only when no hard-evidence reason already claimed it —
|
|
52
|
+
* see ADR, this PR). */
|
|
53
|
+
export interface NoActiveClaimCandidate {
|
|
54
|
+
path: string;
|
|
55
|
+
branch: string | null;
|
|
56
|
+
issue: number;
|
|
57
|
+
prState: 'merged' | 'closed';
|
|
58
|
+
}
|
|
59
|
+
/** A candidate GC would otherwise reap on hard issue evidence but kept to protect local work —
|
|
60
|
+
* surfaced so the operator sees why it survived (#1756). */
|
|
61
|
+
export interface GcHeldCandidate {
|
|
62
|
+
path: string;
|
|
63
|
+
branch: string | null;
|
|
64
|
+
issue: number;
|
|
65
|
+
why: string;
|
|
66
|
+
}
|
|
67
|
+
/** A worktree kept by a worktree-keeps.json record (#3316). */
|
|
68
|
+
export interface GcKeptCandidate {
|
|
69
|
+
path: string;
|
|
70
|
+
branch: string | null;
|
|
71
|
+
issue: number;
|
|
72
|
+
reason: string;
|
|
73
|
+
}
|
|
74
|
+
export interface GcReport {
|
|
75
|
+
removed: GcCandidate[];
|
|
76
|
+
kept: number;
|
|
77
|
+
dryRun: boolean;
|
|
78
|
+
/** Dry-run only: factory-owned candidates whose lane issue number 404'd on GitHub — a strong
|
|
79
|
+
* signal the worktree was created for an issue that never existed. Never read by, or written
|
|
80
|
+
* from, GcReason/BRANCH_REAPABLE_REASONS. Always [] outside dry-run — real mode's equivalent
|
|
81
|
+
* signal shows up as a `removed` entry with `reason: 'issue-not-found'` instead. */
|
|
82
|
+
issueNotFound: Issue404Candidate[];
|
|
83
|
+
/** Dry-run only: factory-owned candidates whose lane issue lookup threw a non-404 error (rate
|
|
84
|
+
* limit, network failure) — "couldn't check," never conflated with issueNotFound's "confirmed
|
|
85
|
+
* gone." Always [] outside dry-run; real mode never acts on an unverifiable lookup (fail-safe:
|
|
86
|
+
* keeps the worktree). */
|
|
87
|
+
issueUnverifiable: Issue404Candidate[];
|
|
88
|
+
/** Dry-run only: factory-owned candidates whose branch's PR is merged or closed and whose
|
|
89
|
+
* owning issue carries no active `factory:claimed-by:*` label — the lane finished (or was
|
|
90
|
+
* abandoned) without releasing its worktree. Fail-safe: any doubt (no client/repo, lookup
|
|
91
|
+
* error, unresolved issue number) means "not flagged." Never read by, or written from,
|
|
92
|
+
* GcReason/BRANCH_REAPABLE_REASONS. Always [] outside dry-run — real mode's equivalent signal
|
|
93
|
+
* shows up as a `removed` entry with `reason: 'no-active-claim'` instead. */
|
|
94
|
+
noActiveClaim: NoActiveClaimCandidate[];
|
|
95
|
+
/** Decomposed-parent worktrees (`factory:decomposed`) kept because they are dirty, hold
|
|
96
|
+
* unpushed commits, or could not be verified (#1756). Populated in dry-run and real mode;
|
|
97
|
+
* every entry is also counted in `kept`. */
|
|
98
|
+
held: GcHeldCandidate[];
|
|
99
|
+
/** Worktrees kept by a worktree-keeps.json record (#3316); also counted in kept. */
|
|
100
|
+
keptByRecord?: GcKeptCandidate[];
|
|
101
|
+
}
|
|
102
|
+
export interface SweepDeps {
|
|
103
|
+
runCommand?: (cmd: string, opts?: {
|
|
104
|
+
cwd?: string;
|
|
105
|
+
}) => Promise<{
|
|
106
|
+
stdout: string;
|
|
107
|
+
}>;
|
|
108
|
+
now?: () => number;
|
|
109
|
+
log?: (type: EventKind, msg: string) => void;
|
|
110
|
+
/** When present (with opts.repo), merged/close status is sourced from GitHub; absent or failing ⇒ local evidence only. */
|
|
111
|
+
octokit?: Pick<Octokit, 'rest'>;
|
|
112
|
+
/** The repo's current docker-sandbox descriptor (runtime + authPaths), or undefined for every
|
|
113
|
+
* other runtime. A reaped candidate may have been provisioned under a different runtime than
|
|
114
|
+
* today's config, but removeMicroVm is a no-op unless `runtime === 'docker-sandbox'` and the
|
|
115
|
+
* named VM exists, so passing today's descriptor for every candidate is safe and idempotent. */
|
|
116
|
+
sandbox?: WorktreeSandbox;
|
|
117
|
+
/** Dedup tracker for resolveIssueDisposition's lookup-failure warning (see IssueWarnDedup).
|
|
118
|
+
* Defaults to a module-level singleton shared across every sweep in the process; tests should
|
|
119
|
+
* inject a fresh instance to avoid bleeding suppression state across cases. */
|
|
120
|
+
issueWarnDedup?: IssueWarnDedup;
|
|
121
|
+
}
|
|
122
|
+
/** Dedupes resolveIssueDisposition's lookup-failure warning across repeated sweeps — the factory
|
|
123
|
+
* loop calls sweepWorktrees every iteration, and a worktree tied to a nonexistent issue number
|
|
124
|
+
* fails that lookup on every one of them. The first failure for a given issue since the last
|
|
125
|
+
* reconcile-clear warns in full; every following one folds into a one-line "suppressed N"
|
|
126
|
+
* summary instead of repeating the same text. `reconcile()` drops an issue's tracking once it's
|
|
127
|
+
* no longer among the sweep's candidates, so a later re-appearance (or a different worktree
|
|
128
|
+
* reusing the number) warns in full again. Keyed by issue number, not by worktree path, since
|
|
129
|
+
* the failing lookup is per-issue (see ADR, this PR). */
|
|
130
|
+
export declare class IssueWarnDedup {
|
|
131
|
+
private readonly counts;
|
|
132
|
+
/** Records one occurrence for `issue`. Returns true the first time since the last
|
|
133
|
+
* reconcile-clear (caller should log the full warning), false thereafter. */
|
|
134
|
+
record(issue: number): boolean;
|
|
135
|
+
/** Occurrences suppressed for `issue` since its last full warning (0 before the second one). */
|
|
136
|
+
suppressedCount(issue: number): number;
|
|
137
|
+
/** Drops tracking for every issue not in `activeIssues` — call once per sweep with the issue
|
|
138
|
+
* numbers still present among that sweep's candidates. */
|
|
139
|
+
reconcile(activeIssues: ReadonlySet<number>): void;
|
|
140
|
+
}
|
|
141
|
+
export declare const defaultIssueWarnDedup: IssueWarnDedup;
|
|
142
|
+
//# sourceMappingURL=worktree-gc-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc-types.d.ts","sourceRoot":"","sources":["../../src/worktree/worktree-gc-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D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,CAAC,QAAQ,CAAC,MAAM,CAA6B;IAEpD;kFAC8E;IAC9E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI7B;IAED,gGAAgG;IAChG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErC;IAED;+DAC2D;IAC3D,SAAS,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAIjD;CACF;AAED,eAAO,MAAM,qBAAqB,gBAAuB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/worktree/worktree-gc-types.ts — report, dep and candidate types shared by the worktree GC files.
|
|
2
|
+
/** Dedupes resolveIssueDisposition's lookup-failure warning across repeated sweeps — the factory
|
|
3
|
+
* loop calls sweepWorktrees every iteration, and a worktree tied to a nonexistent issue number
|
|
4
|
+
* fails that lookup on every one of them. The first failure for a given issue since the last
|
|
5
|
+
* reconcile-clear warns in full; every following one folds into a one-line "suppressed N"
|
|
6
|
+
* summary instead of repeating the same text. `reconcile()` drops an issue's tracking once it's
|
|
7
|
+
* no longer among the sweep's candidates, so a later re-appearance (or a different worktree
|
|
8
|
+
* reusing the number) warns in full again. Keyed by issue number, not by worktree path, since
|
|
9
|
+
* the failing lookup is per-issue (see ADR, this PR). */
|
|
10
|
+
export class IssueWarnDedup {
|
|
11
|
+
counts = new Map();
|
|
12
|
+
/** Records one occurrence for `issue`. Returns true the first time since the last
|
|
13
|
+
* reconcile-clear (caller should log the full warning), false thereafter. */
|
|
14
|
+
record(issue) {
|
|
15
|
+
const count = (this.counts.get(issue) ?? 0) + 1;
|
|
16
|
+
this.counts.set(issue, count);
|
|
17
|
+
return count === 1;
|
|
18
|
+
}
|
|
19
|
+
/** Occurrences suppressed for `issue` since its last full warning (0 before the second one). */
|
|
20
|
+
suppressedCount(issue) {
|
|
21
|
+
return Math.max(0, (this.counts.get(issue) ?? 0) - 1);
|
|
22
|
+
}
|
|
23
|
+
/** Drops tracking for every issue not in `activeIssues` — call once per sweep with the issue
|
|
24
|
+
* numbers still present among that sweep's candidates. */
|
|
25
|
+
reconcile(activeIssues) {
|
|
26
|
+
for (const issue of this.counts.keys()) {
|
|
27
|
+
if (!activeIssues.has(issue))
|
|
28
|
+
this.counts.delete(issue);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const defaultIssueWarnDedup = new IssueWarnDedup();
|
|
33
|
+
//# sourceMappingURL=worktree-gc-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc-types.js","sourceRoot":"","sources":["../../src/worktree/worktree-gc-types.ts"],"names":[],"mappings":"AAAA,uGAAuG;AA2IvG;;;;;;;0DAO0D;AAC1D,MAAM,OAAO,cAAc;IACR,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEpD;kFAC8E;IAC9E,MAAM,CAAC,KAAa;QAClB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,gGAAgG;IAChG,eAAe,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;+DAC2D;IAC3D,SAAS,CAAC,YAAiC;QACzC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,cAAc,EAAE,CAAC"}
|