@kynver-app/runtime 0.1.50 → 0.1.56
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/cleanup-guards.d.ts +3 -0
- package/dist/cleanup-retention-config.d.ts +14 -0
- package/dist/cleanup-run-liveness.d.ts +13 -0
- package/dist/cleanup-types.d.ts +12 -0
- package/dist/cleanup.d.ts +1 -1
- package/dist/cli.js +159 -70
- package/dist/cli.js.map +4 -4
- package/dist/finalize.d.ts +9 -0
- package/dist/index.js +159 -70
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/finalize.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { type HarnessRunRecord } from "./run-store.js";
|
|
1
2
|
export interface RunFinalizeResult {
|
|
2
3
|
runId: string;
|
|
3
4
|
from: string;
|
|
4
5
|
to: string;
|
|
5
6
|
}
|
|
7
|
+
/** Run statuses we treat as "not yet terminal" and therefore candidates for finalization. */
|
|
8
|
+
export declare const ACTIVE_RUN_STATUSES: Set<string>;
|
|
9
|
+
export declare const TERMINAL_RUN_STATUSES: Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Decide the terminal status for a run, or null if it should stay active.
|
|
12
|
+
* A run is terminal once none of its workers are still alive-and-unfinished.
|
|
13
|
+
*/
|
|
14
|
+
export declare function deriveTerminalRunStatus(run: HarnessRunRecord): string | null;
|
|
6
15
|
/**
|
|
7
16
|
* Finalize runs that are still marked active but have no live workers.
|
|
8
17
|
*
|
package/dist/index.js
CHANGED
|
@@ -4930,8 +4930,15 @@ import path24 from "node:path";
|
|
|
4930
4930
|
|
|
4931
4931
|
// src/finalize.ts
|
|
4932
4932
|
import path23 from "node:path";
|
|
4933
|
-
var ACTIVE_RUN_STATUSES = /* @__PURE__ */ new Set([
|
|
4934
|
-
|
|
4933
|
+
var ACTIVE_RUN_STATUSES = /* @__PURE__ */ new Set([
|
|
4934
|
+
"running",
|
|
4935
|
+
"dispatching",
|
|
4936
|
+
"pending",
|
|
4937
|
+
"queued",
|
|
4938
|
+
"needs_attention"
|
|
4939
|
+
]);
|
|
4940
|
+
var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "done"]);
|
|
4941
|
+
function deriveTerminalRunStatus(run) {
|
|
4935
4942
|
const names = Object.keys(run.workers || {});
|
|
4936
4943
|
if (names.length === 0) return "failed";
|
|
4937
4944
|
let anyAlive = false;
|
|
@@ -4969,7 +4976,7 @@ function finalizeStaleRuns() {
|
|
|
4969
4976
|
const finalized = [];
|
|
4970
4977
|
for (const run of listRunRecords()) {
|
|
4971
4978
|
if (!ACTIVE_RUN_STATUSES.has(run.status)) continue;
|
|
4972
|
-
const next =
|
|
4979
|
+
const next = deriveTerminalRunStatus(run);
|
|
4973
4980
|
if (!next || next === run.status) continue;
|
|
4974
4981
|
const from = run.status;
|
|
4975
4982
|
run.status = next;
|
|
@@ -5161,13 +5168,26 @@ async function fetchWorkspaceRuntimePreferences(agentOsId, args) {
|
|
|
5161
5168
|
// src/cleanup.ts
|
|
5162
5169
|
import path30 from "node:path";
|
|
5163
5170
|
|
|
5164
|
-
// src/cleanup-
|
|
5165
|
-
|
|
5166
|
-
|
|
5171
|
+
// src/cleanup-run-liveness.ts
|
|
5172
|
+
function isWorkerProcessLive(indexed) {
|
|
5173
|
+
if (indexed.status.alive) return true;
|
|
5174
|
+
if (indexed.worker.status === "running") return true;
|
|
5175
|
+
return false;
|
|
5176
|
+
}
|
|
5177
|
+
function isRunStaleActive(indexed) {
|
|
5178
|
+
if (TERMINAL_RUN_STATUSES.has(indexed.run.status)) return false;
|
|
5179
|
+
return deriveTerminalRunStatus(indexed.run) !== null;
|
|
5180
|
+
}
|
|
5181
|
+
function runBlocksWorktreeRemoval(indexed) {
|
|
5182
|
+
if (isWorkerProcessLive(indexed)) return true;
|
|
5183
|
+
if (indexed.worker.completionBlocker) return true;
|
|
5184
|
+
if (TERMINAL_RUN_STATUSES.has(indexed.run.status)) return false;
|
|
5185
|
+
if (isRunStaleActive(indexed)) return false;
|
|
5186
|
+
if (!isFinishedWorkerStatus(indexed.status)) return true;
|
|
5187
|
+
return deriveTerminalRunStatus(indexed.run) === null;
|
|
5188
|
+
}
|
|
5167
5189
|
|
|
5168
5190
|
// src/cleanup-guards.ts
|
|
5169
|
-
var ACTIVE_RUN_STATUSES2 = /* @__PURE__ */ new Set(["running", "dispatching", "pending", "queued", "needs_attention"]);
|
|
5170
|
-
var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
|
|
5171
5191
|
function prUrlFromFinalResult(finalResult) {
|
|
5172
5192
|
if (typeof finalResult === "string") {
|
|
5173
5193
|
const match = finalResult.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/i);
|
|
@@ -5189,18 +5209,29 @@ function isPrOrUnmergedWork(status) {
|
|
|
5189
5209
|
if (status.changedFiles.length > 0 && status.finalResult) return true;
|
|
5190
5210
|
return false;
|
|
5191
5211
|
}
|
|
5212
|
+
function materialWorktreeChanges(changedFiles) {
|
|
5213
|
+
return changedFiles.filter((line) => {
|
|
5214
|
+
const trimmed = line.trim();
|
|
5215
|
+
const pathPart = trimmed.startsWith("??") ? trimmed.slice(2).trim() : trimmed.length > 3 ? trimmed.slice(3).trim() : trimmed;
|
|
5216
|
+
return pathPart !== "node_modules" && !pathPart.startsWith("node_modules/");
|
|
5217
|
+
});
|
|
5218
|
+
}
|
|
5219
|
+
function hasUnrestorableWorktreeChanges(status) {
|
|
5220
|
+
if (materialWorktreeChanges(status.changedFiles).length > 0) return true;
|
|
5221
|
+
if (status.gitAncestry?.relation === "diverged") return true;
|
|
5222
|
+
return false;
|
|
5223
|
+
}
|
|
5192
5224
|
function skipWorktreeRemoval(input) {
|
|
5193
5225
|
const { indexed, includeOrphans, worktreesAgeMs, ageMs } = input;
|
|
5194
5226
|
if (worktreesAgeMs <= 0) return "worktrees_disabled";
|
|
5195
5227
|
if (ageMs < worktreesAgeMs) return "below_age_threshold";
|
|
5196
5228
|
if (!indexed) return includeOrphans ? null : "orphan_without_flag";
|
|
5197
|
-
if (
|
|
5198
|
-
if (!TERMINAL_RUN_STATUSES.has(indexed.run.status)) return "run_still_active";
|
|
5199
|
-
if (indexed.status.alive) return "active_worker";
|
|
5200
|
-
if (indexed.worker.status === "running") return "active_worker";
|
|
5229
|
+
if (isWorkerProcessLive(indexed)) return "active_worker";
|
|
5201
5230
|
if (indexed.worker.completionBlocker) return "completion_blocked";
|
|
5231
|
+
if (runBlocksWorktreeRemoval(indexed)) return "run_still_active";
|
|
5232
|
+
if (!isFinishedWorkerStatus(indexed.status)) return "run_still_active";
|
|
5202
5233
|
if (isPrOrUnmergedWork(indexed.status)) return "pr_or_unmerged_commits";
|
|
5203
|
-
if (indexed.status.changedFiles.length > 0) return "dirty_worktree";
|
|
5234
|
+
if (materialWorktreeChanges(indexed.status.changedFiles).length > 0) return "dirty_worktree";
|
|
5204
5235
|
const landing = assessWorkerLanding({
|
|
5205
5236
|
finalResult: indexed.status.finalResult,
|
|
5206
5237
|
changedFiles: indexed.status.changedFiles,
|
|
@@ -5214,18 +5245,19 @@ function skipNodeModulesRemoval(input) {
|
|
|
5214
5245
|
const { indexed, includeOrphans, nodeModulesAgeMs, ageMs } = input;
|
|
5215
5246
|
if (ageMs < nodeModulesAgeMs) return "below_age_threshold";
|
|
5216
5247
|
if (!indexed) return includeOrphans ? null : "orphan_without_flag";
|
|
5217
|
-
if (indexed
|
|
5218
|
-
if (indexed.worker.status === "running") return "active_worker";
|
|
5248
|
+
if (isWorkerProcessLive(indexed)) return "active_worker";
|
|
5219
5249
|
if (indexed.worker.completionBlocker) return "completion_blocked";
|
|
5220
|
-
if (
|
|
5221
|
-
if (indexed.status
|
|
5250
|
+
if (!isFinishedWorkerStatus(indexed.status)) return "run_still_active";
|
|
5251
|
+
if (hasUnrestorableWorktreeChanges(indexed.status)) return "dirty_worktree";
|
|
5222
5252
|
const landing = assessWorkerLanding({
|
|
5223
5253
|
finalResult: indexed.status.finalResult,
|
|
5224
5254
|
changedFiles: indexed.status.changedFiles,
|
|
5225
5255
|
gitAncestry: indexed.status.gitAncestry,
|
|
5226
5256
|
prUrl: prUrlFromFinalResult(indexed.status.finalResult)
|
|
5227
5257
|
});
|
|
5228
|
-
if (landing.blocked)
|
|
5258
|
+
if (landing.blocked && materialWorktreeChanges(indexed.status.changedFiles).length > 0) {
|
|
5259
|
+
return "landing_blocked";
|
|
5260
|
+
}
|
|
5229
5261
|
return null;
|
|
5230
5262
|
}
|
|
5231
5263
|
|
|
@@ -5452,48 +5484,98 @@ function buildWorktreeIndex() {
|
|
|
5452
5484
|
return index;
|
|
5453
5485
|
}
|
|
5454
5486
|
|
|
5455
|
-
// src/cleanup.ts
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
const
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5487
|
+
// src/cleanup-types.ts
|
|
5488
|
+
var DEFAULT_NODE_MODULES_AGE_MS = 6 * 60 * 60 * 1e3;
|
|
5489
|
+
var DEFAULT_WORKTREES_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
5490
|
+
|
|
5491
|
+
// src/cleanup-retention-config.ts
|
|
5492
|
+
function envFlag(name) {
|
|
5493
|
+
const v = process.env[name];
|
|
5494
|
+
return v === "1" || v === "true" || v === "yes";
|
|
5495
|
+
}
|
|
5496
|
+
function envMs(name, fallback) {
|
|
5497
|
+
const raw = process.env[name];
|
|
5498
|
+
if (!raw) return fallback;
|
|
5499
|
+
const n = Number(raw);
|
|
5500
|
+
return Number.isFinite(n) && n >= 0 ? n : fallback;
|
|
5501
|
+
}
|
|
5502
|
+
function resolveHarnessRetention(options = {}) {
|
|
5503
|
+
const execute = options.execute === true || options.execute !== false && envFlag("KYNVER_CLEANUP_EXECUTE");
|
|
5504
|
+
const finalizeStaleRuns2 = options.finalizeStaleRuns !== false && !envFlag("KYNVER_CLEANUP_SKIP_FINALIZE");
|
|
5505
|
+
const nodeModulesAgeMs = options.nodeModulesAgeMs ?? envMs("KYNVER_CLEANUP_NODE_MODULES_AGE_MS", DEFAULT_NODE_MODULES_AGE_MS);
|
|
5506
|
+
const worktreesAgeMs = options.worktreesAgeMs ?? envMs("KYNVER_CLEANUP_WORKTREES_AGE_MS", 0);
|
|
5507
|
+
const includeOrphans = options.includeOrphans === true || envFlag("KYNVER_CLEANUP_INCLUDE_ORPHANS");
|
|
5508
|
+
const scopeAll = envFlag("KYNVER_CLEANUP_SCOPE_ALL") || process.env.KYNVER_CLEANUP_SCOPE === "all";
|
|
5509
|
+
const runIdFilter = scopeAll ? options.runIdFilter : options.runIdFilter ?? (process.env.KYNVER_CLEANUP_RUN_ID || void 0);
|
|
5510
|
+
const accountBytes = options.accountBytes !== false && !envFlag("KYNVER_CLEANUP_SKIP_BYTE_ACCOUNTING");
|
|
5465
5511
|
return {
|
|
5466
|
-
harnessRoot,
|
|
5467
|
-
worktreesDir,
|
|
5468
5512
|
execute,
|
|
5469
|
-
|
|
5513
|
+
finalizeStaleRuns: finalizeStaleRuns2,
|
|
5470
5514
|
nodeModulesAgeMs,
|
|
5471
|
-
worktreesAgeMs,
|
|
5515
|
+
worktreesAgeMs: worktreesAgeMs > 0 ? worktreesAgeMs : 0,
|
|
5472
5516
|
includeOrphans,
|
|
5473
|
-
runIdFilter,
|
|
5474
|
-
|
|
5517
|
+
runIdFilter: runIdFilter ? String(runIdFilter) : void 0,
|
|
5518
|
+
accountBytes
|
|
5475
5519
|
};
|
|
5476
5520
|
}
|
|
5521
|
+
function resolvePipelineHarnessRetention(runId) {
|
|
5522
|
+
const scopeAll = process.env.KYNVER_CLEANUP_SCOPE === "all";
|
|
5523
|
+
const envWorktrees = Number(process.env.KYNVER_CLEANUP_WORKTREES_AGE_MS);
|
|
5524
|
+
const worktreesAgeMs = scopeAll ? Number.isFinite(envWorktrees) && envWorktrees > 0 ? envWorktrees : DEFAULT_WORKTREES_AGE_MS : Number.isFinite(envWorktrees) && envWorktrees > 0 ? envWorktrees : 0;
|
|
5525
|
+
return resolveHarnessRetention({
|
|
5526
|
+
runIdFilter: scopeAll ? void 0 : runId,
|
|
5527
|
+
worktreesAgeMs,
|
|
5528
|
+
finalizeStaleRuns: true,
|
|
5529
|
+
accountBytes: true
|
|
5530
|
+
});
|
|
5531
|
+
}
|
|
5532
|
+
|
|
5533
|
+
// src/cleanup.ts
|
|
5534
|
+
function resolvePaths(options = {}) {
|
|
5535
|
+
const harnessRoot = options.harnessRoot ? resolveUserPath(options.harnessRoot) : resolveHarnessRoot();
|
|
5536
|
+
const { worktreesDir } = options.harnessRoot ? { worktreesDir: path30.join(harnessRoot, "worktrees") } : getHarnessPaths();
|
|
5537
|
+
const now = options.now ?? Date.now();
|
|
5538
|
+
return { harnessRoot, worktreesDir, now };
|
|
5539
|
+
}
|
|
5477
5540
|
function recordSkip(skips, pathValue, reason, detail) {
|
|
5478
5541
|
skips.push({ path: pathValue, reason, ...detail ? { detail } : {} });
|
|
5479
5542
|
}
|
|
5543
|
+
function attachCandidateBytes(candidate, accountBytes) {
|
|
5544
|
+
if (!accountBytes || candidate.bytes != null) return candidate;
|
|
5545
|
+
return { ...candidate, bytes: directorySizeBytes(candidate.path) };
|
|
5546
|
+
}
|
|
5547
|
+
function tallySkipReasons(actions, skips) {
|
|
5548
|
+
const counts = {};
|
|
5549
|
+
for (const skip of skips) {
|
|
5550
|
+
counts[skip.reason] = (counts[skip.reason] ?? 0) + 1;
|
|
5551
|
+
}
|
|
5552
|
+
for (const action of actions) {
|
|
5553
|
+
if (action.skipReason) {
|
|
5554
|
+
counts[action.skipReason] = (counts[action.skipReason] ?? 0) + 1;
|
|
5555
|
+
}
|
|
5556
|
+
}
|
|
5557
|
+
return counts;
|
|
5558
|
+
}
|
|
5480
5559
|
function runHarnessCleanup(options = {}) {
|
|
5481
|
-
const
|
|
5560
|
+
const retention = resolveHarnessRetention(options);
|
|
5561
|
+
const paths = resolvePaths(options);
|
|
5562
|
+
const finalizedRuns = retention.finalizeStaleRuns ? finalizeStaleRuns().map((f) => ({ runId: f.runId, from: f.from, to: f.to })) : [];
|
|
5482
5563
|
const index = buildWorktreeIndex();
|
|
5483
5564
|
const scanOpts = {
|
|
5484
|
-
harnessRoot:
|
|
5485
|
-
worktreesDir:
|
|
5486
|
-
nodeModulesAgeMs:
|
|
5487
|
-
worktreesAgeMs:
|
|
5488
|
-
includeOrphans:
|
|
5489
|
-
runIdFilter:
|
|
5565
|
+
harnessRoot: paths.harnessRoot,
|
|
5566
|
+
worktreesDir: paths.worktreesDir,
|
|
5567
|
+
nodeModulesAgeMs: retention.nodeModulesAgeMs,
|
|
5568
|
+
worktreesAgeMs: retention.worktreesAgeMs,
|
|
5569
|
+
includeOrphans: retention.includeOrphans,
|
|
5570
|
+
runIdFilter: retention.runIdFilter,
|
|
5490
5571
|
index,
|
|
5491
|
-
now:
|
|
5572
|
+
now: paths.now
|
|
5492
5573
|
};
|
|
5493
5574
|
const skips = [];
|
|
5494
5575
|
const actions = [];
|
|
5495
|
-
for (const
|
|
5496
|
-
const
|
|
5576
|
+
for (const raw of scanNodeModulesCandidates(scanOpts)) {
|
|
5577
|
+
const candidate = attachCandidateBytes(raw, retention.accountBytes);
|
|
5578
|
+
const pathSkip = isHarnessNodeModulesPath(candidate.path, paths.harnessRoot, paths.worktreesDir);
|
|
5497
5579
|
if (pathSkip) {
|
|
5498
5580
|
recordSkip(skips, candidate.path, pathSkip);
|
|
5499
5581
|
actions.push({ ...candidate, executed: false, skipped: true, skipReason: pathSkip });
|
|
@@ -5503,8 +5585,8 @@ function runHarnessCleanup(options = {}) {
|
|
|
5503
5585
|
const indexed = index.get(worktreePath) ?? null;
|
|
5504
5586
|
const guardReason = skipNodeModulesRemoval({
|
|
5505
5587
|
indexed,
|
|
5506
|
-
includeOrphans:
|
|
5507
|
-
nodeModulesAgeMs:
|
|
5588
|
+
includeOrphans: retention.includeOrphans,
|
|
5589
|
+
nodeModulesAgeMs: retention.nodeModulesAgeMs,
|
|
5508
5590
|
ageMs: candidate.ageMs
|
|
5509
5591
|
});
|
|
5510
5592
|
if (guardReason) {
|
|
@@ -5512,14 +5594,15 @@ function runHarnessCleanup(options = {}) {
|
|
|
5512
5594
|
actions.push({ ...candidate, executed: false, skipped: true, skipReason: guardReason });
|
|
5513
5595
|
continue;
|
|
5514
5596
|
}
|
|
5515
|
-
actions.push(removeNodeModules(candidate,
|
|
5597
|
+
actions.push(removeNodeModules(candidate, retention.execute));
|
|
5516
5598
|
}
|
|
5517
|
-
for (const
|
|
5599
|
+
for (const raw of scanWorktreeCandidates(scanOpts)) {
|
|
5600
|
+
const candidate = attachCandidateBytes(raw, retention.accountBytes);
|
|
5518
5601
|
const indexed = index.get(path30.resolve(candidate.path)) ?? null;
|
|
5519
5602
|
const guardReason = skipWorktreeRemoval({
|
|
5520
5603
|
indexed,
|
|
5521
|
-
includeOrphans:
|
|
5522
|
-
worktreesAgeMs:
|
|
5604
|
+
includeOrphans: retention.includeOrphans,
|
|
5605
|
+
worktreesAgeMs: retention.worktreesAgeMs,
|
|
5523
5606
|
ageMs: candidate.ageMs
|
|
5524
5607
|
});
|
|
5525
5608
|
if (guardReason) {
|
|
@@ -5527,51 +5610,55 @@ function runHarnessCleanup(options = {}) {
|
|
|
5527
5610
|
actions.push({ ...candidate, executed: false, skipped: true, skipReason: guardReason });
|
|
5528
5611
|
continue;
|
|
5529
5612
|
}
|
|
5530
|
-
actions.push(removeWorktree(candidate,
|
|
5613
|
+
actions.push(removeWorktree(candidate, retention.execute));
|
|
5531
5614
|
}
|
|
5532
5615
|
let candidateBytes = 0;
|
|
5616
|
+
let reclaimableBytes = 0;
|
|
5533
5617
|
let removedBytes = 0;
|
|
5534
5618
|
let removedPaths = 0;
|
|
5535
5619
|
let skippedPaths = 0;
|
|
5536
5620
|
for (const action of actions) {
|
|
5537
5621
|
if (action.bytes) candidateBytes += action.bytes;
|
|
5622
|
+
if (!action.skipped && !action.executed && action.bytes) reclaimableBytes += action.bytes;
|
|
5538
5623
|
if (action.executed) {
|
|
5539
5624
|
removedPaths += 1;
|
|
5540
5625
|
removedBytes += action.bytes ?? 0;
|
|
5541
5626
|
} else if (action.skipped) {
|
|
5542
5627
|
skippedPaths += 1;
|
|
5628
|
+
if (action.skipReason === "dry_run" && action.bytes) reclaimableBytes += action.bytes;
|
|
5543
5629
|
}
|
|
5544
5630
|
}
|
|
5545
5631
|
return {
|
|
5546
|
-
harnessRoot:
|
|
5547
|
-
dryRun:
|
|
5548
|
-
execute:
|
|
5549
|
-
nodeModulesAgeMs:
|
|
5550
|
-
worktreesAgeMs:
|
|
5551
|
-
includeOrphans:
|
|
5552
|
-
scannedAt: new Date(
|
|
5632
|
+
harnessRoot: paths.harnessRoot,
|
|
5633
|
+
dryRun: !retention.execute,
|
|
5634
|
+
execute: retention.execute,
|
|
5635
|
+
nodeModulesAgeMs: retention.nodeModulesAgeMs,
|
|
5636
|
+
worktreesAgeMs: retention.worktreesAgeMs,
|
|
5637
|
+
includeOrphans: retention.includeOrphans,
|
|
5638
|
+
scannedAt: new Date(paths.now).toISOString(),
|
|
5639
|
+
finalizedRuns,
|
|
5553
5640
|
actions,
|
|
5554
5641
|
skips,
|
|
5555
5642
|
totals: {
|
|
5556
5643
|
candidateBytes,
|
|
5644
|
+
reclaimableBytes,
|
|
5557
5645
|
removedBytes,
|
|
5558
5646
|
removedPaths,
|
|
5559
|
-
skippedPaths
|
|
5647
|
+
skippedPaths,
|
|
5648
|
+
skipReasons: tallySkipReasons(actions, skips)
|
|
5560
5649
|
}
|
|
5561
5650
|
};
|
|
5562
5651
|
}
|
|
5563
5652
|
function runPipelineHarnessCleanup(runId) {
|
|
5564
|
-
const
|
|
5565
|
-
const worktreesAgeMs = Number(process.env.KYNVER_CLEANUP_WORKTREES_AGE_MS) || 0;
|
|
5566
|
-
const execute = process.env.KYNVER_CLEANUP_EXECUTE === "1";
|
|
5567
|
-
const includeOrphans = process.env.KYNVER_CLEANUP_INCLUDE_ORPHANS === "1";
|
|
5568
|
-
const scopeAll = process.env.KYNVER_CLEANUP_SCOPE === "all";
|
|
5653
|
+
const retention = resolvePipelineHarnessRetention(runId);
|
|
5569
5654
|
return runHarnessCleanup({
|
|
5570
|
-
execute,
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5655
|
+
execute: retention.execute,
|
|
5656
|
+
finalizeStaleRuns: retention.finalizeStaleRuns,
|
|
5657
|
+
accountBytes: retention.accountBytes,
|
|
5658
|
+
nodeModulesAgeMs: retention.nodeModulesAgeMs,
|
|
5659
|
+
worktreesAgeMs: retention.worktreesAgeMs,
|
|
5660
|
+
includeOrphans: retention.includeOrphans,
|
|
5661
|
+
runIdFilter: retention.runIdFilter
|
|
5575
5662
|
});
|
|
5576
5663
|
}
|
|
5577
5664
|
function isPipelineCleanupEnabled() {
|
|
@@ -6238,12 +6325,14 @@ async function runPlanOutboxDrain(args) {
|
|
|
6238
6325
|
// src/cleanup-cli.ts
|
|
6239
6326
|
function runCleanupCli(args) {
|
|
6240
6327
|
const execute = args.execute === true || args.execute === "true";
|
|
6328
|
+
const skipFinalize = args.skipFinalize === true || args.skipFinalize === "true";
|
|
6241
6329
|
const nodeModulesAgeMs = args.nodeModulesAgeMs ? Number(args.nodeModulesAgeMs) : DEFAULT_NODE_MODULES_AGE_MS;
|
|
6242
6330
|
const worktreesAgeMs = args.worktreesAgeMs ? Number(args.worktreesAgeMs) : 0;
|
|
6243
6331
|
const includeOrphans = args.includeOrphans === true || args.includeOrphans === "true";
|
|
6244
6332
|
const harnessRoot = args.harnessRoot ? String(args.harnessRoot) : void 0;
|
|
6245
6333
|
const summary = runHarnessCleanup({
|
|
6246
6334
|
execute,
|
|
6335
|
+
finalizeStaleRuns: !skipFinalize,
|
|
6247
6336
|
nodeModulesAgeMs: Number.isFinite(nodeModulesAgeMs) ? nodeModulesAgeMs : DEFAULT_NODE_MODULES_AGE_MS,
|
|
6248
6337
|
worktreesAgeMs: Number.isFinite(worktreesAgeMs) ? worktreesAgeMs : 0,
|
|
6249
6338
|
includeOrphans,
|
|
@@ -7362,7 +7451,7 @@ function usage(code = 0) {
|
|
|
7362
7451
|
" kynver plan persist --operation create|add_version|update_metadata --title TITLE (--body-file PATH | --body TEXT) [--slug SLUG] [--plan PLAN_ID] [--summary TEXT] [--failure-kind approval_guard|auth|network|server|tool_interruption]",
|
|
7363
7452
|
" kynver plan outbox list",
|
|
7364
7453
|
" kynver plan outbox drain [--max N] [--id OUTBOX_ID]",
|
|
7365
|
-
" kynver cleanup [--execute] [--node-modules-age-ms MS] [--worktrees-age-ms MS] [--harness-root PATH] [--include-orphans]",
|
|
7454
|
+
" kynver cleanup [--execute] [--node-modules-age-ms MS] [--worktrees-age-ms MS] [--harness-root PATH] [--include-orphans] [--skip-finalize]",
|
|
7366
7455
|
" kynver monitor start --run RUN_ID [--name worker] [--agent-os-id AOS_ID] [--poll-ms MS]",
|
|
7367
7456
|
" kynver monitor status [--run RUN_ID] [--name worker] [--tick]",
|
|
7368
7457
|
" kynver monitor stop --run RUN_ID [--name worker]",
|