Skip to main content

Module rules

Module rules 

Source
Expand description

Rules store with immune-system lifecycle and TTL decay.

Rules are learned from post-mortem analysis and enforced via hooks. Each rule follows an immune-system lifecycle:

Proposed -> Active -> Dormant -> Settled -> Dead | Superseded –+

Three decay mechanisms:

  • Time decay: TTL (default 30 days), reset on each trigger hit
  • Anchor decay: Rule anchored to file; file changes -> stale
  • Contradiction detection: Same trigger, different action -> supersede

Structs§

Rule
A learned rule with TTL decay.
RulesStore
The rules store: manages rules.json persistence and lifecycle.
StoreStats
Summary statistics for the rules store.

Enums§

RuleCategory
What kind of rule this is — determines enforcement mechanism.
RuleStatus
Rule lifecycle status (immune system model).

Constants§

DISALLOWED_TRIGGER_WORDS
Shell builtins, keywords, and ubiquitous utilities whose failures are environmental noise rather than a missing-tool signal. They must never become learned-rule command triggers (GH-813: echo 1789 / cd 1618 hits).

Functions§

command_word
Quote-aware command word of a command segment.
is_disallowed_trigger
True when a stored rule trigger is disallowed and should be reclaimed by the decay cycle. ONLY command_failure: triggers can be disallowed command triggers: file_churn:<path> (paths may contain =), multi_agent_start, and free-text triggers are never revoked by the decay cycle (GH-813).
is_trackable_command
True when a command may become a learned-rule command trigger.
is_var_assignment
True when a bare token is a variable assignment: NAME=value or the bash append form NAME+=value. The name before = / += must be a valid shell identifier (ASCII alpha/underscore, then ASCII alphanum or underscore).
split_command_segments
Split a shell command into segments on ;, &, |, and newline.