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]): broaden label sanitization to C0/C1 controls + scope suppress warn

[._.]/ Adam Eivy8f868e0c71e5
diff --git a/server/services/pipeline/arcPlanner.js b/server/services/pipeline/arcPlanner.js
index 5804d8a752..b4d091d6c8 100644
--- a/server/services/pipeline/arcPlanner.js
+++ b/server/services/pipeline/arcPlanner.js
@@ -1147,11 +1147,17 @@ export function buildSeasonRemap(droppedOldSeasons, newlyMintedSeasons) {
const oldRemaining = droppedOldSeasons.filter((s) => !remap.has(s.id));
const newRemaining = newlyMintedSeasons.filter((n) => !claimed.has(n.id));
if (oldRemaining.length === 1 && newRemaining.length === 1) {
- // Sanitize titles before logging — LLM-generated text can carry newlines
- // or control chars that would break the project's single-line logging
- // convention; fall back to the stable id when the title is empty.
+ // Sanitize titles before logging — LLM-generated text can carry newlines,
+ // C0/C1 control chars, or ANSI escapes that would break the project's
+ // single-line logging convention or corrupt terminal output; fall back to
+ // the stable id when the title is empty after sanitization.
const safeLabel = (s) => {
- const t = typeof s.title === 'string' ? s.title.replace(/\s+/g, ' ').trim().slice(0, 60) : '';
+ const raw = typeof s.title === 'string' ? s.title : '';
+ const t = raw
+ .replace(/[\u0000-\u001F\u007F-\u009F]+/g, ' ')
+ .replace(/\s+/g, ' ')
+ .trim()
+ .slice(0, 60);
return t || s.id;
};
console.warn(
@@ -1159,7 +1165,14 @@ export function buildSeasonRemap(droppedOldSeasons, newlyMintedSeasons) {
);
remap.set(oldRemaining[0].id, newRemaining[0].id);
claimed.add(newRemaining[0].id);
- } else if (oldRemaining.length && newRemaining.length) {
+ } else if (
+ oldRemaining.length === newRemaining.length
+ && oldRemaining.length > 1
+ ) {
+ // Suppression warn ONLY for the cases where the previous behavior would
+ // have fired the positional fallback (equal counts ≥ 2). Unequal counts
+ // were never positional-fallback candidates, so they don't deserve a
+ // "skipped" message.
console.warn(
`⚠️ buildSeasonRemap skipped positional fallback (${oldRemaining.length} old × ${newRemaining.length} new unmatched) — orphan issues route to ungrouped`,
);
diff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.js
index 33cb996045..a08c11d510 100644
--- a/server/services/pipeline/arcPlanner.test.js
+++ b/server/services/pipeline/arcPlanner.test.js
@@ -1058,6 +1058,18 @@ describe('arcPlanner — buildSeasonRemap', () => {
warnSpy.mockRestore();
});
+ it('strips C0/C1 control chars and ANSI escapes 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');
+ expect(msg).toContain('Clean Title');
+ warnSpy.mockRestore();
+ });
+
it('drops orphans to null when 2+ unmatched on each side after pass 1/2', () => {
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
// Titles diverge AND numbers diverge → Pass 1 (title) and Pass 2 (unique