playwright-intelligence-engine 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -229
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/core/version.d.ts +3 -3
- package/dist/index.js +81 -24
- package/package.json +76 -76
- package/src/authoring/author.ts +81 -81
- package/src/authoring/generation-contract.ts +283 -283
- package/src/authoring/hybrid-author.ts +115 -115
- package/src/authoring/index.ts +7 -7
- package/src/authoring/llm-author.ts +282 -282
- package/src/authoring/naming/name-plan.ts +28 -28
- package/src/authoring/naming/name-planner.ts +339 -339
- package/src/authoring/naming/naming-linter.ts +292 -292
- package/src/cli/index.ts +1238 -1172
- package/src/collectors/git-diff-collector.ts +190 -190
- package/src/core/version.ts +25 -25
- package/src/diagnostics/diagnostic-report.ts +204 -204
- package/src/diagnostics/failure-classifier.ts +701 -701
- package/src/evaluation/repository-runner.ts +197 -197
- package/src/gate/quality.ts +101 -101
- package/src/generator/architecture-generator.ts +582 -582
- package/src/generator/assertion-quality-gate.ts +88 -88
- package/src/generator/candidate-writer.ts +288 -288
- package/src/generator/test-generator.ts +52 -52
- package/src/index.ts +107 -107
- package/src/intelligence/evidence-bundle.ts +300 -300
- package/src/intelligence/generation-agent.ts +561 -561
- package/src/intelligence/generation-verifier.ts +1115 -1115
- package/src/intelligence/locator-disambiguation-engine.ts +331 -331
- package/src/intelligence/project-intelligence.ts +140 -140
- package/src/intelligence/repository-profile.ts +796 -796
- package/src/intelligence/trace-proposal-workflow.ts +318 -318
- package/src/intelligence/workflow-planner.ts +966 -966
- package/src/mcp/server.ts +970 -970
- package/src/perception/app-model.ts +32 -32
- package/src/perception/crawler.ts +263 -263
- package/src/perception/index.ts +3 -3
- package/src/repair/assertion-hasher.ts +386 -386
- package/src/repair/diff-allowlist.ts +612 -612
- package/src/repair/intent-validator.ts +761 -761
- package/src/repair/repair-planner.ts +467 -467
- package/src/repair/statement-patcher.ts +544 -544
- package/src/reproduce/interactive-workflow-runner.ts +828 -828
- package/src/sandbox/execution-runner.ts +408 -408
- package/src/selector/abstention-policy.ts +175 -175
- package/src/selector/candidate-extractor.ts +343 -343
- package/src/selector/repair-candidate-ranker.ts +92 -92
- package/src/selector/selector-scorer.ts +344 -344
|
@@ -1,204 +1,204 @@
|
|
|
1
|
-
import { CorrelatedEvidence } from './evidence-correlator.js';
|
|
2
|
-
import { EvidenceScorecard } from '../evidence/evidence-model.js';
|
|
3
|
-
import { CandidateExtractor } from '../selector/candidate-extractor.js';
|
|
4
|
-
import { RepairCandidateRanker } from '../selector/repair-candidate-ranker.js';
|
|
5
|
-
import { AbstentionPolicy } from '../selector/abstention-policy.js';
|
|
6
|
-
import { ProjectIntelligenceSnapshot } from '../intelligence/project-intelligence.js';
|
|
7
|
-
import { RankedRepairCandidate } from '../selector/repair-candidate-ranker.js';
|
|
8
|
-
|
|
9
|
-
export class DiagnosticReportGenerator {
|
|
10
|
-
public static selectRepairCandidate(
|
|
11
|
-
evidence: CorrelatedEvidence,
|
|
12
|
-
intelligence?: ProjectIntelligenceSnapshot,
|
|
13
|
-
): RankedRepairCandidate | undefined {
|
|
14
|
-
const { context, classification } = evidence;
|
|
15
|
-
if (classification.shouldAbstain) return undefined;
|
|
16
|
-
const domRoot = (context as any).domRoot;
|
|
17
|
-
if (!domRoot) return undefined;
|
|
18
|
-
try {
|
|
19
|
-
const candidates = CandidateExtractor.extractCandidates(domRoot, context.failedAction);
|
|
20
|
-
if (candidates.length === 0) return undefined;
|
|
21
|
-
const ranked = RepairCandidateRanker.rank(
|
|
22
|
-
candidates,
|
|
23
|
-
context.failedAction.selector,
|
|
24
|
-
context.failedAction.action,
|
|
25
|
-
intelligence,
|
|
26
|
-
domRoot,
|
|
27
|
-
context.failedAction.selector
|
|
28
|
-
);
|
|
29
|
-
const decision = AbstentionPolicy.evaluate(ranked);
|
|
30
|
-
if (!decision.shouldAbstain && decision.selectedCandidate) {
|
|
31
|
-
return decision.selectedCandidate as RankedRepairCandidate;
|
|
32
|
-
}
|
|
33
|
-
} catch {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public static extractProposedLocator(
|
|
40
|
-
evidence: CorrelatedEvidence,
|
|
41
|
-
intelligence?: ProjectIntelligenceSnapshot,
|
|
42
|
-
): string | undefined {
|
|
43
|
-
return DiagnosticReportGenerator.selectRepairCandidate(evidence, intelligence)?.locatorExpression;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public static generateTerminalReport(
|
|
47
|
-
evidence: CorrelatedEvidence,
|
|
48
|
-
scorecard?: EvidenceScorecard,
|
|
49
|
-
intelligence?: ProjectIntelligenceSnapshot,
|
|
50
|
-
): string {
|
|
51
|
-
const { context, classification } = evidence;
|
|
52
|
-
const { failedAction } = context;
|
|
53
|
-
|
|
54
|
-
const divider = '─'.repeat(72);
|
|
55
|
-
const lines: string[] = [];
|
|
56
|
-
|
|
57
|
-
lines.push('');
|
|
58
|
-
lines.push('╔══════════════════════════════════════════════════════════════════════╗');
|
|
59
|
-
lines.push('║ PLAYWRIGHT INTELLIGENCE ENGINE: DIAGNOSTIC REPORT ║');
|
|
60
|
-
lines.push('╚══════════════════════════════════════════════════════════════════════╝');
|
|
61
|
-
lines.push('');
|
|
62
|
-
|
|
63
|
-
// Summary Header
|
|
64
|
-
lines.push(`Root Cause Classification : ${classification.category}`);
|
|
65
|
-
lines.push(`Confidence Level : ${(classification.confidence * 100).toFixed(1)}%`);
|
|
66
|
-
lines.push(`Failure Fingerprint : ${evidence.failureFingerprint.key}`);
|
|
67
|
-
lines.push(`Action Outcome : ${classification.shouldAbstain ? '⛔ ABSTAIN FROM CODE REPAIR' : '🔍 REPAIR CANDIDATE AVAILABLE'}`);
|
|
68
|
-
lines.push(divider);
|
|
69
|
-
|
|
70
|
-
// Failed Action Context
|
|
71
|
-
lines.push('Failed Action Details:');
|
|
72
|
-
lines.push(` • Call ID : ${failedAction.callId}`);
|
|
73
|
-
lines.push(` • Method : ${failedAction.action}`);
|
|
74
|
-
if (failedAction.selector) {
|
|
75
|
-
lines.push(` • Selector : ${failedAction.selector}`);
|
|
76
|
-
}
|
|
77
|
-
if (failedAction.sourceFile) {
|
|
78
|
-
lines.push(` • Source File : ${failedAction.sourceFile}:${failedAction.line ?? 0}:${failedAction.column ?? 0}`);
|
|
79
|
-
}
|
|
80
|
-
if (failedAction.durationMs) {
|
|
81
|
-
lines.push(` • Duration : ${failedAction.durationMs}ms`);
|
|
82
|
-
}
|
|
83
|
-
if (failedAction.errorMessage) {
|
|
84
|
-
lines.push(` • Error : ${failedAction.errorMessage}`);
|
|
85
|
-
}
|
|
86
|
-
lines.push(divider);
|
|
87
|
-
|
|
88
|
-
// Evidence Scorecard / Completeness
|
|
89
|
-
if (scorecard) {
|
|
90
|
-
lines.push('Multi-Source Evidence Scorecard:');
|
|
91
|
-
lines.push(` • Playwright Error Msg : ${scorecard.playwrightErrorAvailable ? '✅ YES' : '❌ NO'}`);
|
|
92
|
-
lines.push(` • Test Source AST : ${scorecard.testSourceAstAvailable ? '✅ YES' : '❌ NO'}`);
|
|
93
|
-
lines.push(` • DOM Snapshot : ${scorecard.domSnapshotAvailable ? '✅ YES' : '❌ NO'}`);
|
|
94
|
-
lines.push(` • Network Events : ${scorecard.networkEventsAvailable ? '✅ YES' : '❌ NO'}`);
|
|
95
|
-
lines.push(` • Console Events : ${scorecard.consoleEventsAvailable ? '✅ YES' : '❌ NO'}`);
|
|
96
|
-
lines.push(` • Trace Archive : ${scorecard.traceArchiveAvailable ? '✅ YES' : '❌ NO'}`);
|
|
97
|
-
lines.push(` • Git Working Tree Diff : ${scorecard.gitHistoryAvailable ? '✅ YES' : '❌ NO'}`);
|
|
98
|
-
lines.push(` • Environment Metadata : ${scorecard.environmentMetadataAvailable ? '✅ YES' : '❌ NO'}`);
|
|
99
|
-
lines.push(` • Total Ingested Records : ${scorecard.totalRecordsCount}`);
|
|
100
|
-
} else {
|
|
101
|
-
const comp = context.evidenceCompleteness;
|
|
102
|
-
lines.push('Evidence Provenance:');
|
|
103
|
-
lines.push(` • DOM Snapshot Available : ${comp.domAvailable ? '✅ YES' : '❌ NO'}`);
|
|
104
|
-
lines.push(` • Network Logs Ingested : ${comp.networkAvailable ? `✅ YES (${context.networkEvents.length} events)` : '❌ NONE'}`);
|
|
105
|
-
lines.push(` • Source Code Mapped : ${comp.sourceAvailable ? '✅ YES' : '❌ NO'}`);
|
|
106
|
-
}
|
|
107
|
-
lines.push(divider);
|
|
108
|
-
|
|
109
|
-
// Causal Evidence Graph summary
|
|
110
|
-
if (classification.causalGraph) {
|
|
111
|
-
const g = classification.causalGraph;
|
|
112
|
-
lines.push('Causal Evidence Graph:');
|
|
113
|
-
lines.push(` • Graph Size : ${g.nodes.length} nodes, ${g.edges?.length ?? 0} causal edges`);
|
|
114
|
-
if (g.hasCausallyRelevantServerError && g.offendingNetworkEvent) {
|
|
115
|
-
lines.push(` • Offending Request: HTTP ${g.offendingNetworkEvent.status} on ${g.offendingNetworkEvent.method} ${g.offendingNetworkEvent.url}`);
|
|
116
|
-
}
|
|
117
|
-
lines.push(divider);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Suspicious Network & Console Context
|
|
121
|
-
if (evidence.suspiciousNetworkEvents.length > 0) {
|
|
122
|
-
lines.push('Correlated Network Anomalies:');
|
|
123
|
-
for (const net of evidence.suspiciousNetworkEvents.slice(0, 5)) {
|
|
124
|
-
lines.push(` ⚠️ HTTP ${net.status} [${net.method}] ${net.url}`);
|
|
125
|
-
}
|
|
126
|
-
lines.push(divider);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (evidence.suspiciousConsoleEvents.length > 0) {
|
|
130
|
-
lines.push('Correlated Console Errors:');
|
|
131
|
-
for (const con of evidence.suspiciousConsoleEvents.slice(0, 3)) {
|
|
132
|
-
lines.push(` ⚠️ ${con.text}`);
|
|
133
|
-
}
|
|
134
|
-
lines.push(divider);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Abstention or Next Action
|
|
138
|
-
if (classification.shouldAbstain) {
|
|
139
|
-
lines.push('Abstention Rationale:');
|
|
140
|
-
lines.push(` ${classification.abstentionReason ?? classification.reason}`);
|
|
141
|
-
lines.push(' Engine guardrail enforced: zero unsafe AST mutations attempted.');
|
|
142
|
-
} else {
|
|
143
|
-
lines.push('Diagnostic Conclusion:');
|
|
144
|
-
lines.push(` ${classification.reason}`);
|
|
145
|
-
lines.push(' Ready for candidate extraction and isolated worktree verification.');
|
|
146
|
-
|
|
147
|
-
const proposed = DiagnosticReportGenerator.extractProposedLocator(evidence, intelligence);
|
|
148
|
-
if (proposed) {
|
|
149
|
-
lines.push(` Proposed Replacement Locator: \`${proposed}\``);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
lines.push(divider);
|
|
154
|
-
lines.push('');
|
|
155
|
-
|
|
156
|
-
return lines.join('\n');
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
public static generateMarkdownReport(
|
|
160
|
-
evidence: CorrelatedEvidence,
|
|
161
|
-
scorecard?: EvidenceScorecard
|
|
162
|
-
): string {
|
|
163
|
-
const { context, classification } = evidence;
|
|
164
|
-
const { failedAction } = context;
|
|
165
|
-
|
|
166
|
-
const md: string[] = [];
|
|
167
|
-
md.push('# Playwright Intelligence Engine — Diagnostic Report');
|
|
168
|
-
md.push('');
|
|
169
|
-
md.push(`**Classification:** \`${classification.category}\` (Confidence: ${(classification.confidence * 100).toFixed(1)}%) `);
|
|
170
|
-
md.push(`**Failure fingerprint:** \`${evidence.failureFingerprint.key}\` `);
|
|
171
|
-
md.push(`**Status:** ${classification.shouldAbstain ? '⛔ **Abstained from repair**' : '🔍 **Repair candidate eligible**'} `);
|
|
172
|
-
md.push(`**Reason:** ${classification.reason} `);
|
|
173
|
-
md.push('');
|
|
174
|
-
|
|
175
|
-
md.push('## Failed Action');
|
|
176
|
-
md.push(`- **Action:** \`${failedAction.action}\``);
|
|
177
|
-
if (failedAction.selector) md.push(`- **Selector:** \`${failedAction.selector}\``);
|
|
178
|
-
if (failedAction.sourceFile) md.push(`- **Location:** \`${failedAction.sourceFile}:${failedAction.line ?? 0}\``);
|
|
179
|
-
if (failedAction.errorMessage) md.push(`- **Error:** \`${failedAction.errorMessage}\``);
|
|
180
|
-
md.push('');
|
|
181
|
-
|
|
182
|
-
if (scorecard) {
|
|
183
|
-
md.push('## Evidence Scorecard');
|
|
184
|
-
md.push('| Evidence Channel | Available |');
|
|
185
|
-
md.push('|---|---|');
|
|
186
|
-
md.push(`| Playwright Error Message | ${scorecard.playwrightErrorAvailable ? '✅' : '❌'} |`);
|
|
187
|
-
md.push(`| Test Source Code (AST) | ${scorecard.testSourceAstAvailable ? '✅' : '❌'} |`);
|
|
188
|
-
md.push(`| Browser DOM Snapshot | ${scorecard.domSnapshotAvailable ? '✅' : '❌'} |`);
|
|
189
|
-
md.push(`| Network Interception | ${scorecard.networkEventsAvailable ? '✅' : '❌'} |`);
|
|
190
|
-
md.push(`| Browser Console | ${scorecard.consoleEventsAvailable ? '✅' : '❌'} |`);
|
|
191
|
-
md.push(`| Playwright Trace | ${scorecard.traceArchiveAvailable ? '✅' : '❌'} |`);
|
|
192
|
-
md.push(`| Git History / Diff | ${scorecard.gitHistoryAvailable ? '✅' : '❌'} |`);
|
|
193
|
-
md.push(`| Environment Metadata | ${scorecard.environmentMetadataAvailable ? '✅' : '❌'} |`);
|
|
194
|
-
md.push('');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (classification.shouldAbstain) {
|
|
198
|
-
md.push('## Abstention Guardrail Enforced');
|
|
199
|
-
md.push(`> [!IMPORTANT]\n> ${classification.abstentionReason ?? classification.reason}`);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return md.join('\n');
|
|
203
|
-
}
|
|
204
|
-
}
|
|
1
|
+
import { CorrelatedEvidence } from './evidence-correlator.js';
|
|
2
|
+
import { EvidenceScorecard } from '../evidence/evidence-model.js';
|
|
3
|
+
import { CandidateExtractor } from '../selector/candidate-extractor.js';
|
|
4
|
+
import { RepairCandidateRanker } from '../selector/repair-candidate-ranker.js';
|
|
5
|
+
import { AbstentionPolicy } from '../selector/abstention-policy.js';
|
|
6
|
+
import { ProjectIntelligenceSnapshot } from '../intelligence/project-intelligence.js';
|
|
7
|
+
import { RankedRepairCandidate } from '../selector/repair-candidate-ranker.js';
|
|
8
|
+
|
|
9
|
+
export class DiagnosticReportGenerator {
|
|
10
|
+
public static selectRepairCandidate(
|
|
11
|
+
evidence: CorrelatedEvidence,
|
|
12
|
+
intelligence?: ProjectIntelligenceSnapshot,
|
|
13
|
+
): RankedRepairCandidate | undefined {
|
|
14
|
+
const { context, classification } = evidence;
|
|
15
|
+
if (classification.shouldAbstain) return undefined;
|
|
16
|
+
const domRoot = (context as any).domRoot;
|
|
17
|
+
if (!domRoot) return undefined;
|
|
18
|
+
try {
|
|
19
|
+
const candidates = CandidateExtractor.extractCandidates(domRoot, context.failedAction);
|
|
20
|
+
if (candidates.length === 0) return undefined;
|
|
21
|
+
const ranked = RepairCandidateRanker.rank(
|
|
22
|
+
candidates,
|
|
23
|
+
context.failedAction.selector,
|
|
24
|
+
context.failedAction.action,
|
|
25
|
+
intelligence,
|
|
26
|
+
domRoot,
|
|
27
|
+
context.failedAction.selector
|
|
28
|
+
);
|
|
29
|
+
const decision = AbstentionPolicy.evaluate(ranked);
|
|
30
|
+
if (!decision.shouldAbstain && decision.selectedCandidate) {
|
|
31
|
+
return decision.selectedCandidate as RankedRepairCandidate;
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public static extractProposedLocator(
|
|
40
|
+
evidence: CorrelatedEvidence,
|
|
41
|
+
intelligence?: ProjectIntelligenceSnapshot,
|
|
42
|
+
): string | undefined {
|
|
43
|
+
return DiagnosticReportGenerator.selectRepairCandidate(evidence, intelligence)?.locatorExpression;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public static generateTerminalReport(
|
|
47
|
+
evidence: CorrelatedEvidence,
|
|
48
|
+
scorecard?: EvidenceScorecard,
|
|
49
|
+
intelligence?: ProjectIntelligenceSnapshot,
|
|
50
|
+
): string {
|
|
51
|
+
const { context, classification } = evidence;
|
|
52
|
+
const { failedAction } = context;
|
|
53
|
+
|
|
54
|
+
const divider = '─'.repeat(72);
|
|
55
|
+
const lines: string[] = [];
|
|
56
|
+
|
|
57
|
+
lines.push('');
|
|
58
|
+
lines.push('╔══════════════════════════════════════════════════════════════════════╗');
|
|
59
|
+
lines.push('║ PLAYWRIGHT INTELLIGENCE ENGINE: DIAGNOSTIC REPORT ║');
|
|
60
|
+
lines.push('╚══════════════════════════════════════════════════════════════════════╝');
|
|
61
|
+
lines.push('');
|
|
62
|
+
|
|
63
|
+
// Summary Header
|
|
64
|
+
lines.push(`Root Cause Classification : ${classification.category}`);
|
|
65
|
+
lines.push(`Confidence Level : ${(classification.confidence * 100).toFixed(1)}%`);
|
|
66
|
+
lines.push(`Failure Fingerprint : ${evidence.failureFingerprint.key}`);
|
|
67
|
+
lines.push(`Action Outcome : ${classification.shouldAbstain ? '⛔ ABSTAIN FROM CODE REPAIR' : '🔍 REPAIR CANDIDATE AVAILABLE'}`);
|
|
68
|
+
lines.push(divider);
|
|
69
|
+
|
|
70
|
+
// Failed Action Context
|
|
71
|
+
lines.push('Failed Action Details:');
|
|
72
|
+
lines.push(` • Call ID : ${failedAction.callId}`);
|
|
73
|
+
lines.push(` • Method : ${failedAction.action}`);
|
|
74
|
+
if (failedAction.selector) {
|
|
75
|
+
lines.push(` • Selector : ${failedAction.selector}`);
|
|
76
|
+
}
|
|
77
|
+
if (failedAction.sourceFile) {
|
|
78
|
+
lines.push(` • Source File : ${failedAction.sourceFile}:${failedAction.line ?? 0}:${failedAction.column ?? 0}`);
|
|
79
|
+
}
|
|
80
|
+
if (failedAction.durationMs) {
|
|
81
|
+
lines.push(` • Duration : ${failedAction.durationMs}ms`);
|
|
82
|
+
}
|
|
83
|
+
if (failedAction.errorMessage) {
|
|
84
|
+
lines.push(` • Error : ${failedAction.errorMessage}`);
|
|
85
|
+
}
|
|
86
|
+
lines.push(divider);
|
|
87
|
+
|
|
88
|
+
// Evidence Scorecard / Completeness
|
|
89
|
+
if (scorecard) {
|
|
90
|
+
lines.push('Multi-Source Evidence Scorecard:');
|
|
91
|
+
lines.push(` • Playwright Error Msg : ${scorecard.playwrightErrorAvailable ? '✅ YES' : '❌ NO'}`);
|
|
92
|
+
lines.push(` • Test Source AST : ${scorecard.testSourceAstAvailable ? '✅ YES' : '❌ NO'}`);
|
|
93
|
+
lines.push(` • DOM Snapshot : ${scorecard.domSnapshotAvailable ? '✅ YES' : '❌ NO'}`);
|
|
94
|
+
lines.push(` • Network Events : ${scorecard.networkEventsAvailable ? '✅ YES' : '❌ NO'}`);
|
|
95
|
+
lines.push(` • Console Events : ${scorecard.consoleEventsAvailable ? '✅ YES' : '❌ NO'}`);
|
|
96
|
+
lines.push(` • Trace Archive : ${scorecard.traceArchiveAvailable ? '✅ YES' : '❌ NO'}`);
|
|
97
|
+
lines.push(` • Git Working Tree Diff : ${scorecard.gitHistoryAvailable ? '✅ YES' : '❌ NO'}`);
|
|
98
|
+
lines.push(` • Environment Metadata : ${scorecard.environmentMetadataAvailable ? '✅ YES' : '❌ NO'}`);
|
|
99
|
+
lines.push(` • Total Ingested Records : ${scorecard.totalRecordsCount}`);
|
|
100
|
+
} else {
|
|
101
|
+
const comp = context.evidenceCompleteness;
|
|
102
|
+
lines.push('Evidence Provenance:');
|
|
103
|
+
lines.push(` • DOM Snapshot Available : ${comp.domAvailable ? '✅ YES' : '❌ NO'}`);
|
|
104
|
+
lines.push(` • Network Logs Ingested : ${comp.networkAvailable ? `✅ YES (${context.networkEvents.length} events)` : '❌ NONE'}`);
|
|
105
|
+
lines.push(` • Source Code Mapped : ${comp.sourceAvailable ? '✅ YES' : '❌ NO'}`);
|
|
106
|
+
}
|
|
107
|
+
lines.push(divider);
|
|
108
|
+
|
|
109
|
+
// Causal Evidence Graph summary
|
|
110
|
+
if (classification.causalGraph) {
|
|
111
|
+
const g = classification.causalGraph;
|
|
112
|
+
lines.push('Causal Evidence Graph:');
|
|
113
|
+
lines.push(` • Graph Size : ${g.nodes.length} nodes, ${g.edges?.length ?? 0} causal edges`);
|
|
114
|
+
if (g.hasCausallyRelevantServerError && g.offendingNetworkEvent) {
|
|
115
|
+
lines.push(` • Offending Request: HTTP ${g.offendingNetworkEvent.status} on ${g.offendingNetworkEvent.method} ${g.offendingNetworkEvent.url}`);
|
|
116
|
+
}
|
|
117
|
+
lines.push(divider);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Suspicious Network & Console Context
|
|
121
|
+
if (evidence.suspiciousNetworkEvents.length > 0) {
|
|
122
|
+
lines.push('Correlated Network Anomalies:');
|
|
123
|
+
for (const net of evidence.suspiciousNetworkEvents.slice(0, 5)) {
|
|
124
|
+
lines.push(` ⚠️ HTTP ${net.status} [${net.method}] ${net.url}`);
|
|
125
|
+
}
|
|
126
|
+
lines.push(divider);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (evidence.suspiciousConsoleEvents.length > 0) {
|
|
130
|
+
lines.push('Correlated Console Errors:');
|
|
131
|
+
for (const con of evidence.suspiciousConsoleEvents.slice(0, 3)) {
|
|
132
|
+
lines.push(` ⚠️ ${con.text}`);
|
|
133
|
+
}
|
|
134
|
+
lines.push(divider);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Abstention or Next Action
|
|
138
|
+
if (classification.shouldAbstain) {
|
|
139
|
+
lines.push('Abstention Rationale:');
|
|
140
|
+
lines.push(` ${classification.abstentionReason ?? classification.reason}`);
|
|
141
|
+
lines.push(' Engine guardrail enforced: zero unsafe AST mutations attempted.');
|
|
142
|
+
} else {
|
|
143
|
+
lines.push('Diagnostic Conclusion:');
|
|
144
|
+
lines.push(` ${classification.reason}`);
|
|
145
|
+
lines.push(' Ready for candidate extraction and isolated worktree verification.');
|
|
146
|
+
|
|
147
|
+
const proposed = DiagnosticReportGenerator.extractProposedLocator(evidence, intelligence);
|
|
148
|
+
if (proposed) {
|
|
149
|
+
lines.push(` Proposed Replacement Locator: \`${proposed}\``);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
lines.push(divider);
|
|
154
|
+
lines.push('');
|
|
155
|
+
|
|
156
|
+
return lines.join('\n');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public static generateMarkdownReport(
|
|
160
|
+
evidence: CorrelatedEvidence,
|
|
161
|
+
scorecard?: EvidenceScorecard
|
|
162
|
+
): string {
|
|
163
|
+
const { context, classification } = evidence;
|
|
164
|
+
const { failedAction } = context;
|
|
165
|
+
|
|
166
|
+
const md: string[] = [];
|
|
167
|
+
md.push('# Playwright Intelligence Engine — Diagnostic Report');
|
|
168
|
+
md.push('');
|
|
169
|
+
md.push(`**Classification:** \`${classification.category}\` (Confidence: ${(classification.confidence * 100).toFixed(1)}%) `);
|
|
170
|
+
md.push(`**Failure fingerprint:** \`${evidence.failureFingerprint.key}\` `);
|
|
171
|
+
md.push(`**Status:** ${classification.shouldAbstain ? '⛔ **Abstained from repair**' : '🔍 **Repair candidate eligible**'} `);
|
|
172
|
+
md.push(`**Reason:** ${classification.reason} `);
|
|
173
|
+
md.push('');
|
|
174
|
+
|
|
175
|
+
md.push('## Failed Action');
|
|
176
|
+
md.push(`- **Action:** \`${failedAction.action}\``);
|
|
177
|
+
if (failedAction.selector) md.push(`- **Selector:** \`${failedAction.selector}\``);
|
|
178
|
+
if (failedAction.sourceFile) md.push(`- **Location:** \`${failedAction.sourceFile}:${failedAction.line ?? 0}\``);
|
|
179
|
+
if (failedAction.errorMessage) md.push(`- **Error:** \`${failedAction.errorMessage}\``);
|
|
180
|
+
md.push('');
|
|
181
|
+
|
|
182
|
+
if (scorecard) {
|
|
183
|
+
md.push('## Evidence Scorecard');
|
|
184
|
+
md.push('| Evidence Channel | Available |');
|
|
185
|
+
md.push('|---|---|');
|
|
186
|
+
md.push(`| Playwright Error Message | ${scorecard.playwrightErrorAvailable ? '✅' : '❌'} |`);
|
|
187
|
+
md.push(`| Test Source Code (AST) | ${scorecard.testSourceAstAvailable ? '✅' : '❌'} |`);
|
|
188
|
+
md.push(`| Browser DOM Snapshot | ${scorecard.domSnapshotAvailable ? '✅' : '❌'} |`);
|
|
189
|
+
md.push(`| Network Interception | ${scorecard.networkEventsAvailable ? '✅' : '❌'} |`);
|
|
190
|
+
md.push(`| Browser Console | ${scorecard.consoleEventsAvailable ? '✅' : '❌'} |`);
|
|
191
|
+
md.push(`| Playwright Trace | ${scorecard.traceArchiveAvailable ? '✅' : '❌'} |`);
|
|
192
|
+
md.push(`| Git History / Diff | ${scorecard.gitHistoryAvailable ? '✅' : '❌'} |`);
|
|
193
|
+
md.push(`| Environment Metadata | ${scorecard.environmentMetadataAvailable ? '✅' : '❌'} |`);
|
|
194
|
+
md.push('');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (classification.shouldAbstain) {
|
|
198
|
+
md.push('## Abstention Guardrail Enforced');
|
|
199
|
+
md.push(`> [!IMPORTANT]\n> ${classification.abstentionReason ?? classification.reason}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return md.join('\n');
|
|
203
|
+
}
|
|
204
|
+
}
|