opencode-model-router 2.9.0 → 2.10.0
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/CHANGELOG.md +184 -0
- package/README.md +4 -3
- package/package.json +5 -5
- package/src/compat/background.ts +51 -19
- package/src/compat/child-history.ts +134 -0
- package/src/compat/child-report.ts +185 -0
- package/src/compat/child-session.ts +10 -0
- package/src/compat/v2-client.ts +124 -6
- package/src/compat/v2-hooks.ts +301 -147
- package/src/executor/create.ts +44 -28
- package/src/executor/git.ts +121 -9
- package/src/executor/integrate/land.ts +32 -2
- package/src/executor/runtime.ts +52 -17
- package/src/index.ts +84 -4
- package/src/router/config.ts +157 -28
- package/src/router/git-metadata-guard.ts +180 -0
- package/src/router/git-tools.ts +238 -8
- package/src/router/read-only.ts +37 -13
- package/src/router/run-tools.ts +32 -2
- package/src/router/sessions.ts +9 -0
- package/src/router/tool-paths.ts +62 -4
- package/src/routing/roles/read-set.ts +10 -1
- package/src/routing/roles/work-root.ts +20 -3
- package/src/verify/head.ts +6 -1
- package/src/verify/pending.ts +14 -1
- package/src/verify/reference.ts +60 -7
- package/src/verify/tree.ts +30 -10
- package/src/verify/wiring.ts +47 -12
- package/tiers.json +5 -5
package/src/executor/create.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { runArgv } from "../verify/exec";
|
|
|
15
15
|
import { hardeningArgs, spawnBounded, workRootGuards } from "../router/git-tools";
|
|
16
16
|
import { createCapacityController } from "./capacity";
|
|
17
17
|
import { createPlanCompiler, type CompilerDeps } from "./compile";
|
|
18
|
-
import { createGitOps, createGitRunner } from "./git";
|
|
18
|
+
import { createGitOps, createGitRunner, readCommitIdentity, withRepositoryDrivers } from "./git";
|
|
19
19
|
import { BackgroundRuns, createIntegrateGit, createIntegrationChecks, createWriteGuard } from "./integrate/checks";
|
|
20
20
|
import { createLander } from "./integrate/land";
|
|
21
21
|
import { createPhaseSuiteRunner } from "./integrate/phase-suite";
|
|
@@ -143,6 +143,11 @@ export class PlanSlotPools {
|
|
|
143
143
|
return view;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
/** A newly created plan may reuse an id; old views retain their own closed entry and stay fenced. */
|
|
147
|
+
forget(planId: PlanId): void {
|
|
148
|
+
if (this.entries.get(planId)?.closed === true) this.entries.delete(planId);
|
|
149
|
+
}
|
|
150
|
+
|
|
146
151
|
async gc(finished: Parameters<SlotPool["gc"]>[0], opts?: Parameters<SlotPool["gc"]>[1]): ReturnType<SlotPool["gc"]> {
|
|
147
152
|
const removed: string[] = [], reported: string[] = [];
|
|
148
153
|
for (const plan of await this.deps.store.list()) {
|
|
@@ -234,27 +239,31 @@ async function checkBase(git: RuntimeDeps["git"], repo: LedgerV1["repo"]): Promi
|
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
241
|
|
|
237
|
-
const processClaimKey = Symbol.for("omr.executor.claim.
|
|
242
|
+
const processClaimKey = Symbol.for("omr.executor.claim.v2");
|
|
238
243
|
/**
|
|
239
244
|
* QA-5.1-20: the retry callbacks of copies refused by the claim (a hot reload starts the new copy before the old one has
|
|
240
|
-
* disposed).
|
|
241
|
-
*
|
|
245
|
+
* disposed). Both maps are process-wide across module copies, keyed by the canonical executor home shared by linked
|
|
246
|
+
* worktrees. A release calls only that home's waiters; they race for its claim through the same token check.
|
|
247
|
+
* v2 keys keep older loaded copies from misreading the new map shapes.
|
|
242
248
|
*/
|
|
243
|
-
const processClaimWaitersKey = Symbol.for("omr.executor.claim.waiters.
|
|
249
|
+
const processClaimWaitersKey = Symbol.for("omr.executor.claim.waiters.v2");
|
|
244
250
|
const processClaims = globalThis as typeof globalThis & {
|
|
245
|
-
[processClaimKey]?: { token: symbol; toplevel: string }
|
|
246
|
-
[processClaimWaitersKey]?: Set<() => void
|
|
251
|
+
[processClaimKey]?: Map<string, { token: symbol; toplevel: string }>;
|
|
252
|
+
[processClaimWaitersKey]?: Map<string, Set<() => void>>;
|
|
247
253
|
};
|
|
248
254
|
|
|
249
|
-
function claimWaiters(): Set<() => void> {
|
|
250
|
-
|
|
255
|
+
function claimWaiters(home: string): Set<() => void> {
|
|
256
|
+
const waiters = processClaims[processClaimWaitersKey] ??= new Map();
|
|
257
|
+
let own = waiters.get(home);
|
|
258
|
+
if (own === undefined) { own = new Set(); waiters.set(home, own); }
|
|
259
|
+
return own;
|
|
251
260
|
}
|
|
252
261
|
|
|
253
|
-
/** Frees the claim `token` holds (no-op for another holder's), then tells
|
|
254
|
-
function releaseClaim(token: symbol): void {
|
|
255
|
-
if (processClaims[processClaimKey]?.token !== token) return;
|
|
256
|
-
|
|
257
|
-
for (const retry of [...
|
|
262
|
+
/** Frees the home's claim `token` holds (no-op for another holder's), then tells its refused copies they may retry. */
|
|
263
|
+
function releaseClaim(home: string, token: symbol): void {
|
|
264
|
+
if (processClaims[processClaimKey]?.get(home)?.token !== token) return;
|
|
265
|
+
processClaims[processClaimKey]?.delete(home);
|
|
266
|
+
for (const retry of [...(processClaims[processClaimWaitersKey]?.get(home) ?? [])]) {
|
|
258
267
|
try { retry(); } catch { /* A waiter's failure is its own (it logs and clears its access). */ }
|
|
259
268
|
}
|
|
260
269
|
}
|
|
@@ -299,26 +308,27 @@ export function createExecutor(
|
|
|
299
308
|
|
|
300
309
|
/**
|
|
301
310
|
* QA-5.1-20: a copy refused only by the process claim keeps its inputs and retries the assembly once the claim is free: at
|
|
302
|
-
* the release (the holder's dispose calls
|
|
303
|
-
* waiters race for the claim through the same token check, so one wins; the others stay waiters.
|
|
311
|
+
* the release (the holder's dispose calls that home's waiters) or, failing that, the first time its `lateRuntime` is used.
|
|
312
|
+
* The waiters race for the home's claim through the same token check, so one wins; the others stay waiters.
|
|
304
313
|
* QA-5.1-26: the winner is handed to its adapter (`host.onExecutor`), which adopts it through the same path as an executor
|
|
305
314
|
* built at start: it registers the executor's providers and hooks, starts it once (its recovery runs once) and disposes it in
|
|
306
315
|
* the W7 order. A winner its adapter does not adopt (the adapter is already disposing) gets the safety dispose here.
|
|
307
316
|
*/
|
|
308
|
-
function waitForClaim(context: { directory: string }, options: CreateExecutorOptions): void {
|
|
317
|
+
function waitForClaim(home: string, context: { directory: string }, options: CreateExecutorOptions): void {
|
|
309
318
|
const { access, host } = options;
|
|
310
319
|
const lifetime = host.lifetime;
|
|
311
320
|
if (access.deferRetry === undefined || lifetime.aborted) return;
|
|
312
|
-
const waiters = claimWaiters();
|
|
321
|
+
const waiters = claimWaiters(home);
|
|
313
322
|
let spent = false;
|
|
314
323
|
// A copy that ends while it waits stops waiting: no executor is ever assembled for a disposed copy.
|
|
315
324
|
function forget(): void {
|
|
316
325
|
spent = true;
|
|
317
326
|
waiters.delete(retry);
|
|
327
|
+
if (waiters.size === 0) processClaims[processClaimWaitersKey]?.delete(home);
|
|
318
328
|
access.deferRetry?.(null);
|
|
319
329
|
}
|
|
320
330
|
function retry(): void {
|
|
321
|
-
if (spent || lifetime.aborted || processClaims[processClaimKey]
|
|
331
|
+
if (spent || lifetime.aborted || processClaims[processClaimKey]?.has(home)) return;
|
|
322
332
|
lifetime.removeEventListener("abort", forget);
|
|
323
333
|
forget();
|
|
324
334
|
const built = assembleExecutor(context, options);
|
|
@@ -362,14 +372,15 @@ function assembleExecutor(context: { directory: string }, options: CreateExecuto
|
|
|
362
372
|
if (!prepared.ok) return absent(prepared.reason);
|
|
363
373
|
if (host.leases === null) return absent("the lease registry is not available");
|
|
364
374
|
if (host.runner === null) return absent("the child runner is not available");
|
|
365
|
-
|
|
375
|
+
const { toplevel, home } = prepared;
|
|
376
|
+
const claims = processClaims[processClaimKey] ??= new Map();
|
|
377
|
+
if (claims.has(home)) {
|
|
366
378
|
// QA-5.1-20: refused only by the claim (a hot reload's new copy, while the old one disposes): wait for its release.
|
|
367
|
-
waitForClaim(context, options);
|
|
368
|
-
return absent("another plan executor already owns this process");
|
|
379
|
+
waitForClaim(home, context, options);
|
|
380
|
+
return absent("another plan executor already owns this repository in this process");
|
|
369
381
|
}
|
|
370
382
|
const claim = Symbol("plan executor");
|
|
371
|
-
|
|
372
|
-
processClaims[processClaimKey] = { token: claim, toplevel };
|
|
383
|
+
claims.set(home, { token: claim, toplevel });
|
|
373
384
|
const clock = createNodeClock();
|
|
374
385
|
const fs = createNodeFileSystem();
|
|
375
386
|
const spawner = nodeSpawner();
|
|
@@ -382,7 +393,10 @@ function assembleExecutor(context: { directory: string }, options: CreateExecuto
|
|
|
382
393
|
let launcher: ReturnType<typeof createTaskLauncher> | null = null;
|
|
383
394
|
try {
|
|
384
395
|
const rawGit = createGitRunner({ mode: "hardened", toplevel });
|
|
385
|
-
|
|
396
|
+
// Every executor git call (GitOps, the runtime's commits/WIP/reset/clean, igit, the lander's probes, the compiler): the
|
|
397
|
+
// hardening, then the repository-only driver blanking read afresh for that call (required=true: git refuses rather than
|
|
398
|
+
// writing unfiltered content).
|
|
399
|
+
const git: RuntimeDeps["git"] = withRepositoryDrivers({ run: (args, opts) => rawGit.run([...hardeningArgs(), ...args], opts) }, toplevel);
|
|
386
400
|
const userGit = createGitRunner({ mode: "user", toplevel });
|
|
387
401
|
const store = createLedgerStore({ home, observations: options.observations });
|
|
388
402
|
const opsOf = (planId: PlanId) => createGitOps({ git, userGit, fs, planId, toplevel, executorHome: home });
|
|
@@ -529,7 +543,9 @@ function assembleExecutor(context: { directory: string }, options: CreateExecuto
|
|
|
529
543
|
runtime = createExecutorRuntime({ store, compiler, self, executorHome: home,
|
|
530
544
|
observations: options.observations,
|
|
531
545
|
slots: planPools.facade, slotsFor: (id) => planPools.of(id), purgeSlots: (id, finished) => planPools.purge(id, finished),
|
|
532
|
-
|
|
546
|
+
forgetSlots: (id) => planPools.forget(id),
|
|
547
|
+
scheduler: createScheduler(), launcher: taskLauncher, routes, verifier: host.verifier, git,
|
|
548
|
+
commitIdentity: () => readCommitIdentity(userGit, toplevel), hosts: host.hosts, bindings: host.bindings, clock,
|
|
533
549
|
leaseRegistry: { acquireWrite: (owner, writes) => {
|
|
534
550
|
const result = leases.registry.acquireWrite(owner, writes);
|
|
535
551
|
if (result.ok) return { ok: true };
|
|
@@ -571,7 +587,7 @@ function assembleExecutor(context: { directory: string }, options: CreateExecuto
|
|
|
571
587
|
try { await innerRuntime.dispose(); }
|
|
572
588
|
finally {
|
|
573
589
|
try { await planPools.closeAll(); }
|
|
574
|
-
finally { for (const timer of timers) clock.clearTimer(timer); timers.clear(); releaseClaim(claim); }
|
|
590
|
+
finally { for (const timer of timers) clock.clearTimer(timer); timers.clear(); releaseClaim(home, claim); }
|
|
575
591
|
}
|
|
576
592
|
})();
|
|
577
593
|
return disposal;
|
|
@@ -583,7 +599,7 @@ function assembleExecutor(context: { directory: string }, options: CreateExecuto
|
|
|
583
599
|
void pools?.closeAll();
|
|
584
600
|
for (const timer of timers) clock.clearTimer(timer);
|
|
585
601
|
const failed = absent(`assembly failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
586
|
-
releaseClaim(claim);
|
|
602
|
+
releaseClaim(home, claim);
|
|
587
603
|
return failed;
|
|
588
604
|
}
|
|
589
605
|
}
|
package/src/executor/git.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
8
8
|
import {
|
|
9
|
-
gitEnvironment, gitExecutable, gitPointers, hardeningArgs, isNetworkOrDevicePath,
|
|
10
|
-
workRootGuards,
|
|
9
|
+
gitEnvironment, gitExecutable, gitPointers, hardeningArgs, isNetworkOrDevicePath, repositoryDriverArgs,
|
|
10
|
+
spawnBounded, stripUrlUserinfo, workRootGuards,
|
|
11
11
|
} from "../router/git-tools";
|
|
12
12
|
import {
|
|
13
13
|
ExecutorError, GIT_ID_PATTERN, PLAN_ID_PATTERN, WIP_TRAILER,
|
|
@@ -119,7 +119,7 @@ export interface GitContext {
|
|
|
119
119
|
* `hardeningArgs()` (git-tools) then, in this order (a later `-c` wins over the NUL hooksPath it sets):
|
|
120
120
|
* core.longpaths, core.hooksPath, core.excludesFile, core.editor, sequence.editor, the signing switches, the
|
|
121
121
|
* rebase/merge switches, rerere, submodule.recurse, advice.detachedHead, user.useConfigOnly, then core.autocrlf and
|
|
122
|
-
* core.eol when the snapshot has them.
|
|
122
|
+
* core.eol when the snapshot has them. The repository-only driver blanking is the runner's ({@link withRepositoryDrivers}).
|
|
123
123
|
*/
|
|
124
124
|
export function executorGitArgs(c: GitContext): string[] {
|
|
125
125
|
const args = [
|
|
@@ -137,6 +137,65 @@ export function executorGitArgs(c: GitContext): string[] {
|
|
|
137
137
|
return args;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/** Bound of one driver listing (its include reads included) before an executor git call. */
|
|
141
|
+
const DRIVER_LISTING_TIMEOUT_MS = 15_000;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Where an executor git call runs: `cwd` after a leading `-C <dir>`, and the `--git-dir=`/`--work-tree=` options it passes
|
|
145
|
+
* (in-slot calls), read from the global options before the subcommand. A bare `--git-dir`/`--work-tree` (the value as the
|
|
146
|
+
* next argument) throws `E_GIT`: only the `=` form is located.
|
|
147
|
+
*/
|
|
148
|
+
export function gitCallLocation(args: readonly string[], cwd: string): { cwd: string; location: string[] } {
|
|
149
|
+
let at = cwd;
|
|
150
|
+
const location: string[] = [];
|
|
151
|
+
for (let index = 0; index < args.length; index++) {
|
|
152
|
+
const arg = args[index] ?? "";
|
|
153
|
+
if (arg === "-c") { index++; continue; }
|
|
154
|
+
if (arg === "-C") { at = resolve(at, args[++index] ?? ""); continue; }
|
|
155
|
+
if (arg.startsWith("--git-dir=") || arg.startsWith("--work-tree=")) { location.push(arg); continue; }
|
|
156
|
+
// The separate-value form would be skipped as a flag and its value read as the subcommand: the listing would run elsewhere.
|
|
157
|
+
if (arg === "--git-dir" || arg === "--work-tree") {
|
|
158
|
+
throw new ExecutorError("E_GIT", `git ${arg} must carry its value after '=' (${arg}=<path>)`, { op: "config", code: null, stderr: "" });
|
|
159
|
+
}
|
|
160
|
+
if (arg.startsWith("-")) continue; // another global option (--no-pager, --no-optional-locks, --literal-pathspecs)
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
return { cwd: at, location };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A hardened `GitRunner` (`createGitRunner({ mode: "hardened" })`, possibly with a hardening prefix) whose every call first
|
|
168
|
+
* blanks the filter/merge drivers only the repository's own configuration names and sets its own `protocol.<name>.allow` to
|
|
169
|
+
* `never` (git-tools `repositoryDriverArgs`, include targets of any condition included), placed before the call's own
|
|
170
|
+
* arguments. The configuration is read again for every call (one `git config` process, plus one per include target): a
|
|
171
|
+
* driver added or changed mid-plan (a hook-less `git config` in a slot, a checkout that switches an `onbranch:` include) is
|
|
172
|
+
* never missed, and it costs far less than the call it protects. The listing runs where the call runs (its `-C`, `--git-dir`,
|
|
173
|
+
* `--work-tree`) in the call's own environment with the user's system/global configuration visible, so a global LFS filter
|
|
174
|
+
* and its `git lfs install --local` copy are kept. `filter.<name>.required=true`: a blanked filter makes git refuse
|
|
175
|
+
* (commit, cherry-pick, checkout, reset, clean) instead of writing unfiltered content. A configuration that cannot be read
|
|
176
|
+
* is `E_GIT`, and the call does not run.
|
|
177
|
+
*/
|
|
178
|
+
export function withRepositoryDrivers(inner: GitRunner, toplevel: string): GitRunner {
|
|
179
|
+
let executable: string | undefined;
|
|
180
|
+
return {
|
|
181
|
+
async run(args: readonly string[], p: ProcOpts): Promise<ProcessResult> {
|
|
182
|
+
const { cwd, location } = gitCallLocation(args, p.cwd);
|
|
183
|
+
let drivers: string[];
|
|
184
|
+
try {
|
|
185
|
+
executable ??= gitExecutable(workRootGuards(toplevel));
|
|
186
|
+
drivers = await repositoryDriverArgs(cwd, {
|
|
187
|
+
executable, env: hardenedEnvironment(p.env), required: true, location,
|
|
188
|
+
timeoutMs: Math.min(p.timeoutMs, DRIVER_LISTING_TIMEOUT_MS), ...(p.signal === undefined ? {} : { signal: p.signal }),
|
|
189
|
+
});
|
|
190
|
+
} catch (error) {
|
|
191
|
+
throw new ExecutorError("E_GIT", `git driver configuration could not be read: ${stripUrlUserinfo(errorText(error)).slice(0, 300)}`,
|
|
192
|
+
{ op: "config", code: null, stderr: "" });
|
|
193
|
+
}
|
|
194
|
+
return inner.run([...drivers, ...args], p);
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
140
199
|
/** Fixed content of `slot-excludes` (DV5): ignore rules never affect tracked files. */
|
|
141
200
|
export const SLOT_EXCLUDES_CONTENT = [
|
|
142
201
|
"node_modules/", "/.venv/", "/.yarn/cache/", "/.yarn/unplugged/", "/.yarn/install-state.gz", "/.pnp.*", "*.egg-info/",
|
|
@@ -173,11 +232,39 @@ function splitNul(text: string): string[] {
|
|
|
173
232
|
return text.split("\0").filter(part => part !== "");
|
|
174
233
|
}
|
|
175
234
|
|
|
235
|
+
/** Sanitize before clipping, so a clipped credential cannot lose the marker identifying it. */
|
|
236
|
+
export function sanitizeGitDiagnostic(text: string): string {
|
|
237
|
+
let clean = stripUrlUserinfo(text)
|
|
238
|
+
.replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[redacted key]")
|
|
239
|
+
.replace(/\b(Bearer|Basic)\s+\S+/gi, "$1 ***")
|
|
240
|
+
.replace(/\b([\w.-]{0,64}(?:token|password|passwd|secret|api[_-]?key|credential)[\w.-]{0,64}\s{0,64}[=:]\s{0,64})(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s,;]+)/gi, "$1***");
|
|
241
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
242
|
+
if (value !== undefined && value.length >= 4 && /token|password|passwd|secret|api[_-]?key|credential/i.test(key)) clean = clean.split(value).join("***");
|
|
243
|
+
}
|
|
244
|
+
return clean.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function gitStderrTail(text: string): string {
|
|
248
|
+
return sanitizeGitDiagnostic(text).slice(-500);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const IDENTITY_FAILURE = /please tell me who you are|unable to auto-detect|empty ident|(?:author|committer) identity unknown|no email was given/i;
|
|
252
|
+
const IDENTITY_HINT = "git has no commit identity in the executor's environment (global config is not read by hardened git): " +
|
|
253
|
+
"set user.name/user.email in the repository, or configure them in your user/global config for the executor's identity resolver. The executor never invents one.";
|
|
254
|
+
|
|
176
255
|
function gitFailure(op: string, r: ProcessResult): ExecutorError {
|
|
177
256
|
const stderr = tailBytes(stripUrlUserinfo(r.stderr), GIT_STDERR_TAIL_BYTES);
|
|
178
257
|
return new ExecutorError("E_GIT", `git ${op} failed (exit ${r.code ?? r.signal ?? "unknown"})`, { op, code: r.code, stderr });
|
|
179
258
|
}
|
|
180
259
|
|
|
260
|
+
export function gitCommitFailure(op: string, r: ProcessResult): ExecutorError {
|
|
261
|
+
const stderr = gitStderrTail(r.stderr);
|
|
262
|
+
const identity = IDENTITY_FAILURE.test(r.stderr);
|
|
263
|
+
return new ExecutorError(identity ? "E_IDENTITY" : "E_GIT",
|
|
264
|
+
`git ${op} failed (exit ${r.code ?? r.signal ?? "unknown"})${identity ? `; ${IDENTITY_HINT}` : ""}${stderr === "" ? "" : `; stderr: ${stderr}`}`,
|
|
265
|
+
{ op, code: r.code, stderr });
|
|
266
|
+
}
|
|
267
|
+
|
|
181
268
|
function requireCommit(value: string, what: string): string {
|
|
182
269
|
if (!GIT_ID_PATTERN.test(value)) throw invalid(`${what} is not a full git object id`, { value: value.slice(0, 80) });
|
|
183
270
|
return value;
|
|
@@ -189,6 +276,30 @@ function requireCommit(value: string, what: string): string {
|
|
|
189
276
|
|
|
190
277
|
export interface CommitIdentity { name: string; email: string }
|
|
191
278
|
|
|
279
|
+
/** The same explicit identity injection used by GitOps.commit and the runtime's two commit paths. */
|
|
280
|
+
function commitIdentityArgs(identity: CommitIdentity): string[] {
|
|
281
|
+
return ["-c", `user.name=${identity.name}`, "-c", `user.email=${identity.email}`];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export type ResolveCommitIdentity = () => Promise<CommitIdentity>;
|
|
285
|
+
|
|
286
|
+
export async function slotCommitIdentityArgs(
|
|
287
|
+
git: GitRunner, o: { cwd: string; timeoutMs: number }, identity: ResolveCommitIdentity | undefined,
|
|
288
|
+
): Promise<string[]> {
|
|
289
|
+
if (identity === undefined) return []; // Injected test runners may already supply their own identity.
|
|
290
|
+
try {
|
|
291
|
+
return commitIdentityArgs(await identity());
|
|
292
|
+
} catch (error) {
|
|
293
|
+
if (!(error instanceof ExecutorError) || error.code !== "E_IDENTITY") throw error;
|
|
294
|
+
// Read-only probe: retain git's actual exit/stderr without attempting a commit with a guessed identity.
|
|
295
|
+
const r = await git.run(["-c", "user.useConfigOnly=true", "var", "GIT_COMMITTER_IDENT"], o);
|
|
296
|
+
const stderr = gitStderrTail(r.stderr);
|
|
297
|
+
const resolverMessage = sanitizeGitDiagnostic(error.message).slice(0, 1200);
|
|
298
|
+
throw new ExecutorError("E_IDENTITY", `${resolverMessage}; ${IDENTITY_HINT} (git identity probe exit ${r.code ?? "unknown"})${stderr === "" ? "" : `; stderr: ${stderr}`}`,
|
|
299
|
+
{ op: "identity", code: r.code, stderr, resolverMessage });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
192
303
|
const identityCache = new WeakMap<GitRunner, Map<string, Promise<CommitIdentity & { conversion: GitContext["conversion"] }>>>();
|
|
193
304
|
|
|
194
305
|
async function readConfig(userGit: GitRunner, toplevel: string, key: string): Promise<string | null> {
|
|
@@ -380,7 +491,7 @@ async function slotRun(git: GitRunner, o: SlotCall, op: string, args: readonly s
|
|
|
380
491
|
return await git.run(args, { cwd: o.cwd, timeoutMs: o.timeoutMs, maxOutputBytes: GIT_MAX_OUTPUT_BYTES });
|
|
381
492
|
} catch (error) {
|
|
382
493
|
if (error instanceof ExecutorError) throw error;
|
|
383
|
-
throw new ExecutorError("E_GIT", `git ${op} could not run: ${
|
|
494
|
+
throw new ExecutorError("E_GIT", `git ${op} could not run: ${gitStderrTail(errorText(error))}`,
|
|
384
495
|
{ op, code: errorCode(error) ?? null, stderr: "" });
|
|
385
496
|
}
|
|
386
497
|
}
|
|
@@ -417,7 +528,7 @@ export async function snapshotSlotWork(
|
|
|
417
528
|
git: GitRunner,
|
|
418
529
|
i: {
|
|
419
530
|
cwd: string; ref: string; message: string; trailer: string; timeoutMs: number;
|
|
420
|
-
base?: string; fallbackRef?: string; removeIndexLock?: () => Promise<boolean>;
|
|
531
|
+
base?: string; fallbackRef?: string; removeIndexLock?: () => Promise<boolean>; identity?: ResolveCommitIdentity;
|
|
421
532
|
},
|
|
422
533
|
): Promise<WipSnapshot> {
|
|
423
534
|
const o: SlotCall = { cwd: i.cwd, timeoutMs: i.timeoutMs };
|
|
@@ -428,7 +539,7 @@ export async function snapshotSlotWork(
|
|
|
428
539
|
lockRemoved = true;
|
|
429
540
|
if (await i.removeIndexLock()) r = await slotRun(git, o, op, args);
|
|
430
541
|
}
|
|
431
|
-
if (r.code !== 0) throw
|
|
542
|
+
if (r.code !== 0) throw gitCommitFailure(op, r);
|
|
432
543
|
return r.stdout;
|
|
433
544
|
};
|
|
434
545
|
const status = await must("status", ["status", "--porcelain", "--untracked-files=all"]);
|
|
@@ -464,7 +575,8 @@ export async function snapshotSlotWork(
|
|
|
464
575
|
}
|
|
465
576
|
}
|
|
466
577
|
const files = splitNul(await must("diff", ["diff", "--cached", "--name-only", "-z", "--no-renames", parent])).length;
|
|
467
|
-
const
|
|
578
|
+
const identity = await slotCommitIdentityArgs(git, o, i.identity);
|
|
579
|
+
const commit = (await must("commit-tree", [...identity, "commit-tree", "--no-gpg-sign", tree, "-p", parent, "-m", i.message, "-m", i.trailer])).trim();
|
|
468
580
|
requireCommit(commit, "WIP commit");
|
|
469
581
|
const zero = "0".repeat(commit.length);
|
|
470
582
|
const update = ["update-ref", "--no-deref", `refs/heads/${i.ref}`, commit, old ?? zero];
|
|
@@ -482,7 +594,7 @@ export async function snapshotSlotWork(
|
|
|
482
594
|
}
|
|
483
595
|
}
|
|
484
596
|
throw new ExecutorError("E_GIT", `git update-ref failed twice; WIP commit ${commit} ${keptAt === null ? "has no ref" : `kept at ${keptAt}`}`, {
|
|
485
|
-
op: "update-ref", code: r.code, stderr:
|
|
597
|
+
op: "update-ref", code: r.code, stderr: gitStderrTail(r.stderr), commit, keptAt,
|
|
486
598
|
});
|
|
487
599
|
}
|
|
488
600
|
}
|
|
@@ -706,7 +818,7 @@ export function createGitOps(d: GitOpsDeps): GitOps {
|
|
|
706
818
|
}
|
|
707
819
|
|
|
708
820
|
function identityArgs(x: OpsContext, wanted: boolean | undefined): string[] {
|
|
709
|
-
return wanted === true ?
|
|
821
|
+
return wanted === true ? commitIdentityArgs(x.identity) : [];
|
|
710
822
|
}
|
|
711
823
|
|
|
712
824
|
/** The hooks directory is re-checked before every call: an op can run a hook only from a non-empty directory. */
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// (`repo.toplevel`): every probe runs with `-C <toplevel>`, never against another worktree of the same repository.
|
|
4
4
|
// Never forces and never creates a non-fast-forward.
|
|
5
5
|
|
|
6
|
+
import { lstat } from "node:fs/promises";
|
|
7
|
+
import { join } from "node:path";
|
|
6
8
|
import { hardeningArgs } from "../../router/git-tools";
|
|
7
9
|
import { phaseTagName as gitPhaseTagName } from "../git";
|
|
8
10
|
import type { GitOps } from "../git";
|
|
@@ -22,6 +24,8 @@ export interface LanderDeps {
|
|
|
22
24
|
/** Hardened runner for the read-only owner-checkout probes (toplevel, HEAD, status); each call uses `-C <toplevel>`. */
|
|
23
25
|
run: GitRunner;
|
|
24
26
|
realpath: (p: string) => Promise<string>; platform: NodeJS.Platform;
|
|
27
|
+
/** Whether a path exists (a populated submodule's `.git`). Default: `lstat` succeeds. */
|
|
28
|
+
exists?: (p: string) => Promise<boolean>;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
export interface LanderApi {
|
|
@@ -61,12 +65,33 @@ function parseStatusPaths(stdout: string): string[] {
|
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
export function createLander(d: LanderDeps): LanderApi {
|
|
68
|
+
const exists = d.exists ?? (async (p: string) => lstat(p).then(() => true, () => false));
|
|
69
|
+
|
|
64
70
|
async function probe(toplevel: string, args: readonly string[]): Promise<{ code: number | null; stdout: string }> {
|
|
65
|
-
// hardeningArgs() neutralises configured hooks/fsmonitor/pagers: `status` must not run a repo-configured program.
|
|
71
|
+
// hardeningArgs() neutralises configured hooks/fsmonitor/pagers: `status` must not run a repo-configured program. The
|
|
72
|
+
// production runner (executor/git.ts withRepositoryDrivers) also blanks the repository-only filter/merge drivers.
|
|
66
73
|
const r = await d.run.run(["-C", toplevel, "--no-optional-locks", ...hardeningArgs(), ...args], { cwd: toplevel, timeoutMs: READ_TIMEOUT_MS });
|
|
67
74
|
return { code: r.code, stdout: r.stdout };
|
|
68
75
|
}
|
|
69
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The populated submodules of the owner checkout (gitlinks whose directory holds a `.git`). `status --ignore-submodules=none`
|
|
79
|
+
* runs `git status` inside each with that submodule's own configuration, whose filter/merge drivers the superproject's
|
|
80
|
+
* listing never sees, so the cleanliness check refuses to run there (an unpopulated gitlink runs nothing).
|
|
81
|
+
*/
|
|
82
|
+
async function populatedSubmodules(toplevel: string): Promise<string[]> {
|
|
83
|
+
const listed = await probe(toplevel, ["ls-files", "--stage", "-z"]);
|
|
84
|
+
if (listed.code !== 0) throw new Error(`git ls-files failed in the owner checkout (exit ${listed.code ?? "unknown"})`);
|
|
85
|
+
const populated: string[] = [];
|
|
86
|
+
for (const record of listed.stdout.split("\0")) {
|
|
87
|
+
const tab = record.indexOf("\t");
|
|
88
|
+
if (!record.startsWith("160000 ") || tab === -1) continue;
|
|
89
|
+
const path = record.slice(tab + 1);
|
|
90
|
+
if (await exists(join(toplevel, path, ".git"))) populated.push(path);
|
|
91
|
+
}
|
|
92
|
+
return populated;
|
|
93
|
+
}
|
|
94
|
+
|
|
70
95
|
async function inspect(req: LandRequest): Promise<LandInspection> {
|
|
71
96
|
const { toplevel, baseBranch, candidate } = req;
|
|
72
97
|
|
|
@@ -97,7 +122,12 @@ export function createLander(d: LanderDeps): LanderApi {
|
|
|
97
122
|
return { ok: false, refusal: { reason: "not-checked-out", head: headRef === "" ? null : headRef }, baseTip };
|
|
98
123
|
}
|
|
99
124
|
|
|
100
|
-
// 3. The owner checkout is clean.
|
|
125
|
+
// 3. The owner checkout is clean. A populated submodule fails closed first (see populatedSubmodules).
|
|
126
|
+
const submodules = await populatedSubmodules(toplevel);
|
|
127
|
+
if (submodules.length > 0) {
|
|
128
|
+
throw new Error(`the owner checkout has populated submodules (${submodules.slice(0, 5).join(", ")}): the executor does not run git `
|
|
129
|
+
+ "inside them with their own configuration; land manually");
|
|
130
|
+
}
|
|
101
131
|
const status = await probe(toplevel, ["status", "--porcelain=v1", "-z", "--untracked-files=all", "--ignore-submodules=none"]);
|
|
102
132
|
if (status.code !== 0) throw new Error(`git status failed in the owner checkout (exit ${status.code ?? "unknown"})`);
|
|
103
133
|
const dirty = parseStatusPaths(status.stdout);
|
package/src/executor/runtime.ts
CHANGED
|
@@ -16,16 +16,21 @@ import { gitPointers } from "../router/git-tools";
|
|
|
16
16
|
import { expandTask, loadExpansionEnv, type ExpandedTask } from "./expand";
|
|
17
17
|
import {
|
|
18
18
|
deleteSlotRef,
|
|
19
|
+
gitCommitFailure,
|
|
20
|
+
gitStderrTail,
|
|
19
21
|
listSlotRefs,
|
|
20
22
|
orphanRefName,
|
|
21
23
|
phaseTagName,
|
|
22
24
|
planRefPrefix,
|
|
23
25
|
restoreSlotWork,
|
|
26
|
+
sanitizeGitDiagnostic,
|
|
24
27
|
snapshotSlotWork,
|
|
28
|
+
slotCommitIdentityArgs,
|
|
25
29
|
taskBranchName,
|
|
26
30
|
wipRefName,
|
|
27
31
|
wipTrailer,
|
|
28
32
|
type WipRestore,
|
|
33
|
+
type ResolveCommitIdentity,
|
|
29
34
|
} from "./git";
|
|
30
35
|
import { dependentPhases } from "./integrate/queue";
|
|
31
36
|
import type { PlanRoleBindings } from "./launch";
|
|
@@ -323,7 +328,14 @@ function errorCode(e: unknown): string | null {
|
|
|
323
328
|
return null;
|
|
324
329
|
}
|
|
325
330
|
|
|
326
|
-
|
|
331
|
+
/** Git errors keep stderr in details; carry a safe summary through logs, contexts and blocking items. */
|
|
332
|
+
function gitDiagnostic(e: unknown): { message: string; gitExitCode: string; stderr: string } {
|
|
333
|
+
const detail = e instanceof ExecutorError && typeof e.detail === "object" && e.detail !== null && !Array.isArray(e.detail) ? e.detail : {};
|
|
334
|
+
const gitExitCode = typeof detail.code === "number" ? String(detail.code) : "unknown";
|
|
335
|
+
const stderr = gitStderrTail(typeof detail.stderr === "string" ? detail.stderr : "");
|
|
336
|
+
const message = sanitizeGitDiagnostic(errorText(e)).slice(0, 1200);
|
|
337
|
+
return { message: `${message}${gitExitCode === "unknown" || message.includes("exit ") ? "" : ` (git exit ${gitExitCode})`}${stderr === "" || message.includes(stderr) ? "" : `; stderr: ${stderr}`}`, gitExitCode, stderr };
|
|
338
|
+
}
|
|
327
339
|
|
|
328
340
|
/** A git step that failed on a leftover `index.lock` (a git killed mid-commit, D11). */
|
|
329
341
|
const INDEX_LOCK_PATTERN = /index\.lock/i;
|
|
@@ -360,7 +372,7 @@ async function removeIndexLock(git: GitRunner, o: { cwd: string; timeoutMs: numb
|
|
|
360
372
|
*/
|
|
361
373
|
export async function commitTaskInSlot(
|
|
362
374
|
git: GitRunner,
|
|
363
|
-
i: { slot: SlotLease; branch: string; message: string; timeoutMs: number; trailer?: string },
|
|
375
|
+
i: { slot: SlotLease; branch: string; message: string; timeoutMs: number; trailer?: string; identity?: ResolveCommitIdentity },
|
|
364
376
|
): Promise<{ changed: false } | { changed: true; commit: string }> {
|
|
365
377
|
const o = { cwd: i.slot.path, timeoutMs: i.timeoutMs };
|
|
366
378
|
let lockRemoved = false;
|
|
@@ -371,12 +383,7 @@ export async function commitTaskInSlot(
|
|
|
371
383
|
if (await removeIndexLock(git, o)) r = await git.run(args, o);
|
|
372
384
|
}
|
|
373
385
|
if (r.code !== 0) {
|
|
374
|
-
|
|
375
|
-
throw new ExecutorError(IDENTITY_PATTERN.test(text) ? "E_IDENTITY" : "E_GIT", `git ${args[0] ?? ""} failed`, {
|
|
376
|
-
args: [...args],
|
|
377
|
-
code: r.code,
|
|
378
|
-
stderr: r.stderr.slice(0, 2000),
|
|
379
|
-
});
|
|
386
|
+
throw gitCommitFailure(args.includes("commit") ? "commit" : args[0] ?? "", r);
|
|
380
387
|
}
|
|
381
388
|
return r.stdout;
|
|
382
389
|
};
|
|
@@ -393,7 +400,8 @@ export async function commitTaskInSlot(
|
|
|
393
400
|
}
|
|
394
401
|
await step(["switch", "-C", i.branch]);
|
|
395
402
|
await step(["add", "-A"]);
|
|
396
|
-
|
|
403
|
+
const identity = await slotCommitIdentityArgs(git, o, i.identity);
|
|
404
|
+
await step([...identity, "commit", "--no-verify", "--no-gpg-sign", "-m", i.message, ...(i.trailer === undefined ? [] : ["-m", i.trailer])]);
|
|
397
405
|
const head = (await step(["rev-parse", "HEAD"])).trim();
|
|
398
406
|
return { changed: true, commit: head };
|
|
399
407
|
}
|
|
@@ -458,6 +466,8 @@ export interface RuntimeDeps {
|
|
|
458
466
|
* directory and removes the plan's empty slots directory). Without it, purge runs `slotsFor(planId).gc`.
|
|
459
467
|
*/
|
|
460
468
|
purgeSlots?(planId: PlanId, finished: Parameters<SlotPool["gc"]>[0]): ReturnType<SlotPool["gc"]>;
|
|
469
|
+
/** Drop a closed pool entry only after a new plan with this id has been created. */
|
|
470
|
+
forgetSlots?(planId: PlanId): void;
|
|
461
471
|
/** Revalidate the fixed slots directory before approval has any side effects. */
|
|
462
472
|
/** Approve-time validation of the resolved slots root; `planId` names the plan being approved (its ledger, its base). */
|
|
463
473
|
checkSlotsDir?(slotsDir: string, toplevel: string, planId: PlanId): void | Promise<void>;
|
|
@@ -466,6 +476,8 @@ export interface RuntimeDeps {
|
|
|
466
476
|
routes: RouteResolver;
|
|
467
477
|
verifier: PlanTaskVerifier;
|
|
468
478
|
git: GitRunner;
|
|
479
|
+
/** User-mode config read, validated and cached by readCommitIdentity; never enables global config for writes. */
|
|
480
|
+
commitIdentity?: ResolveCommitIdentity;
|
|
469
481
|
hosts: HostSessions;
|
|
470
482
|
clock: Clock;
|
|
471
483
|
leaseRegistry: LeaseRegistryPort;
|
|
@@ -1517,6 +1529,7 @@ export function createExecutorRuntime(d: RuntimeDeps): ExecutorRuntimeHandle {
|
|
|
1517
1529
|
const wipRestored = new Map<string, number>();
|
|
1518
1530
|
/** QA-PDF21-3: `<plan>/<slot>` of the slots whose failed save raised its blocking item already (cleared by a save). */
|
|
1519
1531
|
const wipFailRaised = new Set<string>();
|
|
1532
|
+
const wipFailures = new Map<string, string>();
|
|
1520
1533
|
|
|
1521
1534
|
/** The quarantine directory is durable even if the process dies between the rename and journaling its item. */
|
|
1522
1535
|
function quarantinedSlots(p: PlanRt): string[] {
|
|
@@ -1585,13 +1598,18 @@ export function createExecutorRuntime(d: RuntimeDeps): ExecutorRuntimeHandle {
|
|
|
1585
1598
|
...(slot.base === undefined || slot.base === null ? {} : { base: slot.base }),
|
|
1586
1599
|
fallbackRef: orphanRefName(p.planId, slot.slot, d.clock.now(), orphanTag()),
|
|
1587
1600
|
removeIndexLock: () => removeIndexLock(d.git, o),
|
|
1601
|
+
...(d.commitIdentity === undefined ? {} : { identity: d.commitIdentity }),
|
|
1588
1602
|
});
|
|
1589
1603
|
wipFailRaised.delete(`${p.planId}/${slot.slot}`);
|
|
1604
|
+
wipFailures.delete(`${p.planId}/${slot.slot}`);
|
|
1590
1605
|
if (r.saved) counter(p, "wip-saved", taskId === null ? { slot: slot.slot, ref } : { taskId, slot: slot.slot, ref }, deferredMetrics);
|
|
1591
1606
|
return r.saved || r.reason === "unchanged" ? "saved" : "clean";
|
|
1592
1607
|
} catch (e) {
|
|
1593
|
-
|
|
1594
|
-
|
|
1608
|
+
const diagnostic = gitDiagnostic(e);
|
|
1609
|
+
wipFailures.set(`${p.planId}/${slot.slot}`, diagnostic.message);
|
|
1610
|
+
d.log("error", `saving the work in slot ${slot.slot} failed; the slot is kept as it is`, diagnostic);
|
|
1611
|
+
counter(p, "wip-failed", { ...(taskId === null ? {} : { taskId }), slot: slot.slot,
|
|
1612
|
+
gitExitCode: diagnostic.gitExitCode, stderr: diagnostic.stderr }, deferredMetrics);
|
|
1595
1613
|
return "failed";
|
|
1596
1614
|
}
|
|
1597
1615
|
}
|
|
@@ -1674,7 +1692,7 @@ export function createExecutorRuntime(d: RuntimeDeps): ExecutorRuntimeHandle {
|
|
|
1674
1692
|
kind: "failure",
|
|
1675
1693
|
severity: "blocking",
|
|
1676
1694
|
taskId,
|
|
1677
|
-
text: wipHoldText(slotName, what, taskId),
|
|
1695
|
+
text: wipHoldText(p, slotName, what, taskId),
|
|
1678
1696
|
options: [],
|
|
1679
1697
|
});
|
|
1680
1698
|
return item.id;
|
|
@@ -1795,8 +1813,9 @@ export function createExecutorRuntime(d: RuntimeDeps): ExecutorRuntimeHandle {
|
|
|
1795
1813
|
}
|
|
1796
1814
|
|
|
1797
1815
|
/** The text of `wipHold`'s item; `answer` reads the slot back from it (`wipHoldSlotOf`, QA-PDF21-15). */
|
|
1798
|
-
function wipHoldText(slotName: string, what: string, taskId: TaskId | null): string {
|
|
1799
|
-
|
|
1816
|
+
function wipHoldText(p: PlanRt, slotName: string, what: string, taskId: TaskId | null): string {
|
|
1817
|
+
const diagnostic = wipFailures.get(`${p.planId}/${slotName}`);
|
|
1818
|
+
return `${WIP_HOLD_PREFIX}${slotName} could not be saved before ${what}; the slot keeps its work and stays leased${taskId === null ? "" : ` to ${taskId}`} (see the log).${diagnostic === undefined ? "" : ` ${diagnostic}`} Fix the slot's git state, then answer`;
|
|
1800
1819
|
}
|
|
1801
1820
|
|
|
1802
1821
|
/**
|
|
@@ -3259,7 +3278,7 @@ export function createExecutorRuntime(d: RuntimeDeps): ExecutorRuntimeHandle {
|
|
|
3259
3278
|
// `parkItemOf` picks that item on the answer), its pending dependents are blocked and its file leases are kept with
|
|
3260
3279
|
// the slot (as the policy's park keeps them for a kept slot, and `rebuildLeases` rebuilds them after a restart).
|
|
3261
3280
|
const holdWhat = "its release (lease-needed)";
|
|
3262
|
-
const holdText = saved === "failed" && slotName !== null ? wipHoldText(slotName, holdWhat, t.id) : null;
|
|
3281
|
+
const holdText = saved === "failed" && slotName !== null ? wipHoldText(p, slotName, holdWhat, t.id) : null;
|
|
3263
3282
|
const applied = await appendIf(p, (cur) => {
|
|
3264
3283
|
const c = own(cur, t.id);
|
|
3265
3284
|
if (c === null || c.state !== "running" || openAttempt(c, a.n) === null) return [];
|
|
@@ -3330,22 +3349,31 @@ export function createExecutorRuntime(d: RuntimeDeps): ExecutorRuntimeHandle {
|
|
|
3330
3349
|
let lease: SlotLease;
|
|
3331
3350
|
let r: { changed: false } | { changed: true; commit: string };
|
|
3332
3351
|
const branch = taskBranchName(p.planId, taskId);
|
|
3352
|
+
const att = t.attempts.find((x) => x.n === n);
|
|
3333
3353
|
try {
|
|
3334
3354
|
lease = await slotLeaseOf(p, t);
|
|
3335
3355
|
// D11: the attempt's trailer makes the commit idempotent across a crash between the commit and row 21.
|
|
3336
|
-
const att = t.attempts.find((x) => x.n === n);
|
|
3337
3356
|
if (att !== undefined && d.verifier.observe !== undefined) await d.verifier.observe(t, lease, att, await finalTextOf(p, taskId, att), planTaskContext(p));
|
|
3357
|
+
} catch (e) {
|
|
3358
|
+
if (p.disposed) return;
|
|
3359
|
+
await commitFailed(errorText(e));
|
|
3360
|
+
return;
|
|
3361
|
+
}
|
|
3362
|
+
try {
|
|
3338
3363
|
if (p.disposed) return;
|
|
3339
3364
|
r = await commitTaskInSlot(d.git, {
|
|
3340
3365
|
slot: lease,
|
|
3341
3366
|
branch,
|
|
3342
3367
|
message: `${taskId}: ${t.title} (attempt ${n})`,
|
|
3343
3368
|
timeoutMs: GIT_TIMEOUT_MS,
|
|
3369
|
+
...(d.commitIdentity === undefined ? {} : { identity: d.commitIdentity }),
|
|
3344
3370
|
...(att === undefined ? {} : { trailer: attemptTrailer(p.planId, taskId, n, att.nonce) }),
|
|
3345
3371
|
});
|
|
3346
3372
|
} catch (e) {
|
|
3347
3373
|
if (p.disposed) return;
|
|
3348
|
-
|
|
3374
|
+
const diagnostic = gitDiagnostic(e);
|
|
3375
|
+
d.log("warn", `task ${taskId} git commit failed`, diagnostic);
|
|
3376
|
+
await commitFailed(diagnostic.message);
|
|
3349
3377
|
return;
|
|
3350
3378
|
}
|
|
3351
3379
|
if (p.disposed) return;
|
|
@@ -5454,6 +5482,13 @@ export function createExecutorRuntime(d: RuntimeDeps): ExecutorRuntimeHandle {
|
|
|
5454
5482
|
});
|
|
5455
5483
|
if (isForeign(r.draft.repo.toplevel)) throw new ExecutorError("E_INVALID_INPUT", "the plan belongs to another repository");
|
|
5456
5484
|
const writer = await d.store.create(r.draft, d.holder(i.sessionID));
|
|
5485
|
+
const planId = r.draft.planId;
|
|
5486
|
+
d.forgetSlots?.(planId);
|
|
5487
|
+
collected.delete(planId);
|
|
5488
|
+
const timer = collectionTimers.get(planId);
|
|
5489
|
+
if (timer !== undefined) d.clock.clearTimer(timer);
|
|
5490
|
+
collectionTimers.delete(planId);
|
|
5491
|
+
collectionDelays.delete(planId);
|
|
5457
5492
|
await attach(writer, false);
|
|
5458
5493
|
return { planId: r.draft.planId, summary: r.summary, residuePrompt: r.residueRequest?.prompt ?? null };
|
|
5459
5494
|
},
|