docs: enterprise refactor plan with ralph specs

This commit is contained in:
debian
2026-03-04 16:17:03 -05:00
parent 4c92712d20
commit f8191133c8
204 changed files with 32722 additions and 422 deletions

View File

@@ -0,0 +1,30 @@
/**
* DOMSnapshotCollector — writes the DOM snapshot at anomaly moment to disk.
*/
import * as fs from 'fs';
import * as path from 'path';
import { IAnomaly, IAnomalyEvidence } from '../../core/interfaces';
import { ICollector, IInteractionAgent } from '../interfaces';
interface HasCaptureState {
captureState(): Promise<{ domSnapshot: string }>;
}
export class DOMSnapshotCollector implements ICollector {
readonly name = 'DOMSnapshotCollector';
constructor(private readonly outputDir: string = './reports') {}
async collect(anomaly: IAnomaly, agent: IInteractionAgent): Promise<IAnomalyEvidence> {
const state = await (agent as HasCaptureState).captureState();
const dir = path.join(this.outputDir, anomaly.id);
fs.mkdirSync(dir, { recursive: true });
const domPath = path.join(dir, 'dom.html');
fs.writeFileSync(domPath, state.domSnapshot, 'utf8');
return { domSnapshotPath: path.relative(this.outputDir, domPath) };
}
}