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 (claude): wire countSectionBreaks into computeSlopPenalty
Adam Eivy544a0f11bf4a
diff --git a/server/lib/editorial/slopScore.js b/server/lib/editorial/slopScore.jsindex c4151208e1..3b13e8588f 100644--- a/server/lib/editorial/slopScore.js+++ b/server/lib/editorial/slopScore.js@@ -554,13 +554,16 @@ export const SLOP_PENALTY_WEIGHTS = Object.freeze({transitionRatioThreshold: 0.3,highTransitionRatioPenalty: 0.75,paragraphUniformityPenalty: 0.75,+ sectionBreakThresholdPer1000: 8,+ sectionBreakPenalty: 0.5,});/*** Composite deterministic slop penalty (0–10, clamped) for `text`, combining- * every detector above PLUS the sentence-length CV already measured by- * `measureSentenceRhythm` (repetition.js) — read here for scoring only, never- * re-emitted as its own finding (see the module doc comment's dedupe note).+ * every detector above — including `countSectionBreaks` — PLUS the+ * sentence-length CV already measured by `measureSentenceRhythm`+ * (repetition.js) — read here for scoring only, never re-emitted as its own+ * finding (see the module doc comment's dedupe note).** @param {string} text* @param {object} [opts] passed through to every underlying detector@@ -589,5 +592,10 @@ export function computeSlopPenalty(text, opts = {}) {if (paragraphLengthUniformity(text, opts).length > 0) penalty += w.paragraphUniformityPenalty;+ const words = tokenizeWords(text).length;+ const breaks = countSectionBreaks(text);+ const breakRate = words > 0 ? (breaks / words) * 1000 : 0;+ if (breaks > 0 && breakRate >= w.sectionBreakThresholdPer1000) penalty += w.sectionBreakPenalty;+return Math.max(0, Math.min(10, Math.round(penalty * 100) / 100));}diff --git a/server/lib/editorial/slopScore.test.js b/server/lib/editorial/slopScore.test.jsindex be45d16f99..d8d2584b91 100644--- a/server/lib/editorial/slopScore.test.js+++ b/server/lib/editorial/slopScore.test.js@@ -354,6 +354,17 @@ describe('computeSlopPenalty', () => {expect(penalty).toBeLessThanOrEqual(SLOP_PENALTY_WEIGHTS.tier1Cap + 0.01);});+ it('adds the section-break penalty for an over-fragmented rate of scene breaks', () => {+ // 40 words total (two 20-word paragraphs), 1 section-break line -> 25/1000+ // words, far above the default 8/1000 threshold. Regression test:+ // computeSlopPenalty must actually fold in countSectionBreaks (previously+ // documented but not wired — caught in review).+ const prose = Array.from({ length: 20 }, (_, i) => `word${i}`).join(' ');+ const text = [prose, '***', prose].join('\n');+ const penalty = computeSlopPenalty(text);+ expect(penalty).toBeGreaterThanOrEqual(SLOP_PENALTY_WEIGHTS.sectionBreakPenalty);+ });+it('never exceeds 10 even for an adversarially slop-heavy passage', () => {const adversarial = [TIER1_BANNED_WORDS.join(' '),