diff --git a/.agents/rules/code-review/activation-and-metadata.md b/.agents/rules/code-review/activation-and-metadata.md index bec7e14d122..04474a562ba 100644 --- a/.agents/rules/code-review/activation-and-metadata.md +++ b/.agents/rules/code-review/activation-and-metadata.md @@ -41,7 +41,7 @@ - Old_id: claude-07 - Severity: P1 - Flag: Pick the marker that matches the cause. When one PR excludes tests for different causes, give each exclusion its own reason, and make each reason state the real cause. By default, markers other than `irrelevant` and `flaky` become a non-strict xfail, and `conftest.py` also records a fixture error as `xfailed`. When a marked test fails before its assertions, the reason must name that failure. -- Detect: A marker contradicts its cause, or several exclusions with different causes share one vague reason. A marked test fails during setup because of invalid configuration or a missing required secret that the marker does not describe. +- Detect: A marker contradicts its cause. Several exclusions with different causes share one vague reason or carry no reason. A marked test fails in setup on invalid configuration or a missing secret, and the marker does not say so. - ✅ Use `incomplete_test_app (weblog has no /ffe endpoint)` when the weblog does not implement the endpoint. - ❌ Use `missing_feature` for an endpoint that the weblog does not implement. Set `DD_TRACE_AGENT_PORT` to the literal `agent.port`, causing the library to exit at startup while the run reports an expected failure. - Ref: [Declaration decorators](../../../docs/edit/skip-tests.md#declaration-decorators) @@ -60,7 +60,7 @@ - Old_id: claude-06 - Severity: P0 - Flag: A feature whose docstring links a Feature Parity Dashboard entry must pass that id as `feature_id`, not `NOT_REPORTED_ID`. -- Detect: A feature in `utils/_features.py` links `feature-parity.us1.prod.dog/#/?feature=` and passes `feature_id=NOT_REPORTED_ID`. +- Detect: A feature in `utils/_features.py` links `feature-parity.us1.prod.dog/#/?feature=` and passes `feature_id=NOT_REPORTED_ID`. A PR adds a feature that passes `feature_id=NOT_REPORTED_ID` and has no dashboard link. - ✅ The docstring links `?feature=544` and the code passes `feature_id=544`. - ❌ The docstring links `?feature=544` and the code passes `feature_id=NOT_REPORTED_ID`. - Ref: [Create a feature](../../../docs/edit/features.md#hello-world-test) @@ -74,3 +74,8 @@ - ✅ Add, remove, or rename the workflow step in the same PR as the scenario. - ❌ Add a named scenario without its workflow step, even when its scenario groups are otherwise valid. - Ref: [End-to-end testing rules](../end-to-end-testing.md) + +### META-011: Link a test class to the RFC that it implements. +- Severity: P1 +- Flag: A test class that implements an RFC and has no `@rfc` decorator. If an RFC defines the behavior that a test class checks, the class must carry `@rfc("")` from `utils`. +- Detect: A new test class checks behavior from an RFC that the PR or the feature names. The class has no `@rfc` decorator. diff --git a/.agents/rules/code-review/infrastructure-and-conventions.md b/.agents/rules/code-review/infrastructure-and-conventions.md index a4b93d012e0..052b9d6a36e 100644 --- a/.agents/rules/code-review/infrastructure-and-conventions.md +++ b/.agents/rules/code-review/infrastructure-and-conventions.md @@ -73,3 +73,8 @@ - ✅ Add the `/new_endpoint` route to the weblogs and its section to `end-to-end_weblog.md` in the same pull request. - ❌ Add a field to the response of a parametric endpoint, and leave `parametric_weblog.md` unchanged. - Ref: [Weblogs](../../../docs/understand/weblogs/README.md) + +### INFRA-011: Keep local build output out of the Docker build context. +- Severity: P1 +- Flag: A new weblog or test app that builds locally into a folder must exclude that folder in `.dockerignore`. Add the pattern in the same pull request. Examples are a cargo `target/`, a dotnet `bin/` or `obj/`, or a `node_modules/`. +- Detect: A new app under `utils/build/docker/` has a local build output folder, and no `.dockerignore` pattern excludes it. diff --git a/.agents/rules/code-review/test-effectiveness.md b/.agents/rules/code-review/test-effectiveness.md index 4a68ef64fef..2e62e9dda05 100644 --- a/.agents/rules/code-review/test-effectiveness.md +++ b/.agents/rules/code-review/test-effectiveness.md @@ -28,7 +28,7 @@ - Old_id: claude-13 - Severity: P0 - Flag: A test of behavior that does not depend on the trace encoding must give the same result for v0.4, v0.5, and v1.0 payloads. Compare trace IDs with `trace_id_equals()`, read the sampling priority with `get_sampling_priority()`, and filter intake requests with `interfaces.library.trace_paths`. Use `is_same_boolean()` only when the contract accepts `True`, `1`, and `"true"` as the same value. A test of the wire format itself must check the exact fields and types of its encoding. -- Detect: A test that is not about the encoding compares raw fields, as in `span["trace_id"] == expected` or `meta[key] == "true"`. A test reads a sampling priority field directly. A path filter lists only `/v0.4/traces` or `/v0.5/traces`. +- Detect: A test that is not about the encoding compares raw fields, as in `span["trace_id"] == expected` or `meta[key] == "true"`. A test reads a sampling priority field directly. A path filter lists only `/v0.4/traces` or `/v0.5/traces`. A test mocks Agent responses for some paths of `interfaces.library.trace_paths`, but not for all of them. - Not when: The test is explicitly validating the wire format itself. - ✅ `assert span.trace_id_equals(int(expected_id))`. - ❌ `assert span["trace_id"] == int(expected_id)`. @@ -55,7 +55,12 @@ - Old_id: codex-21 - Severity: P1 - Flag: When the test uses a fake Agent or backend, its request and response must match the real service. Check that shape in the spec, the real code, or a real capture. Do not copy the expected JSON from the fake. A deliberately broken response belongs only in the test of that error. -- Detect: The self-test imports every expected value from the fake. The fake returns a bare body where the real service uses an envelope. The fake sends config for a product the client did not ask for. +- Detect: The self-test imports every expected value from the fake. The fake returns a bare body where the real service uses an envelope. The fake sends config for a product the client did not ask for. A test asserts a request property, such as a content type, that the test agent changes before capture. - Not when: The test intentionally validates a deliberately broken response. - ✅ Return the real backend envelope under `data.attributes`, and derive the check from the real contract. - ❌ Return the flag config as the whole body and make the self-test expect that same body. + +### TEST-008: Make each assertion able to fail on the defect it targets. +- Severity: P0 +- Flag: Each assertion must fail when the SDK lacks the behavior under test. A status code proves only that a route exists. If the endpoint catches every error and returns OK, the status proves nothing. Check each subject, case, and expected field on its own, not as one sum. If sibling tests use a shared assertion helper, a new test must use it too. Do not loosen a helper to accept output that breaks the contract. +- Detect: A regex accepts empty groups, so a missing value still matches. A test asserts only `status_code == 200` on an endpoint that catches every exception. A count sums several subjects, so data from the wrong subject still passes. A type check covers one side only, so `1 == True` passes. A fixture carries expected fields that the runner never asserts. A helper adds a fallback for one SDK that breaks the payload contract.