Skip to content

feat(repo): push scope pre-filter to the git layer - #76

Merged
Ian-stetsenko merged 1 commit into
mainfrom
feat/scope-git-pushdown
Nov 3, 2026
Merged

Ian-stetsenko merged 1 commit into
mainfrom
feat/scope-git-pushdown

Conversation

@TommyC81

@TommyC81 TommyC81 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Picks up the scope half of the scope/author pushdown split from #55 (the author half is already on main: buildLogArgs passes --author). Extends the loreOnly hook as proposed in the split.

Design. LogOptions gains an optional scope; when set, GitClient.log prepends --all-match --extended-regexp --regexp-ignore-case --grep=\(<ERE-escaped scope>\). --all-match ANDs it with the Lore-id pre-filter (git ORs multiple --greps by default); -i matches the parser-level filter's case-insensitivity; the scope value is escaped for POSIX ERE so metacharacters stay literal. findByScope passes its scope through; its exact conventional-commit subject filter stays authoritative, unchanged. The scope grep is a substring over the whole message - deliberately coarse: git skips commits that never mention (scope) at all, false positives cost only a parse.

Documented no-drop boundary: the coarse grep cannot drop an atom whose subject is a single ASCII line; wrapped multi-line subjects (git joins %s with spaces) and non-ASCII case folding (git folds bytes, JS folds Unicode) are the documented residuals.

Three documented side effects of the global --regexp-ignore-case (all recorded on LogOptions.scope):

  1. Author patterns in args case-fold while scope is set - this aligns with the parser-level case-insensitive author refinement (a case-variant author in a combined scope+author query can no longer be dropped at the git level; regression-tested).
  2. The Lore-id pre-filter itself case-folds (over-match only, e.g. LORE-ID: lines pass the grep; the trailer parser stays authoritative).
  3. Callers must not pass their own --grep in args alongside scope (git would AND it under --all-match).

All other log call sites are byte-identical when scope is absent.

Tests: real-git integration (scope api returns only Lore atoms mentioning (api) case-insensitively, excludes other-scope and non-atom commits; a.b matches (a.b) but not (axb); combined scope+author with a case-variant author returns the atoms); unit pins that findByScope carries { loreOnly: true, scope } and every discovery query stays Lore-only. Typecheck clean, full suite 509/509 on Windows.

Picks up the scope half of the scope/author pushdown split from issue #55 (the author half is already on main: buildLogArgs passes --author). LogOptions gains an optional scope string; when set, GitClient.log composes a coarse conventional-commit scope grep: --all-match ANDs it with the Lore-id pre-filter instead of git's default OR across multiple --grep patterns, --regexp-ignore-case keeps the coarse pass case-insensitive like the parser-level filter, and the scope value is escaped for POSIX ERE so metacharacters in user input stay literal (escaping non-metacharacters is undefined in POSIX, so only those are escaped). findByScope passes its scope through; its exact conventional-commit subject filter stays authoritative, unchanged. The scope grep is a substring over the whole message, deliberately coarser than the subject filter: git skips commits that never mention (scope) at all, and false positives cost only a parse. Documented no-drop boundary: the coarse grep cannot drop an atom whose subject is a single ASCII line (the parser-level filter's matches always carry a literal case-folded (scope) line); wrapped multi-line subjects and non-ASCII case folding (git folds bytes, JavaScript folds Unicode) are the documented residuals, recorded here rather than papered over. Three documented side effects of the global --regexp-ignore-case flag: author patterns passed in args become case-insensitive while scope is set, which matches the parser-level author refinement (regression-tested: a case-variant author in a combined scope+author query can no longer be dropped at the git level); the Lore-id pre-filter itself case-folds while scope is set (over-match only, e.g. LORE-ID lines pass the grep; the trailer parser stays authoritative and rejects them); and callers must not pass their own --grep in args alongside scope (git would AND it under --all-match). All three are recorded on LogOptions.scope. Real-git integration tests cover the AND with mixed case, metacharacter escaping, and the author interplay; unit tests pin that findByScope carries the scope option and that every discovery query stays Lore-only.

Lore-id: f089a5ea
Constraint: The git-level scope filter stays coarse: case-insensitive substring over the whole message; it cannot drop an atom with an ASCII single-line subject, while wrapped multi-line subjects and non-ASCII case folding are documented residuals.
Constraint: Multiple --grep patterns require --all-match; git ORs them by default, which would silently return non-Lore commits.
Constraint: POSIX ERE escaping covers metacharacters only; escaping other characters is undefined behaviour in POSIX.
Constraint: No caller may pass its own --grep in args alongside LogOptions.scope: --all-match would silently AND it into the query.
Constraint: --regexp-ignore-case is global: author patterns in args case-fold while scope is set (aligns with the parser-level author refinement), and the Lore-id pre-filter case-folds too (over-match only; the parser stays authoritative).
Tested: npm run typecheck: clean
Tested: Full suite on Windows: 509 tests in 34 files, all passing
Tested: Real-git integration: scope 'api' returns only Lore atoms mentioning (api), case-insensitively, excluding non-atom and other-scope commits; scope 'a.b' matches (a.b) but not (axb); combined scope+author query with a case-variant author returns the atoms
Tested: Unit: findByScope passes { loreOnly: true, scope }; all discovery queries stay Lore-only (toMatchObject)
Related: d181468e
Confidence: high
Scope-risk: narrow
Reversibility: clean
@Ian-stetsenko
Ian-stetsenko merged commit 97f22c2 into main Nov 3, 2026
3 checks passed
@TommyC81
TommyC81 deleted the feat/scope-git-pushdown branch November 3, 2026 14:28
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.

2 participants