Commit graph

60 commits

Author SHA1 Message Date
Claude
bfdf3be4fd
ax(node): rename local variable pc to connection in transport.go
AX Principle 1: predictable names over short names. The abbreviation
`pc` (PeerConnection) in local variable scope is ambiguous — renamed
to `connection` in Connect, Stop, Send, Broadcast, and handleWSUpgrade.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:44:05 +01:00
Claude
48a6532dea
ax(node): rename ackMsg/ackData to acknowledgementMessage/acknowledgementData
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. `ackMsg` and `ackData`
require the reader to expand the abbreviation; `acknowledgementMessage` and
`acknowledgementData` are self-describing in the handshake context.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:35:23 +01:00
Claude
5afb9e98f7
ax(node): remove prose comment from Transport.Start
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Comment restated what the function does in prose rather than showing
a concrete usage example, violating AX principle 2 (comments as usage
examples). The usage example on the preceding line is sufficient.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:31:52 +01:00
Claude
f70f477745
ax(node): rename mux to serveMux for AX predictable naming
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Short name `mux` requires context to understand; `serveMux` is
self-describing per AX Principle 1 (predictable names over short names).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:21:31 +01:00
Claude
7ac13d5e20
ax(node): remove banned encoding/json import from transport.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Replace three direct json.Unmarshal calls with the package-level
UnmarshalJSON wrapper defined in bufpool.go, eliminating the
banned encoding/json import from transport.go.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:19:29 +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
ac21008585
ax(node): remove banned fmt import from transport.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Replace all fmt.Errorf and fmt.Sprintf calls in transport.go with
ProtocolError{} structs and string concatenation, matching the error
pattern already used throughout the node package.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:12:10 +01:00
Claude
58701498ea
ax(node): rename w/r HTTP handler params to responseWriter/request
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Single-letter parameter names w and r violate AX Principle 1
(predictable names over short names). Only i, _, t, and c are
permitted as single-letter names per the AX spec.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:23:25 +01:00
Claude
c9e39451f0
ax(node): replace prose comments with usage examples on debug log vars
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:09:43 +01:00
Claude
dc2f415fc2
ax(node): rename ttl to timeToLive in MessageDeduplicator
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 field `ttl` requires context to decode; `timeToLive` is
self-describing without a comment.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:37:36 +01:00
Claude
237a22e9a5
ax(node): rename single-letter variable u to parsedURL in CheckOrigin
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. The variable `u`
in the WebSocket upgrader CheckOrigin closure required context to
understand; `parsedURL` is self-describing.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:33:43 +01:00
Claude
ea5996ce40
ax(node): rename ctx→cancelContext/requestContext/shutdownContext
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.
`ctx` is an abbreviation that requires prior knowledge to decode;
renamed to describe intent at each call site.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:28:07 +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
4b6ca745f5
ax(node): rename Transport receiver from t to transport
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Single-letter receiver `t` violates AX Principle 1 (predictable names
over short names). All 15 Transport methods now use `transport` as the
receiver name for unambiguous semantic navigation.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:14:26 +01:00
Claude
c03b040240
ax(node): replace prose comment on GracefulClose with usage examples
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 prose descriptions.
The previous comment restated what the function name already conveyed.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 14:00:25 +01:00
Claude
f005921de9
ax(node): rename PeerRateLimiter receiver r to limiter
Single-letter receiver names are banned by AX Principle 1 except for
i (range loops), _ (discards), t (tests), and c (*core.Core).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:40:44 +01:00
Claude
af7070f27a
ax(node): rename receiver d to deduplicator on MessageDeduplicator
Single-letter receiver `d` violates AX Principle 1 (predictable names
over short names). RFC-CORE-008 permits single-letter receivers only for
`i` (range loops), `_` (discards), `t` (tests), and `c` (*core.Core).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:38:25 +01:00
Claude
ac3c869684
ax(node): replace prose comment on MessageHandler with usage example
AX Principle 2: comments show HOW with real values, not WHAT the type does.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:36:58 +01:00
Claude
1c1b2cadf1
ax(node): rename Transport.conns to connections for AX Principle 1 compliance
Abbreviated field name `conns` violates predictable-names-over-short-names.
Renamed to `connections` throughout transport.go — 14 call sites updated.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:31:03 +01:00
Claude
19b076002b
ax(node): replace prose comments with usage examples on encryptMessage/decryptMessage
AX Principle 2: comments must show usage, not restate the signature.
Both internal methods had descriptions that duplicated the function name.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:17:54 +01:00
Claude
895dec281b
ax(node): rename writeMu to writeMutex in PeerConnection
Abbreviation writeMu requires a reader to infer "mutex" — violates AX
Principle 1 (predictable names over short names). writeMutex is
self-describing with no mapping overhead.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 13:15:51 +01:00
Claude
83a4d9d07d
ax(node): replace prose comments with usage examples in transport and identity
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>
2026-04-02 12:43:23 +01:00
Claude
4e10e20a6b
ax(node): replace prose comment with usage example on GetConnection
Some checks failed
Security Scan / security (push) Successful in 34s
Test / test (push) Has been cancelled
AX Principle 2 — comments must show HOW with real values, not restate
what the signature already says. The old comment described the return
value in prose; replaced with a concrete call-site example.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:31:36 +01:00
Claude
d400946352
ax(node): rename u to peerURL in Transport.Connect
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Single-letter variable name violates AX Principle 1 (predictable names
over short names). peerURL is self-describing without requiring context.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:26:37 +01:00
Claude
cb02cdb6b8
ax(node): replace prose comment with usage example on handleWSUpgrade
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
The comment "handleWSUpgrade handles incoming WebSocket connections" restated
the function signature without adding information. Replaced with a concrete
call-site example showing how the method is wired in via Start().

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:18:29 +01:00
Claude
e0893bd299
ax(node): replace prose comment on NewTransport with usage example
Some checks failed
Security Scan / security (push) Successful in 34s
Test / test (push) Has been cancelled
AX Principle 2: comments must show how to call the function with real
values, not restate what the type signature already says.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:08:21 +01:00
Claude
6d77de500d
ax(node): rename dedup field to deduplicator in Transport struct
AX Principle 1: predictable names over short names. The abbreviated
struct field `dedup` requires a reader to mentally expand it; the
full name `deduplicator` is self-describing.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 11:03:44 +01:00
Claude
871e6dd985
ax(node): replace prose comment on DefaultTransportConfig with usage example
AX Principle 2: comments must show HOW with real values, not restate what
the type signature already says. "returns sensible defaults" adds zero
information — the concrete call pattern teaches agents exactly how to use it.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:55:02 +01:00
Claude
e69816f978
ax(node): rename n to connectionCount in ConnectedPeers usage example
AX Principle 1: predictable names over short names. The comment example
used `n` which requires context to understand; `connectionCount` is
self-documenting.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:53:09 +01:00
Claude
22a74415f3
ax(node): rename d to deduplicator in NewMessageDeduplicator (AX-1)
Some checks failed
Security Scan / security (push) Successful in 32s
Test / test (push) Has been cancelled
Single-letter variable `d` requires a reader to infer its type from
context. Rename to `deduplicator` — predictable names over short names
(RFC-CORE-008 §1).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:38:29 +01:00
Claude
6854b7b054
ax(node): replace prose comment with usage example on PeerConnection.Close
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 signature already says. "Close closes the connection." adds zero
information; a usage example shows call site and error handling pattern.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 10:16:45 +01:00
Claude
50169f5a8e
ax(node): replace prose comments with usage examples in transport.go
Four functions in Transport had comments that restated the signature
("sets the handler", "establishes a connection", "sends a message to all
connected peers") rather than showing concrete call examples. Converted
to AX Principle 2 style — usage examples with realistic values.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:58:10 +01:00
Claude
d56f6749ad
ax(node): replace prose comments with usage examples on Start/Stop
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Transport.Start and Transport.Stop had prose comments that restated
the function name — the pattern AX Principle 2 explicitly bans.
Replaced with concrete call-site examples showing how callers use them.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:47:21 +01:00
Claude
e837423cb7
ax(node): replace prose comment with usage example on PeerRateLimiter.Allow
Some checks failed
Test / test (push) Waiting to run
Security Scan / security (push) Has been cancelled
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:39:46 +01:00
Claude
2ea46d8ec0
ax(node): rename Transport.mu to mutex (AX Principle 1)
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Abbreviated field name `mu` is ambiguous — rename to `mutex` to satisfy
AX-025 §1 (predictable names over short names).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:33:54 +01:00
Claude
7a967b9249
ax(node): rename MessageDeduplicator.mu to mutex for AX Principle 1 compliance
Abbreviated field name `mu` violated AX Principle 1 (predictable names over
short names). Renamed to `mutex` to match the convention already used in the
sibling `PeerRateLimiter` struct in the same file.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:19:26 +01:00
Claude
9ad9ecfa05
ax(node): replace prose-description comments with usage examples on MessageDeduplicator
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
IsDuplicate/Mark/Cleanup had comments restating the signature ("checks if",
"records a", "removes") — AX Principle 2 violation. Replaced with concrete
call-site examples showing how to sequence IsDuplicate → Mark → Cleanup.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 09:03:35 +01:00
Claude
315d052b15
ax(node): rename PeerRateLimiter.mu to mutex (AX-1 predictable names)
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:58:53 +01:00
Claude
115672cdfd
ax(node): replace Send comment that restated the signature with a 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 type
signature already says. "Send sends an encrypted message over the
connection." adds zero information.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:27:26 +01:00
Claude
785bb1ff76
ax(node): replace prose comment on ConnectedPeers with usage example
ConnectedPeers() had a comment that restated the function name ("returns
the number of connected peers"), violating AX Principle 2. Replaced with
a concrete usage example showing the guard pattern.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:18:25 +01:00
Claude
0c3c472c44
ax(node): rename Transport.wg to waitGroup (AX Principle 1)
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
'wg' is an abbreviation requiring mental mapping; 'waitGroup' names what
it IS — an explicit sync.WaitGroup, predictable across all call sites.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 08:01:48 +01:00
Claude
248a413dae
ax(node): replace prose comment with usage example on Transport.Send
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 2: comments that restate the type signature add zero
information. Replaced "Send sends a message to a specific peer." with a
concrete call-site example showing error handling.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 07:58:01 +01:00
Claude
45a1dcc987
ax(node): replace prose comment on NewMessageDeduplicator with usage example
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:54:06 +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
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
a48ce861da feat: Implement 8 more findings from 109-finding code review
HIGH priority fixes:
- RESIL-HIGH-2: ProfileManager graceful degradation on init failure
- PERF-HIGH-1: HTTP client connection pooling with transport config
- P2P-HIGH-4: Per-peer rate limiting (100 burst, 50/sec refill)
- P2P-HIGH-2: Message deduplication with 5-min TTL cache
- API-HIGH-2: Config validation for pool URLs, wallets, threads, algos

MEDIUM priority fixes:
- RESIL-MED-4: Health check endpoints (/health, /ready) with component status
- SEC-MED-1: Already using constant-time comparison (verified)
- CONC-MED-5: Already using non-blocking broadcast (verified)

Already implemented (verified):
- P2P-HIGH-3: Handshake timeout already at 10s

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 15:32:07 +00:00
snider
a5ed7ebee6 feat: Implement challenge-response authentication for P2P (P2P-CRIT-4)
- 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>
2025-12-31 15:16:00 +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