Lei.AgenticDetector (LowEndInsight v0.13.1)

Copy Markdown View Source

Classifies contributors as human, bot, or AI-assisted (agent) based on email/name patterns and commit message trailers.

Summary

Functions

Analyzes a list of contributors with their commit messages.

Classifies a contributor as :human or :bot based on name/email patterns.

Classifies an agentic contribution ratio into a human/mixed/agent label.

Detects AI co-author trailers in commit messages. Returns a deduplicated list of matched AI tool names.

Logs a deprecation warning for each legacy agentic env var that is still set. Called once at application startup via Lei.Application.

Functions

analyze(contributors_with_messages, functional_count)

@spec analyze([{map(), [String.t()]}], non_neg_integer()) :: map()

Analyzes a list of contributors with their commit messages.

Expects a list of {contributor, commit_messages} tuples where contributor is a map/struct with :name, :email, :count fields, and commit_messages is a list of commit body strings.

Returns analysis summary with classified contributors and metrics.

classify_contributor(name, email)

@spec classify_contributor(String.t(), String.t()) :: :human | :bot

Classifies a contributor as :human or :bot based on name/email patterns.

classify_ratio(ratio)

@spec classify_ratio(float()) :: {:ok, String.t()}

Classifies an agentic contribution ratio into a human/mixed/agent label.

Thresholds are controlled by env vars:

  • LEI_AGENTIC_MIXED_THRESHOLD (default 0.3): lower boundary for "mixed"
  • LEI_AGENTIC_AGENT_THRESHOLD (default 0.7): lower boundary for "agent"

Boundaries:

  • ratio < mixed_threshold → "human"
  • mixed_threshold ≤ ratio ≤ agent_threshold → "mixed"
  • ratio > agent_threshold → "agent"

Deprecated env vars LEI_CRITICAL_AGENTIC_LEVEL, LEI_HIGH_AGENTIC_LEVEL, and LEI_MEDIUM_AGENTIC_LEVEL are no longer used; a warning is logged at startup if they are set.

detect_ai_coauthors(commit_messages)

@spec detect_ai_coauthors([String.t()]) :: [String.t()]

Detects AI co-author trailers in commit messages. Returns a deduplicated list of matched AI tool names.

warn_deprecated_env_vars()

@spec warn_deprecated_env_vars() :: :ok

Logs a deprecation warning for each legacy agentic env var that is still set. Called once at application startup via Lei.Application.