Closes #3020 — which I filed **instead of** fixing, on a rationale that turned out to be wrong. I said the plugin had no scaffolding for faking `CePipelineStore` + `taskStore` together. It does: `_harness.ts` already builds a real `PluginContext` over a live PostgreSQL layer. The gap was **two missing readers on its task-store stub**, not missing infrastructure. I checked the harness only after filing. ## The defect `TERMINAL_COLUMNS` is `{in-review, done}`, and the reconciler advances a pipeline only when **every** current-stage board task is in that set. On a board whose review and completion lanes are renamed that's false for every task, permanently: - the pipeline never advances a stage - it never creates its outbound task - it sits `running` indefinitely Nothing errors, so it reads as work that hasn't finished. Unlike the display defects in this family (#3014, #3017), the CE flow actually **stops**. ## Shape The decision is extracted to an exported `isStageTerminalColumn` because it *is* the whole decision. Left private it could only be reached through a pipeline-state + links + board-tasks fixture, and the half that needed proving is that a renamed board resolves to its own lanes through this store. It uses `resolveReviewColumns` rather than re-deriving the union — that helper is the documented review **set** (`mergeOrchestration ∪ mergeBlocker ∪ humanReview`), so a board splitting those across a merge lane and a human lane is covered without this site drifting from it. ## Two things my first attempt got wrong **The fixture spelled traits in camelCase** — `{ trait: "humanReview" }`. Trait **ids** are kebab-case (`human-review`, `merge-blocker`, `wip`); the camelCase names are the resolved **flags**. Those columns therefore resolved to *no roles at all*, silently, because an unknown trait isn't an error. `complete` is spelled identically in both vocabularies, which is exactly what made the first run look like *"complete works, review is broken"* rather than *"the fixture is wrong"* — I nearly went debugging the production union. **The harness extension is additive** and inert until a test seeds it, so all 24 existing plugin suites see the previous shape. ## Measured | check | result | |---|---| | new suite | **4/4** | | reverting to the literal-only gate | fails **exactly 2** — the renamed-terminal case, and a board declaring a NON-terminal column named `done` — while the legacy control and the WIP/intake negative still pass | | plugin suite | **24 files, 184 tests green** | | `tsc` + all five gates | clean | That second row is the one that matters: the `done`-without-`complete` board is the only shape where a real resolution and a legacy fallback disagree, so it's what separates the fix from a lucky agreement. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
129 lines
4.4 KiB
JavaScript
129 lines
4.4 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 need both postgresSchema runtime values and Quality's
|
|
* process-group supervisor. Keep this alias implementation in untyped MJS so
|
|
* tsc stays inside the CLI root while esbuild follows the core source schema
|
|
* and bundles every runtime export without a private @fusion/core dependency.
|
|
*/
|
|
import * as postgresSchema from "../../core/src/postgres/schema/index.js";
|
|
|
|
export { 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/workflow-lifecycle-traits.js";
|
|
import { resolveWorkflowIrForTask } from "../../core/src/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);
|
|
},
|
|
};
|
|
}
|