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([med-pipeline-server-services-pipeline-arcplanner-2]): pin 2x2 unique-number regression test + narrow stripAnsi comment
[._.]/ Adam Eivy9b87348c289d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 7f8358bf89..dbe085893d 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,7 +2,7 @@## Changed-- **[med-pipeline-server-services-pipeline-arcplanner-2] Tighten `buildSeasonRemap` Pass 3 — fire only on forced 1↔1 pairings.** `server/services/pipeline/arcPlanner.js#buildSeasonRemap` previously ran its positional fallback whenever the unmatched-old and unmatched-new counts matched (any positive equal length). With 2+ unmatched on each side that's a guess: the LLM may have reshuffled or renamed everything, and number-sorted positional pairing silently invents wrong `oldSeasonId → newSeasonId` mappings — child issues land under the wrong season instead of the visible "ungrouped" bucket. New guard fires Pass 3 only when exactly one unmatched on each side (a forced 1↔1 pairing with no ambiguity) and logs the pairing it made. When the guard suppresses a 2+×2+ fallback, a warning logs the cardinality and the orphans correctly route to `seasonId: null`. Title labels are sanitized (C0/C1 controls + ANSI escapes stripped, whitespace collapsed, capped at 60 chars) before interpolation to keep logging single-line. The pre-existing "2-old × 2-new with matching numbers" test still passes (Pass 2 unique-number handles it); four new tests cover the 1↔1 firing path, the 2+×2+ suppression path, the newline-collapse sanitizer, and the C0/C1-control-char/ANSI-escape sanitizer. 69/69 arcPlanner tests pass; 518/518 pipeline tests pass.+- **[med-pipeline-server-services-pipeline-arcplanner-2] Tighten `buildSeasonRemap` Pass 3 — fire only on forced 1↔1 pairings.** `server/services/pipeline/arcPlanner.js#buildSeasonRemap` previously ran its positional fallback whenever the unmatched-old and unmatched-new counts matched (any positive equal length). With 2+ unmatched on each side that's a guess: the LLM may have reshuffled or renamed everything, and number-sorted positional pairing silently invents wrong `oldSeasonId → newSeasonId` mappings — child issues land under the wrong season instead of the visible "ungrouped" bucket. New guard fires Pass 3 only when exactly one unmatched on each side (a forced 1↔1 pairing with no ambiguity) and logs the pairing it made. When the guard suppresses a 2+×2+ fallback, a warning logs the cardinality and the orphans correctly route to `seasonId: null`. Title labels are sanitized via the shared `stripAnsi` helper (`server/lib/ansiStrip.js`) plus a C0/C1-control sweep + whitespace collapse + 60-char cap before interpolation to keep logging single-line. Five new tests cover the 1↔1 firing path, the 2+×2+ suppression path, the newline-collapse sanitizer, the full-CSI-sequence sanitizer, and a pinned regression for the 2-old × 2-new matching-numbers case (Pass 2 unique-number handles it; no warning fires). 70/70 arcPlanner tests pass; 518/518 pipeline tests pass.- **[strip-stray-tryreadfile-from-instances-mocks] Drop dead `tryReadFile: vi.fn().mockResolvedValue(null)` entries from two `instances.js` mock factories.** `server/services/sharing/subscriptions.test.js:25` and `server/services/sharing/integration.test.js:44` were a leftover copy-paste from when these tests used to mock `lib/fileUtils.js`; `instances.js` doesn't export `tryReadFile`, so the keys are no-ops that only confuse the next reader. Removed and reformatted both factories onto the project's standard multi-line `vi.mock(..., () => ({ ... }))` shape. The third site PLAN.md referenced — `server/services/mediaAnnotations.test.js` — turned out to be a false positive: its `tryReadFile` lives inside the legitimate `lib/fileUtils.js` mock, and its `instances.js` mock at line 15 is already clean. The 45 tests across the two edited files pass; nothing else changes.diff --git a/server/services/pipeline/arcPlanner.js b/server/services/pipeline/arcPlanner.jsindex 5f83460817..6578e445bf 100644--- a/server/services/pipeline/arcPlanner.js+++ b/server/services/pipeline/arcPlanner.js@@ -1154,9 +1154,13 @@ 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 : '';- // 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.+ // stripAnsi removes full ESC + CSI sequences (so "[31m" payload tails+ // don't leak through). Note: per PLAN.md+ // [ansistrip-osc-alternative-unreachable], OSC sequence bodies do leak+ // through stripAnsi today — extremely unlikely in LLM-generated season+ // titles, but called out here so a future fix to ANSI_PATTERN naturally+ // tightens this path. 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, ' ')diff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.jsindex a3a23c4bfa..11a26e50bd 100644--- a/server/services/pipeline/arcPlanner.test.js+++ b/server/services/pipeline/arcPlanner.test.js@@ -1034,6 +1034,25 @@ describe('arcPlanner — buildSeasonRemap', () => {expect(remap.get('old1')).toBe('new2');});+ it('pairs 2-old × 2-new entirely via unique-number when titles diverge but numbers match', () => {+ // Pre-tightening this case used to flow through Pass 3 (positional fallback);+ // now Pass 2 handles it because the numbers 1↔1 and 2↔2 are each unique.+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const dropped = [+ { id: 'old1', number: 1, title: 'A' },+ { id: 'old2', number: 2, title: 'B' },+ ];+ const minted = [+ { id: 'new1', number: 1, title: 'X' },+ { id: 'new2', number: 2, title: 'Y' },+ ];+ const remap = planner.buildSeasonRemap(dropped, minted);+ expect(remap.get('old1')).toBe('new1');+ expect(remap.get('old2')).toBe('new2');+ expect(warnSpy).not.toHaveBeenCalled();+ warnSpy.mockRestore();+ });+it('falls back positionally when exactly one unmatched on each side (forced 1↔1)', () => {const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});const dropped = [{ id: 'old1', number: 1, title: 'A' }];