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>
340 lines
13 KiB
Bash
Executable File
340 lines
13 KiB
Bash
Executable File
#!/bin/bash
|
|
# Batch create all HTTP client claims with dbpool naming alignment
|
|
# Run from httpclient directory
|
|
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
APHORIA="/home/jml/Workspace/stemedb/target/release/aphoria"
|
|
|
|
echo "Creating HTTP client claims with dbpool naming alignment..."
|
|
echo "================================================================"
|
|
|
|
# TIMEOUT CLAIMS (aligned with dbpool connection_timeout pattern)
|
|
echo "1/22: connect_timeout..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-connect-timeout-001" \
|
|
--concept-path "httpclient/connect_timeout" \
|
|
--predicate "max_value" \
|
|
--value "10" \
|
|
--provenance "Mozilla HTTP docs + Requests library (10s connect timeout)" \
|
|
--invariant "TCP connection timeout MUST NOT exceed 10 seconds" \
|
|
--consequence "Unresponsive endpoints block connection establishment" \
|
|
--tier expert \
|
|
--evidence "Mozilla HTTP guidelines, Requests library default" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "2/22: request_timeout..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-request-timeout-001" \
|
|
--concept-path "httpclient/request_timeout" \
|
|
--predicate "max_value" \
|
|
--value "30" \
|
|
--provenance "Mozilla HTTP docs (30s recommended), aligned with dbpool timeout pattern" \
|
|
--invariant "HTTP request timeout MUST NOT exceed 30 seconds" \
|
|
--consequence "Slow external services block thread pool, cascade failures" \
|
|
--tier expert \
|
|
--evidence "Mozilla HTTP guidelines, RFC 7230" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "3/22: read_timeout..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-read-timeout-001" \
|
|
--concept-path "httpclient/read_timeout" \
|
|
--predicate "max_value" \
|
|
--value "30" \
|
|
--provenance "Mozilla HTTP docs (15-30s for response body reading)" \
|
|
--invariant "Response body read timeout MUST NOT exceed 30 seconds" \
|
|
--consequence "Slow streaming responses block thread pool" \
|
|
--tier expert \
|
|
--evidence "Mozilla HTTP guidelines" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "4/22: idle_timeout required..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-idle-timeout-001" \
|
|
--concept-path "httpclient/idle_timeout" \
|
|
--predicate "required" \
|
|
--value "true" \
|
|
--provenance "RFC 7230 Section 6.3 (persistent connections), reused from dbpool/idle_timeout pattern" \
|
|
--invariant "Idle connection timeout MUST be configured" \
|
|
--consequence "Stale connections accumulate, waste resources" \
|
|
--tier expert \
|
|
--evidence "RFC 7230 Section 6.3, dbpool pattern alignment" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "5/22: idle_timeout default value..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-idle-timeout-default-001" \
|
|
--concept-path "httpclient/idle_timeout" \
|
|
--predicate "default_value" \
|
|
--value "60" \
|
|
--provenance "Mozilla HTTP docs + RFC 7230 (60s aligns with server keep-alive)" \
|
|
--invariant "Idle timeout default SHOULD be 60 seconds" \
|
|
--consequence "Too short closes connections prematurely, too long wastes resources" \
|
|
--tier community \
|
|
--evidence "Mozilla HTTP guidelines, RFC 7230" \
|
|
--category constants \
|
|
--by "aphoria-suggest"
|
|
|
|
# TLS CLAIMS (tls/ prefix aligned with dbpool)
|
|
echo "6/22: tls/certificate_validation..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-tls-cert-validation-001" \
|
|
--concept-path "httpclient/tls/certificate_validation" \
|
|
--predicate "required" \
|
|
--value "true" \
|
|
--provenance "OWASP A07:2021 + Mozilla Security Guidelines, reused from dbpool pattern" \
|
|
--invariant "HTTPS connections MUST validate server certificates" \
|
|
--consequence "Man-in-the-middle attacks, credential exposure" \
|
|
--tier expert \
|
|
--evidence "OWASP A07:2021, Mozilla HTTPS guidelines, Requests library default" \
|
|
--category security \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "7/22: tls/enabled..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-tls-enabled-001" \
|
|
--concept-path "httpclient/tls/enabled" \
|
|
--predicate "recommended" \
|
|
--value "true" \
|
|
--provenance "Security best practice, reused from dbpool pattern" \
|
|
--invariant "HTTPS SHOULD be enabled by default for all connections" \
|
|
--consequence "Unencrypted traffic exposes sensitive data (credentials, PII)" \
|
|
--tier community \
|
|
--evidence "Mozilla Security Guidelines, OWASP" \
|
|
--category security \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "8/22: tls/min_version..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-tls-min-version-001" \
|
|
--concept-path "httpclient/tls/min_version" \
|
|
--predicate "min_value" \
|
|
--value "1.2" \
|
|
--provenance "OWASP + Mozilla Security Guidelines (TLS 1.2 minimum as of 2023)" \
|
|
--invariant "TLS version MUST be >= 1.2 (TLS 1.0/1.1 deprecated)" \
|
|
--consequence "Vulnerable to protocol downgrade attacks (BEAST, POODLE)" \
|
|
--tier expert \
|
|
--evidence "OWASP TLS cheat sheet, Mozilla guidelines" \
|
|
--category security \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "9/22: tls/cipher_suites..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-tls-ciphers-001" \
|
|
--concept-path "httpclient/tls/cipher_suites" \
|
|
--predicate "recommended" \
|
|
--value "modern_only" \
|
|
--provenance "Mozilla Security Guidelines (ECDHE, AES-GCM preferred)" \
|
|
--invariant "TLS cipher suites SHOULD use modern ciphers only" \
|
|
--consequence "Weak ciphers (RC4, 3DES, MD5) enable decryption attacks" \
|
|
--tier community \
|
|
--evidence "Mozilla Security Guidelines" \
|
|
--category security \
|
|
--by "aphoria-suggest"
|
|
|
|
# REDIRECT CLAIMS (bounded resource pattern like dbpool/max_connections)
|
|
echo "10/22: max_redirects..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-max-redirects-001" \
|
|
--concept-path "httpclient/max_redirects" \
|
|
--predicate "max_value" \
|
|
--value "10" \
|
|
--provenance "RFC 7231 Section 6.4 (10 redirects recommended), pattern from dbpool/max_connections" \
|
|
--invariant "HTTP redirect limit MUST NOT exceed 10" \
|
|
--consequence "Infinite redirect loops exhaust client resources" \
|
|
--tier expert \
|
|
--evidence "RFC 7231 Section 6.4" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "11/22: redirects/loop_detection..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-redirect-loop-001" \
|
|
--concept-path "httpclient/redirects/loop_detection" \
|
|
--predicate "required" \
|
|
--value "true" \
|
|
--provenance "Requests library pattern (TooManyRedirects exception)" \
|
|
--invariant "Redirect loop detection MUST be implemented" \
|
|
--consequence "Without detection, infinite loops exhaust resources" \
|
|
--tier expert \
|
|
--evidence "Requests library implementation, RFC 7231" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
# RETRY CLAIMS (retry/ prefix)
|
|
echo "12/22: retry/max_attempts..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-retry-max-001" \
|
|
--concept-path "httpclient/retry/max_attempts" \
|
|
--predicate "max_value" \
|
|
--value "3" \
|
|
--provenance "Requests library default + Mozilla guidelines (3 retries max)" \
|
|
--invariant "Retry attempts MUST NOT exceed 3" \
|
|
--consequence "Unlimited retries cause retry storms, amplify cascading failures" \
|
|
--tier expert \
|
|
--evidence "Requests library default, Mozilla HTTP guidelines" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "13/22: retry/backoff..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-retry-backoff-001" \
|
|
--concept-path "httpclient/retry/backoff" \
|
|
--predicate "required" \
|
|
--value "exponential" \
|
|
--provenance "Requests library pattern (exponential backoff 1s, 2s, 4s)" \
|
|
--invariant "Retry backoff MUST use exponential strategy" \
|
|
--consequence "Fixed-interval retries amplify load spikes during outages" \
|
|
--tier expert \
|
|
--evidence "Requests library urllib3.util.retry" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "14/22: retry/idempotent_only..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-retry-idempotent-001" \
|
|
--concept-path "httpclient/retry/idempotent_only" \
|
|
--predicate "required" \
|
|
--value "true" \
|
|
--provenance "Mozilla HTTP docs + Requests library (only retry GET/PUT/DELETE)" \
|
|
--invariant "Retries MUST only apply to idempotent methods" \
|
|
--consequence "Retrying POST requests may cause duplicate operations (charges, bookings)" \
|
|
--tier expert \
|
|
--evidence "Mozilla HTTP guidelines, Requests library default" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "15/22: retry/post_excluded..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-retry-post-excluded-001" \
|
|
--concept-path "httpclient/retry/post_excluded" \
|
|
--predicate "required" \
|
|
--value "true" \
|
|
--provenance "Requests library default (never retry POST by default)" \
|
|
--invariant "POST requests MUST be excluded from automatic retries" \
|
|
--consequence "Retrying POST can cause duplicate charges, bookings, state mutations" \
|
|
--tier expert \
|
|
--evidence "Requests library implementation" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
# METRICS CLAIMS (metrics/ prefix aligned with dbpool)
|
|
echo "16/22: metrics/enabled..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-metrics-enabled-001" \
|
|
--concept-path "httpclient/metrics/enabled" \
|
|
--predicate "recommended" \
|
|
--value "true" \
|
|
--provenance "Observability best practice, reused from dbpool pattern" \
|
|
--invariant "Metrics collection SHOULD be enabled for production HTTP clients" \
|
|
--consequence "Cannot monitor client health, debug production issues, or detect cascades" \
|
|
--tier community \
|
|
--evidence "Prometheus best practices, SRE handbook, dbpool pattern" \
|
|
--category observability \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "17/22: metrics/exposed..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-metrics-exposed-001" \
|
|
--concept-path "httpclient/metrics/exposed" \
|
|
--predicate "required" \
|
|
--value "request_count,active_connections,latency_p99,error_rate" \
|
|
--provenance "RED method (Rate, Errors, Duration), adapted from dbpool/metrics/exposed" \
|
|
--invariant "Core HTTP metrics MUST be exposed: request_count, active_connections, latency_p99, error_rate" \
|
|
--consequence "Incomplete observability prevents production debugging and SLO tracking" \
|
|
--tier community \
|
|
--evidence "RED method (Prometheus), dbpool pattern alignment" \
|
|
--category observability \
|
|
--by "aphoria-suggest"
|
|
|
|
# CONNECTION POOLING CLAIMS
|
|
echo "18/22: pool_size recommended range..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-pool-size-001" \
|
|
--concept-path "httpclient/pool_size" \
|
|
--predicate "recommended_range" \
|
|
--value "50-100" \
|
|
--provenance "Mozilla HTTP docs (50-100 connections per host for production)" \
|
|
--invariant "Connection pool size SHOULD be 50-100 per host in production" \
|
|
--consequence "Too few limits throughput, too many causes resource exhaustion" \
|
|
--tier community \
|
|
--evidence "Mozilla HTTP guidelines" \
|
|
--category constants \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "19/22: pool/default_size..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-pool-default-size-001" \
|
|
--concept-path "httpclient/pool/default_size" \
|
|
--predicate "default_value" \
|
|
--value "10" \
|
|
--provenance "Requests library default (10 connections via urllib3)" \
|
|
--invariant "Default pool size SHOULD be 10 connections per host" \
|
|
--consequence "Default works for most cases, high-concurrency apps need tuning" \
|
|
--tier community \
|
|
--evidence "Requests library urllib3.poolmanager default" \
|
|
--category constants \
|
|
--by "aphoria-suggest"
|
|
|
|
echo "20/22: sessions/connection_pooling..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-connection-pooling-001" \
|
|
--concept-path "httpclient/sessions/connection_pooling" \
|
|
--predicate "recommended" \
|
|
--value "true" \
|
|
--provenance "Requests library best practice (use Session() for connection reuse)" \
|
|
--invariant "Connection pooling SHOULD be enabled for multi-request scenarios" \
|
|
--consequence "Without pooling, every request pays TCP + TLS handshake cost" \
|
|
--tier community \
|
|
--evidence "Requests library Session documentation" \
|
|
--category architecture \
|
|
--by "aphoria-suggest"
|
|
|
|
# HEADER CLAIMS
|
|
echo "21/22: headers/user_agent..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-user-agent-001" \
|
|
--concept-path "httpclient/headers/user_agent" \
|
|
--predicate "required" \
|
|
--value "true" \
|
|
--provenance "Mozilla HTTP docs (always send User-Agent header)" \
|
|
--invariant "User-Agent header MUST be sent with all requests" \
|
|
--consequence "Servers may block or rate-limit requests without User-Agent" \
|
|
--tier community \
|
|
--evidence "Mozilla HTTP guidelines" \
|
|
--category architecture \
|
|
--by "aphoria-suggest"
|
|
|
|
# ERROR HANDLING CLAIMS (aligned with dbpool pattern)
|
|
echo "22/22: error_handling/request_failure..."
|
|
$APHORIA claims create \
|
|
--id "httpclient-error-handling-001" \
|
|
--concept-path "httpclient/error_handling/request_failure" \
|
|
--predicate "must" \
|
|
--value "return_error_not_panic" \
|
|
--provenance "Robustness pattern, reused from dbpool/error_handling/connection_failure" \
|
|
--invariant "HTTP request failures MUST return Result, NEVER panic" \
|
|
--consequence "Unhandled panics crash the application" \
|
|
--tier expert \
|
|
--evidence "Rust error handling best practices, dbpool pattern" \
|
|
--category safety \
|
|
--by "aphoria-suggest"
|
|
|
|
echo ""
|
|
echo "================================================================"
|
|
echo "✅ Created 22 HTTP client claims with dbpool naming alignment"
|
|
echo ""
|
|
echo "Naming alignment achieved:"
|
|
echo " - Timeouts: connect_timeout, request_timeout (match dbpool pattern)"
|
|
echo " - TLS: tls/* prefix (match dbpool: tls/certificate_validation, tls/enabled)"
|
|
echo " - Metrics: metrics/* prefix (match dbpool: metrics/enabled, metrics/exposed)"
|
|
echo " - Retry: retry/* prefix (new for HTTP)"
|
|
echo " - Bounded resources: max_redirects (match dbpool max_connections pattern)"
|
|
echo ""
|
|
echo "Run: aphoria claims list --format table"
|