Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): migrate new info-dumping stage; skip seed on cancel

[._.]/ Adam Eivy890aafdc67e4
diff --git a/scripts/migrations/091-editorial-info-dumping-stage.js b/scripts/migrations/091-editorial-info-dumping-stage.js
new file mode 100644
index 0000000000..e7f2a4adf9
--- /dev/null
+++ b/scripts/migrations/091-editorial-info-dumping-stage.js
@@ -0,0 +1,75 @@
+/**
+ * Seed the `pipeline-editorial-info-dumping` stage into existing installs (#1284).
+ *
+ * Mirrors `090-script-verify-stage.js`: copies the `.md` template from
+ * `data.reference/prompts/stages/` and merges the stage-config entry into
+ * `data/prompts/stage-config.json`. Boot runs migrations (server/index.js) but
+ * NOT `setup-data.js`, so an upgrade that pulls + `pm2 restart`s (rather than
+ * running `update.sh`) would otherwise leave the new editorial info-dumping
+ * stage unseeded and the `prose.info-dumping` editorial check would throw
+ * "Stage not found" the first time it runs.
+ */
+
+import { access, copyFile, mkdir, readFile, writeFile, constants } from 'fs/promises';
+import { dirname, join } from 'path';
+
+const FILENAME = 'pipeline-editorial-info-dumping.md';
+const STAGE_KEY = 'pipeline-editorial-info-dumping';
+
+export default {
+ async up({ rootDir }) {
+ const stagesDir = join(rootDir, 'data', 'prompts', 'stages');
+ await mkdir(stagesDir, { recursive: true });
+
+ const dataPath = join(stagesDir, FILENAME);
+ const samplePath = join(rootDir, 'data.reference', 'prompts', 'stages', FILENAME);
+
+ const exists = await access(dataPath, constants.F_OK).then(() => true, () => false);
+ if (exists) {
+ console.log(`📝 pipeline-editorial-info-dumping prompt: already present`);
+ } else {
+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);
+ if (!sampleExists) {
+ console.warn(`⚠️ pipeline-editorial-info-dumping: sample missing for ${FILENAME} — skipping copy`);
+ } else {
+ try {
+ await copyFile(samplePath, dataPath);
+ console.log(`✅ seeded ${FILENAME}`);
+ } catch (err) {
+ console.warn(`⚠️ pipeline-editorial-info-dumping: copy failed for ${FILENAME}: ${err.message}`);
+ }
+ }
+ }
+
+ const installedConfigPath = join(rootDir, 'data', 'prompts', 'stage-config.json');
+ const sampleConfigPath = join(rootDir, 'data.reference', 'prompts', 'stage-config.json');
+ const sampleConfigExists = await access(sampleConfigPath, constants.F_OK).then(() => true, () => false);
+ if (!sampleConfigExists) {
+ console.warn('⚠️ pipeline-editorial-info-dumping: data.reference stage-config.json missing — cannot resolve entry; skipping config write');
+ return;
+ }
+ try {
+ const sample = JSON.parse(await readFile(sampleConfigPath, 'utf8'));
+ const installedExists = await access(installedConfigPath, constants.F_OK).then(() => true, () => false);
+ const installed = installedExists
+ ? JSON.parse(await readFile(installedConfigPath, 'utf8'))
+ : { stages: {} };
+ installed.stages = installed.stages || {};
+ if (installed.stages[STAGE_KEY]) {
+ console.log(`📝 pipeline-editorial-info-dumping stage-config: already present`);
+ return;
+ }
+ if (!sample?.stages?.[STAGE_KEY]) {
+ console.warn(`⚠️ pipeline-editorial-info-dumping: sample stage-config missing ${STAGE_KEY} — skipping`);
+ return;
+ }
+ installed.stages[STAGE_KEY] = sample.stages[STAGE_KEY];
+ await mkdir(dirname(installedConfigPath), { recursive: true });
+ await writeFile(installedConfigPath, JSON.stringify(installed, null, 2) + '\n', 'utf8');
+ const action = installedExists ? 'merged' : 'created';
+ console.log(`📝 pipeline-editorial-info-dumping stage-config (${action}): 1 added`);
+ } catch (err) {
+ console.warn(`⚠️ pipeline-editorial-info-dumping: stage-config merge failed: ${err.message}`);
+ }
+ },
+};
diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.js
index e59a290277..ff44538104 100644
--- a/server/services/pipeline/editorial/checkRunner.js
+++ b/server/services/pipeline/editorial/checkRunner.js
@@ -102,13 +102,19 @@ export async function runEditorialChecks(seriesId, options = {}) {
perCheck.push({ checkId: check.id, error: message });
onProgress?.({ type: 'check:complete', checkId: check.id, error: message });
}
+ // Re-check AFTER the (possibly long-running LLM) check so a cancellation
+ // during the final check is caught before the seed below — otherwise a
+ // cancel mid-run would still persist the partial findings.
+ if (signal?.aborted) { canceled = true; break; }
}
// Seed in 'merge' mode (never 'fresh'): a per-series seed of only the editorial
// checks' findings must not auto-dismiss completeness or other-check open
// comments. Merge dedups via findingKey (which now includes checkId) and keeps
- // dismissed findings suppressed per-check.
- if (findings.length) {
+ // dismissed findings suppressed per-check. Skip entirely on cancellation — a
+ // canceled run emits a `canceled` terminal event and must not mutate the
+ // review with partial findings collected before the abort.
+ if (findings.length && !canceled) {
await seedReviewFromFindings(seriesId, findings, { runId, mode: 'merge' });
}
return { runId, findings, perCheck, canceled };
diff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.js
index 73b01c7720..5c84fb968b 100644
--- a/server/services/pipeline/editorial/checkRunner.test.js
+++ b/server/services/pipeline/editorial/checkRunner.test.js
@@ -117,6 +117,16 @@ describe('runEditorialChecks', () => {
expect(seedReviewFromFindings).not.toHaveBeenCalled();
});
+ it('skips seeding when canceled mid-run (no partial review mutation)', async () => {
+ // Abort during the LLM check; the deterministic naming check already
+ // collected findings, but a canceled run must not persist them.
+ const controller = new AbortController();
+ runStagedLLM.mockImplementationOnce(async () => { controller.abort(); return { runId: 'x', content: { findings: [] } }; });
+ const result = await runEditorialChecks('s1', { signal: controller.signal });
+ expect(result.canceled).toBe(true);
+ expect(seedReviewFromFindings).not.toHaveBeenCalled();
+ });
+
it('one failing check does not abort the pass', async () => {
runStagedLLM.mockRejectedValueOnce(new Error('provider down'));
const result = await runEditorialChecks('s1');