stemedb/.agentive-remediation/lens-instrumentation/history.md
jordan 1ce4004807 feat: Complete Phase 2 (The Cortex) - query, lens, and API layers
This commit adds the read path (Cortex) to complement the write path (Spine):

## Crates
- stemedb-api: HTTP API with axum + utoipa OpenAPI
  - /v1/assert, /v1/query, /v1/epoch, /v1/skeptic, /v1/trace, /v1/audit
  - Metered endpoints with quota enforcement
  - Ed25519 signature verification
- stemedb-lens: Truth resolution lenses
  - RecencyLens, ConsensusLens, ConfidenceLens
  - VoteAwareConsensusLens (Ballot Box pattern)
  - TrustAwareAuthorityLens (The Hive pattern)
  - SkepticLens (conflict analysis)
  - EpochAwareLens (paradigm-safe queries)
- stemedb-query: Query engine with materialized views

## Storage Extensions
- VoteStore: Vote aggregation with cached counts
- TrustRankStore: Agent reputation with decay
- AuditStore: Query audit trail
- IndexStore: SP/P/S index structures
- SupersessionStore: Epoch supersession chains

## SDKs
- sdk/go/steme: Go HTTP client with Ed25519 signing
- sdk/go/adk: ADK-Go tools for AI agents

## Documentation
- Updated CLAUDE.md, architecture.md, roadmap.md
- New ai-lookup entries for all services
- Use case docs for consumer health intelligence
- Arena roadmap for simulation advancement

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:22:44 -07:00

57 lines
2.6 KiB
Markdown

# 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