stemedb/applications/aphoria/dogfood/PROJECT2-QUICKSTART-DEPRECATED.md
jml 3dac3dc914 feat(aphoria): implement Day 3 debugging features and comprehensive documentation
Implements all product gaps identified in msgqueue Day 3 evaluation (VG-DAY3-001/003/004)
and adds comprehensive documentation to prevent dogfooding failures.

## Product Features (VG-DAY3-XXX)

### VG-DAY3-001: --show-observations flag (P0)
- Shows all observations with concept paths for debugging extractor alignment
- Includes claim matching analysis (/ visual feedback)
- Explains tail-path matching and why observations don't match claims
- 8 unit tests in src/report/observations.rs
- 5 integration tests in src/tests/day3_debugging.rs

### VG-DAY3-003: aphoria extractors validate (P2)
- Validates extractor subject fields match claim concept_paths
- Smart fuzzy matching suggests corrections for typos
- Clear error messages with actionable hints
- Proper exit codes (0=success, 1=validation failed)

### VG-DAY3-004: aphoria extractors test NAME --file (P2)
- Tests single extractor pattern against one file (no full scan needed)
- Shows line numbers and matched text
- Previews what observation would be created
- Helpful troubleshooting when pattern doesn't match

## Documentation (P0-P1)

### New Docs Created
- docs/extractors/declarative-extractors.md (800 lines)
  - Complete field reference with emphasis on subject field format
  - 3 worked examples (timeout=0, unbounded queue, TLS disabled)
  - Common mistakes with fixes
  - Validation workflow
  - Debugging 0% detection rate

- docs/examples/extractors/timeout-zero-example.md (500 lines)
  - End-to-end flow: code → extractor → claim → conflict → fix
  - Visual diagrams showing path alignment
  - Troubleshooting guide
  - Validation checklist

- docs/dogfooding-common-mistakes.md (560 lines)
  - Mistake #1: Skipping Day 3 extractor creation (CRITICAL)
  - Mistake #2: Creating extractors with wrong subject format (NEW)
  - Evidence from msgqueue failures
  - Recovery procedures

### Docs Updated
- dogfood/msgqueue/plan.md (Day 3 Steps 3-4)
  - Added complete manual declarative extractor TOML format
  - Added validation workflow BEFORE scanning
  - Added debug workflow for 0% detection after creating extractors

- dogfood/msgqueue/eval/ (evaluation artifacts)
  - EVALUATION-REPORT-2026-02-10.md (600 lines)
  - DOC-FIXES-2026-02-10.md (summary of fixes)
  - IMPLEMENTATION-REVIEW-2026-02-10.md (feature review)

## New Extractors
- src/extractors/ack_mode_config.rs - Detects AckMode::AutoAck violations
- src/extractors/async_blocking.rs - Detects blocking calls in async functions
- src/extractors/unbounded_resources.rs - Detects unbounded queues/connections

## Code Changes
- src/cli/mod.rs: Add --show-observations flag to scan command
- src/cli/extractors.rs: Add Validate and Test subcommands
- src/handlers/scan.rs: Call format_observations when flag enabled
- src/handlers/extractors.rs: Implement handle_validate() and handle_test()
- src/report/observations.rs: Observation formatting with claim matching analysis
- src/tests/day3_debugging.rs: Integration tests for new features

## Dogfood Artifacts
- dogfood/msgqueue/ - Complete msgqueue Day 3 evaluation with findings
- dogfood/dbpool/ - Database pool dogfooding exercise

## Impact
- Time savings: 30 min per Day 3 debugging (67% faster)
- User experience: Transparent debugging (no blind trial-and-error)
- Documentation: 1,860 new lines covering all P0-P1 gaps

## Related Issues
- Closes VG-DAY3-001 (--show-observations)
- Closes VG-DAY3-002 (concept path alignment docs)
- Closes VG-DAY3-003 (extractors validate)
- Closes VG-DAY3-004 (extractors test)

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

336 lines
9.2 KiB
Markdown

# DEPRECATED
This generic guide has been replaced by the specific **httpclient** project.
**Use instead:** `httpclient/README.md` and `httpclient/plan.md`
---
# Project 2 Quick Start: Demonstrating the Flywheel
**You're starting Project 2.** This is where Aphoria's autonomous flywheel compounds knowledge from Project 1.
**What's different:** Project 1 established baseline patterns. Project 2 reuses them and demonstrates 50-60% time savings.
---
## Pre-Flight: Verify Project 1 Knowledge Exists
Before starting, confirm you can access Project 1's corpus:
```bash
# Verify Project 1 (dbpool) claims exist in corpus
curl 'http://localhost:18180/v1/aphoria/corpus' | \
jq '[.items[] | select(.subject | contains("dbpool"))] | length'
# Expected: 27 claims from dbpool
# Breakdown by source
curl -s 'http://localhost:18180/v1/aphoria/corpus' | \
jq '[.items[] | select(.subject | contains("dbpool"))] | group_by(.source) | map({source: .[0].source, count: length})'
# Expected:
# [
# {"source": "community://", "count": 1},
# {"source": "owasp://", "count": 5},
# {"source": "vendor://", "count": 21}
# ]
```
**If you see 27 claims:** ✅ Ready to proceed
**If you see 0 claims:** ❌ Project 1 incomplete, start there first
---
## What You'll Demonstrate
### Flywheel Metrics (Evidence to Collect)
| Metric | Project 1 (Baseline) | Project 2 (Target) | How to Measure |
|--------|---------------------|-------------------|----------------|
| **Day 1 Time** | 4 hours | <2 hours (50% faster) | Time Day 1 start to finish |
| **Claims Created** | 27 new | ~22 total (8-10 reused, 12-14 new) | Count in corpus after Day 1 |
| **Claims Reused** | 0 | 8-10 (30-40%) | Query corpus for aligned patterns |
| **Naming Errors** | 2-3 (had to fix) | 0 (skills enforce) | Manual review of claim subjects |
| **Pattern Alignment** | N/A | High (connection, timeout, tls) | Semantic comparison |
**Success = Demonstrable time savings + pattern reuse + perfect naming consistency**
---
## Day 0: Pre-Execution (30 min)
### Step 1: Choose Your Project 2 Domain
**Suggested domains** (reuse connection/security patterns from dbpool):
- HTTP client library (connection pooling, timeouts, TLS)
- gRPC service client (similar patterns to dbpool)
- WebSocket connection manager (connection lifecycle)
- Cache client (connection pooling, TTL)
**Why these:** All share connection management patterns with dbpool, demonstrating cross-domain knowledge reuse.
### Step 2: Verify Skills Installed
```bash
# Check all 8 Aphoria skills exist
ls -la ~/.claude/skills/ | grep aphoria
# Expected output:
# aphoria/
# aphoria-claims/ ⭐ Primary for Day 1
# aphoria-suggest/ ⭐ Primary for pattern discovery
# aphoria-custom-extractor-creator/
# aphoria-corpus-import/
# aphoria-install/
# aphoria-post-commit-hook/
# aphoria-ci-setup/
```
**If missing:** Follow `dbpool/docs/multi-project-setup.md` installation section
### Step 3: Run Validator
```bash
cd /home/jml/Workspace/stemedb/applications/aphoria/dogfood/dbpool
./scripts/validate-setup.sh
```
**All checks must pass** (API running, corpus accessible, skills available)
---
## Day 1: Claims with Pattern Discovery (1-2 hours target)
**PRIMARY WORKFLOW: Skills-Driven**
### Step 1: Discover Reusable Patterns (15 min)
**Use aphoria-suggest skill:**
```
In Claude Code:
/aphoria-suggest
"I'm building an HTTP client library. What patterns from dbpool should I reuse?
Show me claims about connection management, timeouts, and security."
```
**Expected skill output:**
```
Found 8-10 reusable patterns from dbpool:
Connection Management:
- connection_timeout: max 30s (vendor://dbpool/connection_timeout)
- max_connections: required (vendor://dbpool/max_connections)
- min_connections: min 2 (vendor://dbpool/min_connections)
Security:
- credentials/plaintext: prohibited (owasp://dbpool/credentials/plaintext)
- tls/enabled: required (owasp://dbpool/tls/enabled)
- certificate_validation: required (owasp://dbpool/certificate_validation)
Lifecycle:
- max_lifetime: required (vendor://dbpool/max_lifetime)
- idle_timeout: recommended (vendor://dbpool/idle_timeout)
```
**Document these** - you'll reference them when creating Project 2 claims.
---
### Step 2: Fetch Project 2 Authority Sources (30 min)
**For HTTP client example:**
- **Fetch:** Requests library documentation (Python/Rust/Node)
- **Fetch:** HTTP client best practices (Mozilla, OWASP)
- **Fetch:** RFC 7230-7235 (HTTP protocol standards)
**Save to:** `project2/docs/sources/`
---
### Step 3: Create Claims Using Skills (30-45 min)
**Use aphoria-claims skill with pattern alignment:**
```
In Claude Code:
/aphoria-claims
"Read project2/docs/sources/requests-docs.md and extract claims for HTTP client.
ALIGN NAMING with dbpool patterns:
- Use 'connection_timeout' (not 'request_timeout') to match dbpool
- Use 'max_connections' (not 'connection_limit') to match dbpool
- Use 'tls/enabled' pattern for security settings
Project prefix: httpclient/"
```
**Skill will:**
1. Extract claims from authority docs
2. Query corpus for similar dbpool patterns
3. Suggest aligned naming (enforces consistency)
4. Generate CLI commands with proper format
**Expected output:**
```bash
# Reused patterns (aligned with dbpool):
aphoria corpus create \
--subject "httpclient/connection_timeout" \
--predicate "max_value" \
--value "30" \
--explanation "HTTP requests MUST timeout within 30s to prevent resource exhaustion. Aligns with dbpool pattern." \
--authority "Requests Docs" \
--category "safety" \
--tier 2
# New patterns (HTTP-specific):
aphoria corpus create \
--subject "httpclient/redirect_limit" \
--predicate "max_value" \
--value "10" \
--explanation "..." \
--authority "RFC 7231" \
--category "safety" \
--tier 0
```
**Execute commands** - verify naming aligns with dbpool patterns
---
### Step 4: Verify Pattern Reuse (5 min)
```bash
# Count total claims for Project 2
curl 'http://localhost:18180/v1/aphoria/corpus' | \
jq '[.items[] | select(.subject | contains("httpclient"))] | length'
# Expected: ~22 claims
# Count aligned patterns (same predicate/category as dbpool)
curl 'http://localhost:18180/v1/aphoria/corpus' | \
jq '[.items[] | select(.subject | contains("connection_timeout"))] | length'
# Expected: 2 (dbpool + httpclient)
# Verify naming consistency
curl 'http://localhost:18180/v1/aphoria/corpus' | \
jq '.items[] | select(.subject | contains("httpclient")) | .subject'
# All should be lowercase, slash-separated (no errors)
```
**Success criteria:**
- 8-10 claims align with dbpool patterns
- 12-14 new claims (HTTP-specific)
- 0 naming errors (skills enforced)
- Completed in <2 hours (vs dbpool's 4 hours)
---
## Day 2-5: Follow dbpool CHECKLIST
**Use:** `dbpool/CHECKLIST.md` Days 2-5
**Key difference:** On Day 3, if built-in extractors don't cover your patterns:
```
/aphoria-custom-extractor-creator
"Generate extractors for these HTTP client violations:
- redirect_limit exceeds 10
- connection_timeout exceeds 30s
- tls disabled"
```
**Skill generates declarative extractors** aligned with your claims.
---
## Measuring Success
### Evidence to Document
**Time savings:**
```markdown
Project 1 (dbpool) Day 1: 4 hours
Project 2 (httpclient) Day 1: 1.5 hours
Improvement: 62.5% time reduction
```
**Pattern reuse:**
```markdown
Project 2 claims: 22 total
- Reused from dbpool: 9 claims (41%)
- New HTTP-specific: 13 claims (59%)
```
**Naming consistency:**
```markdown
Project 1 (manual): 2 naming errors, had to fix
Project 2 (skills): 0 naming errors (enforced automatically)
```
**Cross-project awareness:**
```markdown
Before Day 1: Queried corpus, found 27 dbpool patterns
Day 1: Aligned 9 claims with dbpool naming
Result: Consistent vocabulary across projects
```
---
## Troubleshooting
### Problem: Can't see dbpool claims
**Solution:** See `dbpool/docs/multi-project-setup.md` "Troubleshooting Cross-Project Discovery"
### Problem: Skills not suggesting patterns
**Solution:**
1. Verify API running: `curl http://localhost:18180/health`
2. Verify corpus accessible: Query dbpool claims
3. Give skills clear context: "I'm building X, show patterns from Y"
### Problem: Naming doesn't align with dbpool
**Solution:** Use `/aphoria-claims` skill - it queries corpus and suggests aligned names automatically
---
## Quick Reference
| Phase | Primary Tool | Time |
|-------|-------------|------|
| Pattern Discovery | `/aphoria-suggest` | 15 min |
| Claim Creation | `/aphoria-claims` | 30-45 min |
| Verification | curl + jq | 5 min |
| **Total Day 1** | **Skills-driven** | **1-2 hours** |
Compare to Project 1 (manual): 4 hours
**Time savings: 50-60%**
---
## Next Steps
1. **Complete Day 1** - Create claims with pattern reuse
2. **Measure metrics** - Time, reuse rate, naming consistency
3. **Continue Days 2-5** - Follow dbpool/CHECKLIST.md
4. **Document flywheel** - Write success story with evidence
5. **Optional:** Set up automation (`/aphoria-post-commit-hook` or `/aphoria-ci-setup`)
---
**Ready to start?**
Verify Project 1 corpus exists (27 claims)
Run validator (`./scripts/validate-setup.sh`)
Choose Project 2 domain (httpclient, grpc-client, cache-client)
Start Day 1 with `/aphoria-suggest`
**The flywheel is ready. Let's prove it works.**