Skip to content

Add bulk rule loading from CSV and JSON files#120

Open
ColtonPayne wants to merge 35 commits intomainfrom
add-bulk-rule-loading
Open

Add bulk rule loading from CSV and JSON files#120
ColtonPayne wants to merge 35 commits intomainfrom
add-bulk-rule-loading

Conversation

@ColtonPayne
Copy link
Collaborator

@ColtonPayne ColtonPayne commented Feb 6, 2026

Summary

Adds bulk rule loading from CSV and JSON files, following the same pattern established in PR #100 for bulk fact loading. Also updates the existing text file loader with a raise_errors parameter for consistency (set to False by default for the old text loader only to avoid breaking changes)

Resolves #117

Three-tier rule loading

Each file format supports a different level of expressiveness:

Feature Text (.txt) CSV (.csv) JSON (.json)
rule_text per rule per rule per rule
name auto-generated per rule per rule
infer_edges uniform (function param) per rule per rule
set_static False (default) per rule per rule
custom_thresholds not supported not supported per rule
weights not supported not supported per rule
raise_errors default False True True
  • Text (add_rules_from_file): Simplest format. One rule per line. infer_edges is applied uniformly to all rules. raise_errors defaults to False for backwards compatibility.
  • CSV (add_rule_from_csv): Per-rule control over infer_edges and set_static. Supports flexible boolean formats (True/true/1/yes). Auto-detects headers.
  • JSON (add_rule_from_json): Full expressiveness. Supports all Rule parameters including custom_thresholds (as serialized Threshold objects) and weights per rule.

Other changes

  • Adds duplicate rule name detection with configurable error/warning behavior
  • Adds shared _parse_bool_param() and _parse_and_validate_rule_params() helpers
  • Includes comprehensive test coverage (32 new tests across 3 test classes)

Test plan

  • All 32 new tests pass (12 TestAddRulesFromFile + 9 TestAddRuleFromCSV + 11 TestAddRuleFromJSON)
  • Existing tests remain unaffected
  • Tests cover: valid loading, error handling, duplicate detection, edge cases (empty files, missing fields, invalid types), boolean format flexibility, threshold/weight parsing

🤖 Generated with Claude Code

ColtonPayne and others added 4 commits February 4, 2026 11:48
Implements add_rule_from_csv() and add_rule_from_json() for bulk rule
loading, following the same pattern as bulk fact loading from PR #100.
Updates add_rules_from_file() with raise_errors parameter for
backwards-compatible error handling. Adds comprehensive test coverage.

Resolves #117

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ColtonPayne ColtonPayne added the Ready for Review Awaiting PR Review label Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Review Awaiting PR Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk Rule Loading from CSV and JSON Files

2 participants