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 non-resurfaced findings of a pinned check (#1596)
[._.]/ Adam Eivy4aaab86fcf6a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 0e8635f914..690f0a4334 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -51,7 +51,7 @@## Editorial checks-- **[issue-1596] Override any editorial check's severity to match a series' house style — without touching code.** Every check ships a fixed default severity (e.g. `prose.adverb-density` defaults to `low`), but a literary-fiction series may want adverb density flagged `high` while an action series wants it `low`. Each check in the catalog now has a **Severity** selector: leave it on **Default** to use the registry value, or pin it to `high` / `medium` / `low`. A pin is **authoritative** — every finding that check raises is stamped with the chosen level, consistently across deterministic *and* LLM checks (a pin overrides both a check's escalation-from-default and an LLM's own per-finding severity, so "pin this check to low" actually means low everywhere). The pinned level feeds the editorial-health score and any severity-based autopilot gating exactly like a built-in level. Leaving a check on **Default** preserves its native per-finding nuance untouched. The override is backward-compatible and additive (absent → the check's `severityDefault`), and the catalog badge shows the effective level with a `*` marker when it's been overridden. (`server/lib/editorial/checkRegistry.js`, `server/routes/pipeline/editorial.js`, `server/services/pipeline/editorial/checkRunner.js`, `server/lib/validation.js`, `client/src/components/pipeline/editorial/EditorialCheckCard.jsx`, `client/src/pages/PipelineEditorialChecks.jsx`)+- **[issue-1596] Override any editorial check's severity to match a series' house style — without touching code.** Every check ships a fixed default severity (e.g. `prose.adverb-density` defaults to `low`), but a literary-fiction series may want adverb density flagged `high` while an action series wants it `low`. Each check in the catalog now has a **Severity** selector: leave it on **Default** to use the registry value, or pin it to `high` / `medium` / `low`. A pin is **authoritative** — every finding that check raises is stamped with the chosen level, consistently across deterministic *and* LLM checks (a pin overrides both a check's escalation-from-default and an LLM's own per-finding severity, so "pin this check to low" actually means low everywhere). On the next run the pin also re-grades the check's *existing* open findings — even ones a sampled LLM pass doesn't re-surface — so the editorial-health score and any severity-based autopilot gating reflect the pinned level immediately rather than lagging on stale severities. Leaving a check on **Default** preserves its native per-finding nuance untouched. The override is backward-compatible and additive (absent → the check's `severityDefault`), and the catalog badge shows the effective level with a `*` marker when it's been overridden. (`server/lib/editorial/checkRegistry.js`, `server/routes/pipeline/editorial.js`, `server/services/pipeline/editorial/checkRunner.js`, `server/lib/validation.js`, `client/src/components/pipeline/editorial/EditorialCheckCard.jsx`, `client/src/pages/PipelineEditorialChecks.jsx`)- **[issue-1593] The passive-voice check now ignores intentional passive — predicate-adjective states and weather/setting mood images — so it flags far fewer false positives.** `prose.passive-voice` is a cheap be-verb + past-participle heuristic, and the heuristic alone can't tell weak agentive passive ("the door was opened") from passive constructions writers use on purpose: a predicate-adjective state of being ("she was exhausted", "he was determined") isn't an action done to the subject at all, and a setting/weather mood image ("the sky was streaked with red", "the room was bathed in light") is deliberate atmosphere, not flabby prose. Both used to inflate the per-1000-word passive rate and push otherwise-clean sections over the threshold. A context-tuning pass now classifies each candidate `weak` / `stative` / `mood` and, by default, counts only genuine weak passive toward the density score — an explicit "by <agent>" ("she was exhausted *by the climb*") still always counts as weak. The cheap heuristic stays the base tier: a new **Suppress intentional passive** toggle (on by default) can be turned off per series to fall back to counting every be-verb + participle. (`server/lib/editorial/proseTics.js`, `server/lib/editorial/checkRegistry.js`)diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.jsindex b1758cc86e..c89df2aa29 100644--- a/server/services/pipeline/editorial/checkRunner.js+++ b/server/services/pipeline/editorial/checkRunner.js@@ -621,17 +621,30 @@ export async function runEditorialChecks(seriesId, options = {}) {// accepted/dismissed comments are untouched by either mode.if (!canceled) {let lastReview = null;+ // Per-check severity overrides active this run (#1596). A pinned check's+ // level is authoritative for ALL its open comments, so the seed re-grades+ // even open comments that didn't re-surface this pass — crucial for LLM+ // checks (merge mode preserves a non-resurfaced open finding) and for a+ // pinned check that produced zero findings this run.+ const severityOverrides = {};+ for (const { check, severityOverride } of enabledResolved) {+ if (severityOverride) severityOverrides[check.id] = severityOverride;+ }// Fresh-reconcile each deterministic check that ran, scoped to its checkId —// passing only that check's findings so the scoped 'fresh' pass dismisses the// stale opens it no longer produces.for (const checkId of deterministicRanIds) {const own = findings.filter((f) => f.checkId === checkId);- lastReview = await seedReviewFromFindings(seriesId, own, { runId, mode: 'fresh', checkId });+ lastReview = await seedReviewFromFindings(seriesId, own, { runId, mode: 'fresh', checkId, severityOverrides });}- // Seed the remaining (non-deterministic) findings in merge mode.+ // Seed the remaining (non-deterministic) findings in merge mode. Also run+ // when there are active overrides but no merged findings, so a pinned check+ // that produced ZERO findings this pass still re-grades its lingering open+ // comments (#1596) — merge mode never dismisses, so an empty seed is a safe+ // no-op aside from the authoritative severity re-grade.const merged = findings.filter((f) => !deterministicRanIds.has(f.checkId));- if (merged.length) {- lastReview = await seedReviewFromFindings(seriesId, merged, { runId, mode: 'merge' });+ if (merged.length || Object.keys(severityOverrides).length) {+ lastReview = await seedReviewFromFindings(seriesId, merged, { runId, mode: 'merge', severityOverrides });}// Record a revision-trend snapshot for EVERY non-canceled run (#1316) — a run// is a revision boundary, and a CLEAN run (0 new findings, or a reconciliationdiff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.jsindex 5e8d23c176..a5c19bd6ab 100644--- a/server/services/pipeline/editorial/checkRunner.test.js+++ b/server/services/pipeline/editorial/checkRunner.test.js@@ -174,6 +174,25 @@ describe('runEditorialChecks', () => {expect(infoDump.every((f) => f.severity === 'medium')).toBe(true); // the LLM's own level});+ it('passes active severity overrides to the seed so existing open findings re-grade', async () => {+ await runEditorialChecks('s1', {+ checkIds: ['prose.info-dumping'],+ settings: { pipelineEditorialChecks: { checks: { 'prose.info-dumping': { severity: 'high' } } } },+ });+ // The merge seed (info-dump is an LLM check) carries the override map so the+ // seeding layer can re-grade lingering open comments authoritatively (#1596).+ const mergeCall = seedReviewFromFindings.mock.calls.find((c) => c[2]?.mode === 'merge');+ expect(mergeCall).toBeTruthy();+ expect(mergeCall[2].severityOverrides).toMatchObject({ 'prose.info-dumping': 'high' });+ });++ it('omits the override map from the seed when no check is pinned', async () => {+ await runEditorialChecks('s1', { checkIds: ['prose.info-dumping'] });+ const mergeCall = seedReviewFromFindings.mock.calls.find((c) => c[2]?.mode === 'merge');+ expect(mergeCall).toBeTruthy();+ expect(mergeCall[2].severityOverrides).toEqual({}); // empty → nothing to re-grade+ });+// #1578 — the runner emits check:start / check:complete progress frames so the// autopilot SSE stream can show per-check progress mid-pass, not just a total.it('emits check:start and check:complete progress frames with a severity breakdown', async () => {diff --git a/server/services/pipeline/manuscriptReview.js b/server/services/pipeline/manuscriptReview.jsindex 15d0068435..78d1e450a1 100644--- a/server/services/pipeline/manuscriptReview.js+++ b/server/services/pipeline/manuscriptReview.js@@ -194,8 +194,14 @@ const findingKey = (c) => `${c.checkId ?? ''}|${c.issueNumber ?? ''}|${c.anchorQ* New findings resolve their issueId/stageId from the current manuscript* sections by issueNumber.*/-export async function seedReviewFromFindings(seriesId, findings, { runId = null, mode = 'merge', checkId = null } = {}) {+export async function seedReviewFromFindings(seriesId, findings, { runId = null, mode = 'merge', checkId = null, severityOverrides = null } = {}) {const scopeCheckId = checkId ?? null;+ // Per-check severity overrides (#1596): a pinned check's level is authoritative+ // for EVERY open comment of that check, so we re-grade carried open comments+ // (re-surfaced or not) to the pinned level below. Tolerant of a junk/hand-edited+ // value — only a valid level forces a re-grade.+ const pins = severityOverrides && typeof severityOverrides === 'object' && !Array.isArray(severityOverrides)+ ? severityOverrides : null;const sections = await collectManuscriptSections(seriesId);const byNumber = new Map(sections.map((s) => [s.number, s]));return queueReviewWrite(seriesId, async () => {@@ -258,27 +264,31 @@ export async function seedReviewFromFindings(seriesId, findings, { runId = null,return sanitizeComment({ ...c, status: 'dismissed', updatedAt: now });}if (c.status !== 'open') return c;- const match = candidateByKey.get(findingKey(c));- if (!match) return c;const patch = {};- if (!c.fix) {- const section = c.issueNumber != null ? byNumber.get(c.issueNumber) : null;- const fix = match.replace ? buildSeedFix({ ...c, replace: match.replace }, section) : null;- if (fix) { patch.fix = fix; backfilledCount += 1; }- }- if (match.sourceContentHash && match.sourceContentHash !== (c.sourceContentHash ?? null)) {- patch.sourceContentHash = match.sourceContentHash;+ // 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;refreshedCount += 1;}- // Refresh the persisted severity to the current run's level (#1596): the- // findingKey ignores severity, so a re-surfaced finding whose check now- // carries a different per-check severity override would otherwise keep its- // stale level — leaving the health score + severity gating reading the old- // value. Mirrors the sourceContentHash refresh: the latest run's view of an- // open finding wins.- if (match.severity && match.severity !== c.severity) {- patch.severity = match.severity;- refreshedCount += 1;+ const match = candidateByKey.get(findingKey(c));+ if (match) {+ if (!c.fix) {+ const section = c.issueNumber != null ? byNumber.get(c.issueNumber) : null;+ const fix = match.replace ? buildSeedFix({ ...c, replace: match.replace }, section) : null;+ if (fix) { patch.fix = fix; backfilledCount += 1; }+ }+ if (match.sourceContentHash && match.sourceContentHash !== (c.sourceContentHash ?? null)) {+ patch.sourceContentHash = match.sourceContentHash;+ refreshedCount += 1;+ }}if (Object.keys(patch).length === 0) return c;return sanitizeComment({ ...c, ...patch, updatedAt: now });diff --git a/server/services/pipeline/manuscriptReview.test.js b/server/services/pipeline/manuscriptReview.test.jsindex 4109f7b729..e6ab59e704 100644--- a/server/services/pipeline/manuscriptReview.test.js+++ b/server/services/pipeline/manuscriptReview.test.js@@ -349,30 +349,49 @@ describe('manuscriptReview — sourceContentHash staleness fingerprint (#1345)',});});-describe('manuscriptReview — severity refresh on re-surface (#1596)', () => {+describe('manuscriptReview — authoritative severity override re-grade (#1596)', () => {beforeEach(() => { fileStore.clear(); });-- it('re-grades an existing open comment when a re-surfaced finding carries a new severity', async () => {- await seedReviewFromFindings('ser-sev', [- { problem: 'adverb density', anchorQuote: 'quickly', checkId: 'prose.adverb-density', severity: 'low' },- ]);- // Same finding key (severity is NOT part of the key) re-surfaces from a run- // whose check now carries a `high` per-check severity override.- const second = await seedReviewFromFindings('ser-sev', [- { problem: 'adverb density', anchorQuote: 'quickly', checkId: 'prose.adverb-density', severity: 'high' },- ]);+ const finding = (severity) => ({ problem: 'adverb density', anchorQuote: 'quickly', checkId: 'prose.adverb-density', severity });++ it('re-grades a re-surfaced open comment to the pinned level via severityOverrides', async () => {+ await seedReviewFromFindings('ser-sev', [finding('low')]);+ // Same finding key (severity is NOT part of the key) re-surfaces while the+ // check is now pinned to `high`.+ const second = await seedReviewFromFindings('ser-sev', [finding('high')], {+ severityOverrides: { 'prose.adverb-density': 'high' },+ });expect(second.comments).toHaveLength(1); // deduped, not appended- expect(second.comments[0].severity).toBe('high'); // re-graded to the override level+ expect(second.comments[0].severity).toBe('high'); // re-graded to the pinned level});- it('does NOT churn updatedAt when the re-surfaced finding has the same severity', async () => {- const first = await seedReviewFromFindings('ser-sev-nochurn', [- { problem: 'adverb density', anchorQuote: 'quickly', checkId: 'prose.adverb-density', severity: 'high' },- ]);+ it('re-grades a NON-resurfaced open comment of a pinned check (merge mode)', async () => {+ await seedReviewFromFindings('ser-sev-merge', [finding('low')]);+ // A later merge-mode run finds nothing for this check (LLM variance), but the+ // check is pinned to `high` — the lingering open comment must still re-grade.+ const second = await seedReviewFromFindings('ser-sev-merge', [], {+ mode: 'merge',+ severityOverrides: { 'prose.adverb-density': 'high' },+ });+ expect(second.comments).toHaveLength(1); // not dismissed in merge mode+ 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;- const second = await seedReviewFromFindings('ser-sev-nochurn', [- { problem: 'adverb density', anchorQuote: 'quickly', checkId: 'prose.adverb-density', severity: 'high' },- ]);+ // 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('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;+ const second = await seedReviewFromFindings('ser-sev-nochurn', [finding('high')], {+ severityOverrides: { 'prose.adverb-density': 'high' },+ });expect(second.comments[0].updatedAt).toBe(stamp); // unchanged — no rewrite});});