Skip to content

ci(pr-title): fail PRs carrying changes their title doesn't cover - #10029

Open
bengl wants to merge 1 commit into
masterfrom
bengl/pr-scope-check
Open

ci(pr-title): fail PRs carrying changes their title doesn't cover#10029
bengl wants to merge 1 commit into
masterfrom
bengl/pr-scope-check

Conversation

@bengl

@bengl bengl commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds a Validate PR scope step to the existing Pull Request Title workflow, backed by a new
scripts/pr-scope.js module, that fails a PR carrying changes its title doesn't cover. Four
deterministic rules:

Rule Fails when Allowed under
mixed-commit-type a commit's conventional type is outside the title's test, docs, ci, bench, chore commits support any change
mixed-commit-scope a commit's scope differs from the title's scope unscoped commits, or a title without a scope
formatting-only-file a modified file's hunks differ only in whitespace style, chore titles
rename-only-file a pure move with no content change style, chore, refactor, build, ci, test titles
scratch-artifact an added file is a development leftover (root-level report/log, agent-tool state dir, scratch-*/tmp.*, .orig/.rej, crash dump) never

Applying the scope-exception label skips the whole step, for the cases where a violation is deliberate.

Motivation

AGENTS.md (in #10028) asks that everything in a PR serve its title, but nothing enforced it, so drive-by
refactors, stray reformatting, unrequested file moves and development leftovers kept riding along with
scoped changes — each individually defensible, collectively inflating review surface and coupling
unrelated risk into one revert unit.

Every rule keys off evidence the author already supplied (commit types, file status, whitespace-only
hunks) rather than judging intent, so false positives are limited to cases the label covers. The
deliberate gap: an unrelated one-line fix inside a file the PR legitimately touches, committed under the
right type, passes all five rules. Catching that needs a semantic reviewer, not this check.

Additional Notes

  • The step lives in the existing conventional-commit job, so it reuses that required check rather than
    adding one to all-green. PR_TITLE_PATTERN and the module's parser are pinned to each other by a test.
  • The workflow is pull_request_target and checks out the base revision, so this step never executes
    PR-authored code — which also means the rules here only take effect for PRs opened after this merges,
    including this one.
  • Requires a scope-exception label to be created in repo settings before the escape hatch works;
    until then the step can't be bypassed.
  • Tests: npm run test:scripts (scripts/pr-scope.spec.mjs, 15 cases; existing scripts/pr-title.spec.mjs
    still passes). The new spec also compiles the inline workflow script to catch syntax errors locally.
  • Follow-up: reference this check from the Scope discipline section of AGENTS.md once docs(agents): require PR contents to serve the PR title #10028 lands
    (kept out of here to avoid a conflicting edit to the same section).
  • rename-only-file relies on the files API reporting changes: 0 for a pure rename, verified against
    refactor(appsec): slim down appsec index file #9670, which contains both shapes: appsec/blocked_templates.js -> appsec/blocking/templates.js is
    reported as status: renamed, changes: 0 with no patch, while appsec/blocking.js ->
    appsec/blocking/index.js is status: renamed, changes: 32 with a patch. The rule fires on the former
    and ignores the latter. When a move falls below GitHub's rename-similarity threshold it is reported as an
    add plus a delete instead, and the rule stays silent — it fails open, never falsely.

@dd-octo-sts

dd-octo-sts Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.42 MB
Deduped: 9.08 MB
No deduping: 9.08 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.3 | 125.43 kB | 445.14 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-official

datadog-official Bot commented Aug 27, 2026

Copy link
Copy Markdown

Tests

All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 98.58% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: adf151d | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Aug 27, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-27 18:04:20

Comparing candidate commit adf151d in PR branch bengl/pr-scope-check with baseline commit bacdb78 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2302 metrics, 8 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-20

  • unstable max_rss_usage [-27.236MB; +4.010MB] or [-14.983%; +2.206%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-24083.027KB; +22539.027KB] or [-6.409%; +5.998%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable max_rss_usage [-14754.260KB; +14011.060KB] or [-5.922%; +5.624%]

scenario:debugger-line-probe-without-snapshot-20

  • unstable max_rss_usage [-8.641MB; +11.550MB] or [-4.557%; +6.091%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-443.989ms; +219.852ms] or [-9.093%; +4.503%]
  • unstable execution_time [-451.579ms; +216.944ms] or [-9.102%; +4.373%]
  • unstable throughput [-78831.816op/s; +160754.726op/s] or [-4.660%; +9.502%]

scenario:id-parse-64bit-20

  • unstable execution_time [-110.908ms; +148.368ms] or [-4.344%; +5.811%]

AGENTS.md asks that everything in a PR serve its title, but nothing
enforced it, so drive-by refactors, stray formatting, unrequested file
moves, and development leftovers kept landing alongside scoped changes.

Add scripts/pr-scope.js and a step in the existing pull-request-title
workflow that fails on four deterministic proxies for that creep:

- a commit whose conventional type or scope is outside the title's, with
  test, docs, ci, bench, and chore treated as supporting any change
- a modified file whose hunks differ only in whitespace, unless the
  title is a style or chore change
- a pure rename with no content change under a title that isn't about
  moving files
- an added file matching a development-leftover pattern (root-level
  reports and logs, agent-tool state directories, scratch and tmp
  files, .orig/.rej leftovers, crash dumps)

The workflow step is a one-line call into reportScopeViolations, so the
rules, the API calls, and the annotations all live in a linted, tested
module rather than in YAML.

The checks read evidence the author already supplied rather than judging
intent, so they can't see an unrelated fix buried in an otherwise
relevant hunk. The scope-exception label skips them when a violation is
deliberate.
@bengl
bengl force-pushed the bengl/pr-scope-check branch from bf9bb8e to adf151d Compare August 27, 2026 17:50
@bengl
bengl marked this pull request as ready for review August 27, 2026 17:54
@bengl
bengl requested review from a team as code owners August 27, 2026 17:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: adf151da16

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +83 to +84
# can't see semantic creep inside an otherwise relevant hunk. Apply the scope-exception label when a
# violation is deliberate, and say why in the PR description.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Re-run validation when the exception label changes

The documented escape hatch does not work when the label is applied by itself: this workflow only subscribes to opened, edited, reopened, and synchronize, so adding scope-exception after a failed run never executes this step again. Conversely, removing the label after a successful run leaves the scope check green. Include the labeled and unlabeled activity types so the required check reflects the current label state.

Useful? React with 👍 / 👎.

Comment thread scripts/pr-scope.js
Comment on lines +91 to +92
if (added.length === 0 || added.length !== removed.length) return false
return added.every((line, index) => line === removed[index])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Distinguish moved blocks from whitespace-only changes

When a block is relocated within the same file without reordering its lines, the patch's removed and added sequences are identical after normalization, so this comparison returns true. A dedicated refactor(core): move helper near caller PR is consequently reported as a formatting-only violation because refactor is not in FORMATTING_TITLE_TYPES; compare hunk locations or otherwise exclude delete/add relocations before classifying the whole file as whitespace-only.

Useful? React with 👍 / 👎.

Comment thread scripts/pr-scope.js
// Development leftovers. Anything matching these is a scratch artifact no PR title covers.
const SCRATCH_PATTERNS = [
/^[^/]+\.(?:html|log)$/, // Reports and logs dropped at the repository root
/(?:^|\/)\.(?:claude|cursor|aider|pi-subagents|agents-local)\//, // Agent-tool state directories

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow repository-owned agent configuration files

This pattern treats every newly added path under .claude or .cursor as a development leftover, but this repository already intentionally tracks shared configuration in .cursor/commands, .cursor/skills, and .claude/skills. A PR adding another shared command or skill symlink is therefore unconditionally failed as scratch-artifact; narrow the match to actual local-state files and directories rather than rejecting these entire repository-owned configuration trees.

Useful? React with 👍 / 👎.

Comment thread scripts/pr-scope.js
continue
}

if (title.scope && commit.scope && commit.scope !== title.scope) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat comma-delimited title scopes as a set

The repository already treats comma-delimited Conventional Commit scopes as multiple scopes, and its history contains titles such as feat(mysql,mysql2). With that title and granular feat(mysql) and feat(mysql2) commits, this exact string comparison flags both commits even though each scope is explicitly covered by the title; reuse the existing scope-splitting convention, normalize both lists, and only reject commit scopes outside the title's set.

AGENTS.md reference: AGENTS.md:L231-L232

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.58%. Comparing base (bacdb78) to head (adf151d).

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #10029    +/-   ##
========================================
  Coverage   98.58%   98.58%            
========================================
  Files         990      990            
  Lines      149247   149247            
  Branches    13046    12712   -334     
========================================
  Hits       147130   147130            
  Misses       2117     2117            
Flag Coverage Δ
aiguard 62.24% <ø> (-0.03%) ⬇️
aiguard-integration 58.91% <ø> (+0.07%) ⬆️
apm-bucket-0 61.67% <ø> (-0.03%) ⬇️
apm-bucket-1 67.22% <ø> (-0.03%) ⬇️
apm-bucket-2 66.77% <ø> (-0.03%) ⬇️
apm-bucket-3 63.47% <ø> (-0.03%) ⬇️
apm-capabilities-tracing 62.37% <ø> (ø)
apm-integrations-aerospike 59.54% <ø> (-0.03%) ⬇️
apm-integrations-confluentinc-kafka-javascript 65.72% <ø> (-0.03%) ⬇️
apm-integrations-couchbase 60.05% <ø> (-0.03%) ⬇️
apm-integrations-http 65.48% <ø> (-0.03%) ⬇️
apm-integrations-kafkajs 66.35% <ø> (-0.03%) ⬇️
apm-integrations-next 63.00% <ø> (-0.03%) ⬇️
apm-integrations-prisma 61.15% <ø> (-0.03%) ⬇️
appsec 76.22% <ø> (-0.02%) ⬇️
appsec-express_fastify_graphql 72.73% <ø> (-0.02%) ⬇️
appsec-integration 49.16% <ø> (ø)
appsec-kafka_ldapjs_lodash 66.76% <ø> (-0.06%) ⬇️
appsec-mongodb-core_mongoose_mysql 70.08% <ø> (-0.02%) ⬇️
appsec-next 56.45% <ø> (-0.02%) ⬇️
appsec-node-serialize_passport_postgres 69.53% <ø> (-0.02%) ⬇️
appsec-sourcing_stripe_template 67.91% <ø> (-0.03%) ⬇️
debugger 68.94% <ø> (-0.01%) ⬇️
instrumentations-bucket-0 54.87% <ø> (-0.03%) ⬇️
instrumentations-bucket-1 63.33% <ø> (-0.03%) ⬇️
instrumentations-bucket-10 64.59% <ø> (-0.03%) ⬇️
instrumentations-bucket-11 65.24% <ø> (-0.03%) ⬇️
instrumentations-bucket-12 54.75% <ø> (-0.03%) ⬇️
instrumentations-bucket-13 55.06% <ø> (-0.03%) ⬇️
instrumentations-bucket-14 54.88% <ø> (-0.03%) ⬇️
instrumentations-bucket-2 55.98% <ø> (-0.03%) ⬇️
instrumentations-bucket-3 56.79% <ø> (-0.03%) ⬇️
instrumentations-bucket-4 62.78% <ø> (-0.03%) ⬇️
instrumentations-bucket-5 49.19% <ø> (-0.03%) ⬇️
instrumentations-bucket-6 64.64% <ø> (-0.03%) ⬇️
instrumentations-bucket-7 55.02% <ø> (-0.03%) ⬇️
instrumentations-bucket-8 62.18% <ø> (-0.03%) ⬇️
instrumentations-bucket-9 57.62% <ø> (-0.03%) ⬇️
instrumentations-instrumentation-couchbase 53.46% <ø> (-0.03%) ⬇️
instrumentations-integration-esbuild 34.06% <ø> (ø)
llmobs-ai_anthropic_bedrock 66.11% <ø> (-0.02%) ⬇️
llmobs-bucket-1 64.25% <ø> (-0.02%) ⬇️
llmobs-openai 66.06% <ø> (-0.03%) ⬇️
llmobs-openai-agents_vertex-ai 63.28% <ø> (-0.02%) ⬇️
llmobs-sdk 75.30% <ø> (-0.03%) ⬇️
master-coverage 98.58% <ø> (?)
openfeature 59.52% <ø> (ø)
openfeature-unit 57.27% <ø> (-0.03%) ⬇️
platform-core_esbuild_instrumentations-misc 40.49% <ø> (-0.02%) ⬇️
platform-integration 64.21% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 38.24% <ø> (-0.02%) ⬇️
plugins-browser-bunyan_bullmq_cassandra 65.44% <ø> (-0.03%) ⬇️
plugins-bucket-0 60.14% <ø> (-0.03%) ⬇️
plugins-bucket-1 57.42% <ø> (ø)
plugins-bucket-11 65.96% <ø> (-0.03%) ⬇️
plugins-bucket-18 65.48% <ø> (-0.03%) ⬇️
plugins-bucket-19 64.06% <ø> (-0.03%) ⬇️
plugins-bucket-20 65.93% <ø> (-0.03%) ⬇️
plugins-bucket-4 60.27% <ø> (-0.03%) ⬇️
plugins-cookie_cookie-parser_crypto 54.42% <ø> (-0.03%) ⬇️
plugins-fastify_fetch_fs 64.61% <ø> (-0.03%) ⬇️
plugins-generic-pool_google-cloud-pubsub_grpc 68.20% <ø> (-0.03%) ⬇️
plugins-handlebars_hapi_hono 62.67% <ø> (-0.03%) ⬇️
plugins-ioredis_knex_langgraph 60.76% <ø> (-0.03%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 62.41% <ø> (-0.03%) ⬇️
plugins-lodash_mariadb_memcached 63.03% <ø> (+0.07%) ⬆️
plugins-moleculer_mongodb_mongodb-core 65.30% <ø> (-0.03%) ⬇️
plugins-mongoose_multer_mysql 63.13% <ø> (-0.03%) ⬇️
plugins-mysql2_nats_node-serialize 65.28% <ø> (-0.03%) ⬇️
plugins-opensearch_passport-http_pino 63.14% <ø> (-0.03%) ⬇️
plugins-postgres_process_pug 62.23% <ø> (-0.03%) ⬇️
plugins-redis_router_sequelize 65.88% <ø> (-0.03%) ⬇️
plugins-test-and-upstream-rhea_undici_url 65.26% <ø> (-0.03%) ⬇️
plugins-valkey_vm_winston 61.55% <ø> (-0.03%) ⬇️
plugins-ws 63.53% <ø> (-0.03%) ⬇️
profiling 65.56% <ø> (-0.03%) ⬇️
serverless-aws-sdk-aws-sdk 54.65% <ø> (-0.02%) ⬇️
serverless-aws-sdk-base-inject-field 54.01% <ø> (-0.03%) ⬇️
serverless-aws-sdk-bedrockruntime 57.31% <ø> (-0.03%) ⬇️
serverless-aws-sdk-client 59.13% <ø> (-0.03%) ⬇️
serverless-aws-sdk-dynamodb 58.25% <ø> (-0.03%) ⬇️
serverless-aws-sdk-eventbridge 56.88% <ø> (-0.02%) ⬇️
serverless-aws-sdk-kinesis 62.31% <ø> (-0.03%) ⬇️
serverless-aws-sdk-lambda 60.24% <ø> (-0.03%) ⬇️
serverless-aws-sdk-s3 58.32% <ø> (-0.03%) ⬇️
serverless-aws-sdk-serverless-peer-service 62.88% <ø> (-0.03%) ⬇️
serverless-aws-sdk-sns 63.21% <ø> (-0.03%) ⬇️
serverless-aws-sdk-sqs 63.67% <ø> (-0.03%) ⬇️
serverless-aws-sdk-stepfunctions 58.13% <ø> (-0.03%) ⬇️
serverless-aws-sdk-util 54.67% <ø> (-0.03%) ⬇️
serverless-bucket-0 56.89% <ø> (-0.01%) ⬇️
serverless-bucket-1 62.82% <ø> (-0.03%) ⬇️
test-optimization-cucumber 70.25% <ø> (+0.02%) ⬆️
test-optimization-cypress 64.52% <ø> (+0.08%) ⬆️
test-optimization-jest 71.86% <ø> (-0.01%) ⬇️
test-optimization-mocha 71.71% <ø> (+0.06%) ⬆️
test-optimization-playwright-playwright-atr 59.39% <ø> (+0.01%) ⬆️
test-optimization-playwright-playwright-efd 60.04% <ø> (+0.01%) ⬆️
test-optimization-playwright-playwright-final-status 59.65% <ø> (+<0.01%) ⬆️
test-optimization-playwright-playwright-impacted-tests 59.77% <ø> (+0.15%) ⬆️
test-optimization-playwright-playwright-reporting 60.79% <ø> (-0.04%) ⬇️
test-optimization-playwright-playwright-test-management 60.84% <ø> (-0.09%) ⬇️
test-optimization-playwright-playwright-test-span 59.43% <ø> (-0.05%) ⬇️
test-optimization-selenium 58.50% <ø> (-0.12%) ⬇️
test-optimization-testopt 61.58% <ø> (+0.07%) ⬆️
test-optimization-vitest 72.49% <ø> (+0.09%) ⬆️
test-optimization-vitest-browser 58.39% <ø> (+0.01%) ⬆️
test-optimization-webdriverio 64.96% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant