@bridge_gpt/mcp-server 0.2.69 → 0.2.71
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 +140 -292
- package/build/agent-launchers/claude-executor-adapter.js +27 -5
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +15 -5
- package/build/artifact-diff.js +110 -0
- package/build/bin-entrypoint.js +36 -0
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +36 -9
- package/build/claude-review-workflow-drift.js +3 -3
- package/build/codex-bridge-profile.js +1 -1
- package/build/commands.generated.js +6 -6
- package/build/conductor/bridge-api-client.js +858 -21
- package/build/conductor/bring-up-facts.js +9 -9
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +472 -18
- package/build/conductor/epic-child-continuation.js +54 -3
- package/build/conductor/epic-implementer-cli.js +136 -34
- package/build/conductor/epic-runtime.js +2 -2
- package/build/conductor/epic-state.js +1 -1
- package/build/conductor/gate-discovery.js +524 -10
- package/build/conductor/gate-settings-review.js +451 -0
- package/build/conductor/hook-runtime-qualification.js +1 -1
- package/build/conductor/install-doctor.js +4 -2
- package/build/conductor/launch-need-probes.js +342 -0
- package/build/conductor/launch-plan.js +145 -0
- package/build/conductor/local-merge.js +241 -56
- package/build/conductor/merge-credential.js +172 -0
- package/build/conductor/merge-execution-eligibility.js +1 -1
- package/build/conductor/merged-child-check.js +95 -0
- package/build/conductor/plan-trim.js +30 -0
- package/build/conductor/pr-ci-producer.js +1 -1
- package/build/conductor/precheck-timings.js +14 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-cli.js +11 -6
- package/build/conductor/readiness-prerequisites.js +41 -0
- package/build/conductor/readiness-sections.js +348 -55
- package/build/conductor/readiness.js +99 -87
- package/build/conductor/recovery-cli.js +665 -23
- package/build/conductor/recovery-operations.js +350 -8
- package/build/conductor/repair-contract.js +47 -2
- package/build/conductor/repository-workflow-remedy.js +8 -6
- package/build/conductor/stored-merge-credential.js +76 -0
- package/build/conductor/stored-merge-token-probe.js +28 -0
- package/build/conductor/temporary-plan.js +50 -0
- package/build/conductor/wait-run-cli.js +759 -0
- package/build/conductor/worker-database-doctor-inspector.js +49 -0
- package/build/conductor-bin.js +2 -2
- package/build/conductor-claude-hook-bin.js +2 -2
- package/build/conductor-claude-hook-removed-stub-bin.js +2 -5
- package/build/conductor-removed-stub-bin.js +2 -5
- package/build/credential-store.js +356 -13
- package/build/docs.generated.js +26 -13
- package/build/doctor.js +94 -32
- package/build/drive-epic-help.js +212 -0
- package/build/drive-epic.js +1989 -379
- package/build/epic-ci-workflow-drift.js +125 -0
- package/build/epic-ci-workflow-install.js +240 -0
- package/build/epic-ci-workflow-v1.js +132 -0
- package/build/epic-ci-workflow.js +318 -0
- package/build/epic-contract-context.js +326 -0
- package/build/epic-implementer-bin.js +58 -42
- package/build/epic-implementer-claude-hook-bin.js +2 -2
- package/build/escalation-reachability.js +134 -0
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/cleanup-report.js +99 -0
- package/build/executor/cli.js +12 -1
- package/build/executor/completion-contract.js +66 -11
- package/build/executor/completion-supervision.js +99 -0
- package/build/executor/delivery-outcome.js +179 -0
- package/build/executor/deps.js +3 -0
- package/build/executor/env.js +276 -1
- package/build/executor/failure-reason-codes.js +126 -0
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/heartbeat.js +38 -0
- package/build/executor/http-client.js +72 -0
- package/build/executor/integration-job.js +298 -5
- package/build/executor/job-errors.js +36 -6
- package/build/executor/job-runner.js +830 -45
- package/build/executor/likely-tests.js +42 -3
- package/build/executor/merge-job.js +145 -2
- package/build/executor/observation.js +73 -4
- package/build/executor/permissions.js +193 -97
- package/build/executor/preflight.js +19 -3
- package/build/executor/process-containment.js +46 -2
- package/build/executor/prompt-spec.js +113 -9
- package/build/executor/rebase-finalization.js +38 -3
- package/build/executor/reconcile-overlap-job.js +41 -8
- package/build/executor/required-work-ledger.js +236 -81
- package/build/executor/resume-pre-spawn.js +38 -1
- package/build/executor/runner.js +91 -3
- package/build/executor/test-clock.js +8 -0
- package/build/executor/types.js +37 -2
- package/build/executor/worker-cli-launcher.js +259 -0
- package/build/executor/worker-command.js +177 -5
- package/build/executor/worker-database-target.js +91 -0
- package/build/executor/worker-database.js +927 -0
- package/build/executor/worker-finalization.js +106 -0
- package/build/executor/worker-guard-hook.js +203 -0
- package/build/executor/worker-resources.js +58 -0
- package/build/executor/worker-verification-guidance.js +44 -2
- package/build/executor/worktree.js +303 -15
- package/build/executor-launch.js +11 -1
- package/build/generated-assets-doctor.js +9 -1
- package/build/generated-assets-health.js +13 -4
- package/build/generated-assets-legacy.js +39 -0
- package/build/generated-assets-paths.js +12 -1
- package/build/generated-assets-repair.js +4 -1
- package/build/generated-assets-test-support.js +12 -0
- package/build/github-remote.js +33 -0
- package/build/github-sign-in.js +62 -0
- package/build/index.js +1133 -546
- package/build/init.js +39 -1
- package/build/install-bridge-conductor-gate.js +270 -11
- package/build/install-bridge-conductor-setup.js +427 -0
- package/build/install-bridge-conductor.js +1545 -268
- package/build/install-bridge.js +376 -60
- package/build/mcp-install-state.js +8 -2
- package/build/merge-pull-request.js +6 -0
- package/build/merge-workflow-install.js +782 -344
- package/build/phase-result-artifacts.js +75 -20
- package/build/pipeline-orchestrator.js +247 -4
- package/build/pipelines.generated.js +35 -35
- package/build/plan-discovery.js +15 -2
- package/build/plan-execution-ledger.js +321 -17
- package/build/plan-phase-routing.js +48 -13
- package/build/plane/cli.js +105 -51
- package/build/plane/defaults.js +3 -0
- package/build/plane/plane-freshness.js +298 -0
- package/build/plane/preflight.js +19 -0
- package/build/plane/schema-compatibility.js +137 -0
- package/build/plane/shutdown-deps.js +38 -0
- package/build/plane/shutdown.js +83 -8
- package/build/plane/terminal-run-cleanup.js +303 -0
- package/build/printed-remedy-commands.js +33 -4
- package/build/readiness-check.js +6 -2
- package/build/readiness-prerequisites.generated.js +532 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +581 -0
- package/build/setup-epic.js +421 -34
- package/build/shared-resources.generated.js +5 -0
- package/build/start-tickets.js +28 -15
- package/build/test-command-detection.js +284 -0
- package/build/test-command-validation.js +73 -0
- package/build/testing-config-client.js +150 -0
- package/build/ticket-delivery-artifacts.js +265 -0
- package/build/ticket-delivery-enrollment.js +369 -0
- package/build/ticket-delivery.js +205 -0
- package/build/ticket-review-summary.js +14 -0
- package/build/upgrade-cli.js +13 -0
- package/build/v2-readiness-requirements.js +552 -0
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-core.js +22 -7
- package/docs/BRIDGE-DIRECTORY-README.md +48 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +12 -867
- package/docs/EPIC-IMPLEMENTER.md +142 -63
- package/docs/epic-implementer/getting-started.md +187 -0
- package/docs/epic-implementer/self-hosting.md +133 -0
- package/package.json +4 -4
- package/pipelines/idea-to-ticket.json +1 -1
- package/pipelines/implement-ticket.json +8 -8
- package/pipelines/review-ticket.json +2 -2
- package/design-assets/favicon/favicon-32x32.png +0 -0
- package/design-assets/just-logo-rough-draft.png +0 -0
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
* (claude 2.1.201), so plain `permissions.deny` is provisioned; the PreToolUse
|
|
36
36
|
* fallback is available for CLIs where settings-deny is not enforced.
|
|
37
37
|
*/
|
|
38
|
+
import { randomUUID } from "node:crypto";
|
|
38
39
|
import path from "node:path";
|
|
39
40
|
import { mergeClaudeSettingsWithAutoMemoryDisabled, mergeClaudeSettingsWithCommandHook, provisionClaudeSettingsForWorktree, DEFAULT_PRE_TOOL_USE_MATCHER, } from "../claude-settings.js";
|
|
40
41
|
/**
|
|
@@ -276,139 +277,234 @@ function excludeWarning(worktreePath, category) {
|
|
|
276
277
|
`${EXECUTOR_EXCLUDE_LINES.join(" and ")} are not protected from worker commits on this ` +
|
|
277
278
|
"worktree; inspect it before trusting the worktree's staged changes; continuing fail-open.");
|
|
278
279
|
}
|
|
280
|
+
const EXCLUDE_UNRESOLVED_CATEGORY = {
|
|
281
|
+
no_gitdir_pointer: "git metadata carries no gitdir pointer",
|
|
282
|
+
metadata_unreadable: "git metadata could not be read",
|
|
283
|
+
metadata_invalid: "git metadata does not reference a usable git directory",
|
|
284
|
+
commondir_unusable: "the git common-directory pointer is unusable",
|
|
285
|
+
exclude_unreadable: "the exclude file could not be read",
|
|
286
|
+
writability_unknown: "exclude writability could not be determined",
|
|
287
|
+
};
|
|
288
|
+
function errnoCode(err) {
|
|
289
|
+
return err && typeof err === "object" ? err.code : undefined;
|
|
290
|
+
}
|
|
291
|
+
const S_IFMT = 0o170000;
|
|
292
|
+
const S_IFDIR = 0o040000;
|
|
293
|
+
/** `true` / `false` for a directory / non-directory; `null` when it is absent. */
|
|
294
|
+
async function directoryState(deps, dirPath) {
|
|
295
|
+
try {
|
|
296
|
+
return ((await deps.stat(dirPath)).mode & S_IFMT) === S_IFDIR;
|
|
297
|
+
}
|
|
298
|
+
catch (err) {
|
|
299
|
+
if (errnoCode(err) === "ENOENT")
|
|
300
|
+
return null;
|
|
301
|
+
throw err;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
279
304
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* operator's global git excludes (`~/.config/git/ignore`) no longer apply inside
|
|
284
|
-
* a worker — empirically, a worker `git add -A` commits the deny-layer file this
|
|
285
|
-
* module just wrote. A per-worktree `.git/info/exclude` entry is invisible to
|
|
286
|
-
* the diff and travels with the gitdir, so it closes that without touching the
|
|
287
|
-
* worktree's tracked `.gitignore`.
|
|
288
|
-
*
|
|
289
|
-
* A linked worktree's `.git` is a FILE containing `gitdir: <path>` pointing at
|
|
290
|
-
* the main repository's per-worktree gitdir; that indirection is resolved rather
|
|
291
|
-
* than assuming a directory (`EISDIR` on the read identifies a real main-checkout
|
|
292
|
-
* `.git` directory). The per-worktree gitdir is then resolved onward to the
|
|
293
|
-
* COMMON dir, because that — not the per-worktree dir — is where git reads
|
|
294
|
-
* `info/exclude` from; see the comment at the resolution site. Idempotent: the
|
|
295
|
-
* line is appended once, never duplicated.
|
|
305
|
+
* Locate the COMMON `info/exclude` for a checkout, with filesystem reads only (no
|
|
306
|
+
* Git subprocess, no writes). Shared by the writer and the read-only resolver so
|
|
307
|
+
* they can never disagree about the destination.
|
|
296
308
|
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* pointer, or cannot be read) — non-blocking, but WARNED. Git metadata is
|
|
305
|
-
* there and the executor could not use it, which means the settings file is
|
|
306
|
-
* unprotected on this worktree and a human should look.
|
|
307
|
-
*
|
|
308
|
-
* That distinction is the whole fix: a total failure to ever write was invisible
|
|
309
|
-
* precisely because "could not resolve" and "nothing to do" returned the same
|
|
310
|
-
* silent success.
|
|
311
|
-
*
|
|
312
|
-
* Warnings are bounded to a failure category plus the affected worktree path.
|
|
313
|
-
* They never carry `.git` contents, exception text, environment values, or
|
|
314
|
-
* settings-file content.
|
|
309
|
+
* `info/` is a COMMON-dir file: git reads exclusions from `<common>/info/exclude`,
|
|
310
|
+
* and for a linked worktree the common dir is the MAIN repository's `.git`, not
|
|
311
|
+
* `<main>/.git/worktrees/<name>` (BAPI-815/R2 — writing to the per-worktree gitdir
|
|
312
|
+
* made the whole mechanism a no-op). `<gitdir>/commondir` holds the pointer. Its
|
|
313
|
+
* ABSENCE (`ENOENT`) is the only case that falls back to the git dir itself (a main
|
|
314
|
+
* checkout); any other read error, or a pointer that does not name a directory, is
|
|
315
|
+
* unresolved rather than a guess.
|
|
315
316
|
*/
|
|
316
|
-
async function
|
|
317
|
+
async function resolveWorktreeExcludePath(worktreePath, deps) {
|
|
317
318
|
const gitPath = path.join(worktreePath, ".git");
|
|
318
319
|
let gitDir;
|
|
319
320
|
try {
|
|
320
321
|
const raw = await deps.readFile(gitPath);
|
|
321
322
|
const match = /^gitdir:\s*(.+?)\s*$/m.exec(raw);
|
|
322
|
-
if (!match)
|
|
323
|
-
|
|
324
|
-
// function understands; do not guess at a location to write into. Present
|
|
325
|
-
// but unusable — degrade loudly rather than reporting a clean success.
|
|
326
|
-
return {
|
|
327
|
-
ok: true,
|
|
328
|
-
warning: excludeWarning(worktreePath, "git metadata carries no gitdir pointer"),
|
|
329
|
-
};
|
|
330
|
-
}
|
|
323
|
+
if (!match)
|
|
324
|
+
return { kind: "unresolved", reason: "no_gitdir_pointer" };
|
|
331
325
|
const target = match[1];
|
|
332
326
|
gitDir = path.isAbsolute(target) ? target : path.resolve(worktreePath, target);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
// Main-checkout shape: `.git` is a real directory.
|
|
338
|
-
gitDir = gitPath;
|
|
339
|
-
}
|
|
340
|
-
else if (code === "ENOENT") {
|
|
341
|
-
// No git checkout here at all — nothing to protect, nothing to report.
|
|
342
|
-
return { ok: true };
|
|
327
|
+
try {
|
|
328
|
+
const isDir = await directoryState(deps, gitDir);
|
|
329
|
+
if (isDir !== true)
|
|
330
|
+
return { kind: "unresolved", reason: "metadata_invalid" };
|
|
343
331
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
// error CODE is a bounded category; the exception itself never escapes.
|
|
347
|
-
return {
|
|
348
|
-
ok: true,
|
|
349
|
-
warning: excludeWarning(worktreePath, "git metadata could not be read"),
|
|
350
|
-
};
|
|
332
|
+
catch {
|
|
333
|
+
return { kind: "unresolved", reason: "metadata_unreadable" };
|
|
351
334
|
}
|
|
352
335
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
// operator's `~/.config/git/ignore` carried the same rule — the protection
|
|
363
|
-
// built to be machine-independent was supplied entirely by machine-specific
|
|
364
|
-
// config, and the day that global ignore is absent a worker commits the file.
|
|
365
|
-
//
|
|
366
|
-
// `<gitdir>/commondir` holds the pointer (usually the relative `../..`), and
|
|
367
|
-
// it is a plain file, so this needs no new command-runner dependency. Its
|
|
368
|
-
// absence means this IS the common dir (a main checkout), which is why the
|
|
369
|
-
// fallback is `gitDir` itself rather than an error.
|
|
336
|
+
catch (err) {
|
|
337
|
+
const code = errnoCode(err);
|
|
338
|
+
if (code === "EISDIR")
|
|
339
|
+
gitDir = gitPath; // main-checkout shape
|
|
340
|
+
else if (code === "ENOENT")
|
|
341
|
+
return { kind: "unresolved", reason: "no_checkout" };
|
|
342
|
+
else
|
|
343
|
+
return { kind: "unresolved", reason: "metadata_unreadable" };
|
|
344
|
+
}
|
|
370
345
|
let commonDir = gitDir;
|
|
371
346
|
try {
|
|
372
347
|
const pointer = (await deps.readFile(path.join(gitDir, "commondir"))).trim();
|
|
373
|
-
if (pointer.length
|
|
374
|
-
|
|
348
|
+
if (pointer.length === 0)
|
|
349
|
+
return { kind: "unresolved", reason: "commondir_unusable" };
|
|
350
|
+
commonDir = path.isAbsolute(pointer) ? pointer : path.resolve(gitDir, pointer);
|
|
351
|
+
try {
|
|
352
|
+
if ((await directoryState(deps, commonDir)) !== true) {
|
|
353
|
+
return { kind: "unresolved", reason: "commondir_unusable" };
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
return { kind: "unresolved", reason: "commondir_unusable" };
|
|
375
358
|
}
|
|
376
359
|
}
|
|
377
|
-
catch {
|
|
360
|
+
catch (err) {
|
|
361
|
+
if (errnoCode(err) !== "ENOENT")
|
|
362
|
+
return { kind: "unresolved", reason: "commondir_unusable" };
|
|
378
363
|
/* no commondir pointer: `gitDir` is already the common dir */
|
|
379
364
|
}
|
|
365
|
+
const infoDir = path.join(commonDir, "info");
|
|
366
|
+
return { kind: "resolved", excludePath: path.join(infoDir, "exclude"), infoDir };
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Report the local exclude readiness for a checkout WITHOUT changing anything.
|
|
370
|
+
*
|
|
371
|
+
* `present` means the exclude file is readable and already contains every
|
|
372
|
+
* canonical {@link EXECUTOR_EXCLUDE_LINES} entry as an exact line — not merely that
|
|
373
|
+
* a file exists. An absent file or a missing entry is not present. `writable` comes
|
|
374
|
+
* from non-writing access checks: the existing file when there is one, otherwise
|
|
375
|
+
* the nearest existing ancestor that would have to receive the new file.
|
|
376
|
+
*
|
|
377
|
+
* This is a local filesystem snapshot. It performs no `mkdir`, write, rename, or
|
|
378
|
+
* remediation, and it does not verify worker protection or detect remote executor
|
|
379
|
+
* clones.
|
|
380
|
+
*/
|
|
381
|
+
export async function resolveWorktreeSettingsExclude(worktreePath, deps) {
|
|
382
|
+
const resolved = await resolveWorktreeExcludePath(worktreePath, deps);
|
|
383
|
+
if (resolved.kind === "unresolved")
|
|
384
|
+
return resolved;
|
|
385
|
+
let content = null;
|
|
386
|
+
try {
|
|
387
|
+
content = await deps.readFile(resolved.excludePath);
|
|
388
|
+
}
|
|
389
|
+
catch (err) {
|
|
390
|
+
if (errnoCode(err) !== "ENOENT")
|
|
391
|
+
return { kind: "unresolved", reason: "exclude_unreadable" };
|
|
392
|
+
}
|
|
393
|
+
const lines = new Set((content ?? "").split(/\r?\n/));
|
|
394
|
+
const present = content !== null && EXECUTOR_EXCLUDE_LINES.every((line) => lines.has(line));
|
|
395
|
+
let probe = content !== null ? resolved.excludePath : resolved.infoDir;
|
|
396
|
+
if (content === null) {
|
|
397
|
+
// Nearest existing ancestor that would have to receive the new file.
|
|
398
|
+
for (;;) {
|
|
399
|
+
let exists;
|
|
400
|
+
try {
|
|
401
|
+
exists = (await directoryState(deps, probe)) !== null;
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
return { kind: "unresolved", reason: "writability_unknown" };
|
|
405
|
+
}
|
|
406
|
+
if (exists)
|
|
407
|
+
break;
|
|
408
|
+
const parent = path.dirname(probe);
|
|
409
|
+
if (parent === probe)
|
|
410
|
+
return { kind: "unresolved", reason: "writability_unknown" };
|
|
411
|
+
probe = parent;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
let writable = true;
|
|
415
|
+
try {
|
|
416
|
+
await deps.accessWritable(probe);
|
|
417
|
+
}
|
|
418
|
+
catch (err) {
|
|
419
|
+
const code = errnoCode(err);
|
|
420
|
+
if (code === "EACCES" || code === "EPERM" || code === "EROFS")
|
|
421
|
+
writable = false;
|
|
422
|
+
else
|
|
423
|
+
return { kind: "unresolved", reason: "writability_unknown" };
|
|
424
|
+
}
|
|
425
|
+
return { kind: "resolved", excludePath: resolved.excludePath, present, writable };
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Keep the executor-owned `.claude/settings.local.json` and the conductor's
|
|
429
|
+
* `.conductor/` artifacts out of worker commits (BAPI-740/F2, BAPI-814/D2).
|
|
430
|
+
* Worker-config isolation redirects `XDG_CONFIG_HOME`, so the
|
|
431
|
+
* operator's global git excludes (`~/.config/git/ignore`) no longer apply inside
|
|
432
|
+
* a worker — empirically, a worker `git add -A` commits the deny-layer file this
|
|
433
|
+
* module just wrote. A per-worktree `.git/info/exclude` entry is invisible to
|
|
434
|
+
* the diff and travels with the gitdir, so it closes that without touching the
|
|
435
|
+
* worktree's tracked `.gitignore`.
|
|
436
|
+
*
|
|
437
|
+
* The destination is the COMMON `info/exclude`, located by
|
|
438
|
+
* {@link resolveWorktreeExcludePath}. Fail-open at every step, but NOT silent
|
|
439
|
+
* (BAPI-815/R2): no checkout (`ENOENT` on `.git`) is a benign silent success;
|
|
440
|
+
* present-but-unresolvable metadata is non-blocking but WARNED; a failed read or
|
|
441
|
+
* publish keeps `ok: false`.
|
|
442
|
+
*
|
|
443
|
+
* Publication contract: the file is re-read immediately before composing the
|
|
444
|
+
* replacement (only `ENOENT` counts as empty), existing content is kept verbatim —
|
|
445
|
+
* ordering, comments, line endings, and duplicates — and only absent canonical
|
|
446
|
+
* lines are appended. The result is written to a uniquely named temporary file in
|
|
447
|
+
* the same `info/` directory and renamed into place; no lockfile is used, and
|
|
448
|
+
* nothing is published when no canonical line is missing. Competing executor
|
|
449
|
+
* writers add the same canonical entries, so fresh reads plus atomic publication
|
|
450
|
+
* prevent torn files and executor-created duplicates. This does not serialize
|
|
451
|
+
* against unrelated external editors.
|
|
452
|
+
*
|
|
453
|
+
* Warnings are bounded to a failure category plus the affected worktree path.
|
|
454
|
+
* They never carry `.git` contents, exception text, environment values, or
|
|
455
|
+
* settings-file content.
|
|
456
|
+
*/
|
|
457
|
+
export async function provisionWorktreeSettingsExclude(worktreePath, deps) {
|
|
458
|
+
const resolved = await resolveWorktreeExcludePath(worktreePath, deps);
|
|
459
|
+
if (resolved.kind === "unresolved") {
|
|
460
|
+
if (resolved.reason === "no_checkout")
|
|
461
|
+
return { ok: true };
|
|
462
|
+
return {
|
|
463
|
+
ok: true,
|
|
464
|
+
warning: excludeWarning(worktreePath, EXCLUDE_UNRESOLVED_CATEGORY[resolved.reason]),
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
const { excludePath, infoDir } = resolved;
|
|
468
|
+
let tempPath;
|
|
380
469
|
try {
|
|
381
|
-
const infoDir = path.join(commonDir, "info");
|
|
382
470
|
await deps.mkdir(infoDir, { recursive: true });
|
|
383
|
-
const excludePath = path.join(infoDir, "exclude");
|
|
384
471
|
let existing = "";
|
|
385
472
|
try {
|
|
386
473
|
existing = await deps.readFile(excludePath);
|
|
387
474
|
}
|
|
388
|
-
catch {
|
|
389
|
-
|
|
475
|
+
catch (err) {
|
|
476
|
+
if (errnoCode(err) !== "ENOENT") {
|
|
477
|
+
return {
|
|
478
|
+
ok: false,
|
|
479
|
+
warning: excludeWarning(worktreePath, "the exclude file could not be read"),
|
|
480
|
+
};
|
|
481
|
+
}
|
|
390
482
|
}
|
|
391
483
|
// Idempotent per LINE, not per file: the settings entry predates the
|
|
392
484
|
// `.conductor/` one, so a worktree provisioned by an earlier executor build
|
|
393
|
-
// already contains the first and still needs the second.
|
|
394
|
-
// "does the file mention anything of ours?" check would skip it forever.
|
|
485
|
+
// already contains the first and still needs the second.
|
|
395
486
|
const present = new Set(existing.split(/\r?\n/));
|
|
396
487
|
const missing = EXECUTOR_EXCLUDE_LINES.filter((line) => !present.has(line));
|
|
397
|
-
if (missing.length === 0)
|
|
488
|
+
if (missing.length === 0)
|
|
398
489
|
return { ok: true };
|
|
399
|
-
}
|
|
400
|
-
// One write. Unrelated user-authored entries are preserved verbatim, and a
|
|
401
|
-
// file that did not end in a newline gets one first so the appended lines
|
|
402
|
-
// cannot fuse onto the operator's last entry.
|
|
403
490
|
const prefix = existing.length === 0 || existing.endsWith("\n") ? existing : `${existing}\n`;
|
|
404
|
-
|
|
491
|
+
tempPath = path.join(infoDir, `exclude.${process.pid}.${randomUUID()}.tmp`);
|
|
492
|
+
await deps.writeFile(tempPath, `${prefix}${missing.map((line) => `${line}\n`).join("")}`);
|
|
493
|
+
await deps.rename(tempPath, excludePath);
|
|
405
494
|
return { ok: true };
|
|
406
495
|
}
|
|
407
496
|
catch {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
497
|
+
if (tempPath !== undefined) {
|
|
498
|
+
try {
|
|
499
|
+
await deps.removeFile(tempPath);
|
|
500
|
+
}
|
|
501
|
+
catch {
|
|
502
|
+
/* best effort: only this writer's own temporary file */
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
// The gitdir resolved but the exclude could not be published. This keeps
|
|
506
|
+
// `ok: false`, because the caller's established contract treats a failed
|
|
507
|
+
// WRITE as the degraded case worth aggregating into the deny layer's result.
|
|
412
508
|
return {
|
|
413
509
|
ok: false,
|
|
414
510
|
warning: excludeWarning(worktreePath, "the exclude file could not be written"),
|
|
@@ -2,10 +2,10 @@ import { DEFAULT_PROBE_TIMEOUT_MS } from "../agent-capabilities/types.js";
|
|
|
2
2
|
import { inspectExecutorAgentAdapter, inspectionForFailedResolution, } from "../agent-launchers/executor-adapter-inspection.js";
|
|
3
3
|
import { resolveExecutorAgentAdapter } from "../agent-launchers/executor-adapter-registry.js";
|
|
4
4
|
import { resolveCompletionEvidenceCapability } from "../agent-launchers/executor-adapter.js";
|
|
5
|
-
import { COMPLETION_EVIDENCE_CAPABILITY, REQUIRED_VERIFICATION_CAPABILITY, cliVersionAtLeast, normalizeCliVersion, parseCliVersion, runtimeMatchesSupported, } from "./completion-contract.js";
|
|
5
|
+
import { CLEANUP_REPORT_CAPABILITY, COMPLETION_EVIDENCE_CAPABILITY, REQUIRED_VERIFICATION_CAPABILITY, REQUIRED_VERIFICATION_CI_DEFERRAL_CAPABILITY, cliVersionAtLeast, normalizeCliVersion, parseCliVersion, runtimeMatchesSupported, } from "./completion-contract.js";
|
|
6
6
|
import { buildHeadlessAgentEnv } from "./env.js";
|
|
7
7
|
import { resolveExecutorAgentId } from "./agent-identity.js";
|
|
8
|
-
import { mkdtemp, rm } from "node:fs/promises";
|
|
8
|
+
import { mkdtemp, rm, rename as fsRename } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
10
|
import { join } from "node:path";
|
|
11
11
|
import { spawnSync } from "node:child_process";
|
|
@@ -291,6 +291,9 @@ export async function collectExecutorPreflight(options, deps, seams = {}) {
|
|
|
291
291
|
denyProvisioningDeps: {
|
|
292
292
|
readFile: deps.readFile, writeFile: deps.writeFile,
|
|
293
293
|
mkdir: deps.mkdir, homedir: deps.homedir,
|
|
294
|
+
stat: deps.stat,
|
|
295
|
+
rename: (from, to) => fsRename(from, to),
|
|
296
|
+
removeFile: (filePath) => rm(filePath, { force: true }),
|
|
294
297
|
},
|
|
295
298
|
} : {}),
|
|
296
299
|
},
|
|
@@ -464,6 +467,11 @@ export async function collectExecutorPreflight(options, deps, seams = {}) {
|
|
|
464
467
|
}
|
|
465
468
|
// The probe gets a worker-shaped environment so a nested-session variable in
|
|
466
469
|
// the executor's own process cannot change its verdict (BAPI-1386).
|
|
470
|
+
//
|
|
471
|
+
// BAPI-1521: deliberately NOT a job. This probe has no payload and therefore
|
|
472
|
+
// no `worker_env` declaration, and `buildHeadlessAgentEnv` passes none, so the
|
|
473
|
+
// legacy compatibility base constants apply on purpose. It is the one
|
|
474
|
+
// documented exception to the payload-presence rule.
|
|
467
475
|
const verdict = await denyCapability.value.probeEnforcement({
|
|
468
476
|
timeoutMs: resolveDenyProbeTimeoutMs(deps.env),
|
|
469
477
|
env: buildHeadlessAgentEnv(deps.env),
|
|
@@ -646,7 +654,15 @@ export function buildClaimManifest(report, options, freeSlots) {
|
|
|
646
654
|
// server drops the unknown token (`normalize_declared_capabilities`).
|
|
647
655
|
capabilities: [
|
|
648
656
|
...(report.completionEvidenceQualified === true
|
|
649
|
-
? [
|
|
657
|
+
? [
|
|
658
|
+
COMPLETION_EVIDENCE_CAPABILITY,
|
|
659
|
+
REQUIRED_VERIFICATION_CAPABILITY,
|
|
660
|
+
REQUIRED_VERIFICATION_CI_DEFERRAL_CAPABILITY,
|
|
661
|
+
// BAPI-1504: this executor persists ownership before spawning a
|
|
662
|
+
// covered worker and delivers cleanup reports, so it may claim a job
|
|
663
|
+
// that requires the capability. An older server drops the token.
|
|
664
|
+
CLEANUP_REPORT_CAPABILITY,
|
|
665
|
+
]
|
|
650
666
|
: []),
|
|
651
667
|
FOCUSED_REBASE_CAPABILITY,
|
|
652
668
|
SCOPE_WAIT_CAPABILITY,
|
|
@@ -107,6 +107,24 @@ export function withOwnershipTag(env, token) {
|
|
|
107
107
|
next[OWNERSHIP_TAG_ENV] = token;
|
|
108
108
|
return next;
|
|
109
109
|
}
|
|
110
|
+
/** The environment variable carrying the claimed executor job's ID (BAPI-1544). */
|
|
111
|
+
export const EXECUTOR_JOB_ID_ENV = "BRIDGE_EXECUTOR_JOB_ID";
|
|
112
|
+
/**
|
|
113
|
+
* A NEW environment carrying `jobId` as the claimed executor job ID. Any ambient
|
|
114
|
+
* value is removed first, then the ID is set only when it is a positive safe
|
|
115
|
+
* integer; anything else leaves the key absent. It never throws, so a bad value
|
|
116
|
+
* cannot become a spawn failure, and it touches no other key (the ownership tag and
|
|
117
|
+
* its cleanup are unaffected). Call this AFTER the adapter/base environment is
|
|
118
|
+
* built, from the claimed job row, never from a payload.
|
|
119
|
+
*/
|
|
120
|
+
export function withExecutorJobId(env, jobId) {
|
|
121
|
+
const next = { ...env };
|
|
122
|
+
delete next[EXECUTOR_JOB_ID_ENV];
|
|
123
|
+
if (typeof jobId === "number" && Number.isSafeInteger(jobId) && jobId > 0) {
|
|
124
|
+
next[EXECUTOR_JOB_ID_ENV] = String(jobId);
|
|
125
|
+
}
|
|
126
|
+
return next;
|
|
127
|
+
}
|
|
110
128
|
/** Per-`ps` call bound. The whole sweep is further bounded by its deadline. */
|
|
111
129
|
const PS_TIMEOUT_MS = 10_000;
|
|
112
130
|
/**
|
|
@@ -773,8 +791,34 @@ export async function recoverInterruptedOwnership(options) {
|
|
|
773
791
|
catch {
|
|
774
792
|
/* logging is best-effort */
|
|
775
793
|
}
|
|
776
|
-
|
|
777
|
-
|
|
794
|
+
// A malformed record proved nothing and has no token to report: it is removed
|
|
795
|
+
// exactly as before. A real record is reported only after a CONFIRMED sweep.
|
|
796
|
+
let removeRecord = true;
|
|
797
|
+
if (options.reportCleanup !== undefined && record !== null) {
|
|
798
|
+
removeRecord = false;
|
|
799
|
+
if (verdict.verdict === "confirmed" && verdict.survivors === 0) {
|
|
800
|
+
try {
|
|
801
|
+
const outcome = await options.reportCleanup({
|
|
802
|
+
jobId: record.jobId,
|
|
803
|
+
repoName: record.repoName,
|
|
804
|
+
token: record.token,
|
|
805
|
+
});
|
|
806
|
+
removeRecord = outcome.kind === "accepted" || outcome.kind === "not_applicable";
|
|
807
|
+
try {
|
|
808
|
+
log(`[executor] BAPI-1504 cleanup report job=${fileJobId} outcome=${outcome.kind === "retained" ? `retained:${outcome.reason}` : outcome.kind}`);
|
|
809
|
+
}
|
|
810
|
+
catch {
|
|
811
|
+
/* logging is best-effort */
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
catch {
|
|
815
|
+
removeRecord = false;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (removeRecord)
|
|
820
|
+
await removeOwnershipRecord(stateDir, fileJobId, fsDeps);
|
|
821
|
+
results.push({ jobId: fileJobId, verdict, recordRemoved: removeRecord });
|
|
778
822
|
}
|
|
779
823
|
return results;
|
|
780
824
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderWorkerVerificationGuidance } from "./worker-verification-guidance.js";
|
|
1
|
+
import { renderWorkerVerificationGuidance, renderWorkerTimeBudgetGuidance } from "./worker-verification-guidance.js";
|
|
2
2
|
/**
|
|
3
3
|
* Executor-side structured prompt-spec renderer (BAPI-550, TDD §6/§7).
|
|
4
4
|
*
|
|
@@ -32,13 +32,48 @@ import { EPIC_WORKAROUNDS_DIR, epicWorkaroundRecordPath } from "../epic-workarou
|
|
|
32
32
|
* work unfinished, which parks the ticket as `required_work_incomplete` through
|
|
33
33
|
* the unchanged completion contract.
|
|
34
34
|
*
|
|
35
|
+
* BAPI-1454 adds planned hand-offs: a capability needed only to VERIFY an
|
|
36
|
+
* acceptance criterion (a running app or database, a toolchain version, live
|
|
37
|
+
* credentials) is recorded as a hand-off, never as a core gap, and the worker
|
|
38
|
+
* continues without reporting that criterion as passed.
|
|
39
|
+
*
|
|
40
|
+
* BAPI-1544 widens that order to unit-test steps and a fifth cause
|
|
41
|
+
* (`mcp_unavailable`), makes the hand-off a six-field object that adds the
|
|
42
|
+
* corrected invocation, binds it to the head it observed (a step that failed at one
|
|
43
|
+
* head can be handed off only from a new head), and states the run's actual setting
|
|
44
|
+
* ("this run allows" or "does not allow" hand-offs) when the job carries it.
|
|
45
|
+
*
|
|
46
|
+
* BAPI-1492 adds the verification hand-off order for an E2E or rendered-UI step:
|
|
47
|
+
* run it locally (the disposable job database when one is provided), defer to
|
|
48
|
+
* `remote_ci` only when a named required workflow, job, or command runs it, and
|
|
49
|
+
* otherwise record it escalated with a `handoff` object carrying the observed
|
|
50
|
+
* failure. Review steps always run and are recorded executed. The server alone
|
|
51
|
+
* decides whether a hand-off counts, from persisted run state.
|
|
52
|
+
*
|
|
53
|
+
* BAPI-1533 puts a test invocation rule ahead of that order: a selector that
|
|
54
|
+
* collects zero tests is an invocation error (never a pass, never a missing
|
|
55
|
+
* capability), every affected test-running step is rerun from the repository
|
|
56
|
+
* root with the declared runner and its command and output recorded, the
|
|
57
|
+
* declared build runs before a built-CLI smoke step, and an undeclared runner or
|
|
58
|
+
* build command is never invented. Hand-offs stay limited to the eligible
|
|
59
|
+
* classes, the persisted run policy, and a genuine pre-result missing
|
|
60
|
+
* capability. Nothing converts an ordinary escalation into a hand-off.
|
|
61
|
+
*
|
|
35
62
|
* The worker decides from the ticket and the code alone; no supervisor scan
|
|
36
63
|
* result is injected here. Kept SINGLE-LINE and free of `;`, quotes, and
|
|
37
64
|
* apostrophes, like `buildPrBaseContractLaunchInstruction`, because it travels
|
|
38
65
|
* in the same launch prompt.
|
|
39
66
|
*/
|
|
40
|
-
export function buildEpicWorkaroundWorkerInstruction(ticketKey) {
|
|
67
|
+
export function buildEpicWorkaroundWorkerInstruction(ticketKey, handoffEnabled) {
|
|
41
68
|
const record = (ticketKey ? epicWorkaroundRecordPath(ticketKey) : null) ?? `${EPIC_WORKAROUNDS_DIR}<TICKET>.md`;
|
|
69
|
+
// BAPI-1544: an explicit boolean states the run setting outright. An absent one
|
|
70
|
+
// (a job from an older API) keeps today's conditional wording.
|
|
71
|
+
const policyClause = handoffEnabled === true
|
|
72
|
+
? "This run allows verification hand-offs. "
|
|
73
|
+
: handoffEnabled === false
|
|
74
|
+
? "This run does not allow verification hand-offs, so a step that cannot run is recorded as an ordinary escalation without a handoff object. "
|
|
75
|
+
: "";
|
|
76
|
+
const allowsClause = handoffEnabled === undefined ? " and the persisted run policy allows hand-offs" : "";
|
|
42
77
|
return ("Workaround contract: if a requirement of this ticket cannot be met unattended, such as a missing " +
|
|
43
78
|
"credential, external setting, or access, decide whether it is minor or core. It is minor only when " +
|
|
44
79
|
"the essential behavior of the ticket still works without it. For a minor gap, deliver a guarded " +
|
|
@@ -46,7 +81,41 @@ export function buildEpicWorkaroundWorkerInstruction(ticketKey) {
|
|
|
46
81
|
"only that feature), keep the core path working, and write " + record + " naming the requirement, " +
|
|
47
82
|
"the guarded substitute you delivered, and the step a human must still take. Commit that record on " +
|
|
48
83
|
"this ticket branch with git add -f " + record + ". For a core gap, never write a workaround or a " +
|
|
49
|
-
"record: leave the required work unfinished so the run parks this ticket for a human."
|
|
84
|
+
"record: leave the required work unfinished so the run parks this ticket for a human. Planned " +
|
|
85
|
+
"hand-offs: if a running app or database, a toolchain version, or live credentials are needed only " +
|
|
86
|
+
"to verify an acceptance criterion and not to implement it safely, that is a planned hand-off and " +
|
|
87
|
+
"not a core gap. Record the affected acceptance criterion and the human verification step in " + record +
|
|
88
|
+
" and continue. Never report an unverified acceptance criterion as passed. A dependency needed to " +
|
|
89
|
+
"implement safely keeps ordinary core gap handling. " +
|
|
90
|
+
"Test invocation rule for every step that runs tests: a requested test selector that collects zero " +
|
|
91
|
+
"tests is an invocation error whatever the exit status or runner wording, never a pass and never " +
|
|
92
|
+
"proof of a missing capability. Rerun every affected test-running step from the repository root with " +
|
|
93
|
+
"the repository declared runner and record the exact command and its output in that step evidence. " +
|
|
94
|
+
"Run the repository declared build command before any built CLI smoke step. If no runner or build " +
|
|
95
|
+
"command is declared, that is not a pass and does not let you invent a command or report success. " +
|
|
96
|
+
"Verification hand-off for a unit_tests, e2e_tests, or rendered_ui_review step. " + policyClause +
|
|
97
|
+
"First run it locally, using the disposable job database when one is provided. Record it escalated " +
|
|
98
|
+
"with prDependency remote_ci only when a named required CI workflow, job, or command runs that check. " +
|
|
99
|
+
"Otherwise, if a missing live server, database, toolchain, credential, or MCP capability stopped the " +
|
|
100
|
+
"check before it produced any result, both on your first invocation and on the corrected rerun" + allowsClause +
|
|
101
|
+
", record the step escalated with a handoff object of exactly six fields. The cause is one of " +
|
|
102
|
+
"no_live_server, no_database, toolchain_unavailable, credential_unavailable, or mcp_unavailable. " +
|
|
103
|
+
"The criterion is the affected acceptance criterion. The observation names the command you first " +
|
|
104
|
+
"ran and the missing capability it hit. The corrected_invocation names the corrected rerun and the " +
|
|
105
|
+
"missing capability it hit. The observed_head_sha is the full head SHA both ran against, and it must " +
|
|
106
|
+
"equal the head you record the phase result at. The next_action is the next human step. Never put " +
|
|
107
|
+
"credentials or secrets in the observation or corrected_invocation. For example, a unit step whose " +
|
|
108
|
+
"acquire command timed out names that command and the timeout. " +
|
|
109
|
+
"A failed assertion, an " +
|
|
110
|
+
"application error from a check that did run, and unfinished implementation or test authoring stay " +
|
|
111
|
+
"blockers, and an unclear failure stays an ordinary escalation. Only those three step classes may be " +
|
|
112
|
+
"handed off. Neither you nor the server turns an ordinary escalation into a hand-off, and you never " +
|
|
113
|
+
"invent a missing capability observation. Review steps (test_gap_review, " +
|
|
114
|
+
"final_plan_review, and combined_review_test) always run, acknowledge the handed-off criterion from " +
|
|
115
|
+
"that escalated record and the workaround record written in the same job, and are recorded executed, " +
|
|
116
|
+
"never handed off. A hand-off counts only at the head it observed, so a new head needs a fresh " +
|
|
117
|
+
"observation. A step that already failed at one head can be handed off only from a new head, " +
|
|
118
|
+
"never at the head where it failed.");
|
|
50
119
|
}
|
|
51
120
|
/** Stable named-error kind used for every prompt-spec contract failure. */
|
|
52
121
|
const PROMPT_CONTRACT_ERROR = "ContractError.Prompt";
|
|
@@ -129,6 +198,8 @@ const CI_FIX_PLACEHOLDERS = [
|
|
|
129
198
|
];
|
|
130
199
|
const CI_FIX_EXCERPT_TRUNCATION_MARKER = " …[excerpt truncated]";
|
|
131
200
|
const CI_FIX_HEAD_SHA_RE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
201
|
+
const CI_FIX_STATUS_ONLY_NOTE = "provider_reports_status_only";
|
|
202
|
+
const CI_FIX_STATUS_ONLY_NOTE_LINE = "Note: this provider reports a status only; no log or annotations exist for it.";
|
|
132
203
|
/** Build the named, bounded refusal for a focused ci_fix job. */
|
|
133
204
|
export function ciFixContextError(job, reason) {
|
|
134
205
|
return new ExecutorNamedError(CiFixContext, `ci_fix job ${job.id} refused before worker effects (reason=${reason})`);
|
|
@@ -317,7 +388,14 @@ function readLogExcerpts(raw, headSha, dispatched) {
|
|
|
317
388
|
CI_FIX_EXCERPT_TRUNCATION_MARKER;
|
|
318
389
|
}
|
|
319
390
|
totalBytes += utf8Bytes(text);
|
|
320
|
-
|
|
391
|
+
// A note is optional metadata: only the exact closed token is kept, and an
|
|
392
|
+
// absent, malformed, or unknown one never refuses the excerpt.
|
|
393
|
+
excerpts.push({
|
|
394
|
+
check: e.check.trim(),
|
|
395
|
+
source: e.source.trim(),
|
|
396
|
+
text,
|
|
397
|
+
...(e.note === CI_FIX_STATUS_ONLY_NOTE ? { note: CI_FIX_STATUS_ONLY_NOTE } : {}),
|
|
398
|
+
});
|
|
321
399
|
}
|
|
322
400
|
return { status: "supplied", excerpts };
|
|
323
401
|
}
|
|
@@ -391,24 +469,48 @@ export function readCiFixDispatchContext(job) {
|
|
|
391
469
|
if (repoName !== job.repo_name || (jobExpectedBranch && jobExpectedBranch !== expectedBranch)) {
|
|
392
470
|
throw ciFixContextError(job, "identity_mismatch");
|
|
393
471
|
}
|
|
394
|
-
const
|
|
472
|
+
const candidateAnchor = typeof raw.failing_head_sha === "string"
|
|
473
|
+
? raw.failing_head_sha.trim().toLowerCase() : "";
|
|
474
|
+
const failingHeadSha = CI_FIX_HEAD_SHA_RE.test(candidateAnchor) ? candidateAnchor : undefined;
|
|
475
|
+
// BAPI-1514: a refreshed payload re-reads CI at the bound head and says so with
|
|
476
|
+
// `evidence_head_sha === head_sha`; its checks, snapshot, and excerpts are then
|
|
477
|
+
// bound to that head, not to the original failing anchor. A legacy payload
|
|
478
|
+
// (no or mismatched `evidence_head_sha`) keeps the anchor-bound evidence.
|
|
479
|
+
const candidateEvidence = typeof raw.evidence_head_sha === "string"
|
|
480
|
+
? raw.evidence_head_sha.trim().toLowerCase() : "";
|
|
481
|
+
const evidenceHeadSha = /^[0-9a-f]{40}$/.test(candidateEvidence) && candidateEvidence === headSha
|
|
482
|
+
? candidateEvidence : undefined;
|
|
483
|
+
const evidenceHead = evidenceHeadSha ?? failingHeadSha ?? headSha;
|
|
484
|
+
const logExcerpts = readLogExcerpts(raw.log_excerpts, evidenceHead, seen);
|
|
395
485
|
if (logExcerpts === null) {
|
|
396
486
|
throw ciFixContextError(job, "log_excerpts_invalid");
|
|
397
487
|
}
|
|
398
488
|
return {
|
|
399
489
|
headSha,
|
|
490
|
+
...(failingHeadSha ? { failingHeadSha } : {}),
|
|
491
|
+
...(evidenceHeadSha ? { evidenceHeadSha } : {}),
|
|
400
492
|
repoName,
|
|
401
493
|
expectedBranch,
|
|
402
494
|
failingChecks: failing,
|
|
403
495
|
missingChecks: missing,
|
|
404
496
|
requiredClaimChecks: required,
|
|
405
497
|
logExcerpts,
|
|
406
|
-
evidence: readCiEvidence(raw.evidence_snapshot,
|
|
498
|
+
evidence: readCiEvidence(raw.evidence_snapshot, evidenceHead, new Set(failing)),
|
|
407
499
|
};
|
|
408
500
|
}
|
|
409
501
|
function formatCheckList(names, none) {
|
|
410
502
|
return names.length > 0 ? names.map((name) => `- ${sanitizeCiText(name, 200)}`).join("\n") : none;
|
|
411
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Quote any provider-controlled line that imitates the diagnostics delimiters, so
|
|
506
|
+
* only the renderer's own delimiter lines are structurally active.
|
|
507
|
+
*/
|
|
508
|
+
function quoteDiagnosticDelimiters(value) {
|
|
509
|
+
return value
|
|
510
|
+
.split("\n")
|
|
511
|
+
.map((line) => (line.includes("## UNTRUSTED PROVIDER DIAGNOSTICS") ? `> ${line}` : line))
|
|
512
|
+
.join("\n");
|
|
513
|
+
}
|
|
412
514
|
function formatLogExcerpts(context) {
|
|
413
515
|
const evidence = context.evidence;
|
|
414
516
|
const header = evidence.status === "unavailable"
|
|
@@ -430,10 +532,10 @@ function formatLogExcerpts(context) {
|
|
|
430
532
|
"and local reproduction; do not assume what any log said.") + "\n## UNTRUSTED PROVIDER DIAGNOSTICS END ##";
|
|
431
533
|
}
|
|
432
534
|
const summaries = evidence.status === "available"
|
|
433
|
-
? evidence.required.filter((item) => item.summary).map((item) => `${sanitizeCiText(item.name, 200)} selected summary: ${item.summary}`)
|
|
535
|
+
? evidence.required.filter((item) => item.summary).map((item) => quoteDiagnosticDelimiters(`${sanitizeCiText(item.name, 200)} selected summary: ${item.summary}`))
|
|
434
536
|
: [];
|
|
435
537
|
return header + "\n## UNTRUSTED PROVIDER DIAGNOSTICS BEGIN ##\n" +
|
|
436
|
-
[...summaries, ...excerpts.excerpts.map((e) => `--- check: ${sanitizeCiText(e.check, 200)} (source: ${sanitizeCiText(e.source, 200)}) ---\n${sanitizeCiText(e.text)}`)].join("\n\n") +
|
|
538
|
+
[...summaries, ...excerpts.excerpts.map((e) => quoteDiagnosticDelimiters(`--- check: ${sanitizeCiText(e.check, 200)} (source: ${sanitizeCiText(e.source, 200)}) ---\n${sanitizeCiText(e.text)}`) + (e.note === CI_FIX_STATUS_ONLY_NOTE ? `\n${CI_FIX_STATUS_ONLY_NOTE_LINE}` : ""))].join("\n\n") +
|
|
437
539
|
"\n## UNTRUSTED PROVIDER DIAGNOSTICS END ##";
|
|
438
540
|
}
|
|
439
541
|
/**
|
|
@@ -679,5 +781,7 @@ export async function renderPromptSpecPrompt(job, context) {
|
|
|
679
781
|
const userPrompt = buildPromptSpecUserPrompt(spec, values);
|
|
680
782
|
return `${systemPrompt}\n\n${userPrompt}` +
|
|
681
783
|
(!context.deferComparisonGuidance && ["implement", "resume", "ci_fix"].includes(job.job_type)
|
|
682
|
-
? "\n\n" + renderWorkerVerificationGuidance(context.comparisonSha) : "")
|
|
784
|
+
? "\n\n" + renderWorkerVerificationGuidance(context.comparisonSha) : "") +
|
|
785
|
+
(!context.deferComparisonGuidance && job.job_type === "ci_fix"
|
|
786
|
+
? "\n\n" + renderWorkerTimeBudgetGuidance(context.timeoutSeconds) : "");
|
|
683
787
|
}
|