Repository navigation
feat(cli): expose RecordQuery negation as exclude filters - #1987
Merged
Merged
Conversation
Signed-off-by: András Jáky <[email protected]>
akijakya
force-pushed
the
feat/exclude-filter-dirctl
branch
from
August 6, 2026 19:21
3a370c2 to
bd17e5a
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for “exclude” (--exclude-*) search filters and tri‑state boolean filters (--trusted=false, etc.), with updated CLI docs/examples and expanded test coverage.
Changes:
- Introduces include/exclude value filters and builds negated
RecordQueryentries for--exclude-*flags. - Makes
--verified,--trusted, and--safetri-state by emitting queries for explicit=false. - Updates CLI reference/docs and adds unit + e2e tests covering negation and scan-severity exclusion behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/local/02_search_test.go | Adds end-to-end coverage for --exclude-* behavior, multi-valued fields, and scan severity exclusion. |
| docs/content/dir/dir-cli-reference.md | Documents tri-state booleans and introduces --exclude-* flag behavior and examples. |
| cli/cmd/search/search.go | Updates CLI help examples to include tri-state booleans and new exclude filters. |
| cli/cmd/search/nlsearch.go | Ensures NL extractor only uses included schema versions, not excluded ones. |
| cli/cmd/search/filters_test.go | Adds unit tests for include/exclude query generation and tri-state boolean semantics. |
| cli/cmd/search/filters.go | Implements include/exclude filter model, exclude scan-severity flag, and tri-state boolean query emission. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: András Jáky <[email protected]>
tkircsi
approved these changes
Aug 7, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Aug 7, 2026
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.
Closes #1986.
What
RecordQuery.negatelanded in #1983 and the server compiles exclusion for every filter type — 17Without*options inserver/types/search.go, with the correctNOT EXISTSshape for joined, multi-valued fields. None of it was reachable fromdirctl:BuildQueriesonly ever built inclusion queries, so negation was usable only by hand-rolled SDK callers.This adds an
--exclude-twin for every value filter, plus tri-state booleans.--name--exclude-name--version--exclude-version--skill/--skill-id--exclude-skill/--exclude-skill-id--domain/--domain-id--exclude-domain/--exclude-domain-id--module/--module-id--exclude-module/--exclude-module-id--locator--exclude-locator--author--exclude-author--created-at--exclude-created-at--schema-version--exclude-schema-version--annotation--exclude-annotation--scan-severity--exclude-scan-severity--verified,--trustedand--safebecome tri-state. Cobra already parsed--trusted=false; it just silently meant "do not filter". It now emits a query with value"false", whichQueryToFiltershas understood since #1983. An absent flag still does not filter, so nothing changes for existing invocations.Design notes
Separate flags rather than an inline
!marker.!composes cleanly with wildcards (!nlp*) but awkwardly with comparison operators (!>=1.0.0, and!=1.0.0means different things on a field that supports comparisons versus one that does not) and ambiguously with:—--annotation '!urgent:true'cannot be told apart from a key legitimately named!urgentwithout an escape. Separate flags leave the value grammar untouched:!stays an ordinary character.FilterValues{Include, Exclude}. The server ORs a filter's included values but ANDs each exclusion as its ownNOT EXISTS, so the two cannot share a slice — called out in #1940's own write-up. Splitting at the flag means pflag does the separation andBuildQueriesneeds no parsing.Filtersis now driven by onevalueFilters()table carrying flag name, both help strings and the query type, so registration and query building are a single loop each and a future filter is one entry instead of three edits. Nothing outside the package read the old fields; the only follow-through wasnlsearch.go, where the extractor takesSchemaVersions.Include(an excluded version has no taxonomy to point at).Booleans keep the
=falseform rather than gaining--exclude-trusted— it costs no new flag surface.Notes for reviewers
pull,exportandinstalltoo, since all four shareregisterFilterFlags. Verified: 14 exclude flags on each.dirctl installregisters the filters as persistent flags, so tri-state detection depends on cobra sharing the*pflag.Flagpointer between a parent's persistent set and a subcommand's merged set. Covered byTestBuildQueriesTriStateThroughPersistentFlags.--exclude-scan-severitykeeps never-scanned records: it excludes records that have a report at or above the threshold, and an unscanned record has none. This matches the server's existingapplyExcludedScanSeverities, and is documented next to the flag and in the CLI reference.--safe=falseis likewise not the complement of--safe— it compiles toEXISTS (scan_reports … is_safe = false), so a never-scanned record matches neither.--trusted=falseand--verified=falseare true complements.--exclude-skill nlpdrops a record whose skills are[nlp, python].Testing
cli/cmd/search/filters_test.go(new): every include flag, every exclude flag, include+exclude on one field, repeatability, verbatim pass-through of>=,*,!and:, tri-state booleans, the persistent-flag path, and the programmaticFiltersfallback.tests/e2e/local/02_search_test.go: 8 specs exercising the CLI → server →NOT EXISTSpath, including the multi-valued case and the never-scanned severity case. These have not had a passing local run — the local e2e suite was cut short — so they are unproven until CI runs them.task lint:goclean across all 7 modules; docs markdown and spelling clean.Unblocks
#1977 — the policy CronJob Helm templates, whose
prune-untrustedexample renders--trusted=false.