c8ctl-plugin-nano 1.70.6 → 1.70.8
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 +8 -0
- package/agent-checkpoint.mjs +141 -0
- package/c8ctl-plugin.js +53 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -835,6 +835,14 @@ the job with a decremented retry count. Profiles are stored in the plugin's
|
|
|
835
835
|
> the resume needs (issue #295). The sweep fails closed (any missing key / unreachable
|
|
836
836
|
> lookup spares the ref; the 7-day TTL is the backstop) and degrades to the element-only
|
|
837
837
|
> check on hosts whose SDK lacks process-instance lookup.
|
|
838
|
+
> The same sweep reclaims stale `nano/agent-work/*` fallback branches (tip older than
|
|
839
|
+
> the same TTL) **without losing work**: a branch that heads an open PR is kept (as is
|
|
840
|
+
> any branch whose PR status can't be determined, e.g. non-GitHub remotes or `gh`
|
|
841
|
+
> failing); a branch whose tip is contained in another branch is deleted; otherwise the
|
|
842
|
+
> tip is first pushed to `refs/nano/archive/agent-work/<archivedAtMs>/<name>` and only then
|
|
843
|
+
> is the branch deleted. Archive refs are purged after `NANO_AGENT_WORK_ARCHIVE_TTL_MS`
|
|
844
|
+
> (90 days; `0` keeps them forever). Recover one with
|
|
845
|
+
> `git fetch origin refs/nano/archive/agent-work/<ts>/<name>:refs/heads/<name>`.
|
|
838
846
|
> - **Safety:** pushes use `--force-with-lease`, so a superseded worker can't clobber a
|
|
839
847
|
> newer run's checkpoint. A remote *policy* refusal (repository rules, secret push
|
|
840
848
|
> protection) or a permission error stops checkpointing for that job with a warning;
|
package/agent-checkpoint.mjs
CHANGED
|
@@ -121,6 +121,8 @@ const DEFAULTS = Object.freeze({
|
|
|
121
121
|
// wall clock to observe the cancel-on-timeout behaviour (Copilot review on #296).
|
|
122
122
|
sdkTimeoutMs: 10_000,
|
|
123
123
|
ttlMs: 7 * 24 * 60 * 60 * 1000,
|
|
124
|
+
// Retention for archived (unmerged) fallback-branch tips — see sweepStaleAgentWorkBranches.
|
|
125
|
+
agentWorkArchiveTtlMs: 90 * 24 * 60 * 60 * 1000,
|
|
124
126
|
gcGraceMs: 60 * 60 * 1000,
|
|
125
127
|
gcEveryMs: 60 * 60 * 1000,
|
|
126
128
|
});
|
|
@@ -234,6 +236,8 @@ export function checkpointConfig(env = process.env) {
|
|
|
234
236
|
intervalMs: intOr(env.NANO_AGENT_CHECKPOINT_INTERVAL_MS, DEFAULTS.intervalMs),
|
|
235
237
|
maxFileBytes: intOr(env.NANO_AGENT_CHECKPOINT_MAX_FILE_BYTES, DEFAULTS.maxFileBytes),
|
|
236
238
|
ttlMs: intOr(env.NANO_AGENT_CHECKPOINT_TTL_MS, DEFAULTS.ttlMs),
|
|
239
|
+
// 0 disables purging archived agent-work tips (they are then kept forever).
|
|
240
|
+
agentWorkArchiveTtlMs: intOr(env.NANO_AGENT_WORK_ARCHIVE_TTL_MS, DEFAULTS.agentWorkArchiveTtlMs),
|
|
237
241
|
gcGraceMs: DEFAULTS.gcGraceMs,
|
|
238
242
|
gcEveryMs: DEFAULTS.gcEveryMs,
|
|
239
243
|
gitTimeoutMs: DEFAULTS.gitTimeoutMs,
|
|
@@ -1157,6 +1161,143 @@ export async function sweepStaleCheckpoints({ git, ownRef = null, ttlMs = DEFAUL
|
|
|
1157
1161
|
}
|
|
1158
1162
|
}
|
|
1159
1163
|
|
|
1164
|
+
// The fallback work-branch namespace `provisionRepo` cuts when a push-enabled round is
|
|
1165
|
+
// provisioned WITHOUT a `branch.create` naming a real (non-base) work branch (issue #231):
|
|
1166
|
+
// rather than commit directly on the base, the harness cuts `nano/agent-work/<base>-<runId>`
|
|
1167
|
+
// and pushes it so the round's commits are never lost. When the round's work also landed on a
|
|
1168
|
+
// real PR branch (the app now emits `branch.create`, jwulf/c8ctl-plugin-nano#231 / nano-workforce
|
|
1169
|
+
// service fix), or the run is long dead, these pushed fallbacks are pure orphans that otherwise
|
|
1170
|
+
// accumulate forever — the WIP-checkpoint sweep only reclaims `refs/nano/wip/*`.
|
|
1171
|
+
export const AGENT_WORK_REF_PREFIX = 'refs/heads/nano/agent-work/';
|
|
1172
|
+
|
|
1173
|
+
// Archive namespace for unmerged fallback tips the GC removes from the branch list. NOT under
|
|
1174
|
+
// `refs/heads/`, so it never clutters branches / PR pickers, but the commits stay reachable
|
|
1175
|
+
// (and fetchable by exact ref) on the remote. Layout: `<prefix><archivedAtMs>/<branch-suffix>` —
|
|
1176
|
+
// the archive TIME is encoded in the ref because git refs carry no timestamp and the tip's
|
|
1177
|
+
// commit date (old by construction) can't measure how long it has been archived.
|
|
1178
|
+
export const AGENT_WORK_ARCHIVE_PREFIX = 'refs/nano/archive/agent-work/';
|
|
1179
|
+
|
|
1180
|
+
// Orphan GC for the pushed fallback work branches. A fallback branch can be the ONLY copy of a
|
|
1181
|
+
// run's work (the agent died without opening a PR), so age alone never authorises deleting it.
|
|
1182
|
+
// A branch past `ttlMs` (tip commit age — the branch segment is a UUID runId, not an element
|
|
1183
|
+
// instance key, so the WIP sweep's element-terminal lookup can't map here) is then:
|
|
1184
|
+
// 1. KEPT if it heads an open PR (`hasOpenPr(branch) === true`) — deleting a PR's head branch
|
|
1185
|
+
// closes the PR. FAIL-CLOSED: no lookup, a throw, or any non-boolean answer also keeps it.
|
|
1186
|
+
// 2. DELETED ('merged') if its tip is contained in another remote branch — the work is safe.
|
|
1187
|
+
// 3. Otherwise ARCHIVED ('archived'): the tip is pushed to `AGENT_WORK_ARCHIVE_PREFIX` FIRST and
|
|
1188
|
+
// the branch is deleted only after that push succeeds, so the commits are never unreachable.
|
|
1189
|
+
// Archive refs are purged once `archiveTtlMs` past their archive time (<= 0 disables purging).
|
|
1190
|
+
// Every remote delete is leased against the SHA observed at ls-remote time, so a ref a
|
|
1191
|
+
// concurrent activation just advanced is left intact. Runs in the same isolated scratch repo as
|
|
1192
|
+
// `sweepStaleCheckpoints`, so it shares the GC deadline/abort signal.
|
|
1193
|
+
//
|
|
1194
|
+
// Only GENERATED per-run fallbacks are GC candidates. The `nano/agent-work/` namespace is not
|
|
1195
|
+
// fallback-only — a stable/unrelated branch (`nano/agent-work/my-feature`) can live under it
|
|
1196
|
+
// (see `fallbackBranchParts`), and age must never authorise deleting one. So the ls-remote list
|
|
1197
|
+
// is filtered through the same generated-name parser provisioning's names satisfy
|
|
1198
|
+
// (`<base>-<runToken>`, runToken a UUID or `run-<token>`): a name that does not parse is NOT a
|
|
1199
|
+
// fallback — it is kept (reported 'not-a-fallback'), never fetched as a candidate, and counts
|
|
1200
|
+
// as a safe "other" head for the containment test (its commits are real, retained work).
|
|
1201
|
+
export async function sweepStaleAgentWorkBranches({ git, ttlMs = DEFAULTS.ttlMs, archiveTtlMs = DEFAULTS.agentWorkArchiveTtlMs, hasOpenPr = null, now = () => Date.now(), maxDeletes = 50, remote = 'origin', signal = null }) {
|
|
1202
|
+
const ls = await git(['ls-remote', '--refs', remote, 'refs/heads/*', `${AGENT_WORK_ARCHIVE_PREFIX}*`]);
|
|
1203
|
+
if (!ok(ls)) return { error: errText(ls), deleted: [], kept: [], purged: [] };
|
|
1204
|
+
const entries = out(ls).split('\n').filter(Boolean).map((l) => { const [sha, ref] = l.split(/\s+/); return { sha, ref }; }).filter((e) => e.ref);
|
|
1205
|
+
const inNs = entries.filter((e) => e.ref.startsWith(AGENT_WORK_REF_PREFIX));
|
|
1206
|
+
// Split the namespace into generated fallbacks (GC candidates) and everything else (stable —
|
|
1207
|
+
// kept, and a safe containment home). `fallbackBranchParts` is the single source of truth for
|
|
1208
|
+
// what provisioning's generated name looks like, so the GC can never mistake a stable branch
|
|
1209
|
+
// for a fallback no matter how old its tip is.
|
|
1210
|
+
const work = [];
|
|
1211
|
+
const stable = [];
|
|
1212
|
+
for (const e of inNs) (fallbackBranchParts(e.ref.slice('refs/heads/'.length)) ? work : stable).push(e);
|
|
1213
|
+
const others = entries.filter((e) => e.ref.startsWith('refs/heads/') && !e.ref.startsWith(AGENT_WORK_REF_PREFIX));
|
|
1214
|
+
const archives = entries.filter((e) => e.ref.startsWith(AGENT_WORK_ARCHIVE_PREFIX));
|
|
1215
|
+
const result = { scanned: work.length, deleted: [], kept: stable.map((e) => ({ ref: e.ref, why: 'not-a-fallback' })), purged: [] };
|
|
1216
|
+
let lastError = null;
|
|
1217
|
+
|
|
1218
|
+
// Purge archives past their retention. Needs no fetch: the archive time is in the ref name.
|
|
1219
|
+
if (archiveTtlMs > 0) {
|
|
1220
|
+
for (const { ref, sha } of archives) {
|
|
1221
|
+
if (result.purged.length >= maxDeletes || signal?.aborted) break;
|
|
1222
|
+
const at = Number(ref.slice(AGENT_WORK_ARCHIVE_PREFIX.length).split('/')[0]);
|
|
1223
|
+
if (!Number.isFinite(at) || at <= 0 || now() - at <= archiveTtlMs) continue;
|
|
1224
|
+
const r = await deleteCheckpointRef({ git, ref, remote, expectSha: sha });
|
|
1225
|
+
if (r.ok) result.purged.push({ ref, why: 'archive-ttl' });
|
|
1226
|
+
else if (r.error) lastError = r.error;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
if (!work.length) { if (lastError && !result.purged.length) result.error = lastError; return result; }
|
|
1230
|
+
|
|
1231
|
+
// Fetch the fallback tips AND every other branch head (for the containment test) into
|
|
1232
|
+
// throwaway local refs, always removed in `finally`. The two sets land in DISJOINT namespaces
|
|
1233
|
+
// so the containment scan can never count a fallback branch (itself or a sibling fallback,
|
|
1234
|
+
// both GC candidates) as a safe home for the work. Stable namespace branches are NOT
|
|
1235
|
+
// candidates, so they join `others` as legitimate containment homes.
|
|
1236
|
+
const workLocal = (r) => `refs/nano-gc/agent-work/${r.slice(AGENT_WORK_REF_PREFIX.length)}`;
|
|
1237
|
+
const otherLocal = (r) => `refs/nano-gc/other-heads/${r.slice('refs/heads/'.length)}`;
|
|
1238
|
+
const specs = [...work.map((e) => [e.ref, workLocal(e.ref)]), ...others.map((e) => [e.ref, otherLocal(e.ref)]), ...stable.map((e) => [e.ref, otherLocal(e.ref)])];
|
|
1239
|
+
const fetch = await git(['fetch', '--quiet', '--no-tags', '--no-write-fetch-head', remote, ...specs.map(([r, l]) => `+${r}:${l}`)]);
|
|
1240
|
+
if (!ok(fetch)) return { ...result, error: errText(fetch) };
|
|
1241
|
+
try {
|
|
1242
|
+
const stale = [];
|
|
1243
|
+
for (const e of work) {
|
|
1244
|
+
if (signal?.aborted) break;
|
|
1245
|
+
const at = Number(out(await git(['log', '-1', '--format=%ct', workLocal(e.ref)]))) * 1000;
|
|
1246
|
+
if (!Number.isFinite(at) || at <= 0) continue;
|
|
1247
|
+
if (ttlMs > 0 && now() - at > ttlMs) stale.push(e);
|
|
1248
|
+
}
|
|
1249
|
+
let actions = 0;
|
|
1250
|
+
for (const { ref, sha } of stale) {
|
|
1251
|
+
if (actions >= maxDeletes || signal?.aborted) break;
|
|
1252
|
+
const branch = ref.slice('refs/heads/'.length);
|
|
1253
|
+
let open = null;
|
|
1254
|
+
try { open = typeof hasOpenPr === 'function' ? await hasOpenPr(branch) : null; } catch { open = null; }
|
|
1255
|
+
if (open !== false) { result.kept.push({ ref, why: open === true ? 'open-pr' : 'pr-unknown' }); continue; }
|
|
1256
|
+
actions++;
|
|
1257
|
+
// Any containment home — a non-namespace branch OR a stable namespace branch — runs the query.
|
|
1258
|
+
const contains = (others.length || stable.length)
|
|
1259
|
+
? await git(['for-each-ref', '--count=1', '--format=%(refname)', '--contains', sha, 'refs/nano-gc/other-heads/'])
|
|
1260
|
+
: null;
|
|
1261
|
+
if (contains && !ok(contains)) { lastError = errText(contains); result.kept.push({ ref, why: 'containment-unknown' }); continue; }
|
|
1262
|
+
let contained = !!(contains && out(contains));
|
|
1263
|
+
if (contained) {
|
|
1264
|
+
// The containment answer comes from the ls-remote/fetch SNAPSHOT, but only the
|
|
1265
|
+
// candidate's own delete is leased: a home that contained the tip at scan time can be
|
|
1266
|
+
// force-pushed or deleted before this delete lands, orphaning the tip despite the
|
|
1267
|
+
// must-never-lose-work contract (Copilot discussion_r4475075083). Revalidate the home
|
|
1268
|
+
// against the LIVE remote immediately before deleting: a home that no longer contains
|
|
1269
|
+
// the tip demotes the delete to the archive path. An UNREACHABLE remote fails closed
|
|
1270
|
+
// (kept, 'containment-unknown') — never delete on an unverifiable home.
|
|
1271
|
+
// The for-each-ref output is the LOCAL throwaway ref — map it back to the remote
|
|
1272
|
+
// branch name it was fetched from (the fetch spec inverted `otherLocal`).
|
|
1273
|
+
const homeLocal = out(contains).trim();
|
|
1274
|
+
const homeRef = `refs/heads/${homeLocal.slice('refs/nano-gc/other-heads/'.length)}`;
|
|
1275
|
+
const live = await git(['ls-remote', remote, homeRef]);
|
|
1276
|
+
if (!ok(live)) { lastError = errText(live); result.kept.push({ ref, why: 'containment-unknown' }); continue; }
|
|
1277
|
+
const liveSha = (out(live).split(/\s+/)[0] || '').trim();
|
|
1278
|
+
if (!liveSha) contained = false; // the home itself is gone
|
|
1279
|
+
else {
|
|
1280
|
+
const re = await git(['merge-base', '--is-ancestor', sha, liveSha]);
|
|
1281
|
+
if (re.status !== 0 && re.status !== 1) { lastError = errText(re); result.kept.push({ ref, why: 'containment-unknown' }); continue; }
|
|
1282
|
+
contained = re.status === 0;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
if (!contained) {
|
|
1286
|
+
const archiveRef = `${AGENT_WORK_ARCHIVE_PREFIX}${now()}/${ref.slice(AGENT_WORK_REF_PREFIX.length)}`;
|
|
1287
|
+
const a = await git(['push', '--quiet', '--no-verify', remote, `${sha}:${archiveRef}`]);
|
|
1288
|
+
if (!ok(a)) { lastError = errText(a); result.kept.push({ ref, why: 'archive-failed' }); continue; }
|
|
1289
|
+
}
|
|
1290
|
+
const r = await deleteCheckpointRef({ git, ref, remote, expectSha: sha });
|
|
1291
|
+
if (r.ok) result.deleted.push({ ref, why: contained ? 'merged' : 'archived' });
|
|
1292
|
+
else if (r.error) lastError = r.error;
|
|
1293
|
+
}
|
|
1294
|
+
if (!result.deleted.length && !result.purged.length && lastError) result.error = lastError;
|
|
1295
|
+
return result;
|
|
1296
|
+
} finally {
|
|
1297
|
+
for (const [, l] of specs) await git(['update-ref', '-d', l]);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1160
1301
|
// Prompt note appended when a checkpoint was restored into the workspace.
|
|
1161
1302
|
export function checkpointRestoredNote(info) {
|
|
1162
1303
|
if (!info?.restored) return '';
|
package/c8ctl-plugin.js
CHANGED
|
@@ -90,7 +90,7 @@ import { createAgentInstanceProducer, isExternalAgentJob } from './agent-instanc
|
|
|
90
90
|
// so the new agent CONTINUES rather than cold-reruns — at-least-once delivery becomes
|
|
91
91
|
// a continuation, not a duplicate. Best-effort; degrades to the legacy cold rerun.
|
|
92
92
|
import { resolveEffectiveEnvelope } from './agent-resume.mjs';
|
|
93
|
-
import { checkpointConfig, checkpointEligibility, checkpointRef, recoveredCheckpointRef, predecessorCheckpointRef, resumeRefIsExplicit, pushNamedRef, observeRemoteRefSha, makeOrphanProbe, normalizeSecretValues, credentialsFromUrl, isAuthenticatedRemote, shouldSweep, sweepStaleCheckpoints, createGitRunner, fetchCheckpoint, restoreCheckpoint, createWorkspaceCheckpoint, createCheckpointer, deleteCheckpointRef, withCheckpointNote, sanitizeBranchSegment } from './agent-checkpoint.mjs';
|
|
93
|
+
import { checkpointConfig, checkpointEligibility, checkpointRef, recoveredCheckpointRef, predecessorCheckpointRef, resumeRefIsExplicit, pushNamedRef, observeRemoteRefSha, makeOrphanProbe, normalizeSecretValues, credentialsFromUrl, isAuthenticatedRemote, shouldSweep, sweepStaleCheckpoints, sweepStaleAgentWorkBranches, createGitRunner, fetchCheckpoint, restoreCheckpoint, createWorkspaceCheckpoint, createCheckpointer, deleteCheckpointRef, withCheckpointNote, sanitizeBranchSegment } from './agent-checkpoint.mjs';
|
|
94
94
|
|
|
95
95
|
const requireFromHere = createRequire(import.meta.url);
|
|
96
96
|
const pluginDir = dirname(fileURLToPath(import.meta.url));
|
|
@@ -6726,6 +6726,38 @@ function reconcileAgentPr({ workspaceDir, token, branch, provider }) {
|
|
|
6726
6726
|
}
|
|
6727
6727
|
}
|
|
6728
6728
|
|
|
6729
|
+
// Does `branch` head an OPEN PR? Used by the agent-work branch GC, which must never delete a
|
|
6730
|
+
// PR's head branch (GitHub closes the PR). Tri-state: true / false, or null when unknown (non-
|
|
6731
|
+
// GitHub provider, gh missing/failing, unparsable output) — the GC treats null as "keep".
|
|
6732
|
+
// Async (not spawnSync) so a slow gh never blocks the event loop; aborts with the GC signal.
|
|
6733
|
+
function ghHasOpenPr({ cwd, token, branch, provider = 'github', signal = null, timeoutMs = 30_000, spawnImpl = spawn }) {
|
|
6734
|
+
if (provider !== 'github') return Promise.resolve(null);
|
|
6735
|
+
return new Promise((resolve) => {
|
|
6736
|
+
let stdout = '';
|
|
6737
|
+
let done = false;
|
|
6738
|
+
// Declared BEFORE the spawn so a synchronous spawn throw (invalid cwd/options) reaching
|
|
6739
|
+
// finish() never reads `timer` in its TDZ (a ReferenceError instead of the tri-state null).
|
|
6740
|
+
let timer = null;
|
|
6741
|
+
const finish = (v) => { if (!done) { done = true; if (timer) clearTimeout(timer); resolve(v); } };
|
|
6742
|
+
let child;
|
|
6743
|
+
try {
|
|
6744
|
+
child = spawnImpl('gh', ['pr', 'list', '--head', branch, '--state', 'open', '--json', 'number', '--limit', '1'],
|
|
6745
|
+
{ cwd, env: ghAuthEnv(token, cwd), stdio: ['ignore', 'pipe', 'ignore'], signal: signal || undefined });
|
|
6746
|
+
} catch { finish(null); return; }
|
|
6747
|
+
timer = setTimeout(() => { try { child.kill('SIGKILL'); } catch { /* gone */ } finish(null); }, timeoutMs);
|
|
6748
|
+
timer.unref?.();
|
|
6749
|
+
child.stdout?.on('data', (d) => { stdout += d; });
|
|
6750
|
+
child.on('error', () => finish(null));
|
|
6751
|
+
child.on('close', (code) => {
|
|
6752
|
+
if (code !== 0) return finish(null);
|
|
6753
|
+
try {
|
|
6754
|
+
const arr = JSON.parse(stdout.trim() || 'null');
|
|
6755
|
+
finish(Array.isArray(arr) ? arr.length > 0 : null);
|
|
6756
|
+
} catch { finish(null); }
|
|
6757
|
+
});
|
|
6758
|
+
});
|
|
6759
|
+
}
|
|
6760
|
+
|
|
6729
6761
|
// Build the gh environment for PR-side calls: inject the resolved job token, or
|
|
6730
6762
|
// (anonymous path) scrub every ambient gh credential so we can only use what we
|
|
6731
6763
|
// were explicitly handed. Scrubbing the token env vars alone is not enough — gh
|
|
@@ -6852,6 +6884,8 @@ async function setupWorkspaceCheckpoints({ provisioned, envelope = null, token =
|
|
|
6852
6884
|
restoreCheckpoint: restoreCp = restoreCheckpoint,
|
|
6853
6885
|
deleteCheckpointRef: deleteCp = deleteCheckpointRef,
|
|
6854
6886
|
sweep = sweepStaleCheckpoints,
|
|
6887
|
+
sweepAgentWork = sweepStaleAgentWorkBranches,
|
|
6888
|
+
hasOpenPr: openPr = ghHasOpenPr,
|
|
6855
6889
|
now = () => Date.now(),
|
|
6856
6890
|
} = deps;
|
|
6857
6891
|
const log = {
|
|
@@ -7121,6 +7155,23 @@ async function setupWorkspaceCheckpoints({ provisioned, envelope = null, token =
|
|
|
7121
7155
|
else if (sweepAbort.signal.aborted) log.debug(`checkpoint GC bounded at ${GC_OVERALL_TIMEOUT_MS}ms — aborted its in-flight git and drained; leftover refs reclaimed on a later sweep.`);
|
|
7122
7156
|
else if (r?.error) log.debug(`checkpoint GC skipped — ${redactToken(oneLineLog(r.error), token)}.`);
|
|
7123
7157
|
}, (err) => log.debug(`checkpoint GC threw — ${redactToken(oneLineLog(err?.message || err), token)}.`))
|
|
7158
|
+
// Reclaim orphaned `nano/agent-work/*` fallback branches in the SAME scratch repo, sharing
|
|
7159
|
+
// the deadline/abort (issue #231). Chained (not raced) so `close()`/`discard()` await
|
|
7160
|
+
// both sweeps before the scratch dir is reaped. Never loses work: open-PR heads are kept,
|
|
7161
|
+
// contained tips are deleted, unmerged tips are archived first. Failures stay debug-level.
|
|
7162
|
+
.then(() => sweepAgentWork({
|
|
7163
|
+
git: sweepGit, ttlMs: cfg.ttlMs, archiveTtlMs: cfg.agentWorkArchiveTtlMs, now, signal: sweepAbort.signal,
|
|
7164
|
+
// gh resolves the repo from the scratch repo's `origin`. Unknown (null) => branch kept.
|
|
7165
|
+
hasOpenPr: (branch) => openPr({ cwd: sweepDir, token, branch, provider: envelope?.repository?.provider || 'github', signal: sweepAbort.signal }),
|
|
7166
|
+
}))
|
|
7167
|
+
.then((r) => {
|
|
7168
|
+
if (r?.deleted?.length) logger.info?.(`${prefix} (${corr}): reclaimed ${r.deleted.length} orphaned agent-work branch(es): ${r.deleted.map((d) => `${d.ref} [${d.why}]`).join(', ')}.`);
|
|
7169
|
+
if (r?.purged?.length) logger.info?.(`${prefix} (${corr}): purged ${r.purged.length} expired agent-work archive ref(s): ${r.purged.map((d) => d.ref).join(', ')}.`);
|
|
7170
|
+
if (r?.kept?.length) log.debug(`agent-work branch GC kept ${r.kept.length} stale branch(es): ${r.kept.map((k) => `${k.ref} [${k.why}]`).join(', ')}.`);
|
|
7171
|
+
if (r?.deleted?.length || r?.purged?.length) return;
|
|
7172
|
+
if (sweepAbort.signal.aborted) log.debug(`agent-work branch GC bounded at ${GC_OVERALL_TIMEOUT_MS}ms — aborted its in-flight git and drained; leftover branches reclaimed on a later sweep.`);
|
|
7173
|
+
else if (r?.error) log.debug(`agent-work branch GC skipped — ${redactToken(oneLineLog(r.error), token)}.`);
|
|
7174
|
+
}, (err) => log.debug(`agent-work branch GC threw — ${redactToken(oneLineLog(err?.message || err), token)}.`))
|
|
7124
7175
|
.finally(() => { clearTimeout(deadlineTimer); if (sweepDir) { try { rmSync(sweepDir, { recursive: true, force: true }); } catch { /* best effort */ } } });
|
|
7125
7176
|
} catch (err) {
|
|
7126
7177
|
if (sweepDir) { try { rmSync(sweepDir, { recursive: true, force: true }); } catch { /* best effort */ } }
|
|
@@ -20176,6 +20227,7 @@ export {
|
|
|
20176
20227
|
sanitizeBranchSegment,
|
|
20177
20228
|
shouldPreserveRunDir,
|
|
20178
20229
|
setupWorkspaceCheckpoints,
|
|
20230
|
+
ghHasOpenPr,
|
|
20179
20231
|
computeRelayCloseReason,
|
|
20180
20232
|
describeGitFailure,
|
|
20181
20233
|
boundGitOutput,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c8ctl-plugin-nano",
|
|
3
|
-
"version": "1.70.
|
|
3
|
+
"version": "1.70.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "c8ctl plugin to start, inspect, and stop a local Nano BPM (nanobpmn) cluster",
|
|
6
6
|
"main": "c8ctl-plugin.js",
|
|
@@ -71,17 +71,17 @@
|
|
|
71
71
|
"typescript": "^5.9.3"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@nanobpm/agentic": "^0.
|
|
74
|
+
"@nanobpm/agentic": "^0.16.0",
|
|
75
75
|
"@nanobpm/urban-agent-client": "^0.1.14"
|
|
76
76
|
},
|
|
77
77
|
"optionalDependencies": {
|
|
78
78
|
"node-pty": "^1.0.0",
|
|
79
|
-
"@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.70.
|
|
80
|
-
"@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.70.
|
|
81
|
-
"@nanobpm/c8ctl-plugin-nano-linux-x64": "1.70.
|
|
82
|
-
"@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.70.
|
|
83
|
-
"@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.70.
|
|
84
|
-
"@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.70.
|
|
85
|
-
"@nanobpm/c8ctl-plugin-nano-win32-x64": "1.70.
|
|
79
|
+
"@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.70.8",
|
|
80
|
+
"@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.70.8",
|
|
81
|
+
"@nanobpm/c8ctl-plugin-nano-linux-x64": "1.70.8",
|
|
82
|
+
"@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.70.8",
|
|
83
|
+
"@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.70.8",
|
|
84
|
+
"@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.70.8",
|
|
85
|
+
"@nanobpm/c8ctl-plugin-nano-win32-x64": "1.70.8"
|
|
86
86
|
}
|
|
87
87
|
}
|