# lens-instrumentation ## AUDIT (2026-01-31) **Pattern:** Lens `resolve()` methods missing `#[instrument]` tracing spans **Found:** 3 instances in 3 files | File | Method | Has `#[instrument]` | |------|--------|---------------------| | `recency.rs:24` | `RecencyLens::resolve()` | NO | | `consensus.rs:34` | `ConsensusLens::resolve()` | NO | | `confidence.rs:46` | `ConfidenceLens::resolve()` | NO | | `vote_aware_consensus.rs:120` | `VoteAwareConsensusLens::resolve_async()` | YES (already) | | `trust_aware_authority.rs:90` | `TrustAwareAuthorityLens::resolve_async()` | YES (already) | *Note: `authority.rs` was renamed to `confidence.rs` and `AuthorityLens` to `ConfidenceLens` in Task 2.2.* The async lenses were instrumented when created. The synchronous lenses predate the tracing-coverage remediation. ## FIX (2026-01-31) Added `#[instrument]` to all 3 synchronous lens `resolve()` methods: | File | Change | |------|--------| | `recency.rs` | Added `use tracing::instrument;` + `#[instrument(skip(self, candidates), fields(candidates_count = candidates.len(), lens = "Recency"))]` | | `consensus.rs` | Added `use tracing::instrument;` + `#[instrument(skip(self, candidates), fields(candidates_count = candidates.len(), lens = "Consensus"))]` | | `confidence.rs` | Added `use tracing::instrument;` + `#[instrument(skip(self, candidates), fields(candidates_count = candidates.len(), lens = "Confidence"))]` | *Note: File was originally `authority.rs` (renamed to `confidence.rs` in Task 2.2).* Build verified: `cargo build --workspace` + `cargo clippy --workspace -- -D warnings` both pass. ## VERIFY (2026-01-31) Grep confirmed 5/5 lens implementations instrumented, 0 remaining gaps: - RecencyLens::resolve() ✅ - ConsensusLens::resolve() ✅ - ConfidenceLens::resolve() ✅ (renamed from AuthorityLens in Task 2.2) - VoteAwareConsensusLens::resolve_async() ✅ (already) - TrustAwareAuthorityLens::resolve_async() ✅ (already) ## ENFORCE (2026-01-31) Updated CLAUDE.md critical rule: - Before: "Use `#[instrument]` on public methods in WAL, storage, and ingestion code." - After: "Use `#[instrument]` on public methods in WAL, storage, ingestion, and lens code. Include meaningful fields (key_len, payload_len, offset, candidates_count, lens)." ## DOCUMENT (2026-01-31) Updated `.claude/skills/stemedb-lens/SKILL.md`: - Updated trait signatures to match current code (Lens + AsyncLens) - Added "Current Implementations" table with all 5 lenses - Added "Tracing Pattern (Required)" section with example - Added `#[instrument]` to the "Do" checklist - Updated strategies to reflect actual implementation details