Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 10x 10x 10x 10x 1x 1x 30x 10x 10x 20x 20x 30x 30x 1x 1x 1x 9x 1x 1x 9x 1x 1x 9x 9x 2x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 9x 4x 1x 4x 3x 2x 2x 4x 5x 9x 9x 9x 9x 9x 1x 1x 1x 5x 10x 10x 10x 6x 6x 6x 6x 6x 10x 10x 5x 5x 5x 5x 5x 5x 3x 3x 3x 2x 2x 2x 2x 2x 3x 1x 1x 1x 3x 5x 5x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x | import * as fs from 'fs';
import * as path from 'path';
import { DyE2E_VQA_FeatureManifest_Interface } from '../_models/interfaces/feature-manifest.interface';
/**
* `DyE2E_VQA_ComparisonBundle_Generator` — MP-F: re-audit comparison-bundle (spec §15).
*
* Két korábbi run-folder-t kap inputként + a re-audit-elendő finding-ID-k listáját.
* Output: a `before` bundle-en BELÜLI `comparison/` mappa, ami az AI agentnek strukturált
* delta-t mutat:
* - `comparison/README.md` — review-instrukció (decide: verified / reopened / partial)
* - `comparison/before-run-id.txt`, `after-run-id.txt`
* - `comparison/finding-refs.json` — milyen finding-eket nézzünk
* - `comparison/dom-diff/<state>/<viewport>.json` — DOM-snapshot-delta
* - `comparison/evidence-diff/<state>/<viewport>.json` — detector verdict-delta
* - `comparison/a11y-diff/<state>/<viewport>.json` — axe-finding-delta
*
* **scope-LOCK**: NEM dönt. Az AI agent dönti el verified/reopened-et.
*/
export interface DyE2E_VQA_ComparisonBundle_Options {
/** Bundle-relative output mappa-név (default: `comparison`). */
outputSubdir?: string;
}
export interface DyE2E_VQA_ComparisonBundle_Result {
comparisonPath: string;
filesWritten: string[];
statesCompared: number;
viewportsCompared: number;
}
export class DyE2E_VQA_ComparisonBundle_Generator {
static generate(
beforeBundlePath: string,
afterBundlePath: string,
manifest: DyE2E_VQA_FeatureManifest_Interface,
findingRefs: string[],
options?: DyE2E_VQA_ComparisonBundle_Options,
): DyE2E_VQA_ComparisonBundle_Result {
const subdir: string = options?.outputSubdir ?? 'comparison';
const comparisonPath: string = path.join(afterBundlePath, subdir);
fs.mkdirSync(comparisonPath, { recursive: true });
const orientations: ('portrait' | 'landscape')[] =
manifest.orientations && manifest.orientations.length > 0
? manifest.orientations
: ['portrait'];
const filesWritten: string[] = [];
// run-id refs (read meta)
const beforeRunId: string = this.readMeta(beforeBundlePath, 'run-id.txt');
const afterRunId: string = this.readMeta(afterBundlePath, 'run-id.txt');
fs.writeFileSync(path.join(comparisonPath, 'before-run-id.txt'), beforeRunId);
fs.writeFileSync(path.join(comparisonPath, 'after-run-id.txt'), afterRunId);
filesWritten.push('before-run-id.txt', 'after-run-id.txt');
// finding-refs.json
fs.writeFileSync(
path.join(comparisonPath, 'finding-refs.json'),
JSON.stringify({ findingRefs, beforeRunId, afterRunId }, null, 2),
);
filesWritten.push('finding-refs.json');
// README.md — re-audit decision-instrukció
fs.writeFileSync(path.join(comparisonPath, 'README.md'), this.renderReadme(
manifest, findingRefs, beforeRunId, afterRunId,
));
filesWritten.push('README.md');
// Per (state × viewport × orientation) DOM-diff + evidence-diff + a11y-diff
let statesCompared: number = 0;
let viewportsCompared: number = 0;
for (const s of manifest.states) {
let stateHadFiles: boolean = false;
for (const v of manifest.viewports) {
for (const o of orientations) {
const subPath: string = path.join(s.stateId, `${v.key}-${o}`);
const beforeStateDir: string = path.join(beforeBundlePath, 'states', subPath);
const afterStateDir: string = path.join(afterBundlePath, 'states', subPath);
// dom-diff
const beforeDom: unknown = this.tryReadJson(path.join(beforeStateDir, 'dom-snapshot.json'));
const afterDom: unknown = this.tryReadJson(path.join(afterStateDir, 'dom-snapshot.json'));
if (beforeDom !== null || afterDom !== null) {
const out: string = path.join(comparisonPath, 'dom-diff', subPath + '.json');
fs.mkdirSync(path.dirname(out), { recursive: true });
fs.writeFileSync(out, JSON.stringify(this.deepDiff(beforeDom, afterDom), null, 2));
filesWritten.push(`dom-diff/${subPath}.json`);
}
// evidence-diff
const beforeEv: unknown = this.tryReadJson(path.join(beforeStateDir, 'evidence.json'));
const afterEv: unknown = this.tryReadJson(path.join(afterStateDir, 'evidence.json'));
if (beforeEv !== null || afterEv !== null) {
const out: string = path.join(comparisonPath, 'evidence-diff', subPath + '.json');
fs.mkdirSync(path.dirname(out), { recursive: true });
fs.writeFileSync(out, JSON.stringify(
this.diffEvidenceArrays(beforeEv, afterEv),
null, 2,
));
filesWritten.push(`evidence-diff/${subPath}.json`);
}
// a11y-diff (opcionális; ha valamelyik run-ban nincs, deeper-diff)
const beforeA11y: unknown = this.tryReadJson(path.join(beforeStateDir, 'a11y.json'));
const afterA11y: unknown = this.tryReadJson(path.join(afterStateDir, 'a11y.json'));
if (beforeA11y !== null || afterA11y !== null) {
const out: string = path.join(comparisonPath, 'a11y-diff', subPath + '.json');
fs.mkdirSync(path.dirname(out), { recursive: true });
fs.writeFileSync(out, JSON.stringify(this.deepDiff(beforeA11y, afterA11y), null, 2));
filesWritten.push(`a11y-diff/${subPath}.json`);
}
if (afterStateDir && fs.existsSync(afterStateDir)) {
viewportsCompared++;
stateHadFiles = true;
}
}
}
if (stateHadFiles) {
statesCompared++;
}
}
return { comparisonPath, filesWritten, statesCompared, viewportsCompared };
}
private static readMeta(bundlePath: string, fileName: string): string {
const p: string = path.join(bundlePath, 'meta', fileName);
if (fs.existsSync(p)) {
return fs.readFileSync(p, 'utf-8').trim();
}
return 'unknown';
}
private static tryReadJson(p: string): unknown {
if (!fs.existsSync(p)) {
return null;
}
try {
return JSON.parse(fs.readFileSync(p, 'utf-8'));
} catch {
return null;
}
}
/** Egyszerű deep-diff: `{ added, removed, changed }` map (kulcs-szinten). */
static deepDiff(before: unknown, after: unknown): unknown {
if (before === null && after === null) {
return { unchanged: true };
}
if (before === null) {
return { onlyAfter: after };
}
if (after === null) {
return { onlyBefore: before };
}
if (typeof before !== 'object' || typeof after !== 'object') {
if (before === after) {
return { unchanged: true, value: before };
}
return { before, after };
}
const bObj: Record<string, unknown> = before as Record<string, unknown>;
const aObj: Record<string, unknown> = after as Record<string, unknown>;
const allKeys: Set<string> = new Set([...Object.keys(bObj), ...Object.keys(aObj)]);
const added: Record<string, unknown> = {};
const removed: Record<string, unknown> = {};
const changed: Record<string, unknown> = {};
for (const k of allKeys) {
if (!(k in bObj)) {
added[k] = aObj[k];
} else if (!(k in aObj)) {
removed[k] = bObj[k];
} else if (JSON.stringify(bObj[k]) !== JSON.stringify(aObj[k])) {
changed[k] = { before: bObj[k], after: aObj[k] };
}
}
return {
added: Object.keys(added).length > 0 ? added : undefined,
removed: Object.keys(removed).length > 0 ? removed : undefined,
changed: Object.keys(changed).length > 0 ? changed : undefined,
};
}
/** Evidence-array specifikus diff: minden detektorra verdict-változás. */
static diffEvidenceArrays(before: unknown, after: unknown): unknown {
const toMap = (arr: unknown): Record<string, unknown> => {
const m: Record<string, unknown> = {};
if (Array.isArray(arr)) {
for (const e of arr) {
const d: { detector?: string } = e as { detector?: string };
if (d?.detector) {
m[d.detector] = e;
}
}
}
return m;
};
const bm: Record<string, unknown> = toMap(before);
const am: Record<string, unknown> = toMap(after);
const detectors: Set<string> = new Set([...Object.keys(bm), ...Object.keys(am)]);
const delta: Record<string, unknown> = {};
for (const d of detectors) {
const bDetected: boolean = (bm[d] as { detected?: boolean })?.detected === true;
const aDetected: boolean = (am[d] as { detected?: boolean })?.detected === true;
if (bDetected !== aDetected) {
delta[d] = {
verdictChanged: true,
before: bDetected ? 'detected' : 'clean',
after: aDetected ? 'detected' : 'clean',
};
} else if (JSON.stringify(bm[d]) !== JSON.stringify(am[d])) {
delta[d] = { verdictChanged: false, detailsChanged: true };
} else {
delta[d] = { unchanged: true };
}
}
return delta;
}
private static renderReadme(
manifest: DyE2E_VQA_FeatureManifest_Interface,
findingRefs: string[],
beforeRunId: string,
afterRunId: string,
): string {
return `# Re-audit comparison-bundle — \`${manifest.featureName}\`
> **Mit kell tenned (AI agent):** olvasd át a finding-ek listáját, vesd össze a
> before/after dom-diff + evidence-diff + a11y-diff fájlokat, és minden finding-re dönts:
>
> - **\`verified\`** — a probléma megszűnt (a re-audit ugyanabban az állapotban már nem találja)
> - **\`reopened\`** — a probléma visszatért
> - **\`in-progress\`** (partial) — a probléma részben maradt fenn
- **Before run-id:** \`${beforeRunId}\`
- **After run-id:** \`${afterRunId}\`
- **Feature:** \`${manifest.featureId}\` — ${manifest.featureName}
- **Re-audited finding-count:** ${findingRefs.length}
## Re-audited finding-ek
${findingRefs.length > 0 ? findingRefs.map((f) => `- \`${f}\``).join('\n') : '*Nincs explicit lista — minden finding-et nézz át.*'}
## Bundle-struktúra
- \`dom-diff/<stateId>/<viewport>-<orient>.json\` — DOM-snapshot delta
- \`evidence-diff/<stateId>/<viewport>-<orient>.json\` — 16 detektor verdict-delta
- \`a11y-diff/<stateId>/<viewport>-<orient>.json\` — axe-finding delta (ha van)
## Decision-rubric
1. **Nyisd meg az adott finding state × viewport-jához tartozó \`evidence-diff\`-et**.
Ha a kapcsolódó detektor \`verdictChanged: true\` és \`after: 'clean'\` → erős jel \`verified\`-re.
2. **Nyisd meg a \`dom-diff\`-et** ugyanarra a state-viewport-ra. Nézd meg, hogy a finding-re
vonatkozó DOM-metrika változott-e (pl. modal scrollHeight, body scrollHeight, primary CTA top).
3. **Olvasd a screenshot-okat** a \`states/<stateId>/<viewport>-<orient>/full.png\` és \`fold.png\` után-bundle-jéből (after run-id).
4. **Dönts** és írd a verdict-et a finding \`status\`-ába (\`verified\` | \`reopened\` | \`in-progress\`).
A finding-státusz-FSM megengedett tranzícióit a \`DyE2E_VQA_FindingValidator_Util.canTransition\`
adja — \`readyForReAudit\` → \`verified\` vagy \`reopened\` a jellemző.
---
*Comparison generated by \`@futdevpro/dynamo-e2e/vqa\` \`DyE2E_VQA_ComparisonBundle_Generator\`.*
`;
}
}
|