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
feat: cut passive-voice false positives via context tuning (#1593)
[._.]/ Adam Eivye66bce9b5096
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 61b73c8f3b..75cc7d81f0 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -51,6 +51,8 @@## Editorial checks+- **[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`)+- **[issue-1581] A new editorial check catches timeline and canon contradictions — a dead character who reappears alive, an age that contradicts the bible, an impossible chronology.** PortOS had no editorial check for internal contradictions against canon and the story's own timeline, so a character killed in issue 3 who walks back in alive in issue 6, an age the prose contradicts (the bible says 16, the page says "in her 30s"), or a journey that takes eight days but is dated to day two could slip through to the reader — the kind of mistake that's nearly impossible to catch by eye once an arc spans months of drafting. The new **Timeline / canon contradiction** check (`continuity.timeline-contradiction`) reconciles the stitched manuscript against the **continuity-bible facts ledger** (the ground-truth ages, dates & elapsed time, locations, and world rules already extracted by the continuity bible), the canon character facts (age, role, status, description), the reverse-outline scene ordering (for chronology), and the authored per-character arcs — flagging each contradiction with the two facts that conflict and a verbatim anchor. It runs across the whole manuscript — carrying each character's last-known state (alive/dead, age, location) forward between chunks so a death-then-resurrection that spans chapters is actually visible — and degrades to a prose-only scan when no canon or outline exists. It's a default-on series check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking plot-breaking contradictions high-severity per finding. Its findings go stale (and re-run) when any source it reads drifts — including the continuity-bible ledger — via the new `continuityBible` editorial source. (`server/lib/editorial/checkRegistry.js`, `server/services/pipeline/editorial/checkRunner.js`, `data.reference/prompts/stages/pipeline-editorial-timeline-contradiction.md`, `scripts/migrations/129-editorial-timeline-contradiction-stage.js`)- **[issue-1582] A new editorial check catches unearned personality shifts — a reserved character who suddenly cracks jokes, a stated fear silently ignored, knowledge that appears with no on-page learning.** PortOS's `arc.transitions` check finds *change moments* but nothing flagged a change the story never *earns*: a guarded character trading easy banter a chapter later with no beat to motivate it, an established trait (a fear, an allergy, a skill) quietly contradicted, or a POV character who acts on information they were never shown learning. These read as author slips rather than growth and are hard to catch by eye once an arc spans months of drafting. The new **Character consistency** check (`character.consistency`) reconciles the stitched manuscript against the established canon character *traits* (personality, fixed traits, mannerisms, likes/dislikes, speech), the reverse-outline scene ordering (to spot a knowledge jump within a scene), and — crucially — the **authored per-character arcs**, so an intentional, earned transition the author recorded is *not* flagged. It runs across the whole manuscript, carrying each character's established temperament forward between chunks so a baseline set in an early chapter and an unearned shift in a later one are visible together, and degrades to a prose-only scan when no canon or outline exists. It's a default-on series check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking trait contradictions that break a plot beat high-severity per finding. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-character-consistency.md`, `scripts/migrations/130-editorial-character-consistency-stage.js`)diff --git a/server/lib/editorial/README.md b/server/lib/editorial/README.mdindex a9250ac91c..de9be0245e 100644--- a/server/lib/editorial/README.md+++ b/server/lib/editorial/README.md@@ -155,7 +155,7 @@ runner-injected `ctx.callInlineLLM` (an inline-prompt sibling of| `nameSimilarity.js` | Pure, dependency-free name-confusability primitives for `naming.dissimilar-names` (#1291): `normalizeName`, `vowelSkeleton`, `soundex` (phonetic key), `levenshtein` (edit distance), `nameSimilaritySignals` (the per-pair signal list, with option toggles), and `firstLetterHistogram` / `findFirstLetterClusters` (cast first-letter crowding). || `cliches.js` | Pure, dependency-free cliché + overwriting primitives for `prose.cliches` and `prose.modifier-stacking` (#1308): `CLICHE_PHRASES` (seed stock-simile/idiom list), `findCliches` (whole-word phrase scan with house-style allow/extra lists), and `findModifierStacking` (cumulative no-comma runs of 3+ stacked adjectives/adverbs). The LLM sibling `prose.dead-metaphor` handles the judgment cases (mixed/dead metaphor, novel clichés, purple prose). || `italicThoughts.js` | Pure, dependency-free italic-thought primitive for `prose.italic-thoughts` (#1300): `findItalicThoughts` (multi-word markdown `*…*` / `_…_` italic runs, dedup + word-count threshold so single-word emphasis, bold, and `snake_case` are skipped). The LLM siblings (`opening.wrong-start`, `prose.mirror-description`, `dialogue.pleasantries`, `prose.kill-your-darlings`) handle the judgment cases in the #1300 anti-pattern bundle. |-| `proseTics.js` | Pure, dependency-free copy-edit prose-tic primitives for the #1306 line-edit group: `tokenizeWords` / `splitSentences` (shared tokenization), `findFilterWords` (`prose.filter-words`), `findCrutchWords` (`prose.crutch-words`), `findAdverbs` (`prose.adverbs` — `-ly` adverbs + dialogue-tag adverbs), `findPassiveVoice` (`prose.passive-voice` — be-verb + past-participle heuristic), `findGestures` (`prose.repeated-gestures` — gesture tally + body-part autonomy), plus the seed `FILTER_WORDS` / `CRUTCH_WORDS` / `GESTURE_WORDS` lists. The LLM sibling `prose.telling-emotion` handles the named-emotion judgment case. |+| `proseTics.js` | Pure, dependency-free copy-edit prose-tic primitives for the #1306 line-edit group: `tokenizeWords` / `splitSentences` (shared tokenization), `findFilterWords` (`prose.filter-words`), `findCrutchWords` (`prose.crutch-words`), `findAdverbs` (`prose.adverbs` — `-ly` adverbs + dialogue-tag adverbs), `findPassiveVoice` (`prose.passive-voice` — be-verb + past-participle heuristic; classifies each hit `weak`/`stative`/`mood` + `byAgent` so #1593 context tuning can suppress intentional passive) and its `filterPassiveVoice` companion (drops `stative` predicate-adjectives + `mood` setting images unless `suppressIntentional` is off), `findGestures` (`prose.repeated-gestures` — gesture tally + body-part autonomy), plus the seed `FILTER_WORDS` / `CRUTCH_WORDS` / `GESTURE_WORDS` lists. The LLM sibling `prose.telling-emotion` handles the named-emotion judgment case. || `repetition.js` | Pure, dependency-free word-echo & rhythm primitives for #1306: `findWordEchoes` (`prose.word-echoes` — distinctive word repeated within a window), `findRepeatedOpeners` (runs of sentences sharing an opener, "He… He… He…"), and `measureSentenceRhythm` (`prose.sentence-rhythm` — sentence-length variation). Reuses `tokenizeWords` / `splitSentences` from `proseTics.js`. || `comicPacing.js` | Pure, dependency-free comic-pacing primitives for the #1314 comic-pacing group: `isSplashPage`, `comicSpreadLayout` (recto/verso + spread + `beginsSpread` page-turn map), `summarizeComicPages`, `analyzePanelRhythm` (`comic.panel-rhythm` — splash overuse / back-to-back splashes / overcrowded pages / grid monotony), `comicPageTurnSummary` + `authoredRevealSummary` (LLM-context renderers for `comic.page-turn-beats`). Operates on already-parsed comic pages (the runner parses each issue's stored comic script and injects them as the `comicScript` source) so the editorial dir stays import-pure. || `shotContinuity.js` | Pure, dependency-free storyboard shot-continuity primitives for the deterministic `visual.shot-continuity` check (#1315): `findAxisReversals` (180°-rule axis flips across a continuity-linked shot pair using `screenDirection`) and `findShotTypeMonotony` (a scene whose classified shots all share one `shotType`). Also `summarizeStoryboardShots` (#1466) — renders the collected `{ issueNumber, scene }` storyboard list into a compact per-scene shot block shared by the LLM siblings `visual.eyeline-match` (gaze reciprocity / eyeline-vs-screen-direction) and `visual.appearance-continuity` (#1467 — diffs the same entity's wardrobe/prop/setting descriptions across shots for contradictions). Reads the shot-grammar fields from `server/lib/shotGrammar.js`. |diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex aff8d5381d..9726f05bcc 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -42,6 +42,7 @@ import {findCrutchWords,findAdverbs,findPassiveVoice,+ filterPassiveVoice,findGestures,} from './proseTics.js';import {@@ -4956,7 +4957,7 @@ export const EDITORIAL_CHECKS = [sources: ['manuscript'],label: 'Passive voice (overuse)',description:- 'Advisory flag for passive-voice overuse — a be-verb + past participle heuristic ("the door was opened", "mistakes were made"). Density-scaled per-1000-word frequency; passive voice is a legitimate choice, so this only flags when the rate is high.',+ 'Advisory flag for passive-voice overuse — a be-verb + past participle heuristic ("the door was opened", "mistakes were made"). Density-scaled per-1000-word frequency; passive voice is a legitimate choice, so this only flags when the rate is high. A context-tuning pass (#1593) reduces false positives by default: predicate-adjective states ("she was exhausted") and setting/weather mood images ("the sky was streaked") are not counted as weak passive, while an explicit "by <agent>" always counts.',scope: 'issue',kind: 'deterministic',category: 'style',@@ -4966,14 +4967,16 @@ export const EDITORIAL_CHECKS = [configSchema: z.object({densityPer1000: z.number().min(0).max(50).default(10),maxFindings: z.number().int().min(1).max(50).default(20),+ suppressIntentional: z.boolean().default(true),}),configFields: [{ key: 'densityPer1000', label: 'Passive-voice rate to flag (per 1000 words)', type: 'number', min: 0, max: 50, step: 1, help: 'Flag a section whose passive-construction frequency per 1000 words is at or above this. Advisory — passive voice is sometimes the right choice.' },{ key: 'maxFindings', label: 'Max findings per run', type: 'number', min: 1, max: 50, step: 1, help: 'Cap findings so a heavy draft can not flood the review.' },+ { key: 'suppressIntentional', label: 'Suppress intentional passive', type: 'boolean', help: 'On by default — skip predicate-adjective states ("she was exhausted") and setting/weather mood images ("the sky was streaked"), which are rarely weak passive. Turn off to count every be-verb + participle (the raw heuristic).' },],gate: (ctx) => (ctx.manuscript || '').trim().length > 0,run: (ctx) => runDensityCheck(ctx, {- scan: (text) => findPassiveVoice(text),+ scan: (text, cfg) => filterPassiveVoice(findPassiveVoice(text), { suppressIntentional: cfg?.suppressIntentional !== false }),noun: 'passive constructions',problem: (count, rate, anchor) => `${count} passive construction${count === 1 ? '' : 's'} (e.g. "${anchor}") — about ${rate}/1000 words. Heavy passive voice distances the reader from who is acting.`,suggestion: 'Rephrase to active voice where it sharpens the prose ("the door was opened by Sam" → "Sam opened the door"). Keep passive where the actor is unknown or beside the point.',diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 60e0acd4f3..3019648c3a 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -4052,6 +4052,17 @@ describe('copy-edit prose-tic bundle (#1306)', () => {expect(/passive/i.test(findings[0].problem)).toBe(true);});+ it('prose.passive-voice suppresses intentional passive by default but counts it when toggled off', () => {+ // 1 weak ("was opened") + 1 stative ("was exhausted") + 1 mood ("sky was streaked").+ const sections = [{ number: 1, content: 'The door was opened. She was exhausted. The sky was streaked with red.' }];+ const suppressed = getCheck(PASSIVE).run({ sections, config: { densityPer1000: 0 }, severityDefault: 'low' });+ expect(suppressed).toHaveLength(1);+ expect(/1 passive construction\b/.test(suppressed[0].problem)).toBe(true);+ // With the context tuning off, the raw heuristic counts all three.+ const raw = getCheck(PASSIVE).run({ sections, config: { densityPer1000: 0, suppressIntentional: false }, severityDefault: 'low' });+ expect(/3 passive constructions/.test(raw[0].problem)).toBe(true);+ });+it('prose.repeated-gestures tallies a gesture across the manuscript and flags body-part autonomy', () => {const sections = [{ number: 1, content: Array(5).fill('He nodded.').join(' ') + ' Her eyes followed him across the room.' },diff --git a/server/lib/editorial/proseTics.js b/server/lib/editorial/proseTics.jsindex 4436044d7a..b7dcce197e 100644--- a/server/lib/editorial/proseTics.js+++ b/server/lib/editorial/proseTics.js@@ -82,6 +82,43 @@ const BE_VERBS = Object.freeze(['is', 'are', 'was', 'were', 'be', 'been', 'being', 'am',]);+// Setting / weather / atmosphere subjects (#1593). When the grammatical subject+// of a be-verb + participle is one of these, the construction is almost always an+// intentional mood/atmosphere image ("the sky was streaked with red", "the room+// was bathed in light", "the street was lined with trees") rather than a weak+// agentive passive. Classified `mood` so the check can suppress/downgrade it.+const SETTING_SUBJECTS = new Set([+ 'sky', 'skies', 'sun', 'moon', 'stars', 'star', 'light', 'lights', 'sunlight',+ 'moonlight', 'starlight', 'dawn', 'dusk', 'twilight', 'horizon', 'rain', 'snow',+ 'wind', 'winds', 'air', 'fog', 'mist', 'haze', 'cloud', 'clouds', 'storm',+ 'world', 'ground', 'earth', 'floor', 'ceiling', 'wall', 'walls', 'room',+ 'hall', 'street', 'streets', 'road', 'path', 'valley', 'mountain', 'mountains',+ 'hills', 'hill', 'forest', 'woods', 'sea', 'ocean', 'water', 'waters', 'river',+ 'lake', 'field', 'fields', 'garden', 'meadow', 'landscape', 'silence', 'quiet',+ 'darkness', 'shadow', 'shadows', 'night', 'morning', 'evening', 'afternoon',+ 'day', 'sunset', 'sunrise', 'surface', 'distance', 'town', 'city', 'village',+]);++// Stative / predicate-adjective participles (#1593). A be-verb + one of these+// reads as a state-of-being adjective ("she was exhausted", "he was determined",+// "the bread was gone"), not an agentive passive — the dominant false-positive+// class for the be-verb + past-participle heuristic. Curated to entries that are+// overwhelmingly adjectival as a predicate; classified `stative` so the check can+// suppress them by default. (A trailing "by <agent>" overrides this to `weak`.)+const STATIVE_PARTICIPLES = new Set([+ // Emotional / mental states+ 'tired', 'exhausted', 'worried', 'scared', 'frightened', 'terrified',+ 'excited', 'interested', 'bored', 'confused', 'surprised', 'amazed',+ 'astonished', 'pleased', 'satisfied', 'delighted', 'annoyed', 'frustrated',+ 'embarrassed', 'ashamed', 'relieved', 'concerned', 'determined', 'depressed',+ 'devastated', 'overwhelmed', 'thrilled', 'disappointed', 'shocked', 'stunned',+ 'intrigued', 'fascinated', 'alarmed', 'troubled', 'convinced', 'resigned',+ 'accustomed', 'amused', 'comforted', 'distracted', 'flustered',+ // Physical / positional states+ 'gone', 'dressed', 'seated', 'married', 'finished', 'done', 'located',+ 'situated', 'positioned', 'prepared', 'gathered',+]);+// Irregular past participles the -ed suffix rule misses. Not exhaustive — the// passive check is advisory, so a missed participle just under-flags (safe).const IRREGULAR_PARTICIPLES = new Set([@@ -267,13 +304,31 @@ function isPastParticiple(lower) {return lower.length >= 4 && lower.endsWith('ed');}+// Whether the subject governing a be-verb at token index `i` is a setting noun.+// The subject is the token right before the be-verb ("the sky was", "her eyes+// were" → "sky"/"eyes"), so a known setting/atmosphere noun there marks the+// construction as an intentional mood image.+function hasSettingSubject(tokens, i) {+ return i > 0 && SETTING_SUBJECTS.has(tokens[i - 1].lower);+}+/*** Passive-voice candidates: a be-verb followed (allowing up to two intervening* adverbs) by a past participle — "was broken", "is quietly forgotten". A* heuristic, advisory only; returns the be-verb…participle span anchored.*+ * Each candidate is classified (#1593) so the check can suppress likely-intentional+ * passives and keep the cheap heuristic as the base tier:+ * - `'weak'` — a genuine agentive passive ("the door was opened"); always+ * `'weak'` when a "by <agent>" phrase follows the participle.+ * - `'stative'` — a predicate-adjective state of being ("she was exhausted"),+ * not an action done to the subject — the dominant FP class.+ * - `'mood'` — a setting/weather/atmosphere image ("the sky was streaked"),+ * intentional passive for mood rather than weak prose.+ * `byAgent` is true when an explicit "by <agent>" follows the participle.+ ** @param {string} text- * @returns {Array<{ index: number, anchor: string, be: string, participle: string }>}+ * @returns {Array<{ index: number, anchor: string, be: string, participle: string, classification: ('weak'|'stative'|'mood'), byAgent: boolean }>}*/export function findPassiveVoice(text) {const tokens = tokenizeWords(text);@@ -289,13 +344,33 @@ export function findPassiveVoice(text) {if (j < tokens.length && isPastParticiple(tokens[j].lower) && !beSet.has(tokens[j].lower)) {const start = tokens[i].index;const end = tokens[j].index + tokens[j].word.length;- out.push({ index: start, anchor: text.slice(start, end), be: tokens[i].lower, participle: tokens[j].lower });+ const participle = tokens[j].lower;+ // An explicit "by <agent>" right after the participle is the unambiguous+ // agentive passive — it wins over stative/mood classification.+ const byAgent = j + 2 < tokens.length && tokens[j + 1].lower === 'by';+ let classification = 'weak';+ if (!byAgent) {+ if (hasSettingSubject(tokens, i)) classification = 'mood';+ else if (STATIVE_PARTICIPLES.has(participle)) classification = 'stative';+ }+ out.push({ index: start, anchor: text.slice(start, end), be: tokens[i].lower, participle, classification, byAgent });i = j; // don't re-anchor the same participle}}return out;}+// Filter passive-voice candidates for the density check (#1593). With+// `suppressIntentional` (the default), only genuine `'weak'` agentive passives+// are counted — `'stative'` predicate-adjectives and `'mood'` setting images are+// dropped as intentional. Set it false to fall back to the raw heuristic (count+// every be-verb + participle). Pure so the check and tests share one filter.+export function filterPassiveVoice(hits, { suppressIntentional = true } = {}) {+ if (!Array.isArray(hits)) return [];+ if (!suppressIntentional) return hits;+ return hits.filter((h) => h.classification === 'weak');+}+// Generate the regular inflections of a base verb: the base, +s, +ed/+d,// +ing, plus doubled-final-consonant (nod → nodded/nodding) and dropped-e// (smile → smiled/smiling) forms. Returns lowercased, de-duped surface forms.diff --git a/server/lib/editorial/proseTics.test.js b/server/lib/editorial/proseTics.test.jsindex d25f554e3e..cf9e496f64 100644--- a/server/lib/editorial/proseTics.test.js+++ b/server/lib/editorial/proseTics.test.js@@ -6,6 +6,7 @@ import {findCrutchWords,findAdverbs,findPassiveVoice,+ filterPassiveVoice,findGestures,FILTER_WORDS,CRUTCH_WORDS,@@ -150,6 +151,47 @@ describe('findPassiveVoice', () => {it('does not flag a be-verb with no participle', () => {expect(findPassiveVoice('She was happy.')).toEqual([]);});++ it('classifies an agentive passive as weak', () => {+ const [hit] = findPassiveVoice('The door was opened by Sam.');+ expect(hit.classification).toBe('weak');+ expect(hit.byAgent).toBe(true);+ });++ it('classifies a predicate-adjective state as stative', () => {+ const [hit] = findPassiveVoice('She was exhausted.');+ expect(hit.classification).toBe('stative');+ expect(hit.byAgent).toBe(false);+ });++ it('classifies a setting/weather subject as mood', () => {+ const [hit] = findPassiveVoice('The sky was streaked with red.');+ expect(hit.classification).toBe('mood');+ });++ it('an explicit "by <agent>" overrides a stative participle to weak', () => {+ const [hit] = findPassiveVoice('She was exhausted by the climb.');+ expect(hit.byAgent).toBe(true);+ expect(hit.classification).toBe('weak');+ });+});++describe('filterPassiveVoice', () => {+ const text = 'The door was opened by Sam. She was exhausted. The sky was streaked with red.';++ it('keeps only weak passive by default (drops stative + mood)', () => {+ const kept = filterPassiveVoice(findPassiveVoice(text));+ expect(kept.map((h) => h.classification)).toEqual(['weak']);+ });++ it('keeps every candidate when suppressIntentional is off (raw heuristic)', () => {+ const kept = filterPassiveVoice(findPassiveVoice(text), { suppressIntentional: false });+ expect(kept.length).toBe(3);+ });++ it('tolerates a non-array input', () => {+ expect(filterPassiveVoice(null)).toEqual([]);+ });});describe('findGestures', () => {