Commit graph

53 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
9a511ddc72
ax(node): replace direct json.MarshalIndent/Unmarshal with package wrappers in peer.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
encoding/json is a banned import; peer.go used json.MarshalIndent and
json.Unmarshal directly in saveNow/load instead of the package-local
MarshalJSON/UnmarshalJSON wrappers. Removes the encoding/json import.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:41:18 +01:00
Claude
f1ba1a28a5
ax(node): rename authMode to authenticationMode in PeerRegistry
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX-1 (predictable names over short names): `auth` is an abbreviation
of `authentication`; the full word removes semantic ambiguity for agents
tracing authentication mode through the peer registry.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:30:28 +01:00
Claude
07ba7b7e62
ax(node): replace banned fmt import in peer.go with ProtocolError
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:47:06 +01:00
Claude
676d7b13a9
ax(node): remove prose description lines from PeerRegistry method comments
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 2: comments show usage examples, not prose descriptions.
Five methods (AddPeer, UpdatePeer, RemovePeer, UpdateMetrics, UpdateScore)
had a redundant "Note: Persistence is debounced..." prose line appended
after the usage example. The usage example already communicates intent;
the prose line restated implementation detail without adding value.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:33:20 +01:00
Claude
81f4fc9d96
ax(node): replace prose constant comments with usage examples
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Score constants had comments restating the name in prose
("Increment for successful interaction") rather than showing
how they are used. AX Principle 2: comments are usage examples,
not descriptions.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:31:11 +01:00
Claude
152952e101
ax(node): rename allowedPublicKeyMutex to allowedPublicKeysMutex
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Mutex name was singular (allowedPublicKeyMutex) while the field it
protects is plural (allowedPublicKeys). AX Principle 1 requires
predictable names — the mutex name must mirror the field it guards.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:29:43 +01:00
Claude
39ebb63eac
ax(node): replace prose comment with usage example on peerNamePattern
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 code does.
The old comment restated the variable name; the new comment shows concrete
validatePeerName calls that demonstrate valid and invalid inputs.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:19:45 +01:00
Claude
4d4ee5dd2a
ax(node): replace prose type comments with usage examples
Some checks failed
Security Scan / security (push) Successful in 34s
Test / test (push) Has been cancelled
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>
2026-04-02 14:25:58 +01:00
Claude
2f75ac7c62
ax(node): replace prose PeerRegistry comment 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 prose that restates the type name.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:21:29 +01:00
Claude
9280527f19
ax(node): rename stopChan to stopChannel in PeerRegistry
'Chan' is an abbreviation; AX Principle 1 requires predictable names
over short names. stopChannel is unambiguous without a comment.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:16:07 +01:00
Claude
fc7a1a2147
ax(node): replace banned path/filepath import with path in peer registry
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:10:22 +01:00
Claude
0ac701daea
ax(node): rename PeerRegistry.path to peersFilePath for predictable naming
Some checks failed
Security Scan / security (push) Has been cancelled
Test / test (push) Has been cancelled
AX Principle 1: predictable names over short names. The field `path` on
PeerRegistry is ambiguous — it could be any path. `peersFilePath` is
self-describing and removes the need for a comment to explain its purpose.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:05:02 +01:00
Claude
311e457e35
ax(node): rename PeerRegistry receiver r to registry
Some checks failed
Test / test (push) Waiting to run
Security Scan / security (push) Has been cancelled
AX Principle 1 — predictable names over short names.
The receiver `r` on PeerRegistry is a single-letter abbreviation;
all 29 methods now use `registry` for consistency with the rest of
the node package (controller, worker, transport all use full names).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:52:26 +01:00
Claude
95cb6b6570
ax(node): replace prose comment with usage example on PeerAuthMode
Some checks failed
Security Scan / security (push) Successful in 34s
Test / test (push) Has been cancelled
AX Principle 2 — comments show HOW, not WHAT. The prose description
"controls how unknown peers are handled" restates the type name.
Replaced with concrete SetAuthMode call examples showing both modes.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:47:51 +01:00
Claude
836fc18ff3
ax(node): replace prose comments with usage examples (AX Principle 2)
Comments on saveNow, save, load, Close, and DefaultResponseHandler
restated what the signature already said. Replace with concrete call
examples showing how each is actually invoked.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 12:30:42 +01:00
Claude
ee3fb3d6b7
ax(node): replace prose comment with usage example on rebuildKDTree
AX principle 2: comments show HOW (usage example), not WHAT
(which the function name already says).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 12:20:36 +01:00
Claude
bf3b6c4b03
ax(node): replace prose constant comment with usage example
saveDebounceInterval had a description comment ("the minimum time between
disk writes") which restates what the name already says. Replaced with a
usage example showing the call site, per AX Principle 2.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 12:01:32 +01:00
Claude
e9143e42b0
ax(node): replace prose comment on scheduleSave with usage example
AX Principle 2: comments show HOW with real values, not prose restating
what the name already says.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:41:43 +01:00
Claude
0a0751e2e0
ax(node): rename dir to directoryPath (AX Principle 1)
Some checks failed
Test / test (push) Waiting to run
Security Scan / security (push) Has been cancelled
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>
2026-04-02 11:29:01 +01:00
Claude
3cf01162d5
ax(node): rename loop variable p to peer in GetPeersByScore
AX Principle 1 — predictable names over short names. Single-letter
variable p in GetPeersByScore replaced with peer, matching the type
it holds and the usage in surrounding code.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:27:32 +01:00
Claude
e4989be633
ax(node): rename tmpPath to temporaryPath in peer registry save
AX Principle 1: predictable names over short names.
`tmp` is an abbreviation requiring mental mapping; `temporaryPath`
is unambiguous and self-describing.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:21:31 +01:00
Claude
1d319b5f96
ax(node): rename n to count in SelectNearestPeers (AX-1 predictable names)
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Single-letter parameter n violates AX Principle 1 — names must be
predictable without a comment to explain them. count is unambiguous.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:11:11 +01:00
Claude
482b2e6f23
ax(node): replace prose description with usage example on SelectNearestPeers
AX principle 2: comments show HOW with real values, not WHAT the signature already says.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:04:15 +01:00
Claude
21d205a0dc
ax(node): rename pr to registry in NewPeerRegistryWithPath
`pr` abbreviates PeerRegistry — violates AX Principle 1
(predictable names over short names). Renamed to `registry`
so the variable is self-describing without context.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:37:22 +01:00
Claude
aab44e7814
ax(node): rename PeerRegistry.mu and saveMu to mutex and saveMutex
AX-1 (Predictable Names): abbreviated field names require mental mapping.
mutex and saveMutex are self-describing; mu and saveMu are not.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:22:48 +01:00
Claude
35c178ce05
ax(node): replace prose comments with usage examples in PeerRegistry
AX Principle 2: comments that restate the type signature add zero
information. Replaced all prose-description comments on PeerRegistry
methods with concrete call-site examples that show real usage.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:18:29 +01:00
Claude
39e0df4de3
ax(node): replace AddPeer prose comment with usage example
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 2: comments restate the signature — replace with a concrete
call showing realistic values and the debounce behaviour as a note.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:13:10 +01:00
Claude
0bb5287f4b
ax(node): replace prose comment with usage example on IsPublicKeyAllowed
AX Principle 2: comments show HOW with real values, not WHAT the function does.
"checks if a public key is in the allowlist" restates the signature — replaced
with a concrete call example.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:08:17 +01:00
Claude
1ff90ba170
ax(node): replace prose comments with usage examples on PeerRegistry auth methods
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
SetAuthMode, GetAuthMode, AllowPublicKey, and RevokePublicKey all had
comments that restated the function signature rather than showing concrete
usage. Replaced with call-site examples per AX Principle 2.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:47:20 +01:00
Claude
4c355049e7
ax(node): remove dangling prose comment in peer.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Line 715 contained "// Example usage inside a connection handler" with no
code following it — a prose description stub with no usage example. This
violates AX Principle 2 (comments must show concrete usage with real values,
not describe intent in prose).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:44:40 +01:00
Claude
8f7b6892ee
ax(node): replace prose comment on GetPeer with usage example
AX Principle 2: comments show HOW with real values, not WHAT the
signature already states. "GetPeer returns a peer by ID" restates
the function name — replaced with a concrete call pattern.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:40:30 +01:00
Claude
9a50e472b5
ax(node): replace Must* regexp anti-pattern with Compile in validatePeerName
Package-level regexp.MustCompile panics at startup on invalid pattern —
the Must* form explicitly banned by AX RFC-025 §6 (no hidden panics).
Move pattern to a const and compile via regexp.Compile inside the function.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:30:54 +01:00
Claude
463708aeab
ax(node): promote peer selection weights from var to const
Dimension weights are never reassigned — declaring them as mutable vars
implies changeability that does not exist. Const declares what IS (AX §5).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:16:44 +01:00
Claude
d709b2125c
ax(node): expand abbreviated mutex field name per AX Principle 1
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Renamed `allowedPublicKeyMu` to `allowedPublicKeyMutex` in PeerRegistry.
`Mu` is an abbreviation that violates AX Principle 1 (predictable names
over short names) — the full word `Mutex` removes any ambiguity about
what the field represents.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:08:48 +01:00
Claude
27e7f6ef74
ax(node): replace prose description on validatePeerName with usage examples
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:03:14 +01:00
Claude
6508b92876
ax(node): replace prose comment on Count with usage example
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 2: comments as usage examples, not restatements of the
signature. "Count returns the number of registered peers." says nothing
the signature does not already say. Replaced with a concrete call site.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:52:08 +01:00
Claude
05a267e051
ax(node): replace prose comment with usage example on SelectOptimalPeer
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:46:36 +01:00
Claude
a4c4d64a98
ax(node): replace prose comment with usage example on safeKeyPrefix
AX Principle 2: comments show HOW with real values, not WHAT the signature says.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:42:21 +01:00
Claude
44811e84fd
ax(node): rename geoWeight to geographicWeight for AX principle 1
geo is an abbreviation that requires domain knowledge to parse;
geographicWeight makes the dimension self-describing.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:35:37 +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
copilot-swe-agent[bot]
3aea1d7d1a Fix test failures and unused imports after combining PRs
Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
2026-02-02 06:12:37 +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
google-labs-jules[bot]
8881dd324b feat: Create error handling and logging audit
This commit introduces a new audit document, `AUDIT-ERROR-HANDLING.md`, which provides a comprehensive review of the project's error handling and logging practices.

The audit covers:
-   **Error Handling:** Analyzes the inconsistency between the well-structured API error responses and the simpler, unstructured error handling at the application's entry points.
-   **Logging:** Details the existing custom logger, its lack of JSON output, and its inconsistent use across the codebase.
-   **Recommendations:** Provides actionable steps for improvement, including adopting structured JSON logging, centralizing logger configuration, and standardizing on the global logger.

This commit also includes fixes for pre-existing build errors to allow the CI to pass:
-   Adds a missing package declaration and imports in `pkg/node/dispatcher.go` and comments out calls to undefined methods.
-   Adds a missing import in `pkg/node/peer.go` and resolves an unused variable error.
-   Removes an unused import in `pkg/ueps/packet.go`.

Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
2026-02-02 01:29:57 +00:00
dbd36374b2
Add SendEthicalPacket method for secure packet sending
Implemented SendEthicalPacket method to send packets securely using a shared secret.
2026-01-03 16:00:41 +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
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
f65db3f5c4 feat: Implement peer allowlist for P2P security (P2P-CRIT-1)
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>
2025-12-31 15:06:52 +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