Delete inline comments that restate what the next line of code does
(AX Principle 2). Affected: circuit_breaker.go, service.go, transport.go,
worker.go, identity.go, peer.go, bufpool.go, settings_manager.go,
node_service.go.
Co-Authored-By: Charon <charon@lethean.io>
Applies AX principle 2 (Comments as Usage Examples) — removes prose
descriptions that restate the function signature ("returns", "retrieves",
"creates", "wraps", etc.) and keeps or replaces with concrete usage
examples showing real calls with realistic values.
Co-Authored-By: Charon <charon@lethean.io>
identity.go was calling encoding/json directly (json.MarshalIndent,
json.Unmarshal) despite the package already defining MarshalJSON and
UnmarshalJSON in bufpool.go. Switch to the wrappers and remove the
direct encoding/json import from identity.go.
Co-Authored-By: Charon <charon@lethean.io>
Remove banned `encoding/json` import from pkg/mining/version.go; read
response body with io.ReadAll then decode via the package-local
UnmarshalJSON wrapper (bufpool.go). Also complete the partial fmt
removal in pkg/node/identity.go left broken by the previous sweep.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1: predictable names over short names. The `nm` shorthand
in seven comment examples was inconsistent with the full `nodeManager`
name used in actual call-site code and the `manager` receiver name
throughout the file.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2: comments show HOW with real values, not WHAT the
type signature already says. Converted 8 prose-style comments on
type declarations (Transport, TransportConfig, PeerConnection,
PeerRateLimiter, MessageDeduplicator, DisconnectPayload, NodeRole,
NodeIdentity, Peer) to concrete call-site examples.
Co-Authored-By: Charon <charon@lethean.io>
NodeManager's type comment restated the name in prose ("handles node
identity operations") rather than showing concrete usage. Replaced with
a three-line example demonstrating construction, identity check, and
retrieval — per AX Principle 2 (Comments as Usage 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. Five prose descriptions replaced with
concrete call-site examples.
Co-Authored-By: Charon <charon@lethean.io>
ChallengeSize comment restated the name ("is the size of the challenge
in bytes") — violating AX Principle 2. Replace with a concrete usage
example showing how the constant is used at call sites.
Co-Authored-By: Charon <charon@lethean.io>
Short variable name `dir` violated predictable-names-over-short-names.
Renamed to `directoryPath` in savePrivateKey, saveIdentity, and saveNow.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names. The receiver `n`
for *NodeManager is a non-standard abbreviation; only `i`, `_`, `t`,
and `c` are permitted single-letter receivers per RFC-CORE-008.
Co-Authored-By: Charon <charon@lethean.io>
AX-2: comments that restate the function name add zero information.
savePrivateKey, saveIdentity, and loadIdentity now show a concrete
call-site with context on when each is invoked.
Co-Authored-By: Charon <charon@lethean.io>
GenerateChallenge, SignChallenge, and VerifyChallenge had comments that
restated what the type signature already says. Replaced with concrete call
examples showing how each function is used in the handshake flow (AX §2).
Co-Authored-By: Charon <charon@lethean.io>
HasIdentity, GetIdentity, and GenerateIdentity had comments that
restated the type signature rather than showing concrete call patterns.
Replaced with AX-compliant usage examples per RFC-025 Principle 2.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2 — comments show HOW with real values, not WHAT the
signature already says. The old comment restated the method name;
the new comment shows the exact call pattern used in transport.go.
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>
- Add GenerateChallenge() for random 32-byte challenge generation
- Add SignChallenge() using HMAC-SHA256 with shared secret
- Add VerifyChallenge() with constant-time comparison
- Update performHandshake() to send challenge and verify response
- Update handleWSUpgrade() to sign incoming challenges
- Add comprehensive tests for challenge-response flow
The challenge-response authentication proves the peer has the matching
private key for their public key by signing a random challenge with
the ECDH-derived shared secret. This prevents impersonation attacks.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The xdg library caches paths, so setting XDG environment variables
in tests doesn't work when there's already an identity file at the
default path. Added NewNodeManagerWithPaths constructor similar to
NewPeerRegistryWithPath to allow tests to use isolated temp directories.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement secure peer-to-peer communication between Mining CLI instances
for remote control of mining rigs. Uses Borg library for encryption
(SMSG, STMF, TIM) and Poindexter for KD-tree based peer selection.
Features:
- Node identity management with X25519 keypairs
- Peer registry with multi-factor optimization (ping/hops/geo/score)
- WebSocket transport with SMSG encryption
- Controller/Worker architecture for remote operations
- TIM/STIM encrypted bundles for profile/miner deployment
- CLI commands: node, peer, remote
- REST API endpoints for node/peer/remote operations
- Docker support for P2P testing with multiple nodes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>