stemedb/applications/aphoria/dogfood
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
..
archive chore(dogfood): archive dated documentation and remove database files from git 2026-02-11 06:12:34 +00:00
cachewrap feat(aphoria): implement programmatic extractors for Option<T> semantics 2026-02-11 06:43:10 +00:00
dbpool chore(dogfood): archive dated documentation and remove database files from git 2026-02-11 06:12:34 +00:00
httpclient feat(aphoria): implement programmatic extractors for Option<T> semantics 2026-02-11 06:43:10 +00:00
msgqueue feat(aphoria): implement Day 3 debugging features and comprehensive documentation 2026-02-11 03:31:06 +00:00
CLEANUP-PLAN.md feat(aphoria): implement programmatic extractors for Option<T> semantics 2026-02-11 06:43:10 +00:00
README.md feat(aphoria): implement Day 3 debugging features and comprehensive documentation 2026-02-11 03:31:06 +00:00

Aphoria Dogfood Projects

Purpose: Demonstrate Aphoria's autonomous flywheel through real-world projects.


Quick Navigation

Starting Fresh?

Project 1 (dbpool) - Database connection pool library

  • Status: Day 1 complete (27 claims created)
  • Purpose: Establish baseline patterns
  • Start here if: This is your first dogfood project
  • Time: 5 days (Days 2-5 remaining)

Project 2 (httpclient) - HTTP client library (autonomous flywheel demo)

  • Status: Ready to start (requires Project 1 complete)
  • Purpose: Demonstrate 50-60% time savings via pattern reuse from dbpool
  • Start here if: Project 1 Day 1 is complete (27 claims in corpus)
  • Time: 4 days (Day 1 faster due to skills + pattern reuse)

Project Status

Project 1: dbpool (Database Connection Pool)

Current State: Day 1 complete, ready for Day 2

What's done:

  • 27 claims created in corpus
    • 21 vendor (HikariCP + PostgreSQL)
    • 5 owasp (security requirements)
    • 1 community (Rust best practices)

Next steps: Follow dbpool/CHECKLIST.md Day 2+

Documentation:

  • dbpool/CHECKLIST.md - Day-by-day execution guide
  • dbpool/STATE-2026-02-10.md - Current state and progress
  • dbpool/docs/ - Claim extraction examples, flywheel setup, multi-project guide

🚀 Project 2: httpclient (HTTP Client Library)

What we're building: Production-ready HTTP client with connection pooling, timeout management, TLS enforcement

Pre-requisites:

  • Project 1 Day 1 complete (27 claims in corpus)
  • Skills installed (~/.claude/skills/aphoria*)
  • API running with corpus access

Why this project:

  • Reuses dbpool connection/timeout/TLS patterns
  • Demonstrates skills-driven pattern discovery
  • Shows measurable flywheel value (60% time reduction, 40% pattern reuse)

Start here: httpclient/README.md

What you'll demonstrate:

  • 50-60% time reduction (Day 1: <2 hours vs dbpool's 4 hours)
  • 30-40% pattern reuse (8-10 claims aligned with dbpool)
  • 0 naming errors (skills enforce consistency)
  • Cross-project knowledge compounding

Documentation Index

Getting Started

  • New to dogfooding?dbpool/README.md
  • Ready for Project 2?PROJECT2-QUICKSTART.md
  • Skills setup?dbpool/CHECKLIST.md (Pre-Execution section)

Deep Dives

  • Claim extraction walkthrough: dbpool/docs/claim-extraction-example.md
  • Custom extractors guide: dbpool/docs/CUSTOM-EXTRACTOR-GUIDE.md
  • Flywheel setup (persistent mode): dbpool/docs/flywheel-setup.md
  • Multi-project pattern reuse: dbpool/docs/multi-project-setup.md

Reference

  • Authority sources: dbpool/docs/sources/ (HikariCP, PostgreSQL, OWASP)
  • Evaluation reports: dbpool/eval/ (what we learned from Project 1)

Quick Verification Commands

Check Project 1 Corpus

# Verify 27 dbpool claims exist
curl 'http://localhost:18180/v1/aphoria/corpus' | \
  jq '[.items[] | select(.subject | contains("dbpool"))] | length'

# Expected: 27

Check Skills Installation

# List installed Aphoria skills
ls -la ~/.claude/skills/ | grep aphoria

# Expected: 8 skills
# aphoria, aphoria-claims, aphoria-suggest, aphoria-custom-extractor-creator,
# aphoria-corpus-import, aphoria-install, aphoria-post-commit-hook, aphoria-ci-setup

Check API Running

# Health check
curl http://localhost:18180/health

# Expected: {"status":"healthy","version":"0.1.0"}

What Each Project Demonstrates

Project 1 (Baseline)

Goal: Establish authoritative patterns from vendor docs (HikariCP, PostgreSQL)

Workflow:

  1. Extract claims from authority sources (manual or skills)
  2. Create library with intentional violations
  3. Scan and detect violations
  4. Fix incrementally with verification
  5. Document success story

Value: Proves Aphoria can detect real violations with high accuracy

Time: 16-20 hours (spread over 5 days)


Project 2 (Flywheel)

Goal: Demonstrate autonomous knowledge compounding across projects

Workflow:

  1. Skills discover patterns from Project 1 (not starting from scratch)
  2. Skills enforce naming alignment (consistency across projects)
  3. Create library aligned with Project 1 patterns
  4. Skills generate extractors if needed (autonomous coverage)
  5. Document flywheel metrics (time savings, reuse rate)

Value: Proves Aphoria compounds knowledge, teams get faster over time

Time: 12-15 hours (spread over 4 days) - 25-30% faster than Project 1


Success Criteria

Project 1

  • 25-30 claims created
  • 7-8 intentional violations embedded in code
  • 85-100% detection accuracy
  • Scan performance ≤0.3s
  • Final scan: 0 conflicts (all fixed)

Project 2

  • Day 1 completed in <2 hours (50% faster than Project 1)
  • 8-10 claims reused from Project 1 (30-40% reuse rate)
  • 0 naming errors (skills enforce consistency)
  • Pattern alignment high (connection, timeout, TLS)
  • Flywheel metrics documented (evidence of knowledge compounding)

Need Help?

Pre-Flight Issues

  • Validator fails? → Run dbpool/scripts/validate-setup.sh for diagnostics
  • No claims in corpus? → Check API env var: STEMEDB_CORPUS_DB_DIR
  • Skills not found? → Follow installation in dbpool/CHECKLIST.md

During Dogfooding

  • Scan returns 0 observations?dbpool/docs/CUSTOM-EXTRACTOR-GUIDE.md
  • Cross-project patterns not showing?dbpool/docs/multi-project-setup.md
  • Naming inconsistencies? → Use /aphoria-claims skill (enforces automatically)

Architecture Reminder

What Aphoria IS:

  • Autonomous LLM-driven system (runs on every commit in production)
  • Skills ARE the primary workflow (/aphoria-claims, /aphoria-suggest)
  • Manual CLI is debug interface (fallback when LLM unavailable)

What Aphoria is NOT:

  • NOT a CLI tool you run manually
  • NOT "42 extractors + custom additions"
  • NOT optional LLM features

For dogfooding: Skills demonstrate the autonomous flywheel. Manual CLI is available but not the primary workflow.


Ready to start?

  • First time:dbpool/README.md
  • Project 2:PROJECT2-QUICKSTART.md