chump-perception 0.1.0

Structured perception layer for LLM agents: rule-based extraction of entities, constraints, risk indicators, ambiguity score, and task type from raw user input. No LLM calls — fast pattern matching only.
Documentation
  • Coverage
  • 15.79%
    3 out of 19 items documented0 out of 4 items with examples
  • Size
  • Source code size: 20.64 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.07 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 47s Average build duration of successful builds.
  • all releases: 47s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • repairman29/chump
    0 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • repairman29

chump-perception

Structured perception layer for LLM agents. Runs rule-based extraction on raw user input and produces a typed PerceivedInput struct with:

  • Entities — capitalized words, quoted strings, file paths, version numbers
  • Constraints — "must", "before", "cannot", "exactly N" markers
  • Risk indicators — destructive verbs ("delete", "force-push"), urgency words
  • Ambiguity score (0.0 – 1.0) — heuristic over question count, entity scarcity, vague pronouns
  • Question count? density
  • Task typeQuestion, Action, Planning, Research, Meta, Unclear

No LLM calls. Pure pattern-matching, ~100µs per call.

Why a separate crate

The reference architecture pattern of "perceive → reason → act" is general. Any agent framework benefits from a structured pre-reasoning view of the input that downstream code can branch on (clarify when ambiguity > 0.7, refuse when risk > 0, choose tool budget by task_type, etc.). This crate ships that layer in isolation so it can be reused outside chump.

Install

cargo add chump-perception

Use

use chump_perception::{perceive, TaskType};

let p = perceive("delete src/foo.rs", /* needs_tools_hint */ true);
assert!(p.risk_indicators.iter().any(|r| r == "delete"));
assert_eq!(p.task_type, TaskType::Action);
assert!(p.ambiguity_level < 0.5);

let q = perceive("what was that thing?", false);
assert_eq!(q.task_type, TaskType::Question);
assert!(q.ambiguity_level > 0.5);

API

symbol what
perceive(text, needs_tools_hint) -> PerceivedInput the main entry point
PerceivedInput struct with all extracted fields
TaskType enum: Question / Action / Planning / Research / Meta / Unclear
context_summary(p) -> String one-line digest suitable for injection into a system prompt

Implements serde::Serialize for both PerceivedInput and TaskType so they round-trip through JSON / blackboard / log.

Status

  • v0.1.0 — initial publish (extracted from the chump repo, where it powers the agent-loop pre-reasoning step)
  • 9 unit tests cover the major code paths (entity extraction, risk detection, ambiguity scoring, task classification)

License

MIT.

Companion crates