Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
234 commits
Select commit Hold shift + click to select a range
4d04910
unfinished draft for NewEventDetector.
ernstleierzopf Mar 9, 2026
8fbb34d
unfinished draft NewEventDetector.
ernstleierzopf Mar 10, 2026
1076a8f
Merge pull request #91 from ait-detectmate/development
ernstleierzopf Mar 16, 2026
3ca95de
test outputs.
ernstleierzopf Mar 16, 2026
6328a43
Merge branch 'feature/new-event-detector' of github.com:ait-detectmat…
ernstleierzopf Mar 16, 2026
c5ed199
add STATIC classification trackers to all detectors.
ernstleierzopf Mar 16, 2026
d9ab23d
fix prek issues.
ernstleierzopf Mar 16, 2026
ad04055
fix prek issues.
ernstleierzopf Mar 16, 2026
fc7cc18
update gitignore
viktorbeck98 Mar 17, 2026
f5bdc8c
add option for combo and value detector to use static or stable varia…
viktorbeck98 Mar 17, 2026
a52aa36
fix prek issues
viktorbeck98 Mar 17, 2026
f5e4801
fix prek issues
viktorbeck98 Mar 17, 2026
0a55953
path_templates is not longer required by the MatcherParser
viktorbeck98 Mar 30, 2026
faea48c
Merge pull request #109 from ait-detectmate/small_fixes
ipmach Mar 30, 2026
0641866
Merge branch 'main' into development
ipmach Mar 30, 2026
b2e00b3
add security file
ipmach Mar 30, 2026
04cb190
Merge branch 'development' into fix/new_value_detector
viktorbeck98 Mar 30, 2026
67dc28b
Warn when detector config doesn't match training data
viktorbeck98 Mar 30, 2026
fe9f7c8
fix minor issue
viktorbeck98 Mar 30, 2026
3e73ae8
Merge pull request #110 from ait-detectmate/feat/security
viktorbeck98 Mar 30, 2026
f410dff
add issue and PR templates
viktorbeck98 Mar 31, 2026
f574b55
feat(config): support named wildcards and named event IDs in template…
viktorbeck98 Mar 31, 2026
1190139
Merge pull request #92 from ait-detectmate/fix/new_value_detector
ipmach Mar 31, 2026
f159791
Merge branch 'main' into development
ipmach Mar 31, 2026
467f50d
Merge pull request #113 from ait-detectmate/feat/templates
ipmach Mar 31, 2026
e7f0bf7
Merge pull request #114 from ait-detectmate/feat/configuration2.0
ipmach Mar 31, 2026
3ad3c58
Merge pull request #111 from ait-detectmate/feat/warnings
ipmach Mar 31, 2026
3b21465
Merge branch 'feature/new-event-detector' into development
ernstleierzopf Apr 1, 2026
a9112a1
Merge pull request #119 from ait-detectmate/development
ernstleierzopf Apr 1, 2026
162ebd5
Revert "Merge branch 'feature/new-event-detector' into development"
ernstleierzopf Apr 1, 2026
ec89dbc
Add log format catalog documentation
viktorbeck98 Apr 3, 2026
57199ee
adapt folder structure
viktorbeck98 Apr 3, 2026
dbc2716
fix hyperref
viktorbeck98 Apr 3, 2026
1a9f481
add new changes from NewValueDetector to NewEventDetector.
ernstleierzopf Apr 6, 2026
dfd2ca1
finalize implementation of NewEventDetector.
ernstleierzopf Apr 10, 2026
21a13b6
fix prek issues.
ernstleierzopf Apr 10, 2026
f71a8b0
add files for ValueRangeDetector.
ernstleierzopf Apr 10, 2026
13114e3
Merge branch 'development' of github.com:ait-detectmate/DetectMateLib…
ernstleierzopf Apr 10, 2026
5f12c0f
add new_event docs.
ernstleierzopf Apr 10, 2026
42bcc5d
add structure for ValueRangeDetector.
ernstleierzopf Apr 10, 2026
a7f1357
add NewEventDetector to pipeline_config_default.
ernstleierzopf Apr 10, 2026
021426f
add current state of ValueRangeDetector.
ernstleierzopf Apr 10, 2026
ec91c93
update ValueRangeDetector.
ernstleierzopf Apr 11, 2026
5e46169
extend ValueRangeDetector.
ernstleierzopf Apr 12, 2026
d3c5673
Merge pull request #120 from ait-detectmate/docs/log_format_catalog
ipmach Apr 14, 2026
b892564
add doc
ipmach Apr 14, 2026
13df401
Merge pull request #126 from ait-detectmate/imp/doc
viktorbeck98 Apr 14, 2026
0e2e81b
small change for auto config
viktorbeck98 Apr 14, 2026
6338979
Merge pull request #88 from ait-detectmate/feature/new-event-detector
viktorbeck98 Apr 14, 2026
ce68ead
Update basic_idea.md
4cti0nfi9ure Apr 14, 2026
54c0636
Update overall_architecture.md
4cti0nfi9ure Apr 14, 2026
c0a6b08
Update template_matcher.md
4cti0nfi9ure Apr 14, 2026
f9ac6c5
update versioning
ipmach Apr 16, 2026
e8c7480
first version of the code
ipmach Apr 16, 2026
d781546
add first test of tree matcher
ipmach Apr 16, 2026
1e7f432
add disclaimer
ipmach Apr 16, 2026
eb0772f
update docs for clarity
viktorbeck98 Apr 16, 2026
bba06ed
rename method
ipmach Apr 16, 2026
9b23c0b
minor update in tests
ipmach Apr 16, 2026
4bd4d85
minor type correction
ipmach Apr 16, 2026
41a1a43
add doc tree matcher
ipmach Apr 16, 2026
afdbfa5
preparing rule detector
ipmach Apr 16, 2026
d1a1021
start adding rules
ipmach Apr 16, 2026
51d4e4a
minor bug issue generated by MYPY!
ipmach Apr 16, 2026
07061e9
improve small formatting issue
ipmach Apr 16, 2026
a6ec337
add more rules
ipmach Apr 17, 2026
32124c5
Merge pull request #131 from ait-detectmate/update_docs
ipmach Apr 17, 2026
e33f146
Fix typo in template matcher documentation
thorinaboenke Apr 17, 2026
9669d66
rule detector ready
ipmach Apr 21, 2026
de1401b
remove print
ipmach Apr 21, 2026
618ddb0
prepare documentation
ipmach Apr 21, 2026
53d3b79
add rule based method documentation
ipmach Apr 21, 2026
6015037
Merge branch 'main' into development
ipmach Apr 21, 2026
6e02aaf
minor formating
ipmach Apr 23, 2026
cc7326a
improve typing
ipmach Apr 23, 2026
92b621e
small cleaning
ipmach Apr 23, 2026
a64999e
adapt input from performance
ipmach Apr 27, 2026
63a53f6
remove warning
ipmach Apr 27, 2026
bae2b50
rename treematcher
ipmach Apr 27, 2026
d027454
Merge branch 'development' into feat/tree_match
ipmach Apr 27, 2026
d781d2e
add issue templates
thorinaboenke Apr 27, 2026
6c3540a
add issue config template
thorinaboenke Apr 27, 2026
d7a93e4
update readme
thorinaboenke Apr 27, 2026
5f97586
add contribution.md
thorinaboenke Apr 27, 2026
4ba861b
add development.md
thorinaboenke Apr 27, 2026
4d1d75a
Merge branch 'development' into security_contribution_templates
thorinaboenke Apr 27, 2026
d8e039b
Delete src/detectmatelibrary/schemas/"""Integration tests for Service…
thorinaboenke Apr 27, 2026
e3ad1eb
prek
thorinaboenke Apr 27, 2026
327c96d
Merge branch 'security_contribution_templates' of https://github.com/…
thorinaboenke Apr 27, 2026
3213734
update dependency
ipmach Apr 27, 2026
ef0921e
Merge branch 'feat/tree_match' of https://github.com/ait-detectmate/D…
ipmach Apr 27, 2026
fdafec8
Merge pull request #138 from ait-detectmate/security_contribution_tem…
ipmach Apr 30, 2026
7371bba
change message of template_not_found rule
ipmach Apr 30, 2026
655c1bf
update documentation to be consistent with code
ipmach Apr 30, 2026
ec7641f
Merge pull request #129 from ait-detectmate/feat/tree_match
ipmach Apr 30, 2026
9d5cc1a
solve test issues
ipmach Apr 30, 2026
7717195
add buffer_train from configuration
ipmach Apr 30, 2026
c981bf5
improve testing
ipmach Apr 30, 2026
2096e7c
remove unnecessary print in test_new_event_detector.
ernstleierzopf May 4, 2026
6239314
remove unnecessary import.
ernstleierzopf May 4, 2026
4479aaa
Merge branch 'feature/value-range-detector' into mergebranch-DELETE
ernstleierzopf May 4, 2026
f6d9e25
Merge pull request #143 from ait-detectmate/mergebranch-DELETE
ernstleierzopf May 4, 2026
8fff876
implement ignore_non_numerical_val in ValueRangeDetector.
ernstleierzopf May 4, 2026
624713e
Merge pull request #132 from ait-detectmate/feat/rule_detector
viktorbeck98 May 4, 2026
70305e6
change name to be agent agnostic
viktorbeck98 May 4, 2026
5ad3abe
Merge branch 'development' into feat/bench_ready
ipmach May 4, 2026
955ef9b
free memory of buffer train
ipmach May 4, 2026
a02ed75
add from polars
ipmach May 4, 2026
3247a15
add polars2json and correct minor bug in from.polars
ipmach May 4, 2026
61625c2
add polars to binary files
ipmach May 4, 2026
40d49c6
add from polars to yaml
ipmach May 4, 2026
62af97e
add test case polars
ipmach May 4, 2026
2d4c023
trainbuffer now is a class
ipmach May 4, 2026
50ed746
update documentation
ipmach May 4, 2026
9bdb4e2
feat: add PersistencyLoadError and dump/load protocol to EventDataStr…
viktorbeck98 May 4, 2026
2327e4c
test: strengthen abstract contract verification for EventDataStructure
viktorbeck98 May 4, 2026
7bb165d
feat: add to_state/from_state serialization to SingleStabilityTracker
viktorbeck98 May 4, 2026
b7a8617
Merge pull request #142 from ait-detectmate/feat/bench_ready
viktorbeck98 May 4, 2026
18990b4
feat: implement dump/load on EventTracker via MessagePack
viktorbeck98 May 4, 2026
a72b03a
docs: document converter_function and event_id limitations in EventTr…
viktorbeck98 May 4, 2026
6aa82f5
feat: implement dump/load on EventDataFrame via Parquet
viktorbeck98 May 4, 2026
b0d9c7e
docs: document event_id/template limitations in EventDataFrame load
viktorbeck98 May 4, 2026
357e7a8
feat: implement dump/load on ChunkedEventDataFrame via Parquet + msgp…
viktorbeck98 May 4, 2026
bec28ee
feat: add _dirty_count counter and reset_dirty_count() to EventPersis…
viktorbeck98 May 4, 2026
b842599
feat: add PersistencySaverConfig and _SaveTimer
viktorbeck98 May 4, 2026
5b227b1
feat: implement PersistencySaver save() and load() with fsspec
viktorbeck98 May 4, 2026
36962a2
fix: collapse _tick dead branch, coerce event ID types on load, impro…
viktorbeck98 May 4, 2026
997acdc
test: add trigger tests for PersistencySaver timer, dirty threshold, …
viktorbeck98 May 4, 2026
c869b68
fix: join timer thread in stop(), rename misleading dirty-threshold test
viktorbeck98 May 4, 2026
dc7a2f6
feat: add context manager protocol to Component for saver cleanup
viktorbeck98 May 4, 2026
0e7f2ac
fix: remove redundant hasattr, add _Stoppable Protocol type for saver
viktorbeck98 May 4, 2026
e07853f
test: add integration tests for full save/load cycle across backends
viktorbeck98 May 4, 2026
3d36643
test: add cell-value assertion to DataFrame integration test
viktorbeck98 May 4, 2026
9d3d5bb
chore: add fsspec, msgpack, pyarrow deps with optional s3/gcs/azure e…
viktorbeck98 May 4, 2026
2ef2b47
adapt gitignore
viktorbeck98 May 6, 2026
03e8162
minor changes
viktorbeck98 May 6, 2026
5c704fd
chore: never commit design docs
viktorbeck98 May 6, 2026
204bd1f
feat: change dirty_threshold default to None in PersistencySaverConfig
viktorbeck98 May 6, 2026
ac2f1fc
feat: add PersistConfig model and persist field to CoreDetectorConfig
viktorbeck98 May 6, 2026
5cd8d39
feat: add _register_persistency() helper to CoreDetector
viktorbeck98 May 6, 2026
7b1a58a
style: fix import ordering in detector.py
viktorbeck98 May 6, 2026
515ee3b
feat: handle persist block in config serialization and suppress spuri…
viktorbeck98 May 6, 2026
7f9cd7e
style: update MissingParamsWarning message to include global and persist
viktorbeck98 May 6, 2026
8bbc6df
feat: wire _register_persistency() into NewValueDetector, NewValueCom…
viktorbeck98 May 6, 2026
9b47ffd
fix: preserve persist config across set_configuration() rebuild
viktorbeck98 May 6, 2026
b893e98
fix: filter non-serializable event_data_kwargs and make stop() idempo…
viktorbeck98 May 6, 2026
1049ab0
refactor: rename dirty counter to events_since_save / events_until_save
viktorbeck98 May 6, 2026
bceb931
docs: document persist block, PersistencySaver API, and storage optio…
viktorbeck98 May 6, 2026
a58d016
docs: add persist block and detector wiring guidance to AGENTS.md
viktorbeck98 May 6, 2026
f80041e
feat: implement events_until_save trigger in PersistencySaver
viktorbeck98 May 6, 2026
57830a2
chore: merge development into feat/save_persistency
viktorbeck98 May 6, 2026
2c59e91
finalize ValueRangeDetector.
ernstleierzopf May 8, 2026
b0b3536
Merge branch 'development' into feature/value-range-detector
ernstleierzopf May 8, 2026
fba1edd
reset correct logger level in ValueRangeDetector tests.
ernstleierzopf May 8, 2026
256d471
extend pipeline_config_default.yml with ValueRangeDetector.
ernstleierzopf May 8, 2026
eb2fa53
Merge branch 'feature/value-range-detector' of github.com:ait-detectm…
ernstleierzopf May 8, 2026
d85ccab
small bugfix.
ernstleierzopf May 8, 2026
353b282
refactor: drop explicit pyarrow API in EventDataFrame
viktorbeck98 May 12, 2026
8534b8c
docs: explain msgpack config header layout in ChunkedEventDataFrame.dump
viktorbeck98 May 12, 2026
5202bed
implement CharsetDetector.
ernstleierzopf May 13, 2026
596294a
Apply suggestions from code review
ernstleierzopf May 13, 2026
6838603
change exit to sys.exit in CharsetDetector.
ernstleierzopf May 13, 2026
5b81e9d
first commit for EntropyDetector.
ernstleierzopf May 14, 2026
d41068d
rename EntropyDetector to BigramFrequencyDetector.
ernstleierzopf May 14, 2026
aa19b10
refactor: treat persistency as a sub-library and slim CoreDetector
viktorbeck98 May 15, 2026
72b2f72
Merge pull request #144 from ait-detectmate/feat/save_persistency
ipmach May 17, 2026
9789e60
first implementation of BigramFrequencyDetector.
ernstleierzopf May 18, 2026
6940b59
fix CharsetDetector.
ernstleierzopf May 18, 2026
4f6df6b
fix content_parser_name in json_parser.
ernstleierzopf May 18, 2026
03f7fba
add BigramFrequencyDetector to pipeline_config_default.yml.
ernstleierzopf May 18, 2026
8da2cd0
fix wrong usage of TemplateMatcher in AGENTS.md.
ernstleierzopf May 18, 2026
bb2a7e2
Add dynamic version to pyproject.toml.
ernstleierzopf May 18, 2026
e4f2556
fix CI errors.
ernstleierzopf May 18, 2026
54e7e62
Merge pull request #153 from ait-detectmate/fix/refactor_matcher_parser
viktorbeck98 May 19, 2026
8d5be0c
Merge pull request #152 from ait-detectmate/fix/json_matcher
viktorbeck98 May 19, 2026
ea19067
Merge branch 'development' into feature/charset-detector
viktorbeck98 May 19, 2026
36c469c
feat(persistency): add expand_value flag to SingleStabilityTracker
viktorbeck98 May 19, 2026
a105317
feat(persistency): persist expand_value through tracker serialization
viktorbeck98 May 19, 2026
8fba9ef
feat(persistency): expose expand_value on EventStabilityTracker
viktorbeck98 May 19, 2026
b87706f
fix(persistency): honor subclass __init__ on EventTracker.load
viktorbeck98 May 19, 2026
ab74cc2
docs(persistency): document EventTracker.load subclass contract
viktorbeck98 May 19, 2026
d38060d
feat(charset): store characters per variable instead of full values
viktorbeck98 May 19, 2026
7b809a3
feat(charset): rewrite detect() as O(len(value)) char-set difference
viktorbeck98 May 19, 2026
648ffc4
fix(charset): preserve persist config across set_configuration()
viktorbeck98 May 19, 2026
5336d98
refactor(persistency): widen single_tracker_type to Callable
viktorbeck98 May 19, 2026
5a6b70b
Merge pull request #148 from ait-detectmate/feature/charset-detector
viktorbeck98 May 19, 2026
0dab8a6
Merge branch 'development' into feature/bigram-detector
viktorbeck98 May 19, 2026
e2b80be
feat(persistency): add generic extra_state slot on SingleStabilityTra…
viktorbeck98 May 20, 2026
374e8fb
test(persistency): cover extra_state msgpack round-trip
viktorbeck98 May 20, 2026
5c1ee1f
refactor(constants): drop dead leading flag and ignore-chars from DEF…
viktorbeck98 May 20, 2026
b287a7f
feat(bigram): register persistency and remove instance-level model state
viktorbeck98 May 20, 2026
544ae80
test(bigram): assert _register_persistency received correct persisten…
viktorbeck98 May 20, 2026
e774209
fix(bigram): preserve persist config across set_configuration()
viktorbeck98 May 20, 2026
dc43a80
fix(bigram): train per-variable bigram frequencies, fix first-occurre…
viktorbeck98 May 20, 2026
037c42c
test(bigram): deduplicate skip_repetitions config in tests
viktorbeck98 May 20, 2026
53aae84
fix(bigram): widen detect_helper event_id to int | str and add tracke…
viktorbeck98 May 20, 2026
61036fd
test(bigram): cover detect None guard and default_freqs fallback
viktorbeck98 May 20, 2026
1ff2e4f
test(bigram): cover save/load round-trip and per-var isolation
viktorbeck98 May 20, 2026
0a397c5
docs(bigram): describe bigram-frequency detection, not new-value
viktorbeck98 May 20, 2026
7d41548
Merge remote-tracking branch 'origin/development' into feature/value-…
viktorbeck98 May 20, 2026
76fe4d7
update metadata to match DetectMateService metadata.
ernstleierzopf May 21, 2026
1163364
fix init.
ernstleierzopf May 21, 2026
21c0782
Merge pull request #154 from ait-detectmate/feature/metadata
whotwagner May 21, 2026
a0fb189
Merge pull request #162 from ait-detectmate/development
ernstleierzopf May 26, 2026
6b556c0
move dummy_detector into test_detectors
ernstleierzopf May 28, 2026
534de20
add dummy detector and parser to tests.
ernstleierzopf May 28, 2026
548df5d
fix prek tests.
ernstleierzopf May 31, 2026
b8e8153
fix pyproject.toml.
ernstleierzopf May 31, 2026
b768a2b
move global variables for tests.
ernstleierzopf May 31, 2026
570e5da
Merge pull request #149 from ait-detectmate/feature/bigram-detector
viktorbeck98 Jun 1, 2026
00505ea
Merge branch 'development' into feature/value-range-detector
ernstleierzopf Jun 1, 2026
7f45d4f
Merge pull request #125 from ait-detectmate/feature/value-range-detector
viktorbeck98 Jun 1, 2026
3af5276
docs: fix json_parser and new_value examples to match actual code beh…
viktorbeck98 Jun 3, 2026
0821bcf
minor change
viktorbeck98 Jun 3, 2026
11a9a51
Merge branch 'development' of github.com:ait-detectmate/DetectMateLib…
ernstleierzopf Jun 4, 2026
f5b3664
fix tools imports.
ernstleierzopf Jun 4, 2026
342eac4
fix test paths.
ernstleierzopf Jun 4, 2026
1b62bd6
fix prek fails.
ernstleierzopf Jun 4, 2026
ceda9d8
Merge pull request #163 from ait-detectmate/fix/move_dummy_classes
viktorbeck98 Jun 4, 2026
d306977
Merge branch 'development' into fix/docs
viktorbeck98 Jun 4, 2026
7ef30d2
Merge pull request #165 from ait-detectmate/fix/docs
ipmach Jun 5, 2026
8174aef
add update_state in coreComponent
ipmach Jun 5, 2026
29b73e5
check what is wrong
ipmach Jun 5, 2026
4f5194e
Merge branch 'development' into feat/start_stop_training
ipmach Jun 5, 2026
6a3c3cf
update doc
ipmach Jun 5, 2026
0155c9b
add warning
ipmach Jun 8, 2026
88e6126
small refavctor tests and preparing get_state
ipmach Jun 12, 2026
fb7bff1
add get_state logic
ipmach Jun 12, 2026
d963b98
add extra test verifications
ipmach Jun 12, 2026
4f028cc
minor change
ipmach Jun 12, 2026
61dd23e
update docs
ipmach Jun 12, 2026
72a4ae6
Add GitHub Actions workflow for Python package upload
whotwagner Jun 12, 2026
459b178
Merge pull request #169 from ait-detectmate/feat/start_stop_training
whotwagner Jun 12, 2026
8971e6a
Merge branch 'main' into development
ipmach Jun 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/01_bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: 🐜 Bug report
about: If something isn't working 🔧
---

### Subject of the issue
Describe your issue here.

### Your environment
* Version of detectmate
* Version of python
* Docker or manual installation?

### Steps to reproduce
Tell us how to reproduce this issue.

### Expected behaviour
Tell us what should happen

### Actual behaviour
Tell us what happens instead
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/02_feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: 🚀 Feature request
about: If you have a feature request 💡
---

**Context**

What are you trying to do and how would you want to do it differently? Is it something you currently you cannot do? Is this related to an issue/problem?

**Alternatives**

Can you achieve the same result doing it in an alternative way? Is the alternative considerable?

**Has the feature been requested before?**

Please provide a link to the issue.

**If the feature request is approved, would you be willing to submit a PR?**

Yes / No _(Help can be provided if you need assistance submitting a PR)_
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Task
<!-- Please add link a relevant issue or task -->

# Description
<!-- Please include a summary of the change -->
<!-- Any details that you think are important to review this PR? -->
<!-- Are there other PRs related to this one? -->

# How Has This Been Tested?
<!-- Please describe how you tested your changes -->

# Checklist
<!-- Go over all the following points, and put an `x` in all the boxes that apply -->

- [ ] This Pull-Request goes to the **development** branch.
- [ ] I have successfully run prek locally.
- [ ] I have added tests to cover my changes.
- [ ] I have linked the issue-id to the task-description.
- [ ] I have performed a self-review of my own code.
26 changes: 26 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ __pycache__/
# C extensions
*.so

dummy*

# Distribution / packaging
.Python
build/
Expand Down Expand Up @@ -199,3 +197,9 @@ cython_debug/
local/
test.ipynb
test.py

# claude code
CLAUDE.md
docs/superpowers/
docs/design/
.claude/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
hooks:
- id: mypy
args: [--strict, --ignore-missing-imports]
exclude: ^(docs/|tests/)
exclude: ^(docs/|detectmatelibrary_tests/)
additional_dependencies:
- pydantic
- types-PyYAML
Expand Down Expand Up @@ -58,7 +58,7 @@ repos:
rev: 1.8.6
hooks:
- id: bandit
exclude: (^tests/|.*/test_.*|^test_.*)
exclude: (^detectmatelibrary_tests/|.*/test_.*|^test_.*)

# Unused code detection
- repo: https://github.com/jendrikseipp/vulture
Expand Down
199 changes: 199 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# AGENTS.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

DetectMateLibrary is a Python library for log processing and anomaly detection. It provides composable, stream-friendly components (parsers and detectors) that communicate via Protobuf-based schemas. The library is designed for both single-process and microservice deployments.

## Development Commands

```bash
# Install dependencies and pre-commit hooks
uv sync --dev
uv run prek install

# Run tests
uv run pytest -q
uv run pytest -s # verbose with stdout
uv run pytest --cov=. --cov-report=term-missing # with coverage
uv run pytest detectmatelibrary_tests/test_foo.py # single test file

# Run linting/formatting (all pre-commit hooks)
uv run prek run -a

# Recompile Protobuf (only if schemas.proto is modified)
protoc --proto_path=src/detectmatelibrary/schemas/ \
--python_out=src/detectmatelibrary/schemas/ \
src/detectmatelibrary/schemas/schemas.proto

# Scaffold a new component workspace
mate create --type <parser|detector> --name <name> --dir <target_dir>
```

## Architecture

### Data Flow

```
Raw Logs → Parser → ParserSchema → Detector → DetectorSchema (Alerts)
```

All data flows through typed Protobuf-backed schema objects. Components are stateful and support an optional training phase before detection.

### Core Abstractions (`src/detectmatelibrary/common/`)

- **`CoreComponent`** — base class managing buffering, ID generation, and training state
- **`CoreParser(CoreComponent)`** — parse raw logs into `ParserSchema`
- **`CoreDetector(CoreComponent)`** — detect anomalies in `ParserSchema`, emit `DetectorSchema`
- **`CoreConfig`** / **`CoreParserConfig`** / **`CoreDetectorConfig`** — Pydantic-based configuration hierarchy (`extra="forbid"`)

#### Component Lifecycle (FitLogic)

Each `process()` call passes through a state machine controlled by config fields:

| Config field | Meaning |
|---|---|
| `data_use_configure` | How many items to run through `configure()` before training. `None` = skip. |
| `data_use_training` | How many items to run through `train()` before detection. `None` = skip. |

Phases in order: **CONFIGURE → TRAIN → DETECT** (phases are skipped when the corresponding field is `None`).

State control enums allow overriding automatic transitions: `TrainState.KEEP_TRAINING` / `STOP_TRAINING` and `ConfigState.KEEP_CONFIGURE` / `STOP_CONFIGURE` on the component's `fit_logic`.

#### CoreDetectorConfig: EventsConfig

Detectors use a nested `events` structure to select which variables to track per event ID, plus `global_instances` for event-ID-independent variables (e.g., hostname, level):

```yaml
detectors:
MyDetector:
method_type: new_value_detector
auto_config: false # true = auto-discover variables from training data
persist: # optional — omit to disable state saving
path: ./state # base path; detector name is appended automatically
interval_seconds: 300 # save every N seconds
events_until_save: null # also save after N ingested events (null = disabled)
auto_load: false # restore saved state on construction
storage_options: {} # fsspec credentials (S3, Azure, GCS, etc.)
events:
login_failure: # named event ID (string) or integer EventID
instance_label: # arbitrary instance name
params: {}
variables:
- pos: pid # named wildcard label OR integer position in ParserSchema.variables[]
name: pid
header_variables:
- pos: Type # key in ParserSchema.logFormatVariables{}
params: {}
global: # event-ID-independent instances (GLOBAL_EVENT_ID = "*")
global_monitor:
header_variables:
- pos: Level
params: {}
```

Named event IDs (strings) and named variable positions require templates loaded from a CSV with an `EventId` column. Call `TemplateMatcher.compile_detector_config(config)` to resolve names to integers at setup time.

Use `generate_detector_config()` (`src/detectmatelibrary/common/_config/_compile.py`) to build this programmatically:

```python
from detectmatelibrary.common._config import generate_detector_config

config = generate_detector_config(
variable_selection={1: ["var_0", "var_1"]},
detector_name="MyDetector",
method_type="new_value_detector",
)
```

Load/save configs via `BasicConfig.from_dict(d, method_id=...)` and `.to_dict(method_id=...)` for YAML round-trip compatibility.

After training completes, detectors with `auto_config=False` automatically call `validate_config_coverage()` (`src/detectmatelibrary/common/detector.py`), which logs warnings when configured EventIDs or variable positions were never observed in training data. This catches config/data mismatches early — check logs after the training phase when adding new detector configs.

### Schema System (`src/detectmatelibrary/schemas/`)

- `BaseSchema` wraps generated Protobuf messages with dict-like access (`schema["field"]`)
- Key schemas: `LogSchema`, `ParserSchema`, `DetectorSchema`
- Support serialization to/from bytes for transport and persistence

### Buffering Modes (`src/detectmatelibrary/utils/data_buffer.py`)

Three modes via `ArgsBuffer` config:
- **NO_BUF** — one item at a time (default)
- **BATCH** — accumulate N items, process as batch
- **WINDOW** — sliding window of size N

### Implementations

- **Parsers** (`src/detectmatelibrary/parsers/`): `JsonParser`, `LogBatcherParser`, `DummyParser`, `MatcherParser` (Drain3 template mining; supports named wildcards `<username>` alongside positional `<*>`)
- **Detectors** (`src/detectmatelibrary/detectors/`): `NewValueDetector`, `NewValueComboDetector`, `RandomDetector`, `DummyDetector`
- **Utilities** (`src/detectmatelibrary/utils/`): `DataBuffer`, `EventPersistency`, `KeyExtractor`, `TimeFormatHandler`, `IdGenerator`
- Uses the `regex` package (not stdlib `re`) — relevant when writing type annotations or imports involving patterns

## Extending the Library

Implement a custom detector by subclassing `CoreDetector`:

```python
class MyDetectorConfig(CoreDetectorConfig):
method_type: str = "my_detector"
my_param: int = 10

class MyDetector(CoreDetector):
def __init__(self, name="MyDetector", config=MyDetectorConfig()):
super().__init__(name=name, config=config)

def train(self, input_: ParserSchema) -> None:
pass # optional

def detect(self, input_: ParserSchema, output_: DetectorSchema) -> bool:
output_["detectorID"] = self.name
output_["score"] = 0.0
return False # True = anomaly detected
```

Same pattern applies for `CoreParser` — implement `parse(input_: LogSchema, output_: ParserSchema) -> bool`.

### Wiring persist support into a new detector

Detectors that maintain an `EventPersistency` instance must do two things to support the `persist:` config block:

**1. Call `_register_persistency()` at the end of `__init__`:**

```python
def __init__(self, name="MyDetector", config=MyDetectorConfig()):
super().__init__(name=name, config=config)
self.persistency = EventPersistency(event_data_class=EventStabilityTracker)
self._register_persistency(self.persistency) # must be last
```

**2. Preserve `config.persist` across `set_configuration()` rebuilds:**

`set_configuration()` replaces `self.config` via `from_dict()`, which produces a config with no `persist` key — silently dropping the user's persist settings. Save and restore it:

```python
def set_configuration(self) -> None:
old_persist = self.config.persist
# ... build config_dict, call from_dict() ...
self.config = MyDetectorConfig.from_dict(config_dict, self.name)
self.config.persist = old_persist
```

Omitting either step means a `persist:` block in the YAML is silently ignored with no error.

## Code Quality

Pre-commit hooks enforce:
- **mypy** strict mode
- **flake8** linting, **autopep8** formatting (max line 110)
- **bandit** security checks, **vulture** dead-code detection (70% threshold)
- **docformatter** docstring style

Python 3.12 is required (see `.python-version`).


# Git
NEVER include "Co-Authored-By ..." in your commit or PR messages.

Design documents (files under `docs/design/`) must NEVER be committed to the repository.
Loading
Loading