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
fix: matrix view honors per-series baseline override + correct blended label (#2179)
Adam Eivyd86c3cf368d7
diff --git a/client/src/pages/PipelineVoiceFingerprint.jsx b/client/src/pages/PipelineVoiceFingerprint.jsxindex 5f67f35b04..9fa230488b 100644--- a/client/src/pages/PipelineVoiceFingerprint.jsx+++ b/client/src/pages/PipelineVoiceFingerprint.jsx@@ -73,6 +73,13 @@ export default function PipelineVoiceFingerprint() {// and returns `series: {}`, so the footer row + intro copy must fall back to the// plain description rather than promising a baseline that never ran.const usesChosenVoice = data?.exemplarBaselineUsed === true && !data?.gatedOff;+ // The baseline phrase for the intro copy — blended is the midpoint, NOT the+ // exemplars alone, so it must not be described as "the chosen voice."+ const baselineNoun = !usesChosenVoice+ ? 'series mean'+ : (baselineMode === 'blended'+ ? "blend of the series mean and the style guide's chosen voice"+ : "style guide's chosen voice (its voice exemplars)");return (<div className="h-full overflow-y-auto p-4 md:p-6">@@ -101,11 +108,9 @@ export default function PipelineVoiceFingerprint() {Every drafted issue's prose fingerprint. Each column is a metric; a cellhighlighted in <span className="text-port-warning">amber</span> is astatistical outlier — more than {data?.threshold ?? 1.5}σ from the{' '}- {usesChosenVoice- ? "style guide's chosen voice (its voice exemplars)"- : 'series mean'}{' '}+ {baselineNoun}{' '}on that metric. The bottom rows are the series mean and standard- deviation (σ){usesChosenVoice ? ', plus the chosen-voice baseline the outliers are measured against' : ''}.+ deviation (σ){usesChosenVoice ? `, plus the ${baselineMode === 'blended' ? 'blended' : 'chosen-voice'} baseline the outliers are measured against` : ''}.This measures the same vectors the deterministic{' '}<code className="text-gray-400">style.voice-drift</code> editorial checkflags; it just shows the whole matrix, not only the flagged outliers.diff --git a/client/src/pages/PipelineVoiceFingerprint.test.jsx b/client/src/pages/PipelineVoiceFingerprint.test.jsxindex 30771112cb..daf4034f4b 100644--- a/client/src/pages/PipelineVoiceFingerprint.test.jsx+++ b/client/src/pages/PipelineVoiceFingerprint.test.jsx@@ -106,6 +106,24 @@ describe('PipelineVoiceFingerprint', () => {expect(screen.getByText('5 words')).toBeInTheDocument();});+ it('labels blended mode as a blend, not the chosen voice alone (#2179)', async () => {+ getVoiceFingerprint.mockResolvedValue({+ ...MATRIX_PAYLOAD,+ baselineMode: 'blended',+ exemplarBaselineUsed: true,+ series: {+ sentenceLenMean: { mean: 10.5, std: 3, center: 7.75 },+ dialogueRatio: { mean: 15, std: 8, center: 8.5 },+ },+ });+ renderAt();+ await waitFor(() => expect(screen.getByText('Voice Fingerprint')).toBeInTheDocument());+ // The intro copy calls it a blend, and the footer row is labeled "blend".+ expect(screen.getByText(/blend of the series mean/)).toBeInTheDocument();+ expect(screen.getByText('blend')).toBeInTheDocument();+ expect(screen.queryByText('voice')).not.toBeInTheDocument();+ });+it('does not claim the chosen-voice baseline on a gated-off run (#2179)', async () => {// A gated-off run (< minIssues) still reports the configured mode, but the// baseline was never applied and series is empty — the UI must fall back.diff --git a/server/services/pipeline/voiceFingerprint.js b/server/services/pipeline/voiceFingerprint.jsindex 3e9ab5bc19..6031674f63 100644--- a/server/services/pipeline/voiceFingerprint.js+++ b/server/services/pipeline/voiceFingerprint.js@@ -37,20 +37,37 @@ export const VOICE_DRIFT_CHECK_ID = 'style.voice-drift';/*** Resolve the effective `style.voice-drift` config for a series from the persisted- * per-check settings (threshold / minIssues / vocabularyWells), tolerant of a- * hand-edited or absent slice. `resolveCheckConfig` validates the stored slice- * through the check's Zod `configSchema`, so every key comes back populated with- * its schema default when unset — the caller can trust the fields are present.- * (`style.voice-drift` is statically registered, so `getCheckById` never misses.)+ * per-check settings (threshold / minIssues / vocabularyWells / baselineMode),+ * tolerant of a hand-edited or absent slice. `resolveCheckConfig` validates the+ * stored slice through the check's Zod `configSchema`, so every key comes back+ * populated with its schema default when unset — the caller can trust the fields+ * are present. (`style.voice-drift` is statically registered, so `getCheckById`+ * never misses.)+ *+ * `seriesOverrides` is the series' `editorialCheckConfig` map (#1591): when it+ * carries an override for this check, it is overlaid on the global stored config+ * exactly as `applySeriesCheckConfig` does for the finding-emitting run — so the+ * matrix view and the editor's findings resolve the SAME effective config (a+ * per-series `baselineMode`/threshold override drives both).** @param {object} [settings] pre-loaded settings (optional; fetched when omitted)+ * @param {object} [seriesOverrides] the series' editorialCheckConfig map (optional)* @returns {Promise<{ sigmaThreshold: number, minIssues: number, vocabularyWells: string, maxFindings: number, baselineMode: string }>}*/-export async function resolveVoiceDriftConfig(settings) {+export async function resolveVoiceDriftConfig(settings, seriesOverrides) {const s = settings || await getSettings();const check = getCheckById(s, VOICE_DRIFT_CHECK_ID);- const stored = readChecksSlice(s)[VOICE_DRIFT_CHECK_ID] || {};- return resolveCheckConfig(check, stored.config);+ const stored = readChecksSlice(s)[VOICE_DRIFT_CHECK_ID]?.config;+ const override = seriesOverrides && typeof seriesOverrides === 'object' && !Array.isArray(seriesOverrides)+ ? seriesOverrides[VOICE_DRIFT_CHECK_ID]+ : null;+ // Overlay the per-series override on the global stored config before validating,+ // mirroring applySeriesCheckConfig's `{ ...config, ...override }` merge. A+ // non-object override is ignored (the spread of a non-object is a no-op).+ const merged = (override && typeof override === 'object' && !Array.isArray(override))+ ? { ...(stored || {}), ...override }+ : stored;+ return resolveCheckConfig(check, merged);}/**@@ -83,7 +100,9 @@ export async function getVoiceFingerprint(seriesId) {const [sections, cfg] = await Promise.all([collectManuscriptSections(seriesId),- resolveVoiceDriftConfig(),+ // Overlay this series' per-check overrides (#1591) so the matrix view resolves+ // the same effective config the finding-emitting run does.+ resolveVoiceDriftConfig(undefined, series?.editorialCheckConfig),]);// `cfg` is schema-validated, so sigmaThreshold/minIssues/vocabularyWells/baselineModediff --git a/server/services/pipeline/voiceFingerprint.test.js b/server/services/pipeline/voiceFingerprint.test.jsindex 374d51c58f..752efbd700 100644--- a/server/services/pipeline/voiceFingerprint.test.js+++ b/server/services/pipeline/voiceFingerprint.test.js@@ -20,10 +20,11 @@ let settingsStore = {};let manuscriptCorpus = buildManuscript();let seriesStyleGuide = null;+let seriesEditorialCheckConfig = null;vi.mock('./series.js', () => ({getSeries: vi.fn(async (id) => {if (id === 'missing') throw Object.assign(new Error('nope'), { code: 'PIPELINE_SERIES_NOT_FOUND' });- return { id, name: 'Test Series', styleGuide: seriesStyleGuide };+ return { id, name: 'Test Series', styleGuide: seriesStyleGuide, editorialCheckConfig: seriesEditorialCheckConfig };}),}));@@ -42,6 +43,7 @@ beforeEach(() => {settingsStore = {};manuscriptCorpus = buildManuscript();seriesStyleGuide = null;+ seriesEditorialCheckConfig = null;});describe('resolveVoiceDriftConfig', () => {@@ -66,6 +68,26 @@ describe('resolveVoiceDriftConfig', () => {expect(cfg.minIssues).toBe(3);expect(cfg.vocabularyWells).toBe('trade: forge, anvil');});++ it('overlays a per-series editorialCheckConfig override on the global config (#1591)', async () => {+ settingsStore = {+ pipelineEditorialChecks: {+ checks: { [VOICE_DRIFT_CHECK_ID]: { config: { sigmaThreshold: 2, baselineMode: 'drafted' } } },+ },+ };+ // The series override flips baselineMode and threshold; the un-overridden+ // global sigmaThreshold is replaced, other globals persist.+ const cfg = await resolveVoiceDriftConfig(undefined, {+ [VOICE_DRIFT_CHECK_ID]: { baselineMode: 'blended', sigmaThreshold: 1.2 },+ });+ expect(cfg.baselineMode).toBe('blended');+ expect(cfg.sigmaThreshold).toBe(1.2);+ });++ it('ignores a non-object per-series override', async () => {+ const cfg = await resolveVoiceDriftConfig(undefined, { [VOICE_DRIFT_CHECK_ID]: 'nope' });+ expect(cfg.baselineMode).toBe('drafted');+ });});describe('getVoiceFingerprint', () => {@@ -156,6 +178,17 @@ describe('getVoiceFingerprint', () => {expect(shifted).toBe(true);});+ it('applies a per-series editorialCheckConfig override for the baseline (#2179/#1591)', async () => {+ // Global config leaves baselineMode at the default 'drafted'; the SERIES+ // override flips it to exemplars — the matrix must honor the override, exactly+ // as the finding-emitting run does via applySeriesCheckConfig.+ seriesStyleGuide = { voiceExemplars: [{ passage: METRONOMIC }, { passage: METRONOMIC }] };+ seriesEditorialCheckConfig = { [VOICE_DRIFT_CHECK_ID]: { baselineMode: 'exemplars' } };+ const res = await getVoiceFingerprint('ser-1');+ expect(res.baselineMode).toBe('exemplars');+ expect(res.exemplarBaselineUsed).toBe(true);+ });+it('falls back to drafted when configured for exemplars but the style guide has none (#2179)', async () => {settingsStore = {pipelineEditorialChecks: {