Seven setter/getter comments restated the function signature rather than
showing a concrete call (AX Principle 2). Replaced all with real invocation
examples so agents know exactly how to call each method.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1: predictable names over short names.
`opts` and `opt` are abbreviations — `options` and `option` are unambiguous.
Co-Authored-By: Charon <charon@lethean.io>
Four exported methods on TaskSupervisor had comments restating the
signature (AX §2 violation). Replaced with concrete call-site examples.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2 — comments as usage examples, not prose descriptions.
DefaultCircuitBreakerConfig, NewCircuitBreaker, State, Reset, GetCached
all had comments that restated the signature; replaced with concrete call examples.
Co-Authored-By: Charon <charon@lethean.io>
Closure parameters in UninstallMiner and updateMinerConfig used the
abbreviated name cfg instead of configuration, violating AX Principle 1
(predictable names over short names).
Co-Authored-By: Charon <charon@lethean.io>
All four exported function comments in ratelimiter.go were prose
descriptions that restate the signature (AX Principle 2 violation).
Replaced with concrete usage examples showing realistic call sites.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2: comments that restate the type signature add zero information.
Nine accessor methods converted from "Foo returns the bar" to concrete call examples.
Co-Authored-By: Charon <charon@lethean.io>
`fn` is a single-letter abbreviation — AX principle 1 requires predictable
names over short names. `modifier` describes the parameter's role clearly.
Comment updated to a usage example per principle 2.
Co-Authored-By: Charon <charon@lethean.io>
All public API comments on ProfileManager restated the type signature in
prose — violating AX principle 2 (comments as usage examples). Replaced
with concrete call examples showing realistic values.
Co-Authored-By: Charon <charon@lethean.io>
SettingsManager.Load and Save had comments that restated the function
signature ("reads settings from disk", "writes settings to disk") rather
than showing a concrete call site. Replaced with usage examples per
AX Principle 2 (Comments as Usage Examples).
Co-Authored-By: Charon <charon@lethean.io>
AX-2 (Comments as Usage Examples): Load, Save, and Update on
Repository[T] and FileRepository[T] had comments that restated
the signature in prose. Replaced with concrete call examples.
Co-Authored-By: Charon <charon@lethean.io>
AX principle 2: comments must show HOW with real values, not restate
what the function name already says. All 14 error constructor comments
converted from "ErrX creates a Y error" to concrete call-site examples.
Co-Authored-By: Charon <charon@lethean.io>
ErrCircuitOpen used errors.New (banned import). Replaced with
NewMiningError using the package's own error infrastructure.
Co-Authored-By: Charon <charon@lethean.io>
mgr is an abbreviated variable name. AX Principle 1 requires predictable
names over short names — names should not require a comment to explain.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names: variable `copy` shadows
the Go builtin and carries no semantic meaning. Renamed to `settingsCopy`.
AX Principle 2 — comments as usage examples: replaced prose description on
SettingsManager.Get with a concrete call showing how the return value is used.
Co-Authored-By: Charon <charon@lethean.io>
fmt is a banned import (AX §banned-imports). miner_factory.go used
fmt.Errorf for the unsupported-miner error path; the package already
provides ErrUnsupportedMiner() in errors.go, so use that instead and
drop the fmt import entirely.
Co-Authored-By: Charon <charon@lethean.io>
All 12 exported functions in metrics.go had comments that restated their
signatures in prose (e.g. "records a miner start event") instead of
showing concrete call examples. Replaced with AX-compliant usage examples
per RFC-025 principle 2 (Comments as Usage Examples).
Co-Authored-By: Charon <charon@lethean.io>
AX principle 1: predictable names over short names.
cl abbreviates rateLimitClient; rename to client throughout Middleware
and cleanup for semantic clarity.
Co-Authored-By: Charon <charon@lethean.io>
All public function comments restated the signature (AX-2 violation).
Replace each with a concrete call example showing real values.
Co-Authored-By: Charon <charon@lethean.io>
Seven MiningError method comments restated the function signature verbatim
(AX principle 2 violation). Deleted all seven and replaced NewMiningError's
comment with a concrete call-site example per the RFC rule: if a comment
restates what the type signature already says, delete it.
Co-Authored-By: Charon <charon@lethean.io>
`minerCfg` is an abbreviated name for `MinerAutostartConfig` loop
variables. Renamed to `autostartEntry` across three range loops in
manager.go for AX Principle 1 compliance (predictable names over
short names).
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1: predictable names over short names.
`dbCfg` abbreviates both the `db` prefix and `Cfg` suffix — both banned
by the AX naming rules. `databaseConfiguration` is unambiguous.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names. The Manager struct
fields dbEnabled and dbRetention used the db abbreviation which requires
context to decode. Renamed to databaseEnabled and databaseRetention across
manager.go and the single service.go callsite. No behaviour change.
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>
- Skip tests that attempt to start miner processes (`StartMiner`, `StopMiner`) to avoid resource usage and flakiness in CI.
- Add `TestXMRigMiner_CheckInstallation` to verify binary detection and version parsing using a dummy script that prints version info.
- Refactor `TestGetMiner_Good` and `TestListMiners_Good` to manually inject miner instances, preserving coverage for retrieval logic without starting processes.
- Fix UI test compilation by updating imports and mocks.
- Fix panic in `TestStopMiner_Good` by checking errors (though now skipped).
- TEST-HIGH-5: Add comprehensive database tests for schema, migrations,
re-initialization, and concurrent access
- RESIL-MED-6: Add TaskSupervisor for background task monitoring with
automatic restart on failure
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- P2P-HIGH-1: Add peer scoring system with success/failure/timeout tracking
- PERF-HIGH-2: Add JSON encoding buffer pool for hot paths
- API-HIGH-1: Standardize error responses using APIError struct
- RESIL-MED-5: Add graceful disconnect with reason/code messages
All verified items (SQL indexes, keepalive) were already implemented.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 11 tests covering CRUD operations for ProfileManager
- Test persistence/loading of profiles from disk
- Test concurrent access (multiple goroutines)
- Test error handling for invalid JSON and missing files
- Test rollback on failed create
- Test config data preservation through save/load
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add PeerAuthMode to control peer registration:
- PeerAuthOpen: Allow all peers (backward compatible default)
- PeerAuthAllowlist: Only allow pre-registered peers or allowlisted public keys
New features:
- PeerRegistry.SetAuthMode/GetAuthMode for mode control
- PeerRegistry.AllowPublicKey/RevokePublicKey for key management
- PeerRegistry.IsPeerAllowed check before connection acceptance
- Transport rejects unauthorized peers with proper handshake rejection
New API endpoints:
- GET/PUT /peers/auth/mode - Get/set authentication mode
- GET/POST/DELETE /peers/auth/allowlist - Manage allowlisted keys
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <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>
Integrate gin-mcp to expose mining API endpoints as MCP tools,
enabling AI assistants like Claude, Cursor, and Continue to
interact directly with the mining dashboard.
- Add gin-mcp dependency
- Initialize MCP server in SetupRoutes
- Mount at /api/v1/mining/mcp
- Automatically converts 40 API routes to MCP tools
AI assistants can now connect via SSE to discover and call
mining API operations programmatically.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reliability fixes:
- Fix race condition on uninitialized HTTP server in transport.go
- Add proper error logging for HTTP server startup errors
- Fix potential goroutine leak in process cleanup (xmrig_start.go)
- Propagate context to DB writes for proper timeout handling
Architecture improvements:
- Centralize GitHub version fetching via FetchLatestGitHubVersion()
- Add respondWithMiningError() helper for standardized API error responses
- Update XMRig and TTMiner to use centralized version fetcher
Documentation:
- Add CHANGELOG.md with release history
- Update FUTURE_IDEAS.md with demo GIF task
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>