@bridge_gpt/mcp-server 0.2.75 → 0.2.77
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 -6
- package/build/agents.generated.js +5 -5
- package/build/cli-dispatch.js +333 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +8 -8
- package/build/conductor/bridge-api-client.js +193 -13
- package/build/conductor/declare-blocked.js +146 -7
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/driver-register.js +8 -2
- package/build/conductor/epic-implementer-cli.js +15 -10
- package/build/conductor/epic-server-journal.js +52 -22
- package/build/conductor/epic-server-recipe.js +15 -5
- package/build/conductor/epic-server-runtime.js +163 -45
- package/build/conductor/epic-server.js +13 -6
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +28 -7
- package/build/conductor/local-merge.js +55 -13
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/readiness-prerequisites.js +89 -2
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +14 -12
- package/build/conductor/repository-workflow-remedy.js +147 -7
- package/build/conductor/ui-readiness.js +224 -0
- package/build/conductor/wait-run-attention.js +9 -4
- package/build/conductor/wait-run-cli.js +9 -2
- package/build/docs.generated.js +67 -4
- package/build/doctor.js +97 -1
- package/build/drive-epic.js +625 -33
- package/build/engine-paths.js +10 -0
- package/build/epic-coherence-input-cli.js +105 -10
- package/build/epic-coherence-input.js +877 -4
- package/build/epic-coherence-input.test-fixtures.js +117 -0
- package/build/epic-implementer-bin.js +947 -120
- package/build/epic-implementer-env.js +2 -2
- package/build/epic-launch-context.js +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +14 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/guarded-fast-forward-push.js +25 -2
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +87 -28
- package/build/executor/likely-tests.js +78 -6
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/provider-checks.js +101 -5
- package/build/executor/rebase-finalization.js +29 -27
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/rename-aside.js +265 -0
- package/build/executor/required-work-ledger.js +89 -6
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +26 -4
- package/build/executor/types.js +121 -0
- package/build/executor/worktree.js +39 -2
- package/build/index.js +2500 -495
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +4 -0
- package/build/install-bridge-conductor-apply.js +10 -0
- package/build/install-bridge-conductor-assessment.js +84 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-setup.js +103 -3
- package/build/install-bridge-conductor.js +440 -812
- package/build/install-bridge.js +4 -11
- package/build/language-catalog.generated.js +2649 -0
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +47 -19
- package/build/plan-execution-ledger.js +35 -0
- package/build/plan-generation.js +34 -0
- package/build/plane/build-freshness.js +6 -0
- package/build/plane/cli.js +12 -5
- package/build/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +17 -0
- package/build/readiness-prerequisites.generated.js +28 -0
- package/build/readme.generated.js +1 -1
- package/build/run-unit-tests-launcher.js +3 -1
- package/build/secret-redaction.js +3 -0
- package/build/server.js +7946 -0
- package/build/setup-epic.js +41 -8
- package/build/start-tickets-prereqs.js +3 -6
- package/build/test-support/console-guard.js +30 -0
- package/build/test-support/create-preview-world.js +232 -0
- package/build/test-support/module-imports.js +155 -0
- package/build/test-support/server-client.js +96 -0
- package/build/test-support/stdio-server.js +146 -0
- package/build/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +39 -5
- package/build/version.generated.js +3 -3
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +150 -2
- package/docs/epic-implementer/getting-started.md +5 -1
- package/package.json +3 -3
- package/pipelines/implement-ticket.json +2 -2
- package/pipelines/learn-repository.json +19 -1
|
@@ -51,8 +51,8 @@ const renamed = (suffix) => [
|
|
|
51
51
|
* `mcp_server/src/**\/*.ts` at HEAD `45d854081` (re-confirmed at `315572187`).
|
|
52
52
|
*
|
|
53
53
|
* Deliberately absent: `PUBLISHED_IDENTITY_FIXTURE` (removed from source), the
|
|
54
|
-
* retired `LLM_*` names (
|
|
55
|
-
*
|
|
54
|
+
* retired `LLM_*` names (the supervisor judgment they configured was removed), and
|
|
55
|
+
* test-only sentinels. All of
|
|
56
56
|
* those still fall through to the generic prefix pointer.
|
|
57
57
|
*
|
|
58
58
|
* These 37 prefix-derived suffixes are distinct from the three BAPI-1237
|
|
@@ -49,6 +49,7 @@ import path from "node:path";
|
|
|
49
49
|
import { BRIDGE_RUN_STATE_DIR } from "./bridge-permissions.js";
|
|
50
50
|
import { READINESS_FRESH_RECONCILER_COUNT_CAP, } from "./conductor/bridge-api-client.js";
|
|
51
51
|
import { EMAIL_TRANSPORT_LIVE_DIAGNOSTIC_ID } from "./escalation-reachability.js";
|
|
52
|
+
import { repositoryReadinessVerdict } from "./conductor/repository-workflow-remedy.js";
|
|
52
53
|
/** The schema this writer produces (BAPI-1595: the corrected projection). */
|
|
53
54
|
export const LAUNCH_CONTEXT_SCHEMA_VERSION = 2;
|
|
54
55
|
/** The earlier, lossy schema. Still readable; its bring-up values are read as unknown. */
|
|
@@ -151,6 +152,9 @@ export function projectMandatoryDiagnostics(diagnostics) {
|
|
|
151
152
|
}
|
|
152
153
|
return results;
|
|
153
154
|
}
|
|
155
|
+
function readinessVerdictFact(verdict) {
|
|
156
|
+
return verdict === "confirmed" ? true : verdict === "denied" ? false : null;
|
|
157
|
+
}
|
|
154
158
|
function readinessFacts(report) {
|
|
155
159
|
const provider = typeof report.provider_repository === "string" && PROVIDER_REPO_RE.test(report.provider_repository)
|
|
156
160
|
? report.provider_repository
|
|
@@ -166,7 +170,10 @@ function readinessFacts(report) {
|
|
|
166
170
|
bring_up: bringUpFacts(report.bring_up),
|
|
167
171
|
unattended_conductor_allowed: boolOrNull(report.unattended?.conductor_allowed),
|
|
168
172
|
escalation_email_available: boolOrNull(report.unattended?.escalation_email_available),
|
|
169
|
-
|
|
173
|
+
// BAPI-1714 — the same shared-verdict mapping setup-epic reads from a full
|
|
174
|
+
// report: confirmed -> true, denied -> false, unknown -> null. The document
|
|
175
|
+
// format, version, and field type are unchanged.
|
|
176
|
+
repository_readiness_confirmed: readinessVerdictFact(repositoryReadinessVerdict(report)),
|
|
170
177
|
merge_execution_probe_skipped_reason: report.merge_execution?.probe_skipped_reason === LAUNCH_CONTEXT_PROBE_SKIPPED_REASON
|
|
171
178
|
? LAUNCH_CONTEXT_PROBE_SKIPPED_REASON
|
|
172
179
|
: null,
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
*
|
|
19
19
|
* - **Never force-updates an existing branch.** The push refspec has no leading
|
|
20
20
|
* `+`, so it can only create. A branch that already exists at any commit other
|
|
21
|
-
* than the held cut commit is a refusal, never a repoint.
|
|
21
|
+
* than the held cut commit is a refusal, never a repoint. The push skips
|
|
22
|
+
* client-side pre-push hooks (`--no-verify`) because it sends no new code; the
|
|
23
|
+
* comment at the push says why.
|
|
22
24
|
* - **Takes an already validated branch and SHA.** Callers validate the branch
|
|
23
25
|
* name (`validateBranchName`) and normalize the candidate SHA before calling;
|
|
24
26
|
* this module re-proves the SHA shape it pushes, but it is not a parser.
|
|
@@ -27,10 +29,12 @@
|
|
|
27
29
|
* only inside the typed client's headers.
|
|
28
30
|
* - **Every failure is classified, never thrown.** Callers get a discriminated
|
|
29
31
|
* outcome with operator-ready sentences and the bounded facts (expected and
|
|
30
|
-
* observed SHAs) they need to report; there is nothing to `try/catch`.
|
|
32
|
+
* observed SHAs) they need to report; there is nothing to `try/catch`. A failed
|
|
33
|
+
* push also carries a short, redacted tail of git's own output.
|
|
31
34
|
*/
|
|
32
35
|
import { execFile } from "node:child_process";
|
|
33
36
|
import { abandonIndexScopeCut, beginIndexScopeCut, commitIndexScopeCut, getIndexScopeStatus, } from "./bridge-client.js";
|
|
37
|
+
import { redactSecrets } from "../secret-redaction.js";
|
|
34
38
|
/**
|
|
35
39
|
* Poll bound for a scope bootstrap, shared by `implement-epic init` and
|
|
36
40
|
* `setup-epic`. A seed copies a repository's whole parse cache and the
|
|
@@ -96,6 +100,40 @@ export function normalizeCommitSha(value) {
|
|
|
96
100
|
const normalized = value.trim().toLowerCase();
|
|
97
101
|
return /^[0-9a-f]{40}$/.test(normalized) ? normalized : null;
|
|
98
102
|
}
|
|
103
|
+
/** How many trailing non-empty lines of git's output a failure message keeps. */
|
|
104
|
+
export const GIT_FAILURE_TAIL_MAX_LINES = 5;
|
|
105
|
+
/** The most characters of git's output a failure message keeps. */
|
|
106
|
+
export const GIT_FAILURE_TAIL_MAX_CHARS = 600;
|
|
107
|
+
/**
|
|
108
|
+
* A short, safe tail of a failed git command's output, or `null` when it said nothing.
|
|
109
|
+
*
|
|
110
|
+
* Without git's own words, a failed push reads the same whether a hook failed, a
|
|
111
|
+
* ruleset refused it, or the credentials were wrong. This keeps the last few
|
|
112
|
+
* non-empty lines of stderr (stdout when stderr is empty), strips color codes and
|
|
113
|
+
* other control characters, and redacts credentials: the shared
|
|
114
|
+
* {@link redactSecrets} patterns, plus the exact Bridge API key when one is given.
|
|
115
|
+
*/
|
|
116
|
+
export function gitFailureTail(result, apiKey) {
|
|
117
|
+
const raw = result.stderr.trim().length > 0 ? result.stderr : result.stdout;
|
|
118
|
+
const lines = raw
|
|
119
|
+
// ANSI CSI sequences (colors, cursor moves) and OSC sequences (titles, links).
|
|
120
|
+
.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "")
|
|
121
|
+
.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, "")
|
|
122
|
+
// Progress output redraws with a bare carriage return; treat it as a line break.
|
|
123
|
+
.split(/\r\n|\r|\n/)
|
|
124
|
+
.map((line) => line.replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "").trim())
|
|
125
|
+
.filter((line) => line.length > 0);
|
|
126
|
+
if (lines.length === 0)
|
|
127
|
+
return null;
|
|
128
|
+
let text = lines.slice(-GIT_FAILURE_TAIL_MAX_LINES).join(" | ");
|
|
129
|
+
if (apiKey && apiKey.length >= 4)
|
|
130
|
+
text = text.split(apiKey).join("[REDACTED]");
|
|
131
|
+
text = redactSecrets(text);
|
|
132
|
+
if (text.length > GIT_FAILURE_TAIL_MAX_CHARS) {
|
|
133
|
+
text = `...${text.slice(text.length - (GIT_FAILURE_TAIL_MAX_CHARS - 3))}`;
|
|
134
|
+
}
|
|
135
|
+
return text;
|
|
136
|
+
}
|
|
99
137
|
/**
|
|
100
138
|
* Read the head of `origin/<branch>` WITHOUT mutating anything.
|
|
101
139
|
*
|
|
@@ -207,17 +245,31 @@ export async function performExactIndexScopeCut(deps, access, request) {
|
|
|
207
245
|
// local checkout, no branch, no worktree — and deliberately not the GitHub
|
|
208
246
|
// App, which is `contents: read` and cannot create refs. Not a force push:
|
|
209
247
|
// the refspec has no leading `+`, so it can only create.
|
|
248
|
+
//
|
|
249
|
+
// `--no-verify` skips the repository's own client-side pre-push hook (tests,
|
|
250
|
+
// Husky, pre-commit) for THIS push only. The push sends no new code: it only
|
|
251
|
+
// names a branch at a commit the server already indexed from origin. A hook
|
|
252
|
+
// here would run inside the launch, with the operator's inherited
|
|
253
|
+
// environment, while the server's cut hold is open, and a hook failure would
|
|
254
|
+
// block the cut for reasons unrelated to it. Server-side branch protection
|
|
255
|
+
// and rulesets still apply. Pushes that carry new code (worker and
|
|
256
|
+
// child-branch pushes) keep running their hooks.
|
|
210
257
|
const pushed = await runGit(deps, [
|
|
211
258
|
"push",
|
|
259
|
+
"--no-verify",
|
|
212
260
|
"origin",
|
|
213
261
|
`${cut.cut_commit_sha}:refs/heads/${featureBranch}`,
|
|
214
262
|
]);
|
|
215
263
|
if (pushed.exitCode !== 0) {
|
|
264
|
+
// Keep git's own words (redacted), so the cause is visible: a hook, a
|
|
265
|
+
// ruleset, a network error, or credentials.
|
|
266
|
+
const gitSaid = gitFailureTail(pushed, access.apiKey);
|
|
216
267
|
return {
|
|
217
268
|
ok: false,
|
|
218
269
|
kind: "push_failed",
|
|
219
270
|
failures: [
|
|
220
|
-
`Could not create origin/${featureBranch} at the canonical indexed commit ${cut.cut_commit_sha}
|
|
271
|
+
`Could not create origin/${featureBranch} at the canonical indexed commit ${cut.cut_commit_sha}.` +
|
|
272
|
+
(gitSaid === null ? "" : ` git said: ${gitSaid}`),
|
|
221
273
|
],
|
|
222
274
|
lease: cut,
|
|
223
275
|
expectedSha: cut.cut_commit_sha,
|
|
@@ -452,7 +452,7 @@ export function successRefusalReason(envelope) {
|
|
|
452
452
|
* order as the server's `derive_park_cause`; the server re-derives it and never
|
|
453
453
|
* lets this value widen what the rest of the envelope proves.
|
|
454
454
|
*/
|
|
455
|
-
export function deriveCompletionCause(envelope) {
|
|
455
|
+
export function deriveCompletionCause(envelope, options = {}) {
|
|
456
456
|
const reasons = new Set(envelope.insufficient_reasons);
|
|
457
457
|
if (reasons.has("unsupported_runtime"))
|
|
458
458
|
return "unsupported_completion_evidence";
|
|
@@ -485,6 +485,19 @@ export function deriveCompletionCause(envelope) {
|
|
|
485
485
|
return "verification_runner_unavailable";
|
|
486
486
|
if (envelope.verification === "failed")
|
|
487
487
|
return "required_check_failed";
|
|
488
|
+
// BAPI-1779 rank 7 — a covered job that ran out of time before finalization
|
|
489
|
+
// finished is unfinished required work, so the existing required-work park
|
|
490
|
+
// and its automatic continuation take it. Only the claimed job type decides:
|
|
491
|
+
// a missing type, `rebase` (a renewal-mode rebase also carries completion
|
|
492
|
+
// evidence) and `merge` never activate it. The server re-derives this with the
|
|
493
|
+
// job row's own type, so an older executor's `null` cause is fixed there.
|
|
494
|
+
if (typeof options.jobType === "string" &&
|
|
495
|
+
isCoveredJobType(options.jobType) &&
|
|
496
|
+
envelope.end_cause === "job_timeout" &&
|
|
497
|
+
envelope.finalization !== "ok" &&
|
|
498
|
+
envelope.finalization !== "not_required") {
|
|
499
|
+
return "required_work_incomplete";
|
|
500
|
+
}
|
|
488
501
|
// Nothing completion-specific is wrong: an unmet finalization (or success)
|
|
489
502
|
// keeps its existing executor/server classification.
|
|
490
503
|
return null;
|
|
@@ -2,6 +2,30 @@ export const PUSH_TIMEOUT_MS = 180_000;
|
|
|
2
2
|
export const PUSH_AUTH_FAILURE_RE = /authentication failed|could not read username|permission denied|terminal prompts disabled|invalid username or password|returned error: 403|requested url returned error: 401/i;
|
|
3
3
|
const PUSH_LEASE_FAILURE_RE = /stale info|\[rejected\]|non-fast-forward|fetch first/i;
|
|
4
4
|
const SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
|
|
5
|
+
/**
|
|
6
|
+
* The ONE lease expression the executor builds (BAPI-1686): create-only leaves
|
|
7
|
+
* the expected value empty, otherwise the remote ref must hold exactly `baseSha`.
|
|
8
|
+
* `guardedFastForwardPush` pushes `HEAD`; BAPI-1781's rename-aside pushes an
|
|
9
|
+
* exact SHA through {@link leasedRefPushArgs}. There is no unleased variant.
|
|
10
|
+
*/
|
|
11
|
+
function leasedPushArgv(destination, creating, baseSha, source) {
|
|
12
|
+
return ["push", "--no-verify", "--porcelain",
|
|
13
|
+
`--force-with-lease=${destination}:${creating ? "" : baseSha}`, "origin", `${source}:${destination}`];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* BAPI-1781 — a rename-aside's leased push: the create-only backup
|
|
17
|
+
* (`expected === ""`) or the move of an ended run's branch (`expected` = the
|
|
18
|
+
* exact old tip). Returns `null` unless `sha` and a non-empty `expected` are full
|
|
19
|
+
* 40-hex SHAs and `ref` is a safe branch name.
|
|
20
|
+
*/
|
|
21
|
+
export function leasedRefPushArgs(sha, ref, expected) {
|
|
22
|
+
const full = /^[0-9a-f]{40}$/;
|
|
23
|
+
if (!full.test(sha) || (expected !== "" && !full.test(expected)))
|
|
24
|
+
return null;
|
|
25
|
+
if (!isSafePublicationBranch(ref))
|
|
26
|
+
return null;
|
|
27
|
+
return leasedPushArgv(`refs/heads/${ref}`, expected === "", expected, sha);
|
|
28
|
+
}
|
|
5
29
|
export function isSafePublicationBranch(branch) {
|
|
6
30
|
return branch.length > 0 && !branch.startsWith("-") && !branch.startsWith("/") &&
|
|
7
31
|
!branch.endsWith("/") && !branch.endsWith(".") && branch !== "@" &&
|
|
@@ -109,8 +133,7 @@ export async function guardedFastForwardPush(input) {
|
|
|
109
133
|
if ((!input.mayMutate() || input.signal?.aborted) || input.remainingMs() <= 0)
|
|
110
134
|
return refuse("timeout");
|
|
111
135
|
const destination = `refs/heads/${input.branch}`;
|
|
112
|
-
const push = await git(
|
|
113
|
-
`--force-with-lease=${destination}:${creating ? "" : baseSha}`, "origin", `HEAD:${destination}`]);
|
|
136
|
+
const push = await git(leasedPushArgv(destination, creating, baseSha, "HEAD"));
|
|
114
137
|
const text = `${push.stdout}\n${push.stderr}`;
|
|
115
138
|
if (timedOut || push.exitCode === 124 || /timed out|timeout/i.test(text))
|
|
116
139
|
return refuse("timeout");
|
|
@@ -66,6 +66,7 @@ import { buildLocalMergeChildEnv, sanitizeLocalMergeOutput, } from "../conductor
|
|
|
66
66
|
import { resolveMergeCredentialAtAction } from "../conductor/stored-merge-credential.js";
|
|
67
67
|
import { EPIC_INTEGRATION_PR_READ_TIMEOUT_MS, createProductionEpicIntegrationGhRunner, ensureEpicIntegrationPullRequest, } from "../epic-integration-pr.js";
|
|
68
68
|
import { EPIC_WORKAROUNDS_DIR_PATH } from "../epic-workarounds-path.js";
|
|
69
|
+
import { captureExecutorMergeIndex, stageExecutorAllowedTree, unstageExecutorExcludedPaths, } from "./permissions.js";
|
|
69
70
|
import { HANDOFF_REPORT_DETAIL_CODES, HANDOFF_REPORT_PAYLOAD_VERSION, HANDOFF_REPORT_SHAPES, INTEGRATION_ACTION_OPERATIONS, INTEGRATION_ACTION_OUTCOMES, INTEGRATION_ACTION_PROTOCOL_VERSION, MAX_HANDOFF_REPORT_COMMENT_CHARS, } from "./types.js";
|
|
70
71
|
/** The route prefix, mirrored from `api/routes/__init__.py`. */
|
|
71
72
|
export const INTEGRATION_ACTION_ROUTE_PREFIX = "/epic-integration-actions";
|
|
@@ -918,6 +919,9 @@ export function createIntegrationCorrectionDriver(action, deps) {
|
|
|
918
919
|
const baseSha = action.expected_base_sha;
|
|
919
920
|
const remoteUrl = `https://github.com/${action.provider_repository}.git`;
|
|
920
921
|
const destination = `refs/heads/${action.epic_branch}`;
|
|
922
|
+
// BAPI-1732: the protected-path index state of THIS action's conflicted merge.
|
|
923
|
+
// `null` is "not captured", distinct from a captured empty snapshot.
|
|
924
|
+
let mergeSnapshot = null;
|
|
921
925
|
const git = async (ctx, args, timeoutMs = GIT_TIMEOUT_MS, env) => {
|
|
922
926
|
try {
|
|
923
927
|
const r = await deps.runCommand("git", args, {
|
|
@@ -1025,6 +1029,21 @@ export function createIntegrationCorrectionDriver(action, deps) {
|
|
|
1025
1029
|
await restore(ctx);
|
|
1026
1030
|
return finish(complete({ outcome: "failed", detailCode: "merge_start_failed" }));
|
|
1027
1031
|
}
|
|
1032
|
+
// The merge's own protected-path index entries, kept so the worker's
|
|
1033
|
+
// staging of host files can be undone without losing them.
|
|
1034
|
+
mergeSnapshot = null;
|
|
1035
|
+
let captured = null;
|
|
1036
|
+
try {
|
|
1037
|
+
captured = await captureExecutorMergeIndex((args) => git(ctx, args));
|
|
1038
|
+
}
|
|
1039
|
+
catch {
|
|
1040
|
+
captured = null;
|
|
1041
|
+
}
|
|
1042
|
+
if (captured === null) {
|
|
1043
|
+
await restore(ctx);
|
|
1044
|
+
return finish(complete({ outcome: "failed", detailCode: "merge_start_failed" }));
|
|
1045
|
+
}
|
|
1046
|
+
mergeSnapshot = captured;
|
|
1028
1047
|
}
|
|
1029
1048
|
return {
|
|
1030
1049
|
kind: "spawn_worker",
|
|
@@ -1043,11 +1062,44 @@ export function createIntegrationCorrectionDriver(action, deps) {
|
|
|
1043
1062
|
await restore(ctx);
|
|
1044
1063
|
return complete({ outcome: "failed", detailCode: "worker_rewrote_history" });
|
|
1045
1064
|
}
|
|
1046
|
-
|
|
1065
|
+
const commitFailed = async () => {
|
|
1066
|
+
await restore(ctx);
|
|
1067
|
+
return complete({ outcome: "failed", detailCode: "commit_failed" });
|
|
1068
|
+
};
|
|
1069
|
+
const snapshot = mergeSnapshot;
|
|
1070
|
+
if (isConflict && snapshot === null)
|
|
1071
|
+
return commitFailed();
|
|
1072
|
+
// Stage the allowed tree only; protected host paths never enter the commit.
|
|
1073
|
+
try {
|
|
1074
|
+
await stageExecutorAllowedTree((args) => git(ctx, args));
|
|
1075
|
+
}
|
|
1076
|
+
catch {
|
|
1077
|
+
return commitFailed();
|
|
1078
|
+
}
|
|
1079
|
+
// Conflicted protected paths belong to the worker's resolution: stage exactly
|
|
1080
|
+
// those, in a call of their own.
|
|
1081
|
+
if (snapshot !== null && snapshot.conflicted.size > 0) {
|
|
1082
|
+
const literal = Array.from(snapshot.conflicted, (p) => `:(top,literal)${p}`);
|
|
1083
|
+
// `-f`: these paths are tracked and unmerged, but `info/exclude` also names
|
|
1084
|
+
// them, and Git refuses an ignored path without it.
|
|
1085
|
+
const resolved = await git(ctx, ["add", "-f", "--", ...literal]);
|
|
1086
|
+
if (resolved.exitCode !== 0)
|
|
1087
|
+
return commitFailed();
|
|
1088
|
+
}
|
|
1089
|
+
try {
|
|
1090
|
+
await unstageExecutorExcludedPaths((args) => git(ctx, args), isConflict ? (snapshot ?? undefined) : undefined);
|
|
1091
|
+
}
|
|
1092
|
+
catch {
|
|
1093
|
+
return commitFailed();
|
|
1094
|
+
}
|
|
1047
1095
|
if (isConflict) {
|
|
1048
1096
|
const unmerged = await git(ctx, ["ls-files", "-u"]);
|
|
1097
|
+
if (unmerged.exitCode !== 0)
|
|
1098
|
+
return commitFailed();
|
|
1049
1099
|
const markers = await git(ctx, ["grep", "--cached", "-n", "-I", "-E", "^(<{7}|>{7})( |$)"]);
|
|
1050
|
-
if (
|
|
1100
|
+
if (markers.exitCode !== 0 && markers.exitCode !== 1)
|
|
1101
|
+
return commitFailed();
|
|
1102
|
+
if (unmerged.stdout.trim().length > 0 || markers.exitCode === 0) {
|
|
1051
1103
|
await restore(ctx);
|
|
1052
1104
|
return complete({ outcome: "failed", detailCode: "conflicts_unresolved" });
|
|
1053
1105
|
}
|
|
@@ -1058,6 +1110,8 @@ export function createIntegrationCorrectionDriver(action, deps) {
|
|
|
1058
1110
|
await restore(ctx);
|
|
1059
1111
|
return complete({ outcome: "failed", detailCode: "correction_no_change" });
|
|
1060
1112
|
}
|
|
1113
|
+
if (staged.exitCode !== 1)
|
|
1114
|
+
return commitFailed();
|
|
1061
1115
|
}
|
|
1062
1116
|
const message = isConflict
|
|
1063
1117
|
? `Merge ${action.base_branch} into ${action.epic_branch}`
|
|
@@ -82,7 +82,7 @@ import { CI_FIX_JOB_TYPE, renderCiFixOperatorNote, renderLocalEnvironmentLimits,
|
|
|
82
82
|
import { CORRECTION_INTENT_CAPABILITY, isRemainingWork, validateCorrectionIntent, } from "./correction-dispatch.js";
|
|
83
83
|
import { collectGitTelemetry, collectRemoteTrackingSha, createMcpSurfaceObserver, evaluatePreSpawnGitVerification, formatWorkerRateLimitAdvisory, normalizeMcpServerNames, } from "./observation.js";
|
|
84
84
|
import { failureReasonCode, isFailureReasonCode } from "./failure-reason-codes.js";
|
|
85
|
-
import { readCustomizedCommands, TERMINAL_CAPACITY_PROTOCOL_VERSIONS, TERMINAL_CAPACITY_RUNTIME_CONTRACTS, TERMINAL_CAPACITY_RUNTIMES, } from "./types.js";
|
|
85
|
+
import { parseRenameAsidePlan, readCustomizedCommands, RENAME_ASIDE_PLAN_PAYLOAD_KEY, RENAME_ASIDE_RESULT_KEY, TERMINAL_CAPACITY_PROTOCOL_VERSIONS, TERMINAL_CAPACITY_RUNTIME_CONTRACTS, TERMINAL_CAPACITY_RUNTIMES, } from "./types.js";
|
|
86
86
|
import { resolvePackagedRecipes } from "./packaged-recipe.js";
|
|
87
87
|
import { recordObservedPr, recordVerificationFacts, recordVerificationObservation, withDeliveryObservations, } from "./delivery-observations.js";
|
|
88
88
|
import { probeInstalledCorrectionHook } from "./preflight.js";
|
|
@@ -1107,6 +1107,50 @@ function readFencedResumeHead(payload) {
|
|
|
1107
1107
|
const head = raw.trim().toLowerCase();
|
|
1108
1108
|
return /^[0-9a-f]{40}$/.test(head) ? head : null;
|
|
1109
1109
|
}
|
|
1110
|
+
/**
|
|
1111
|
+
* BAPI-1781: the server's rename-aside plan, validated at the payload boundary and
|
|
1112
|
+
* bound to the job's claimed branch, for a fresh `implement`/`spec_review` only.
|
|
1113
|
+
* Absent or malformed degrades to `null`: the ordinary stale-branch guard applies.
|
|
1114
|
+
*/
|
|
1115
|
+
export function readRenameAsidePlan(job) {
|
|
1116
|
+
if (job.job_type !== "implement" && job.job_type !== "spec_review")
|
|
1117
|
+
return null;
|
|
1118
|
+
if (!job.payload || typeof job.payload !== "object")
|
|
1119
|
+
return null;
|
|
1120
|
+
const raw = job.payload[RENAME_ASIDE_PLAN_PAYLOAD_KEY];
|
|
1121
|
+
if (raw === undefined || raw === null)
|
|
1122
|
+
return null;
|
|
1123
|
+
const branch = resolveExecutorBranch(job);
|
|
1124
|
+
if (!branch.ok)
|
|
1125
|
+
return null;
|
|
1126
|
+
return parseRenameAsidePlan(raw, branch.branch);
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* BAPI-1781: a client view whose `complete` carries the executor-owned
|
|
1130
|
+
* rename-aside confirmation as `result.rename_aside`, set last so worker-authored
|
|
1131
|
+
* result data cannot replace it. `fail` and every other call are unchanged, so a
|
|
1132
|
+
* failed job never claims a confirmation.
|
|
1133
|
+
*/
|
|
1134
|
+
export function withRenameAsideConfirmation(client, confirmation) {
|
|
1135
|
+
const confirmed = {
|
|
1136
|
+
old_branch: confirmation.old_branch,
|
|
1137
|
+
backup_name: confirmation.backup_name,
|
|
1138
|
+
old_run_id: confirmation.old_run_id,
|
|
1139
|
+
short_sha: confirmation.short_sha,
|
|
1140
|
+
};
|
|
1141
|
+
return new Proxy(client, {
|
|
1142
|
+
get(target, property, receiver) {
|
|
1143
|
+
if (property === "complete") {
|
|
1144
|
+
return (job, completion) => target.complete(job, {
|
|
1145
|
+
...completion,
|
|
1146
|
+
result: { ...completion.result, [RENAME_ASIDE_RESULT_KEY]: confirmed },
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
const value = Reflect.get(target, property, receiver);
|
|
1150
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
1151
|
+
},
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1110
1154
|
/**
|
|
1111
1155
|
* Prepare a job's worktree. A job the server dispatched as a parked-child
|
|
1112
1156
|
* CONTINUATION (BAPI-1300; `payload.continuation.retained_worktree === true`)
|
|
@@ -1358,6 +1402,9 @@ async function prepareSpawn(job, httpClient, options, deps, seams, preparation)
|
|
|
1358
1402
|
// BAPI-1530: forwarded separately from the claim's prior-attempt head so
|
|
1359
1403
|
// same-row retry preservation keeps its own semantics.
|
|
1360
1404
|
...(readFencedResumeHead(job.payload) ? { fencedImplementResumeHeadSha: readFencedResumeHead(job.payload) } : {}),
|
|
1405
|
+
// BAPI-1781: the server's dispatch-time rename-aside plan (fresh implement and
|
|
1406
|
+
// spec_review only). Spread only when present so other jobs keep their policy.
|
|
1407
|
+
...(!reuseExistingBranch && readRenameAsidePlan(job) ? { renameAsidePlan: readRenameAsidePlan(job) } : {}),
|
|
1361
1408
|
});
|
|
1362
1409
|
if (!wt.ok) {
|
|
1363
1410
|
await httpClient.fail(job, jobWorktreeFailure(wt));
|
|
@@ -1379,6 +1426,7 @@ async function prepareSpawn(job, httpClient, options, deps, seams, preparation)
|
|
|
1379
1426
|
...(wt.publication ? { publication: wt.publication } : {}),
|
|
1380
1427
|
...(wt.priorWork ? { priorWork: wt.priorWork } : {}),
|
|
1381
1428
|
...(focusedRebase ? { focusedRebase } : {}),
|
|
1429
|
+
...("renameAside" in wt && wt.renameAside ? { renameAside: wt.renameAside } : {}),
|
|
1382
1430
|
};
|
|
1383
1431
|
}
|
|
1384
1432
|
// No explicit/synthesized prompt: render the structured `payload.prompt_spec`
|
|
@@ -1403,6 +1451,7 @@ async function prepareSpawn(job, httpClient, options, deps, seams, preparation)
|
|
|
1403
1451
|
expectedHeadSha: wt.expectedHeadSha,
|
|
1404
1452
|
...(wt.publication ? { publication: wt.publication } : {}),
|
|
1405
1453
|
...(wt.priorWork ? { priorWork: wt.priorWork } : {}),
|
|
1454
|
+
...("renameAside" in wt && wt.renameAside ? { renameAside: wt.renameAside } : {}),
|
|
1406
1455
|
};
|
|
1407
1456
|
}
|
|
1408
1457
|
catch (err) {
|
|
@@ -1643,9 +1692,11 @@ async function readFocusedRebaseStartTip(deps, worktreePath, branch, remainingMs
|
|
|
1643
1692
|
* BAPI-1311 — run the focused rebase's post-push wait and, unless it is `ready`,
|
|
1644
1693
|
* report the job's ONE terminal outcome.
|
|
1645
1694
|
*
|
|
1646
|
-
* Returns `null` when the wait is `ready
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1695
|
+
* Returns `null` when the wait is `ready` — including BAPI-1780's CI-deferred
|
|
1696
|
+
* `ready` (verified push, required checks still pending with none failed): the
|
|
1697
|
+
* caller then submits the ordinary `/complete` exactly once, and the server's
|
|
1698
|
+
* completion verifier re-reads the provider as the final authority. Every other
|
|
1699
|
+
* ending is reported here, once:
|
|
1649
1700
|
*
|
|
1650
1701
|
* - a PROVEN failure (red required check, closed or conflicting pull request, a
|
|
1651
1702
|
* moved number/head/head branch/base) → `ContractError.RebaseNotVerified`, the
|
|
@@ -1694,7 +1745,10 @@ async function superviseFocusedRebaseWait(params) {
|
|
|
1694
1745
|
platform: deps.platform,
|
|
1695
1746
|
readFile: deps.readFile,
|
|
1696
1747
|
stat: deps.stat,
|
|
1697
|
-
}
|
|
1748
|
+
},
|
|
1749
|
+
// BAPI-1527: the rebase's own required-check list, so a repository with no
|
|
1750
|
+
// CI check cache is still read from live provider evidence.
|
|
1751
|
+
params.context.requiredChecks);
|
|
1698
1752
|
const phase = await superviseDriverPhase({
|
|
1699
1753
|
job,
|
|
1700
1754
|
httpClient,
|
|
@@ -1712,7 +1766,6 @@ async function superviseFocusedRebaseWait(params) {
|
|
|
1712
1766
|
expectedBaseBranch: params.expectedBaseBranch,
|
|
1713
1767
|
readPullRequest: (timeoutMs) => readFocusedPullRequest(deps.runCommand, params.worktreePath, params.context.prNumber, { timeoutMs }),
|
|
1714
1768
|
pollChecks,
|
|
1715
|
-
...(params.readDelivery ? { readDelivery: params.readDelivery } : {}),
|
|
1716
1769
|
now: deps.now,
|
|
1717
1770
|
sleep: deps.sleep,
|
|
1718
1771
|
signal,
|
|
@@ -2188,6 +2241,10 @@ resolvedTimeoutSeconds) {
|
|
|
2188
2241
|
prep = await prepareSpawn(job, httpClient, jobOptions, deps, seams);
|
|
2189
2242
|
if (!prep.ok)
|
|
2190
2243
|
return prep.result;
|
|
2244
|
+
// BAPI-1781: from here every successful `/complete` for this job carries the
|
|
2245
|
+
// executor-owned rename-aside confirmation; failures never do.
|
|
2246
|
+
if (prep.renameAside)
|
|
2247
|
+
httpClient = withRenameAsideConfirmation(httpClient, prep.renameAside);
|
|
2191
2248
|
deps = executionDeps;
|
|
2192
2249
|
if (preparation)
|
|
2193
2250
|
prep = { ...prep, deadlineMs: deps.now() + preparation.remainingMs() };
|
|
@@ -4242,21 +4299,29 @@ async function runPreparedSpawn(params) {
|
|
|
4242
4299
|
// exited cleanly and finalization PROVED its push is the origin tip, so what
|
|
4243
4300
|
// remains is evidence the server's completion verifier will read: the bound
|
|
4244
4301
|
// pull request at that head, mergeable, with its effective required checks
|
|
4245
|
-
// green
|
|
4246
|
-
//
|
|
4247
|
-
//
|
|
4248
|
-
//
|
|
4302
|
+
// green — or pending with none failed (DEFERRED CI below). The wait runs under
|
|
4303
|
+
// the SAME claim, heartbeat, dead-man, and timeout supervision a worker gets,
|
|
4304
|
+
// bounded by the job's ORIGINAL absolute deadline. It launches no worker,
|
|
4305
|
+
// enqueues nothing, and resets nothing: a pending check is never repaired
|
|
4306
|
+
// again. Only `ready` reaches `/complete`, once.
|
|
4249
4307
|
//
|
|
4250
|
-
//
|
|
4251
|
-
// exactly once below and leaving the server's completion
|
|
4252
|
-
// delivery guard as the authority:
|
|
4253
|
-
// - NO PUSH: the verified origin tip equals the tip recorded
|
|
4254
|
-
// so the worker only renewed evidence. Skip the
|
|
4255
|
-
// - DEFERRED CI: the wait
|
|
4256
|
-
//
|
|
4257
|
-
//
|
|
4258
|
-
//
|
|
4259
|
-
//
|
|
4308
|
+
// Two narrower successful ends, both still submitting the ordinary
|
|
4309
|
+
// `/complete` exactly once below and leaving the server's completion
|
|
4310
|
+
// contract and delivery guard as the authority:
|
|
4311
|
+
// - NO PUSH (BAPI-1473): the verified origin tip equals the tip recorded
|
|
4312
|
+
// before launch, so the worker only renewed evidence. Skip the wait.
|
|
4313
|
+
// - DEFERRED CI (BAPI-1780): the wait ends `ready` with `ciDeferred` once
|
|
4314
|
+
// the push is verified (same open PR, at the pushed head, bound head
|
|
4315
|
+
// branch and base, mergeable) and the required checks at that head are
|
|
4316
|
+
// readably pending or absent with none concluded non-success. It no
|
|
4317
|
+
// longer asks the server for renewed delivery evidence. This is a
|
|
4318
|
+
// successful rebase awaiting CI, not green CI or delivery completion.
|
|
4319
|
+
// A missing or unverified push still refuses (`pushed_head_unverified`), a
|
|
4320
|
+
// lost claim still abandons with no terminal mutation, and red checks,
|
|
4321
|
+
// identity changes, conflicts, unresolved mergeability, and unavailable reads
|
|
4322
|
+
// still stop the wait. Neither end is merge behavior: the merge guard keeps
|
|
4323
|
+
// the child in `merging` until readiness is `complete`, which needs green
|
|
4324
|
+
// checks at the head.
|
|
4260
4325
|
const focusedRebasePushedNothing = prep.focusedRebase !== undefined &&
|
|
4261
4326
|
focusedRebaseStartTip !== null &&
|
|
4262
4327
|
typeof finalization.pushedHeadSha === "string" &&
|
|
@@ -4270,14 +4335,6 @@ async function runPreparedSpawn(params) {
|
|
|
4270
4335
|
job, httpClient, options, jobOptions, deps, ownership, observation, seams, control,
|
|
4271
4336
|
context: prep.focusedRebase,
|
|
4272
4337
|
pushedHeadSha: finalization.pushedHeadSha ?? null,
|
|
4273
|
-
readDelivery: () => readDeliveryOutcomeForFinalization({
|
|
4274
|
-
job,
|
|
4275
|
-
branch,
|
|
4276
|
-
deps,
|
|
4277
|
-
seams,
|
|
4278
|
-
remainingMs,
|
|
4279
|
-
resolvedBaseUrl: options.resolvedBaseUrl,
|
|
4280
|
-
}),
|
|
4281
4338
|
expectedBaseBranch: effectiveBaseBranch,
|
|
4282
4339
|
worktreePath,
|
|
4283
4340
|
jobDeadlineMs,
|
|
@@ -4629,6 +4686,7 @@ async function runCoveredAttempt(params) {
|
|
|
4629
4686
|
lifecycleSupported: true,
|
|
4630
4687
|
optionalWatchers: readOptionalWatchers(job.payload),
|
|
4631
4688
|
obligations,
|
|
4689
|
+
jobType: job.job_type,
|
|
4632
4690
|
});
|
|
4633
4691
|
// --- Ownership persisted BEFORE the spawn (BAPI-1504) ---------------------------
|
|
4634
4692
|
// A job stamped with `cleanup_report.v1` stores `NULL` ownership only if no worker
|
|
@@ -4971,6 +5029,7 @@ async function runCoveredAttempt(params) {
|
|
|
4971
5029
|
...(facts.prSatisfied ? [obligations[1]] : []),
|
|
4972
5030
|
],
|
|
4973
5031
|
...(facts.verificationFacts ? { verificationFacts: facts.verificationFacts } : {}),
|
|
5032
|
+
endCause: processEndCause,
|
|
4974
5033
|
}),
|
|
4975
5034
|
end_cause: processEndCause,
|
|
4976
5035
|
});
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import path from "node:path";
|
|
27
27
|
import { execFile } from "node:child_process";
|
|
28
28
|
import { normalizeDeclaredTouchedFiles } from "../conductor/file-scope-guard.js";
|
|
29
|
+
import { LANGUAGE_CATALOG } from "../language-catalog.generated.js";
|
|
29
30
|
import { containedKind, containedText, object, readVerificationHints, validReference, validRepoPath, MAX_OPTIONAL_JSON_BYTES, } from "./verification-hints.js";
|
|
30
31
|
export { validTestReference } from "./verification-hints.js";
|
|
31
32
|
export const RECENTLY_FAILED_TESTS_PATH = ".conductor/recently-failed-tests.json";
|
|
@@ -82,14 +83,85 @@ function nulPaths(output) {
|
|
|
82
83
|
return output.split("\0").filter(Boolean);
|
|
83
84
|
}
|
|
84
85
|
const ordinal = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
86
|
+
const NAME_KINDS = new Set(["basename", "basename_prefix", "basename_suffix"]);
|
|
87
|
+
/**
|
|
88
|
+
* Python's `str.strip()` whitespace set. It adds U+001C-U+001F and U+0085 to, and
|
|
89
|
+
* omits U+FEFF from, what `String.prototype.trim()` removes, so `trim()` is not used.
|
|
90
|
+
*/
|
|
91
|
+
const PY_WHITESPACE = "\\t\\n\\v\\f\\r\\x1c-\\x1f \\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
92
|
+
const PY_STRIP = new RegExp(`^[${PY_WHITESPACE}]+|[${PY_WHITESPACE}]+$`, "g");
|
|
93
|
+
/** Maps only `A`-`Z` to `a`-`z`; never `toLowerCase()`, which folds non-ASCII too. */
|
|
94
|
+
function asciiFold(text) {
|
|
95
|
+
return text.replace(/[A-Z]/g, (ch) => String.fromCharCode(ch.charCodeAt(0) + 32));
|
|
96
|
+
}
|
|
97
|
+
function normalizeTestPath(file) {
|
|
98
|
+
const normalized = file.replace(/\\/g, "/").replace(PY_STRIP, "");
|
|
99
|
+
return normalized.startsWith("./") ? normalized.slice(2) : normalized;
|
|
100
|
+
}
|
|
101
|
+
function compareForm(convention, text) {
|
|
102
|
+
return convention.case_sensitive ? text : asciiFold(text);
|
|
103
|
+
}
|
|
104
|
+
function nameMatches(convention, basename) {
|
|
105
|
+
const name = compareForm(convention, basename);
|
|
106
|
+
const value = compareForm(convention, convention.value);
|
|
107
|
+
if (convention.kind === "basename")
|
|
108
|
+
return name === value;
|
|
109
|
+
if (convention.kind === "basename_suffix")
|
|
110
|
+
return name.endsWith(value) && name.length > value.length;
|
|
111
|
+
if (convention.kind === "basename_prefix") {
|
|
112
|
+
if (!name.startsWith(value))
|
|
113
|
+
return false;
|
|
114
|
+
if (convention.extensions.length === 0)
|
|
115
|
+
return name.length > value.length;
|
|
116
|
+
return convention.extensions.some((extension) => {
|
|
117
|
+
const folded = compareForm(convention, extension);
|
|
118
|
+
return name.endsWith(folded) && name.length > value.length + folded.length;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Path-only classification, the TypeScript twin of Python `classify_test_path`.
|
|
125
|
+
* Name conventions outrank directory conventions; within each category catalog
|
|
126
|
+
* order decides. `conventions` is a test seam and defaults to the generated catalog.
|
|
127
|
+
*/
|
|
128
|
+
export function classifyTestPath(file, conventions = LANGUAGE_CATALOG.test_conventions) {
|
|
129
|
+
const segments = normalizeTestPath(file).split("/");
|
|
130
|
+
const basename = segments[segments.length - 1] ?? "";
|
|
131
|
+
if (!basename)
|
|
132
|
+
return null;
|
|
133
|
+
for (const convention of conventions) {
|
|
134
|
+
if (NAME_KINDS.has(convention.kind) && nameMatches(convention, basename)) {
|
|
135
|
+
return { conventionId: convention.id, basis: "name", role: convention.role };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const directories = segments.slice(0, -1).filter(Boolean);
|
|
139
|
+
if (directories.length > 0) {
|
|
140
|
+
for (const convention of conventions) {
|
|
141
|
+
if (convention.kind !== "segment")
|
|
142
|
+
continue;
|
|
143
|
+
const value = compareForm(convention, convention.value);
|
|
144
|
+
if (directories.some((segment) => compareForm(convention, segment) === value)) {
|
|
145
|
+
return { conventionId: convention.id, basis: "directory", role: convention.role };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
export function isTestPath(file) { return classifyTestPath(file) !== null; }
|
|
152
|
+
/**
|
|
153
|
+
* Runnable-target rule: classification is wider than runnability. Accept a
|
|
154
|
+
* name-matched `test` role file, or a lowercase `.rs` file under a test directory.
|
|
155
|
+
* Support files (`conftest.py`) and directory-only non-Rust files are classified
|
|
156
|
+
* but never inferred or declared as runnable targets.
|
|
157
|
+
*/
|
|
85
158
|
function testCandidate(file) {
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
if (/_test\.go$|_test\.rs$|(?:Test|Tests|IT)\.java$|_spec\.rb$/.test(base))
|
|
159
|
+
const match = classifyTestPath(file);
|
|
160
|
+
if (!match)
|
|
161
|
+
return false;
|
|
162
|
+
if (match.basis === "name" && match.role === "test")
|
|
91
163
|
return true;
|
|
92
|
-
return
|
|
164
|
+
return match.basis === "directory" && file.endsWith(".rs");
|
|
93
165
|
}
|
|
94
166
|
/** Proximity tiers for an inferred test candidate; lower is scanned first. */
|
|
95
167
|
const TIER_NEARBY_NAME = 0;
|