Skip to content

Review learning: rule changes from 2026-11-03 to 2026-11-22 - #8648

Open
dd-apm-ecosystems[bot] wants to merge 4 commits into
mainfrom
review-learning/run-system-tests-2026-11-03-c99f585f
Open

dd-apm-ecosystems[bot] wants to merge 4 commits into
mainfrom
review-learning/run-system-tests-2026-11-03-c99f585f

Conversation

@dd-apm-ecosystems

Copy link
Copy Markdown

Note

Monthly review learning. 3 changes to the code review rules, learned from the 247 PRs merged from 2026-11-03 to 2026-11-22.
Review them in Files changed, and answer on each rule: ok, discard, a suggestion, or a comment. Once a day, a workflow applies the answers and replies.

Merged PRs With human review Fixes linked to their cause Verified lessons Proposals Changes in this PR
247 183 12 32 33 3

🆕 New rules (1)

Rules that the review does not have yet. Open the last cell of a row for what it does, why, a bad and a good example, and the evidence.

RuleLensChangeEvidenceWhy, and examples
LIFE-005 lifecycle-and-isolation new rule: Do not tie counts to one flush or one bucket. #8352 · #8441 · #8519
Three pull requests show exact counts that depend on flush or bucket timing.

What it does: Telemetry, stats, and spans can arrive over several flushes and time buckets. If a test asserts an exact count, it must merge all payloads and buckets. The wait must also last long enough for late payloads to arrive.

Why is this bad? Three pull requests show exact counts that depend on flush or bucket timing. One test assumed a single 10s stats bucket. One asserted a scenario-wide telemetry count that races the flush interval. One stopped waiting once the expected span count showed up. No existing rule names this defect.

Example

            for metric in series
            if metric.get("type") == "count"
            and "event_type:custom" in metric.get("tags", ())
            and "sdk_version:v2" in metric.get("tags", ())
            for point in metric["points"]
        )
        assert expected_count > 0, "No custom-event v2 requests found in traces"
        assert actual_count == expected_count, (actual_count, expected_count, series)

Use instead

Merge stats entries across all requests and buckets by aggregation key, then sum the counters.

Evidence:

  • #8352 correction: "so it depends on every metric point being flushed before teardown"
  • #8441 correction: "This returns as soon as 2 spans show up, so a third evaluation landing in a later flush wouldn't be caught."
  • #8519 miss (culprit #5543)

🔧 Existing rules, tuned (2)

Rules that exist, with a new case, a new exception, or better words. The Change column says which. Open the last cell of a row for the details.

RuleLensChangeEvidenceWhy, and examples
META-006 activation-and-metadata sharpen Detect #8352 · #8371 · #8457
META-006 requires a marker and reason that match the real cause, but its Detect line misses three cases.

What it does: 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. A declaration has no reason in parentheses. A file-level declaration hides classes that pass or that fail for other causes. A flaky declaration hides a deterministic bug in the test logic.

Why is this bad? META-006 requires a marker and reason that match the real cause, but its Detect line misses three cases. In one, missing_feature entries had no reason. In another, a whole file was declared incomplete_test_app and that hid passing classes. In the third, a flaky declaration hid a deterministic tag assertion bug.

Example

        alb-multi: irrelevant (function-url event type does not support path params)
        function-url: irrelevant (function-url event type does not support path params)
  tests/appsec/test_conf.py::Test_ConfigurationVariables_New_Obfuscation: v8.113.0
  tests/appsec/test_event_tracking.py: incomplete_test_app (Event-tracking endpoints not implemented)

Use instead

The fix removed the flaky declarations and added adjust_meta_checks_for_schema, which expects the _dd.p.ts tag when the span carries an API Security schema.

Evidence:

  • #8352 correction: "Would you consider declaring these per class with the real cause, or letting the ones that pass run?"
  • #8371 absence (culprit #8348)
  • #8457 correction: "These new missing_feature entries have no reason."
LIFE-002 lifecycle-and-isolation sharpen Detect #8323 · #7464
The ffe_start and ffe_evaluate POSTs had no HTTP timeout.

What it does: A setup or test uses a fixed sleep, polls without a deadline, or increases an arbitrary delay instead of waiting for an observable condition. An HTTP call to the test app has no timeout, so a silent app blocks the test and its retry deadline. A wait uses a shorter timeout than other call sites of the same helper.

Why is this bad? The ffe_start and ffe_evaluate POSTs had no HTTP timeout. That is an unbounded wait that the current Detect wording, which only mentions polling, does not catch. Separately, an app-started wait used half the usual budget and could fail on a busy CI runner.

Example

        except BaseException as error:
            # Stop the server before the executor joins its worker: /ffe/start
            # may still be waiting for configuration that will never arrive.
            try:
                test_library.terminate()
            except Exception as cleanup_error:
                error.add_note(f"Failed to terminate the test application: {cleanup_error}")
            raise

Evidence:

  • #8323 correction: "Please give the POST a finite timeout and add a control where termination fails."
  • #8323 correction: "Please pass timeout=self.timeout in ParametricTestClientApi.ffe_evaluate()"
  • #7464 correction: "Other wait_for_telemetry_event("app-started", ...) call sites in this repo"
13 more changes with evidence from one PR only. They stay out of the diff. Comment add <ID> to apply one.
Rule Lens Change Why Evidence
META-010 activation-and-metadata new rule: Validate a lowered version on every weblog it activates. No rule covers a version gate whose evidence is narrower than the set of weblogs that the entry activates. #8457
INFRA-007 infrastructure-and-conventions sharpen Detect INFRA-007 already asks for a retry on brittle fetches. #8202
INFRA-005 infrastructure-and-conventions sharpen Detect The upload step used !cancelled() but also required the weblog build to succeed, so PARAMETRIC runs saved no logs. #8313
INFRA-013 infrastructure-and-conventions new rule: Implement backend behavior in the shared mocked backend. No rule in any lens says where mocked backend behavior must live. #8266
INFRA-014 infrastructure-and-conventions new rule: Do not hide broken weblog dependencies. INFRA-011 covers hidden shell errors only. #8441
LIFE-003 lifecycle-and-isolation sharpen Detect The root cause is a helper that reads telemetry from the shared test agent without scoping it to the restarted runtime. #7464
TEST-001 test-effectiveness sharpen Detect The flag already forbids counts that the protocol does not define. #8519
TEST-001 test-effectiveness sharpen Flag Comparing a serialized JSON string to Python json.dumps output rejects valid output from other tracers because of separator choices. #8441
TEST-004 test-effectiveness sharpen Flag A check relaxed for v1 payload-level git tags dropped the strict first-span-only check for v0.4 and v0.5 too. #7843
TEST-007 test-effectiveness sharpen Flag The mock could drift from the shared evaluation vectors without failing CI. #8304
TEST-007 test-effectiveness sharpen Detect The mock backend checked the whole query for strict equality and returned 404 for a client capability parameter, so SDK tests failed with PROVIDER_NOT_READY. #8399
TEST-008 test-effectiveness new rule: Do not treat a failed command as an empty result. No rule covers a test that treats a failed container exec like an empty result. #8578
TEST-009 test-effectiveness new rule: Check a run-wide guarantee over the whole run. Test_V1PayloadByDefault was narrowed to one request, so a tracer that falls back to v0.4 later in the run would pass. #7843

META-010 · new rule: Validate a lowered version on every weblog it activates. · activation-and-metadata

No rule covers a version gate whose evidence is narrower than the set of weblogs that the entry activates.

Proposed:

META-010: Validate a lowered version on every weblog it activates.

  • Severity: P1
  • Flag: A lowered manifest version for all weblogs needs evidence for each weblog variant that it activates. If the evidence covers one variant only, scope the entry to the validated variants.
  • Detect: A manifest lowers a version for all weblogs. The PR validates it on one weblog variant only.
  • ✅ Lower the version only for the weblog variants that the PR validated.
  • ❌ Lower Test_Lfi_StackTrace to v1.67.0 for all weblogs after a run on API Gateway v2 only.

Proposed severity: P1. An unvalidated activation shows up as visible failures on other variants and does not hide any coverage.

Evidence:

  • #8457 correction: "If I read the description correctly, 1.67.0 was validated on API Gateway v2 only"

INFRA-007 · sharpen Detect · infrastructure-and-conventions

INFRA-007 already asks for a retry on brittle fetches. Its Detect only names CI steps that pull from a registry, so it missed a base-image build script that runs curl on a GitHub tarball with no retry.

Current:

A CI step pulls or installs from a registry on every run, and a base image already has those files. The pull skips a mirror that exists. The remaining registry command has no retry.

Proposed:

A CI step pulls or installs from a registry on every run, and a base image already has those files. The pull skips a mirror that exists. The remaining registry command has no retry. A build script or Dockerfile downloads a remote file with curl or wget, and the command has no retry option such as --retry.

Evidence:

  • #8202 correction: "can you add a retry policy"

INFRA-005 · sharpen Detect · infrastructure-and-conventions

The upload step used !cancelled() but also required the weblog build to succeed, so PARAMETRIC runs saved no logs. The current Detect does not cover extra conditions on the outcome of another step.

Current:

A required upload, tag, or cleanup has no if, or it uses if: always(). In one set -e script it follows a command that can fail, and no trap runs it.

Proposed:

A required upload, tag, or cleanup has no if, or it uses if: always(). In one set -e script it follows a command that can fail, and no trap runs it. The if of a required upload also tests the outcome of another step. Then a run that skips or fails that step saves no logs.

Evidence:

  • #8313 correction: "with parametric, you won't have any logs saved"

INFRA-013 · new rule: Implement backend behavior in the shared mocked backend. · infrastructure-and-conventions

No rule in any lens says where mocked backend behavior must live. A maintainer asked to move the endpoint behavior from the test into the shared mocked backend, and the author did it.

Proposed:

INFRA-013: Implement backend behavior in the shared mocked backend.

  • Severity: P1
  • Flag: Implement the behavior of an official backend endpoint in the shared mocked backend under utils/mocked_backend/. A test must not add that handler itself.
  • Detect: A test file calls mocked_backend.add_handler to emulate an official backend endpoint.
  • ✅ Add the behavior to utils/mocked_backend/_backend_ffe.py, and let the test request it.
  • ❌ mocked_backend.add_handler("GET", f"{RULES_CONFIG_PATH}/{channel}", handle_rules) inside a test.

Proposed severity: P1. A handler defined in one test duplicates the mock and can drift from it, but it does not by itself hide a failure.

Evidence:

  • #8266 correction: "can you add it directly in the mocked backend, rather dynamically in a test ?"

INFRA-014 · new rule: Do not hide broken weblog dependencies. · infrastructure-and-conventions

INFRA-011 covers hidden shell errors only. No rule covers weblog code that hides a broken dependency behind a broad ImportError handler. The author applied the requested find_spec gate.

Proposed:

INFRA-014: Do not hide broken weblog dependencies.

  • Severity: P0
  • Flag: A broken dependency must stop the weblog at startup. The weblog must not catch a broad ImportError and answer 501. For an optional dependency, check it with find_spec. Then import it without a guard.
  • Detect: A weblog wraps imports in try and except ImportError. The endpoint then returns an error status, not a startup failure.
  • ✅ Gate the import on find_spec, and import the module without try.
  • ❌ except ImportError: around from mcp import ClientSession.

Proposed severity: P0. A swallowed import error turns a broken install into a 501 response, so the test fails or gets skipped for the wrong reason.

Evidence:

  • #8441 correction: "on anthropic>=0.84 this also swallows a broken mcp install"

LIFE-003 · sharpen Detect · lifecycle-and-isolation

The root cause is a helper that reads telemetry from the shared test agent without scoping it to the restarted runtime. Stale app-started data from the old runtime matched. LIFE-003 already requires matching the reply to its action, but its Detect only names request ids and config versions.

Current:

The wait accepts a trace or event whose request id is from an earlier request. It accepts a Remote Config acknowledgement for an older config version. Watching starts after the request. The test sends traffic as soon as Remote Config says "received".

Proposed:

The wait accepts a trace or event whose request id is from an earlier request. It accepts a Remote Config acknowledgement for an older config version. Watching starts after the request. The test sends traffic as soon as Remote Config says "received". After a restart of the test app, the test reads telemetry without filtering on the runtime id of the new process.

Evidence:

TEST-001 · sharpen Detect · test-effectiveness

The flag already forbids counts that the protocol does not define. Detect missed stats tests that assume one wall-clock bucket and flake at bucket boundaries.

Current:

A sampled-bit assertion requires exact flags 01. A test requires len(tracestate) == 1 or compares x-datadog-tags as a raw string. A redaction check searches an entire payload for a short marker such as 1234.

Proposed:

A sampled-bit assertion requires exact flags 01. A test requires len(tracestate) == 1 or compares x-datadog-tags as a raw string. A redaction check searches an entire payload for a short marker such as 1234. A stats test requires one time bucket or reads only bucket [0] of the stats payload.

Evidence:

TEST-001 · sharpen Flag · test-effectiveness

Comparing a serialized JSON string to Python json.dumps output rejects valid output from other tracers because of separator choices. The rule covers unrelated formatting, but its fields did not name this case.

Current:

When checking one protocol flag, mask that bit and accept other bits the protocol allows, unless the whole field is under test. When checking one member of a list field, such as a tracestate vendor or an x-datadog-tags entry, find that member. Do not require a count or an order that the protocol does not define. When checking for redaction leaks, use a distinctive marker or the relevant parsed field so unrelated payload values cannot count as leaked input.

Proposed:

When checking one protocol flag, mask that bit and accept other bits the protocol allows, unless the whole field is under test. When checking one member of a list field, such as a tracestate vendor or an x-datadog-tags entry, find that member. Do not require a count or an order that the protocol does not define. When checking for redaction leaks, use a distinctive marker or the relevant parsed field so unrelated payload values cannot count as leaked input. If a field holds serialized JSON, compare the parsed value. Do not compare it to the string that json.dumps produces.

Evidence:

  • #8441 correction: "Once nodejs implements this, JSON.stringify gives"

TEST-004 · sharpen Flag · test-effectiveness

A check relaxed for v1 payload-level git tags dropped the strict first-span-only check for v0.4 and v0.5 too. The rule covers encoding differences but did not say to keep the strict check for the other encodings.

Current:

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.

Proposed:

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. If one encoding allows a looser result, apply the looser check only to that encoding. Keep the strict check for the other encodings.

Evidence:

  • #7843 correction: "Shouldn't we still be validating the git tags are only on the first span for them?"

TEST-007 · sharpen Flag · test-effectiveness

The mock could drift from the shared evaluation vectors without failing CI. The only test that used it was xfail for every SDK, and the self-test checked only the selected keys.

Current:

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.

Proposed:

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. If every SDK marks the test that uses the mock as xfail or missing_feature, add a blocking self-test of the mock. That self-test must compare the full mock output with each shared vector, not only the selected keys.

Evidence:

  • #8304 correction: "Add a test-the-test check that each suite case file agrees with the mock."
  • #8304 correction: "Also compare the mock's normalized selection with each vector's sdk.selection."

TEST-007 · sharpen Detect · test-effectiveness

The mock backend checked the whole query for strict equality and returned 404 for a client capability parameter, so SDK tests failed with PROVIDER_NOT_READY.

Current:

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.

Proposed:

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. The fake compares the whole query to a fixed dict and rejects extra parameters that the real service accepts.

Evidence:

TEST-008 · new rule: Do not treat a failed command as an empty result. · test-effectiveness

No rule covers a test that treats a failed container exec like an empty result. The process discovery test could then drop real holders and pass for the wrong reason.

Proposed:

TEST-008: Do not treat a failed command as an empty result.

  • Severity: P0
  • Flag: A test must tell a failed container command from a command without a match. A failed command must fail the test.
  • Detect: The test skips the output when the exec fails, as it does when the command finds no match.
  • ✅ assert rc, f"pgrep -P {parent} exec failed: {out}"
  • ❌ if rc: candidates.extend(int(p) for p in out.split())

Proposed severity: P0. If an exec failure counts as an empty result, the test can pass without checking anything.

Evidence:

  • #8578 correction: "if rc: treats exec failures like pgrep no-match, so real holders can vanish from holders."

TEST-009 · new rule: Check a run-wide guarantee over the whole run. · test-effectiveness

Test_V1PayloadByDefault was narrowed to one request, so a tracer that falls back to v0.4 later in the run would pass. No existing rule names this loss of scope.

Proposed:

TEST-009: Check a run-wide guarantee over the whole run.

  • Severity: P0
  • Flag: A run-wide guarantee must hold for every captured payload of the run. Do not narrow its check to the request of one setup.
  • Detect: A test that forbids a fallback, such as a downgrade from v1 to v0.4 payloads, inspects only one request.
  • ✅ Check that no trace request of the run uses a v0.4 or v0.5 path.
  • ❌ self.r = weblog.get("/"), and the test checks only the payloads of that request.

Proposed severity: P0. If the check covers only one request, the test misses a fallback later in the run.

Evidence:

  • #7843 correction: "Is it possible a tracer could downgrade back down to v0.4 and we wouldn't catch it here?"
5 defects that a rule already describes
  • INFRA-008 · infrastructure-and-conventions: INFRA-008 already requires exact pins or a lockfile for every dependency that the weblog does not test, including the transitive dependencies of mcp. #8441
  • INFRA-011 · infrastructure-and-conventions: INFRA-011 already describes this exact `find ... #8572
  • INFRA-012 · infrastructure-and-conventions: INFRA-012 already flags a new weblog Dockerfile that starts with FROM python:3.11-slim and runs apt-get and pip install. #8554
  • TEST-002 · test-effectiveness: TEST-002 already asks for a positive control and names new skip.yml entries as a review signal. #8398
  • TEST-005 · test-effectiveness: A condition on context.library inside an assertion is the case that TEST-005 detects. #8306
How to answer, and run details

How to answer each change

  • Nothing, ok, LGTM or a thumbs up: keep the change.
  • discard or discard: <reason>: put the rule back as it is on main. Outside a review thread, name the rule: discard LIFE-005.
  • A suggestion block: replace those lines.
  • add <ID>: apply a folded change, for example one with evidence from one PR only.
  • Any other comment on a rule: an agent edits that rule as you ask.
  • A change goes into the diff when its evidence comes from 2 or more distinct PRs. Each change must also pass the evidence thresholds and lint.
  • If the reason of a discard holds for the future, write it in the rule, for example as Not when:. The next runs read the rules.

This PR only edits .agents/rules/code-review/. It never merges by itself: a person from system-tests-core approves it. The next monthly run publishes nothing while it is open.

Not applied

Rule Action Status Reason
META-011 new_rule not_enough_evidence needs a fix, an applied maintainer correction, or two PRs
INFRA-015 new_rule not_enough_evidence needs a fix, an applied maintainer correction, or two PRs

Human-only review and outside context: never rule material.

  • #8266 context: FFE flag-selection test encoded reject behavior that conflicts with the external flag-selection RFC and shared vectors.
  • #8324 context: Java manifest activation depends on an unmerged dd-trace-java change (PR 12901) for dev builds.
  • #8344 context: Dotnet manifest: OTEL_ENABLED startup-log tests disabled temporarily to unblock a dd-trace-dotnet merge; the easy-wins script will reactivate them.

Coverage: test-effectiveness 12 · lifecycle-and-isolation 6 · activation-and-metadata 4 · infrastructure-and-conventions 11. 63 candidates went to another lens. 1 candidates had a quote that does not match.

Run: the workflow run in Datadog.

@github-actions

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

.agents/rules/code-review/activation-and-metadata.md                    @DataDog/system-tests-core
.agents/rules/code-review/lifecycle-and-isolation.md                    @DataDog/system-tests-core

- 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, 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. A declaration has no reason in parentheses. A file-level declaration hides classes that pass or that fail for other causes. A `flaky` declaration hides a deterministic bug in the test logic.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, it should be simplified and rephrased :

Follow marker semantics :

  • Use irrelevant when the test will never be activated (not possible/ RFC explicitly says the feature is not supported)
  • Use missing_feature when the feature is not implemented
  • Use incomplete_test_app when the weblog lack an endpoint
  • Use flaky when the test outcome is not stable (whatever the reason)
  • Use bug when the feature is implemented, but the test fails deterministicly

Detect : anything (comments, weblog code, tracer code, RFC) contradicts the used marker.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edited META-006 in 76e3f04. I simplified Flag into the marker semantics the reviewer listed, made Detect flag any source that contradicts the marker, and cut the example of a failure during setup.

The review learning workflow answers once a day. It does not read this reply.

- Ref: [End-to-end test flow](../../../docs/understand/test-flow.md#end-to-end-scenario), [Flushing default behavior](../../../docs/edit/flushing.md#default-behavior)

### LIFE-005: Do not tie counts to one flush or one bucket.
- Severity: P0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set the severity to P1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edited LIFE-005 in 238102a. The severity of LIFE-005 is now P1, as the reviewer asked.

The review learning workflow answers once a day. It does not read this reply.

@robertomonteromiguel
robertomonteromiguel marked this pull request as ready for review November 23, 2026 16:40
@robertomonteromiguel
robertomonteromiguel requested a review from a team as a code owner November 23, 2026 16:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T16:43:37.050553Z 238102a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant