Single-letter receiver `h` requires mental mapping to understand it refers to
*ResponseHandler. Renamed to `handler` for self-documenting, predictable naming.
Co-Authored-By: Charon <charon@lethean.io>
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>
Replace fmt.Sprintf endpoint construction with string concatenation
and return errors directly, eliminating the banned fmt import.
Co-Authored-By: Charon <charon@lethean.io>
TestWorker_HandleGetStats_Bad and TestWorker_HandleGetStats_Ugly were
missing; AX requires all three categories mandatory per function.
Bad covers uninitialised identity, Ugly covers failed miner stat collection.
Co-Authored-By: Charon <charon@lethean.io>
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>
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>
AX Principle 1: predictable names over short names. `nm` requires a
comment to explain; `nodeManager` is self-documenting.
Co-Authored-By: Charon <charon@lethean.io>
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>
Comment used `gw` (AX-1: predictable names over short names).
Expanded to `gateway` so the usage example matches what code should look like.
Co-Authored-By: Charon <charon@lethean.io>
NodeManager's type comment restated the name in prose ("handles node
identity operations") rather than showing concrete usage. Replaced with
a three-line example demonstrating construction, identity check, and
retrieval — per AX Principle 2 (Comments as Usage Examples).
Co-Authored-By: Charon <charon@lethean.io>
Replace fmt.Sprintf/fmt.Errorf with strconv.Itoa and string
concatenation; surface fmt.Errorf error paths as typed
*ProtocolError values for consistent protocol error handling.
Co-Authored-By: Charon <charon@lethean.io>
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>
All test functions now follow the mandatory AX test naming convention.
TestResponseHandler_ValidateResponse, TestResponseHandler_ParseResponse,
TestProtocolError, and TestGetProtocolErrorCode_NonProtocolError renamed
and restructured into Good/Bad/Ugly triplets.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names. `ctrl` is an
abbreviation that requires a comment to explain; `controller` is
self-documenting and consistent with the `manager` pattern used in
NodeManager and PeerRegistry receivers.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names. The variable
`channel` in handleResponse required context to understand its role;
`responseChannel` is self-describing on first read.
Co-Authored-By: Charon <charon@lethean.io>
The field name `pending` required an inline comment to explain its
purpose ("message ID -> response channel"). Per AX Principle 1,
names that require a comment to explain are too short — rename to
`pendingRequests` so the field is self-describing without annotation.
Co-Authored-By: Charon <charon@lethean.io>
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>
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>
Test names must follow TestFilename_Function_{Good,Bad,Ugly}.
The extra _WrongURL qualifier broke the AX naming convention
(RFC-CORE-008 §10 — CLI tests as artifact validation).
Co-Authored-By: Charon <charon@lethean.io>
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>
AX Principle 10 requires all three categories (Good, Bad, Ugly) per test
group. identity_test.go had TestIdentity_NodeManager_Good with no Bad or
Ugly counterparts. Adds error-path tests for non-writable paths and
uninitialised identity, plus edge cases for double-generation and
delete-before-generate.
Co-Authored-By: Charon <charon@lethean.io>
ChallengeSize comment restated the name ("is the size of the challenge
in bytes") — violating AX Principle 2. Replace with a concrete usage
example showing how the constant is used at call sites.
Co-Authored-By: Charon <charon@lethean.io>
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>
Single-letter variable f is not in the permitted set (i, _, t, c).
outputFile names the handle by what it contains.
Co-Authored-By: Charon <charon@lethean.io>
AX-1: names that require a comment to explain are too short.
'dirs', 'dir', and 'mode' all needed the surrounding comment
to clarify their meaning; full names are self-documenting.
Co-Authored-By: Charon <charon@lethean.io>
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>
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>
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>
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>
AX Principle 10 requires test names to follow TestFilename_Function_{Good,Bad,Ugly}.
message_test.go used bare names (TestNewMessage, TestMessageReply, etc.) with no
suffix. Added Bad/Ugly cases for ParsePayload (nil payload, malformed JSON).
Co-Authored-By: Charon <charon@lethean.io>
RFC-025 Principle 2 — comments must show a concrete call with realistic
values, not restate what the signature already says.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX Principle 1 — predictable names over short names.
`Caps` is an abbreviation that requires context to understand;
`Capabilities` is self-documenting.
Co-Authored-By: Charon <charon@lethean.io>
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>
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>
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>
AX Principle 1 — predictable names over short names. `dn` is an
opaque abbreviation for a *datanode.DataNode; `dataNode` conveys
the type at a glance without requiring context lookup.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2: comments that restate what the surrounding code already
says are noise. The inline comment inside TestReader_ReadAndVerify_Ugly
duplicated the usage example already present in the function docstring.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 10 requires all three categories (Good, Bad, Ugly) for
every test function. TestWorker_HandlePing had only Good; add Bad
(invalid payload) and Ugly (zero SentAt edge case).
Co-Authored-By: Charon <charon@lethean.io>
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>