Complete subnet immune autopsy UI and prefix normalization.
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
Normalize /24 labels for autopsy API and cred-graph triggers; add Emberwake/Path Tracer autopsy cards and Vitest coverage for Seer feed consumers.
This commit is contained in:
27
server/web/src/help/subnetAutopsy.test.ts
Normal file
27
server/web/src/help/subnetAutopsy.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseSeerSubnetAutopsy, subnetAutopsyPrefix } from './subnetAutopsy';
|
||||
|
||||
describe('subnetAutopsy helpers', () => {
|
||||
it('parses seer subnet immune autopsy events', () => {
|
||||
const ev = parseSeerSubnetAutopsy({
|
||||
type: 'subnet_immune_autopsy',
|
||||
prefix: '10.0.0',
|
||||
cause: 'Subnet 10.0.0 immune pause',
|
||||
packet: { prefix: '10.0.0', fail_count: 5, cause_of_death: 'paused' },
|
||||
});
|
||||
expect(ev?.prefix).toBe('10.0.0');
|
||||
expect(ev?.cause).toContain('immune pause');
|
||||
expect(ev?.packet?.fail_count).toBe(5);
|
||||
});
|
||||
|
||||
it('rejects non-autopsy seer payloads', () => {
|
||||
expect(parseSeerSubnetAutopsy({ type: 'court_debate' })).toBeNull();
|
||||
expect(parseSeerSubnetAutopsy(null)).toBeNull();
|
||||
});
|
||||
|
||||
it('normalizes subnet labels to /24 prefix', () => {
|
||||
expect(subnetAutopsyPrefix('10.0.0.x')).toBe('10.0.0');
|
||||
expect(subnetAutopsyPrefix('10.0.0/24')).toBe('10.0.0');
|
||||
expect(subnetAutopsyPrefix('192.168.5.12')).toBe('192.168.5');
|
||||
});
|
||||
});
|
||||
34
server/web/src/help/subnetAutopsy.ts
Normal file
34
server/web/src/help/subnetAutopsy.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { SubnetAutopsyPacket } from '../types';
|
||||
|
||||
export interface SeerSubnetAutopsyEvent {
|
||||
type: 'subnet_immune_autopsy';
|
||||
prefix: string;
|
||||
triggered?: string;
|
||||
cause?: string;
|
||||
packet?: SubnetAutopsyPacket;
|
||||
}
|
||||
|
||||
export function parseSeerSubnetAutopsy(payload: unknown): SeerSubnetAutopsyEvent | null {
|
||||
if (!payload || typeof payload !== 'object') return null;
|
||||
const raw = payload as Record<string, unknown>;
|
||||
if (raw.type !== 'subnet_immune_autopsy') return null;
|
||||
const prefix = typeof raw.prefix === 'string' ? raw.prefix.trim() : '';
|
||||
if (!prefix) return null;
|
||||
return {
|
||||
type: 'subnet_immune_autopsy',
|
||||
prefix,
|
||||
triggered: typeof raw.triggered === 'string' ? raw.triggered : undefined,
|
||||
cause: typeof raw.cause === 'string' ? raw.cause : undefined,
|
||||
packet: raw.packet as SubnetAutopsyPacket | undefined,
|
||||
};
|
||||
}
|
||||
|
||||
/** Normalize subnet labels to /24 prefix keys used by the API. */
|
||||
export function subnetAutopsyPrefix(label: string): string {
|
||||
const s = label.trim().replace(/\.x$/i, '').replace(/\/24$/, '');
|
||||
const parts = s.split('.');
|
||||
if (parts.length >= 3) {
|
||||
return `${parts[0]}.${parts[1]}.${parts[2]}`;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
Reference in New Issue
Block a user