dd-trace 6.24.0 → 6.26.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/README.md +3 -0
- package/ci/cypress/support.js +2 -1
- package/ci/init.js +2 -22
- package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-setup.mjs +729 -724
- package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/package.json +41 -36
- package/packages/datadog-esbuild/index.js +16 -70
- package/packages/datadog-esbuild/src/log.js +2 -29
- package/packages/datadog-instrumentations/src/ai.js +6 -1
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
- 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-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
- 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 +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -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/modelcontextprotocol-client.js +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
- 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/microgateway-core.js +1 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
- package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
- package/packages/datadog-instrumentations/src/next.js +203 -26
- 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/router.js +35 -12
- package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
- 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/arn.js +41 -0
- package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
- package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +34 -10
- package/packages/datadog-plugin-http2/src/client.js +40 -14
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
- package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-postgres/src/index.js +118 -41
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
- 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-plugin-vitest/src/index.js +3 -2
- package/packages/datadog-plugin-ws/src/close.js +3 -5
- package/packages/datadog-plugin-ws/src/producer.js +1 -4
- package/packages/datadog-plugin-ws/src/receiver.js +3 -5
- package/packages/datadog-plugin-ws/src/server.js +44 -13
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-vite/index.js +537 -0
- package/packages/datadog-vite/src/log.js +5 -0
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/datadog-webpack/src/log.js +2 -29
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
- 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 +21 -1
- package/packages/dd-trace/src/appsec/channels.js +7 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
- package/packages/dd-trace/src/appsec/graphql.js +89 -7
- package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
- package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
- package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
- package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
- package/packages/dd-trace/src/appsec/index.js +6 -0
- package/packages/dd-trace/src/appsec/lambda.js +17 -17
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
- package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
- package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
- package/packages/dd-trace/src/appsec/recommended.json +1358 -94
- package/packages/dd-trace/src/appsec/reporter.js +9 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
- package/packages/dd-trace/src/appsec/waf/index.js +65 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
- 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 +46 -4
- package/packages/dd-trace/src/config/index.js +63 -31
- package/packages/dd-trace/src/config/parsers.js +44 -0
- package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
- package/packages/dd-trace/src/config/remote_config.js +2 -1
- package/packages/dd-trace/src/config/supported-configurations.json +172 -10
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/datastreams/fnv.js +27 -0
- package/packages/dd-trace/src/datastreams/pathway.js +113 -28
- package/packages/dd-trace/src/datastreams/processor.js +5 -4
- package/packages/dd-trace/src/debugger/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
- package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
- 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/git_metadata.js +2 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +6 -3
- package/packages/dd-trace/src/lambda/facade.js +75 -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/modelcontextprotocol-sdk/index.js +54 -3
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
- 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 +7 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +55 -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 +143 -17
- package/packages/dd-trace/src/plugins/index.js +8 -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 +52 -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 +80 -56
- 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 +92 -40
- package/packages/dd-trace/src/plugins/util/url.js +18 -7
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiler.js +74 -12
- package/packages/dd-trace/src/profiling/profiler.js +30 -2
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/profiling/remote-config.js +354 -0
- package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/propagation-hash/index.js +7 -0
- package/packages/dd-trace/src/proxy.js +46 -54
- 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 +220 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -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/vite.d.ts +7 -0
- package/vite.js +3 -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/datadog-esbuild/src/utils.js +0 -318
- package/packages/datadog-plugin-cypress/src/support.js +0 -1348
- 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,541 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const crypto = require('node:crypto')
|
|
4
|
-
const path = require('node:path')
|
|
5
|
-
|
|
6
|
-
const { VERSION } = require('../../version')
|
|
7
|
-
const { getRequiredCapabilities } = require('./approval')
|
|
8
|
-
const { writeApprovalArtifacts } = require('./approval-artifacts')
|
|
9
|
-
const { serializeApprovalCommand } = require('./command-runner')
|
|
10
|
-
const { getUnavailableExecutable } = require('./executable')
|
|
11
|
-
const { sanitizeString } = require('./redaction')
|
|
12
|
-
const {
|
|
13
|
-
getBasicCommand,
|
|
14
|
-
getGeneratedCommand,
|
|
15
|
-
} = require('./runner-command')
|
|
16
|
-
const { writeFileSafely } = require('./safe-files')
|
|
17
|
-
|
|
18
|
-
const VALIDATOR_PATH = path.resolve(__dirname, '..', 'validate-test-optimization.js')
|
|
19
|
-
const EXECUTION_PLAN_FILENAME = 'execution-plan.md'
|
|
20
|
-
const SCENARIO_TO_GENERATED_ID = {
|
|
21
|
-
atr: 'atr-fail-once',
|
|
22
|
-
efd: 'basic-pass',
|
|
23
|
-
'test-management': 'test-management-target',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Produces the deterministic execution plan shown before live validation.
|
|
28
|
-
*
|
|
29
|
-
* @param {object} input plan inputs
|
|
30
|
-
*/
|
|
31
|
-
function formatExecutionPlan (input) {
|
|
32
|
-
return formatExecutionPlanArtifacts(input).plan
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Writes approval artifacts and the customer-visible plan without running project code.
|
|
37
|
-
*
|
|
38
|
-
* @param {object} input plan inputs
|
|
39
|
-
* @param {object} input.manifest normalized manifest
|
|
40
|
-
* @param {string} input.out output directory
|
|
41
|
-
* @param {string[]} [input.selectedFrameworkIds] selected framework ids
|
|
42
|
-
* @param {string|null} [input.requestedScenario] selected scenario
|
|
43
|
-
* @param {boolean} [input.keepTempFiles] retain temporary files
|
|
44
|
-
* @param {object} [input.packageCheck] installed package-load result
|
|
45
|
-
* @param {Map<string, object>} [input.ciPreflightResults] static CI results by framework
|
|
46
|
-
* @param {Array<{path: string, sha256: string}>} [input.expectedProjectFiles] preflight project snapshot
|
|
47
|
-
* @param {boolean} [input.verbose] print progress
|
|
48
|
-
* @returns {{plan: string}} written plan
|
|
49
|
-
*/
|
|
50
|
-
function formatExecutionPlanArtifacts ({
|
|
51
|
-
manifest,
|
|
52
|
-
out,
|
|
53
|
-
selectedFrameworkIds = [],
|
|
54
|
-
requestedScenario = null,
|
|
55
|
-
keepTempFiles = false,
|
|
56
|
-
packageCheck,
|
|
57
|
-
ciPreflightResults = new Map(),
|
|
58
|
-
expectedProjectFiles,
|
|
59
|
-
verbose = false,
|
|
60
|
-
}) {
|
|
61
|
-
const offlineFixtureNonce = crypto.randomBytes(16).toString('hex')
|
|
62
|
-
const approvalArtifacts = writeApprovalArtifacts({
|
|
63
|
-
manifest,
|
|
64
|
-
out,
|
|
65
|
-
selectedFrameworkIds,
|
|
66
|
-
requestedScenario,
|
|
67
|
-
offlineFixtureNonce,
|
|
68
|
-
keepTempFiles,
|
|
69
|
-
verbose,
|
|
70
|
-
expectedProjectFiles,
|
|
71
|
-
})
|
|
72
|
-
const validatorArgv = [
|
|
73
|
-
process.execPath,
|
|
74
|
-
VALIDATOR_PATH,
|
|
75
|
-
'--run-approved-plan',
|
|
76
|
-
approvalArtifacts.approvalJsonPath,
|
|
77
|
-
'--sha256',
|
|
78
|
-
approvalArtifacts.digest,
|
|
79
|
-
]
|
|
80
|
-
const plan = formatApprovalPlan({
|
|
81
|
-
approvalArtifacts,
|
|
82
|
-
ciPreflightResults,
|
|
83
|
-
manifest,
|
|
84
|
-
out,
|
|
85
|
-
keepTempFiles,
|
|
86
|
-
packageCheck,
|
|
87
|
-
requestedScenario,
|
|
88
|
-
validatorArgv,
|
|
89
|
-
})
|
|
90
|
-
writeFileSafely(out, getExecutionPlanPath(out), `${plan}\n`, 'validation execution plan')
|
|
91
|
-
return { plan }
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Formats the complete bounded approval plan.
|
|
96
|
-
*
|
|
97
|
-
* @param {object} input formatting inputs
|
|
98
|
-
* @param {object} input.approvalArtifacts approval artifact paths and digest
|
|
99
|
-
* @param {Map<string, object>} input.ciPreflightResults static CI results by framework
|
|
100
|
-
* @param {object} input.manifest normalized manifest
|
|
101
|
-
* @param {string} input.out output directory
|
|
102
|
-
* @param {boolean} input.keepTempFiles retain temporary files
|
|
103
|
-
* @param {object|undefined} input.packageCheck installed package-load result
|
|
104
|
-
* @param {string|null} input.requestedScenario selected scenario
|
|
105
|
-
* @param {string[]} input.validatorArgv exact validator command
|
|
106
|
-
*/
|
|
107
|
-
function formatApprovalPlan ({
|
|
108
|
-
approvalArtifacts,
|
|
109
|
-
ciPreflightResults,
|
|
110
|
-
manifest,
|
|
111
|
-
out,
|
|
112
|
-
keepTempFiles,
|
|
113
|
-
packageCheck,
|
|
114
|
-
requestedScenario,
|
|
115
|
-
validatorArgv,
|
|
116
|
-
}) {
|
|
117
|
-
const root = manifest.repository.root
|
|
118
|
-
const runnableFrameworks = manifest.frameworks.filter(framework => framework.status === 'runnable')
|
|
119
|
-
const requiredCapabilities = getRequiredCapabilities({
|
|
120
|
-
manifest,
|
|
121
|
-
requestedScenario,
|
|
122
|
-
})
|
|
123
|
-
const buildPrerequisites = runnableFrameworks.filter(framework => {
|
|
124
|
-
return framework.buildArtifactRequired === true ||
|
|
125
|
-
(framework.validation?.fallbackTests || []).some(fallback => fallback.buildArtifactRequired === true)
|
|
126
|
-
}).length
|
|
127
|
-
const lines = [
|
|
128
|
-
'# Test Optimization Validation Plan',
|
|
129
|
-
'',
|
|
130
|
-
`Repository: ${inline(root)}`,
|
|
131
|
-
`Validator: ${inline(`dd-trace ${VERSION}`)}`,
|
|
132
|
-
`Results: ${inline(relative(root, out))}`,
|
|
133
|
-
...(packageCheck?.ok
|
|
134
|
-
? [`Installed package check: ${plain(packageCheck.diagnosis)}`]
|
|
135
|
-
: []),
|
|
136
|
-
'',
|
|
137
|
-
'## Approval Summary',
|
|
138
|
-
'',
|
|
139
|
-
requestedScenario === 'ci-wiring'
|
|
140
|
-
? 'Local execution: none; this plan performs static CI analysis only.'
|
|
141
|
-
: `Local execution: ${runnableFrameworks.length} framework target${
|
|
142
|
-
runnableFrameworks.length === 1 ? '' : 's'
|
|
143
|
-
} eligible; ${manifest.frameworks.length - runnableFrameworks.length} setup or static-only.`,
|
|
144
|
-
`Required host capabilities: ${
|
|
145
|
-
requiredCapabilities.length > 0 ? requiredCapabilities.map(formatCapability).join(', ') : 'none declared'
|
|
146
|
-
}.`,
|
|
147
|
-
`Build prerequisites: ${
|
|
148
|
-
buildPrerequisites > 0
|
|
149
|
-
? `${buildPrerequisites} eligible framework target${
|
|
150
|
-
buildPrerequisites === 1 ? '' : 's'
|
|
151
|
-
} may require the project's normal build`
|
|
152
|
-
: 'none detected statically'
|
|
153
|
-
}.`,
|
|
154
|
-
`Mutable paths: ${inline(relative(root, out))} and the temporary files disclosed below; temporary files ${
|
|
155
|
-
keepTempFiles ? 'will be retained by request' : 'will be removed after validation'
|
|
156
|
-
}.`,
|
|
157
|
-
'CI replay: none. CI configuration is inspected statically and CI commands are never executed.',
|
|
158
|
-
'Approval: one checksum-bound validator command, shown once at the end of this plan.',
|
|
159
|
-
'',
|
|
160
|
-
'The validator will run only the displayed `node <repository-contained-runner> <one-test-file>` commands. The ' +
|
|
161
|
-
'runner may be an exact repository-owned Node test wrapper. The validator itself will not directly invoke ' +
|
|
162
|
-
'package managers, shells, setup commands, or CI commands; approved repository code may start subprocesses.',
|
|
163
|
-
'',
|
|
164
|
-
'## Checks',
|
|
165
|
-
'',
|
|
166
|
-
]
|
|
167
|
-
|
|
168
|
-
for (const framework of manifest.frameworks) {
|
|
169
|
-
lines.push(`### ${plain(getFrameworkLabel(framework, root))}`, '')
|
|
170
|
-
if (framework.status !== 'runnable') {
|
|
171
|
-
lines.push(
|
|
172
|
-
`Status: ${plain(formatStatus(framework.status))}.`,
|
|
173
|
-
...(framework.blockerCategory
|
|
174
|
-
? [`Blocker: ${plain(framework.blockerCategory.replaceAll('_', ' '))}.`]
|
|
175
|
-
: [])
|
|
176
|
-
)
|
|
177
|
-
if (framework.notes) {
|
|
178
|
-
for (const note of framework.notes) lines.push(`- ${plain(note)}`)
|
|
179
|
-
}
|
|
180
|
-
lines.push('')
|
|
181
|
-
continue
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (requestedScenario === 'ci-wiring') {
|
|
185
|
-
lines.push('Status: static CI audit only; no project test command is selected.', '')
|
|
186
|
-
} else {
|
|
187
|
-
const basic = getBasicCommand(framework)
|
|
188
|
-
const fallbackTests = framework.validation.fallbackTests || []
|
|
189
|
-
const unavailable = getUnavailableExecutable(basic)
|
|
190
|
-
const status = unavailable
|
|
191
|
-
? `local validation will be incomplete because ${inline(unavailable)} is unavailable`
|
|
192
|
-
: 'eligible for approved clean preflight; runtime prerequisites are unverified'
|
|
193
|
-
lines.push(
|
|
194
|
-
`Status: ${status}.`,
|
|
195
|
-
`Representative test: ${inline(relative(root, framework.validation.testFile))}${formatCandidateRequirements({
|
|
196
|
-
buildArtifactRequired: framework.buildArtifactRequired,
|
|
197
|
-
localSocketRequired: framework.localSocketRequired,
|
|
198
|
-
})}`,
|
|
199
|
-
...(fallbackTests.length > 0
|
|
200
|
-
? [
|
|
201
|
-
'Fallback tests, tried in order only if the representative does not pass cleanly:',
|
|
202
|
-
...fallbackTests.map(fallback => {
|
|
203
|
-
return `- ${inline(relative(root, fallback.testFile))}${formatCandidateRequirements(fallback)}`
|
|
204
|
-
}),
|
|
205
|
-
]
|
|
206
|
-
: []),
|
|
207
|
-
`Working directory: ${inline(relative(root, basic.cwd))}`,
|
|
208
|
-
`Timeout: ${basic.timeoutMs} ms`,
|
|
209
|
-
...(Object.keys(basic.env || {}).length > 0
|
|
210
|
-
? [`Runner environment: ${inline(JSON.stringify(basic.env))}`]
|
|
211
|
-
: []),
|
|
212
|
-
...formatOmittedRunnerOptions(framework.validation.omittedRunnerOptions),
|
|
213
|
-
'',
|
|
214
|
-
...(framework.browserRequired
|
|
215
|
-
? [
|
|
216
|
-
'Browser permission: this approved validation command launches the project browser through its ' +
|
|
217
|
-
'selected test runner. If the agent platform blocks browser processes, request its narrow permission ' +
|
|
218
|
-
'for the exact checksum-bound validator command below; do not change or broaden the command. ' +
|
|
219
|
-
'Complete ' +
|
|
220
|
-
'the project\'s normal browser installation, application startup, and build first when the selected ' +
|
|
221
|
-
'test depends on them.',
|
|
222
|
-
'',
|
|
223
|
-
]
|
|
224
|
-
: []),
|
|
225
|
-
...(framework.localSocketRequired
|
|
226
|
-
? [
|
|
227
|
-
`Localhost prerequisite: ${
|
|
228
|
-
framework.allCandidatesRequireLocalSocket
|
|
229
|
-
? 'every approved candidate appears'
|
|
230
|
-
: 'the selected test appears'
|
|
231
|
-
} to open or contact a local listener. A restricted execution environment may require narrow ` +
|
|
232
|
-
'permission for the exact validator command.',
|
|
233
|
-
'',
|
|
234
|
-
]
|
|
235
|
-
: []),
|
|
236
|
-
...(framework.buildArtifactRequired
|
|
237
|
-
? [
|
|
238
|
-
'Build prerequisite: the selected test appears to load a build or dist artifact. Complete the ' +
|
|
239
|
-
'project\'s normal build before validation if that artifact is not already present.',
|
|
240
|
-
'',
|
|
241
|
-
]
|
|
242
|
-
: []),
|
|
243
|
-
'Basic Reporting command:',
|
|
244
|
-
'',
|
|
245
|
-
codeBlock(serializeApprovalCommand(basic)),
|
|
246
|
-
'',
|
|
247
|
-
'The command runs once without Datadog and once with validator-owned offline initialization. A debug rerun ' +
|
|
248
|
-
'and one clean confirmation may run only when needed to diagnose a mismatch.',
|
|
249
|
-
...(fallbackTests.length > 0
|
|
250
|
-
? [
|
|
251
|
-
'If this test does not pass cleanly, the validator may try the disclosed fallback tests in order. It ' +
|
|
252
|
-
'will initialize only the first candidate that passes, and will stop early when the failure is a ' +
|
|
253
|
-
'confirmed shared runtime prerequisite rather than a candidate-specific test failure.',
|
|
254
|
-
]
|
|
255
|
-
: []),
|
|
256
|
-
''
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
for (const [index, fallback] of fallbackTests.entries()) {
|
|
260
|
-
const fallbackCommand = getBasicCommand(framework, fallback.testFile)
|
|
261
|
-
lines.push(
|
|
262
|
-
`Fallback Basic Reporting command ${index + 1}:`,
|
|
263
|
-
'',
|
|
264
|
-
codeBlock(serializeApprovalCommand(fallbackCommand)),
|
|
265
|
-
''
|
|
266
|
-
)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const selectedScenarios = getSelectedGeneratedScenarios(framework, requestedScenario)
|
|
270
|
-
if (selectedScenarios.length > 0) {
|
|
271
|
-
lines.push(
|
|
272
|
-
`Advanced checks use working directory: ${inline(relative(
|
|
273
|
-
root,
|
|
274
|
-
getGeneratedCommand(framework, selectedScenarios[0]).cwd
|
|
275
|
-
))}`,
|
|
276
|
-
''
|
|
277
|
-
)
|
|
278
|
-
}
|
|
279
|
-
for (const scenario of selectedScenarios) {
|
|
280
|
-
const command = getGeneratedCommand(framework, scenario)
|
|
281
|
-
const source = getGeneratedSource(framework, scenario)
|
|
282
|
-
lines.push(
|
|
283
|
-
`Advanced check ${inline(scenario.id)}:`,
|
|
284
|
-
'',
|
|
285
|
-
codeBlock(serializeApprovalCommand(command)),
|
|
286
|
-
'',
|
|
287
|
-
`Temporary file: ${inline(relative(root, scenario.testIdentities[0].file))}`,
|
|
288
|
-
'',
|
|
289
|
-
codeBlock(source),
|
|
290
|
-
''
|
|
291
|
-
)
|
|
292
|
-
}
|
|
293
|
-
for (const file of getSelectedSupportFiles(framework, selectedScenarios)) {
|
|
294
|
-
lines.push(
|
|
295
|
-
'Advanced check support file:',
|
|
296
|
-
'',
|
|
297
|
-
`Temporary file: ${inline(relative(root, file.path))}`,
|
|
298
|
-
'',
|
|
299
|
-
codeBlock(file.contentLines.join('\n')),
|
|
300
|
-
''
|
|
301
|
-
)
|
|
302
|
-
}
|
|
303
|
-
if (selectedScenarios.length > 0) {
|
|
304
|
-
lines.push(
|
|
305
|
-
'Advanced execution policy: each generated scenario has one clean verification, one instrumented ' +
|
|
306
|
-
'identity-discovery run, and one feature-validation run. One debug rerun may run only after a failure.',
|
|
307
|
-
''
|
|
308
|
-
)
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
const ci = framework.ciWiring
|
|
313
|
-
const ciPreflight = ciPreflightResults.get(framework.id)
|
|
314
|
-
lines.push(
|
|
315
|
-
'CI audit: static only; no CI or package command will execute.',
|
|
316
|
-
`CI review: ${plain(ci?.reviewComplete ? 'complete' : 'incomplete')}.`,
|
|
317
|
-
...(ciPreflight
|
|
318
|
-
? [`CI pre-approval result: ${plain(formatCiPreflightResult(ciPreflight))}`]
|
|
319
|
-
: []),
|
|
320
|
-
...(ci?.configFile ? [`CI file: ${inline(relative(root, ci.configFile))}`] : []),
|
|
321
|
-
''
|
|
322
|
-
)
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
lines.push(
|
|
326
|
-
'## Writes and Cleanup',
|
|
327
|
-
'',
|
|
328
|
-
`- Validation artifacts: ${inline(relative(root, out))}`,
|
|
329
|
-
'- Single-flight lock: the approved validator creates one fixed lock in the result directory while it runs. An ' +
|
|
330
|
-
'existing lock blocks execution and is never reclaimed automatically.',
|
|
331
|
-
...(requestedScenario === 'ci-wiring'
|
|
332
|
-
? []
|
|
333
|
-
: [
|
|
334
|
-
'- Temporary generated tests shown above are created only for advanced checks and removed afterward.',
|
|
335
|
-
'- Declared framework output is refused if it already exists and removed after each command.',
|
|
336
|
-
'- Private offline fixtures are created outside the repository and removed after each check.',
|
|
337
|
-
]),
|
|
338
|
-
'',
|
|
339
|
-
'## Security Boundary',
|
|
340
|
-
'',
|
|
341
|
-
'- The validation transport opens no listener, contacts no Datadog endpoint, and uses no real Datadog ' +
|
|
342
|
-
'credentials.',
|
|
343
|
-
...(requestedScenario === 'ci-wiring'
|
|
344
|
-
? ['- This CI-only plan executes no project test command.']
|
|
345
|
-
: [
|
|
346
|
-
'- Project runners and tests are arbitrary repository code. Approval means trusting the listed files, ' +
|
|
347
|
-
'their imported code, and any subprocesses they start.',
|
|
348
|
-
]),
|
|
349
|
-
'- The approval digest binds the manifest, validator package, Node.js binary, runner, selected test, config ' +
|
|
350
|
-
'files, CI evidence file, generated source, options, and output directory.',
|
|
351
|
-
'- Missing dependencies, unsupported launchers, arbitrary wrapper chains, dynamic CI, and ambiguous evidence ' +
|
|
352
|
-
'produce an incomplete result.',
|
|
353
|
-
'',
|
|
354
|
-
'Approval details:',
|
|
355
|
-
'',
|
|
356
|
-
`- JSON: ${inline(relative(root, approvalArtifacts.approvalJsonPath))}`,
|
|
357
|
-
`- Checksums: ${inline(relative(root, approvalArtifacts.coveredFilesPath))}`,
|
|
358
|
-
`- SHA-256: ${inline(approvalArtifacts.digest)}`,
|
|
359
|
-
'',
|
|
360
|
-
'Run exactly this command after approval:',
|
|
361
|
-
'',
|
|
362
|
-
codeBlock(serializeApprovalCommand({
|
|
363
|
-
argv: validatorArgv,
|
|
364
|
-
cwd: root,
|
|
365
|
-
usesShell: false,
|
|
366
|
-
})),
|
|
367
|
-
'',
|
|
368
|
-
`Working directory: ${inline(root)}`,
|
|
369
|
-
'',
|
|
370
|
-
'If an agent platform hard-denies the exact command, do not alter it or broaden permissions. Run this same ' +
|
|
371
|
-
'command in a normal project terminal and ask the agent to interpret the generated report.'
|
|
372
|
-
)
|
|
373
|
-
return lines.join('\n')
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function formatCapability (capability) {
|
|
377
|
-
const labels = {
|
|
378
|
-
browser_process: 'browser process',
|
|
379
|
-
localhost_socket: 'localhost socket',
|
|
380
|
-
}
|
|
381
|
-
return labels[capability] || capability
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function formatCandidateRequirements (candidate) {
|
|
385
|
-
const requirements = [
|
|
386
|
-
...(candidate.localSocketRequired ? ['localhost'] : []),
|
|
387
|
-
...(candidate.buildArtifactRequired ? ['build output'] : []),
|
|
388
|
-
]
|
|
389
|
-
return requirements.length > 0 ? ` (${requirements.join(', ')} required)` : ''
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function formatCiPreflightResult (result) {
|
|
393
|
-
const status = result.status === 'fail'
|
|
394
|
-
? 'confirmed actionable problem'
|
|
395
|
-
: result.status === 'pass'
|
|
396
|
-
? 'no confirmed problem'
|
|
397
|
-
: 'incomplete'
|
|
398
|
-
return `${status}: ${result.diagnosis}`
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function formatOmittedRunnerOptions (options = []) {
|
|
402
|
-
const descriptions = {
|
|
403
|
-
'-R': 'Omitted runner option: `-R` selects only Mocha report presentation; the validator uses its bounded ' +
|
|
404
|
-
'reporter.',
|
|
405
|
-
'--reporter': 'Omitted runner option: `--reporter` selects only Mocha report presentation; the validator uses ' +
|
|
406
|
-
'its bounded reporter.',
|
|
407
|
-
'--run': 'Normalized runner option: `--run` is omitted because the validator supplies Vitest `run` itself.',
|
|
408
|
-
'--typecheck': 'Omitted runner option: `--typecheck` is excluded because validation executes runtime tests only.',
|
|
409
|
-
}
|
|
410
|
-
return options.map(option => descriptions[option])
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Selects generated scenarios covered by a plan.
|
|
415
|
-
*
|
|
416
|
-
* @param {object} framework framework entry
|
|
417
|
-
* @param {string|null} requestedScenario selected scenario
|
|
418
|
-
* @returns {object[]} selected generated scenarios
|
|
419
|
-
*/
|
|
420
|
-
function getSelectedGeneratedScenarios (framework, requestedScenario) {
|
|
421
|
-
if (requestedScenario === 'basic-reporting' || requestedScenario === 'ci-wiring') return []
|
|
422
|
-
const scenarios = framework.generatedTestStrategy?.scenarios || []
|
|
423
|
-
if (!requestedScenario) return scenarios
|
|
424
|
-
const id = SCENARIO_TO_GENERATED_ID[requestedScenario]
|
|
425
|
-
return id ? scenarios.filter(scenario => scenario.id === id) : []
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Returns adapter support files required by selected generated scenarios.
|
|
430
|
-
*
|
|
431
|
-
* @param {object} framework framework entry
|
|
432
|
-
* @param {object[]} selectedScenarios selected generated scenarios
|
|
433
|
-
* @returns {object[]} support files
|
|
434
|
-
*/
|
|
435
|
-
function getSelectedSupportFiles (framework, selectedScenarios) {
|
|
436
|
-
if (selectedScenarios.length === 0) return []
|
|
437
|
-
const scenarioPaths = new Set((framework.generatedTestStrategy?.scenarios || []).map(scenario => {
|
|
438
|
-
return path.resolve(scenario.testIdentities[0].file)
|
|
439
|
-
}))
|
|
440
|
-
return (framework.generatedTestStrategy?.files || []).filter(file => {
|
|
441
|
-
return !scenarioPaths.has(path.resolve(file.path))
|
|
442
|
-
})
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Returns canonical generated source for a scenario.
|
|
447
|
-
*
|
|
448
|
-
* @param {object} framework framework entry
|
|
449
|
-
* @param {object} scenario generated scenario
|
|
450
|
-
*/
|
|
451
|
-
function getGeneratedSource (framework, scenario) {
|
|
452
|
-
const filename = path.resolve(scenario.testIdentities[0].file)
|
|
453
|
-
const file = framework.generatedTestStrategy.files.find(candidate => path.resolve(candidate.path) === filename)
|
|
454
|
-
return file?.contentLines?.join('\n') || '<generated source unavailable>'
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Returns the execution plan path.
|
|
459
|
-
*
|
|
460
|
-
* @param {string} out output directory
|
|
461
|
-
*/
|
|
462
|
-
function getExecutionPlanPath (out) {
|
|
463
|
-
return path.join(out, EXECUTION_PLAN_FILENAME)
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Formats a framework label.
|
|
468
|
-
*
|
|
469
|
-
* @param {object} framework framework entry
|
|
470
|
-
* @param {string} root repository root
|
|
471
|
-
*/
|
|
472
|
-
function getFrameworkLabel (framework, root) {
|
|
473
|
-
const project = framework.project?.name || relative(root, framework.project?.root || root)
|
|
474
|
-
return `${framework.framework} in ${project || 'root project'}`
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Formats a framework status.
|
|
479
|
-
*
|
|
480
|
-
* @param {string} status status id
|
|
481
|
-
*/
|
|
482
|
-
function formatStatus (status) {
|
|
483
|
-
return {
|
|
484
|
-
detected_not_runnable: 'detected but no direct target was selected',
|
|
485
|
-
requires_manual_setup: 'requires normal project setup',
|
|
486
|
-
unsupported_by_validator: 'unsupported by this validator',
|
|
487
|
-
}[status] || status
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Formats a repository-relative path.
|
|
492
|
-
*
|
|
493
|
-
* @param {string} root repository root
|
|
494
|
-
* @param {string} filename absolute path
|
|
495
|
-
*/
|
|
496
|
-
function relative (root, filename) {
|
|
497
|
-
const value = path.relative(root, filename)
|
|
498
|
-
return value || '.'
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Formats a safe Markdown code block.
|
|
503
|
-
*
|
|
504
|
-
* @param {string} value text
|
|
505
|
-
*/
|
|
506
|
-
function codeBlock (value) {
|
|
507
|
-
return `\`\`\`text\n${plainMultiline(value).replaceAll('```', String.raw`\u0060\u0060\u0060`)}\n\`\`\``
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Formats safe inline code.
|
|
512
|
-
*
|
|
513
|
-
* @param {string} value text
|
|
514
|
-
*/
|
|
515
|
-
function inline (value) {
|
|
516
|
-
return `\`${plain(value).replaceAll('`', String.raw`\u0060`)}\``
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Sanitizes one line of plan text.
|
|
521
|
-
*
|
|
522
|
-
* @param {unknown} value text
|
|
523
|
-
*/
|
|
524
|
-
function plain (value) {
|
|
525
|
-
return sanitizeString(String(value ?? '')).replaceAll(/\p{Cc}+/gu, ' ').trim()
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Sanitizes multiline plan text.
|
|
530
|
-
*
|
|
531
|
-
* @param {unknown} value text
|
|
532
|
-
*/
|
|
533
|
-
function plainMultiline (value) {
|
|
534
|
-
return sanitizeString(String(value ?? '')).replaceAll('\r\n', '\n').replaceAll('\r', '\n').trim()
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
module.exports = {
|
|
538
|
-
formatExecutionPlan,
|
|
539
|
-
formatExecutionPlanArtifacts,
|
|
540
|
-
getExecutionPlanPath,
|
|
541
|
-
}
|