Registry
provide.foundation.file.operations.detectors.registry
¶
Registry for file operation detectors.
Classes¶
Functions¶
clear_detector_registry
¶
Clear all registered detectors (primarily for testing).
get_all_detectors
¶
Get all registered detectors sorted by priority (highest first).
Returns:
| Type | Description |
|---|---|
list[tuple[str, DetectorFunc, int]]
|
List of tuples: (name, detector_func, priority) |
Source code in provide/foundation/file/operations/detectors/registry.py
get_detector_registry
¶
Get the global detector registry singleton.
Returns:
| Type | Description |
|---|---|
Registry
|
Registry instance for file operation detectors |
Source code in provide/foundation/file/operations/detectors/registry.py
register_detector
¶
Register a file operation detector function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique detector name (e.g., "detect_atomic_save") |
required |
func
|
DetectorFunc
|
Detector function conforming to DetectorFunc protocol |
required |
priority
|
int
|
Execution priority (0-100, higher = earlier execution) |
required |
description
|
str
|
Human-readable description of what pattern is detected |
''
|
Raises:
| Type | Description |
|---|---|
AlreadyExistsError
|
If detector name already registered |
Example
def detect_custom_pattern(events): ... # Custom detection logic ... return FileOperation(...) if pattern_found else None
register_detector( ... name="detect_custom", ... func=detect_custom_pattern, ... priority=75, ... description="Detects custom file operation pattern" ... )