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([med-pipeline-server-services-pipeline-arcplanner-2]): route safeLabel through stripAnsi for full CSI removal

[._.]/ Adam Eivy824f69d33eaf
diff --git a/server/services/pipeline/arcPlanner.js b/server/services/pipeline/arcPlanner.js
index b4d091d6c8..5f83460817 100644
--- a/server/services/pipeline/arcPlanner.js
+++ b/server/services/pipeline/arcPlanner.js
@@ -21,6 +21,7 @@
import { runStagedLLM } from '../../lib/stageRunner.js';
import { ServerError } from '../../lib/errorHandler.js';
+import { stripAnsi } from '../../lib/ansiStrip.js';
import { getSeries, updateSeries, updateSeasonOnSeries, ARC_LOCKABLE_FIELDS } from './series.js';
import { listIssues, updateIssue, recomputeIssueNumbersForSeries, getIssue, updateStageWithLatest, assertStageUnlocked } from './issues.js';
import { emitRecordUpdated, withReexportSuppressed } from '../sharing/recordEvents.js';
@@ -1153,7 +1154,10 @@ export function buildSeasonRemap(droppedOldSeasons, newlyMintedSeasons) {
// the stable id when the title is empty after sanitization.
const safeLabel = (s) => {
const raw = typeof s.title === 'string' ? s.title : '';
- const t = raw
+ // stripAnsi removes full ESC + CSI/OSC sequences (so "[31m" payload
+ // tails don't leak through); the trailing control-char sweep catches
+ // any bare C0/C1 bytes the regex doesn't match.
+ const t = stripAnsi(raw)
.replace(/[\u0000-\u001F\u007F-\u009F]+/g, ' ')
.replace(/\s+/g, ' ')
.trim()
diff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.js
index a08c11d510..a3a23c4bfa 100644
--- a/server/services/pipeline/arcPlanner.test.js
+++ b/server/services/pipeline/arcPlanner.test.js
@@ -1058,14 +1058,17 @@ describe('arcPlanner — buildSeasonRemap', () => {
warnSpy.mockRestore();
});
- it('strips C0/C1 control chars and ANSI escapes from titles before logging', () => {
+ it('strips C0/C1 control chars and full ANSI CSI sequences from titles before logging', () => {
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const dropped = [{ id: 'old1', number: 1, title: 'Pre\x1b[31mEvil\x1b[0mSuffix\x07' }];
const minted = [{ id: 'new1', number: 2, title: 'Clean\u0085Title' }]; // U+0085 = NEL (C1)
planner.buildSeasonRemap(dropped, minted);
const msg = warnSpy.mock.calls[0][0];
expect(msg).not.toMatch(/[\u0000-\u001F\u007F-\u009F]/);
- expect(msg).toContain('Pre [31mEvil [0mSuffix');
+ // stripAnsi removes the full CSI sequences (ESC + '[31m' / ESC + '[0m'),
+ // not just the ESC byte — so the '[31m' / '[0m' payload tails do NOT leak.
+ expect(msg).toContain('PreEvilSuffix');
+ expect(msg).not.toMatch(/\[31m|\[0m/);
expect(msg).toContain('Clean Title');
warnSpy.mockRestore();
});