dd-trace 5.135.0 → 5.136.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/ci/init.js +2 -22
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/package.json +11 -9
- package/packages/datadog-esbuild/index.js +8 -55
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +18 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +17 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +22 -11
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +42 -2
- package/packages/dd-trace/src/config/index.js +17 -5
- package/packages/dd-trace/src/config/parsers.js +9 -0
- package/packages/dd-trace/src/config/supported-configurations.json +158 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +4 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +35 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +41 -10
- package/packages/dd-trace/src/plugins/index.js +6 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +75 -46
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +64 -39
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +33 -53
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -1,666 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
|
-
|
|
5
|
-
const path = require('node:path')
|
|
6
|
-
const fs = require('node:fs')
|
|
7
|
-
|
|
8
|
-
const { sanitizeConsoleText, sanitizeForReport, sanitizeString } = require('./redaction')
|
|
9
|
-
const { writeFileSafely } = require('./safe-files')
|
|
10
|
-
|
|
11
|
-
const REPORT_FILENAME = 'report.md'
|
|
12
|
-
const APPROVAL_DIGEST_PATTERN = /^[a-f0-9]{64}$/
|
|
13
|
-
const MAX_EXECUTION_PLAN_BYTES = 1024 * 1024
|
|
14
|
-
const SHARING_WARNING =
|
|
15
|
-
'This local diagnostic may contain repository paths, package names, CI metadata, commands, and sanitized output. ' +
|
|
16
|
-
'Review it before sharing outside trusted support or engineering channels.'
|
|
17
|
-
const SCENARIO_NAMES = {
|
|
18
|
-
all: 'Setup',
|
|
19
|
-
atr: 'Auto Test Retries',
|
|
20
|
-
'basic-reporting': 'Basic Reporting',
|
|
21
|
-
'ci-wiring': 'CI configuration',
|
|
22
|
-
efd: 'Early Flake Detection',
|
|
23
|
-
'generated-test-verification': 'Temporary test verification',
|
|
24
|
-
'test-management': 'Test Management',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Writes the final human-readable report and compact console summary.
|
|
29
|
-
*
|
|
30
|
-
* @param {object} input report inputs
|
|
31
|
-
* @param {object} input.manifest normalized manifest
|
|
32
|
-
* @param {object[]} input.results validation results
|
|
33
|
-
* @param {string} input.out output directory
|
|
34
|
-
* @param {object} [input.staticDiagnosis] static diagnosis artifacts
|
|
35
|
-
* @param {object} [input.runSummary] run summary
|
|
36
|
-
*/
|
|
37
|
-
function writeReport ({ manifest, results, out, staticDiagnosis, runSummary = {} }) {
|
|
38
|
-
const reportPath = path.join(out, REPORT_FILENAME)
|
|
39
|
-
const labels = getFrameworkLabels(manifest)
|
|
40
|
-
const sanitizedResults = sanitizeForReport(results).map(result => ({
|
|
41
|
-
...result,
|
|
42
|
-
frameworkDisplayName: labels.get(result.frameworkId) || result.frameworkId,
|
|
43
|
-
}))
|
|
44
|
-
const report = renderReport({
|
|
45
|
-
manifest,
|
|
46
|
-
out,
|
|
47
|
-
reportPath,
|
|
48
|
-
results: sanitizedResults,
|
|
49
|
-
runSummary: sanitizeForReport(runSummary),
|
|
50
|
-
staticDiagnosisPath: staticDiagnosis?.reportPath,
|
|
51
|
-
})
|
|
52
|
-
writeFileSafely(out, reportPath, report, 'Markdown report')
|
|
53
|
-
console.log(sanitizeConsoleText(renderConsole(sanitizedResults, runSummary, reportPath)))
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Writes an explicit pending report before project code runs.
|
|
58
|
-
*
|
|
59
|
-
* @param {object} input pending report inputs
|
|
60
|
-
* @param {object} input.manifest normalized manifest
|
|
61
|
-
* @param {string} input.out output directory
|
|
62
|
-
*/
|
|
63
|
-
function writePendingReport ({ manifest, out }) {
|
|
64
|
-
const reportPath = path.join(out, REPORT_FILENAME)
|
|
65
|
-
writeFileSafely(out, reportPath, [
|
|
66
|
-
'# Datadog Test Optimization Validation Report',
|
|
67
|
-
'',
|
|
68
|
-
'**Report state: PENDING**',
|
|
69
|
-
'',
|
|
70
|
-
'**Status: PENDING**',
|
|
71
|
-
'',
|
|
72
|
-
'Validation started but did not finish. This is not a final report. Do not draw a Test Optimization conclusion ' +
|
|
73
|
-
'from this file.',
|
|
74
|
-
'',
|
|
75
|
-
`Manifest: ${code(relative(out, manifest.__path))}`,
|
|
76
|
-
'',
|
|
77
|
-
`> ${SHARING_WARNING}`,
|
|
78
|
-
'',
|
|
79
|
-
].join('\n'), 'pending Markdown report')
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Renders the final Markdown report.
|
|
84
|
-
*
|
|
85
|
-
* @param {object} input rendering inputs
|
|
86
|
-
* @param {object} input.manifest normalized manifest
|
|
87
|
-
* @param {string} input.out output directory
|
|
88
|
-
* @param {string} input.reportPath report path
|
|
89
|
-
* @param {object[]} input.results sanitized results
|
|
90
|
-
* @param {object} input.runSummary run summary
|
|
91
|
-
* @param {string|undefined} input.staticDiagnosisPath static diagnosis path
|
|
92
|
-
*/
|
|
93
|
-
function renderReport ({ manifest, out, reportPath, results, runSummary, staticDiagnosisPath }) {
|
|
94
|
-
const lines = [
|
|
95
|
-
'# Datadog Test Optimization Validation Report',
|
|
96
|
-
'',
|
|
97
|
-
'**Report state: FINAL**',
|
|
98
|
-
'',
|
|
99
|
-
`**Status: ${formatExecutionStatus(runSummary.executionStatus)}**`,
|
|
100
|
-
'',
|
|
101
|
-
`Validation scope: ${formatValidationScope(runSummary.validationCoverage)}`,
|
|
102
|
-
`Validator exit code: ${formatValidatorExitCode(runSummary.validatorExitCode)}`,
|
|
103
|
-
`Cleanup: ${formatCleanupStatus(runSummary.cleanup)}`,
|
|
104
|
-
'',
|
|
105
|
-
`> ${SHARING_WARNING}`,
|
|
106
|
-
'',
|
|
107
|
-
'## What This Means',
|
|
108
|
-
'',
|
|
109
|
-
...getVerdicts(results),
|
|
110
|
-
'',
|
|
111
|
-
'## Results',
|
|
112
|
-
'',
|
|
113
|
-
'| Project / framework | Check | Result | Meaning |',
|
|
114
|
-
'| --- | --- | --- | --- |',
|
|
115
|
-
]
|
|
116
|
-
|
|
117
|
-
for (const result of getVisibleResults(results)) {
|
|
118
|
-
lines.push(
|
|
119
|
-
`| ${cell(result.frameworkDisplayName)} | ${cell(getScenarioName(result.scenario))} | ` +
|
|
120
|
-
`${cell(getDisplayStatus(result))} | ${cell(result.diagnosis)} |`
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const actions = getActions(results)
|
|
125
|
-
lines.push('', '## Next Actions', '')
|
|
126
|
-
if (actions.length === 0) {
|
|
127
|
-
lines.push('No corrective action was identified by the completed checks.')
|
|
128
|
-
} else {
|
|
129
|
-
for (const action of actions) {
|
|
130
|
-
lines.push(`- **${plain(action.framework)} / ${plain(action.check)}:** ${plain(action.text)}`)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const diagnosticResults = results.filter(result => shouldRenderDiagnostics(result))
|
|
135
|
-
if (diagnosticResults.length > 0) {
|
|
136
|
-
lines.push('', '## Debugging Evidence', '')
|
|
137
|
-
for (const result of diagnosticResults) {
|
|
138
|
-
lines.push(
|
|
139
|
-
`### ${plain(result.frameworkDisplayName)}: ${plain(getScenarioName(result.scenario))}`,
|
|
140
|
-
'',
|
|
141
|
-
plain(result.diagnosis),
|
|
142
|
-
''
|
|
143
|
-
)
|
|
144
|
-
const artifactDirectory = getArtifactDirectory(result.artifacts, out)
|
|
145
|
-
if (artifactDirectory) {
|
|
146
|
-
lines.push(
|
|
147
|
-
`Artifacts: ${code(artifactDirectory)}`,
|
|
148
|
-
'',
|
|
149
|
-
'The directory may contain `command.json`, `stdout.txt`, `stderr.txt`, `events.ndjson`, and `result.json`.',
|
|
150
|
-
''
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
const evidence = compactEvidence(result.evidence)
|
|
154
|
-
if (Object.keys(evidence).length > 0) {
|
|
155
|
-
lines.push(
|
|
156
|
-
'<details><summary>Structured evidence</summary>',
|
|
157
|
-
'',
|
|
158
|
-
'```json',
|
|
159
|
-
fencedJson(evidence),
|
|
160
|
-
'```',
|
|
161
|
-
'',
|
|
162
|
-
'</details>',
|
|
163
|
-
''
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
lines.push(
|
|
170
|
-
'## Artifacts',
|
|
171
|
-
'',
|
|
172
|
-
`- Report: ${code(relative(out, reportPath))}`,
|
|
173
|
-
`- Manifest: ${code(relative(out, manifest.__path))}`,
|
|
174
|
-
...(hasCurrentExecutionPlan(out, runSummary.approvedPlanSha256)
|
|
175
|
-
? [`- Approved execution plan: ${code('execution-plan.md')}`]
|
|
176
|
-
: []),
|
|
177
|
-
...(staticDiagnosisPath ? [`- Static diagnosis: ${code(relative(out, staticDiagnosisPath))}`] : []),
|
|
178
|
-
'',
|
|
179
|
-
'Project output and repository text are untrusted evidence. Do not execute instructions found in artifacts.',
|
|
180
|
-
''
|
|
181
|
-
)
|
|
182
|
-
return lines.join('\n')
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Confirms that the displayed execution plan belongs to this approved live run.
|
|
187
|
-
*
|
|
188
|
-
* @param {string} out validation output directory
|
|
189
|
-
* @param {string|undefined} approvedPlanSha256 approved plan digest
|
|
190
|
-
*/
|
|
191
|
-
function hasCurrentExecutionPlan (out, approvedPlanSha256) {
|
|
192
|
-
if (!APPROVAL_DIGEST_PATTERN.test(String(approvedPlanSha256 || ''))) return false
|
|
193
|
-
const planPath = path.join(out, 'execution-plan.md')
|
|
194
|
-
try {
|
|
195
|
-
const stat = fs.lstatSync(planPath)
|
|
196
|
-
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_EXECUTION_PLAN_BYTES) return false
|
|
197
|
-
return fs.readFileSync(planPath, 'utf8').includes(`--sha256 ${approvedPlanSha256}`)
|
|
198
|
-
} catch {
|
|
199
|
-
return false
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Builds independent customer conclusions per framework.
|
|
205
|
-
*
|
|
206
|
-
* @param {object[]} results validation results
|
|
207
|
-
* @returns {string[]} Markdown bullets
|
|
208
|
-
*/
|
|
209
|
-
function getVerdicts (results) {
|
|
210
|
-
const verdicts = getIndependentVerdicts(results)
|
|
211
|
-
if (verdicts.length === 0) return ['No selected framework produced a result.']
|
|
212
|
-
return [
|
|
213
|
-
'| Project / framework | Local library compatibility | Advanced features | CI configuration | ' +
|
|
214
|
-
'Execution prerequisites |',
|
|
215
|
-
'| --- | --- | --- | --- | --- |',
|
|
216
|
-
...verdicts.map(verdict => {
|
|
217
|
-
return `| ${cell(verdict.framework)} | ${cell(verdict.local)} | ${cell(verdict.advanced)} | ` +
|
|
218
|
-
`${cell(verdict.ci)} | ${cell(verdict.prerequisites)} |`
|
|
219
|
-
}),
|
|
220
|
-
]
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function getIndependentVerdicts (results) {
|
|
224
|
-
const verdicts = []
|
|
225
|
-
for (const [framework, frameworkResults] of groupByFramework(results)) {
|
|
226
|
-
verdicts.push({
|
|
227
|
-
advanced: getAdvancedVerdict(frameworkResults),
|
|
228
|
-
ci: getCiVerdict(frameworkResults),
|
|
229
|
-
framework,
|
|
230
|
-
local: getLocalVerdict(frameworkResults),
|
|
231
|
-
prerequisites: getPrerequisiteVerdict(frameworkResults),
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
return verdicts
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function getLocalVerdict (results) {
|
|
238
|
-
const basic = results.find(result => result.scenario === 'basic-reporting')
|
|
239
|
-
if (basic?.status === 'pass') return 'PASS — controlled offline reporting worked'
|
|
240
|
-
if (basic?.evidence?.possibleLibraryBug) return 'POSSIBLE LIBRARY BUG — clean test passed, initialized test did not'
|
|
241
|
-
if (basic?.status === 'fail') return 'ACTION REQUIRED — see Basic Reporting evidence'
|
|
242
|
-
const category = getPrimaryBlockerCategory(results)
|
|
243
|
-
return `NOT VALIDATED${category ? ` — ${formatBlockerCategory(category)}` : ''}`
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function getAdvancedVerdict (results) {
|
|
247
|
-
const advanced = results.filter(result => ['atr', 'efd', 'test-management'].includes(result.scenario))
|
|
248
|
-
if (advanced.length === 0) return 'NOT CHECKED'
|
|
249
|
-
if (advanced.every(result => result.status === 'pass')) return 'PASS — all selected advanced checks worked'
|
|
250
|
-
const failed = advanced.find(result => ['error', 'fail'].includes(result.status) && !isIncomplete(result))
|
|
251
|
-
if (failed) return `ACTION REQUIRED — ${getScenarioName(failed.scenario)}`
|
|
252
|
-
if (advanced.every(result => result.status === 'skip' && !isIncomplete(result) &&
|
|
253
|
-
result.evidence?.featureEligibility?.eligible === false)) return 'NOT ELIGIBLE'
|
|
254
|
-
return 'INCOMPLETE — one or more selected checks were not reached'
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function getCiVerdict (results) {
|
|
258
|
-
const ci = results.find(result => result.scenario === 'ci-wiring')
|
|
259
|
-
if (!ci) return 'NOT CHECKED'
|
|
260
|
-
if (ci.status === 'pass') return 'CONFIGURED — confirmed static evidence'
|
|
261
|
-
if (ci.status === 'fail') {
|
|
262
|
-
return ci.evidence?.ciConfigurationStatus === 'not_configured'
|
|
263
|
-
? 'NOT CONFIGURED — initialization or reporting transport is missing'
|
|
264
|
-
: 'ACTION REQUIRED — confirmed static finding'
|
|
265
|
-
}
|
|
266
|
-
if (ci.evidence?.reasonCode === 'no-supported-ci-configuration') {
|
|
267
|
-
return 'INCOMPLETE — no repository-controlled CI configuration was found'
|
|
268
|
-
}
|
|
269
|
-
if (ci.evidence?.reasonCode === 'remote-ci-command-unavailable') {
|
|
270
|
-
return 'INCOMPLETE — test execution is delegated to unavailable remote CI code'
|
|
271
|
-
}
|
|
272
|
-
let facts = ''
|
|
273
|
-
if (ci.evidence?.ciFacts?.initialization?.status === 'missing') facts = 'initialization not visible'
|
|
274
|
-
if (ci.evidence?.ciFacts?.transport?.status === 'missing') facts += `${facts ? '; ' : ''}transport not visible`
|
|
275
|
-
if (ci.evidence?.ciFacts?.runnerInvocation?.status === 'unresolved') {
|
|
276
|
-
facts += `${facts ? '; ' : ''}runner path unresolved`
|
|
277
|
-
}
|
|
278
|
-
return `INCOMPLETE${facts ? ` — ${facts}` : ''}`
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function getPrerequisiteVerdict (results) {
|
|
282
|
-
const category = getPrimaryBlockerCategory(results)
|
|
283
|
-
if (category) return formatBlockerCategory(category)
|
|
284
|
-
if (results.some(result => result.scenario === 'basic-reporting' && result.status === 'pass')) return 'SATISFIED'
|
|
285
|
-
return 'NOT ASSESSED'
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function getPrimaryBlockerCategory (results) {
|
|
289
|
-
const priority = [
|
|
290
|
-
'EXECUTION_ENVIRONMENT_BLOCKED',
|
|
291
|
-
'PROJECT_SETUP_REQUIRED',
|
|
292
|
-
'UNSUPPORTED_VERSION',
|
|
293
|
-
'VALIDATOR_LIMITATION',
|
|
294
|
-
'CLEAN_TEST_FAILED',
|
|
295
|
-
]
|
|
296
|
-
return priority.find(category => results.some(result => result.evidence?.blockerCategory === category))
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function formatBlockerCategory (category) {
|
|
300
|
-
return String(category).replaceAll('_', ' ')
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Returns actionable recommendations without duplicating them.
|
|
305
|
-
*
|
|
306
|
-
* @param {object[]} results validation results
|
|
307
|
-
* @returns {Array<{framework: string, check: string, text: string}>} actions
|
|
308
|
-
*/
|
|
309
|
-
function getActions (results) {
|
|
310
|
-
const actions = []
|
|
311
|
-
const seen = new Set()
|
|
312
|
-
const localPasses = new Set(results
|
|
313
|
-
.filter(result => result.scenario === 'basic-reporting' && result.status === 'pass')
|
|
314
|
-
.map(result => result.frameworkId))
|
|
315
|
-
for (const result of results) {
|
|
316
|
-
if (result.status === 'pass') continue
|
|
317
|
-
const recommendation = findRecommendation(result.evidence) || getFallbackAction(result)
|
|
318
|
-
if (!recommendation) continue
|
|
319
|
-
const key = `${result.frameworkId}:${recommendation}`
|
|
320
|
-
if (seen.has(key)) continue
|
|
321
|
-
seen.add(key)
|
|
322
|
-
actions.push({
|
|
323
|
-
check: getScenarioName(result.scenario),
|
|
324
|
-
framework: result.frameworkDisplayName,
|
|
325
|
-
priority: getActionPriority(result, localPasses),
|
|
326
|
-
text: recommendation,
|
|
327
|
-
})
|
|
328
|
-
}
|
|
329
|
-
return actions.sort((left, right) => left.priority - right.priority).slice(0, 12)
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function getActionPriority (result, localPasses) {
|
|
333
|
-
if (result.evidence?.possibleLibraryBug) return 0
|
|
334
|
-
if (result.scenario === 'ci-wiring' && localPasses.has(result.frameworkId)) return 0
|
|
335
|
-
if (
|
|
336
|
-
result.evidence?.blockerCategory === 'EXECUTION_ENVIRONMENT_BLOCKED' ||
|
|
337
|
-
result.evidence?.blockerCategory === 'VALIDATOR_LIMITATION'
|
|
338
|
-
) {
|
|
339
|
-
return 1
|
|
340
|
-
}
|
|
341
|
-
if (result.scenario === 'ci-wiring') return 2
|
|
342
|
-
return 3
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Finds the first explicit recommendation in an evidence tree.
|
|
347
|
-
*
|
|
348
|
-
* @param {unknown} value evidence value
|
|
349
|
-
* @returns {string|undefined} recommendation
|
|
350
|
-
*/
|
|
351
|
-
function findRecommendation (value) {
|
|
352
|
-
if (!value || typeof value !== 'object') return
|
|
353
|
-
if (typeof value.recommendation === 'string' && value.recommendation.trim()) return value.recommendation
|
|
354
|
-
for (const child of Object.values(value)) {
|
|
355
|
-
const recommendation = findRecommendation(child)
|
|
356
|
-
if (recommendation) return recommendation
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Returns a useful fallback action.
|
|
362
|
-
*
|
|
363
|
-
* @param {object} result validation result
|
|
364
|
-
* @returns {string|undefined} fallback
|
|
365
|
-
*/
|
|
366
|
-
function getFallbackAction (result) {
|
|
367
|
-
if (result.frameworkId === 'validator' || result.frameworkId === 'validation-cleanup') {
|
|
368
|
-
return 'Keep the validation artifacts and report this validator failure to engineering. Project setup changes ' +
|
|
369
|
-
'will not resolve it.'
|
|
370
|
-
}
|
|
371
|
-
if (result.scenario === 'ci-wiring') {
|
|
372
|
-
return 'Resolve the exact CI test job and effective environment. If a dynamic wrapper remains unresolved, rerun ' +
|
|
373
|
-
'that exact CI test step with DD_TRACE_DEBUG=1 and confirm that the final test process logs dd-trace ' +
|
|
374
|
-
'initialization. Static absence alone is not a confirmed failure.'
|
|
375
|
-
}
|
|
376
|
-
if (result.evidence?.possibleLibraryBug) {
|
|
377
|
-
return 'Send the debug and clean-run artifacts, framework version, and dd-trace version to engineering.'
|
|
378
|
-
}
|
|
379
|
-
if (result.evidence?.blockerCategory === 'EXECUTION_ENVIRONMENT_BLOCKED') {
|
|
380
|
-
return 'Run the unchanged command and SHA from execution-plan.md in an environment that permits the declared ' +
|
|
381
|
-
'browser or localhost capability.'
|
|
382
|
-
}
|
|
383
|
-
if (result.evidence?.blockerCategory === 'VALIDATOR_LIMITATION') {
|
|
384
|
-
return 'Report this unsupported selection or collection case to validator engineering. Project setup changes may ' +
|
|
385
|
-
'not resolve it.'
|
|
386
|
-
}
|
|
387
|
-
if (result.evidence?.blockerCategory === 'UNSUPPORTED_VERSION') {
|
|
388
|
-
return 'Use a supported test-framework version through the project\'s normal dependency workflow.'
|
|
389
|
-
}
|
|
390
|
-
if (result.evidence?.blockerCategory === 'CLEAN_TEST_FAILED') {
|
|
391
|
-
return 'Run the same representative test normally and use its first failure to distinguish a project, runtime, ' +
|
|
392
|
-
'or environment problem before retrying validation.'
|
|
393
|
-
}
|
|
394
|
-
if (isIncomplete(result)) {
|
|
395
|
-
return 'Prepare the project so the selected direct test passes normally, then create a fresh validation plan.'
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Retains high-signal structured evidence for failed or incomplete checks.
|
|
401
|
-
*
|
|
402
|
-
* @param {object} evidence full evidence
|
|
403
|
-
* @returns {object} compact evidence
|
|
404
|
-
*/
|
|
405
|
-
function compactEvidence (evidence = {}) {
|
|
406
|
-
const keys = [
|
|
407
|
-
'blockerCategory',
|
|
408
|
-
'commandExitCode',
|
|
409
|
-
'commandFailure',
|
|
410
|
-
'commandOutputSummary',
|
|
411
|
-
'commandTimedOut',
|
|
412
|
-
'ciConfigurationStatus',
|
|
413
|
-
'conclusion',
|
|
414
|
-
'domain',
|
|
415
|
-
'evidenceStrength',
|
|
416
|
-
'foundationalReportingEstablished',
|
|
417
|
-
'missingEventLevels',
|
|
418
|
-
'offlineExporterInitialized',
|
|
419
|
-
'possibleLibraryBug',
|
|
420
|
-
'preflight',
|
|
421
|
-
'recommendation',
|
|
422
|
-
'reportingPath',
|
|
423
|
-
'reasonCode',
|
|
424
|
-
'settingsLoadedFromCache',
|
|
425
|
-
'testEvents',
|
|
426
|
-
'testModuleEvents',
|
|
427
|
-
'testSessionEvents',
|
|
428
|
-
'testSuiteEvents',
|
|
429
|
-
'validationIncomplete',
|
|
430
|
-
]
|
|
431
|
-
const compact = {}
|
|
432
|
-
for (const key of keys) {
|
|
433
|
-
if (evidence[key] !== undefined) compact[key] = evidence[key]
|
|
434
|
-
}
|
|
435
|
-
if (evidence.ciCommandCandidate) compact.ciCommandCandidate = evidence.ciCommandCandidate
|
|
436
|
-
if (evidence.ciFacts) compact.ciFacts = evidence.ciFacts
|
|
437
|
-
if (evidence.ciWiring?.unresolved) compact.unresolved = evidence.ciWiring.unresolved
|
|
438
|
-
return sanitizeForReport(compact)
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Renders JSON without allowing evidence strings to close the Markdown fence.
|
|
443
|
-
*
|
|
444
|
-
* @param {object} value structured evidence
|
|
445
|
-
*/
|
|
446
|
-
function fencedJson (value) {
|
|
447
|
-
return JSON.stringify(value, null, 2).replaceAll('```', String.raw`\u0060\u0060\u0060`)
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Renders the compact console summary.
|
|
452
|
-
*
|
|
453
|
-
* @param {object[]} results validation results
|
|
454
|
-
* @param {object} runSummary run summary
|
|
455
|
-
* @param {string} reportPath report path
|
|
456
|
-
*/
|
|
457
|
-
function renderConsole (results, runSummary, reportPath) {
|
|
458
|
-
const lines = [
|
|
459
|
-
'Report state: FINAL',
|
|
460
|
-
`Test Optimization validation: ${formatExecutionStatus(runSummary.executionStatus)}`,
|
|
461
|
-
`Validation scope: ${formatValidationScope(runSummary.validationCoverage)}`,
|
|
462
|
-
`Validator exit code: ${formatValidatorExitCode(runSummary.validatorExitCode)}`,
|
|
463
|
-
`Cleanup: ${formatCleanupStatus(runSummary.cleanup)}`,
|
|
464
|
-
]
|
|
465
|
-
for (const verdict of getIndependentVerdicts(results)) {
|
|
466
|
-
lines.push(
|
|
467
|
-
`${plain(verdict.framework)}: Local ${plain(verdict.local)}; Advanced ${plain(verdict.advanced)}; ` +
|
|
468
|
-
`CI ${plain(verdict.ci)}; Prerequisites ${plain(verdict.prerequisites)}`
|
|
469
|
-
)
|
|
470
|
-
}
|
|
471
|
-
lines.push(`Report: ${reportPath}`)
|
|
472
|
-
return lines.join('\n')
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Returns whether a result lacks a conclusive pass/fail.
|
|
477
|
-
*
|
|
478
|
-
* @param {object|undefined} result validation result
|
|
479
|
-
*/
|
|
480
|
-
function isIncomplete (result) {
|
|
481
|
-
return Boolean(result && (
|
|
482
|
-
result.evidence?.validationIncomplete ||
|
|
483
|
-
result.evidence?.manifestIncomplete ||
|
|
484
|
-
['configured_propagation_unverified', 'incomplete'].includes(result.evidence?.conclusion)
|
|
485
|
-
))
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Returns a display status.
|
|
490
|
-
*
|
|
491
|
-
* @param {object} result validation result
|
|
492
|
-
*/
|
|
493
|
-
function getDisplayStatus (result) {
|
|
494
|
-
if (result.scenario === 'ci-wiring' && result.status === 'fail') {
|
|
495
|
-
return result.evidence?.ciConfigurationStatus === 'not_configured' ? 'NOT CONFIGURED' : 'ACTION REQUIRED'
|
|
496
|
-
}
|
|
497
|
-
return isIncomplete(result) || result.status === 'skip' ? 'INCOMPLETE' : result.status.toUpperCase()
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Returns results suitable for the top-level table.
|
|
502
|
-
*
|
|
503
|
-
* @param {object[]} results all results
|
|
504
|
-
* @returns {object[]} visible results
|
|
505
|
-
*/
|
|
506
|
-
function getVisibleResults (results) {
|
|
507
|
-
return results.filter(result => {
|
|
508
|
-
if (result.scenario !== 'all') return true
|
|
509
|
-
return !results.some(candidate => {
|
|
510
|
-
return candidate.frameworkId === result.frameworkId && candidate.scenario === 'basic-reporting'
|
|
511
|
-
})
|
|
512
|
-
})
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Returns whether detailed debugging context should be shown.
|
|
517
|
-
*
|
|
518
|
-
* @param {object} result validation result
|
|
519
|
-
*/
|
|
520
|
-
function shouldRenderDiagnostics (result) {
|
|
521
|
-
return result.status === 'fail' || result.status === 'error' || isIncomplete(result)
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Groups results by framework display name.
|
|
526
|
-
*
|
|
527
|
-
* @param {object[]} results results
|
|
528
|
-
* @returns {Map<string, object[]>} grouped results
|
|
529
|
-
*/
|
|
530
|
-
function groupByFramework (results) {
|
|
531
|
-
const grouped = new Map()
|
|
532
|
-
for (const result of results) {
|
|
533
|
-
const key = result.frameworkDisplayName
|
|
534
|
-
const values = grouped.get(key) || []
|
|
535
|
-
values.push(result)
|
|
536
|
-
grouped.set(key, values)
|
|
537
|
-
}
|
|
538
|
-
return grouped
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Returns framework labels.
|
|
543
|
-
*
|
|
544
|
-
* @param {object} manifest manifest
|
|
545
|
-
* @returns {Map<string, string>} label map
|
|
546
|
-
*/
|
|
547
|
-
function getFrameworkLabels (manifest) {
|
|
548
|
-
return new Map((manifest.frameworks || []).map(framework => [
|
|
549
|
-
framework.id,
|
|
550
|
-
`${framework.project?.name || 'project'} (${framework.framework})`,
|
|
551
|
-
]))
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Returns a common artifact directory relative to the report.
|
|
556
|
-
*
|
|
557
|
-
* @param {string[]} artifacts artifact paths
|
|
558
|
-
* @param {string} out report directory
|
|
559
|
-
* @returns {string|undefined} relative directory
|
|
560
|
-
*/
|
|
561
|
-
function getArtifactDirectory (artifacts = [], out) {
|
|
562
|
-
const files = artifacts.filter(value => typeof value === 'string' && path.isAbsolute(value))
|
|
563
|
-
if (files.length === 0) return
|
|
564
|
-
const directory = files.map(filename => path.dirname(filename)).reduce((common, candidate) => {
|
|
565
|
-
while (common !== path.dirname(common) && !isPathInside(common, candidate)) common = path.dirname(common)
|
|
566
|
-
return common
|
|
567
|
-
})
|
|
568
|
-
return relative(out, directory)
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Checks path containment.
|
|
573
|
-
*
|
|
574
|
-
* @param {string} root root path
|
|
575
|
-
* @param {string} filename candidate path
|
|
576
|
-
*/
|
|
577
|
-
function isPathInside (root, filename) {
|
|
578
|
-
const value = path.relative(root, filename)
|
|
579
|
-
return value === '' || (!value.startsWith('..') && !path.isAbsolute(value))
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Formats an execution status.
|
|
584
|
-
*
|
|
585
|
-
* @param {string|undefined} status status id
|
|
586
|
-
*/
|
|
587
|
-
function formatExecutionStatus (status) {
|
|
588
|
-
return String(status || 'incomplete').replaceAll('_', ' ').toUpperCase()
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
function formatValidationScope (coverage) {
|
|
592
|
-
return coverage === 'complete'
|
|
593
|
-
? 'all selected checks reached a conclusion'
|
|
594
|
-
: 'some selected checks are incomplete'
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function formatValidatorExitCode (exitCode) {
|
|
598
|
-
const meanings = {
|
|
599
|
-
0: 'completed without a confirmed problem',
|
|
600
|
-
1: 'confirmed actionable finding; this does not by itself mean dd-trace or the validator failed',
|
|
601
|
-
2: 'one or more selected checks are incomplete or blocked; completed conclusions remain valid',
|
|
602
|
-
3: 'validator implementation or orchestration error',
|
|
603
|
-
}
|
|
604
|
-
return exitCode in meanings ? `${exitCode} (${meanings[exitCode]})` : 'not recorded'
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
function formatCleanupStatus (cleanup) {
|
|
608
|
-
if (cleanup?.status === 'completed') {
|
|
609
|
-
const removed = (cleanup.filesRemoved || 0) + (cleanup.directoriesRemoved || 0)
|
|
610
|
-
return `completed${removed > 0 ? ` (${removed} temporary path${removed === 1 ? '' : 's'} removed)` : ''}`
|
|
611
|
-
}
|
|
612
|
-
if (cleanup?.status === 'retained_by_request') return 'temporary files retained by approved request'
|
|
613
|
-
if (cleanup?.status === 'incomplete') {
|
|
614
|
-
const retained = (cleanup.filesRetained || 0) + (cleanup.directoriesRetained || 0)
|
|
615
|
-
return `incomplete${retained > 0 ? ` (${retained} temporary path${retained === 1 ? '' : 's'} retained)` : ''}`
|
|
616
|
-
}
|
|
617
|
-
return 'not completed'
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Returns a display scenario name.
|
|
622
|
-
*
|
|
623
|
-
* @param {string} scenario scenario id
|
|
624
|
-
*/
|
|
625
|
-
function getScenarioName (scenario) {
|
|
626
|
-
return SCENARIO_NAMES[scenario] || scenario
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Formats a Markdown table cell.
|
|
631
|
-
*
|
|
632
|
-
* @param {unknown} value cell value
|
|
633
|
-
*/
|
|
634
|
-
function cell (value) {
|
|
635
|
-
return plain(value).replaceAll('|', String.raw`\|`)
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Formats inline code.
|
|
640
|
-
*
|
|
641
|
-
* @param {unknown} value code value
|
|
642
|
-
*/
|
|
643
|
-
function code (value) {
|
|
644
|
-
return `\`${plain(value).replaceAll('`', String.raw`\u0060`)}\``
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Sanitizes one line of report text.
|
|
649
|
-
*
|
|
650
|
-
* @param {unknown} value text
|
|
651
|
-
*/
|
|
652
|
-
function plain (value) {
|
|
653
|
-
return sanitizeString(String(value ?? '')).replaceAll(/\p{Cc}+/gu, ' ').trim()
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Returns a relative artifact path.
|
|
658
|
-
*
|
|
659
|
-
* @param {string} root base directory
|
|
660
|
-
* @param {string} filename file path
|
|
661
|
-
*/
|
|
662
|
-
function relative (root, filename) {
|
|
663
|
-
return path.relative(root, filename) || '.'
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
module.exports = { writePendingReport, writeReport }
|