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 (self): preserve subtype on re-review, cover prompt 4th-criterion + proto-key crash

[._.]/ Adam Eivy8d99235c9bf5
diff --git a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
index 91d61b469a..c7e15351dc 100644
--- a/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
+++ b/client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx
@@ -32,7 +32,7 @@ import {
FINDINGS_TRIAGE_ANCHOR_ID,
} from '../../../lib/editorialChecks';
import { fixEditsOf, selectedEditsFor } from '../manuscript/ManuscriptCommentCard';
-import { SUBTYPE_LABEL } from '../manuscript/constants';
+import { subtypeLabel } from '../manuscript/constants';
import InlineDiff from '../../ui/InlineDiff';
import toast from '../../ui/Toast';
import { useAsyncAction } from '../../../hooks/useAsyncAction';
@@ -208,7 +208,7 @@ function FindingRow({ seriesId, comment, onCommentChange, selected, onToggleSele
{comment.location ? <span className="block text-[11px] text-gray-500">{comment.location}</span> : null}
{comment.subtype ? (
<span className="inline-flex items-center rounded border border-port-border px-1 text-[10px] text-gray-400" title="Why this line was flagged">
- {SUBTYPE_LABEL[comment.subtype] || comment.subtype}
+ {subtypeLabel(comment.subtype)}
</span>
) : null}
{isOpen && comment.stale ? <StaleBadge /> : null}
diff --git a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx
index 32fa71f843..2314b79203 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.jsx
@@ -23,7 +23,7 @@ import {
patchPipelineManuscriptComment, generatePipelineManuscriptFix, acceptPipelineManuscriptFix,
undoPipelineManuscriptFix,
} from '../../../services/api';
-import { SEVERITY_TONE, CATEGORY_LABEL, SUBTYPE_LABEL } from './constants';
+import { SEVERITY_TONE, CATEGORY_LABEL, subtypeLabel } from './constants';
// Truncated comment id + copy button — so a note that looks wrong can be quoted
// by id when reporting/debugging.
@@ -133,7 +133,7 @@ export function Badge({ comment }) {
<span className="text-[10px] uppercase tracking-wider text-gray-500">{CATEGORY_LABEL[comment.category] || comment.category}</span>
{comment.subtype ? (
<span className="text-[10px] px-1.5 py-0.5 rounded border border-port-border text-gray-400" title="Why this line was flagged">
- {SUBTYPE_LABEL[comment.subtype] || comment.subtype}
+ {subtypeLabel(comment.subtype)}
</span>
) : null}
{comment.dismissReason === 'false-positive' ? (
diff --git a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx
index cdeffdeb1b..c5e2107853 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptCommentCard.test.jsx
@@ -246,4 +246,12 @@ describe('ManuscriptCommentCard Badge — subtype (#1626)', () => {
render(<Badge comment={{ ...baseComment, category: 'dialogue', subtype: null }} />);
expect(screen.queryByText('Emotion-tell')).toBeNull();
});
+
+ it('renders a prototype-key subtype as its raw string without crashing', () => {
+ // A hand-edited / older-peer record whose subtype is a prototype key must not
+ // resolve to an inherited Object.prototype member (a truthy non-string) — that
+ // would throw "Objects are not valid as a React child" and blank the card.
+ render(<Badge comment={{ ...baseComment, category: 'dialogue', subtype: '__proto__' }} />);
+ expect(screen.getByText('__proto__')).toBeTruthy();
+ });
});
diff --git a/client/src/components/pipeline/manuscript/constants.js b/client/src/components/pipeline/manuscript/constants.js
index e146552a6e..9267fd5397 100644
--- a/client/src/components/pipeline/manuscript/constants.js
+++ b/client/src/components/pipeline/manuscript/constants.js
@@ -69,6 +69,14 @@ export const SUBTYPE_LABEL = {
'relationship-report': 'Relationship-report',
};
+// Resolve a subtype to its display label. Use this (not a bare
+// `SUBTYPE_LABEL[subtype] || subtype`) so a hand-edited / older-peer record whose
+// subtype is a prototype key (`__proto__`, `constructor`, `toString`) can't return
+// an inherited Object.prototype member — a truthy non-string that the `|| subtype`
+// fallback wouldn't catch and that React then throws on as a non-element child.
+export const subtypeLabel = (subtype) =>
+ (Object.prototype.hasOwnProperty.call(SUBTYPE_LABEL, subtype) ? SUBTYPE_LABEL[subtype] : null) || subtype;
+
// Approximate a textarea's height to its content so the manuscript reads as one
// continuous scroll (lets jump-to-anchor scroll the page, not an inner box).
export const rowsFor = (text) => Math.min(400, Math.max(8, (text || '').split('\n').length + 1));
diff --git a/data.reference/prompts/stages/pipeline-editorial-on-the-nose.md b/data.reference/prompts/stages/pipeline-editorial-on-the-nose.md
index 9b9a5eff65..18f2a9b302 100644
--- a/data.reference/prompts/stages/pipeline-editorial-on-the-nose.md
+++ b/data.reference/prompts/stages/pipeline-editorial-on-the-nose.md
@@ -52,7 +52,11 @@ line reads on-the-nose and how to fix it:
characters rather than dramatizing it through how they treat each other.
When a line spans more than one, pick the **dominant** failure — the one the
-fix should target first.
+fix should target first. A line flagged only for *answering its own question*
+(too-literal call-and-response, no evasion) still takes the subtype of what the
+over-direct answer over-states — the feeling (`emotion-tell`), the fact
+(`exposition`), or the bond (`relationship-report`) it lays bare. Every finding
+gets exactly one of these three labels.
## Manuscript
diff --git a/scripts/migrations/144-editorial-on-the-nose-subtype.js b/scripts/migrations/144-editorial-on-the-nose-subtype.js
index 45eff12e98..d13f044b7d 100644
--- a/scripts/migrations/144-editorial-on-the-nose-subtype.js
+++ b/scripts/migrations/144-editorial-on-the-nose-subtype.js
@@ -33,7 +33,7 @@ export const ACCEPTED_OLD_MD5 = {
// file's only prior migration (112) is a seed that tracks no hash, so there are
// no earlier MD5 tables to mirror into.
export const NEW_SHIPPED_MD5 = {
- 'pipeline-editorial-on-the-nose.md': '8d9038a2b197728f6edeedb84699f364',
+ 'pipeline-editorial-on-the-nose.md': 'e5786fb019e5bf19c7aa6ed0c8b35cda',
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.js
index 221e42390c..8014087190 100644
--- a/scripts/setup-data-drift.test.js
+++ b/scripts/setup-data-drift.test.js
@@ -68,7 +68,7 @@ const EXPECTED_STAGE_NEW = {
'pipeline-manuscript-fix.md': 'e2baaf0f2f53c8aa1e934a428c0ca583',
'pipeline-editorial-telling-emotion.md': '871f7e8bea2a2d95f28875ab45a318e2',
'pipeline-editorial-chekhov.md': '1f8a1696b5e4f476051dc5b2e5737db9',
- 'pipeline-editorial-on-the-nose.md': '8d9038a2b197728f6edeedb84699f364',
+ 'pipeline-editorial-on-the-nose.md': 'e5786fb019e5bf19c7aa6ed0c8b35cda',
'pipeline-tv-script.md': '376f779f4687b598f1c92ca4e770fd5a',
};
const EXPECTED_PARTIAL_OLD = {
diff --git a/server/services/pipeline/manuscriptReview.js b/server/services/pipeline/manuscriptReview.js
index 36b6d59cab..0f81a21793 100644
--- a/server/services/pipeline/manuscriptReview.js
+++ b/server/services/pipeline/manuscriptReview.js
@@ -383,8 +383,16 @@ export async function seedReviewFromFindings(seriesId, findings, { runId = null,
// on-the-nose check sub-classified its output gains the label on the next
// run without the user having to clear it — the finding key is unchanged,
// so the merge path (not the append path) is the only place it can land.
- if ((match.subtype ?? null) !== (c.subtype ?? null)) {
- patch.subtype = match.subtype ?? null;
+ // Only ADOPT a recognized (non-null) subtype; never clobber a stored
+ // classification back to null. `match.subtype` is null both when the model
+ // omitted the field AND when it returned an off-list value (checkRegistry's
+ // mapLlmFindings collapses both to null), so a non-deterministic re-run
+ // that drops/garbles the label must NOT erase the prior good one — that's
+ // the "absent vs intentionally empty" rule (there is no model signal for
+ // "this line is no longer this subtype"). A genuinely different non-null
+ // subtype still updates (a real re-classification).
+ if (match.subtype != null && match.subtype !== (c.subtype ?? null)) {
+ patch.subtype = match.subtype;
refreshedCount += 1;
}
}
diff --git a/server/services/pipeline/manuscriptReview.test.js b/server/services/pipeline/manuscriptReview.test.js
index 3397b5d0a4..e64e6d0ed5 100644
--- a/server/services/pipeline/manuscriptReview.test.js
+++ b/server/services/pipeline/manuscriptReview.test.js
@@ -142,6 +142,26 @@ describe('manuscriptReview — record-event emission on write', () => {
expect(same.subtype).toBe('emotion-tell');
});
+ it('re-surfacing a finding does NOT clobber a stored subtype back to null when the run omits it (#1626)', async () => {
+ // Run 1 classifies the finding.
+ const seeded = await seedReviewFromFindings('ser-subtype-preserve', [
+ { checkId: 'dialogue.on-the-nose', category: 'dialogue', issueNumber: 3, subtype: 'emotion-tell', problem: 'names the feeling', anchorQuote: 'I am angry' },
+ ]);
+ expect(seeded.comments[0].subtype).toBe('emotion-tell');
+ const id = seeded.comments[0].id;
+
+ // Run 2 re-surfaces the SAME finding (same key) but the non-deterministic LLM
+ // omits the subtype this time — the runner collapses absent AND off-list to
+ // null. The merge must PRESERVE the prior classification, not erase it (the
+ // badge would otherwise silently flicker off on re-review).
+ const next = await seedReviewFromFindings('ser-subtype-preserve', [
+ { checkId: 'dialogue.on-the-nose', category: 'dialogue', issueNumber: 3, problem: 'names the feeling', anchorQuote: 'I am angry' },
+ ]);
+ const same = next.comments.find((c) => c.id === id);
+ expect(same).toBeDefined();
+ expect(same.subtype).toBe('emotion-tell');
+ });
+
it('persists replacementStrategy (explicit value, derived from category, and legacy fallback)', async () => {
const seeded = await seedReviewFromFindings('ser-4', [
{ category: 'comic-structure', problem: 'page is prose', suggestion: 'Panel 1 …', anchorQuote: 'PAGE 5' },