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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex P2): re-grade re-surfaced findings when a pin is cleared (#1596)
[._.]/ Adam Eivyc18cb2d6aeff
diff --git a/server/services/pipeline/manuscriptReview.js b/server/services/pipeline/manuscriptReview.jsindex 78d1e450a1..32a36e9b5e 100644--- a/server/services/pipeline/manuscriptReview.js+++ b/server/services/pipeline/manuscriptReview.js@@ -265,20 +265,26 @@ export async function seedReviewFromFindings(seriesId, findings, { runId = null,}if (c.status !== 'open') return c;const patch = {};- // Authoritative per-check severity override (#1596): re-grade this open- // comment to its check's pinned level even if it did NOT re-surface this- // pass. LLM checks seed in 'merge' mode (a non-resurfaced open is preserved,- // not dismissed), and a pinned check can produce zero findings in a run, so- // the override would otherwise never reach those lingering opens — leaving- // the health score + severity gating on the stale level. Skipped when the- // check has no override (severity left exactly as persisted — no churn from- // run-to-run LLM severity variance on un-pinned checks).- const pinned = pins && c.checkId ? pins[c.checkId] : null;- if (pinned && ['high', 'medium', 'low'].includes(pinned) && pinned !== c.severity) {- patch.severity = pinned;+ const match = candidateByKey.get(findingKey(c));+ // Effective-severity re-grade (#1596), in priority order:+ // 1. A RE-SURFACED finding carries the run's EFFECTIVE severity in+ // `match.severity` — the pin when one is set (the runner force-stamps+ // it), else the check's native/default level. Adopting it keeps BOTH+ // setting AND clearing a pin authoritative: clearing a pin re-grades the+ // re-surfaced open back down to the native level (the findingKey ignores+ // severity, so the comment is carried, not re-appended).+ // 2. NOT re-surfaced but the check is still pinned → force the pinned level+ // so a pin reaches lingering opens too (LLM 'merge' mode preserves a+ // non-resurfaced open; a pinned check can also produce zero findings in a+ // run). A cleared pin has no map entry, so a non-resurfaced open keeps+ // its level until it next re-surfaces (then case 1 re-grades it) — the+ // inherent merge-mode lag, not specific to severity.+ const pin = pins && c.checkId && ['high', 'medium', 'low'].includes(pins[c.checkId]) ? pins[c.checkId] : null;+ const nextSeverity = (match && match.severity) ? match.severity : pin;+ if (nextSeverity && nextSeverity !== c.severity) {+ patch.severity = nextSeverity;refreshedCount += 1;}- const match = candidateByKey.get(findingKey(c));if (match) {if (!c.fix) {const section = c.issueNumber != null ? byNumber.get(c.issueNumber) : null;diff --git a/server/services/pipeline/manuscriptReview.test.js b/server/services/pipeline/manuscriptReview.test.jsindex e6ab59e704..93813ae884 100644--- a/server/services/pipeline/manuscriptReview.test.js+++ b/server/services/pipeline/manuscriptReview.test.js@@ -376,14 +376,16 @@ describe('manuscriptReview — authoritative severity override re-grade (#1596)'expect(second.comments[0].severity).toBe('high');});- it('leaves severity untouched (no churn) when the check has no override', async () => {- const first = await seedReviewFromFindings('ser-sev-nopin', [finding('low')]);- const stamp = first.comments[0].updatedAt;- // A re-surface carrying a different native severity but NO override must not- // flip the persisted level (avoids run-to-run LLM-variance churn).- const second = await seedReviewFromFindings('ser-sev-nopin', [finding('high')]);- expect(second.comments[0].severity).toBe('low'); // unchanged- expect(second.comments[0].updatedAt).toBe(stamp); // no rewrite+ it('re-grades a re-surfaced open comment back to native when a pin is CLEARED', async () => {+ // Pinned to high.+ await seedReviewFromFindings('ser-sev-clear', [finding('high')], {+ severityOverrides: { 'prose.adverb-density': 'high' },+ });+ // Pin cleared (no override map) and the finding re-surfaces at its native+ // 'low' level — the comment must drop back to 'low', not stay stuck at 'high'.+ const second = await seedReviewFromFindings('ser-sev-clear', [finding('low')]);+ expect(second.comments).toHaveLength(1);+ expect(second.comments[0].severity).toBe('low');});it('does NOT churn updatedAt when the pinned level already matches', async () => {