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
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:
56
server/web/src/help/seerEvents.ts
Normal file
56
server/web/src/help/seerEvents.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/** Seer feed event from WS `seer_events` or GET /api/v1/seer/stream. */
|
||||
export interface SeerEventRecord {
|
||||
id?: number;
|
||||
event_type: string;
|
||||
agent_id?: string;
|
||||
payload?: Record<string, unknown>;
|
||||
ts?: string;
|
||||
}
|
||||
|
||||
export function isPathTraceTimelineEvent(event: SeerEventRecord): boolean {
|
||||
return event.event_type === 'pathtrace_timeline';
|
||||
}
|
||||
|
||||
export function pathTraceTimelineSummary(event: SeerEventRecord): string {
|
||||
if (!isPathTraceTimelineEvent(event)) return '';
|
||||
const p = event.payload ?? {};
|
||||
const ev = typeof p.event === 'string' ? p.event : 'update';
|
||||
const branch = p.branch as { persona?: string; status?: string; hashrate?: number } | undefined;
|
||||
if (ev === 'fork') return 'Path Tracer fork — ghost branches spawned';
|
||||
if (ev === 'branch_won') {
|
||||
return `Path Tracer branch won (${branch?.persona ?? 'unknown'})${branch?.hashrate ? ` · ${Math.round(branch.hashrate)} H/s` : ''}`;
|
||||
}
|
||||
if (ev === 'merge') return `Path Tracer merged ${branch?.persona ?? 'winner'} into canonical timeline`;
|
||||
return `Path Tracer timeline ${ev}`;
|
||||
}
|
||||
|
||||
export function isSurgicalReplayEvent(event: SeerEventRecord): boolean {
|
||||
return event.event_type === 'surgical_replay';
|
||||
}
|
||||
|
||||
export function surgicalReplaySummary(event: SeerEventRecord): string {
|
||||
if (!isSurgicalReplayEvent(event)) {
|
||||
return '';
|
||||
}
|
||||
const p = event.payload ?? {};
|
||||
const tier = typeof p.failed_tier === 'string' ? p.failed_tier : 'tier';
|
||||
const fix = typeof p.fix_type === 'string' ? p.fix_type : 'fix';
|
||||
const outcome = typeof p.outcome === 'string' ? p.outcome : '';
|
||||
return `Surgical replay ${tier} → ${fix}${outcome ? ` (${outcome})` : ''}`;
|
||||
}
|
||||
|
||||
export function mergeSeerEvents(
|
||||
existing: SeerEventRecord[],
|
||||
incoming: SeerEventRecord | SeerEventRecord[],
|
||||
): SeerEventRecord[] {
|
||||
const batch = Array.isArray(incoming) ? incoming : [incoming];
|
||||
const seen = new Set(existing.map((e) => `${e.id ?? ''}:${e.event_type}:${e.ts ?? ''}`));
|
||||
const merged = [...existing];
|
||||
for (const ev of batch) {
|
||||
const key = `${ev.id ?? ''}:${ev.event_type}:${ev.ts ?? ''}`;
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
merged.unshift(ev);
|
||||
}
|
||||
return merged.slice(0, 200);
|
||||
}
|
||||
Reference in New Issue
Block a user