Commit graph

28 commits

Author SHA1 Message Date
Claude
4e7d4d906b
ax(batch): remove redundant prose comments in source files
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>
2026-04-02 18:48:08 +01:00
Claude
54481b16ba
ax(node): rename NewWorker param node→nodeManager for AX clarity
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Parameter named `node` shadowed the package name inside package node,
creating semantic ambiguity. AX Principle 1: predictable names over
short names — `nodeManager` matches the field name and the type.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:56:22 +01:00
Claude
9261820ab2
ax(node): rename msg/conn to message/connection in worker handlers
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 and conn
are abbreviations that require context to decode; message and connection
are self-documenting.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:51:30 +01:00
Claude
e68fbcaef0
ax(node): rename Worker.node field to nodeManager for AX Principle 1 compliance
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
The field `node *NodeManager` used an ambiguous single-word name that required
context to understand. Renamed to `nodeManager` to be self-describing per AX
Principle 1: predictable names over short names.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:49:13 +01:00
Claude
0e5956f57d
ax(node): replace path with filepath for filesystem path joining
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
The "path" package uses forward-slash separators and is intended for
URL paths; filesystem paths require "path/filepath" for OS-correct
behaviour. Fixes worker.go handleDeploy to use filepath.Join when
constructing the miners installation directory.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:53:35 +01:00
Claude
1b021a073b
ax(node): rename ack to acknowledgement in Worker message handlers
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX-1: predictable names over short names. The variable `ack` is an
abbreviation for `acknowledgement` — renamed in all six callsites
within handleStartMiner, handleStopMiner, and handleDeploy so the
name is self-describing without a comment.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:50:13 +01:00
Claude
485411912a
ax(node): replace banned fmt import in worker.go with ProtocolError
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
All fmt.Errorf calls replaced with &ProtocolError{Code, Message} using
the package-native error type, removing the banned fmt import entirely.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:44:42 +01:00
Claude
b4c73147fe
ax(node): replace direct encoding/json with package-level UnmarshalJSON wrapper
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
worker.go imported encoding/json directly and called json.Unmarshal at two
call sites. bufpool.go already provided MarshalJSON as the package wrapper;
add matching UnmarshalJSON and route both worker.go call sites through it,
removing the encoding/json import from worker.go.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:42:45 +01:00
Claude
9945f2b031
ax(node): replace banned path/filepath import with path in worker.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
path/filepath is a banned import per AX conventions; path is the
correct alternative when core.JoinPath is not available in this repo.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:08:14 +01:00
Claude
653db6563f
ax(node): replace prose comment on MinerManager with usage example
AX Principle 2 — comments show HOW with real values, not prose descriptions.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:20:03 +01:00
Claude
fb998ce2df
ax(node): replace banned path/filepath with path in worker.go
worker.go imported path/filepath (banned import) solely for two
filepath.Join calls building the miner install directory path.
Replaced with path.Join from the stdlib path package which is
not banned and behaves identically on Linux for absolute paths.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:03:13 +01:00
Claude
68ee594149
ax(node): replace prose comment on ProfileManager with usage example
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Principle 2 (Comments as Usage Examples): the ProfileManager interface
comment described what the interface was rather than showing how to use it.
Replaced with concrete call examples for GetProfile and SaveProfile.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:02:05 +01:00
Claude
4b8271647a
ax(node): replace prose MinerInstance comment with usage example
AX Principle 2: comments show HOW with real values, not restate
what the type signature already says.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:54:44 +01:00
Claude
8d1e007d69
ax(node): rename errMsg to errorMessage in Worker.HandleMessage
AX Principle 1 — predictable names over short names. errMsg is an
abbreviation that requires a comment to explain; errorMessage is
self-documenting.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:09:22 +01:00
Claude
f9b2a5dd75
ax(node): rename Worker receiver from w to worker
AX Principle 1 — predictable names over short names.
The single-letter receiver `w` is ambiguous; `worker` is self-describing.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 12:59:05 +01:00
Claude
a8e962a4df
ax(node): replace prose Worker comment with usage example
Principle 2: comments show HOW with real values, not WHAT the type is.
The old comment restated the struct name; the new block demonstrates the
full setup sequence an agent needs to wire a Worker.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:06:08 +01:00
Claude
df17944be5
ax(node): replace prose-description comments with usage examples in worker.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
All private handler function comments restated what the function name
already said (AX Principle 2 violation). Replaced with concrete call
examples showing how each handler is invoked.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:26:09 +01:00
Claude
da9e0d3982
ax(node): replace prose comment on HandleMessage 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 with real values, not WHAT the
signature already says. "processes incoming messages and returns a
response" restates the signature; the usage example shows how
HandleMessage is wired up via RegisterWithTransport.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:24:15 +01:00
Claude
88e6910e3a
ax(node): replace prose comments with usage examples on SetMinerManager and SetProfileManager
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:37:54 +01:00
Claude
e707710e9d
ax(node): replace NewWorker prose comment with usage example
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:26:50 +01:00
Claude
140f038f37
chore: migrate module path from github.com to forge.lthn.ai
Some checks failed
E2E Tests / E2E Tests (push) Failing after 1m23s
Tests / Go Tests (push) Failing after 39s
Desktop Release / Build linux (push) Failing after 46s
Release / Test (push) Failing after 2s
Tests / C++ Tests (push) Failing after 1m12s
Release / Release (push) Has been cancelled
Desktop Release / Build darwin (push) Has been cancelled
Desktop Release / Build windows (push) Has been cancelled
Desktop Release / Create Release (push) Has been cancelled
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>
2026-02-22 21:39:01 +00:00
google-labs-jules[bot]
1f464a62f1 Implement STIM bundle decryption and installation
- Updated `Worker.handleDeploy` to handle STIM bundles using `ExtractProfileBundle` and `ExtractMinerBundle`.
- Used `PeerConnection.SharedSecret` as the password for decryption.
- Implemented logic for `BundleProfile`, `BundleMiner`, and `BundleFull`.
- Fixed broken files `pkg/node/dispatcher.go` and `pkg/node/peer.go` to ensure compilation and testing.
- Updated tests in `pkg/node/worker_test.go` and added coverage for deployment logic.
2026-02-02 06:07:05 +00:00
snider
4072bdaf0d fix: Address 16 security findings from parallel code review
Critical fixes (6):
- CRIT-001/002: Add safeKeyPrefix() to prevent panic on short public keys
- CRIT-003/004: Add sync.Once pattern for thread-safe singleton initialization
- CRIT-005: Harden console ANSI parser with length limits and stricter validation
- CRIT-006: Add client-side input validation for profile creation

High priority fixes (10):
- HIGH-001: Add secondary timeout in TTMiner to prevent goroutine leak
- HIGH-002: Verify atomic flag prevents timeout middleware race
- HIGH-004: Add LimitReader (100MB) to prevent decompression bombs
- HIGH-005: Add Lines parameter validation (max 10000) in worker
- HIGH-006: Add TLS 1.2+ config with secure cipher suites
- HIGH-007: Add pool URL format and wallet length validation
- HIGH-008: Add SIGHUP handling and force cleanup on Stop() failure
- HIGH-009: Add WebSocket message size limit and event type validation
- HIGH-010: Refactor to use takeUntil(destroy$) for observable cleanup
- HIGH-011: Add sanitizeErrorDetails() with debug mode control

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 17:44:49 +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
89f74aebff refactor: Replace log.Printf with structured logging
Migrate all log.Printf/Println calls across the codebase to use the
new pkg/logging structured logging package. This provides consistent
log formatting with levels, timestamps, and structured key-value fields.

Files updated:
- pkg/mining/manager.go, service.go, events.go, miner.go
- pkg/mining/xmrig_start.go, ttminer_start.go
- pkg/mining/syslog_unix.go, syslog_windows.go
- pkg/database/hashrate.go
- pkg/node/worker.go, transport.go, peer.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 11:48:45 +00:00
snider
d61a8aff8b refactor: Remove unused code and fix nil dereference issues
- Remove unused exported functions from pkg/database (session tracking,
  bulk hashrate inserts, various query helpers)
- Remove unused exported functions from pkg/node (identity management,
  bundle operations, controller methods)
- Make internal-only functions unexported in config_manager.go and database.go
- Remove unused EventProfile* constants from events.go
- Add GetCommit() and GetBuildDate() to expose version.go variables
- Fix potential nil dereference issues flagged by Qodana:
  - Add nil checks for GetIdentity() in controller.go, transport.go, worker.go
  - Add nil checks for GetPeer() in peer_test.go
  - Add nil checks in worker_test.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 09:24:12 +00:00
snider
e0c9c92244 feat: Implement logging functionality for miners with log buffer and retrieval endpoint 2025-12-29 22:10:45 +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