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

feat: mark editorial finding as false positive distinct from dismiss (#1605)

[._.]/ Adam Eivycdd972e33d7e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index bb2cccda42..fadc7ac5dd 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -105,6 +105,8 @@
- **[issue-1603] The editorial comment card is now keyboard-drivable, so a triage pass is one keystroke per note instead of a mouse round-trip.** Reviewing findings forced you to reach for the mouse for every Accept / Dismiss / Generate, and stepping between open notes meant detouring back through the sidebar. The open note's card now responds to keyboard shortcuts — **← / →** (or **k / j**, vim-style) to step prev/next through the triage order, **a** to accept the suggested fix, **d** to dismiss, and **g** to generate or regenerate the fix — with an on-screen hint row in the card showing the keys available for that note. The shortcuts never fire while you're typing in the replacement textarea or the manuscript editor (and ⌘/Ctrl chords still reach the browser), so letters never misfire. (`client/src/hooks/useKeyboardShortcuts.js`, `client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx`, `client/src/components/ui/Kbd.jsx`)
+- **[issue-1605] You can now mark a finding as a *false positive* — "this check is wrong here" — distinct from a plain dismiss, and each check shows how often it's wrong.** Triage offered only Accept ("fixed") and Dismiss ("won't fix"), with no way to say a check itself misfired — so a broken check kept regenerating the same bad finding every run with nothing tracking its quality. Both the manuscript comment card and the findings-triage list now offer a **False positive** action (keyboard **f** on the card) alongside Dismiss; it records the dismissal with a `false-positive` reason and tags the finding so the call is visible. Each check's group header in triage now surfaces a **% FP** badge — the share of that check's findings you've flagged as false positives, computed over the check's full finding set so it stays stable under the active status filter — turning per-check false-positive rate into a quality signal for the catalog. The new reason is optional and additive, so the synced `manuscript-review.json` stays backward-compatible with older peers (which simply ignore it), and a finding re-opened or plainly dismissed clears any prior false-positive mark. (`server/services/pipeline/manuscriptReview.js`, `server/routes/pipeline/manuscript.js`, `client/src/lib/editorialChecks.js`, `client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx`, `client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`)
+
## Series Autopilot
- **[issue-1510] Series Autopilot now catches whole-book continuity problems at the cheap beat stage, before it generates full scripts.** The autopilot reviewed continuity at two altitudes — the cross-volume synopsis pass (before beats exist) and the full-text editorial pass (after every issue's script is written, the most expensive stage) — leaving a gap in between. So structural defects spanning the whole book (a cliffhanger raised in one issue and never resolved, a finale that drifts onto a new subplot instead of landing the arc's intended ending, a promised through-line that never pays off, an event staged as the "first" in two different issues, a broken volume-to-volume hand-off) were only caught *after* all the scripts already existed — or not until a human read it. The autopilot now runs a **whole-manuscript beat-continuity pass over every issue's beat sheet, between beat generation and script generation**. Blocking findings are auto-resolved by rewriting just the affected issues' beats and re-checking (bounded, then it pauses for review with the residual findings), so the fix lands before any script is generated. The full-text editorial pass is unchanged and still catches what only the verbatim script can show (pacing, repeated/looping passages, dialogue craft). A new **Beat continuity rounds** control in the autopilot Options tunes how many auto-resolve rounds it attempts (0 skips the pass), saved as a per-install default like the existing Arc-verify and Editorial round knobs.
diff --git a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
index 87ed0a5f92..b5ed1a1504 100644
--- a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
+++ b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
@@ -20,6 +20,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
import CheckKindBadge from './CheckKindBadge';
import {
groupFindingsByCheck,
+ checkFalsePositiveRate,
findingManuscriptLink,
openFindingsTotal,
deriveFindingFacets,
@@ -138,9 +139,13 @@ function FindingRow({ seriesId, comment, onCommentChange, selected, onToggleSele
{ errorMessage: 'Failed to apply fix' },
);
const [runDismiss, dismissing] = useAsyncAction(
- () => patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed' }, { silent: true }),
+ () => patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed', dismissReason: null }, { silent: true }),
{ errorMessage: 'Failed to dismiss' },
);
+ const [runFalsePositive, flagging] = useAsyncAction(
+ () => patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed', dismissReason: 'false-positive' }, { silent: true }),
+ { errorMessage: 'Failed to flag false positive' },
+ );
const accept = async () => {
const result = await runAccept();
@@ -152,6 +157,12 @@ function FindingRow({ seriesId, comment, onCommentChange, selected, onToggleSele
const result = await runDismiss();
if (result?.comment) onCommentChange?.(result.comment);
};
+ // "This check is wrong here" — distinct from dismiss so the per-check
+ // false-positive rate can flag a broken check (#1605).
+ const markFalsePositive = async () => {
+ const result = await runFalsePositive();
+ if (result?.comment) onCommentChange?.(result.comment);
+ };
return (
<li className="p-2.5 space-y-2">
@@ -176,6 +187,9 @@ function FindingRow({ seriesId, comment, onCommentChange, selected, onToggleSele
<span className="flex items-center gap-2">
{comment.location ? <span className="block text-[11px] text-gray-500">{comment.location}</span> : null}
{isOpen && comment.stale ? <StaleBadge /> : null}
+ {comment.dismissReason === 'false-positive' ? (
+ <span className="inline-flex items-center gap-1 text-[10px] text-port-warning"><Ban size={10} /> false positive</span>
+ ) : null}
</span>
</span>
<ExternalLink size={13} className="mt-0.5 shrink-0 text-gray-600 group-hover:text-port-accent" />
@@ -211,12 +225,24 @@ function FindingRow({ seriesId, comment, onCommentChange, selected, onToggleSele
<button
type="button"
onClick={dismiss}
- disabled={accepting || dismissing}
+ disabled={accepting || dismissing || flagging}
className="inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-gray-500 hover:text-white disabled:opacity-40"
>
{dismissing ? <Loader2 size={11} className="animate-spin" /> : <X size={11} />}
Dismiss
</button>
+ {comment.checkId ? (
+ <button
+ type="button"
+ onClick={markFalsePositive}
+ disabled={accepting || dismissing || flagging}
+ className="inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-gray-500 hover:text-port-warning disabled:opacity-40"
+ title="Flag as a false positive — the check is wrong here"
+ >
+ {flagging ? <Loader2 size={11} className="animate-spin" /> : <Ban size={11} />}
+ False positive
+ </button>
+ ) : null}
</div>
{hasFix && showFix ? (
<div className="space-y-1.5 rounded border border-port-border/60 bg-port-card/40">
@@ -279,6 +305,17 @@ function CheckGroup({ seriesId, group, onCommentChange, selectedIds, onToggleSel
<span className="text-[10px] text-gray-500 shrink-0">{group.open} open · {group.total} total</span>
</span>
<span className="flex items-center gap-1.5 shrink-0">
+ {group.falsePositive > 0 ? (
+ // Per-check quality signal (#1605): how often this check is wrong.
+ // Rate is stamped over the full finding set, so it's stable under
+ // the active status filter.
+ <span
+ className="inline-flex items-center gap-1 rounded border border-port-warning/40 px-1.5 py-0.5 text-[10px] text-port-warning"
+ title={`${group.falsePositive} finding${group.falsePositive === 1 ? '' : 's'} flagged false positive (${Math.round((checkFalsePositiveRate(group) || 0) * 100)}% of this check's findings)`}
+ >
+ <Ban size={10} /> {Math.round((checkFalsePositiveRate(group) || 0) * 100)}% FP
+ </span>
+ ) : null}
{group.stale > 0 ? <StaleBadge count={group.stale} /> : null}
<CountPills counts={group.counts} />
</span>
@@ -355,7 +392,7 @@ function BulkActionBar({ seriesId, selected, onCommentChange, onClear }) {
for (const comment of targets) {
const result = mode === 'accept'
? await acceptPipelineManuscriptFix(seriesId, comment.id, { edits: acceptEditsOf(comment) }, { silent: true }).catch(() => null)
- : await patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed' }, { silent: true }).catch(() => null);
+ : await patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed', dismissReason: null }, { silent: true }).catch(() => null);
if (result?.comment) {
onCommentChange?.(result.comment);
ok += 1;
diff --git a/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx b/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx
index 8a42026c47..42476f9694 100644
--- a/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx
+++ b/client/src/components/pipeline/editorial/EditorialFindingsTriage.test.jsx
@@ -137,11 +137,23 @@ describe('EditorialFindingsTriage', () => {
expect(screen.queryByRole('button', { name: /preview fix/i })).toBeNull();
fireEvent.click(screen.getByRole('button', { name: /dismiss/i }));
await waitFor(() => expect(patchPipelineManuscriptComment).toHaveBeenCalledWith(
- 'ser-1', 'c1', { status: 'dismissed' }, { silent: true },
+ 'ser-1', 'c1', { status: 'dismissed', dismissReason: null }, { silent: true },
));
await waitFor(() => expect(onCommentChange).toHaveBeenCalledWith(expect.objectContaining({ id: 'c1', status: 'dismissed' })));
});
+ it('flags a finding as a false positive inline (#1605)', async () => {
+ const onCommentChange = vi.fn();
+ patchPipelineManuscriptComment.mockResolvedValue({ comment: { id: 'c1', checkId: 'naming.dissimilar-names', status: 'dismissed', dismissReason: 'false-positive', severity: 'high', problem: 'Bad finding' } });
+ const comments = [{ id: 'c1', checkId: 'naming.dissimilar-names', status: 'open', severity: 'high', problem: 'Bad finding' }];
+ renderTriage({ comments, onCommentChange });
+
+ fireEvent.click(screen.getByRole('button', { name: /false positive/i }));
+ await waitFor(() => expect(patchPipelineManuscriptComment).toHaveBeenCalledWith(
+ 'ser-1', 'c1', { status: 'dismissed', dismissReason: 'false-positive' }, { silent: true },
+ ));
+ });
+
it('does not offer inline actions on a resolved finding (#1598)', () => {
const comments = [{ id: 'c1', checkId: 'naming.dissimilar-names', status: 'accepted', severity: 'high', problem: 'Done', fix: { edits: [{ find: 'a', replace: 'b' }] } }];
renderTriage({ comments });
@@ -179,8 +191,8 @@ describe('EditorialFindingsTriage', () => {
fireEvent.click(screen.getByRole('button', { name: /dismiss 2/i }));
await waitFor(() => expect(patchPipelineManuscriptComment).toHaveBeenCalledTimes(2));
- expect(patchPipelineManuscriptComment).toHaveBeenCalledWith('ser-1', 'c1', { status: 'dismissed' }, { silent: true });
- expect(patchPipelineManuscriptComment).toHaveBeenCalledWith('ser-1', 'c2', { status: 'dismissed' }, { silent: true });
+ expect(patchPipelineManuscriptComment).toHaveBeenCalledWith('ser-1', 'c1', { status: 'dismissed', dismissReason: null }, { silent: true });
+ expect(patchPipelineManuscriptComment).toHaveBeenCalledWith('ser-1', 'c2', { status: 'dismissed', dismissReason: null }, { silent: true });
await waitFor(() => expect(onCommentChange).toHaveBeenCalledTimes(2));
});
diff --git a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx
index 7fe10a8e0d..fe8588faa8 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx
@@ -11,7 +11,7 @@
*/
import { useMemo, useState } from 'react';
-import { Loader2, Sparkles, Check, X, Columns2, Rows2, Copy, ChevronLeft, ChevronRight } from 'lucide-react';
+import { Loader2, Sparkles, Check, X, Ban, Columns2, Rows2, Copy, ChevronLeft, ChevronRight } from 'lucide-react';
import InlineDiff from '../../ui/InlineDiff';
import SideBySideDiff from '../../ui/SideBySideDiff';
import toast from '../../ui/Toast';
@@ -43,7 +43,7 @@ export function CopyId({ id }) {
// On-screen cheatsheet for the card's keyboard shortcuts (#1603) — only the
// actions actually available for this note are shown (prev/next when the card is
// part of a triage order, Accept/regenerate when a fix exists, Generate when not).
-function ShortcutHints({ hasNav, hasFix }) {
+function ShortcutHints({ hasNav, hasFix, hasFalsePositive }) {
return (
<div className="flex flex-wrap items-center gap-x-2.5 gap-y-1 pt-1.5 text-[10px] text-gray-600">
{hasNav ? (
@@ -58,6 +58,9 @@ function ShortcutHints({ hasNav, hasFix }) {
<span className="inline-flex items-center gap-1"><Kbd size="sm">g</Kbd> generate</span>
)}
<span className="inline-flex items-center gap-1"><Kbd size="sm">d</Kbd> dismiss</span>
+ {hasFalsePositive ? (
+ <span className="inline-flex items-center gap-1"><Kbd size="sm">f</Kbd> false positive</span>
+ ) : null}
</div>
);
}
@@ -69,6 +72,11 @@ export function Badge({ comment }) {
{comment.severity}
</span>
<span className="text-[10px] uppercase tracking-wider text-gray-500">{CATEGORY_LABEL[comment.category] || comment.category}</span>
+ {comment.dismissReason === 'false-positive' ? (
+ <span className="text-[10px] px-1.5 py-0.5 rounded border border-port-warning/40 text-port-warning" title="Flagged as a false positive">
+ false positive
+ </span>
+ ) : null}
</span>
);
}
@@ -194,11 +202,24 @@ export default function ManuscriptCommentCard({
};
const dismiss = async () => {
- const result = await patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed' }, { silent: true })
+ // A plain dismiss is "won't fix" — clear any prior false-positive reason so
+ // re-dismissing a re-opened finding doesn't keep a stale mark.
+ const result = await patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed', dismissReason: null }, { silent: true })
.catch((err) => { toast.error(err.message || 'Failed to dismiss'); return null; });
if (result?.comment) onCommentChange(result.comment);
};
+ // "This check is wrong here" (#1605) — distinct from a plain dismiss so broken
+ // checks are tracked for the per-check quality view instead of silently
+ // re-surfacing the same bad finding every run. Only offered for check-sourced
+ // findings (completeness-pass findings carry no checkId to attribute it to).
+ const markFalsePositive = async () => {
+ const result = await patchPipelineManuscriptComment(seriesId, comment.id, { status: 'dismissed', dismissReason: 'false-positive' }, { silent: true })
+ .catch((err) => { toast.error(err.message || 'Failed to flag false positive'); return null; });
+ if (result?.comment) onCommentChange(result.comment);
+ };
+ const canFlagFalsePositive = !!comment.checkId;
+
const fuzzy = comment.fix?.fuzzy || fixEdits.some((e) => e.fuzzy);
const Diff = diffStyle === 'side' ? SideBySideDiff : InlineDiff;
// At least one selected edit carries usable replacement text — gates both the
@@ -220,6 +241,7 @@ export default function ManuscriptCommentCard({
j: nav?.onNext,
a: canAccept && !accepting ? accept : undefined,
d: !accepting ? dismiss : undefined,
+ f: canFlagFalsePositive && !accepting ? markFalsePositive : undefined,
g: !generating && !accepting ? generate : undefined,
});
@@ -358,16 +380,27 @@ export default function ManuscriptCommentCard({
</button>
</>
)}
+ {canFlagFalsePositive ? (
+ <button
+ type="button"
+ onClick={markFalsePositive}
+ disabled={accepting}
+ className="ml-auto inline-flex items-center gap-1 px-2 py-1 rounded text-[12px] text-gray-500 hover:text-port-warning disabled:opacity-40"
+ title="Flag this finding as a false positive — the check is wrong here"
+ >
+ <Ban size={12} /> False positive
+ </button>
+ ) : null}
<button
type="button"
onClick={dismiss}
- className="ml-auto inline-flex items-center gap-1 px-2 py-1 rounded text-[12px] text-gray-500 hover:text-white"
+ className={`${canFlagFalsePositive ? '' : 'ml-auto '}inline-flex items-center gap-1 px-2 py-1 rounded text-[12px] text-gray-500 hover:text-white`}
>
<X size={12} /> Dismiss
</button>
</div>
- <ShortcutHints hasNav={!!nav} hasFix={hasFix} />
+ <ShortcutHints hasNav={!!nav} hasFix={hasFix} hasFalsePositive={canFlagFalsePositive} />
</div>
);
}
diff --git a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx
index 6c3a948955..aa101a6ecc 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx
@@ -71,10 +71,31 @@ describe('ManuscriptCommentCard keyboard shortcuts (#1603)', () => {
renderCard();
pressKey('d');
await waitFor(() => expect(patchPipelineManuscriptComment).toHaveBeenCalledWith(
- 'ser-1', 'c1', { status: 'dismissed' }, { silent: true },
+ 'ser-1', 'c1', { status: 'dismissed', dismissReason: null }, { silent: true },
));
});
+ it('f flags a check-sourced finding as a false positive (#1605)', async () => {
+ const checkComment = { ...baseComment, checkId: 'prose.info-dumping' };
+ patchPipelineManuscriptComment.mockResolvedValue({ comment: { ...checkComment, status: 'dismissed', dismissReason: 'false-positive' } });
+ render(
+ <>
+ <ManuscriptCommentCard comment={checkComment} seriesId="ser-1" onCommentChange={vi.fn()} onAccepted={vi.fn()} draft={null} onDraftChange={vi.fn()} />
+ <Toaster />
+ </>,
+ );
+ expect(screen.getByText('False positive')).toBeTruthy();
+ pressKey('f');
+ await waitFor(() => expect(patchPipelineManuscriptComment).toHaveBeenCalledWith(
+ 'ser-1', 'c1', { status: 'dismissed', dismissReason: 'false-positive' }, { silent: true },
+ ));
+ });
+
+ it('does NOT offer the false-positive action for a completeness finding (no checkId)', () => {
+ renderCard();
+ expect(screen.queryByText('False positive')).toBeNull();
+ });
+
it('a accepts the suggested fix when one exists, and shows accept/regenerate hints', () => {
acceptPipelineManuscriptFix.mockResolvedValue({ comment: { ...withFix, status: 'accepted' } });
renderCard({ comment: withFix });
diff --git a/client/src/lib/editorialChecks.js b/client/src/lib/editorialChecks.js
index d382836940..bd0a071948 100644
--- a/client/src/lib/editorialChecks.js
+++ b/client/src/lib/editorialChecks.js
@@ -69,6 +69,11 @@ export function groupFindingsByCheck(comments = [], rowsById = {}) {
total: 0,
counts: emptyCounts(),
stale: 0,
+ // Dismissal tally (#1605): `dismissed` counts every dismissed finding,
+ // `falsePositive` the subset flagged as a broken check. The ratio drives
+ // the per-check quality signal in the catalog/triage view.
+ dismissed: 0,
+ falsePositive: 0,
});
}
const g = groups.get(c.checkId);
@@ -79,8 +84,17 @@ export function groupFindingsByCheck(comments = [], rowsById = {}) {
const sev = SEVERITY_ORDER.includes(c.severity) ? c.severity : 'low';
g.counts[sev] += 1;
if (c.stale) g.stale += 1;
+ } else if (c.status === 'dismissed') {
+ g.dismissed += 1;
+ if (c.dismissReason === 'false-positive') g.falsePositive += 1;
}
}
+ // Stamp a stable false-positive rate over the FULL finding set (#1605) so the
+ // catalog/triage quality signal stays correct even when a status filter later
+ // recounts `total` to the matched subset (see applyFindingsView/recountGroup).
+ for (const g of groups.values()) {
+ g.falsePositiveRate = g.total > 0 ? g.falsePositive / g.total : null;
+ }
const scopeRank = (s) => {
const i = CHECK_SCOPE_ORDER.indexOf(s);
return i === -1 ? CHECK_SCOPE_ORDER.length : i;
@@ -93,6 +107,20 @@ export function groupFindingsByCheck(comments = [], rowsById = {}) {
export const openFindingsTotal = (groups = []) =>
groups.reduce((sum, g) => sum + g.open, 0);
+/**
+ * Per-check false-positive rate (#1605): the fraction of a check's findings the
+ * user flagged as a broken check (`false-positive` dismissals over total
+ * findings). `null` when the check has surfaced nothing yet, so callers can
+ * distinguish "no data" from a genuine 0%. Prefers the stable rate stamped by
+ * `groupFindingsByCheck` (immune to status-filter recounts), falling back to a
+ * direct compute for hand-built groups.
+ */
+export const checkFalsePositiveRate = (group) => {
+ if (!group) return null;
+ if (group.falsePositiveRate !== undefined) return group.falsePositiveRate;
+ return group.total > 0 ? group.falsePositive / group.total : null;
+};
+
/**
* Deep-link a finding into the manuscript editor: focuses the finding's issue
* (when it has one) and opens its comment card via the `?comment=` param the
diff --git a/client/src/lib/editorialChecks.test.js b/client/src/lib/editorialChecks.test.js
index aec36b07b3..0018327ff7 100644
--- a/client/src/lib/editorialChecks.test.js
+++ b/client/src/lib/editorialChecks.test.js
@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';
import {
groupChecksByScope,
groupFindingsByCheck,
+ checkFalsePositiveRate,
openFindingsTotal,
findingManuscriptLink,
scopeLabel,
@@ -90,6 +91,41 @@ describe('groupFindingsByCheck', () => {
expect(groups.find((g) => g.checkId === 'a.series').stale).toBe(1);
expect(groups.find((g) => g.checkId === 'b.issue').stale).toBe(0);
});
+
+ it('tallies dismissed + false-positive counts and stamps a stable rate (#1605)', () => {
+ const fpComments = [
+ { id: '1', checkId: 'a.series', status: 'open', severity: 'high' },
+ { id: '2', checkId: 'a.series', status: 'dismissed', severity: 'low' }, // plain dismiss
+ { id: '3', checkId: 'a.series', status: 'dismissed', severity: 'high', dismissReason: 'false-positive' },
+ { id: '4', checkId: 'a.series', status: 'dismissed', severity: 'high', dismissReason: 'false-positive' },
+ { id: '5', checkId: 'b.issue', status: 'open', severity: 'medium' },
+ ];
+ const groups = groupFindingsByCheck(fpComments, rows);
+ const series = groups.find((g) => g.checkId === 'a.series');
+ expect(series.dismissed).toBe(3);
+ expect(series.falsePositive).toBe(2);
+ expect(series.falsePositiveRate).toBeCloseTo(2 / 4); // 2 of 4 findings
+ const issue = groups.find((g) => g.checkId === 'b.issue');
+ expect(issue.falsePositive).toBe(0);
+ expect(issue.falsePositiveRate).toBe(0);
+ });
+});
+
+describe('checkFalsePositiveRate', () => {
+ it('prefers the stamped rate over a recompute (survives status-filter recounts)', () => {
+ // A group whose `total` was recounted to the open-only subset, but whose
+ // stamped rate reflects the full finding set.
+ expect(checkFalsePositiveRate({ total: 1, falsePositive: 0, falsePositiveRate: 0.5 })).toBe(0.5);
+ });
+
+ it('falls back to falsePositive/total for a hand-built group', () => {
+ expect(checkFalsePositiveRate({ total: 4, falsePositive: 1 })).toBe(0.25);
+ });
+
+ it('returns null when the check has no findings yet', () => {
+ expect(checkFalsePositiveRate({ total: 0, falsePositive: 0 })).toBeNull();
+ expect(checkFalsePositiveRate(null)).toBeNull();
+ });
});
describe('findingManuscriptLink', () => {
diff --git a/server/routes/pipeline/manuscript.js b/server/routes/pipeline/manuscript.js
index 82387e96c2..ad4796c85b 100644
--- a/server/routes/pipeline/manuscript.js
+++ b/server/routes/pipeline/manuscript.js
@@ -57,6 +57,10 @@ const manuscriptFixAcceptSchema = z.object({
// stray keys; `fix` nullable so an explicit clear is distinguishable from absent.
const manuscriptCommentPatchSchema = z.object({
status: z.enum(['open', 'accepted', 'dismissed']).optional(),
+ // Why a dismissal was made (#1605) — `false-positive` flags a broken check;
+ // `null` clears the reason back to a plain "won't fix" dismiss. Validated
+ // against the same source the service sanitizes from.
+ dismissReason: z.enum(manuscriptReview.DISMISS_REASONS).nullable().optional(),
fix: z.object({
find: z.string().max(issuesSvc.STAGE_OUTPUT_MAX).optional(),
replace: z.string().max(issuesSvc.STAGE_OUTPUT_MAX).optional(),
diff --git a/server/services/pipeline/manuscriptReview.js b/server/services/pipeline/manuscriptReview.js
index 174c56319e..dc92e8addb 100644
--- a/server/services/pipeline/manuscriptReview.js
+++ b/server/services/pipeline/manuscriptReview.js
@@ -31,6 +31,16 @@ const SCHEMA_VERSION = 1;
export const COMMENT_STATUSES = Object.freeze(['open', 'accepted', 'dismissed']);
const STATUS_SET = new Set(COMMENT_STATUSES);
+// Why a dismissal was made (#1605). A plain dismiss (`dismissReason: null`)
+// means "won't fix" — the finding is real but the user is leaving it. A
+// `false-positive` reason means "this check is wrong here" — it feeds the
+// per-check quality view so broken checks are tracked instead of silently
+// re-surfacing the same bad finding every run. Only meaningful when
+// `status === 'dismissed'`. Optional + additive, so the synced review doc stays
+// backward-compatible with older peers (who simply ignore the field).
+export const DISMISS_REASONS = Object.freeze(['false-positive']);
+const DISMISS_REASON_SET = new Set(DISMISS_REASONS);
+
// Re-run modes for seedReviewFromFindings — see its doc comment. Exported so the
// route's Zod enum validates against the same source (mirrors COMMENT_STATUSES).
export const REVIEW_RUN_MODES = Object.freeze(['merge', 'fresh']);
@@ -129,6 +139,13 @@ function sanitizeComment(raw) {
// Optional + additive, so the synced review doc stays backward-compatible.
sourceContentHash: typeof raw.sourceContentHash === 'string' && raw.sourceContentHash ? raw.sourceContentHash : null,
status: STATUS_SET.has(raw.status) ? raw.status : 'open',
+ // Dismissal reason (#1605) — only carried while dismissed. A status flip
+ // back to open/accepted drops it here so a re-opened finding can't keep a
+ // stale `false-positive` mark. Legacy/older-peer records lack the field and
+ // sanitize to `null` (a plain "won't fix" dismiss).
+ dismissReason: raw.status === 'dismissed' && DISMISS_REASON_SET.has(raw.dismissReason)
+ ? raw.dismissReason
+ : null,
fix: sanitizeFix(raw.fix),
sourceRunId: typeof raw.sourceRunId === 'string' ? raw.sourceRunId : null,
createdAt: typeof raw.createdAt === 'string' ? raw.createdAt : new Date().toISOString(),
@@ -372,6 +389,12 @@ export async function updateComment(seriesId, commentId, patch) {
const cur = review.comments[idx];
const merged = { ...cur };
if (patch.status !== undefined && STATUS_SET.has(patch.status)) merged.status = patch.status;
+ // Dismissal reason (#1605). `null` is an explicit clear; a valid reason sets
+ // it. sanitizeComment below drops it anyway when the resulting status isn't
+ // `dismissed`, so re-opening a false-positive can't leave the mark behind.
+ if (patch.dismissReason !== undefined) {
+ merged.dismissReason = DISMISS_REASON_SET.has(patch.dismissReason) ? patch.dismissReason : null;
+ }
// `fix: null` is an explicit clear; absent leaves it untouched.
if (patch.fix !== undefined) merged.fix = sanitizeFix(patch.fix);
merged.updatedAt = new Date().toISOString();
diff --git a/server/services/pipeline/manuscriptReview.test.js b/server/services/pipeline/manuscriptReview.test.js
index 4429538f12..1bb7ba8711 100644
--- a/server/services/pipeline/manuscriptReview.test.js
+++ b/server/services/pipeline/manuscriptReview.test.js
@@ -25,7 +25,7 @@ vi.mock('./arcPlanner.js', () => ({
import { recordEvents } from '../sharing/recordEvents.js';
import { collectManuscriptSections } from './arcPlanner.js';
-import { seedReviewFromFindings, updateComment, mergeReviewFromSync, getReview } from './manuscriptReview.js';
+import { seedReviewFromFindings, updateComment, mergeReviewFromSync, getReview, DISMISS_REASONS } from './manuscriptReview.js';
describe('manuscriptReview — record-event emission on write', () => {
let updates;
@@ -433,3 +433,64 @@ describe('manuscriptReview — authoritative severity override re-grade (#1596)'
expect(second.comments[0].updatedAt).toBe(stamp); // unchanged — no rewrite
});
});
+
+describe('manuscriptReview — false-positive dismissal reason (#1605)', () => {
+ beforeEach(() => fileStore.clear());
+
+ it('exposes false-positive as the canonical dismissal reason', () => {
+ expect(DISMISS_REASONS).toContain('false-positive');
+ });
+
+ it('seeded findings carry a null dismissReason by default', async () => {
+ const seeded = await seedReviewFromFindings('fp-seed', [{ problem: 'P', anchorQuote: 'q' }]);
+ expect(seeded.comments[0].dismissReason).toBeNull();
+ });
+
+ it('updateComment records a false-positive dismissal', async () => {
+ const seeded = await seedReviewFromFindings('fp-set', [{ problem: 'P', anchorQuote: 'q' }]);
+ const id = seeded.comments[0].id;
+ const updated = await updateComment('fp-set', id, { status: 'dismissed', dismissReason: 'false-positive' });
+ expect(updated.status).toBe('dismissed');
+ expect(updated.dismissReason).toBe('false-positive');
+ // Survives a read-back through sanitize (the same shaper sync uses).
+ const persisted = (await getReview('fp-set')).comments[0];
+ expect(persisted.dismissReason).toBe('false-positive');
+ });
+
+ it('clears the reason when the finding is re-opened', async () => {
+ const seeded = await seedReviewFromFindings('fp-reopen', [{ problem: 'P', anchorQuote: 'q' }]);
+ const id = seeded.comments[0].id;
+ await updateComment('fp-reopen', id, { status: 'dismissed', dismissReason: 'false-positive' });
+ const reopened = await updateComment('fp-reopen', id, { status: 'open' });
+ // sanitize drops a reason that no longer applies to the (non-dismissed) status.
+ expect(reopened.dismissReason).toBeNull();
+ });
+
+ it('clears the reason on an explicit plain dismiss (dismissReason: null)', async () => {
+ const seeded = await seedReviewFromFindings('fp-plain', [{ problem: 'P', anchorQuote: 'q' }]);
+ const id = seeded.comments[0].id;
+ await updateComment('fp-plain', id, { status: 'dismissed', dismissReason: 'false-positive' });
+ const plain = await updateComment('fp-plain', id, { status: 'dismissed', dismissReason: null });
+ expect(plain.status).toBe('dismissed');
+ expect(plain.dismissReason).toBeNull();
+ });
+
+ it('rejects an unknown reason (sanitizes to null)', async () => {
+ const seeded = await seedReviewFromFindings('fp-bad', [{ problem: 'P', anchorQuote: 'q' }]);
+ const id = seeded.comments[0].id;
+ const updated = await updateComment('fp-bad', id, { status: 'dismissed', dismissReason: 'bogus' });
+ expect(updated.dismissReason).toBeNull();
+ });
+
+ it('survives a sync round-trip and never resurrects a stale reason on a non-dismissed peer record', async () => {
+ const merged = await mergeReviewFromSync('fp-sync', {
+ comments: [
+ { id: 'fp1', problem: 'real fp', status: 'dismissed', dismissReason: 'false-positive', updatedAt: '2026-06-25T00:00:00Z' },
+ { id: 'fp2', problem: 'open with stray reason', status: 'open', dismissReason: 'false-positive', updatedAt: '2026-06-25T00:00:00Z' },
+ ],
+ });
+ const byId = Object.fromEntries(merged.comments.map((c) => [c.id, c]));
+ expect(byId.fp1.dismissReason).toBe('false-positive');
+ expect(byId.fp2.dismissReason).toBeNull(); // not dismissed → reason dropped
+ });
+});