stemedb/applications/aphoria/dogfood/cachewrap/scan-v1.md
jml e758f2ebfb feat(aphoria): implement programmatic extractors for Option<T> semantics
Completes Task #3 of httpclient dogfooding with 100% detection rate (7/7 violations).

## New Extractors

- **OptionBoundsExtractor**: Detects Option<T> fields set to None (unbounded)
- **OptionValueExtractor**: Extracts values from Some(n) for threshold checks

Both extractors use context-aware pattern matching to understand Rust Option<T>
semantics, which declarative extractors cannot handle.

## Implementation

**Files Created**:
- applications/aphoria/src/extractors/option_bounds.rs (257 lines)
- applications/aphoria/src/extractors/option_value.rs (277 lines)
- applications/aphoria/docs/examples/extractors/programmatic-option-semantics.md

**Files Modified**:
- applications/aphoria/src/extractors/mod.rs - Added module declarations
- applications/aphoria/src/extractors/registry.rs - Registered extractors
- applications/aphoria/dogfood/httpclient/.aphoria/claims.toml - Added 4 claims
- applications/aphoria/dogfood/httpclient/TASK-1-SUMMARY.md - Task #3 completion

## Results

| Metric | Value |
|--------|-------|
| Detection Rate | 100% (7/7 violations) |
| Improvement | +29 percentage points (from 71%) |
| New Violations | 2 (max_redirects, max_retries unbounded) |
| Unit Tests | 13 (all passing) |

## Two-Claim Strategy

For each bounded Option<T> field:
1. **configured** claim - Detects None (unbounded)
2. **max_value** claim - Validates Some(n) threshold

Example:
- `max_redirects: None` → CONFLICT (not configured)
- `max_redirects: Some(20)` → CONFLICT (exceeds 10)
- `max_redirects: Some(5)` → PASS

## Enterprise Quality

✓ Proper error handling (no unwrap/expect)
✓ Comprehensive tests (6+7 unit tests)
✓ Full documentation with examples
✓ Reusable for 10+ similar patterns
✓ Screening patterns for performance

## Cachewrap Dogfood

Also includes complete cachewrap dogfood exercise:
- 10 claims for Redis cache wrapper
- Day 1-5 summaries
- Full retrospective and evaluation
- Declarative extractors for all patterns

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 06:43:10 +00:00

2.9 KiB

Aphoria Scan: cachewrap

6 files scanned | 26 observations | 20 claims (0 pass, 0 conflict, 20 missing)

Claim Verification

Verdict Claim Invariant Explanation
MISSING cache-timeout-001 Cache operation timeout MUST NOT exceed 5 seconds No matching observation found
MISSING cache-tls-validation-001 TLS certificate validation MUST be enabled for Redis connections No matching observation found
MISSING cache-retry-max-001 Cache command retry attempts MUST NOT exceed 3 No matching observation found
MISSING cache-async-blocking-001 Async cache operations MUST NOT use blocking calls No matching observation found
MISSING cache-max-connections-001 Cache connection pool MUST have bounded max_connections (10-50 recommended) No matching observation found
MISSING cache-connection-lifecycle-001 Cache connections MUST be validated (PING) before use No matching observation found
MISSING cache-metrics-enabled-001 Metrics MUST be enabled for production cache clients (hit_rate, miss_rate, latency) No matching observation found
MISSING cache-ttl-required-001 TTL (Time To Live) MUST be set for all cached values No matching observation found
MISSING cache-key-validation-001 Cache keys MUST be validated for control characters and length No matching observation found
MISSING cache-max-size-001 Cache MUST have bounded max_size to prevent OOM No matching observation found
MISSING cache-eviction-policy-001 Eviction policy MUST be configured (LRU, LFU, or TTL-based) No matching observation found
MISSING cache-hardcoded-password-001 Redis passwords MUST NOT be hardcoded in source code No matching observation found
MISSING cache-key-prefix-001 Cache keys SHOULD use consistent prefixes for namespacing No matching observation found
MISSING cache-serialization-001 Cache values SHOULD use structured serialization (JSON, MessagePack, bincode) No matching observation found
MISSING cache-compression-001 Compression SHOULD be enabled for values >1KB No matching observation found
MISSING cache-consistency-mode-001 Consistency mode MUST be configured (strong, eventual, client-side) No matching observation found
MISSING cache-sharding-strategy-001 Sharding SHOULD use consistent hashing for multi-node deployments No matching observation found
MISSING cache-read-through-001 Read-through pattern SHOULD be used for cache-aside workloads No matching observation found
MISSING cache-write-through-001 Write-through SHOULD be used for critical data requiring strong consistency No matching observation found
MISSING cache-stampede-prevention-001 Cache stampede prevention MUST be implemented (locks, PER, or jitter) No matching observation found