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

fix: don't claim chosen-voice baseline on a gated-off run; document σ≈0 boundary (#2179)

Adam Eivyb1023e85ac8f
diff --git a/client/src/pages/PipelineVoiceFingerprint.jsx b/client/src/pages/PipelineVoiceFingerprint.jsx
index 663d793ea5..5f67f35b04 100644
--- a/client/src/pages/PipelineVoiceFingerprint.jsx
+++ b/client/src/pages/PipelineVoiceFingerprint.jsx
@@ -68,7 +68,11 @@ export default function PipelineVoiceFingerprint() {
const outlierSet = new Set((data?.outliers || []).map((o) => outlierKey(o.issue, o.metricKey)));
const hasMatrix = issues.length > 0;
const baselineMode = data?.baselineMode || 'drafted';
- const usesChosenVoice = data?.exemplarBaselineUsed === true;
+ // Only claim the chosen-voice baseline once it was actually applied: a gatedOff
+ // run (< minIssues) still reports the configured mode but computes no comparison
+ // 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;
return (
<div className="h-full overflow-y-auto p-4 md:p-6">
diff --git a/client/src/pages/PipelineVoiceFingerprint.test.jsx b/client/src/pages/PipelineVoiceFingerprint.test.jsx
index 4e9af4eb8f..30771112cb 100644
--- a/client/src/pages/PipelineVoiceFingerprint.test.jsx
+++ b/client/src/pages/PipelineVoiceFingerprint.test.jsx
@@ -106,6 +106,26 @@ describe('PipelineVoiceFingerprint', () => {
expect(screen.getByText('5 words')).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.
+ getVoiceFingerprint.mockResolvedValue({
+ ...MATRIX_PAYLOAD,
+ baselineMode: 'exemplars',
+ exemplarBaselineUsed: true,
+ gatedOff: true,
+ issueCount: 2,
+ outliers: [],
+ series: {},
+ matrix: { metricKeys: ['sentenceLenMean'], issues: [{ issue: 1, words: 5, sentences: 1, metrics: { sentenceLenMean: 5 } }, { issue: 2, words: 4, sentences: 1, metrics: { sentenceLenMean: 4 } }] },
+ });
+ renderAt();
+ await waitFor(() => expect(screen.getByText(/Drift detection is off/)).toBeInTheDocument());
+ // No chosen-voice copy or footer row when the baseline never ran.
+ expect(screen.queryByText(/chosen voice/)).not.toBeInTheDocument();
+ expect(screen.queryByText('voice')).not.toBeInTheDocument();
+ });
+
it('renders an empty state when nothing is drafted', async () => {
getVoiceFingerprint.mockResolvedValue({
...MATRIX_PAYLOAD,
diff --git a/server/lib/editorial/voiceFingerprint.js b/server/lib/editorial/voiceFingerprint.js
index 217f22e176..3eadc412cd 100644
--- a/server/lib/editorial/voiceFingerprint.js
+++ b/server/lib/editorial/voiceFingerprint.js
@@ -501,8 +501,17 @@ export function computeVoiceDrift(manuscript, opts = {}) {
center = effectiveMode === 'blended' ? (mean + target) / 2 : target;
}
series[key] = { mean: round2(mean), std: round2(std), center: round2(center) };
- // A metric with no spread can't have an outlier — and dividing by ~0 σ would
- // manufacture infinite z-scores. Skip it.
+ // A metric with no drafted spread can't have a per-issue OUTLIER — and dividing
+ // by ~0 σ would manufacture infinite z-scores — so skip it. Note the boundary
+ // this leaves for the exemplar/blended baseline (#2179): when every drafted
+ // issue shares the SAME value on a metric (σ≈0) but that shared value sits far
+ // from the chosen-voice center, this per-issue z-score model emits nothing —
+ // there's no per-issue outlier, the whole corpus is uniformly off. That
+ // "uniformly-off-register" case wants a SERIES-level finding (a different shape
+ // than the per-issue outliers here), tracked as a #2179 follow-up. It does NOT
+ // affect the common case the feature targets: issues that drifted the same
+ // DIRECTION still have natural per-metric variance (σ>0), so they still flag
+ // against the chosen-voice center.
if (std < 1e-9) continue;
for (const it of issues) {
const value = it.metrics[key] ?? 0;