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 (simplify): honest trend-dedup comment, align severity fallback, reuse merged comments (#1316)

Adam Eivy26b9d6824212
diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.js
index 9b3a112163..651338f6f9 100644
--- a/server/services/pipeline/editorial/checkRunner.js
+++ b/server/services/pipeline/editorial/checkRunner.js
@@ -418,12 +418,13 @@ export async function runEditorialChecks(seriesId, options = {}) {
// 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' });
+ const review = await seedReviewFromFindings(seriesId, findings, { runId, mode: 'merge' });
// Record a revision-trend snapshot (#1316): this run is a revision boundary,
// so snapshot the post-seed open-finding counts for the health-trend ledger.
+ // Pass the just-merged comments so the ledger doesn't re-read the review file.
// Best-effort — a ledger write must never fail the check run (it's telemetry).
const gate = readReadinessGate(settings) || undefined;
- await recordTrendSnapshot(seriesId, { runId, gate }).catch((err) => {
+ await recordTrendSnapshot(seriesId, { runId, gate, comments: review.comments }).catch((err) => {
console.error(`⚠️ editorial trend snapshot failed — series=${String(seriesId).slice(0, 12)} ${err.message}`);
});
}
diff --git a/server/services/pipeline/editorialScore.js b/server/services/pipeline/editorialScore.js
index e5ec2456a3..486a654c3b 100644
--- a/server/services/pipeline/editorialScore.js
+++ b/server/services/pipeline/editorialScore.js
@@ -66,7 +66,11 @@ const ledgerPath = (seriesId) => join(healthDir(), `${seriesId}.json`);
// Pure scoring.
// ---------------------------------------------------------------------------
-const normalizeSeverity = (s) => (SEVERITIES.includes(s) ? s : 'low');
+// Default an unknown/absent severity to 'medium' to match manuscriptReview's
+// sanitizeComment (so the two never disagree on how an odd value scores). Stored
+// comments are always already high/medium/low, so this only guards a hand-edited
+// or older-peer record.
+const normalizeSeverity = (s) => (SEVERITIES.includes(s) ? s : 'medium');
const emptySeverityCounts = () => ({ high: 0, medium: 0, low: 0 });
// Resolve the readiness gate to one of READINESS_GATES, falling back to the
@@ -238,9 +242,15 @@ export async function getTrendLedger(seriesId) {
* Record a revision-trend snapshot for a series from its CURRENT review state.
* Called after each editorial-checks / completeness run (the run is the
* revision boundary). Reads the freshest review, derives the open-finding
- * counts, and appends a snapshot — de-duped by `runId` so a re-entrant seed for
- * the same run replaces rather than doubles the point. The ledger is capped at
- * MAX_TREND_SNAPSHOTS (oldest roll off).
+ * counts, and appends a snapshot.
+ *
+ * De-duped by `runId`: a second record for the SAME run id replaces its point
+ * rather than doubling it (defensive — guards a route + its SSE runner both
+ * firing for one invocation). NOTE this does NOT collapse a completeness pass and
+ * an editorial-checks pass into one point — those mint independent run ids, so a
+ * user who runs both in an editing cycle gets two trend points (completeness then
+ * checks), which is intended: each is a distinct revision boundary. A null runId
+ * always appends. The ledger is capped at MAX_TREND_SNAPSHOTS (oldest roll off).
*
* @param {string} seriesId
* @param {object} [opts]
@@ -276,6 +286,8 @@ export async function recordTrendSnapshot(seriesId, { runId = null, gate = DEFAU
snapshots: [...kept, snapshot].slice(-MAX_TREND_SNAPSHOTS),
};
await atomicWrite(ledgerPath(seriesId), next);
+ // Returned for callers/tests that want the appended point; the fire-and-forget
+ // triggers ignore it.
return snapshot;
});
}