AX Principle 1: Predictable names over short names.
`msg` is an abbreviation; `errorMessage` names what it is.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 2: comments show HOW to call, not WHAT the body does.
The old comment restated the lock/defer mechanics; the new comment
shows the caller context (Save and Update) so an agent knows when
saveUnlocked is the right call.
Co-Authored-By: Charon <charon@lethean.io>
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>
Two names for the same constant violates AX Principle 1 (predictable
names over short names). The alias `ErrCodeInternal` is ambiguous and
shorter than the fully-descriptive `ErrCodeInternalError`. Remove the
alias and update all five call sites to use the canonical name.
Co-Authored-By: Charon <charon@lethean.io>
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>
Single-letter receiver `c` is only permitted for `*core.Core`.
`*wsClient` methods (safeClose, writePump, readPump) used the
ambiguous single-letter `c`; renamed to the full `client` so the
receiver is self-describing without a comment.
Co-Authored-By: Charon <charon@lethean.io>
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>
Single-letter receiver `h` on all EventHub methods is a predictability
violation — `hub` carries semantic meaning across the file.
Co-Authored-By: Charon <charon@lethean.io>
`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>
AX Principle 1: predictable names over short names. The abbreviated
field minersMu was missed when the EventHub mu was renamed to mutex
in a prior sweep.
Co-Authored-By: Charon <charon@lethean.io>
Remove `fmt` import from miner.go; replace all fmt.Errorf calls with
ErrInstallFailed, ErrInternal, and ErrMinerNotFound using .WithCause/.WithDetails.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX Principle 1 — predictable names over short names. The two-character
receiver `da` on DigestAuth methods mirrors the `cb` → `circuitBreaker`
fix already applied. The local variables `ha1` and `ha2` (RFC 2617 hash
computation steps) are renamed to `hashA1` and `hashA2` for the same reason.
Co-Authored-By: Charon <charon@lethean.io>
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>
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>
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>
AX Principle 1: predictable names over short names. The receiver abbreviation
`cb` required mapping overhead — replaced with the full `circuitBreaker` name
across all eight methods in circuit_breaker.go.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX Principle 2 — comments must show HOW (concrete call), not describe WHAT.
The wsUpgrader var comment restated the variable's purpose in prose; replaced
with a usage example showing the Upgrade call site.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX principle #2: comments show HOW with real values, not WHAT
the signature already says. Replaced two prose description blocks
on MinerTypeXMRig and getXMRigConfigPath with concrete call examples.
Co-Authored-By: Charon <charon@lethean.io>
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>
Two uses of the banned fmt import used fmt.Sprintf for trivial string
concatenation (timestamp prefix in LogBuffer.Write, XDG path in GetPath).
Replaced with direct string concatenation per AX banned-import rules.
Co-Authored-By: Charon <charon@lethean.io>
Adds containsStr alongside existing equalFold/hasPrefix string helpers in manager.go,
then removes the banned "strings" import from node_service.go.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX Principle 1 — predictable names over short names. `rl` requires
mental decoding; `limiter` is self-documenting at the call site.
Co-Authored-By: Charon <charon@lethean.io>
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>
Replace json.NewDecoder streaming decode with io.ReadAll + the package's
own UnmarshalJSON wrapper (bufpool.go), eliminating the direct encoding/json
dependency in line with AX banned-import rules.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX principle 2: comments show HOW with real values, not WHAT the name already says.
"DefaultMetrics is the global metrics instance" restates the declaration.
Replace with concrete field access examples an agent can copy directly.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1: predictable names over short names. tr requires
the reader to know tar conventions; tarReader is self-describing.
Co-Authored-By: Charon <charon@lethean.io>
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>
Four fmt.Errorf calls in updateInstallationCache used the banned fmt
package for error construction. Replaced with ErrInternal().WithCause()
to match the established pattern used throughout the package. Also
replaced the prose comment with a usage example per AX Principle 2.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX Principle 1 — predictable names over short names. The parameter `st`
required a mental mapping to `*SupervisedTask`; `supervisedTask` is
self-documenting at every call site inside the function.
Co-Authored-By: Charon <charon@lethean.io>
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>
Three comments violated AX Principle 2 (comments as usage examples):
- Repository interface comment described what it was rather than showing usage
- FileRepositoryOption comment said "configures a FileRepository" (restates the type)
- saveUnlocked comment described behaviour rather than showing the call pattern
Co-Authored-By: Charon <charon@lethean.io>
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>
AX Principle 2: comments show HOW with real values, not WHAT the
signature already says. The previous comment restated the function
name in prose; now it shows a concrete call site.
Co-Authored-By: Charon <charon@lethean.io>
Comments on TTMiner, TTMinerSummary, and getTTMinerConfigPath restated
what the type signature already said. Replace with concrete call examples
per AX Principle 2 (Comments as Usage Examples).
Co-Authored-By: Charon <charon@lethean.io>
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>