ci/runbook.md
Use this runbook when Test Optimization breaks a customer's JavaScript tests or sends no test data.
The validator answers two separate questions:
dd-trace report one real project test when initialized correctly?It also checks Early Flake Detection, Auto Test Retries, and Test Management when Basic Reporting succeeds.
Recommended agent prompt:
From the current repository, resolve
dd-traceonly withnode -p "require.resolve('dd-trace/package.json', { paths: [process.cwd()] })", then read and execute the adjacentci/runbook.md. Do not search outside this repository. Reading the single resolved package path, including its symlink target, is allowed.
dd-trace; do not search sibling repositories, home
directories, package-manager stores, or unrelated temporary directories.node <repository-contained-runner> <one-test-file>.node <repository-file> test runner; the resulting direct command is shown in the approval plan.This boundary intentionally prefers an incomplete result over interpreting an arbitrary command language.
From the customer repository, resolve the installed package without searching outside the repository. For example:
node -p "require.resolve('dd-trace/package.json', { paths: [process.cwd()] })"
Then run its validator:
node ./node_modules/dd-trace/ci/validate-test-optimization.js --init-manifest
The scaffold performs bounded static discovery. For each supported framework, it records:
Live adapters exist for Cucumber, Cypress, Jest, Mocha, Playwright, and Vitest.
The scaffold excludes type declarations and explicit type-test conventions. For Jest, Mocha, and Vitest it prefers
normal *.test.* or *.spec.* files. A non-suffixed file is eligible only under a literal conventional test root; a
bare test.* file may also directly import the selected framework. If every confident Cypress representative directly
accesses a localhost application, that framework requires setup; discovery does not start the application.
The manifest is data, not an execution plan. Do not edit the scaffolded runner, representative test, generated-test
strategy, or validator settings. Do not add argv, shell commands, package scripts, setup commands, fallback tests, or
wrapper commands. The only agent-edited section is ciWiring. If the scaffold cannot select a direct runner or one
representative file, leave that framework incomplete.
If ciDiscovery.reviewRequired is true, inspect only ciDiscovery.reviewTargets, in order. Stop after identifying one
relevant test job for each runnable framework.
Record only inert evidence in that framework's ciWiring:
configFile: absolute path to the CI file;job key and optional literal step;command: only the exact literal command bytes from that job's execution field; put explanations in evidence;workingDirectory: the effective directory, including a statically known provider default;initialization.status and short evidence;transport.mode and short evidence;NODE_OPTIONS, Datadog configuration, operating system, shell, or transport.Set reviewComplete to true only when configuration relevant to initialization, runner invocation, and transport is
resolved. An ordinary Node.js version matrix is not unresolved evidence unless it changes one of those facts.
Record initialization and transport independently of command indirection: use not_configured when the selected job
contains no visible dd-trace/ci/init, and none when it declares neither agentless transport nor an Agent. GitHub
repository and organization secrets or variables are not ambient job environment; do not list them as unresolved
unless the workflow explicitly references them. Do not carry evidence from unselected jobs into the selected job.
Do not add generic wrapper-propagation uncertainty when a direct or bounded package-script path already proves that
initialization is absent.
The CI audit is deliberately conservative:
package.json.
Lifecycle scripts are disclosed but are never executed.dd-trace/ci/init in its checksum-bound CI job can
produce a confirmed finding.NODE_OPTIONS reset can produce a confirmed finding.No CI or package command is executed.
Validate the manifest without running project code:
node ./node_modules/dd-trace/ci/validate-test-optimization.js \
--manifest ./dd-test-optimization-validation-manifest.json \
--validate-manifest
Finalize discovery and CI evidence before printing the complete approval plan:
node ./node_modules/dd-trace/ci/validate-test-optimization.js \
--manifest ./dd-test-optimization-validation-manifest.json \
--out ./dd-test-optimization-validation-results \
--print-plan
The plan shows every direct runner command, selected test, working directory, timeout, temporary file and source, cleanup target, artifact location, and the final checksum-bound validator command.
Present the complete delimited plan in the next user-facing message. Ask exactly once:
Approve executing exactly the plan above?
Do not run more discovery while waiting. After printing the plan, do not edit the manifest. Any correction or retry requires a fresh plan and fresh approval.
After approval, run only the checksum-bound command printed in the plan. Do not modify it, add setup, change permissions, or substitute a package script.
If the agent platform offers a narrowly scoped native permission for that exact command, request it once. If the platform hard-denies the command, do not retry with a bypass or broader allowlist. Give the exact command to the user to run in a normal project terminal, then interpret the generated report.
The validator:
Each framework is independent. A missing browser, runner, build artifact, service, localhost permission, or other prerequisite leaves only that framework incomplete.
Lead with the strongest actionable conclusion:
dd-trace can report in this project; fix the identified CI configuration.dd-trace compatibility bug; use the clean confirmation and debug
artifacts for engineering investigation.dd-trace failure.ECONNREFUSED: the project application is unavailable. Start it through
the project's normal setup before creating a fresh plan; the validator does not start it.Advanced checks are useful after Basic Reporting and do not depend on a conclusive CI audit.
Report:
dd-test-optimization-validation-results/report.md.Exit codes are:
0: completed without a confirmed problem;1: completed with a confirmed actionable problem;2: incomplete or blocked;3: validator implementation or orchestration error.A nonzero exit code does not by itself mean dd-trace is broken.
After presenting the report, stop. Do not repair evidence, inspect validator internals, or retry without a fresh plan
and approval.