Skip to content

State Vectors

The engine reduces a diff to six vectors plus a bounded health score, then derives a severity level suitable for gating pipelines.

The six vectors

VectorFieldSource
Securitymetrics.security_violationsgrep -ciE of added lines against config/rules/security.yml
Massmetrics.mass_insertions/deletions/mass_files_changedgit diff --shortstat
Entropymetrics.entropy_nodeslexical stripper (removes strings + comments) then branch-keyword count
Testingmetrics.test_files_modifiedfilename match against config/rules/tests.yml
Debtmetrics.debt_issuesgrep -ciE of added lines against config/rules/debt.yml
Check verdictcheck.level, check.reasons[]derived (see below)

The regex bundles ship with sensible defaults; replace them with your own in config/rules/*.yml. --validate confirms each patterns key is a valid POSIX ERE before load.

Health score

Starts at 100. Penalty rules:

TriggerPenalty
Any security_violations > 0-50
mass_insertions > threshold_mass_critical-(20 + files_changed × 2)
mass_insertions > threshold_mass_warn-(10 + files_changed)
entropy_nodes > threshold_entropy_critical-15
entropy_nodes > threshold_entropy_warn-8
Each debt_issues-5 per occurrence
Any test_files_modified > 0+10 (clamped ≤ 100)

Clamped to [0, 100]. Exposed as health_score and shown as a bar in the TUI / dashboard.

Severity levels

Computed independently of the score; the score is a continuous heuristic, severity is a discrete gate.

none  <  low  <  medium  <  high  <  critical

Promotion rules (always move up, never down):

LevelPromoted when
criticalsecurity_violations > 0 · intelligence.syntax_invalid non-empty · any analyzer finding severity: critical
highmass_insertions > threshold_mass_critical · entropy_nodes > threshold_entropy_critical · infrastructure_changes non-empty · schema_mutations non-empty · any analyzer high
mediummass_insertions > threshold_mass_warn · entropy_nodes > threshold_entropy_warn · debt_issues >= 5 · any analyzer medium
lowdebt_issues > 0 · network_outbound non-empty · any analyzer low
noneno triggers

check.reasons[] enumerates every trigger that fired, in the order listed above. Agents can inspect this array to explain a failed --check --fail-on.

Thresholds

Defaults (overridable in config/main.yml):

KeyDefault
threshold_mass_warn150
threshold_mass_critical300
threshold_entropy_warn5
threshold_entropy_critical10

Constraint enforced by --validate: warn < critical for both mass and entropy, otherwise the config is rejected with exit 3.

Example check block

json
"check": {
  "level": "critical",
  "reasons": [
    "security_violations=1",
    "mass=420>300",
    "schema_mutations_present",
    "analyzer_critical=2",
    "analyzer_high=1"
  ]
}

Each reason is a stable, machine-parseable token of the form <signal>=<value> or <signal>_present.

Released under the MIT License.