Commit graph

20 commits

Author SHA1 Message Date
Claude
aba728ff83
ax(node): rename msg to errorMessage in NewErrorMessage
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 1: Predictable names over short names.
`msg` is an abbreviation; `errorMessage` names what it is.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:55:08 +01:00
Claude
096d7e0137
ax(node): replace direct json.Unmarshal with package-local UnmarshalJSON wrapper
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
ParsePayload was calling encoding/json.Unmarshal directly, bypassing the
package-local UnmarshalJSON wrapper that already exists in bufpool.go.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:27:01 +01:00
Claude
697394c1f4
ax(node): replace prose comment with usage example on MessageType
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 2: comments must show HOW with real values, not restate
what the type signature already says.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:26:02 +01:00
Claude
409749926d
ax(node): replace prose comment on Message with usage example
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX principle 2 — comments show HOW, not WHAT. The previous comment
restated the type name; replaced with concrete NewMessage/Reply calls.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:17:24 +01:00
Claude
5e525396ed
ax(node): replace banned strings import with inline version join
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Removes the banned `strings` import from transport.go by extracting
a `joinVersions` helper into message.go alongside SupportedProtocolVersions,
eliminating the single `strings.Join` call in the handshake rejection path.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:14:17 +01:00
Claude
ea9eb19e5b
ax(node): replace prose constant comments with usage examples in message.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 2: comments show usage, not prose descriptions. The
ProtocolVersion/MinProtocolVersion block comment and SupportedProtocolVersions
doc comment restated what the names already say; replaced with concrete
call-site examples.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:48:39 +01:00
Claude
906b2c9456
ax(node): rename abbreviated receiver names to full predictable names
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Replace single-letter receivers (m *Message, e *ProtocolError) and
parameter (v interface{}) with full names (message, protocolError, target)
per AX Principle 1: predictable names over short names.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:22:52 +01:00
Claude
519cbca6de
ax(node): rename errMsg to errorMessage in NewErrorMessage usage example
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:11:02 +01:00
Claude
c57462bd52
ax(node): replace prose struct comments with usage examples
AX Principle 2: comments must show HOW with real values, not restate
what the type signature already says. All payload struct comments in
message.go were prose descriptions ("HandshakePayload is sent during
connection establishment") — replaced with concrete construction
examples showing field usage.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 12:16:41 +01:00
Claude
b15b1654cb
ax(node): expand abbreviated json tag ts to timestamp on Message struct
AX Principle 1 — predictable names over short names. The wire format
field "ts" requires a reader to guess its meaning; "timestamp" is
self-documenting and consistent with every other field on the struct.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:36:07 +01:00
Claude
fd1aed63fe
ax(node): replace prose comment on NewErrorMessage with usage example
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX principle 2: comments must show HOW with real values, not restate
what the type signature already says.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:13:41 +01:00
Claude
546d97ae6a
ax(node): replace prose comment with usage example on ParsePayload
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX-2: comments must show HOW with real values, not restate the signature.
"ParsePayload unmarshals the payload into the given struct" adds zero
information. Replaced with a concrete call showing the pattern callers
actually use throughout this package.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:14:28 +01:00
Claude
28dfe3f31e
ax(node): replace prose comment with usage examples on IsProtocolVersionSupported
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:56:12 +01:00
Claude
d886b3905c
ax(node): replace prose comments with usage examples on NewMessage and Reply
AX Principle 2: comments must show HOW with real values, not restate the
type signature in prose. The previous comments added zero information.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:50:39 +01:00
Claude
7cb8487475
ax(node): rename loop variable v to supported in IsProtocolVersionSupported
Single-letter v is not AX-exempt — only i (index) is allowed in range loops.
The element variable names the thing being iterated, so: supported.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:31:27 +01:00
snider
ae68119329 feat: Rename XMRig references to Miner and add miner.cpp for new platform 2025-12-31 16:38:48 +00:00
snider
41cc0c295c feat: Implement multiple code review improvements
- 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>
2025-12-31 15:45:25 +00:00
snider
d533164893 fix: Comprehensive code hardening from 4-domain Opus review
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>
2025-12-31 14:33:30 +00:00
snider
34f860309f refactor: Add reliability fixes and architecture improvements
Reliability fixes:
- Fix HTTP response body drainage in xmrig, ttminer, miner
- Fix database init race condition (nil before close)
- Fix empty minerType bug in P2P StartMinerPayload
- Add context timeout to InsertHashratePoint (5s default)

Architecture improvements:
- Extract HashrateStore interface with DefaultStore/NopStore
- Create ServiceContainer for centralized initialization
- Extract protocol response handler (ValidateResponse, ParseResponse)
- Create generic FileRepository[T] with atomic writes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 12:43:46 +00:00
snider
9a781ae3f0 feat: Add multi-node P2P mining management system
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>
2025-12-29 19:49:33 +00:00