Repository navigation
feat(classify): per-field patterns on the existing regex rule - #206
Open
TimeToBuildBob wants to merge 2 commits into
Open
TimeToBuildBob wants to merge 2 commits into
TimeToBuildBob wants to merge 2 commits into
Conversation
A regex rule may now carry 'fields' (e.g. {"app": "mstsc\\.exe", "title": "office"})
instead of 'regex'. Every listed field must match, each with the same
unanchored search as 'regex'. This lets users split two apps that show the
same window title (ActivityWatch/aw-webui#939) without a new rule type.
A fields rule carries no 'regex', so servers that predate it match nothing
for it rather than misclassifying. Combining 'fields' with 'regex' or
'select_keys', or an empty/invalid mapping, is logged and matches nothing.
Git-Session-Id: bd564fff-a9f8-42c7-a783-31ca4204a2c6
Contributor
Author
Review guide (auto-posted)Structured warm-up for reviewers — what changed, what to run, where to look. Key files
Suggested verification
Known risks / watch points
Suggested review focus
Generated by |
[Medium impact] The change reaches Python category and tag queries that classify events. The PR appears safe to merge, with a non-blocking gap in rejecting mixed rules with empty values. Findings
SummaryAdds per-field patterns to existing regex rules for categories and tags.
One non-blocking gap remains: mixed rules with empty legacy values are accepted instead of disabled. Reviews (1) · Last reviewed commit: "feat(classify): per-field patterns on th..." · Reviewed by Greptile |
Git-Session-Id: bd564fff-a9f8-42c7-a783-31ca4204a2c6
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.
Python side of the "extend the existing
regextype" direction for ActivityWatch/aw-webui#939, replacing the separateregex_fieldstype proposed in #155 (closed pending judgement).{"type": "regex", "fields": {"app": "mstsc\\.exe", "title": "office\\.example"}}fieldsmust match (AND). Each pattern uses the same unanchoredsearchasregex, andignore_caseapplies. Use^…$for an exact match, as today.regexalone andregex+select_keysbehave exactly as before.fieldsrule has noregex, so an older server matches nothing for it instead of misclassifying events.fieldscombined withregexorselect_keys, an empty or non-mapping value, or an invalid pattern is logged and the rule matches nothing. This mirrors the existing invalid-regex handling.Rule.matchand the planned fast path (_plan/_matching, used bycategorize/tag) support it.Not in this PR: the aw-server-rust twin, capability advertising, and the webui editor. The editor should only offer
fieldsonce both servers support it.Tests:
tests/test_classify_fields.pycovers the mstsc/winbox split, AND semantics, missing and non-string fields, search andignore_case, the rejected combinations, tags, and legacy rules. Local run: 188 passed across the classify, query-cache, transform and query2 suites. mypy and ruff are clean.