Repository navigation
feat(cli): expose caller-selected reference-source exclusions - #5472
Closed
Manakavoo-Kadit wants to merge 1 commit into
Closed
Manakavoo-Kadit wants to merge 1 commit into
Manakavoo-Kadit wants to merge 1 commit into
Conversation
The reference-source importer already accepted caller exclusion rules, marked them caller-excluded and pruned traversal, but import-reference-source could not pass them, so an analyst could not omit irrelevant repository paths from the imported tree. Add --exclude-paths to import-reference-source. The option carries a JSON array of Git-ignore-style rules that the new domain module owns: rules must be nonempty strings without control characters, must stay relative to the imported root, and are bounded in count. Malformed JSON and rejected rules fail before the import starts, so a rejected option never reads the source tree. Also keep a directory-only caller rule as written instead of deriving a second pattern that matches nothing. Fixes morluto#2443
2 tasks done
Owner
|
Thanks for working on caller-selected exclusions. There is another open implementation of #2443 in #2630, including coverage for negation and declared-secret precedence. This PR also addresses directory-only rules and proposes input bounds. Could you coordinate around a single implementation, keeping any distinct behavior and coverage that is still needed? Both PRs remain open while that is worked out. |
2 tasks done
4 of 17 tasks
This was referenced Oct 29, 2026
13 tasks
Contributor
|
Just a heads-up: #2443, the issue this pull request is for, closed on 6 Nov when #2630 merged. So this pull request may not be needed anymore. If it still adds something #2630 doesn't, a short note saying what would help a maintainer decide. 🤖 Written with Claude Code (Opus 5.5), posted with my OK 🦊 |
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
import-reference-sourcecould not pass caller-selected path exclusions to thereference-source importer. The importer already accepted exclusion rules,
recorded
caller-excludedprovenance and pruned traversal, but no CLI callercould reach that behavior, so an analyst could not omit irrelevant repository
paths from an imported source tree.
Fixes #2443
Problem and expected behavior
An analyst comparing an older source tree with the current artifact often wants
to omit paths that carry no signal (vendored dependencies, generated output,
scratch files). REA's importer already models this choice, but the CLI exposes
no way to make it.
Expected behavior:
rea import-reference-source <root> --exclude-paths '["vendor","*.tmp"]'omits the matching paths from the imported tree, reportseach omission as a
caller-excludedexclusion with its matched pattern, andnever traverses an excluded directory. Malformed JSON and rejected rules fail
the command before the import starts.
Change and scope
src/domain/referenceSourceExclusionRules.tsowns therule grammar: a rule is a nonempty string without control characters, stays
relative to the imported root, and the accepted rule count is bounded.
import-reference-sourcegains an optional--exclude-pathsoption thatcarries a JSON array of those rules. The CLI decodes and validates the value
before any import work and reports rejected input against
excludePaths.src/application/ReferenceSourceImportPolicy.tskeeps a directory-onlycaller rule as written instead of deriving a second pattern (
vendor//)that matches nothing.
docs/cli.mddocuments the option, its grammar, its failure behavior and itsprecedence against project, default and configured-secret rules.
Not included: the MCP surface (the importer is a CLI workflow today), a
secrecy heuristic for exclusions (an explicit exclusion is a context choice),
and the
docs/specs/reference-source/caller-exclusions/files named in theissue.
Contract and boundary impact
rule grammar; the CLI adapter decodes the caller's JSON text and delegates.
inside existing boundaries; not applicable.
import-reference-sourcegains oneoptional CLI option. No MCP tool changes.
import itself still requires safe no-follow file opens, so it runs on Linux
and macOS, not native Windows.
keep the existing
caller-excludedreason and matched pattern in thecommitted graph. Project, default and configured-secret rules keep their own
precedence.
applicable.
docs/public/product-catalog.json), package, orinstallation impact: none; CI regenerates the ignored catalogs.
Expected effects:
Evidence and regression coverage
src/domain/referenceSourceExclusionRules.test.ts— rule grammar, boundsand correction metadata.
tests/boundary/cli/referenceSourceExclusionInput.test.ts— compiled CLIrejects malformed JSON, a non-array value, a non-string rule, a blank rule
and an absolute host path rule before the import starts.
tests/boundary/cli/referenceSourceExclusions.test.ts— compiled CLIprunes caller-excluded paths with their provenance, matches a wildcard rule,
and keeps the default import unchanged for an empty rule list. This file's
import-dependent cases are skipped on native Windows, because the import
requires safe no-follow file opens.
tests/boundary/filesystem/referenceSourceExclusionPolicy.test.ts— theimporter's matcher marks caller rules apart from default rules and keeps a
directory-only rule away from a file with the same name.
--exclude-pathsoption andimportReferenceSourcewas called withoutexcludePaths, so no caller rule could reach the importer.the empty-array comparison) was not executed on this Windows host, because the
reference-source import requires safe no-follow file opens and returns
unsupported_hoston native Windows. Those cases run on Linux and macOSCI.
Validation performed
npx vitest run --project domain src/domain/referenceSourceExclusionRules.test.ts— 8 passed.npx vitest run --project boundary tests/boundary/filesystem/referenceSourceExclusionPolicy.test.ts— 2 passed.npx vitest run --project cli-boundary tests/boundary/cli/referenceSourceExclusionInput.test.ts tests/boundary/cli/referenceSourceExclusions.test.ts tests/boundary/cli/referenceSourceSummary.test.ts— 15 passed, 6 skipped (the skipped cases need Linux or macOS).npx tsc --noEmit— passed.npx oxlint <changed files>andnpx oxfmt --check <changed files>— passed.npx knip— passed.npm run docs:check— passed.npx vitest run --project cli-boundary— 60 files passed, 23 skipped, 14 files failed with 28 failed assertions. Every failure is a pre-existing native-Windows host limit, and the same 14 files fail identically on the base commit: the reference-source cases fail with "Safe no-follow file opens are unavailable", the Electron, Apktool, Cutter, pcap and client-profile cases need tools this host does not provide, and thejsonInputStatus,scenarioCliInputDiagnosticsandcliOptionAliasescases expect POSIX-style paths in error messages.npx vitest run --project cli-boundary tests/boundary/cli/cliInputSchemaRequired.test.ts— 5 passed; the advertised input schema accepts the new optional option.node scripts/rea.mjs import-reference-source --help— the option is documented in public command help.node scripts/rea.mjs import-reference-source <root> --exclude-paths ... --json— observed the four rejection outputs above.npx vitest run --project boundary tests/boundary/filesystem/referenceSource— 13 files fail on this Windows host with "Safe no-follow file opens are unavailable". These failures are the host limitation of the existing reference-source suite, not a regression from this change; the same files fail on the base commit.Compatibility, safety, and release
absence keeps the current import.
CI cover the import-dependent cases.
no source file, hook, build script, remote fetch or LLM request. Exclusions
are a context choice and are not a secrecy heuristic; configured-secret rules
keep their own reason.
Author readiness
Human owner: @MANAKAVOO-SIVA-BALAJI
Before merge
type(scope): outcome.