playwright-intelligence-engine 0.0.0-stage → 2.0.0
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/LICENSE +191 -0
- package/README.md +229 -3
- package/bin/pw-intel.js +37 -0
- package/dist/authoring/author.d.ts +83 -0
- package/dist/authoring/author.d.ts.map +1 -0
- package/dist/authoring/generation-contract.d.ts +90 -0
- package/dist/authoring/generation-contract.d.ts.map +1 -0
- package/dist/authoring/hybrid-author.d.ts +6 -0
- package/dist/authoring/hybrid-author.d.ts.map +1 -0
- package/dist/authoring/index.d.ts +7 -0
- package/dist/authoring/index.d.ts.map +1 -0
- package/dist/authoring/llm-author.d.ts +28 -0
- package/dist/authoring/llm-author.d.ts.map +1 -0
- package/dist/authoring/naming/index.d.ts +4 -0
- package/dist/authoring/naming/index.d.ts.map +1 -0
- package/dist/authoring/naming/name-plan.d.ts +45 -0
- package/dist/authoring/naming/name-plan.d.ts.map +1 -0
- package/dist/authoring/naming/name-planner.d.ts +25 -0
- package/dist/authoring/naming/name-planner.d.ts.map +1 -0
- package/dist/authoring/naming/naming-linter.d.ts +20 -0
- package/dist/authoring/naming/naming-linter.d.ts.map +1 -0
- package/dist/authoring/template-author.d.ts +6 -0
- package/dist/authoring/template-author.d.ts.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/collectors/collector-interface.d.ts +7 -0
- package/dist/collectors/collector-interface.d.ts.map +1 -0
- package/dist/collectors/environment-collector.d.ts +12 -0
- package/dist/collectors/environment-collector.d.ts.map +1 -0
- package/dist/collectors/error-collector.d.ts +18 -0
- package/dist/collectors/error-collector.d.ts.map +1 -0
- package/dist/collectors/git-diff-collector.d.ts +20 -0
- package/dist/collectors/git-diff-collector.d.ts.map +1 -0
- package/dist/collectors/live-browser-collector.d.ts +45 -0
- package/dist/collectors/live-browser-collector.d.ts.map +1 -0
- package/dist/collectors/network-collector.d.ts +28 -0
- package/dist/collectors/network-collector.d.ts.map +1 -0
- package/dist/collectors/static-ast-collector.d.ts +32 -0
- package/dist/collectors/static-ast-collector.d.ts.map +1 -0
- package/dist/collectors/trace-collector.d.ts +12 -0
- package/dist/collectors/trace-collector.d.ts.map +1 -0
- package/dist/config/project-config.d.ts +33 -0
- package/dist/config/project-config.d.ts.map +1 -0
- package/dist/core/errors/engine-errors.d.ts +34 -0
- package/dist/core/errors/engine-errors.d.ts.map +1 -0
- package/dist/core/types/diagnostic-context.d.ts +151 -0
- package/dist/core/types/diagnostic-context.d.ts.map +1 -0
- package/dist/core/types/repair-evidence.d.ts +56 -0
- package/dist/core/types/repair-evidence.d.ts.map +1 -0
- package/dist/core/version.d.ts +13 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/diagnostics/diagnostic-contract.d.ts +52 -0
- package/dist/diagnostics/diagnostic-contract.d.ts.map +1 -0
- package/dist/diagnostics/diagnostic-report.d.ts +11 -0
- package/dist/diagnostics/diagnostic-report.d.ts.map +1 -0
- package/dist/diagnostics/evidence-correlator.d.ts +22 -0
- package/dist/diagnostics/evidence-correlator.d.ts.map +1 -0
- package/dist/diagnostics/external-failure-evidence.d.ts +18 -0
- package/dist/diagnostics/external-failure-evidence.d.ts.map +1 -0
- package/dist/diagnostics/failure-category.d.ts +4 -0
- package/dist/diagnostics/failure-category.d.ts.map +1 -0
- package/dist/diagnostics/failure-classifier.d.ts +58 -0
- package/dist/diagnostics/failure-classifier.d.ts.map +1 -0
- package/dist/evaluation/evaluation-scorecard.d.ts +72 -0
- package/dist/evaluation/evaluation-scorecard.d.ts.map +1 -0
- package/dist/evaluation/repository-inspector.d.ts +21 -0
- package/dist/evaluation/repository-inspector.d.ts.map +1 -0
- package/dist/evaluation/repository-runner.d.ts +24 -0
- package/dist/evaluation/repository-runner.d.ts.map +1 -0
- package/dist/evidence/evidence-model.d.ts +88 -0
- package/dist/evidence/evidence-model.d.ts.map +1 -0
- package/dist/evidence/evidence-normalizer.d.ts +19 -0
- package/dist/evidence/evidence-normalizer.d.ts.map +1 -0
- package/dist/evidence/evidence-redactor.d.ts +37 -0
- package/dist/evidence/evidence-redactor.d.ts.map +1 -0
- package/dist/framework/config-adapter.d.ts +28 -0
- package/dist/framework/config-adapter.d.ts.map +1 -0
- package/dist/gate/index.d.ts +21 -0
- package/dist/gate/index.d.ts.map +1 -0
- package/dist/gate/oracle.d.ts +26 -0
- package/dist/gate/oracle.d.ts.map +1 -0
- package/dist/gate/quality.d.ts +27 -0
- package/dist/gate/quality.d.ts.map +1 -0
- package/dist/gate/safety.d.ts +28 -0
- package/dist/gate/safety.d.ts.map +1 -0
- package/dist/generator/architecture-generator.d.ts +55 -0
- package/dist/generator/architecture-generator.d.ts.map +1 -0
- package/dist/generator/assertion-quality-gate.d.ts +18 -0
- package/dist/generator/assertion-quality-gate.d.ts.map +1 -0
- package/dist/generator/candidate-writer.d.ts +34 -0
- package/dist/generator/candidate-writer.d.ts.map +1 -0
- package/dist/generator/test-generator.d.ts +26 -0
- package/dist/generator/test-generator.d.ts.map +1 -0
- package/dist/governance/audit-log.d.ts +23 -0
- package/dist/governance/audit-log.d.ts.map +1 -0
- package/dist/governance/governance-policy.d.ts +24 -0
- package/dist/governance/governance-policy.d.ts.map +1 -0
- package/dist/governance/team-dashboard.d.ts +51 -0
- package/dist/governance/team-dashboard.d.ts.map +1 -0
- package/dist/governance/workflow-audit.d.ts +13 -0
- package/dist/governance/workflow-audit.d.ts.map +1 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20318 -0
- package/dist/integrations/ci-summary.d.ts +14 -0
- package/dist/integrations/ci-summary.d.ts.map +1 -0
- package/dist/integrations/playwright-report-adapter.d.ts +22 -0
- package/dist/integrations/playwright-report-adapter.d.ts.map +1 -0
- package/dist/integrations/quality-gate.d.ts +35 -0
- package/dist/integrations/quality-gate.d.ts.map +1 -0
- package/dist/integrations/sarif-report.d.ts +48 -0
- package/dist/integrations/sarif-report.d.ts.map +1 -0
- package/dist/intelligence/autonomous-repair-workflow.d.ts +31 -0
- package/dist/intelligence/autonomous-repair-workflow.d.ts.map +1 -0
- package/dist/intelligence/business-intent.d.ts +58 -0
- package/dist/intelligence/business-intent.d.ts.map +1 -0
- package/dist/intelligence/evidence-bundle.d.ts +364 -0
- package/dist/intelligence/evidence-bundle.d.ts.map +1 -0
- package/dist/intelligence/failure-clustering.d.ts +38 -0
- package/dist/intelligence/failure-clustering.d.ts.map +1 -0
- package/dist/intelligence/generation-agent.d.ts +120 -0
- package/dist/intelligence/generation-agent.d.ts.map +1 -0
- package/dist/intelligence/generation-verifier.d.ts +151 -0
- package/dist/intelligence/generation-verifier.d.ts.map +1 -0
- package/dist/intelligence/llm-proposal.d.ts +377 -0
- package/dist/intelligence/llm-proposal.d.ts.map +1 -0
- package/dist/intelligence/locator-disambiguation-engine.d.ts +38 -0
- package/dist/intelligence/locator-disambiguation-engine.d.ts.map +1 -0
- package/dist/intelligence/model-contract.d.ts +86 -0
- package/dist/intelligence/model-contract.d.ts.map +1 -0
- package/dist/intelligence/model-provider.d.ts +75 -0
- package/dist/intelligence/model-provider.d.ts.map +1 -0
- package/dist/intelligence/project-intelligence.d.ts +22 -0
- package/dist/intelligence/project-intelligence.d.ts.map +1 -0
- package/dist/intelligence/repair-agent.d.ts +46 -0
- package/dist/intelligence/repair-agent.d.ts.map +1 -0
- package/dist/intelligence/repository-profile.d.ts +131 -0
- package/dist/intelligence/repository-profile.d.ts.map +1 -0
- package/dist/intelligence/suite-intelligence.d.ts +59 -0
- package/dist/intelligence/suite-intelligence.d.ts.map +1 -0
- package/dist/intelligence/test-intelligence.d.ts +44 -0
- package/dist/intelligence/test-intelligence.d.ts.map +1 -0
- package/dist/intelligence/trace-proposal-workflow.d.ts +30 -0
- package/dist/intelligence/trace-proposal-workflow.d.ts.map +1 -0
- package/dist/intelligence/verified-llm-repair-workflow.d.ts +21 -0
- package/dist/intelligence/verified-llm-repair-workflow.d.ts.map +1 -0
- package/dist/intelligence/workflow-planner.d.ts +278 -0
- package/dist/intelligence/workflow-planner.d.ts.map +1 -0
- package/dist/mcp/server.d.ts +32 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/memory/stability-ledger.d.ts +46 -0
- package/dist/memory/stability-ledger.d.ts.map +1 -0
- package/dist/perception/app-model.d.ts +55 -0
- package/dist/perception/app-model.d.ts.map +1 -0
- package/dist/perception/crawler.d.ts +18 -0
- package/dist/perception/crawler.d.ts.map +1 -0
- package/dist/perception/index.d.ts +3 -0
- package/dist/perception/index.d.ts.map +1 -0
- package/dist/repair/approval-service.d.ts +139 -0
- package/dist/repair/approval-service.d.ts.map +1 -0
- package/dist/repair/assertion-hasher.d.ts +62 -0
- package/dist/repair/assertion-hasher.d.ts.map +1 -0
- package/dist/repair/ast-patcher.d.ts +36 -0
- package/dist/repair/ast-patcher.d.ts.map +1 -0
- package/dist/repair/browser-operation-executor.d.ts +27 -0
- package/dist/repair/browser-operation-executor.d.ts.map +1 -0
- package/dist/repair/diff-allowlist.d.ts +74 -0
- package/dist/repair/diff-allowlist.d.ts.map +1 -0
- package/dist/repair/intent-validator.d.ts +157 -0
- package/dist/repair/intent-validator.d.ts.map +1 -0
- package/dist/repair/repair-operations.d.ts +40 -0
- package/dist/repair/repair-operations.d.ts.map +1 -0
- package/dist/repair/repair-planner.d.ts +98 -0
- package/dist/repair/repair-planner.d.ts.map +1 -0
- package/dist/repair/repair-workflow.d.ts +42 -0
- package/dist/repair/repair-workflow.d.ts.map +1 -0
- package/dist/repair/safe-operation-compiler.d.ts +15 -0
- package/dist/repair/safe-operation-compiler.d.ts.map +1 -0
- package/dist/repair/source-mapper.d.ts +19 -0
- package/dist/repair/source-mapper.d.ts.map +1 -0
- package/dist/repair/statement-patcher.d.ts +75 -0
- package/dist/repair/statement-patcher.d.ts.map +1 -0
- package/dist/repair/verification-gates.d.ts +25 -0
- package/dist/repair/verification-gates.d.ts.map +1 -0
- package/dist/repair/workflow-plan.d.ts +35 -0
- package/dist/repair/workflow-plan.d.ts.map +1 -0
- package/dist/repair/workspace-promoter.d.ts +43 -0
- package/dist/repair/workspace-promoter.d.ts.map +1 -0
- package/dist/reproduce/diagnostic-rerunner.d.ts +40 -0
- package/dist/reproduce/diagnostic-rerunner.d.ts.map +1 -0
- package/dist/reproduce/direct-browser-investigator.d.ts +41 -0
- package/dist/reproduce/direct-browser-investigator.d.ts.map +1 -0
- package/dist/reproduce/interactive-workflow-runner.d.ts +43 -0
- package/dist/reproduce/interactive-workflow-runner.d.ts.map +1 -0
- package/dist/sandbox/dependency-strategy.d.ts +45 -0
- package/dist/sandbox/dependency-strategy.d.ts.map +1 -0
- package/dist/sandbox/execution-runner.d.ts +81 -0
- package/dist/sandbox/execution-runner.d.ts.map +1 -0
- package/dist/sandbox/worktree-manager.d.ts +51 -0
- package/dist/sandbox/worktree-manager.d.ts.map +1 -0
- package/dist/selector/abstention-policy.d.ts +34 -0
- package/dist/selector/abstention-policy.d.ts.map +1 -0
- package/dist/selector/candidate-extractor.d.ts +71 -0
- package/dist/selector/candidate-extractor.d.ts.map +1 -0
- package/dist/selector/live-locator-verifier.d.ts +28 -0
- package/dist/selector/live-locator-verifier.d.ts.map +1 -0
- package/dist/selector/repair-candidate-ranker.d.ts +10 -0
- package/dist/selector/repair-candidate-ranker.d.ts.map +1 -0
- package/dist/selector/selector-scorer.d.ts +43 -0
- package/dist/selector/selector-scorer.d.ts.map +1 -0
- package/dist/trace/adapters/adapter-registry.d.ts +18 -0
- package/dist/trace/adapters/adapter-registry.d.ts.map +1 -0
- package/dist/trace/adapters/trace-adapter.d.ts +21 -0
- package/dist/trace/adapters/trace-adapter.d.ts.map +1 -0
- package/dist/trace/adapters/unknown-adapter.d.ts +10 -0
- package/dist/trace/adapters/unknown-adapter.d.ts.map +1 -0
- package/dist/trace/adapters/v10-adapter.d.ts +10 -0
- package/dist/trace/adapters/v10-adapter.d.ts.map +1 -0
- package/dist/trace/adapters/v4-adapter.d.ts +11 -0
- package/dist/trace/adapters/v4-adapter.d.ts.map +1 -0
- package/dist/trace/adapters/v8-adapter.d.ts +10 -0
- package/dist/trace/adapters/v8-adapter.d.ts.map +1 -0
- package/dist/trace/adapters/v9-adapter.d.ts +10 -0
- package/dist/trace/adapters/v9-adapter.d.ts.map +1 -0
- package/dist/trace/archive-reader.d.ts +44 -0
- package/dist/trace/archive-reader.d.ts.map +1 -0
- package/dist/trace/snapshot-resolver.d.ts +55 -0
- package/dist/trace/snapshot-resolver.d.ts.map +1 -0
- package/dist/trace/trace-parser.d.ts +50 -0
- package/dist/trace/trace-parser.d.ts.map +1 -0
- package/dist/trace/version-detector.d.ts +20 -0
- package/dist/trace/version-detector.d.ts.map +1 -0
- package/package.json +76 -6
- package/skills/README.md +20 -0
- package/skills/pie-failure-investigation/SKILL.md +16 -0
- package/skills/pie-quality-engineer/SKILL.md +66 -0
- package/skills/pie-release-readiness/SKILL.md +22 -0
- package/skills/pie-repair-review/SKILL.md +21 -0
- package/skills/pie-trace-to-repair/SKILL.md +35 -0
- package/src/authoring/author.ts +81 -0
- package/src/authoring/generation-contract.ts +283 -0
- package/src/authoring/hybrid-author.ts +115 -0
- package/src/authoring/index.ts +7 -0
- package/src/authoring/llm-author.ts +282 -0
- package/src/authoring/naming/index.ts +4 -0
- package/src/authoring/naming/name-plan.ts +28 -0
- package/src/authoring/naming/name-planner.ts +339 -0
- package/src/authoring/naming/naming-linter.ts +292 -0
- package/src/authoring/template-author.ts +39 -0
- package/src/cli/index.ts +1172 -0
- package/src/collectors/collector-interface.ts +8 -0
- package/src/collectors/environment-collector.ts +103 -0
- package/src/collectors/error-collector.ts +177 -0
- package/src/collectors/git-diff-collector.ts +190 -0
- package/src/collectors/live-browser-collector.ts +412 -0
- package/src/collectors/network-collector.ts +90 -0
- package/src/collectors/static-ast-collector.ts +226 -0
- package/src/collectors/trace-collector.ts +66 -0
- package/src/config/project-config.ts +114 -0
- package/src/core/errors/engine-errors.ts +90 -0
- package/src/core/types/diagnostic-context.ts +94 -0
- package/src/core/types/repair-evidence.ts +45 -0
- package/src/core/version.ts +25 -0
- package/src/diagnostics/diagnostic-contract.ts +79 -0
- package/src/diagnostics/diagnostic-report.ts +204 -0
- package/src/diagnostics/evidence-correlator.ts +117 -0
- package/src/diagnostics/external-failure-evidence.ts +72 -0
- package/src/diagnostics/failure-category.ts +40 -0
- package/src/diagnostics/failure-classifier.ts +701 -0
- package/src/evaluation/evaluation-scorecard.ts +198 -0
- package/src/evaluation/repository-inspector.ts +143 -0
- package/src/evaluation/repository-runner.ts +197 -0
- package/src/evidence/evidence-model.ts +76 -0
- package/src/evidence/evidence-normalizer.ts +322 -0
- package/src/evidence/evidence-redactor.ts +218 -0
- package/src/framework/config-adapter.ts +131 -0
- package/src/gate/index.ts +43 -0
- package/src/gate/oracle.ts +69 -0
- package/src/gate/quality.ts +101 -0
- package/src/gate/safety.ts +94 -0
- package/src/generator/architecture-generator.ts +582 -0
- package/src/generator/assertion-quality-gate.ts +88 -0
- package/src/generator/candidate-writer.ts +288 -0
- package/src/generator/test-generator.ts +52 -0
- package/src/governance/audit-log.ts +115 -0
- package/src/governance/governance-policy.ts +72 -0
- package/src/governance/team-dashboard.ts +189 -0
- package/src/governance/workflow-audit.ts +72 -0
- package/src/index.ts +107 -0
- package/src/integrations/ci-summary.ts +37 -0
- package/src/integrations/playwright-report-adapter.ts +173 -0
- package/src/integrations/quality-gate.ts +95 -0
- package/src/integrations/sarif-report.ts +110 -0
- package/src/intelligence/autonomous-repair-workflow.ts +139 -0
- package/src/intelligence/business-intent.ts +163 -0
- package/src/intelligence/evidence-bundle.ts +300 -0
- package/src/intelligence/failure-clustering.ts +134 -0
- package/src/intelligence/generation-agent.ts +561 -0
- package/src/intelligence/generation-verifier.ts +1115 -0
- package/src/intelligence/llm-proposal.ts +519 -0
- package/src/intelligence/locator-disambiguation-engine.ts +331 -0
- package/src/intelligence/model-contract.ts +205 -0
- package/src/intelligence/model-provider.ts +348 -0
- package/src/intelligence/project-intelligence.ts +140 -0
- package/src/intelligence/repair-agent.ts +297 -0
- package/src/intelligence/repository-profile.ts +796 -0
- package/src/intelligence/suite-intelligence.ts +305 -0
- package/src/intelligence/test-intelligence.ts +136 -0
- package/src/intelligence/trace-proposal-workflow.ts +318 -0
- package/src/intelligence/verified-llm-repair-workflow.ts +48 -0
- package/src/intelligence/workflow-planner.ts +966 -0
- package/src/mcp/server.ts +970 -0
- package/src/memory/stability-ledger.ts +243 -0
- package/src/perception/app-model.ts +32 -0
- package/src/perception/crawler.ts +263 -0
- package/src/perception/index.ts +3 -0
- package/src/repair/approval-service.ts +541 -0
- package/src/repair/assertion-hasher.ts +386 -0
- package/src/repair/ast-patcher.ts +223 -0
- package/src/repair/browser-operation-executor.ts +263 -0
- package/src/repair/diff-allowlist.ts +612 -0
- package/src/repair/intent-validator.ts +761 -0
- package/src/repair/repair-operations.ts +65 -0
- package/src/repair/repair-planner.ts +467 -0
- package/src/repair/repair-workflow.ts +241 -0
- package/src/repair/safe-operation-compiler.ts +68 -0
- package/src/repair/source-mapper.ts +156 -0
- package/src/repair/statement-patcher.ts +544 -0
- package/src/repair/verification-gates.ts +46 -0
- package/src/repair/workflow-plan.ts +59 -0
- package/src/repair/workspace-promoter.ts +313 -0
- package/src/reproduce/diagnostic-rerunner.ts +287 -0
- package/src/reproduce/direct-browser-investigator.ts +208 -0
- package/src/reproduce/interactive-workflow-runner.ts +828 -0
- package/src/sandbox/dependency-strategy.ts +215 -0
- package/src/sandbox/execution-runner.ts +408 -0
- package/src/sandbox/worktree-manager.ts +287 -0
- package/src/selector/abstention-policy.ts +175 -0
- package/src/selector/candidate-extractor.ts +343 -0
- package/src/selector/live-locator-verifier.ts +139 -0
- package/src/selector/repair-candidate-ranker.ts +92 -0
- package/src/selector/selector-scorer.ts +344 -0
- package/src/trace/adapters/adapter-registry.ts +49 -0
- package/src/trace/adapters/trace-adapter.ts +28 -0
- package/src/trace/adapters/unknown-adapter.ts +50 -0
- package/src/trace/adapters/v10-adapter.ts +39 -0
- package/src/trace/adapters/v4-adapter.ts +31 -0
- package/src/trace/adapters/v8-adapter.ts +42 -0
- package/src/trace/adapters/v9-adapter.ts +39 -0
- package/src/trace/archive-reader.ts +246 -0
- package/src/trace/snapshot-resolver.ts +308 -0
- package/src/trace/trace-parser.ts +467 -0
- package/src/trace/version-detector.ts +81 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DiagnosticContext, FailureCategorySchema } from '../core/types/diagnostic-context.js';
|
|
3
|
+
import { ClassificationResult } from './failure-classifier.js';
|
|
4
|
+
import { normalizeTypedFailureCategory } from './failure-category.js';
|
|
5
|
+
|
|
6
|
+
export const DiagnosticRecommendationSchema = z.enum([
|
|
7
|
+
'REPAIR_CANDIDATE',
|
|
8
|
+
'REPRODUCE_WITH_MORE_EVIDENCE',
|
|
9
|
+
'REPORT_APPLICATION_OR_ENVIRONMENT_FAILURE',
|
|
10
|
+
'ABSTAIN_FROM_REPAIR',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export type DiagnosticRecommendation = z.infer<typeof DiagnosticRecommendationSchema>;
|
|
14
|
+
|
|
15
|
+
export const DiagnosticDecisionSchema = z.object({
|
|
16
|
+
category: FailureCategorySchema,
|
|
17
|
+
confidence: z.number().min(0).max(1),
|
|
18
|
+
shouldAbstain: z.boolean(),
|
|
19
|
+
reason: z.string(),
|
|
20
|
+
recommendation: DiagnosticRecommendationSchema,
|
|
21
|
+
supportingEvidence: z.array(z.string()),
|
|
22
|
+
missingEvidence: z.array(z.string()),
|
|
23
|
+
provenance: z.object({
|
|
24
|
+
failedActionId: z.string(),
|
|
25
|
+
traceFormatVersion: z.number(),
|
|
26
|
+
playwrightVersion: z.string(),
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type DiagnosticDecision = z.infer<typeof DiagnosticDecisionSchema>;
|
|
31
|
+
|
|
32
|
+
function recommendationFor(classification: ClassificationResult): DiagnosticRecommendation {
|
|
33
|
+
if (classification.shouldAbstain) {
|
|
34
|
+
if (
|
|
35
|
+
classification.category === 'BACKEND_500' ||
|
|
36
|
+
classification.category === 'AUTH_EXPIRED' ||
|
|
37
|
+
classification.category === 'AUTH_SESSION_EXPIRED' ||
|
|
38
|
+
classification.category === 'ENVIRONMENT_FAILURE' ||
|
|
39
|
+
classification.category === 'ASSERTION_FAILURE' ||
|
|
40
|
+
classification.category === 'ASSERTION_FAILED'
|
|
41
|
+
) {
|
|
42
|
+
return 'REPORT_APPLICATION_OR_ENVIRONMENT_FAILURE';
|
|
43
|
+
}
|
|
44
|
+
return 'ABSTAIN_FROM_REPAIR';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (classification.category === 'INCOMPLETE_EVIDENCE') return 'REPRODUCE_WITH_MORE_EVIDENCE';
|
|
48
|
+
if (classification.category === 'LOCATOR_DRIFT') return 'REPAIR_CANDIDATE';
|
|
49
|
+
return 'ABSTAIN_FROM_REPAIR';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function missingEvidenceFor(context: DiagnosticContext): string[] {
|
|
53
|
+
const missing: string[] = [];
|
|
54
|
+
if (!context.evidenceCompleteness.domAvailable) missing.push('DOM or accessibility snapshot');
|
|
55
|
+
if (!context.evidenceCompleteness.networkAvailable) missing.push('network timeline');
|
|
56
|
+
if (!context.evidenceCompleteness.sourceAvailable) missing.push('test source and Page Object context');
|
|
57
|
+
return missing;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function createDiagnosticDecision(
|
|
61
|
+
context: DiagnosticContext,
|
|
62
|
+
classification: ClassificationResult,
|
|
63
|
+
): DiagnosticDecision {
|
|
64
|
+
return DiagnosticDecisionSchema.parse({
|
|
65
|
+
category: normalizeTypedFailureCategory(classification.category),
|
|
66
|
+
confidence: classification.confidence,
|
|
67
|
+
shouldAbstain: classification.shouldAbstain,
|
|
68
|
+
reason: classification.reason,
|
|
69
|
+
recommendation: recommendationFor(classification),
|
|
70
|
+
supportingEvidence: classification.supportingEvidence,
|
|
71
|
+
missingEvidence: missingEvidenceFor(context),
|
|
72
|
+
provenance: {
|
|
73
|
+
failedActionId: context.failedAction.callId,
|
|
74
|
+
traceFormatVersion: context.traceFormatVersion,
|
|
75
|
+
playwrightVersion: context.playwrightVersion,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DiagnosticContext,
|
|
3
|
+
NetworkEvent,
|
|
4
|
+
ConsoleEvent,
|
|
5
|
+
} from '../core/types/diagnostic-context.js';
|
|
6
|
+
import { FailureClassifier, ClassificationResult } from './failure-classifier.js';
|
|
7
|
+
import { FailureFingerprint, FailureObservation, fingerprintFailure } from '../intelligence/failure-clustering.js';
|
|
8
|
+
|
|
9
|
+
export interface CorrelatedEvidence {
|
|
10
|
+
context: DiagnosticContext;
|
|
11
|
+
classification: ClassificationResult;
|
|
12
|
+
failureObservation: FailureObservation;
|
|
13
|
+
failureFingerprint: FailureFingerprint;
|
|
14
|
+
suspiciousNetworkEvents: NetworkEvent[];
|
|
15
|
+
suspiciousConsoleEvents: ConsoleEvent[];
|
|
16
|
+
temporalWindowMs: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class EvidenceCorrelator {
|
|
20
|
+
/**
|
|
21
|
+
* Correlates network and console anomalies within an action-anchored temporal window
|
|
22
|
+
* leading up to the failure (AUDIT-12).
|
|
23
|
+
* Filters events FIRST before classification so the classifier evaluates only
|
|
24
|
+
* causally relevant, frame-matched events.
|
|
25
|
+
*/
|
|
26
|
+
public static correlate(
|
|
27
|
+
context: DiagnosticContext,
|
|
28
|
+
windowMs = 5000
|
|
29
|
+
): CorrelatedEvidence {
|
|
30
|
+
// 1. Anchor reference time strictly to failedAction.timestamp if available
|
|
31
|
+
let refTime: number | undefined = context.failedAction.timestamp;
|
|
32
|
+
|
|
33
|
+
if (refTime === undefined) {
|
|
34
|
+
// Fallback: collect timestamps from network and console events
|
|
35
|
+
const allTimestamps: number[] = [];
|
|
36
|
+
for (const net of context.networkEvents) {
|
|
37
|
+
if (typeof net.timestamp === 'number') allTimestamps.push(net.timestamp);
|
|
38
|
+
}
|
|
39
|
+
for (const con of context.consoleEvents) {
|
|
40
|
+
if (typeof con.timestamp === 'number') allTimestamps.push(con.timestamp);
|
|
41
|
+
}
|
|
42
|
+
refTime = allTimestamps.length > 0 ? Math.max(...allTimestamps) : undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const windowStart = refTime !== undefined ? refTime - windowMs : undefined;
|
|
46
|
+
const windowEnd = refTime !== undefined ? refTime + 1000 : undefined;
|
|
47
|
+
|
|
48
|
+
// 2. Filter network events that occurred within the action-anchored temporal window with error status codes (4xx, 5xx)
|
|
49
|
+
const suspiciousNetworkEvents = context.networkEvents.filter((event) => {
|
|
50
|
+
const isError = event.status >= 400 || Boolean(event.errorText);
|
|
51
|
+
if (!isError) return false;
|
|
52
|
+
|
|
53
|
+
if (windowStart !== undefined && windowEnd !== undefined && typeof event.timestamp === 'number') {
|
|
54
|
+
const sameScale =
|
|
55
|
+
(refTime! > 1e11 && event.timestamp > 1e11) ||
|
|
56
|
+
(refTime! < 1e11 && event.timestamp < 1e11);
|
|
57
|
+
|
|
58
|
+
if (sameScale) {
|
|
59
|
+
return event.timestamp >= windowStart && event.timestamp <= windowEnd;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// 3. If frameId is specified, sort matching frame events to the front
|
|
66
|
+
if (context.failedAction.frameId) {
|
|
67
|
+
const targetFrame = context.failedAction.frameId;
|
|
68
|
+
suspiciousNetworkEvents.sort((a, b) => {
|
|
69
|
+
const aMatch = a.frameId === targetFrame ? 1 : 0;
|
|
70
|
+
const bMatch = b.frameId === targetFrame ? 1 : 0;
|
|
71
|
+
return bMatch - aMatch;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 4. Filter console errors within the action-anchored temporal window
|
|
76
|
+
const suspiciousConsoleEvents = context.consoleEvents.filter((event) => {
|
|
77
|
+
const isConsoleError = event.type === 'error' || event.text.toLowerCase().includes('uncaught');
|
|
78
|
+
if (!isConsoleError) return false;
|
|
79
|
+
|
|
80
|
+
if (windowStart !== undefined && windowEnd !== undefined && typeof event.timestamp === 'number') {
|
|
81
|
+
return event.timestamp >= windowStart && event.timestamp <= windowEnd;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// 5. Pipe filtered, frame-matched events directly to the FailureClassifier
|
|
87
|
+
const windowedContext: DiagnosticContext = {
|
|
88
|
+
...context,
|
|
89
|
+
networkEvents: suspiciousNetworkEvents,
|
|
90
|
+
consoleEvents: suspiciousConsoleEvents,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const classification = FailureClassifier.classify(windowedContext);
|
|
94
|
+
const failureObservation: FailureObservation = {
|
|
95
|
+
id: context.failedAction.callId,
|
|
96
|
+
category: classification.category,
|
|
97
|
+
action: context.failedAction.action,
|
|
98
|
+
selector: context.failedAction.selector,
|
|
99
|
+
sourceFile: context.failedAction.sourceFile,
|
|
100
|
+
errorMessage: context.failedAction.errorMessage,
|
|
101
|
+
errorStack: context.failedAction.errorStack,
|
|
102
|
+
networkStatuses: suspiciousNetworkEvents.map((event) => event.status),
|
|
103
|
+
timestamp: context.failedAction.timestamp,
|
|
104
|
+
durationMs: context.failedAction.durationMs,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
context,
|
|
109
|
+
classification,
|
|
110
|
+
failureObservation,
|
|
111
|
+
failureFingerprint: fingerprintFailure(failureObservation),
|
|
112
|
+
suspiciousNetworkEvents,
|
|
113
|
+
suspiciousConsoleEvents,
|
|
114
|
+
temporalWindowMs: windowMs,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DiagnosticContext, FailedAction } from '../core/types/diagnostic-context.js';
|
|
2
|
+
import { EvidenceRedactor } from '../evidence/evidence-redactor.js';
|
|
3
|
+
|
|
4
|
+
export interface ExternalFailureEvidence {
|
|
5
|
+
errorMessage: string;
|
|
6
|
+
errorStack?: string | undefined;
|
|
7
|
+
action?: string | undefined;
|
|
8
|
+
selector?: string | undefined;
|
|
9
|
+
sourceFile?: string | undefined;
|
|
10
|
+
line?: number | undefined;
|
|
11
|
+
column?: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function extractSelector(text: string): string | undefined {
|
|
15
|
+
const match = text.match(/waiting for (?:locator|getByRole|getByText|getByTestId|getByLabel|getByPlaceholder)\((['"`])([\s\S]*?)\1\)/i)
|
|
16
|
+
?? text.match(/locator\((['"`])([\s\S]*?)\1\)/i);
|
|
17
|
+
return match?.[2];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function extractAction(text: string): string | undefined {
|
|
21
|
+
const match = text.match(/\b(page|locator|frameLocator)\.(click|fill|press|check|uncheck|hover|selectOption|goto|waitFor|dblclick)\b/i);
|
|
22
|
+
return match ? `${match[1]}.${match[2]}` : undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function extractLocation(text: string): Pick<ExternalFailureEvidence, 'sourceFile' | 'line' | 'column'> {
|
|
26
|
+
const lines = text.split(/\r?\n/);
|
|
27
|
+
for (const line of lines) {
|
|
28
|
+
const match = line.match(/(?:at\s+.*?\s+)?((?:[A-Za-z]:[\\/]|\/)?[^()\r\n]+?\.(?:ts|tsx|js|jsx):([0-9]+):([0-9]+))/i);
|
|
29
|
+
if (match?.[1] && match[2] && match[3]) {
|
|
30
|
+
return { sourceFile: match[1].trim(), line: Number(match[2]), column: Number(match[3]) };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Parses a Playwright error-context.md file without treating it as trusted source code. */
|
|
37
|
+
export function parseExternalFailureEvidence(rawText: string): ExternalFailureEvidence {
|
|
38
|
+
const raw = rawText.trim();
|
|
39
|
+
const { redactedText: errorMessage } = EvidenceRedactor.redactText(raw);
|
|
40
|
+
const location = extractLocation(raw);
|
|
41
|
+
return {
|
|
42
|
+
errorMessage: errorMessage.slice(0, 20000),
|
|
43
|
+
errorStack: errorMessage.slice(0, 20000),
|
|
44
|
+
action: extractAction(raw),
|
|
45
|
+
selector: extractSelector(raw),
|
|
46
|
+
...location,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Supplements a trace context only when the trace did not contain a usable
|
|
52
|
+
* failed action. Existing trace evidence remains authoritative.
|
|
53
|
+
*/
|
|
54
|
+
export function supplementDiagnosticContext(
|
|
55
|
+
context: DiagnosticContext,
|
|
56
|
+
external: ExternalFailureEvidence,
|
|
57
|
+
): DiagnosticContext {
|
|
58
|
+
const isFallback = context.failedAction.callId === 'unknown' || context.failedAction.errorMessage === 'No explicit action failure recorded in trace';
|
|
59
|
+
if (!isFallback) return context;
|
|
60
|
+
|
|
61
|
+
const failedAction: FailedAction = {
|
|
62
|
+
...context.failedAction,
|
|
63
|
+
...(external.action ? { action: external.action } : {}),
|
|
64
|
+
...(external.selector ? { selector: external.selector } : {}),
|
|
65
|
+
...(external.sourceFile ? { sourceFile: external.sourceFile } : {}),
|
|
66
|
+
...(external.line !== undefined ? { line: external.line } : {}),
|
|
67
|
+
...(external.column !== undefined ? { column: external.column } : {}),
|
|
68
|
+
errorMessage: external.errorMessage,
|
|
69
|
+
...(external.errorStack ? { errorStack: external.errorStack } : {}),
|
|
70
|
+
};
|
|
71
|
+
return { ...context, failedAction };
|
|
72
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FailureCategory } from '../core/types/diagnostic-context.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts historical, external, and compatibility labels into the
|
|
5
|
+
* canonical categories used by current diagnostics and reporting.
|
|
6
|
+
* Unknown labels are preserved in normalized uppercase form so external
|
|
7
|
+
* evaluation data remains auditable instead of being silently discarded.
|
|
8
|
+
*/
|
|
9
|
+
const CATEGORY_ALIASES: Record<string, string> = {
|
|
10
|
+
AUTH_SESSION_EXPIRED: 'AUTH_EXPIRED',
|
|
11
|
+
AUTHENTICATION_FAILURE: 'AUTH_EXPIRED',
|
|
12
|
+
AUTHENTICATION_EXPIRED: 'AUTH_EXPIRED',
|
|
13
|
+
AUTHENTICATION_ERROR: 'AUTH_EXPIRED',
|
|
14
|
+
ASSERTION_FAILED: 'ASSERTION_FAILURE',
|
|
15
|
+
ASSERTION_MISMATCH: 'ASSERTION_FAILURE',
|
|
16
|
+
ASSERTION_DISCREPANCY: 'ASSERTION_FAILURE',
|
|
17
|
+
BACKEND_ERROR: 'BACKEND_500',
|
|
18
|
+
BACKEND_SERVICE_OUTAGE: 'BACKEND_500',
|
|
19
|
+
BACKEND_OUTAGE: 'BACKEND_500',
|
|
20
|
+
AMBIGUOUS_LOCATOR: 'AMBIGUOUS_MATCH',
|
|
21
|
+
AMBIGUOUS_CONTROL: 'AMBIGUOUS_MATCH',
|
|
22
|
+
DISABLED_CONTROL: 'DISABLED_ELEMENT',
|
|
23
|
+
DYNAMIC_CONTENT_SLOW: 'HYDRATION_OR_TIMING',
|
|
24
|
+
HYDRATION_DELAY: 'HYDRATION_OR_TIMING',
|
|
25
|
+
NETWORK_ERROR: 'NETWORK_OFFLINE',
|
|
26
|
+
UNRELATED_NETWORK_ERROR: 'NETWORK_OFFLINE',
|
|
27
|
+
TIMEOUT: 'TIMING_RACE',
|
|
28
|
+
UNKNOWN: 'UNKNOWN_ERROR',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function normalizeFailureCategory(category: string | undefined): string {
|
|
32
|
+
const normalized = (category ?? '').trim().toUpperCase().replace(/[\s-]+/g, '_');
|
|
33
|
+
if (!normalized) return 'UNKNOWN_ERROR';
|
|
34
|
+
return CATEGORY_ALIASES[normalized] ?? normalized;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function normalizeTypedFailureCategory(category: FailureCategory): FailureCategory {
|
|
38
|
+
return normalizeFailureCategory(category) as FailureCategory;
|
|
39
|
+
}
|
|
40
|
+
|