Skip to content

[Demo option D: scan, then a ruff card] Review learning: rule changes from 2026-10-20 to 2026-11-18 - #8619

Closed
robertomonteromiguel wants to merge 4 commits into
mainfrom
review-learning-demo/option-d
Closed

robertomonteromiguel wants to merge 4 commits into
mainfrom
review-learning-demo/option-d

Conversation

@robertomonteromiguel

Copy link
Copy Markdown
Collaborator

Important

Demo, not to merge. Option D: same changes as #8614, #8616 and #8617. The workflow does not process comments on this PR.

Note

Monthly review learning. 8 changes to the code review rules, learned from the 364 PRs merged from 2026-10-20 to 2026-11-18.
Review them in Files changed. ok keeps a change, discard puts the rule back, a suggestion replaces lines. Once a day, a workflow applies the answers and replies.

This month What you do
New rules META-010 · TEST-008 · TEST-009 Read the card. These rules do not exist yet.
New cases META-006 · INFRA-011 · LIFE-002 · TEST-001 · TEST-004 Read the line under New cases. Open it only for the example.
Wording none Nothing this month. Same meaning, other words. With no comment, they stay.
Merged PRs With a human review Verified lessons Changes in this diff Held back, one PR only
364 283 47 8 8

New rules

Each card is the shape of a ruff rule: what it does, why it is bad, a bad line, a good line.

META-010

Match each manifest version range to the versions that have the behavior. · activation-and-metadata · P1

What it does. A manifest range starts at the first release that has the behavior, on every weblog the entry covers, and it stops before a later version that replaces that behavior.

Why is this bad. No rule checks the range. META-002 and META-007 only cover the version prefix and the dev or RC version. Three PRs set a range that was too wide.

Example

tests/parametric/test_ffe/test_serial_id_metadata.py: v2.10.1

Use instead

tests/parametric/test_ffe/test_serial_id_metadata.py: v2.11.0-dev

v2.10.1 keeps the legacy dd.serialId class active on every later Go version.

Evidence

  • #7844 "This activates the legacy dd.serialId class for every Go version from v2.10.1."
  • #8093 "Gate this class at v2.11.0-dev for Go."
  • #8457 "the 1.67.0 lower bound on java-alb, java-alb-multi, java-apigw-rest and java-function-url would never be exercised"

TEST-008

Assert every expectation that the contract defines. · test-effectiveness · P0

What it does. A test checks each expectation its contract defines, on each subject. It does not merge subjects into a sum, and it does not drop the error path.

Why is this bad. A summed count still passes when one subject is wrong. No current rule names that gap.

Example

counts[case["flag"]] = counts.get(case["flag"], 0) + case["expected_count"]

Use instead

Validate the shared flag separately for the opted-out subject and the allowed subject.

Evidence

  • #8080 "Please validate the shared flag separately for the opted-out and allowed subjects."
  • #8080 "Please add opt-out cases on the evaluation error path."
  • #8093 "Route this test through _assert_context_evaluation, as its two siblings do."
  • #8139 "The imported split-feature cases include result.features expectations for hook, exposure, and evaluation metadata, which this runner doesn’t assert."
  • #7843 "Shouldn't we still be validating the git tags are only on the first span for them?"

TEST-009

Prove that the test reached the behavior under test. · test-effectiveness · P0

What it does. The test fails when the behavior under test does not run. The app must not swallow an error and report success.

Why is this bad. A status check then proves only that the route exists. This is not the absence case of TEST-002.

Example

} catch (Exception ignored) {}

Use instead

Accept only the expected exception. Any other failure returns HTTP 500.

Evidence

  • #8182 "checks only prove that the proxy and Handler routes exist"
  • #8128 "the cookie only goes into multiValueHeaders, while parse_alb_lambda_output(..., multi=False)"
  • #8398 "could you add a positive assertion inside the same test"

New cases

The rule already exists. The line is the case we add. Open it for one bad line, one good line, and the quotes.

META-006 — a marker with no reason, a file-wide skip, a flaky marker on a wrong expectation, or a declaration left behind after its endpoint exists

Added to Detect

  • A declaration has no reason.
  • A file-level declaration also deactivates tests that pass.
  • A flaky declaration hides a wrong test expectation.
  • A PR adds the endpoint that an incomplete_test_app declaration names, and the declaration stays.

Example

tests/appsec/test_event_tracking.py: incomplete_test_app (Event-tracking endpoints not implemented)

Use instead

Remove the declaration once /add_event exists, or name the real cause and let the tests that pass run.

Evidence

  • #8352 "Would you consider declaring these per class with the real cause, or letting the ones that pass run?"
  • #8457 "These new missing_feature entries have no reason."
  • #8371 absence, culprit #8348
  • #7843 "now that /add_event exists do you need to update"
INFRA-011 — a script that continues after a failed command, or a swallowed import that looks like a missing feature

Added to Detect. The current line only names bash (2>/dev/null, || true, a pipeline with pipefail off).

  • A PowerShell provisioning script continues after a failed command, such as Restart-Service.
  • A weblog catches the ImportError of a dependency, so a broken install looks like a missing feature.
  • A build gates an install on a file path inside a package.

Example

Restart-Service -Name datadogagent -Force

Use instead

Stop when the restart fails. A failed restart leaves the agent off the mocked backend.

Evidence

  • #8071 "Restart-Service -Name datadogagent -Force fails with Cannot stop datadogagent service, but the script continues."
  • #8441 "Checking for the mcp.py file feels a bit fragile"
LIFE-002 — a timeout that ends before the last flush, an exact flush count, or a wait that returns as soon as the expected count arrives

Added to Detect. The current line only names a fixed sleep and a poll with no deadline.

  • The flush timeout ends before the last periodic flush that the test counts.
  • A test requires an exact count of telemetry points or stats requests that periodic flushes send.
  • A wait returns as soon as the expected count arrives, and the test then asserts that no extra item exists.

Example

A wait returns as soon as 2 spans show up, so a third span in a later flush is never seen.

Use instead

Wait long enough to see a later flush, then assert the count.

Evidence

  • #8093 "Set library_interface_timeout=15 here."
  • #8352 "so it depends on every metric point being flushed before teardown"
  • #8441 "This returns as soon as 2 spans show up, so a third evaluation landing in a later flush wouldn't be caught."
  • #8519 "I think this is a valid point."
TEST-001 — an exact stats-request count, a timing-dependent outcome, or a comparison against a json.dumps string

Added to Detect. The current line covers exact sampled flags, len(tracestate) == 1, raw x-datadog-tags, and a short marker searched in a whole payload.

  • A test requires exactly one stats request, or an exact telemetry count, although periodic flushes can split or delay the data.
  • A test requires a timing-dependent outcome, such as at least one dropped trace under a rate limit.
  • A test compares serialized JSON with a json.dumps string instead of the parsed value.

Example

assert len(requests) == 1, "Only one stats request is expected"

Use instead

Assert the stats payload. A periodic flush may split it into more than one request.

Evidence

  • #8519 "I think this is a valid point."
  • #8352 "so it depends on every metric point being flushed before teardown"
  • #7425 "dropped >= 1 will flake"
  • #8441 "Once nodejs implements this, JSON.stringify gives"
TEST-004 — a check that treats 1 as True, or rejects a valid 1.0

Added to Detect. The current line covers raw field comparisons, a sampling-priority field read directly, and a path filter that lists only /v0.4/traces or /v0.5/traces.

  • A numeric or boolean check ignores Python coercion, so it accepts 1 for True or rejects a valid 1.0.

Example

assert attributes[ATTRIBUTE] == expected

Use instead

Compare bools as bools, in both directions, and accept 1.0 where the value may be a float.

Evidence

  • #8080 "Please compare bool-ness in both directions here."
  • #8130 "I think it could be a float with value 1.0 or 0.0 and not pass the test here"

Wording

Same meaning, other words. You can leave these closed.

Nothing this month. A line in this lane would read like this, and it would not be a new case:

TEST-001 — "A test that sums the counts of every subject" becomes "A test sums the counts of every subject."

8 more changes, each from one PR. They stay out of the diff. Comment add INFRA-014 to apply one.
Rule Change The new case Evidence
INFRA-005 sharpen Detect An upload if depends on a step that some runs skip, so those runs save no logs. #8313
INFRA-007 sharpen Detect A build script downloads a file with curl or wget and has no retry. #8202
INFRA-008 sharpen Flag Pin transitive packages whose versions change recorded output, such as VCR cassettes. #8441
INFRA-014 new rule A scenario must detect its host. It must not require an opt-in variable the user has to know. #8064
INFRA-015 new rule Require a secret only when the selected configuration uses it. A mocked backend must not require real backend keys. #8071
LIFE-003 sharpen Detect After a restart, read telemetry only from the new runtime id. #7464
TEST-005 sharpen Detect An assertion helper must not accept one library's output in place of the specified output. #7876
TEST-007 sharpen Detect A fake must not reject extra parameters that the real service accepts. #8399
6 defects that a rule already describes
  • META-009 · a named scenario has no step in .github/workflows/run-end-to-end.yml. #8080
  • INFRA-010 · new weblog endpoints are missing from end-to-end_weblog.md. #7425
  • INFRA-006 · a new base image that the mirroring job does not pick up. #8121
  • INFRA-011 · find with 2>/dev/null piped to wc -l is already the example in the rule. #8572
  • TEST-005 · an expected field depends on context.library inside the assertion. #8306
  • TEST-002 · absence tests have no enabled control, and the PR adds a skip.yml entry. #8144
How to answer, and the rest of the run

On each rule, in Files changed

  • 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, for example discard LIFE-002.
  • A suggestion block: replace those lines.
  • add INFRA-014: apply one folded change. Name the rule id.
  • Any other comment on a rule: an agent edits that rule as you ask.
  • A change is in the diff when its evidence comes from 2 or more distinct PRs.
  • If a discard should hold next month, write it in the rule, for example as Not when:. Later 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
INFRA-013 new rule not enough evidence needs a fix, an applied maintainer correction, or two PRs

Not rule material

  • #8153 human only: unit tests of the test classes were judged unnecessary, because those classes already run in CI.
  • #8266 outside context: an SDK reject behavior contradicted an external RFC.
  • #8344 outside context: dotnet tests were disabled on Slack, outside the repository, to unblock a merge.
  • #8324 outside context: Akka HTTP and Play tests were enabled while they still depend on an unmerged dd-trace-java PR.

Coverage. test-effectiveness 11 · lifecycle-and-isolation 4 · activation-and-metadata 4 · infrastructure-and-conventions 14. 65 candidates went to another lens. 0 quotes failed to match. 16 fixes were linked to their cause. 33 proposals were considered.

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/infrastructure-and-conventions.md             @DataDog/system-tests-core
.agents/rules/code-review/lifecycle-and-isolation.md                    @DataDog/system-tests-core
.agents/rules/code-review/test-effectiveness.md                         @DataDog/system-tests-core

@robertomonteromiguel
robertomonteromiguel deleted the review-learning-demo/option-d branch November 20, 2026 15:42
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