Applies AX principle 1 (Predictable Names Over Short Names) to function
signatures and local variables: s->input/raw, v->target/value, d->duration,
a,b->left,right, w->writer, r->reader, l->logger, p->part/databasePoint,
fn parameter names left as-is where they are callback conventions.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names. The two-character
receiver `da` on DigestAuth methods mirrors the `cb` → `circuitBreaker`
fix already applied. The local variables `ha1` and `ha2` (RFC 2617 hash
computation steps) are renamed to `hashA1` and `hashA2` for the same reason.
Co-Authored-By: Charon <charon@lethean.io>
Replace fmt.Sprintf calls with string concatenation (+) and
strconv.FormatInt for integer formatting. fmt is a banned import
per AX conventions; all string formatting goes through Core primitives
or native concatenation.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names. Single-letter variables
b (random byte buffer) and h (MD5 digest array) require mental mapping; full
names make intent self-evident without comments.
Co-Authored-By: Charon <charon@lethean.io>
All comments on AuthConfig, DefaultAuthConfig, AuthConfigFromEnv,
DigestAuth, NewDigestAuth, Stop, Middleware, and all private methods
were restating the type signature in prose. Replaced with concrete
call-site examples per AX Principle 2 (comments as usage examples).
Co-Authored-By: Charon <charon@lethean.io>
Move module declaration and all internal imports from
github.com/Snider/Mining to forge.lthn.ai/Snider/Mining. Also updates
Borg, Enchantrix, and Poindexter dependency paths to forge.lthn.ai.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CONC-HIGH-1: Add mutex to wsClient.miners map to prevent race condition
P2P-CRIT-2: Add MaxMessageSize config (1MB default) to prevent memory exhaustion
P2P-CRIT-3: Track pending connections during handshake to enforce connection limits
RESIL-HIGH-1: Add recover() to 4 background goroutines to prevent service crashes
TEST-CRIT-1: Create auth_test.go with 16 tests covering Basic/Digest auth
RESIL-HIGH-3: Implement circuit breaker for GitHub API with caching fallback
Also fixed: NonceExpiry validation in auth.go to prevent panic on zero interval
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Error Handling:
- Fix silent Write() error in WebSocket (events.go)
- Add error context to transport handshake messages
- Check os.MkdirAll error in zip extraction (miner.go)
- Explicitly ignore io.Copy errors on drain with comments
- Add retry logic (2 attempts) for transient stats collection failures
Resource Lifecycle:
- Add shutdown mechanism to DigestAuth goroutine
- Call Service.Stop() on context cancellation
- Add NodeService transport cleanup to Service.Stop()
- Fix WriteStdin goroutine leak on timeout with non-blocking send
API Design:
- Add profile validation (name, miner type required)
- Return 404 instead of 500 for missing profile PUT
- Make DELETE profile idempotent (return success if not found)
- Standardize error responses in node_service.go handlers
Observability:
- Add logging for P2P GetAllStats failures
- Add request ID correlation helper for handler logs
- Add logging for miner process exits (xmrig_start.go)
- Rate limit debug logs in transport hot path (1 in 100)
- Add metrics infrastructure with /metrics endpoint
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>