## Summary
Wave 18 continues the package code-organization program after wave 17
domain folders (U4 Slice A from
`docs/plans/2026-07-14-001-refactor-package-code-organization-plan.md`).
### What changed
Peel **pure, behavior-preserving** helpers out of
`packages/engine/src/executor.ts` into domain modules under
`packages/engine/src/executor/`, with **stable re-exports** from
`executor.ts` so deep imports and `vi.mock("../executor.js")` keep
working.
| New module | Symbols |
|------------|---------|
| `executor/task-done-refusal.ts` | `evaluateTaskDoneRefusal`,
`determineRevisionResetStart`, skip-bypass refusal helper |
| `executor/workflow-feedback-paths.ts` |
`extractReferencedPathsFromWorkflowFeedback`,
`isAlwaysAllowedScopeLeakPath`, `workflowPathMatchesDeclaredScope` |
| `executor/workflow-step-verdict.ts` |
`FUSION_WORKFLOW_STEP_CONVENTIONS_PREAMBLE`, `parseWorkflowStepVerdict`
/ `parseWorkflowStepOutput`, step outcome types |
| `executor/await-input-parse.ts` | `parseAwaitInputSentinel`,
`parseAwaitInputQuestionToolCall` |
| `executor/no-commit-eligibility.ts` | `getNoCommitEligibilityReason`
(+ prompt heuristics) |
`executor.ts` live LOC ~**22817 → ~22427** (first pure-peel batch; more
peels needed to approach the 2k cap).
### Shims
- `old path` `executor.ts` public exports → `new path` `executor/*.ts` →
delete-when consumer deep-imports are re-pointed (not this PR)
### Test plan
- [x] `@fusion/engine` typecheck
- [x] Oracle: task-done refusal, skip-bypass, workflow malformed
verdict, scope-leak allowlist, executor-step-session, executor-prompt
- [x] `vitest --project=engine-core` (merge-gate curated suite)
- [ ] CI merge gate
**Stack:** wave17 (merged) → **this PR**
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Improved recognition of workflow outcomes from structured and
conversational responses.
* Added support for extracting questions from await-input responses and
tool calls.
* Improved workflow feedback handling for referenced files and declared
scope patterns.
* Added clearer guidance for task execution, approvals, verification,
and available tools.
* **Bug Fixes**
* Prevented completion when required review approvals are missing or
revisions remain pending.
* Improved handling of workflows that legitimately require no code
changes.
* Added clearer refusal messages and more reliable revision restarts.
* Sanitized repository paths in Git remediation instructions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
138 lines
5.0 KiB
JavaScript
138 lines
5.0 KiB
JavaScript
import { spawn } from "node:child_process";
|
|
|
|
/*
|
|
* FNXC:BundledPlugins 2026-07-15-13:40:
|
|
* Clean CI typechecks the CLI before @fusion/core emits dist, but published
|
|
* bundled plugins import selected core runtime values through this alias
|
|
* (currently postgresSchema, AgentStore, and Quality's process supervisor).
|
|
* Keep this implementation in untyped MJS so tsc stays inside the CLI root
|
|
* while esbuild follows core source and bundles each required runtime export
|
|
* without a private @fusion/core dependency.
|
|
*/
|
|
import * as postgresSchema from "../../core/src/postgres/schema/index.js";
|
|
/*
|
|
* FNXC:BundledPlugins 2026-08-03-17:18:
|
|
* The bundled Todo plugin lists project agents through AgentStore. Re-export the source implementation from the runtime shim so clean CLI packaging does not leave a private @fusion/core runtime import unresolved.
|
|
*
|
|
* FNXC:BundledPlugins 2026-08-03-12:25:
|
|
* FN-8762 also needs AgentStore for create-task-from-item routes. A second import/export of the same binding broke lint (no-redeclare) and esbuild ("already been declared") after main merged two parallel shim fixes — keep a single AgentStore re-export.
|
|
*/
|
|
import { AgentStore } from "../../core/src/agents/agent-store.js";
|
|
|
|
export { AgentStore, postgresSchema };
|
|
|
|
/*
|
|
* FNXC:BundledPlugins 2026-07-31-09:55:
|
|
* Lifecycle ROLE resolution, re-exported for bundled plugins.
|
|
*
|
|
* A plugin that asks "is this card in a terminal lane?" must resolve the board's roles rather than
|
|
* compare against `done`/`archived`, or it stalls forever on a renamed board. That is what the
|
|
* compound-engineering reconciler now does — but this shim is what `@fusion/core` resolves to inside
|
|
* the bundled build, so an import it does not re-export is a hard esbuild failure ("No matching
|
|
* export"), not a runtime fallback. The plugin built fine in the workspace and broke only in the CLI
|
|
* bundle.
|
|
*
|
|
* Source paths, not the package barrel, for the reason above: esbuild follows core's source here and
|
|
* the CLI must not take a private @fusion/core dependency.
|
|
*/
|
|
import {
|
|
columnsWithFlag,
|
|
resolveReviewColumns,
|
|
} from "../../core/src/workflows/workflow-lifecycle-traits.js";
|
|
import { resolveWorkflowIrForTask } from "../../core/src/workflows/workflow-ir-resolver.js";
|
|
|
|
export { columnsWithFlag, resolveReviewColumns, resolveWorkflowIrForTask };
|
|
|
|
export const FUSION_RESTART_EXIT_CODE = 86;
|
|
|
|
export function superviseSpawn(command, args = [], options = {}) {
|
|
const killGraceMs = options.killGraceMs ?? 2_000;
|
|
const maxLifetimeMs = options.maxLifetimeMs;
|
|
const spawnOptions = { ...options };
|
|
delete spawnOptions.killGraceMs;
|
|
delete spawnOptions.maxLifetimeMs;
|
|
const processGroup = globalThis.process.platform !== "win32";
|
|
const child = spawn(command, [...args], { ...spawnOptions, detached: processGroup });
|
|
const pgid = processGroup && typeof child.pid === "number" ? child.pid : null;
|
|
let settled = false;
|
|
let resolveExit;
|
|
const waitExit = new Promise((resolve) => {
|
|
resolveExit = resolve;
|
|
});
|
|
|
|
const killProcess = (signal = "SIGTERM") => {
|
|
if (typeof child.pid !== "number") return;
|
|
try {
|
|
if (pgid != null) globalThis.process.kill(-pgid, signal);
|
|
else child.kill(signal);
|
|
} catch {
|
|
try {
|
|
child.kill(signal);
|
|
} catch {
|
|
// FNXC:Quality 2026-07-15-13:40: A concurrently exited child needs no further cancellation action.
|
|
}
|
|
}
|
|
};
|
|
|
|
let lifetimeTimer = null;
|
|
if (typeof maxLifetimeMs === "number" && Number.isFinite(maxLifetimeMs) && maxLifetimeMs > 0) {
|
|
lifetimeTimer = globalThis.setTimeout(() => {
|
|
if (settled) return;
|
|
killProcess("SIGTERM");
|
|
const escalationTimer = globalThis.setTimeout(() => {
|
|
if (!settled) killProcess("SIGKILL");
|
|
}, killGraceMs);
|
|
escalationTimer.unref?.();
|
|
}, maxLifetimeMs);
|
|
lifetimeTimer.unref?.();
|
|
}
|
|
|
|
child.once("close", (code, signal) => {
|
|
settled = true;
|
|
if (lifetimeTimer) globalThis.clearTimeout(lifetimeTimer);
|
|
resolveExit?.({ code, signal });
|
|
});
|
|
// FNXC:Quality 2026-07-15-13:40: Spawn failures must not crash a bundled plugin; close settles waitExit.
|
|
child.on("error", () => {});
|
|
|
|
return {
|
|
pid: child.pid,
|
|
pgid,
|
|
child,
|
|
kill(signal = "SIGTERM") {
|
|
if (settled) return;
|
|
killProcess(signal);
|
|
if (signal === "SIGTERM") {
|
|
const escalationTimer = globalThis.setTimeout(() => {
|
|
if (!settled) killProcess("SIGKILL");
|
|
}, killGraceMs);
|
|
escalationTimer.unref?.();
|
|
}
|
|
},
|
|
waitExit() {
|
|
return waitExit;
|
|
},
|
|
};
|
|
}
|
|
|
|
export const ProcessSupervisor = { superviseSpawn };
|
|
export const WORKFLOW_EXTENSION_SCHEMA_VERSION = 1;
|
|
|
|
export function workflowExtensionRegistryId(pluginId, extensionId) {
|
|
return `plugin:${pluginId}:${extensionId}`;
|
|
}
|
|
|
|
export function createBoardActionServices(store) {
|
|
return {
|
|
moveTask(input) {
|
|
return store.moveTask(input.taskId, input.column, {
|
|
preserveProgress: input.preserveProgress,
|
|
moveSource: input.source ?? "user",
|
|
});
|
|
},
|
|
updateTask(input) {
|
|
return store.updateTask(input.taskId, input.updates);
|
|
},
|
|
};
|
|
}
|