@skyramp/mcp 0.3.2-rc.pom-3 → 0.3.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/build/commands/commandLibrary.d.ts +1 -0
- package/build/commands/commandLibrary.js +19 -13
- package/build/commands/localDevTestChangesCommand.d.ts +15 -0
- package/build/commands/localDevTestChangesCommand.js +201 -0
- package/build/index.js +80 -6
- package/build/prompts/code-reuse.js +3 -0
- package/build/prompts/enhance-assertions/sharedAssertionRules.d.ts +1 -0
- package/build/prompts/enhance-assertions/sharedAssertionRules.js +17 -0
- package/build/prompts/initialize-workspace/initializeWorkspacePrompt.js +11 -9
- package/build/prompts/local-dev/local-dev-plan.d.ts +35 -0
- package/build/prompts/local-dev/local-dev-plan.js +429 -0
- package/build/prompts/local-dev/local-dev-prompts.d.ts +4 -0
- package/build/prompts/local-dev/local-dev-prompts.js +190 -0
- package/build/prompts/pom-aware-code-reuse.js +12 -0
- package/build/prompts/prompt-utils.d.ts +8 -0
- package/build/prompts/prompt-utils.js +33 -0
- package/build/prompts/sut-setup/modes/adaptWorkflowPrompt.js +37 -14
- package/build/prompts/sut-setup/shared.js +16 -12
- package/build/prompts/test-recommendation/analysisOutputPrompt.js +21 -29
- package/build/prompts/test-recommendation/scopeAssessment.d.ts +24 -7
- package/build/prompts/test-recommendation/scopeAssessment.js +111 -12
- package/build/prompts/test-recommendation/test-recommendation-prompt.js +41 -4
- package/build/prompts/testbot/testbot-prompts.d.ts +0 -5
- package/build/prompts/testbot/testbot-prompts.js +32 -52
- package/build/recommendation/planRanker.d.ts +15 -2
- package/build/recommendation/planRanker.js +76 -5
- package/build/resources/testbotResource.js +2 -1
- package/build/services/AnalyticsService.d.ts +1 -1
- package/build/services/TestExecutionService.d.ts +2 -1
- package/build/services/TestExecutionService.js +8 -3
- package/build/services/TestGenerationService.d.ts +2 -2
- package/build/services/TestGenerationService.js +39 -21
- package/build/services/containerEnv.js +3 -1
- package/build/tool-phases.js +6 -0
- package/build/tools/code-refactor/codeReuseTool.js +43 -4
- package/build/tools/code-refactor/enhanceAssertionsTool.js +68 -18
- package/build/tools/code-refactor/reuse-outcome.d.ts +109 -0
- package/build/tools/code-refactor/reuse-outcome.js +158 -0
- package/build/tools/code-refactor/reuse-state.d.ts +45 -0
- package/build/tools/code-refactor/reuse-state.js +140 -0
- package/build/tools/enrichTestWithMocksTool.d.ts +28 -0
- package/build/tools/enrichTestWithMocksTool.js +726 -0
- package/build/tools/executeSkyrampTestTool.d.ts +11 -0
- package/build/tools/executeSkyrampTestTool.js +62 -21
- package/build/tools/generate-tests/batchMockGenerationTool.d.ts +106 -0
- package/build/tools/generate-tests/batchMockGenerationTool.js +545 -0
- package/build/tools/generate-tests/generateBatchScenarioRestTool.js +25 -23
- package/build/tools/generate-tests/generateContractRestTool.js +2 -2
- package/build/tools/generate-tests/generateE2ERestTool.d.ts +1 -1
- package/build/tools/generate-tests/generateE2ERestTool.js +1 -1
- package/build/tools/generate-tests/generateLoadRestTool.d.ts +1 -1
- package/build/tools/generate-tests/generateLoadRestTool.js +1 -1
- package/build/tools/generate-tests/generateMockRestTool.d.ts +179 -6
- package/build/tools/generate-tests/generateMockRestTool.js +391 -22
- package/build/tools/generate-tests/loadTestSchema.d.ts +1 -1
- package/build/tools/generate-tests/planGuard.js +2 -22
- package/build/tools/generateEnrichedIntegrationTestTool.d.ts +25 -0
- package/build/tools/generateEnrichedIntegrationTestTool.js +235 -0
- package/build/tools/localDevWorkerComposeTool.d.ts +24 -0
- package/build/tools/localDevWorkerComposeTool.js +264 -0
- package/build/tools/one-click/oneClickTool.d.ts +13 -0
- package/build/tools/one-click/oneClickTool.js +195 -24
- package/build/tools/preflightMockCheckTool.d.ts +2 -0
- package/build/tools/preflightMockCheckTool.js +96 -0
- package/build/tools/queryProxyMocksTool.d.ts +70 -0
- package/build/tools/queryProxyMocksTool.js +522 -0
- package/build/tools/runExistingTestsTool.d.ts +31 -0
- package/build/tools/runExistingTestsTool.js +214 -13
- package/build/tools/submitReportTool.js +38 -3
- package/build/tools/test-management/analyzeChangesTool.d.ts +2 -1
- package/build/tools/test-management/analyzeChangesTool.js +63 -40
- package/build/tools/test-management/registerTestPlanTool.js +55 -7
- package/build/tools/trace/startTraceCollectionTool.js +3 -3
- package/build/types/FrontendIntegration.d.ts +3 -0
- package/build/types/FrontendIntegration.js +3 -0
- package/build/types/OneClickCommands.d.ts +1 -1
- package/build/types/Recommendation.d.ts +20 -0
- package/build/types/Recommendation.js +32 -6
- package/build/types/RepositoryAnalysis.d.ts +131 -14
- package/build/types/RepositoryAnalysis.js +16 -2
- package/build/types/ReuseOutcome.d.ts +63 -0
- package/build/types/ReuseOutcome.js +33 -0
- package/build/types/TestExecution.d.ts +1 -0
- package/build/types/TestTypes.d.ts +25 -7
- package/build/types/TestTypes.js +22 -6
- package/build/types/TestbotReport.d.ts +7 -0
- package/build/types/index.d.ts +2 -0
- package/build/types/index.js +1 -0
- package/build/utils/AnalysisStateManager.d.ts +26 -0
- package/build/utils/AnalysisStateManager.js +31 -1
- package/build/utils/analyze-openapi.js +18 -1
- package/build/utils/branchDiff.d.ts +17 -1
- package/build/utils/branchDiff.js +99 -14
- package/build/utils/featureFlags.d.ts +31 -0
- package/build/utils/featureFlags.js +37 -0
- package/build/utils/frontendIntegration.js +8 -1
- package/build/utils/grpcMockValidation.d.ts +1 -0
- package/build/utils/grpcMockValidation.js +49 -0
- package/build/utils/httpMethodValidation.d.ts +4 -0
- package/build/utils/httpMethodValidation.js +15 -0
- package/build/utils/logger.js +1 -1
- package/build/utils/mockCompatibility.d.ts +49 -0
- package/build/utils/mockCompatibility.js +82 -0
- package/build/utils/pom-scope/pom-files.js +7 -0
- package/build/utils/pom-verify/bindings.js +11 -1
- package/build/utils/pom-verify/re-exports.d.ts +10 -0
- package/build/utils/pom-verify/re-exports.js +61 -0
- package/build/utils/pom-verify/resolve.d.ts +4 -1
- package/build/utils/pom-verify/resolve.js +7 -4
- package/build/utils/pom-verify/verify.d.ts +5 -0
- package/build/utils/pom-verify/verify.js +25 -3
- package/build/utils/progress.js +10 -5
- package/build/utils/proxy-terminal.js +3 -3
- package/build/utils/routeParsers.d.ts +3 -9
- package/build/utils/routeParsers.js +79 -4
- package/build/utils/utils.js +2 -2
- package/build/utils/versions.d.ts +4 -3
- package/build/utils/versions.js +3 -1
- package/build/utils/workspaceAuth.d.ts +46 -0
- package/build/utils/workspaceAuth.js +156 -1
- package/build/workspace/testSuites.d.ts +2 -1
- package/build/workspace/testSuites.js +1 -1
- package/build/workspace/workspace.d.ts +108 -32
- package/build/workspace/workspace.js +32 -4
- package/package.json +5 -2
- package/build/adapters/jestAdapter.test.d.ts +0 -1
- package/build/adapters/jestAdapter.test.js +0 -93
- package/build/adapters/mochaAdapter.test.d.ts +0 -1
- package/build/adapters/mochaAdapter.test.js +0 -63
- package/build/adapters/playwrightAdapter.test.d.ts +0 -1
- package/build/adapters/playwrightAdapter.test.js +0 -169
- package/build/adapters/pytestAdapter.test.d.ts +0 -1
- package/build/adapters/pytestAdapter.test.js +0 -90
- package/build/prompts/code-reuse.test.d.ts +0 -1
- package/build/prompts/code-reuse.test.js +0 -62
- package/build/prompts/pom-aware-code-reuse.test.d.ts +0 -1
- package/build/prompts/pom-aware-code-reuse.test.js +0 -11
- package/build/prompts/test-maintenance/drift-analysis-prompt.test.d.ts +0 -1
- package/build/prompts/test-maintenance/drift-analysis-prompt.test.js +0 -51
- package/build/prompts/test-recommendation/analysisOutputPrompt.test.d.ts +0 -1
- package/build/prompts/test-recommendation/analysisOutputPrompt.test.js +0 -264
- package/build/prompts/test-recommendation/mergeEnrichedScenarios.test.d.ts +0 -1
- package/build/prompts/test-recommendation/mergeEnrichedScenarios.test.js +0 -126
- package/build/prompts/test-recommendation/promptPlan.test.d.ts +0 -1
- package/build/prompts/test-recommendation/promptPlan.test.js +0 -336
- package/build/prompts/test-recommendation/scopeAssessment.test.d.ts +0 -1
- package/build/prompts/test-recommendation/scopeAssessment.test.js +0 -371
- package/build/prompts/test-recommendation/test-recommendation-prompt.test.d.ts +0 -1
- package/build/prompts/test-recommendation/test-recommendation-prompt.test.js +0 -1925
- package/build/prompts/testbot/testbot-prompts.test.d.ts +0 -1
- package/build/prompts/testbot/testbot-prompts.test.js +0 -451
- package/build/recommendation/budgeters/diversityBalancedBudgeter.test.d.ts +0 -1
- package/build/recommendation/budgeters/diversityBalancedBudgeter.test.js +0 -138
- package/build/recommendation/budgeters/fixedNBudgeter.test.d.ts +0 -1
- package/build/recommendation/budgeters/fixedNBudgeter.test.js +0 -66
- package/build/recommendation/discriminators.test.d.ts +0 -1
- package/build/recommendation/discriminators.test.js +0 -324
- package/build/recommendation/diversity.test.d.ts +0 -1
- package/build/recommendation/diversity.test.js +0 -77
- package/build/recommendation/planRanker.test.d.ts +0 -1
- package/build/recommendation/planRanker.test.js +0 -110
- package/build/resources/testbotResource.test.d.ts +0 -1
- package/build/resources/testbotResource.test.js +0 -44
- package/build/services/AnalyticsService.test.d.ts +0 -1
- package/build/services/AnalyticsService.test.js +0 -86
- package/build/services/ScenarioGenerationService.integration.test.d.ts +0 -1
- package/build/services/ScenarioGenerationService.integration.test.js +0 -162
- package/build/services/ScenarioGenerationService.test.d.ts +0 -1
- package/build/services/ScenarioGenerationService.test.js +0 -414
- package/build/services/TestDiscoveryService.test.d.ts +0 -1
- package/build/services/TestDiscoveryService.test.js +0 -983
- package/build/services/TestExecutionService.test.d.ts +0 -1
- package/build/services/TestExecutionService.test.js +0 -1032
- package/build/services/TestGenerationService.test.d.ts +0 -1
- package/build/services/TestGenerationService.test.js +0 -578
- package/build/tool-phase-coverage.test.d.ts +0 -1
- package/build/tool-phase-coverage.test.js +0 -49
- package/build/tools/code-refactor/codeReuseTool.test.d.ts +0 -1
- package/build/tools/code-refactor/codeReuseTool.test.js +0 -572
- package/build/tools/generate-tests/generateBatchScenarioRestTool.test.d.ts +0 -1
- package/build/tools/generate-tests/generateBatchScenarioRestTool.test.js +0 -433
- package/build/tools/generate-tests/generateContractRestTool.test.d.ts +0 -1
- package/build/tools/generate-tests/generateContractRestTool.test.js +0 -142
- package/build/tools/generate-tests/generateIntegrationRestTool.test.d.ts +0 -1
- package/build/tools/generate-tests/generateIntegrationRestTool.test.js +0 -159
- package/build/tools/generate-tests/generateLoadRestTool.test.d.ts +0 -1
- package/build/tools/generate-tests/generateLoadRestTool.test.js +0 -169
- package/build/tools/generate-tests/generateUIRestTool.test.d.ts +0 -1
- package/build/tools/generate-tests/generateUIRestTool.test.js +0 -32
- package/build/tools/generate-tests/planGuard.test.d.ts +0 -1
- package/build/tools/generate-tests/planGuard.test.js +0 -185
- package/build/tools/generate-tests/scenarioLint.test.d.ts +0 -1
- package/build/tools/generate-tests/scenarioLint.test.js +0 -100
- package/build/tools/runExistingTestsTool.test.d.ts +0 -1
- package/build/tools/runExistingTestsTool.test.js +0 -379
- package/build/tools/submitReportTool.test.d.ts +0 -1
- package/build/tools/submitReportTool.test.js +0 -1428
- package/build/tools/test-management/actionsTool.test.d.ts +0 -1
- package/build/tools/test-management/actionsTool.test.js +0 -436
- package/build/tools/test-management/analyzeChangesTool.test.d.ts +0 -1
- package/build/tools/test-management/analyzeChangesTool.test.js +0 -522
- package/build/tools/test-management/analyzeTestHealthTool.test.d.ts +0 -1
- package/build/tools/test-management/analyzeTestHealthTool.test.js +0 -385
- package/build/tools/test-management/registerTestPlanTool.test.d.ts +0 -1
- package/build/tools/test-management/registerTestPlanTool.test.js +0 -296
- package/build/tools/trace/resolveSaveStoragePath.test.d.ts +0 -1
- package/build/tools/trace/resolveSaveStoragePath.test.js +0 -17
- package/build/tools/trace/resolveSessionPaths.test.d.ts +0 -1
- package/build/tools/trace/resolveSessionPaths.test.js +0 -104
- package/build/tools/trace/sessionState.test.d.ts +0 -1
- package/build/tools/trace/sessionState.test.js +0 -17
- package/build/tools/workspace/initializeWorkspaceTool.test.d.ts +0 -1
- package/build/tools/workspace/initializeWorkspaceTool.test.js +0 -139
- package/build/tools/workspace/serviceUpsert.test.d.ts +0 -1
- package/build/tools/workspace/serviceUpsert.test.js +0 -50
- package/build/utils/AnalysisStateManager.test.d.ts +0 -1
- package/build/utils/AnalysisStateManager.test.js +0 -134
- package/build/utils/dartRouteExtractor.test.d.ts +0 -1
- package/build/utils/dartRouteExtractor.test.js +0 -307
- package/build/utils/docker.test.d.ts +0 -1
- package/build/utils/docker.test.js +0 -114
- package/build/utils/featureFlags.test.d.ts +0 -1
- package/build/utils/featureFlags.test.js +0 -81
- package/build/utils/fileWalk.test.d.ts +0 -1
- package/build/utils/fileWalk.test.js +0 -252
- package/build/utils/frontendIntegration.test.d.ts +0 -1
- package/build/utils/frontendIntegration.test.js +0 -229
- package/build/utils/frontendSelectors.test.d.ts +0 -1
- package/build/utils/frontendSelectors.test.js +0 -118
- package/build/utils/gitStaging.test.d.ts +0 -1
- package/build/utils/gitStaging.test.js +0 -111
- package/build/utils/httpDefaults.test.d.ts +0 -1
- package/build/utils/httpDefaults.test.js +0 -21
- package/build/utils/importerHop.test.d.ts +0 -1
- package/build/utils/importerHop.test.js +0 -469
- package/build/utils/pathAffinityClassification.test.d.ts +0 -1
- package/build/utils/pathAffinityClassification.test.js +0 -208
- package/build/utils/planMatchKeys.test.d.ts +0 -1
- package/build/utils/planMatchKeys.test.js +0 -123
- package/build/utils/pom-scope/index.test.d.ts +0 -1
- package/build/utils/pom-scope/index.test.js +0 -278
- package/build/utils/pom-scope/pom-files.test.d.ts +0 -1
- package/build/utils/pom-scope/pom-files.test.js +0 -29
- package/build/utils/pom-scope/scoring.test.d.ts +0 -1
- package/build/utils/pom-scope/scoring.test.js +0 -39
- package/build/utils/pom-scope/selector-extractor.test.d.ts +0 -1
- package/build/utils/pom-scope/selector-extractor.test.js +0 -67
- package/build/utils/pom-verify/bindings.test.d.ts +0 -1
- package/build/utils/pom-verify/bindings.test.js +0 -164
- package/build/utils/pom-verify/calls.test.d.ts +0 -1
- package/build/utils/pom-verify/calls.test.js +0 -61
- package/build/utils/pom-verify/resolve.test.d.ts +0 -1
- package/build/utils/pom-verify/resolve.test.js +0 -114
- package/build/utils/pom-verify/verify.test.d.ts +0 -1
- package/build/utils/pom-verify/verify.test.js +0 -374
- package/build/utils/pr-comment-parser.test.d.ts +0 -1
- package/build/utils/pr-comment-parser.test.js +0 -428
- package/build/utils/progress.test.d.ts +0 -1
- package/build/utils/progress.test.js +0 -37
- package/build/utils/projectMetadata.test.d.ts +0 -1
- package/build/utils/projectMetadata.test.js +0 -172
- package/build/utils/pythonMountPrefixes.test.d.ts +0 -1
- package/build/utils/pythonMountPrefixes.test.js +0 -113
- package/build/utils/repoScanner.test.d.ts +0 -1
- package/build/utils/repoScanner.test.js +0 -190
- package/build/utils/reportVerification.test.d.ts +0 -1
- package/build/utils/reportVerification.test.js +0 -185
- package/build/utils/routeParsers.test.d.ts +0 -1
- package/build/utils/routeParsers.test.js +0 -1011
- package/build/utils/scenarioDrafting.test.d.ts +0 -1
- package/build/utils/scenarioDrafting.test.js +0 -876
- package/build/utils/sourceRouteExtractor.test.d.ts +0 -1
- package/build/utils/sourceRouteExtractor.test.js +0 -738
- package/build/utils/telemetry.test.d.ts +0 -1
- package/build/utils/telemetry.test.js +0 -70
- package/build/utils/trace-parser.test.d.ts +0 -6
- package/build/utils/trace-parser.test.js +0 -140
- package/build/utils/uiPageEnumerator.test.d.ts +0 -1
- package/build/utils/uiPageEnumerator.test.js +0 -824
- package/build/utils/utils.test.d.ts +0 -1
- package/build/utils/utils.test.js +0 -103
- package/build/utils/walkerCharacterization.test.d.ts +0 -1
- package/build/utils/walkerCharacterization.test.js +0 -233
- package/build/utils/workspaceAuth.test.d.ts +0 -1
- package/build/utils/workspaceAuth.test.js +0 -260
- package/build/workspace/testSuites.test.d.ts +0 -1
- package/build/workspace/testSuites.test.js +0 -23
- package/build/workspace/workspace.test.d.ts +0 -1
- package/build/workspace/workspace.test.js +0 -264
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import { logger } from "../../utils/logger.js";
|
|
4
|
+
import { resolveRunStatePath, StateManager, } from "../../utils/AnalysisStateManager.js";
|
|
5
|
+
import { verifyReuse } from "../../utils/pom-verify/index.js";
|
|
6
|
+
import { buildSkipped, findUnparsableKeptInline, flaggedFrom, mergeFlagged, verificationFrom, ReuseVerificationOutcome, } from "./reuse-outcome.js";
|
|
7
|
+
/**
|
|
8
|
+
* Persistence for the server-derived POM-reuse outcome, keyed by test-file
|
|
9
|
+
* basename (what `newTestsCreated[].fileName` carries, so
|
|
10
|
+
* `skyramp_submit_report` can match without path normalization).
|
|
11
|
+
*
|
|
12
|
+
* Every write is best-effort. Reuse observability must never be able to fail a
|
|
13
|
+
* refactor that otherwise succeeded, so a missing/unreadable/unwritable state
|
|
14
|
+
* file degrades to "no reuse summary in the report" — the same outcome as running
|
|
15
|
+
* outside a Testbot run, where there is no run state to record into.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Read-modify-write one spec's outcome. `patch` receives the entry recorded so
|
|
19
|
+
* far, so a caller that needs prior state (the verify pass, which accumulates
|
|
20
|
+
* flagged members) uses the same path as one that does not.
|
|
21
|
+
*
|
|
22
|
+
* Fields the patch omits are preserved: the prompt-generation call knows the
|
|
23
|
+
* candidate count, each verify pass knows the counts and verdict.
|
|
24
|
+
*/
|
|
25
|
+
async function updateReuseOutcome(testFile, patch, explicitStateFile) {
|
|
26
|
+
const stateFile = resolveRunStatePath(explicitStateFile);
|
|
27
|
+
if (!stateFile)
|
|
28
|
+
return;
|
|
29
|
+
try {
|
|
30
|
+
const manager = StateManager.fromStatePath(stateFile);
|
|
31
|
+
const data = await manager.readData();
|
|
32
|
+
if (!data)
|
|
33
|
+
return;
|
|
34
|
+
const key = path.basename(testFile);
|
|
35
|
+
const existing = data.reuseOutcomes?.[key] ?? {};
|
|
36
|
+
await manager.writeData({
|
|
37
|
+
...data,
|
|
38
|
+
reuseOutcomes: { ...data.reuseOutcomes, [key]: { ...existing, ...patch(existing) } },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
logger.warning("Could not record POM-reuse outcome — report will omit the reuse summary", {
|
|
43
|
+
testFile,
|
|
44
|
+
error: String(err),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Record the tier-1 candidate count STEP 1 detected. */
|
|
49
|
+
export async function recordCandidates(testFile, candidatesDetected, explicitStateFile) {
|
|
50
|
+
await updateReuseOutcome(testFile, () => ({ candidatesDetected }), explicitStateFile);
|
|
51
|
+
}
|
|
52
|
+
/** The prompt-generation call found no reusable POM layer at all. No candidate
|
|
53
|
+
* count is recorded: "0 candidates" adds nothing to "no POM layer was found",
|
|
54
|
+
* and rendering both produces a redundant zero in the summary. */
|
|
55
|
+
export async function recordNoPomLayer(testFile, explicitStateFile) {
|
|
56
|
+
await updateReuseOutcome(testFile, () => ({ verification: ReuseVerificationOutcome.SkippedNoPom }), explicitStateFile);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Record what one verify pass established: the call counts, the verdict, and the
|
|
60
|
+
* declines read out of the spec the verifier just parsed.
|
|
61
|
+
*
|
|
62
|
+
* `flagged` accumulates across passes because a PASSED verdict has no violations
|
|
63
|
+
* left to inspect — a member that was substituted and then restored survives only
|
|
64
|
+
* as a `// kept inline:` comment, indistinguishable from one the mapper never
|
|
65
|
+
* promoted. Accumulating is what keeps that distinction recoverable at all; it does
|
|
66
|
+
* not by itself establish it, since a flagged member may have been remapped rather
|
|
67
|
+
* than restored (see buildSkipped for how narrowly it is trusted).
|
|
68
|
+
*/
|
|
69
|
+
export async function recordVerifyOutcome(testFile, r, gateFired, language, explicitStateFile) {
|
|
70
|
+
if (!resolveRunStatePath(explicitStateFile))
|
|
71
|
+
return;
|
|
72
|
+
await updateReuseOutcome(testFile, (existing) => {
|
|
73
|
+
const flagged = mergeFlagged(existing.flagged, flaggedFrom(r));
|
|
74
|
+
return {
|
|
75
|
+
testFilePath: testFile,
|
|
76
|
+
language,
|
|
77
|
+
verification: verificationFrom(gateFired, r),
|
|
78
|
+
...(flagged.length > 0 ? { flagged } : {}),
|
|
79
|
+
};
|
|
80
|
+
}, explicitStateFile);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Re-derive a recorded outcome from the spec as it stands NOW, so the report
|
|
84
|
+
* describes the delivered artifact rather than the state at verify time.
|
|
85
|
+
*
|
|
86
|
+
* The two can differ: the execution fix-up may restore `<testFile>.raw.bak` over
|
|
87
|
+
* the spec after verification, reverting every substitution with a plain `cp` that
|
|
88
|
+
* this tool never sees. Trusting the recorded counts there would publish
|
|
89
|
+
* `callsReused: 5, verification: "passed"` for a spec containing no POM calls —
|
|
90
|
+
* a confident false claim, strictly worse than the silence this feature replaced.
|
|
91
|
+
* Re-deriving here rather than requiring a final `verify: true` pass is deliberate:
|
|
92
|
+
* the report step always runs, so the agent cannot skip it.
|
|
93
|
+
*
|
|
94
|
+
* `candidatesDetected` is kept as recorded — it counts POM FILES that detection
|
|
95
|
+
* found, which a restore does not change. Everything else comes from the file.
|
|
96
|
+
*
|
|
97
|
+
* `verification` is dropped when the delivered spec reuses nothing: a PASSED
|
|
98
|
+
* verdict describes a spec that no longer exists, and pairing it with a zero count
|
|
99
|
+
* reads as though the empty result had been blessed.
|
|
100
|
+
*
|
|
101
|
+
* Returns the recorded outcome minus internals when re-derivation is impossible
|
|
102
|
+
* (no path recorded — e.g. only the candidate count was ever written), and
|
|
103
|
+
* `undefined` when it fails outright. Failing closed matters: falling back to the
|
|
104
|
+
* recorded counts is exactly the false claim this exists to prevent.
|
|
105
|
+
*/
|
|
106
|
+
export async function rederiveReuseOutcome(record) {
|
|
107
|
+
const { candidatesDetected, verification, flagged, testFilePath, language } = record;
|
|
108
|
+
// No verify pass ran for this spec, so there are no counts to derive — only the
|
|
109
|
+
// detection-time facts, which no spec change can invalidate.
|
|
110
|
+
if (!testFilePath || !language)
|
|
111
|
+
return { candidatesDetected, verification };
|
|
112
|
+
try {
|
|
113
|
+
const r = await verifyReuse(testFilePath, language);
|
|
114
|
+
const specContent = await readFile(testFilePath, "utf8");
|
|
115
|
+
// Diagnose the file the report is actually built from. A marker the zero-reuse
|
|
116
|
+
// gate accepts but this cannot parse satisfies the escape hatch while its
|
|
117
|
+
// decline never reaches the report — silent signal loss is the failure class
|
|
118
|
+
// this feature exists to close.
|
|
119
|
+
const unparsable = findUnparsableKeptInline(specContent);
|
|
120
|
+
if (unparsable.length > 0) {
|
|
121
|
+
logger.warning("Malformed `// kept inline:` marker(s) in the delivered spec — these declines will be missing from the PR report. " +
|
|
122
|
+
"Use `// kept inline: <file basename> — <reason>` (em dash, or a hyphen with spaces around it).", { testFile: testFilePath, markers: unparsable });
|
|
123
|
+
}
|
|
124
|
+
const skipped = buildSkipped(specContent, flagged);
|
|
125
|
+
return {
|
|
126
|
+
candidatesDetected,
|
|
127
|
+
callsReused: r.reusedCalls,
|
|
128
|
+
callsVerified: r.checkedCalls,
|
|
129
|
+
// A PASSED verdict describes a spec that no longer exists once reuse is gone,
|
|
130
|
+
// and pairing it with a zero count reads as though the empty result had been
|
|
131
|
+
// blessed.
|
|
132
|
+
verification: r.reusedCalls > 0 ? verification : undefined,
|
|
133
|
+
skipped: skipped.length > 0 ? skipped : undefined,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
logger.warning("Could not re-derive the POM-reuse outcome from the delivered spec — omitting the reuse summary rather than reporting counts that may no longer hold", { testFile: testFilePath, error: String(err) });
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { ProgrammingLanguage, MockProtocol } from "../types/TestTypes.js";
|
|
3
|
+
/**
|
|
4
|
+
* skyramp_enrich_test_with_mocks
|
|
5
|
+
*
|
|
6
|
+
* Injects mock imports and apply_mock() calls into a generated test file.
|
|
7
|
+
* The mock files are generated by skyramp_mock_generation — this tool wires
|
|
8
|
+
* them into the test so the mocks are applied before the test runs.
|
|
9
|
+
*
|
|
10
|
+
* No data duplication — the test imports from the generated mock files.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerEnrichTestWithMocksTool(server: McpServer): void;
|
|
13
|
+
declare function injectMockImports(original: string, testFile: string, scenarioName: string, mockFiles: string[], traceComments?: string[], language?: ProgrammingLanguage): string;
|
|
14
|
+
declare function isSupportedMockEnrichmentLanguage(language: ProgrammingLanguage | string): language is ProgrammingLanguage;
|
|
15
|
+
type MockEntry = {
|
|
16
|
+
serviceName: string;
|
|
17
|
+
moduleName: string;
|
|
18
|
+
relativePath: string;
|
|
19
|
+
importPath: string;
|
|
20
|
+
importLabel: string;
|
|
21
|
+
mockFile: string;
|
|
22
|
+
className: string;
|
|
23
|
+
classReference: string;
|
|
24
|
+
targetUrl?: string;
|
|
25
|
+
protocol: MockProtocol;
|
|
26
|
+
};
|
|
27
|
+
declare function buildMockImportBlock(testFile: string, scenarioName: string, mockFiles: string[], traceComments?: string[], language?: ProgrammingLanguage, mockEntries?: MockEntry[]): string;
|
|
28
|
+
export { injectMockImports, buildMockImportBlock, isSupportedMockEnrichmentLanguage };
|