Skip to content

feat(vcli-perception): Tier-1 and Tier-2 predicate evaluators - #8

Merged
blaksmatic merged 16 commits into
masterfrom
implement/plan-2-vcli-perception
Apr 17, 2026
Merged

blaksmatic merged 16 commits into
masterfrom
implement/plan-2-vcli-perception

Conversation

@blaksmatic

Copy link
Copy Markdown
Owner

Summary

  • Implements vcli-perception crate (Tasks 1–15 of plan 2026-04-16-vcli-perception.md), providing all predicate evaluators for the vcli perception pipeline
  • Adds DashMap-backed PredicateCache (per-tick, cleared by runtime at tick start) and PerceptionState (cross-tick: dHash snapshots for pixel_diff, first-true timers for elapsed_ms_since_true)
  • Implements six evaluator kinds: ColorAt (pixel sample + Euclidean distance), PixelDiff (dHash motion detection), AllOf/AnyOf/Not (logical composition with depth-bounded recursion and shared-cache dedup), ElapsedMsSinceTrue (program-scoped rising-edge timer), Template (imageproc NCC with bbox recovery)
  • Perception façade wraps everything with evaluate_named(), memoizes through PredicateCache, and routes to per-kind evaluators

Key design decisions

  • Decision A: Evaluator is &self + Send + Sync (safe under rayon::par_iter)
  • DashMap 6 for both cache and state (lock-free concurrent access)
  • imageproc 0.25 CrossCorrelationNormalized for NCC; templates must have non-zero variance (constant templates return NCC=0 — documented in test comments)
  • All canonical JSON hashing via vcli_core::predicate_hash() for content-addressed cache keys
  • #![forbid(unsafe_code)], #![deny(rust_2018_idioms)], #![warn(clippy::pedantic)]

Verification gate (Task 15)

  • cargo fmt --all -- --check — PASS
  • cargo clippy -p vcli-perception --all-targets -- -D warnings — PASS (0 warnings)
  • cargo clippy --workspace --all-targets -- -D warnings — PASS (0 warnings)
  • cargo test --workspace --locked — PASS (141 tests: 84 vcli-core + 55 vcli-perception)
  • cargo doc -p vcli-perception --no-deps — PASS (0 warnings)
  • cargo check --workspace — PASS

Test plan

  • cargo test --workspace --locked runs green (141 tests)
  • cargo clippy --workspace --all-targets -- -D warnings produces no output
  • cargo doc -p vcli-perception --no-deps builds without warnings
  • All six predicate evaluator kinds have unit tests covering truthy, falsy, and error paths
  • Integration tests in tests/cache_and_state.rs verify cross-tick state persistence and per-tick cache dedup

🤖 Generated with Claude Code

blaksmatic and others added 16 commits April 17, 2026 07:41
…ursion

Plan deviation: stub perception.rs pre-wires ColorAt + PixelDiff dispatch
so logical evaluator tests can call through to leaf evaluators; the full
façade is wired in Task 13.
Plan deviation: NCC (CrossCorrelationNormalized) returns 0 for constant-
valued (all-black) templates due to zero variance. Adapted test to use a
template with variation (white border + black inner block) and a matching
scene. The evaluator implementation is unchanged; only the test fixture
was adapted. Noted in template.rs test doccomment.
Fix all clippy::pedantic warnings surfaced by -D warnings:
- doc_markdown: backtick-wrap DashMap, pixel_diff, elapsed_ms_since_true,
  program_id, predicate_name identifiers in doc comments
- many_single_char_names: #[allow] on ColorAtEvaluator::sample (r/g/b/dr/dg/db
  are the only natural names for RGB components)
- cast_sign_loss / cast_possible_wrap / cast_possible_truncation: replace bare
  `as` casts with #[allow]-annotated let bindings at each site; all casts are
  provably safe (coords non-negative after guard, dimensions < 2^31)

Verification gate (Task 15):
  cargo fmt --all -- --check       PASS (no diffs)
  cargo clippy -p vcli-perception  PASS (0 warnings)
  cargo clippy --workspace         PASS (0 warnings)
  cargo test --workspace --locked  PASS (141 tests: 84 core + 55 perception)
  cargo doc -p vcli-perception     PASS (no warnings)
  cargo check --workspace          PASS

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…li-perception

# Conflicts:
#	Cargo.lock
#	Cargo.toml
@blaksmatic
blaksmatic merged commit 16385ef into master Apr 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant