AX Principle 2 — comments as usage examples: the ReadAndVerify doc
comment only showed the success path; both errMissingHMAC and
errIntegrityViolation sentinel branches are now illustrated so callers
can copy-paste correct dispatch logic.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1: predictable names over short names. wg requires
mental mapping to WaitGroup; waitGroup is self-documenting.
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>
AX Principle 2: comments show usage examples, not descriptions.
The trailing "raw bytes after the 0xFF payload tag" restated what
the tag constant already communicates — deleted.
Co-Authored-By: Charon <charon@lethean.io>
AX principle #2: comments must show HOW (concrete call), not describe
WHAT (which the signature already says).
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>
Comment "→ covers all header TLVs before the HMAC tag" was prose
describing effect rather than showing usage with concrete values,
violating AX Principle 2 (comments as usage examples, not descriptions).
Replaced with a full usage example showing all three messageAuthCode calls.
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>
AX Principle 2: comments show HOW with real values, not what the
signature already says. Replace description with call example.
Co-Authored-By: Charon <charon@lethean.io>
Variables e, a, b violate AX Principle 1 (predictable names over short names).
Renamed to sentinel, sentinelFirst, sentinelSecond across test functions and
the usage-example comment in packet.go.
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>
RawConfig and MiningProfile had description-style comments restating what
the types are rather than showing how to use them (AX Principle 2 violation).
Replaced with concrete call-site examples demonstrating real usage patterns.
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>
TestPacket_sentinelError_{Good,Bad,Ugly} were absent — AX requires all
three test categories for every exported and package-level function.
The Error() method on sentinelError had no direct coverage.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2 — comments show HOW with real values, not WHAT the
function does. The prose description restated the signature; replaced
with a concrete call sequence.
Co-Authored-By: Charon <charon@lethean.io>
Four type comments in mining.go restated the type name in prose
("represents a ...", "provides ..."), violating AX Principle 2.
Replaced with concrete usage examples showing realistic field values.
Co-Authored-By: Charon <charon@lethean.io>
The comment on `sentinelError` restated the `errTLVValueTooLarge`
declaration directly above it (AX principle 2 violation). Replaced
with a distinct concrete example showing how to define any sentinel
of this type.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2 — comments must show realistic usage with actual values from
the codebase, not placeholder examples. The sentinelError type comment used
errNotFound (a fictional variable) instead of errTLVValueTooLarge (the actual
sentinel declared on the next line).
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>
AX principle 2: comments show HOW with real values, not WHAT the type
signature already states. Metrics and LatencyHistogram had prose
descriptions; replaced with concrete call-site examples.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2 requires comments to show concrete usage with realistic values.
The writeTLV comment used `intentID` (a variable name) as a placeholder
rather than a real value; replaced with `0x01` and added error-capture
pattern to show the full call site shape.
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>
AX Principle 2: comments must show HOW with real values, not restate what
the type signature already says. "checks if an algorithm name contains only
valid characters" is a prose description — replaced with concrete call examples.
Co-Authored-By: Charon <charon@lethean.io>
Comment described assertion in prose ("integrity violation" in error message) rather
than showing the concrete sentinel pattern. Test also failed to verify err identity
consistently with TestReader_ReadAndVerify_Ugly and packet_test.go error tests.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2 — comments must show HOW with real values, not restate WHAT
the type already says. WindowState, MinerDefaults and AppSettings all had
prose descriptions ("stores…") replaced with concrete call-site examples.
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>
Replaces `header := UEPSHeader{}` with `var header UEPSHeader` for
consistency with the surrounding zero-value var declarations in the
same block — predictable, uniform pattern over mixed init styles.
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>
Four internal methods had comments that restated prose descriptions
(e.g. "saves the autostart and last-used config for a miner") instead
of showing a concrete call site — violating AX Principle 2.
Replaced with usage-example comments showing realistic invocations with
argument values.
Co-Authored-By: Charon <charon@lethean.io>
AX-2 — the Error() method on sentinelError had no comment; added a
concrete call-and-result example so an agent can understand the
sentinel identity contract without tracing the type definition.
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>
AX Principle 2: comments show HOW via concrete call, not WHAT via prose.
The previous comment described the variable's purpose in prose — replaced
with a direct usage example showing the Get/Reset/Put pattern.
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>
sentinelError had no comment, violating AX Principle 2 (comments as
usage examples). Added a concrete call-site example showing sentinel
identity comparison pattern.
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 2: usage example comments must show realistic call sites.
The writeTLV header comments used `buffer` as the first argument name,
but the parameter is `writer` and all callers pass `frameBuffer`.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2 — comments show HOW with real values, not WHAT the
signature already says. "NewService creates a new mining service"
restates the name; the usage example teaches call-site shape.
Co-Authored-By: Charon <charon@lethean.io>
The type name uepsError used the package abbreviation as a prefix, which
adds no semantic value inside the ueps package and violates AX Principle 1
(predictable names over short names). sentinelError names what the type IS:
an immutable, comparable error value.
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>
AX principle 2: comments show HOW with real values, not WHAT the signature says.
Removed five prose headers ("returns a mining config for...") that restated type
signatures. Retained concrete usage-example lines already present.
Co-Authored-By: Charon <charon@lethean.io>
The type was named packetError but also used in reader.go for reader-side
sentinel errors (errMissingHMAC, errIntegrityViolation). The name implied
packet-only scope, misleading agents reading reader.go. uepsError names the
type after the package it belongs to, matching AX principle 1.
Co-Authored-By: Charon <charon@lethean.io>
Replace fmt.Errorf/Sprintf with package-native ErrInternal constructors
and strconv.Itoa for URL assembly in FetchJSONStats.
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>