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): persist native severity so clearing a pin fully restores it (#1596)
[._.]/ Adam Eivyf752a91a0c1a
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex b71ed17178..5a24316e4a 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -334,8 +334,8 @@ describe('per-check severity override (#1596)', () => {it('getEnabledChecks threads the effective severity AND the raw override for the runner', () => {const target = flip(NAMING);const pinned = getEnabledChecks(checksSettings(NAMING, target), [NAMING])[0];- expect(pinned.severity).toBe(target); // effective → ctx.severityDefault base- expect(pinned.severityOverride).toBe(target); // raw → authoritative force-stamp+ expect(pinned.severity).toBe(target); // effective level (used by the catalog UI)+ expect(pinned.severityOverride).toBe(target); // raw → authoritative force-stamp in the runnerconst unpinned = getEnabledChecks({}, [NAMING])[0];expect(unpinned.severity).toBe(getCheck(NAMING).severityDefault);expect(unpinned.severityOverride).toBeNull(); // no override → no force-stampdiff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.jsindex c89df2aa29..a8700e50d4 100644--- a/server/services/pipeline/editorial/checkRunner.js+++ b/server/services/pipeline/editorial/checkRunner.js@@ -552,14 +552,16 @@ export async function runEditorialChecks(seriesId, options = {}) {// must dismiss their now-stale prior open comments.const deterministicRanIds = new Set();let canceled = false;- for (const { check, config, severity, severityOverride } of enabledResolved) {+ for (const { check, config, severityOverride } of enabledResolved) {if (signal?.aborted) { canceled = true; break; }onProgress?.({ type: 'check:start', checkId: check.id, label: check.label });- // `severity` is the effective per-check level (#1596): the user's stored- // override or the registry default. It seeds `ctx.severityDefault` so checks- // that escalate FROM the default honor the override. Fall back to the- // registry default if a pair somehow arrives without one (defensive).- const ctx = { ...baseCtx, config, severityDefault: severity || check.severityDefault };+ // Run every check with its NATIVE default severity (#1596). A per-check+ // override is applied AUTHORITATIVELY as a post-stamp below rather than via+ // ctx, so escalation / LLM per-finding severities are computed natively and+ // preserved as `nativeSeverity` — which lets a later "reset to Default"+ // restore the true native level on carried findings (even ones that don't+ // re-surface).+ const ctx = { ...baseCtx, config, severityDefault: check.severityDefault };// Boundary try/catch: a check's run() calls into arbitrary logic / LLM// providers — one bad check must not abort the whole pass (mirrors the// per-comment fix guard in seriesAutopilot.runEditorial).@@ -571,18 +573,21 @@ export async function runEditorialChecks(seriesId, options = {}) {}const raw = (await check.run(ctx)) || [];const sourceContentHash = fingerprintForCheck(check, resolvedSources);- // A pinned per-check severity (#1596) is AUTHORITATIVE: force every finding- // to the chosen level so the pin is consistent across all check kinds —- // including LLM checks (which emit their own per-finding severity) and- // explicit-severity deterministic checks (e.g. lettering's overflowSeverity),- // not just escalation-from-default ones. No override → keep the emitted- // severity untouched, preserving each check's native per-finding nuance.- const stamped = raw.map((f) => ({- ...f,- ...(severityOverride ? { severity: severityOverride } : {}),- checkId: check.id,- sourceContentHash,- }));+ // Stamp each finding with its NATIVE severity (the check's own escalated /+ // LLM-emitted level, or the registry default fallback) AND its EFFECTIVE+ // severity: a pin (#1596) is authoritative across every check kind, else+ // the native level stands. Carrying `nativeSeverity` lets the review-seed+ // layer re-grade a carried finding back to native when a pin is cleared.+ const stamped = raw.map((f) => {+ const nativeSeverity = ['high', 'medium', 'low'].includes(f.severity) ? f.severity : check.severityDefault;+ return {+ ...f,+ nativeSeverity,+ severity: severityOverride || nativeSeverity,+ checkId: check.id,+ sourceContentHash,+ };+ });findings.push(...stamped);// A deterministic check is a pure function of its sources, so a finding it// no longer produces is genuinely resolved (not provider variance) — mark itdiff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.jsindex a5c19bd6ab..7d89ea3b38 100644--- a/server/services/pipeline/editorial/checkRunner.test.js+++ b/server/services/pipeline/editorial/checkRunner.test.js@@ -165,6 +165,8 @@ describe('runEditorialChecks', () => {const infoDump = result.findings.filter((f) => f.checkId === 'prose.info-dumping');expect(infoDump.length).toBeGreaterThan(0);expect(infoDump.every((f) => f.severity === 'high')).toBe(true);+ // The native (LLM-emitted) level is preserved so clearing the pin can restore it.+ expect(infoDump.every((f) => f.nativeSeverity === 'medium')).toBe(true);});it('keeps the native per-finding severity when a check has no severity override', async () => {@@ -172,6 +174,7 @@ describe('runEditorialChecks', () => {const infoDump = result.findings.filter((f) => f.checkId === 'prose.info-dumping');expect(infoDump.length).toBeGreaterThan(0);expect(infoDump.every((f) => f.severity === 'medium')).toBe(true); // the LLM's own level+ expect(infoDump.every((f) => f.nativeSeverity === 'medium')).toBe(true); // native == effective});it('passes active severity overrides to the seed so existing open findings re-grade', async () => {diff --git a/server/services/pipeline/manuscriptReview.js b/server/services/pipeline/manuscriptReview.jsindex 32a36e9b5e..52fad306b6 100644--- a/server/services/pipeline/manuscriptReview.js+++ b/server/services/pipeline/manuscriptReview.js@@ -91,12 +91,20 @@ function sanitizeComment(raw) {const problem = clampStr(raw.problem, 2000);if (!problem) return null;const category = clampStr(raw.category, 40) || 'other';+ const severity = ['high', 'medium', 'low'].includes(raw.severity) ? raw.severity : 'medium';return {id: typeof raw.id === 'string' && raw.id ? raw.id : `mrc-${randomUUID()}`,issueNumber: Number.isInteger(raw.issueNumber) ? raw.issueNumber : null,issueId: typeof raw.issueId === 'string' ? raw.issueId : null,stageId: typeof raw.stageId === 'string' ? raw.stageId : null,- severity: ['high', 'medium', 'low'].includes(raw.severity) ? raw.severity : 'medium',+ severity,+ // The check's NATIVE per-finding level (#1596), independent of any per-check+ // severity override. Carried so that clearing an override re-grades the+ // finding back to its true native level (not a guessed default). Defaults to+ // `severity` for legacy/older-peer comments written before this field (all of+ // which predate overrides, so native == severity is correct). Optional ++ // additive → the synced review doc stays backward-compatible.+ nativeSeverity: ['high', 'medium', 'low'].includes(raw.nativeSeverity) ? raw.nativeSeverity : severity,category,location: clampStr(raw.location, 200),problem,@@ -268,24 +276,28 @@ export async function seedReviewFromFindings(seriesId, findings, { runId = null,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+ // `match.severity` (the pin when set, else the native level). Adopt it.+ // 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.+ // non-resurfaced open; a pinned check can also produce zero findings).+ // 3. NOT re-surfaced and NOT pinned → fall back to the comment's stored+ // `nativeSeverity`, so CLEARING a pin re-grades even a non-resurfaced+ // open back to its true native level (not a guessed default). For a+ // never-pinned comment native == severity, so this is a no-op (no churn).const pin = pins && c.checkId && ['high', 'medium', 'low'].includes(pins[c.checkId]) ? pins[c.checkId] : null;- const nextSeverity = (match && match.severity) ? match.severity : pin;+ const carriedNative = ['high', 'medium', 'low'].includes(c.nativeSeverity) ? c.nativeSeverity : null;+ const nextSeverity = (match && match.severity) ? match.severity : (pin || carriedNative);if (nextSeverity && nextSeverity !== c.severity) {patch.severity = nextSeverity;refreshedCount += 1;}if (match) {+ // Keep the stored native level current so a future pin-clear restores the+ // latest run's native severity, not a stale one.+ if (match.nativeSeverity && match.nativeSeverity !== (c.nativeSeverity ?? null)) {+ patch.nativeSeverity = match.nativeSeverity;+ refreshedCount += 1;+ }if (!c.fix) {const section = c.issueNumber != null ? byNumber.get(c.issueNumber) : null;const fix = match.replace ? buildSeedFix({ ...c, replace: match.replace }, section) : null;diff --git a/server/services/pipeline/manuscriptReview.test.js b/server/services/pipeline/manuscriptReview.test.jsindex 93813ae884..255b1af9c6 100644--- a/server/services/pipeline/manuscriptReview.test.js+++ b/server/services/pipeline/manuscriptReview.test.js@@ -388,6 +388,27 @@ describe('manuscriptReview — authoritative severity override re-grade (#1596)'expect(second.comments[0].severity).toBe('low');});+ it('re-grades a NON-resurfaced open comment back to native when a pin is cleared', async () => {+ // Mirror the runner's stamp for a pinned finding: effective high, native low.+ await seedReviewFromFindings('ser-sev-clearmerge', [+ { problem: 'adverb density', anchorQuote: 'quickly', checkId: 'prose.adverb-density', severity: 'high', nativeSeverity: 'low' },+ ], { severityOverrides: { 'prose.adverb-density': 'high' } });+ // Pin cleared, and a later merge run produces NO finding for this check — the+ // lingering open must still drop from the old pin back to its stored native.+ const second = await seedReviewFromFindings('ser-sev-clearmerge', [], { mode: 'merge' });+ expect(second.comments).toHaveLength(1); // preserved in merge mode+ expect(second.comments[0].severity).toBe('low'); // restored from stored nativeSeverity+ });++ it('does NOT churn a never-pinned non-resurfaced comment (native == severity)', async () => {+ const first = await seedReviewFromFindings('ser-sev-stable', [finding('high')]);+ const stamp = first.comments[0].updatedAt;+ expect(first.comments[0].nativeSeverity).toBe('high'); // defaults to severity+ const second = await seedReviewFromFindings('ser-sev-stable', [], { mode: 'merge' });+ expect(second.comments[0].severity).toBe('high'); // unchanged+ expect(second.comments[0].updatedAt).toBe(stamp); // no rewrite+ });+it('does NOT churn updatedAt when the pinned level already matches', async () => {const first = await seedReviewFromFindings('ser-sev-nochurn', [finding('high')]);const stamp = first.comments[0].updatedAt;