Commit graph

262 commits

Author SHA1 Message Date
Claude
b12db10680
ax(batch): expand abbreviated parameter and local variable names across all packages
Applies AX principle 1 (Predictable Names Over Short Names) to function
signatures and local variables: s->input/raw, v->target/value, d->duration,
a,b->left,right, w->writer, r->reader, l->logger, p->part/databasePoint,
fn parameter names left as-is where they are callback conventions.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 18:27:21 +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
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
f766f06c18
ax(node): rename msg/smsgMsg to message/decryptedMessage in transport
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Abbreviated variable names `msg` and `smsgMsg` violate AX Principle 1
(predictable names over short names). Renamed to `message` and
`decryptedMessage` for semantic clarity without context switching.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:53:58 +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
8695098988
ax(node): rename body to requestBody in lethean.go (AX Principle 1)
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 17:47:53 +01:00
Claude
0ef766ee36
ax(node): rename Controller.node field to nodeManager for AX Principle 1
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
`node` is ambiguous in the `node` package — callers cannot distinguish the
field from the package name without tracing. `nodeManager` names the type
it holds and removes all mapping overhead.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:46:35 +01:00
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
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
21c815b494
ax(node): route identity JSON through package MarshalJSON/UnmarshalJSON wrappers
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
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>
2026-04-02 17:39:43 +01:00
Claude
3e48734e7e
ax(node): add missing _Bad and _Ugly test variants for TestMessage_NewMessage
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 10 (CLI tests as artifact validation) requires all three
test categories — Good, Bad, Ugly — to be mandatory. TestMessage_NewMessage
had only _Good; add _Bad (unmarshalable payload returns error) and _Ugly
(empty From/To fields succeed and produce a valid message ID).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:38:04 +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
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
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
882dff4afc
ax(node): replace banned encoding/json import with package UnmarshalJSON wrapper in lethean.go
Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:24:46 +01:00
Claude
09a87eb021
ax(node): rename resp parameter to response in ResponseHandler methods
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Abbreviated parameter names violate AX Principle 1 (predictable names
over short names). resp → response in ValidateResponse and ParseResponse.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:23:03 +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
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
bcdce246f6
ax(node): add missing _Bad and _Ugly tests for TestMessage_Reply
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
AX Principle 10 requires all three categories (Good, Bad, Ugly) for
every test function. TestMessage_Reply had only _Good; adds _Bad
(unmarshalable payload propagates error) and _Ugly (self-to-self
addressing preserves correct From/To reversal).

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:16:05 +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
70fc8a6552
ax(node): remove banned fmt import from bundle.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Replace all fmt.Errorf calls in bundle.go with ProtocolError structs,
eliminating the banned fmt import. Error messages are preserved via
string concatenation consistent with the rest of the node package.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:10:07 +01:00
Claude
224a3c6118
ax(node): rename cfg.json to config.json in test path
AX Principle 1: predictable names over short names. cfg.json →
config.json makes the path self-describing without a comment.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:07:55 +01:00
Claude
2508b03df1
ax(mining): replace encoding/json with internal UnmarshalJSON in version.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
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>
2026-04-02 17:07:00 +01:00
Claude
c5bb4cf632
ax(node): replace single-letter loop variables p and k with peer and key
Range variables `p` and `k` in peer_test.go require context to decode —
violates AX Principle 1 (predictable names over short names). Renamed to
`peer` and `key` so intent is self-evident without reading the loop body.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 17:03:24 +01:00
Claude
406005b21a
ax(node): rename abbreviated msg locals to message in controller
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. Local variables
declared as `msg` in GetRemoteStats, StartRemoteMiner, StopRemoteMiner,
GetRemoteLogs, and PingPeer renamed to `message`.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:59:58 +01:00
Claude
b210b160d9
ax(node): rename tt to testCase in TestWorker_ConvertMinerStats_Good
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. `tt` is an
abbreviated loop variable; `testCase` states the semantic clearly.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:57:50 +01:00
Claude
09f6f12f08
ax(node): fix TestProtocol_ValidateResponse_Ugly comment and assertion
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
ValidateResponse wraps type-mismatch in *ProtocolError (correct behaviour).
The docstring example showed the wrong negation and the assertion fired on
every run. Both the comment (AX §2 — comments as accurate usage examples)
and the guard were inverted; corrected to !IsProtocolError.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:56:38 +01:00
Claude
aa69d9c933
ax(node): add Good and Ugly test variants for GetChainInfo, DiscoverPools, DiscoverGateways
AX principle 10 requires all three test categories (Good, Bad, Ugly).
lethean_test.go only had Bad variants for the three discovery functions;
added Good (happy-path via httptest.Server) and Ugly (edge-case filtering
and malformed JSON) for each, using a local test server to avoid live daemon dependency.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:54:59 +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
b4cef1305e
ax(node): expand nm abbreviation to nodeManager in usage comments
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 `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>
2026-04-02 16:51:54 +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
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
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
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
695a62b61a
ax(node): remove banned fmt import from controller.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Replace all fmt.Errorf calls with typed *ProtocolError values using the
native node error type — consistent with how protocol.go was cleaned up.
Error wrapping cases (failed to create message) now surface the original
error directly, preserving the call chain without fmt.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:41:30 +01:00
Claude
68fbe70c54
ax(node): rename ack to acknowledgement in controller (AX Principle 1)
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 16:38:18 +01:00
Claude
acef50ad62
ax(node): rename tt loop variable to testCase in lethean_test.go
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 `tt` loop variable
is a two-letter abbreviation with no defined exception in the AX naming rules
(only `i`, `_`, `t`, `c` are acceptable short names). Renamed to `testCase`
throughout TestParseComment_{Good,Bad,Ugly}.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:36:41 +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
e06f8de589
ax(node): rename buf to buffer in bundle_test for predictable naming
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. `buf` is an
abbreviation that requires a comment to understand; `buffer` is
self-describing.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:26:37 +01:00
Claude
8fe169aeb6
ax(node): replace prose comment with usage example on bufferPool
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
RFC-025 Principle 2: comments must show HOW with real values, not
restate what the variable does in prose.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:24:39 +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
e263fe7f1e
ax(node): rename loop variable p to peer in peer_test.go
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 single-letter `p` in `for _, p := range peers` is not listed
in the allowed exceptions (only `i`, `_`, `t`, `c` are permitted).
Rename to `peer` for semantic clarity.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 16:21:34 +01:00