Skip to content

fix(config): exclude dependency and build-output directories by default - #1499

Merged
lizhengfeng101 merged 4 commits into
alibaba:mainfrom
basil-k-aji-dev:fix/config-default-exclude-deps
Sep 21, 2026
Merged

lizhengfeng101 merged 4 commits into
alibaba:mainfrom
basil-k-aji-dev:fix/config-default-exclude-deps

Conversation

@basil-k-aji-dev

@basil-k-aji-dev basil-k-aji-dev commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the dependency and build-output patterns from #1494 to default_exclude_patterns.json, and drops the now-redundant **/vendor/**/*.{jsonnet,libsonnet} line.

I checked the two premises in the issue before writing anything, because both are what make this worth doing rather than a .gitignore problem:

  • .gitignore does not cover it. Once a directory has been committed, git diff stops consulting .gitignore for it. c640c109 committed extensions/frontend/node_modules because the root .gitignore had /node_modules anchored to the root; 27c43fa8 removed it, but reviewing either commit, or any range spanning them, still pulls in all 389 files.
  • The extension allowlist does not cover it. I confirmed against supported_file_types.json: .map, .lock, .sum, .class and .jar are absent, so source maps, yarn.lock, Cargo.lock, go.sum and compiled artifacts are already stopped at the extension gate and need no pattern. But .json, .yaml, .js, .ts, .css, .cjs, .mjs and .hcl are all present, so package-lock.json, pnpm-lock.yaml and everything inside these directories reaches the path gate unfiltered.

One behaviour change that needs a decision, not just a review

**/vendor/** is broader than what it replaces, and the narrow pattern was narrow on purpose. allowed_ext_test.go said so:

// The pattern is extension-scoped: IsExcludedPath applies every pattern to every
// path, so a bare **/vendor/** would also drop vendored Go and PHP sources.
{"go under vendor still reviewed", "vendor/github.com/pkg/errors/errors.go", false},
{"php under vendor still reviewed", "vendor/monolog/monolog/src/Logger.php", false},

The issue asks for **/vendor/** and for that line to go, so those two cases now assert true and carry a comment saying #1494 reversed the earlier decision deliberately. Flagging it here rather than burying it: this is the one change in the PR that stops something being reviewed that used to be, and if the intent was only to widen it for jsonnet, this is the line to push back on.

Additions beyond the issue's list

Six, each from a toolchain that writes the directory and no hand-written source:

pattern written by
**/.angular/** Angular CLI build cache
**/.parcel-cache/** Parcel bundler cache
**/.docusaurus/** Docusaurus build cache
**/.stack-work/** Haskell Stack build output
**/.pnp.cjs, **/.pnp.loader.mjs Yarn PnP, generated — .cjs/.mjs are both in the allowlist
**/.terraform.lock.hcl Terraform, and it sits outside .terraform/ so the directory pattern misses it — .hcl is in the allowlist

**/build/** and **/bin/** stay out, per the issue. This repository's own bin/ocr.js is the counter-example, and both are pinned as not excluded so a later well-meaning addition fails the test rather than silently dropping files.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

  • make test passes locally
  • Manual testing (described below)

Against the acceptance criteria:

  • extensions/frontend/node_modules/@babel/core/lib/index.js is excluded, as are node_modules/left-pad/index.js and a/b/c/d/node_modules/pkg/dist/index.js — root, workspace and depth.
  • Ten lookalikes assert the opposite, because a directory pattern matching a prefix of a segment instead of the whole segment is how this kind of change quietly deletes coverage: src/distribution/index.js, src/objects/model.ts, app/targeting/rules.go, src/vendors/stripe.ts, ios/podsmith/Helper.swift, tools/venvironment/setup.py, app/coverages/report.ts, src/node_modules_helper.ts, src/minified.ts, src/package-lock-utils.ts.
  • 45 positive cases in total, one per ecosystem, so a later edit to any single pattern fails a named test rather than the whole block.

One existing test outside this package needed updating and I want it visible rather than folded into the diff: TestWhyExcluded_UserIncludePattern used vendor/baz.go purely as "a path outside the include patterns that nothing else excludes", to demonstrate that include is additive. **/vendor/** invalidates the fixture, not the assertion, so the path is now cmd/baz.go with a comment saying why it changed.

Local run caveat: make test uses -race, and this machine's kernel has a 47-bit VMA where ThreadSanitizer needs 48, so every package aborts before running. I ran go test -count=1 ./..., which is green, plus make check and make english-check.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable) — the pattern-syntax docs in allowed_ext.go are unchanged and still accurate
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI/LLM disclosure: written with AI assistance — Claude Code, model Claude Opus 5. I reviewed every pattern individually, checked each one against supported_file_types.json and the existing tests rather than assuming, and found the vendor reversal and the TestWhyExcluded_UserIncludePattern fixture by running the suite. The reasoning above and in any review thread is my own.

Related Issues

Closes #1494

The default list covered tests, snapshots and generated code but not the
directories a package manager writes. **/oh_modules/** was there and
**/node_modules/** was not.

.gitignore does not stand in for this. Once a directory has been committed
git diff stops consulting .gitignore for it, so reviewing that commit or any
range spanning it pulls in every file -- this repository committed
extensions/frontend/node_modules and one review picked up 389 files. The
extension allowlist does not either: the contents are .js, .ts, .json and
.css, all supported, so they reach the path gate unfiltered.

**/build/** and **/bin/** are deliberately absent. Projects keep hand-written
sources in both, including this repository's own bin/ocr.js, and a false
exclusion is silent.

One behaviour change worth naming: **/vendor/** supersedes the old
extension-scoped **/vendor/**/*.{jsonnet,libsonnet}, so vendored Go and PHP
sources are now excluded where they previously were not. Two test cases
asserted the old behaviour and now assert the new one.

Fixes alibaba#1494
@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

@Qiyuanqiii Qiyuanqiii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The implementation itself looks solid to me. The new patterns use the existing path-matching semantics cleanly, the nesting/lookalike coverage is good, and CI/CodeQL are green.

I do think the documentation needs to move with this change before merge, though.

The current Viewer/rule documentation does not merely omit these new patterns; it describes a different filtering model. In particular, the existing review-rules.md / architecture.md text says that default_path is primarily the built-in test-file exclusion gate, while noisy directories such as vendor/, node_modules/, and target/ are filtered earlier by the diff provider.

After this PR, that is no longer generally true. Nested dependency/build directories such as:

  • extensions/frontend/node_modules/...
  • foo/vendor/...
  • foo/target/...

can now reach the per-file filter and be excluded by default_path. That distinction is user-visible because a user include rule can override a default-path exclusion, whereas the provider-level root-directory blocklist cannot be overridden.

There is also a sequencing issue with #1491: that PR is currently synchronizing the five localized review-rules.md files to the pre-#1499 exclude list. If #1491 lands first and this PR lands unchanged afterwards, the documentation becomes stale again immediately.

Could we update the relevant documentation after rebasing on #1491 (or otherwise coordinate the two PRs), including the five localized review-rules.md files and the corresponding architecture.md explanation of the filtering layers?

I don't have a code-level blocker beyond that. The broader **/vendor/** behavior is a real coverage change, but #1494 explicitly asks for that pattern, so I consider that a maintainer policy decision rather than an implementation defect in this PR.

review-rules.md and architecture.md both said default_path matches built-in
test-file patterns, and that noisy directories are filtered earlier at the diff
level. After the new patterns the first is incomplete and the second is only
true at the repository root: providerDirIgnoreDirs matches by path prefix, so
vendor/pkg/x.go never reaches the per-file filter while api/vendor/pkg/x.go
does and is excluded by default_path instead.

That distinction is user-visible, because an include rule can override a
default_path exclusion and cannot override the provider blocklist. Both
documents now say which one reports which, and the pattern list covers the
dependency and build-output group alongside the test group.

Five locales each.
@basil-k-aji-dev

Copy link
Copy Markdown
Contributor Author

@Qiyuanqiii you were right that this was not an omission but a contradiction, and the docs are updated. Pushed.

What was wrong. Both documents said default_path matches built-in test-file patterns, and that noisy directories are handled earlier at the diff level. I checked ProviderDirPrefix before writing anything, and your reading is exact:

if relPath == dirPart || strings.HasPrefix(relPath, prefix) {

prefix is "vendor/", so it matches only at the repository root. vendor/pkg/x.go never reaches the per-file filter; api/vendor/pkg/x.go always did reach it, and after this PR it is excluded there by default_path.

The user-visible half is the part I would have under-documented without your review. The two outcomes are not interchangeable: provider_directory cannot be brought back by an include rule and default_path can. Both documents now say which path reports which, with that exact pair of examples, rather than leaving a reader to infer it.

Changed in five locales each: review-rules.md gains the dependency and build-output group beside the test group, and corrects the "happens earlier" sentence to say root-only. architecture.md gets the same correction in its filtering-layers section, and gate 5 no longer says test-file.

On sequencing with #1491. You are right that whichever of us lands second makes the other stale. I have not rebased onto it, and I would rather say why than do it silently: #1491 is @wu21-web's and is still open, so rebasing onto an unmerged branch would put their commits inside my PR and make this one unreviewable for the thing it is actually about.

What I have done instead is make my change additive to the same sections, so the conflict is small and mechanical. My preference, if it helps you sequence them:

Either way I will follow whichever order you pick rather than race it.

@wu21-web, since this touches the five files you are already syncing: if you would rather carry the pattern-list half in #1491 yourself and leave me only the root-only correction, say so and I will cut mine back. You have also just told me on #1490 that my translations need work, which I accept, so I would rather you had the option than have me push four more locales past you.

On **/vendor/**. Agreed that it is a policy call rather than a defect, and I flagged it in the PR description for the same reason: it stops vendored Go and PHP sources being reviewed, which allowed_ext_test.go previously asserted on purpose. #1494 asks for the pattern explicitly, so I implemented it and made the reversal visible rather than quiet, but it is @lizhengfeng101's to confirm.

@wu21-web

Copy link
Copy Markdown
Contributor

You are so thoughtful. Yes indeed, you have to pick up the new docs session after my PR gets merged.

@basil-k-aji-dev

Copy link
Copy Markdown
Contributor Author

Agreed, #1491 first. Once it lands I will rebase onto your list and keep only the two additions this PR needs: the dependency and build-output group, and the correction that the diff-level blocklist matches at the repository root only.

Ping me when it merges, or I will pick it up when I see it.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@basil-k-aji-dev please rebase main

@Qiyuanqiii

Copy link
Copy Markdown
Contributor

ci failing

…clude-deps

# Conflicts:
#	pages/src/content/docs/en/review-rules.md
#	pages/src/content/docs/ja/review-rules.md
#	pages/src/content/docs/ko/review-rules.md
#	pages/src/content/docs/zh/review-rules.md

@Qiyuanqiii Qiyuanqiii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment on lines +196 to +203
- `**/node_modules/**`
- `**/bower_components/**`
- `**/vendor/**`
- `**/target/**`
- `**/dist/**`
- `**/__pycache__/**`, `**/.venv/**`, `**/site-packages/**`
- `**/Pods/**`, `**/Carthage/**`
- `**/.next/**`, `**/.nuxt/**`, `**/.gradle/**`, `**/.terraform/**`, …

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest adding these to the list already there instead of creating a new list per translation, because they are all in the same json file.

@Qiyuanqiii

Copy link
Copy Markdown
Contributor

@NanaseInori review

@NanaseInori NanaseInori 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.

Re-reviewed the current head (4410d29).

The implementation and regression coverage still look good to me, and the earlier documentation issue about the provider-level versus default_path filtering semantics has been addressed correctly.

I agree with @wu21-web's documentation comment, and I think there is a concrete consistency issue behind it rather than only a formatting preference.

After the rebase, the localized review-rules.md files currently document both:

**/vendor/**/*.{jsonnet,libsonnet}

and:

**/vendor/**

However, default_exclude_patterns.json removes the former and replaces it with the latter. So the documentation now describes an exclusion pattern that no longer exists in the source of truth.

This appears to have been left behind while resolving the documentation conflicts with #1491: the existing synchronized list was retained, and the new dependency/build-output patterns were added as a separate list.

I suggest applying this PR's pattern changes directly to the existing list, as @wu21-web proposed, across the maintained locales. In particular, the old **/vendor/**/*.{jsonnet,libsonnet} entry should be removed when **/vendor/** is added, so the documented list continues to match default_exclude_patterns.json.

I don't see another implementation blocker at the current head. The filtering behavior, nested-path coverage, lookalike regressions, and provider/default-path distinction look coherent, and the current CI, CodeQL, Pages, translation-sync, and plugin-contract checks are green.

Requesting changes only for the documentation/source-of-truth mismatch above.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@basil-k-aji-dev

Copy link
Copy Markdown
Contributor Author

@NanaseInori @wu21-web your two comments landed a few minutes before this merged, so I have taken both in #1541.

@NanaseInori, you were right: the localized review-rules.md files still documented **/vendor/**/*.{jsonnet,libsonnet} after the rebase removed it from the json, so the page described an exclusion that no longer exists.

@wu21-web, also right that one json file should not appear as two lists.

Checking both turned up something neither of you had reason to look for. The page listed 74 of the 97 patterns in the file. That gap predates this PR; the list is hand-maintained and has fallen behind more than once.

So #1541 generates the single list from the json, and adds a test that fails when the two disagree in either direction. I checked it against both before relying on it, and the stale-entry direction reproduces @NanaseInori's finding exactly:

en/review-rules.md lists "**/vendor/**/*.{jsonnet,libsonnet}",
which is not in default_exclude_patterns.json

That test would have caught this before merge, which is the part worth having.

@lizhengfeng101, your **/coverage/** narrowing and the src/coverage/plan.ts pin are both on main and unchanged here.

kall added a commit to kall/open-code-review that referenced this pull request Sep 23, 2026
Resolve the five conflicts, the one parity gap and the one stale test
the merge exposed:

- internal/agent/{agent,preview}.go: take upstream's selectFiles
  refactor (alibaba#782, now in selection.go), then re-apply the branch-side
  switch to the shared model primitives (EffectivePath, Status,
  ExtFromPath) across agent.go, preview.go and the new selection.go,
  and drop the local effectivePath/diffStatus/extFromPath copies.
  Taking upstream's agent.go also removes executePlanPhase, dead code
  upstream deleted in alibaba#808 that the v1.11.2 merge had resurrected.
- internal/agent/{agent,preview}_test.go, internal/scan/coverage_test.go:
  take upstream's new tests, drop the resurrected TestExtFromPath,
  TestEffectivePath and TestDiffStatus (covered in internal/model).
- internal/diff/core_diff.go: silent parity break, no conflict. Upstream
  added the built-in secret-path gate ahead of the user rules (alibaba#1240),
  so `ocr core diff` still offered .env and friends for review. Mirror
  agent.whyExcluded: check OldPath and NewPath, return secret_exclude.
  Both parity tables gain the same six secret cases.
- Parity tables: the nested-directory case used vendor/, which alibaba#1499
  now excludes by default. Move it to apps/ so it still tests user glob
  depth. The agent-side table now calls selectFiles directly instead of
  re-composing the deleted check.
- skills/open-code-review-local (0.2.1) and the usage doc: document
  secret_exclude and the provider-directory drop.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

fix(config): cover dependency and build-output directories in default_exclude_patterns.json

5 participants