Add Path Tracer onion timeline fork/merge with ghost branches and Seer feed.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled

Operators fork at hop N to run persona ensembles in parallel on the target agent until mining links; winners merge back into the canonical SQLite-persisted session with WS and Seer events plus mermaid branch graphs in the UI.
This commit is contained in:
AetherForge
2026-06-07 09:20:51 -07:00
parent 23d107b144
commit e1cecd8aef
6 changed files with 1056 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/**
* @vitest-environment node
*/
import { describe, expect, it } from 'vitest';
import {
branchStatusClass,
ghostBranchesByHop,
mergeMermaidStyles,
pickMergeCandidate,
} from './pathTracerTimeline';
import type { PathTraceTimelineBranch } from './pathTracerTimeline';
function branch(partial: Partial<PathTraceTimelineBranch>): PathTraceTimelineBranch {
return {
id: 'b1',
fork_hop_index: 0,
status: 'running',
is_ghost: true,
...partial,
};
}
describe('pathTracerTimeline', () => {
it('groups ghost branches by fork hop', () => {
const map = ghostBranchesByHop([
branch({ id: 'a', fork_hop_index: 1 }),
branch({ id: 'b', fork_hop_index: 1 }),
branch({ id: 'c', fork_hop_index: 0 }),
]);
expect(map.get(1)?.map((b) => b.id)).toEqual(['a', 'b']);
expect(map.get(0)?.map((b) => b.id)).toEqual(['c']);
});
it('prefers won branch for merge candidate', () => {
const pick = pickMergeCandidate([
branch({ id: 'run', status: 'running' }),
branch({ id: 'win', status: 'won', mining_linked: true, hashrate: 120 }),
]);
expect(pick?.id).toBe('win');
});
it('maps status to CSS class', () => {
expect(branchStatusClass('won')).toBe('won');
expect(branchStatusClass('running')).toBe('running');
expect(branchStatusClass('failed')).toBe('failed');
});
it('appends mermaid classDef styles once', () => {
const raw = 'graph TD\n a --> b';
const styled = mergeMermaidStyles(raw);
expect(styled).toContain('classDef won');
expect(mergeMermaidStyles(styled)).toBe(styled);
});
});