stemedb/ai-lookup/services/lens.md
jordan a776744889 Initial project setup with Claude Code monorepo structure
- Rust workspace with stemedb-core crate
- Full .claude/ configuration (agents, skills, commands, guides)
- ai-lookup/ for token-efficient fact storage
- Quality gates: clippy, fmt, jscpd duplication detection
- Pre-commit hook with 5-phase quality checks
- CLAUDE.md router and CODING_GUIDELINES.md standards

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 10:56:26 -07:00

47 lines
1.3 KiB
Markdown

# Lens
**Last Updated:** 2025-01-31
**Confidence:** High
## Summary
A Lens resolves conflicting assertions into a deterministic answer at read time. Multiple truths coexist; the Lens chooses which to return.
**Key Facts:**
- Stateless compute (no side effects)
- Deterministic (same input = same output)
- Fast (runs on every read, avoid allocations)
- Pluggable (implement `Lens` trait)
**File Pointer:** `crates/stemedb-lens/src/lib.rs` (planned)
## The Trait
```rust
pub trait Lens {
fn resolve(&self, candidates: &[Assertion], context: &QueryContext) -> LensResult;
}
```
## Standard Lenses
| Lens | Strategy | Use Case |
|------|----------|----------|
| Recency | Latest timestamp wins | News, real-time |
| Consensus | Highest vote count | Democratic truth |
| Authority | Weighted by agent reputation | Expert truth |
| Skeptic | Returns variance/conflict | Finding controversy |
## Query Flow
1. Client: `GET(Subject="Tesla", Predicate="Revenue", Lens="Consensus")`
2. Index lookup: `SP:Tesla:Revenue` -> `[Hash1, Hash2, Hash3]`
3. Hydrate: Load assertions from hashes
4. Resolve: `ConsensusLens.resolve(assertions, context)`
5. Return: Single deterministic answer with confidence
## Related Topics
- [Assertion](./assertion.md)
- [stemedb-lens skill](../../.claude/skills/stemedb-lens/SKILL.md)