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): don't feed stale outline into panel digest; clear snapshot on no-content

[._.]/ Adam Eivy3e5f0c27c36c
diff --git a/server/services/pipeline/readerPanel.js b/server/services/pipeline/readerPanel.js
index c119bc98e5..91dce7ef2c 100644
--- a/server/services/pipeline/readerPanel.js
+++ b/server/services/pipeline/readerPanel.js
@@ -19,6 +19,7 @@
*/
import { join } from 'path';
+import { rm } from 'fs/promises';
import { PATHS, atomicWrite, ensureDir, tryReadFile, safeJSONParse } from '../../lib/fileUtils.js';
import { runStagedLLM } from '../../lib/stageRunner.js';
import {
@@ -55,6 +56,10 @@ async function saveSnapshot(snapshot) {
await atomicWrite(snapshotPath(snapshot.seriesId), snapshot);
}
+async function removeSnapshot(seriesId) {
+ await rm(snapshotPath(seriesId), { force: true }).catch(() => {});
+}
+
const personaStage = (personaId) => `pipeline-panel-${personaId}`;
// Shared variables every persona prompt reads — the rendered digest + series meta.
@@ -130,14 +135,17 @@ export async function finalizePanel(seriesId, digest, responses, { runId = null
}
/**
- * Dismiss any prior reader-panel consensus findings when the panel can't produce
- * a fresh read (no analyzable content). A `fresh`-mode seed with no findings
- * auto-dismisses every open finding of this check id, so removing all content
- * doesn't strand old consensus findings as open (inflating the health score). A
- * no-op when none exist.
+ * Handle a convene that has no analyzable content to read. Two cleanups so a
+ * later `GET /panel` doesn't surface obsolete state:
+ * 1. Dismiss any prior consensus findings — a `fresh`-mode seed with no findings
+ * auto-dismisses every open finding of this check id (so they don't linger
+ * open and inflate the health score). A no-op when none exist.
+ * 2. Remove the stored snapshot — otherwise `getReaderPanel` keeps returning the
+ * old `status: 'complete'` personas after the content was removed.
*/
-export async function reconcileConsensusFindings(seriesId, { runId = null } = {}) {
+export async function clearReaderPanel(seriesId, { runId = null } = {}) {
await seedReviewFromFindings(seriesId, [], { runId, mode: 'fresh', checkId: CONSENSUS_CHECK_ID });
+ await removeSnapshot(seriesId);
}
// Re-hash the current issue content to decide whether a stored panel is stale
diff --git a/server/services/pipeline/readerPanel.test.js b/server/services/pipeline/readerPanel.test.js
index b920f76960..7f8815094e 100644
--- a/server/services/pipeline/readerPanel.test.js
+++ b/server/services/pipeline/readerPanel.test.js
@@ -8,6 +8,9 @@ const atomicWrite = vi.fn(async () => {});
const ensureDir = vi.fn(async () => {});
const tryReadFile = vi.fn(async () => null);
const computeSourceContentHash = vi.fn(async () => 'hash-current');
+const rm = vi.fn(async () => {});
+
+vi.mock('fs/promises', () => ({ rm: (...a) => rm(...a) }));
vi.mock('../../lib/fileUtils.js', () => ({
PATHS: { data: '/tmp/panel-test-data' },
@@ -25,7 +28,7 @@ vi.mock('./manuscriptReview.js', () => ({
seedReviewFromFindings: (...a) => seedReviewFromFindings(...a),
}));
-const { finalizePanel, getReaderPanel, reconcileConsensusFindings } = await import('./readerPanel.js');
+const { finalizePanel, getReaderPanel, clearReaderPanel } = await import('./readerPanel.js');
// Build a persona response with a given per-question citation set.
function persona(id, cites = {}) {
@@ -42,6 +45,7 @@ beforeEach(() => {
seedReviewFromFindings.mockClear();
atomicWrite.mockClear();
ensureDir.mockClear();
+ rm.mockClear();
tryReadFile.mockReset().mockResolvedValue(null);
computeSourceContentHash.mockReset().mockResolvedValue('hash-current');
});
@@ -79,10 +83,12 @@ describe('finalizePanel', () => {
});
});
-describe('reconcileConsensusFindings', () => {
- it('fresh-seeds an empty finding set to dismiss stale consensus findings', async () => {
- await reconcileConsensusFindings('ser-3', { runId: 'run-3' });
+describe('clearReaderPanel', () => {
+ it('fresh-seeds an empty finding set AND removes the stored snapshot', async () => {
+ await clearReaderPanel('ser-3', { runId: 'run-3' });
expect(seedReviewFromFindings).toHaveBeenCalledWith('ser-3', [], { runId: 'run-3', mode: 'fresh', checkId: 'reader-panel.consensus' });
+ expect(rm).toHaveBeenCalledTimes(1);
+ expect(rm.mock.calls[0][0]).toContain('ser-3.json');
});
});
diff --git a/server/services/pipeline/readerPanelDigest.js b/server/services/pipeline/readerPanelDigest.js
index ec9ce89e19..c7d22c57e2 100644
--- a/server/services/pipeline/readerPanelDigest.js
+++ b/server/services/pipeline/readerPanelDigest.js
@@ -156,8 +156,13 @@ export async function buildDigestForSeries(seriesId, { issues: issuesArg, series
seriesArg !== undefined ? seriesArg : getSeries(seriesId).catch(() => null),
getSceneSegmentation(seriesId).catch(() => ({ scenes: [] })),
]);
+ // Only trust scene summaries from a CURRENT outline. A stale outline (manuscript
+ // edited since it was generated) would leak old summaries into the digest while
+ // the panel's sourceContentHash — which covers only issue text — still reports
+ // the panel as current; fall back to text-derived summaries instead.
+ const usableScenes = segmentation.stale ? [] : (segmentation.scenes || []);
const scenesByNumber = new Map();
- for (const scene of segmentation.scenes || []) {
+ for (const scene of usableScenes) {
const num = scene?.issueNumber;
if (!Number.isInteger(num)) continue;
if (!scenesByNumber.has(num)) scenesByNumber.set(num, []);
diff --git a/server/services/pipeline/readerPanelRunner.js b/server/services/pipeline/readerPanelRunner.js
index 1c6744554e..dfb1db73de 100644
--- a/server/services/pipeline/readerPanelRunner.js
+++ b/server/services/pipeline/readerPanelRunner.js
@@ -13,7 +13,7 @@
import { createSseRunner } from '../../lib/sseUtils.js';
import { PANEL_PERSONAS } from '../../lib/editorial/panelDisagreement.js';
import { buildDigestForSeries } from './readerPanelDigest.js';
-import { runPersona, finalizePanel, reconcileConsensusFindings } from './readerPanel.js';
+import { runPersona, finalizePanel, clearReaderPanel } from './readerPanel.js';
const runner = createSseRunner({ logLabel: 'reader panel' });
@@ -38,9 +38,9 @@ export function startReaderPanel(seriesId, options = {}) {
return runner.start(seriesId, async ({ runId, record, broadcast }) => {
const digest = await buildDigestForSeries(seriesId);
if (!digest.issueCount) {
- // No analyzable content — clear any stale consensus findings a prior panel
- // seeded so they don't linger open after the content was removed.
- await reconcileConsensusFindings(seriesId, { runId });
+ // No analyzable content — clear any stale consensus findings AND the stored
+ // snapshot a prior panel left, so the panel reflects "nothing to read" now.
+ await clearReaderPanel(seriesId, { runId });
broadcast({ type: 'complete', runId, personas: 0, empty: true, completedAt: new Date().toISOString() });
return;
}