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,954 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
|
-
|
|
5
|
-
const fs = require('node:fs')
|
|
6
|
-
const path = require('node:path')
|
|
7
|
-
|
|
8
|
-
const { assertApprovalDigest, getApprovalProjectSnapshot } = require('./approval')
|
|
9
|
-
const { loadApprovedPlan } = require('./approval-artifacts')
|
|
10
|
-
const { BLOCKER_CATEGORIES, getBlockerDomain } = require('./blocker-category')
|
|
11
|
-
const { annotateCiDiscovery } = require('./ci-discovery')
|
|
12
|
-
const { cleanupGeneratedFiles } = require('./generated-files')
|
|
13
|
-
const { verifyGeneratedTestStrategy } = require('./generated-verifier')
|
|
14
|
-
const {
|
|
15
|
-
acquireExecutionLock,
|
|
16
|
-
releaseExecutionLock,
|
|
17
|
-
} = require('./execution-lock')
|
|
18
|
-
const { loadManifest } = require('./manifest-loader')
|
|
19
|
-
const { createManifestScaffold } = require('./manifest-scaffold')
|
|
20
|
-
const {
|
|
21
|
-
formatExecutionPlanArtifacts,
|
|
22
|
-
getExecutionPlanPath,
|
|
23
|
-
} = require('./plan-writer')
|
|
24
|
-
const { checkInstalledPackage, getInstalledPackageFailure } = require('./package-check')
|
|
25
|
-
const { runFrameworkPreflight } = require('./preflight-runner')
|
|
26
|
-
const { sanitizeConsoleText } = require('./redaction')
|
|
27
|
-
const {
|
|
28
|
-
annotateResults,
|
|
29
|
-
getExecutionStatus,
|
|
30
|
-
getValidationCoverage,
|
|
31
|
-
getValidatorExitCode,
|
|
32
|
-
} = require('./result-semantics')
|
|
33
|
-
const { writePendingReport, writeReport } = require('./report-writer')
|
|
34
|
-
const { getBasicCommand } = require('./runner-command')
|
|
35
|
-
const { getUnavailableExecutable } = require('./executable')
|
|
36
|
-
const { runAutoTestRetries } = require('./scenarios/auto-test-retries')
|
|
37
|
-
const { runBasicReporting } = require('./scenarios/basic-reporting')
|
|
38
|
-
const { runCiWiring } = require('./scenarios/ci-wiring')
|
|
39
|
-
const { runEarlyFlakeDetection } = require('./scenarios/early-flake-detection')
|
|
40
|
-
const { runTestManagement } = require('./scenarios/test-management')
|
|
41
|
-
const { ensureSafeDirectory } = require('./safe-files')
|
|
42
|
-
const { getStaticBlocker, runStaticDiagnosis } = require('./static-diagnosis')
|
|
43
|
-
const { getValidationBlockerEvidence } = require('./validation-blocker')
|
|
44
|
-
|
|
45
|
-
const DEFAULT_MANIFEST = './dd-test-optimization-validation-manifest.json'
|
|
46
|
-
const DEFAULT_OUT = './dd-test-optimization-validation-results'
|
|
47
|
-
const SCENARIOS = {
|
|
48
|
-
'basic-reporting': runBasicReporting,
|
|
49
|
-
efd: runEarlyFlakeDetection,
|
|
50
|
-
atr: runAutoTestRetries,
|
|
51
|
-
'test-management': runTestManagement,
|
|
52
|
-
}
|
|
53
|
-
const BASIC_REPORTING = 'basic-reporting'
|
|
54
|
-
const CI_WIRING = 'ci-wiring'
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Parses validator CLI arguments.
|
|
58
|
-
*
|
|
59
|
-
* @param {string[]} argv command arguments
|
|
60
|
-
* @returns {object} parsed options
|
|
61
|
-
*/
|
|
62
|
-
function parseArgs (argv) {
|
|
63
|
-
const options = {
|
|
64
|
-
approvalOverrides: [],
|
|
65
|
-
frameworks: new Set(),
|
|
66
|
-
keepTempFiles: false,
|
|
67
|
-
manifest: DEFAULT_MANIFEST,
|
|
68
|
-
out: DEFAULT_OUT,
|
|
69
|
-
requestedScenario: null,
|
|
70
|
-
scenarios: new Set(getSelectableScenarios()),
|
|
71
|
-
verbose: false,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
for (let index = 0; index < argv.length; index++) {
|
|
75
|
-
const argument = argv[index]
|
|
76
|
-
if (argument === '--manifest') {
|
|
77
|
-
options.manifest = requireValue(argv, ++index, argument)
|
|
78
|
-
options.approvalOverrides.push(argument)
|
|
79
|
-
} else if (argument === '--out') {
|
|
80
|
-
options.out = requireValue(argv, ++index, argument)
|
|
81
|
-
options.approvalOverrides.push(argument)
|
|
82
|
-
} else if (argument === '--framework') {
|
|
83
|
-
options.frameworks.add(normalizeFrameworkTarget(requireValue(argv, ++index, argument)))
|
|
84
|
-
options.approvalOverrides.push(argument)
|
|
85
|
-
} else if (argument === '--scenario') {
|
|
86
|
-
options.requestedScenario = requireValue(argv, ++index, argument)
|
|
87
|
-
options.scenarios = normalizeScenarioSelection(options.requestedScenario)
|
|
88
|
-
options.approvalOverrides.push(argument)
|
|
89
|
-
} else if (argument === '--keep-temp-files') {
|
|
90
|
-
options.keepTempFiles = true
|
|
91
|
-
options.approvalOverrides.push(argument)
|
|
92
|
-
} else if (argument === '--verbose') {
|
|
93
|
-
options.verbose = true
|
|
94
|
-
options.approvalOverrides.push(argument)
|
|
95
|
-
} else if (argument === '--validate-manifest') {
|
|
96
|
-
options.validateManifest = true
|
|
97
|
-
} else if (argument === '--init-manifest') {
|
|
98
|
-
options.initManifest = true
|
|
99
|
-
} else if (argument === '--print-plan') {
|
|
100
|
-
options.printPlan = true
|
|
101
|
-
} else if (argument === '--run-approved-plan') {
|
|
102
|
-
options.runApprovedPlan = requireValue(argv, ++index, argument)
|
|
103
|
-
} else if (argument === '--sha256') {
|
|
104
|
-
options.approvedArtifactSha256 = requireValue(argv, ++index, argument)
|
|
105
|
-
} else if (argument === '--help' || argument === '-h') {
|
|
106
|
-
options.help = true
|
|
107
|
-
} else {
|
|
108
|
-
throw new Error(`Unknown argument: ${argument}`)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return options
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Runs the validator CLI.
|
|
116
|
-
*
|
|
117
|
-
* @param {string[]} argv command arguments
|
|
118
|
-
* @returns {Promise<void>} completion
|
|
119
|
-
*/
|
|
120
|
-
async function main (argv) {
|
|
121
|
-
let activeApprovedPlanSha256
|
|
122
|
-
let activeManifest
|
|
123
|
-
let activeOut
|
|
124
|
-
let cleanupOutcome = { status: 'not_started' }
|
|
125
|
-
let executionLock
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
const options = parseArgs(argv)
|
|
129
|
-
assertCompatibleModes(options)
|
|
130
|
-
if (options.help) return printHelp()
|
|
131
|
-
if (options.initManifest) return initializeManifest(options)
|
|
132
|
-
|
|
133
|
-
if (options.runApprovedPlan) applyApprovedPlanOptions(options)
|
|
134
|
-
const manifest = loadManifest(options.manifest)
|
|
135
|
-
|
|
136
|
-
if (options.validateManifest) {
|
|
137
|
-
console.log(sanitizeConsoleText(`Validation manifest is valid: ${manifest.__path}`))
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
if (options.printPlan) return printPlan(manifest, options)
|
|
141
|
-
if (!options.approvedPlanSha256 || !options.offlineFixtureNonce) {
|
|
142
|
-
throw new Error('Live validation requires the checksum-bound command produced by --print-plan.')
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const out = validateOutputPath(manifest, options.out)
|
|
146
|
-
activeManifest = manifest
|
|
147
|
-
activeOut = out
|
|
148
|
-
options.repositoryRoot = manifest.repository.root
|
|
149
|
-
const selectedFrameworks = filterFrameworks(manifest.frameworks, options.frameworks)
|
|
150
|
-
const approvalManifest = getApprovalManifest(manifest, options.frameworks)
|
|
151
|
-
assertApprovalDigest(options.approvedPlanSha256, {
|
|
152
|
-
manifest: approvalManifest,
|
|
153
|
-
out,
|
|
154
|
-
selectedFrameworkIds: options.frameworks.size > 0
|
|
155
|
-
? selectedFrameworks.map(framework => framework.id)
|
|
156
|
-
: [],
|
|
157
|
-
requestedScenario: options.requestedScenario,
|
|
158
|
-
offlineFixtureNonce: options.offlineFixtureNonce,
|
|
159
|
-
keepTempFiles: options.keepTempFiles,
|
|
160
|
-
verbose: options.verbose,
|
|
161
|
-
})
|
|
162
|
-
activeApprovedPlanSha256 = options.approvedPlanSha256
|
|
163
|
-
const packageCheck = hasLocalScenarios(options.scenarios)
|
|
164
|
-
? checkInstalledPackage()
|
|
165
|
-
: undefined
|
|
166
|
-
options.requireExecutableApproval = true
|
|
167
|
-
ensureSafeDirectory(manifest.repository.root, out, 'validation output directory', { allowRootSymlink: true })
|
|
168
|
-
executionLock = acquireExecutionLock({
|
|
169
|
-
out,
|
|
170
|
-
approvedPlanSha256: options.approvedPlanSha256,
|
|
171
|
-
})
|
|
172
|
-
writePendingReport({ manifest, out })
|
|
173
|
-
|
|
174
|
-
const staticDiagnosis = runStaticDiagnosis({ manifest, out })
|
|
175
|
-
annotateCiDiscovery({ manifest, diagnosis: staticDiagnosis.report })
|
|
176
|
-
const results = []
|
|
177
|
-
|
|
178
|
-
try {
|
|
179
|
-
for (const framework of selectedFrameworks) {
|
|
180
|
-
// Each framework is independent. A setup blocker must not discard useful results from another adapter.
|
|
181
|
-
// eslint-disable-next-line no-await-in-loop
|
|
182
|
-
await validateFramework({ framework, manifest, options, out, packageCheck, results, staticDiagnosis })
|
|
183
|
-
}
|
|
184
|
-
} finally {
|
|
185
|
-
try {
|
|
186
|
-
cleanupOutcome = await cleanupGeneratedFiles(manifest, { keep: options.keepTempFiles })
|
|
187
|
-
if (cleanupOutcome.status === 'incomplete') {
|
|
188
|
-
results.push(getCleanupFailure(undefined, cleanupOutcome))
|
|
189
|
-
}
|
|
190
|
-
} catch (error) {
|
|
191
|
-
cleanupOutcome = { errorCount: 1, status: 'incomplete' }
|
|
192
|
-
results.push(getCleanupFailure(error, cleanupOutcome))
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
addMissingResults(results, selectedFrameworks, options.scenarios)
|
|
197
|
-
const annotatedResults = annotateResults(results)
|
|
198
|
-
const executionStatus = getExecutionStatus(annotatedResults)
|
|
199
|
-
const validatorExitCode = getValidatorExitCode(annotatedResults, executionStatus)
|
|
200
|
-
await writeReport({
|
|
201
|
-
manifest,
|
|
202
|
-
out,
|
|
203
|
-
results: annotatedResults,
|
|
204
|
-
staticDiagnosis,
|
|
205
|
-
runSummary: {
|
|
206
|
-
approvedPlanSha256: activeApprovedPlanSha256,
|
|
207
|
-
checkedScenarios: [...options.scenarios],
|
|
208
|
-
cleanup: cleanupOutcome,
|
|
209
|
-
executionStatus,
|
|
210
|
-
omittedScenarios: getSelectableScenarios().filter(scenario => !options.scenarios.has(scenario)),
|
|
211
|
-
requestedScenario: options.requestedScenario,
|
|
212
|
-
runCompleted: true,
|
|
213
|
-
selectedFrameworkIds: selectedFrameworks.map(framework => framework.id),
|
|
214
|
-
validationCoverage: getValidationCoverage(annotatedResults),
|
|
215
|
-
validatorExitCode,
|
|
216
|
-
},
|
|
217
|
-
})
|
|
218
|
-
releaseExecutionLock(executionLock)
|
|
219
|
-
executionLock = undefined
|
|
220
|
-
console.log(`Validation report: ${path.join(out, 'report.md')}`)
|
|
221
|
-
console.log('Present the report and stop. Any correction or retry requires a fresh plan and approval.')
|
|
222
|
-
process.exitCode = validatorExitCode
|
|
223
|
-
} catch (error) {
|
|
224
|
-
let reportError = error
|
|
225
|
-
if (executionLock) {
|
|
226
|
-
await publishFailureReport({
|
|
227
|
-
approvedPlanSha256: activeApprovedPlanSha256,
|
|
228
|
-
cleanup: cleanupOutcome,
|
|
229
|
-
error: reportError,
|
|
230
|
-
manifest: activeManifest,
|
|
231
|
-
out: activeOut,
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
if (executionLock) {
|
|
235
|
-
try {
|
|
236
|
-
releaseExecutionLock(executionLock)
|
|
237
|
-
executionLock = undefined
|
|
238
|
-
} catch (releaseError) {
|
|
239
|
-
reportError = releaseError
|
|
240
|
-
await publishFailureReport({
|
|
241
|
-
approvedPlanSha256: activeApprovedPlanSha256,
|
|
242
|
-
cleanup: cleanupOutcome,
|
|
243
|
-
error: reportError,
|
|
244
|
-
manifest: activeManifest,
|
|
245
|
-
out: activeOut,
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const validatorExitCode = reportError?.validationExitCode || 3
|
|
250
|
-
process.exitCode = validatorExitCode
|
|
251
|
-
const blockerRecommendation = reportError?.validationBlocker?.recommendation
|
|
252
|
-
const displayedError = reportError?.validationExitCode
|
|
253
|
-
? `${reportError.message}${blockerRecommendation ? ` ${blockerRecommendation}` : ''}`
|
|
254
|
-
: (reportError?.stack || reportError)
|
|
255
|
-
console.error(sanitizeConsoleText(displayedError))
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async function publishFailureReport ({ approvedPlanSha256, cleanup, error, manifest, out }) {
|
|
260
|
-
if (!manifest || !out || error?.suppressReport) return
|
|
261
|
-
try {
|
|
262
|
-
await writeReport({
|
|
263
|
-
manifest,
|
|
264
|
-
out,
|
|
265
|
-
results: [getOrchestrationFailure(error)],
|
|
266
|
-
runSummary: {
|
|
267
|
-
approvedPlanSha256,
|
|
268
|
-
checkedScenarios: [],
|
|
269
|
-
cleanup,
|
|
270
|
-
executionStatus: error?.validationBlocker ? 'incomplete' : 'validator_error',
|
|
271
|
-
omittedScenarios: getSelectableScenarios(),
|
|
272
|
-
runCompleted: true,
|
|
273
|
-
selectedFrameworkIds: [],
|
|
274
|
-
validationCoverage: 'partial',
|
|
275
|
-
validatorExitCode: error?.validationExitCode || 3,
|
|
276
|
-
},
|
|
277
|
-
})
|
|
278
|
-
} catch {}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Runs selected checks for one framework.
|
|
283
|
-
*
|
|
284
|
-
* @param {object} input framework execution inputs
|
|
285
|
-
* @param {object} input.framework framework manifest entry
|
|
286
|
-
* @param {object} input.manifest validation manifest
|
|
287
|
-
* @param {object} input.options validator options
|
|
288
|
-
* @param {string} input.out output directory
|
|
289
|
-
* @param {object|undefined} input.packageCheck installed package-load result
|
|
290
|
-
* @param {object[]} input.results accumulated results
|
|
291
|
-
* @param {object} input.staticDiagnosis static diagnosis
|
|
292
|
-
* @returns {Promise<void>} completion
|
|
293
|
-
*/
|
|
294
|
-
async function validateFramework ({ framework, manifest, options, out, packageCheck, results, staticDiagnosis }) {
|
|
295
|
-
let ciResult
|
|
296
|
-
if (options.scenarios.has(CI_WIRING)) {
|
|
297
|
-
logPhase(framework, 'CI configuration audit', 'start')
|
|
298
|
-
ciResult = runCiWiring({ manifest, framework })
|
|
299
|
-
logPhase(framework, 'CI configuration audit', ciResult.status)
|
|
300
|
-
}
|
|
301
|
-
if (![...options.scenarios].some(scenario => scenario !== CI_WIRING)) {
|
|
302
|
-
if (ciResult) results.push(ciResult)
|
|
303
|
-
return
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (framework.status !== 'runnable') {
|
|
307
|
-
results.push(getFrameworkStatusResult(framework))
|
|
308
|
-
if (ciResult) results.push(ciResult)
|
|
309
|
-
addNotReachedLocalResults(results, framework, options.scenarios, 'framework-not-runnable')
|
|
310
|
-
return
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (packageCheck?.ok === false) {
|
|
314
|
-
const packageFailure = getInstalledPackageFailure(framework, packageCheck)
|
|
315
|
-
results.push(packageFailure)
|
|
316
|
-
if (ciResult) results.push(ciResult)
|
|
317
|
-
addAdvancedNotReached(results, framework, options.scenarios, packageFailure)
|
|
318
|
-
return
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const unavailable = getUnavailableExecutable(getBasicCommand(framework))
|
|
322
|
-
if (unavailable) {
|
|
323
|
-
const unavailableResult = getUnavailableRunnerResult(framework, unavailable)
|
|
324
|
-
results.push(unavailableResult)
|
|
325
|
-
if (ciResult) results.push(ciResult)
|
|
326
|
-
addNotReachedLocalResults(
|
|
327
|
-
results,
|
|
328
|
-
framework,
|
|
329
|
-
options.scenarios,
|
|
330
|
-
'runner-unavailable',
|
|
331
|
-
unavailableResult.evidence.blockerCategory
|
|
332
|
-
)
|
|
333
|
-
return
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const blocker = getStaticBlocker(framework, staticDiagnosis.report)
|
|
337
|
-
if (blocker) {
|
|
338
|
-
const staticFailure = getStaticFailure(framework, blocker, staticDiagnosis.reportPath)
|
|
339
|
-
const basicNotReached = getBasicNotReached(
|
|
340
|
-
framework,
|
|
341
|
-
blocker.reason,
|
|
342
|
-
'static-project-blocker',
|
|
343
|
-
blocker.blockerCategory
|
|
344
|
-
)
|
|
345
|
-
results.push(staticFailure, basicNotReached)
|
|
346
|
-
if (ciResult) results.push(ciResult)
|
|
347
|
-
addAdvancedNotReached(results, framework, options.scenarios, basicNotReached)
|
|
348
|
-
return
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
let basicResult
|
|
352
|
-
if (options.scenarios.has(BASIC_REPORTING)) {
|
|
353
|
-
logPhase(framework, 'clean direct test', 'start')
|
|
354
|
-
const preflight = await runFrameworkPreflight({ framework, out, options })
|
|
355
|
-
logPhase(framework, 'clean direct test', preflight.ok ? 'pass' : 'incomplete')
|
|
356
|
-
if (preflight.ok) {
|
|
357
|
-
logPhase(framework, 'Basic Reporting', 'start')
|
|
358
|
-
basicResult = await runBasicReporting({ manifest, framework, out, options })
|
|
359
|
-
logPhase(framework, 'Basic Reporting', basicResult.status)
|
|
360
|
-
} else {
|
|
361
|
-
basicResult = preflight.failure
|
|
362
|
-
}
|
|
363
|
-
results.push(basicResult)
|
|
364
|
-
}
|
|
365
|
-
if (ciResult) results.push(ciResult)
|
|
366
|
-
|
|
367
|
-
const advanced = getAdvancedScenarios(options.scenarios)
|
|
368
|
-
if (advanced.length === 0) return
|
|
369
|
-
if (basicResult?.evidence?.foundationalReportingEstablished !== true) {
|
|
370
|
-
addAdvancedNotReached(results, framework, options.scenarios, basicResult)
|
|
371
|
-
return
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
const generated = await verifyGeneratedTestStrategy({ framework, out, options })
|
|
375
|
-
if (!generated.ok) {
|
|
376
|
-
results.push(generated.failure)
|
|
377
|
-
addAdvancedNotReached(results, framework, options.scenarios, generated.failure)
|
|
378
|
-
return
|
|
379
|
-
}
|
|
380
|
-
for (const scenario of advanced) {
|
|
381
|
-
// Advanced scenarios are serial because their offline fixtures and generated retry state are isolated.
|
|
382
|
-
// eslint-disable-next-line no-await-in-loop
|
|
383
|
-
results.push(await SCENARIOS[scenario]({ manifest, framework, out, options }))
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Creates a manifest scaffold and prints the bounded next step.
|
|
389
|
-
*
|
|
390
|
-
* @param {object} options CLI options
|
|
391
|
-
*/
|
|
392
|
-
function initializeManifest (options) {
|
|
393
|
-
const manifestPath = path.resolve(options.manifest)
|
|
394
|
-
if (path.dirname(manifestPath) !== process.cwd()) {
|
|
395
|
-
throw new Error('The generated manifest must be stored directly in the current repository root.')
|
|
396
|
-
}
|
|
397
|
-
if (fs.existsSync(manifestPath)) return reuseExistingManifest(manifestPath)
|
|
398
|
-
|
|
399
|
-
const manifest = createManifestScaffold({ root: process.cwd(), frameworks: options.frameworks })
|
|
400
|
-
try {
|
|
401
|
-
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, { flag: 'wx' })
|
|
402
|
-
} catch (error) {
|
|
403
|
-
if (error.code === 'EEXIST') return reuseExistingManifest(manifestPath)
|
|
404
|
-
throw error
|
|
405
|
-
}
|
|
406
|
-
const targets = manifest.ciDiscovery.reviewTargets
|
|
407
|
-
console.log(sanitizeConsoleText([
|
|
408
|
-
`Created a data-only validation manifest: ${manifestPath}`,
|
|
409
|
-
'No project code ran. The validator selected repository-contained runners and one test file per framework.',
|
|
410
|
-
targets.length > 0
|
|
411
|
-
? `Review only these CI files, in order: ${targets.join(', ')}. Record one exact test job, command, and ` +
|
|
412
|
-
'effective initialization/transport evidence. Set reviewComplete=true only after resolving wrappers and ' +
|
|
413
|
-
'inherited configuration; otherwise leave the uncertainty in unresolved.'
|
|
414
|
-
: 'No supported CI configuration file was found. Leave CI review incomplete.',
|
|
415
|
-
'Do not add commands, setup steps, package scripts, wrapper chains, or fallback tests to the manifest.',
|
|
416
|
-
'Then run --validate-manifest and --print-plan.',
|
|
417
|
-
].join('\n')))
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Writes and prints the approval plan.
|
|
422
|
-
*
|
|
423
|
-
* @param {object} manifest loaded manifest
|
|
424
|
-
* @param {object} options CLI options
|
|
425
|
-
*/
|
|
426
|
-
function printPlan (manifest, options) {
|
|
427
|
-
const out = validateOutputPath(manifest, options.out)
|
|
428
|
-
const approvalManifest = getApprovalManifest(manifest, options.frameworks)
|
|
429
|
-
const localScenariosSelected = hasLocalScenarios(options.scenarios)
|
|
430
|
-
if (!localScenariosSelected ||
|
|
431
|
-
!approvalManifest.frameworks.some(framework => framework.status === 'runnable')) {
|
|
432
|
-
return writeStaticOnlyReport(approvalManifest, out, options)
|
|
433
|
-
}
|
|
434
|
-
ensureSafeDirectory(manifest.repository.root, out, 'validation output directory', { allowRootSymlink: true })
|
|
435
|
-
const publicationLock = acquireExecutionLock({ out, approvedPlanSha256: 'plan-publication' })
|
|
436
|
-
try {
|
|
437
|
-
const packageCheck = localScenariosSelected
|
|
438
|
-
? checkInstalledPackage()
|
|
439
|
-
: undefined
|
|
440
|
-
if (packageCheck?.ok === false) throw getInstalledPackageCheckError(packageCheck)
|
|
441
|
-
|
|
442
|
-
const projectSnapshot = getApprovalProjectSnapshot(approvalManifest, {
|
|
443
|
-
includeLocal: options.requestedScenario !== CI_WIRING,
|
|
444
|
-
})
|
|
445
|
-
const ciPreflightResults = options.scenarios.has(CI_WIRING)
|
|
446
|
-
? new Map(approvalManifest.frameworks.map(framework => [
|
|
447
|
-
framework.id,
|
|
448
|
-
runCiWiring({ manifest: approvalManifest, framework, projectFileSources: projectSnapshot.sources }),
|
|
449
|
-
]))
|
|
450
|
-
: new Map()
|
|
451
|
-
const { plan } = formatExecutionPlanArtifacts({
|
|
452
|
-
manifest: approvalManifest,
|
|
453
|
-
out,
|
|
454
|
-
selectedFrameworkIds: options.frameworks.size > 0
|
|
455
|
-
? approvalManifest.frameworks.map(framework => framework.id)
|
|
456
|
-
: [],
|
|
457
|
-
requestedScenario: options.requestedScenario,
|
|
458
|
-
keepTempFiles: options.keepTempFiles,
|
|
459
|
-
packageCheck,
|
|
460
|
-
ciPreflightResults,
|
|
461
|
-
expectedProjectFiles: projectSnapshot.projectFiles,
|
|
462
|
-
verbose: options.verbose,
|
|
463
|
-
})
|
|
464
|
-
console.log(sanitizeConsoleText([
|
|
465
|
-
'===== CUSTOMER APPROVAL PLAN =====',
|
|
466
|
-
plan,
|
|
467
|
-
'===== END CUSTOMER APPROVAL PLAN =====',
|
|
468
|
-
'',
|
|
469
|
-
`Saved execution plan: ${getExecutionPlanPath(out)}`,
|
|
470
|
-
'LIVE VALIDATION HAS NOT RUN.',
|
|
471
|
-
'Present the complete delimited plan and ask exactly: Approve executing exactly the plan above?',
|
|
472
|
-
].join('\n')))
|
|
473
|
-
} finally {
|
|
474
|
-
releaseExecutionLock(publicationLock)
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
function writeStaticOnlyReport (manifest, out, options) {
|
|
479
|
-
const results = []
|
|
480
|
-
const localScenariosSelected = hasLocalScenarios(options.scenarios)
|
|
481
|
-
for (const framework of manifest.frameworks) {
|
|
482
|
-
if (localScenariosSelected) {
|
|
483
|
-
results.push(getFrameworkStatusResult(framework))
|
|
484
|
-
addNotReachedLocalResults(results, framework, options.scenarios, 'framework-not-runnable')
|
|
485
|
-
}
|
|
486
|
-
if (options.scenarios.has(CI_WIRING)) results.push(runCiWiring({ manifest, framework }))
|
|
487
|
-
}
|
|
488
|
-
const annotatedResults = annotateResults(results)
|
|
489
|
-
const executionStatus = getExecutionStatus(annotatedResults)
|
|
490
|
-
const validatorExitCode = getValidatorExitCode(annotatedResults, executionStatus)
|
|
491
|
-
ensureSafeDirectory(manifest.repository.root, out, 'validation output directory', { allowRootSymlink: true })
|
|
492
|
-
const publicationLock = acquireExecutionLock({ out, approvedPlanSha256: 'static-only-report' })
|
|
493
|
-
try {
|
|
494
|
-
writeReport({
|
|
495
|
-
manifest,
|
|
496
|
-
out,
|
|
497
|
-
results: annotatedResults,
|
|
498
|
-
runSummary: {
|
|
499
|
-
checkedScenarios: [...options.scenarios],
|
|
500
|
-
cleanup: { directoriesRemoved: 0, filesRemoved: 0, status: 'completed' },
|
|
501
|
-
executionStatus,
|
|
502
|
-
omittedScenarios: getSelectableScenarios().filter(scenario => !options.scenarios.has(scenario)),
|
|
503
|
-
requestedScenario: options.requestedScenario,
|
|
504
|
-
runCompleted: true,
|
|
505
|
-
selectedFrameworkIds: manifest.frameworks.map(framework => framework.id),
|
|
506
|
-
validationCoverage: getValidationCoverage(annotatedResults),
|
|
507
|
-
validatorExitCode,
|
|
508
|
-
},
|
|
509
|
-
})
|
|
510
|
-
} finally {
|
|
511
|
-
releaseExecutionLock(publicationLock)
|
|
512
|
-
}
|
|
513
|
-
const reason = localScenariosSelected
|
|
514
|
-
? 'No selected framework has an eligible local command.'
|
|
515
|
-
: 'The selected CI-only audit does not require local execution.'
|
|
516
|
-
console.log(sanitizeConsoleText(
|
|
517
|
-
`${reason} A final static-only report was written; no new approval artifact or live validation command was ` +
|
|
518
|
-
'created. Present the report and stop.'
|
|
519
|
-
))
|
|
520
|
-
process.exitCode = validatorExitCode
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function reuseExistingManifest (manifestPath) {
|
|
524
|
-
try {
|
|
525
|
-
const manifest = loadManifest(manifestPath)
|
|
526
|
-
if (fs.realpathSync(manifest.repository.root) !== fs.realpathSync(process.cwd())) {
|
|
527
|
-
throw new Error('repository.root does not identify the current physical repository')
|
|
528
|
-
}
|
|
529
|
-
} catch (error) {
|
|
530
|
-
const recovery = new Error(
|
|
531
|
-
`The existing validation manifest cannot be reused: ${error.message}. ` +
|
|
532
|
-
`Inspect and remove only ${manifestPath}, then rerun --init-manifest. The validator did not delete or replace it.`
|
|
533
|
-
)
|
|
534
|
-
recovery.validationExitCode = 2
|
|
535
|
-
throw recovery
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
console.log(sanitizeConsoleText([
|
|
539
|
-
`Existing validation manifest is valid for this repository: ${manifestPath}`,
|
|
540
|
-
'Reuse it, refresh only its ciWiring evidence if needed, then run --validate-manifest and --print-plan.',
|
|
541
|
-
'The validator did not overwrite the manifest or delete existing approval and report artifacts.',
|
|
542
|
-
].join('\n')))
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
function hasLocalScenarios (scenarios) {
|
|
546
|
-
return [...scenarios].some(scenario => scenario !== CI_WIRING)
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function getInstalledPackageCheckError (packageCheck) {
|
|
550
|
-
const error = new Error(
|
|
551
|
-
`INSTALLED DD-TRACE PACKAGE BLOCKER: ${packageCheck.diagnosis} ${packageCheck.recommendation}`
|
|
552
|
-
)
|
|
553
|
-
error.validationExitCode = 2
|
|
554
|
-
return error
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Restores approved execution options from approval.json.
|
|
559
|
-
*
|
|
560
|
-
* @param {object} options parsed options
|
|
561
|
-
*/
|
|
562
|
-
function applyApprovedPlanOptions (options) {
|
|
563
|
-
if (!options.approvedArtifactSha256) throw new Error('--run-approved-plan requires --sha256.')
|
|
564
|
-
if (options.approvalOverrides.length > 0) {
|
|
565
|
-
throw new Error('--run-approved-plan cannot be combined with manifest, output, or selection flags.')
|
|
566
|
-
}
|
|
567
|
-
const { material } = loadApprovedPlan(options.runApprovedPlan, options.approvedArtifactSha256)
|
|
568
|
-
options.manifest = material.manifest.path
|
|
569
|
-
options.out = material.validation.outputDirectory
|
|
570
|
-
options.frameworks = new Set(material.selection.frameworks.map(normalizeFrameworkTarget))
|
|
571
|
-
options.requestedScenario = material.selection.scenario
|
|
572
|
-
options.scenarios = options.requestedScenario
|
|
573
|
-
? normalizeScenarioSelection(options.requestedScenario)
|
|
574
|
-
: new Set(getSelectableScenarios())
|
|
575
|
-
options.offlineFixtureNonce = material.validation.offlineFixtureNonce
|
|
576
|
-
options.keepTempFiles = material.validation.keepTemporaryFiles === true
|
|
577
|
-
options.verbose = material.validation.verbose === true
|
|
578
|
-
options.approvedPlanSha256 = options.approvedArtifactSha256
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* Filters manifest frameworks.
|
|
583
|
-
*
|
|
584
|
-
* @param {object[]} frameworks framework entries
|
|
585
|
-
* @param {Set<string>} targets selected ids or kinds
|
|
586
|
-
* @returns {object[]} selected entries
|
|
587
|
-
*/
|
|
588
|
-
function filterFrameworks (frameworks, targets) {
|
|
589
|
-
if (targets.size === 0) return frameworks
|
|
590
|
-
const selected = frameworks.filter(framework => targets.has(framework.id) || targets.has(framework.framework))
|
|
591
|
-
if (selected.length === 0) throw new Error('No framework matched the requested selection.')
|
|
592
|
-
return selected
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Returns a framework-scoped approval manifest.
|
|
597
|
-
*
|
|
598
|
-
* @param {object} manifest loaded manifest
|
|
599
|
-
* @param {Set<string>} targets selected frameworks
|
|
600
|
-
* @returns {object} approval manifest
|
|
601
|
-
*/
|
|
602
|
-
function getApprovalManifest (manifest, targets) {
|
|
603
|
-
if (targets.size === 0) return manifest
|
|
604
|
-
const approvalManifest = { ...manifest, frameworks: filterFrameworks(manifest.frameworks, targets) }
|
|
605
|
-
Object.defineProperty(approvalManifest, '__sourceSha256', {
|
|
606
|
-
enumerable: false,
|
|
607
|
-
value: manifest.__sourceSha256,
|
|
608
|
-
})
|
|
609
|
-
return approvalManifest
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* Adds explicit not-reached results for advanced scenarios.
|
|
614
|
-
*
|
|
615
|
-
* @param {object[]} results result list
|
|
616
|
-
* @param {object} framework framework entry
|
|
617
|
-
* @param {Set<string>} scenarios selected scenarios
|
|
618
|
-
* @param {object} blocker blocking result
|
|
619
|
-
*/
|
|
620
|
-
function addAdvancedNotReached (results, framework, scenarios, blocker) {
|
|
621
|
-
for (const scenario of getAdvancedScenarios(scenarios)) {
|
|
622
|
-
results.push({
|
|
623
|
-
frameworkId: framework.id,
|
|
624
|
-
scenario,
|
|
625
|
-
status: 'skip',
|
|
626
|
-
diagnosis: 'Not reached because Basic Reporting did not establish the direct reporting path.',
|
|
627
|
-
evidence: {
|
|
628
|
-
blockedBy: blocker?.scenario || 'basic-reporting',
|
|
629
|
-
...(blocker?.evidence?.blockerCategory
|
|
630
|
-
? { blockerCategory: blocker.evidence.blockerCategory }
|
|
631
|
-
: {}),
|
|
632
|
-
validationIncomplete: true,
|
|
633
|
-
},
|
|
634
|
-
artifacts: [],
|
|
635
|
-
})
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* Adds local not-reached results for a non-runnable framework.
|
|
641
|
-
*
|
|
642
|
-
* @param {object[]} results result list
|
|
643
|
-
* @param {object} framework framework entry
|
|
644
|
-
* @param {Set<string>} scenarios selected scenarios
|
|
645
|
-
* @param {string} reasonCode blocker id
|
|
646
|
-
* @param {string} [blockerCategoryOverride] blocker category supplied by a runtime result
|
|
647
|
-
*/
|
|
648
|
-
function addNotReachedLocalResults (results, framework, scenarios, reasonCode, blockerCategoryOverride) {
|
|
649
|
-
const blockerCategory = blockerCategoryOverride || framework.blockerCategory || (
|
|
650
|
-
framework.status === 'requires_manual_setup'
|
|
651
|
-
? BLOCKER_CATEGORIES.PROJECT_SETUP_REQUIRED
|
|
652
|
-
: BLOCKER_CATEGORIES.VALIDATOR_LIMITATION
|
|
653
|
-
)
|
|
654
|
-
for (const scenario of scenarios) {
|
|
655
|
-
if (scenario === CI_WIRING) continue
|
|
656
|
-
results.push({
|
|
657
|
-
frameworkId: framework.id,
|
|
658
|
-
scenario,
|
|
659
|
-
status: 'skip',
|
|
660
|
-
diagnosis: 'Not reached because this framework has no available direct-runner validation target.',
|
|
661
|
-
evidence: { blockerCategory, reasonCode, validationIncomplete: true },
|
|
662
|
-
artifacts: [],
|
|
663
|
-
})
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Adds fail-closed results for missing orchestration output.
|
|
669
|
-
*
|
|
670
|
-
* @param {object[]} results result list
|
|
671
|
-
* @param {object[]} frameworks selected frameworks
|
|
672
|
-
* @param {Set<string>} scenarios selected scenarios
|
|
673
|
-
*/
|
|
674
|
-
function addMissingResults (results, frameworks, scenarios) {
|
|
675
|
-
for (const framework of frameworks) {
|
|
676
|
-
for (const scenario of scenarios) {
|
|
677
|
-
if (results.some(result => result.frameworkId === framework.id && result.scenario === scenario)) continue
|
|
678
|
-
results.push({
|
|
679
|
-
frameworkId: framework.id,
|
|
680
|
-
scenario,
|
|
681
|
-
status: 'error',
|
|
682
|
-
diagnosis: 'The selected check produced no result. This is a validator orchestration error.',
|
|
683
|
-
evidence: { validationIncomplete: true, validationOrchestrationFailed: true },
|
|
684
|
-
artifacts: [],
|
|
685
|
-
})
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Returns selected advanced scenario ids.
|
|
692
|
-
*
|
|
693
|
-
* @param {Set<string>} scenarios selected scenarios
|
|
694
|
-
* @returns {string[]} advanced scenarios
|
|
695
|
-
*/
|
|
696
|
-
function getAdvancedScenarios (scenarios) {
|
|
697
|
-
return Object.keys(SCENARIOS).filter(scenario => scenario !== BASIC_REPORTING && scenarios.has(scenario))
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* Returns all selectable scenarios.
|
|
702
|
-
*
|
|
703
|
-
* @returns {string[]} scenario ids
|
|
704
|
-
*/
|
|
705
|
-
function getSelectableScenarios () {
|
|
706
|
-
return [...Object.keys(SCENARIOS), CI_WIRING]
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Normalizes scenario selection.
|
|
711
|
-
*
|
|
712
|
-
* @param {string} scenario requested scenario
|
|
713
|
-
* @returns {Set<string>} effective scenarios
|
|
714
|
-
*/
|
|
715
|
-
function normalizeScenarioSelection (scenario) {
|
|
716
|
-
if (!getSelectableScenarios().includes(scenario)) throw new Error(`Unknown scenario: ${scenario}`)
|
|
717
|
-
if (scenario === BASIC_REPORTING || scenario === CI_WIRING) return new Set([scenario])
|
|
718
|
-
return new Set([BASIC_REPORTING, scenario])
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* Normalizes a framework target.
|
|
723
|
-
*
|
|
724
|
-
* @param {string} target target value
|
|
725
|
-
*/
|
|
726
|
-
function normalizeFrameworkTarget (target) {
|
|
727
|
-
const normalized = target.trim().replace(/(?<!:):+$/, '')
|
|
728
|
-
if (!normalized) throw new Error('Framework target cannot be empty.')
|
|
729
|
-
return normalized
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* Validates the output directory.
|
|
734
|
-
*
|
|
735
|
-
* @param {object} manifest loaded manifest
|
|
736
|
-
* @param {string} outputPath output path
|
|
737
|
-
*/
|
|
738
|
-
function validateOutputPath (manifest, outputPath) {
|
|
739
|
-
const root = path.resolve(manifest.repository.root)
|
|
740
|
-
const out = path.resolve(outputPath)
|
|
741
|
-
const relative = path.relative(root, out)
|
|
742
|
-
if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
743
|
-
throw new Error('Validation output directory must be a dedicated child of repository.root.')
|
|
744
|
-
}
|
|
745
|
-
return out
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Prevents incompatible CLI modes.
|
|
750
|
-
*
|
|
751
|
-
* @param {object} options parsed options
|
|
752
|
-
*/
|
|
753
|
-
function assertCompatibleModes (options) {
|
|
754
|
-
if (!options.runApprovedPlan) return
|
|
755
|
-
if (options.help || options.initManifest || options.printPlan || options.validateManifest) {
|
|
756
|
-
throw new Error('--run-approved-plan cannot be combined with another mode.')
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
/**
|
|
761
|
-
* Reads a required flag value.
|
|
762
|
-
*
|
|
763
|
-
* @param {string[]} argv arguments
|
|
764
|
-
* @param {number} index value index
|
|
765
|
-
* @param {string} flag flag name
|
|
766
|
-
*/
|
|
767
|
-
function requireValue (argv, index, flag) {
|
|
768
|
-
if (!argv[index]) throw new Error(`${flag} requires a value.`)
|
|
769
|
-
return argv[index]
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
* Prints CLI help.
|
|
774
|
-
*
|
|
775
|
-
*/
|
|
776
|
-
function printHelp () {
|
|
777
|
-
console.log(`Usage: node ci/validate-test-optimization.js [options]
|
|
778
|
-
|
|
779
|
-
--init-manifest
|
|
780
|
-
--validate-manifest
|
|
781
|
-
--print-plan
|
|
782
|
-
--run-approved-plan <approval.json> --sha256 <digest>
|
|
783
|
-
--manifest <path>
|
|
784
|
-
--out <path>
|
|
785
|
-
--framework <id>
|
|
786
|
-
--scenario <${getSelectableScenarios().join('|')}>
|
|
787
|
-
--keep-temp-files
|
|
788
|
-
--verbose`)
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
* Logs one phase transition.
|
|
793
|
-
*
|
|
794
|
-
* @param {object} framework framework entry
|
|
795
|
-
* @param {string} phase phase name
|
|
796
|
-
* @param {string} status status
|
|
797
|
-
*/
|
|
798
|
-
function logPhase (framework, phase, status) {
|
|
799
|
-
console.log(sanitizeConsoleText(`[test-optimization-validator] ${framework.id}: ${phase}: ${status}`))
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
/**
|
|
803
|
-
* Builds a non-runnable framework result.
|
|
804
|
-
*
|
|
805
|
-
* @param {object} framework framework entry
|
|
806
|
-
* @returns {object} result
|
|
807
|
-
*/
|
|
808
|
-
function getFrameworkStatusResult (framework) {
|
|
809
|
-
const blockerCategory = framework.blockerCategory || (
|
|
810
|
-
framework.status === 'requires_manual_setup'
|
|
811
|
-
? BLOCKER_CATEGORIES.PROJECT_SETUP_REQUIRED
|
|
812
|
-
: BLOCKER_CATEGORIES.VALIDATOR_LIMITATION
|
|
813
|
-
)
|
|
814
|
-
const domain = getBlockerDomain(blockerCategory)
|
|
815
|
-
return {
|
|
816
|
-
frameworkId: framework.id,
|
|
817
|
-
scenario: 'all',
|
|
818
|
-
status: 'skip',
|
|
819
|
-
diagnosis: framework.notes?.[0] || `Framework status is ${framework.status}.`,
|
|
820
|
-
evidence: {
|
|
821
|
-
blockerCategory,
|
|
822
|
-
domain,
|
|
823
|
-
frameworkStatus: framework.status,
|
|
824
|
-
validationIncomplete: true,
|
|
825
|
-
...(blockerCategory === BLOCKER_CATEGORIES.PROJECT_SETUP_REQUIRED
|
|
826
|
-
? {
|
|
827
|
-
blockedByProjectSetup: true,
|
|
828
|
-
...(framework.notes?.[0] ? { recommendation: framework.notes[0] } : {}),
|
|
829
|
-
}
|
|
830
|
-
: {
|
|
831
|
-
validatorAdapterUnavailable: true,
|
|
832
|
-
...(framework.notes?.[0] ? { recommendation: framework.notes[0] } : {}),
|
|
833
|
-
}),
|
|
834
|
-
},
|
|
835
|
-
artifacts: [],
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* Builds an unavailable runner result.
|
|
841
|
-
*
|
|
842
|
-
* @param {object} framework framework entry
|
|
843
|
-
* @param {string} unavailable missing file
|
|
844
|
-
* @returns {object} result
|
|
845
|
-
*/
|
|
846
|
-
function getUnavailableRunnerResult (framework, unavailable) {
|
|
847
|
-
return {
|
|
848
|
-
frameworkId: framework.id,
|
|
849
|
-
scenario: 'all',
|
|
850
|
-
status: 'skip',
|
|
851
|
-
diagnosis: `The direct runner is unavailable: ${unavailable}. Complete normal project setup and retry.`,
|
|
852
|
-
evidence: {
|
|
853
|
-
blockerCategory: BLOCKER_CATEGORIES.PROJECT_SETUP_REQUIRED,
|
|
854
|
-
blockedByProjectSetup: true,
|
|
855
|
-
unavailableRunner: unavailable,
|
|
856
|
-
validationIncomplete: true,
|
|
857
|
-
},
|
|
858
|
-
artifacts: [],
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Builds a static project blocker result.
|
|
864
|
-
*
|
|
865
|
-
* @param {object} framework framework entry
|
|
866
|
-
* @param {object} blocker static blocker
|
|
867
|
-
* @param {string} reportPath static report path
|
|
868
|
-
* @returns {object} result
|
|
869
|
-
*/
|
|
870
|
-
function getStaticFailure (framework, blocker, reportPath) {
|
|
871
|
-
const blockerCategory = blocker.blockerCategory || BLOCKER_CATEGORIES.PROJECT_SETUP_REQUIRED
|
|
872
|
-
return {
|
|
873
|
-
frameworkId: framework.id,
|
|
874
|
-
scenario: 'all',
|
|
875
|
-
status: 'error',
|
|
876
|
-
diagnosis: blocker.reason,
|
|
877
|
-
evidence: {
|
|
878
|
-
blockerCategory,
|
|
879
|
-
domain: getBlockerDomain(blockerCategory),
|
|
880
|
-
recommendation: blocker.recommendation,
|
|
881
|
-
staticDiagnosis: reportPath,
|
|
882
|
-
validationIncomplete: true,
|
|
883
|
-
...(blockerCategory === BLOCKER_CATEGORIES.PROJECT_SETUP_REQUIRED
|
|
884
|
-
? { blockedByProjectSetup: true }
|
|
885
|
-
: {}),
|
|
886
|
-
},
|
|
887
|
-
artifacts: [reportPath],
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* Builds a Basic Reporting not-reached result.
|
|
893
|
-
*
|
|
894
|
-
* @param {object} framework framework entry
|
|
895
|
-
* @param {string} diagnosis blocker diagnosis
|
|
896
|
-
* @param {string} reasonCode blocker id
|
|
897
|
-
* @param {string | undefined} blockerCategory blocker category
|
|
898
|
-
* @returns {object} result
|
|
899
|
-
*/
|
|
900
|
-
function getBasicNotReached (framework, diagnosis, reasonCode, blockerCategory) {
|
|
901
|
-
return {
|
|
902
|
-
frameworkId: framework.id,
|
|
903
|
-
scenario: BASIC_REPORTING,
|
|
904
|
-
status: 'skip',
|
|
905
|
-
diagnosis: `Basic Reporting was not reached: ${diagnosis}`,
|
|
906
|
-
evidence: {
|
|
907
|
-
...(blockerCategory ? { blockerCategory } : {}),
|
|
908
|
-
reasonCode,
|
|
909
|
-
validationIncomplete: true,
|
|
910
|
-
},
|
|
911
|
-
artifacts: [],
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
/**
|
|
916
|
-
* Builds a cleanup failure.
|
|
917
|
-
*
|
|
918
|
-
* @param {Error|undefined} error cleanup error
|
|
919
|
-
* @param {object} cleanup cleanup outcome
|
|
920
|
-
* @returns {object} result
|
|
921
|
-
*/
|
|
922
|
-
function getCleanupFailure (error, cleanup) {
|
|
923
|
-
const retained = (cleanup.filesRetained || 0) + (cleanup.directoriesRetained || 0)
|
|
924
|
-
const reason = error?.message || error ||
|
|
925
|
-
`${retained} temporary validation path${retained === 1 ? '' : 's'} remained after safe cleanup`
|
|
926
|
-
return {
|
|
927
|
-
frameworkId: 'validation-cleanup',
|
|
928
|
-
scenario: 'all',
|
|
929
|
-
status: 'error',
|
|
930
|
-
diagnosis: `Temporary validation files could not be removed safely: ${reason}`,
|
|
931
|
-
evidence: { cleanup, cleanupFailed: true, validationIncomplete: true },
|
|
932
|
-
artifacts: [],
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
/**
|
|
937
|
-
* Builds a top-level orchestration failure.
|
|
938
|
-
*
|
|
939
|
-
* @param {Error} error failure
|
|
940
|
-
* @returns {object} result
|
|
941
|
-
*/
|
|
942
|
-
function getOrchestrationFailure (error) {
|
|
943
|
-
const blockerEvidence = getValidationBlockerEvidence(error)
|
|
944
|
-
return {
|
|
945
|
-
frameworkId: 'validator',
|
|
946
|
-
scenario: 'all',
|
|
947
|
-
status: blockerEvidence ? 'blocked' : 'error',
|
|
948
|
-
diagnosis: error?.message || String(error),
|
|
949
|
-
evidence: blockerEvidence || { validationIncomplete: true, validationOrchestrationFailed: true },
|
|
950
|
-
artifacts: [],
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
module.exports = { filterFrameworks, main, normalizeFrameworkTarget, parseArgs }
|