Delete inline comments that restate what the next line of code does
(AX Principle 2). Affected: circuit_breaker.go, service.go, transport.go,
worker.go, identity.go, peer.go, bufpool.go, settings_manager.go,
node_service.go.
Co-Authored-By: Charon <charon@lethean.io>
Applies AX principle 2 (Comments as Usage Examples) — removes prose
descriptions that restate the function signature ("returns", "retrieves",
"creates", "wraps", etc.) and keeps or replaces with concrete usage
examples showing real calls with realistic values.
Co-Authored-By: Charon <charon@lethean.io>
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>
Replaces fmt.Sscanf with strconv.Atoi for port parsing, removing the
banned fmt import from the test file per AX banned-imports rules.
Co-Authored-By: Charon <charon@lethean.io>
Replace all fmt.Println, fmt.Sprintf, log.Printf, log.Println, and
json.Unmarshal references in doc comments with logging.Info/logging.Warn
or direct value access patterns. Comments are examples that agents
learn from -- they must not demonstrate banned imports.
Co-Authored-By: Charon <charon@lethean.io>
Rename short receivers to predictable full names across all packages:
- lb -> logBuffer (LogBuffer methods in miner.go)
- l -> logger (Logger methods in logging/logger.go)
- l -> level (Level.String() in logging/logger.go)
- h -> histogram (LatencyHistogram methods in metrics.go)
- r -> repository (FileRepository methods in repository.go)
Agents can now grep for the receiver name and get the type without
context. Single-letter 'c', 'm', 's', 'e' kept where idiomatic for
Container, Miner, Store, and Error types per Go convention.
Co-Authored-By: Charon <charon@lethean.io>
Convert "X returns the Y" / "X holds Y" / "X represents Y" style
comments to concrete usage examples across database/, logging/, and
mining/ packages. Comments now show how to call the function with
realistic values instead of restating what the signature already says.
Co-Authored-By: Charon <charon@lethean.io>
Replace fmt.Sprintf with string concatenation + strconv.Itoa/FormatInt.
Replace fmt.Errorf with project MiningError constructors (ErrStartFailed,
ErrInstallFailed, ErrInternal) and a new databaseError helper in pkg/database.
Leaves fmt in pkg/logging (it IS the logging package) and test files.
Co-Authored-By: Charon <charon@lethean.io>
AX Principle 1 — predictable names over short names. `msg` required
reading the struct to understand what it contained; `clientMessage`
is self-describing at the call site.
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>
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>
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>
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>
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 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>
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 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>
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>
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>
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>
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>
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>
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 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>
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>
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>
AX principle 2: comments show HOW with real values, not WHAT the type is.
The old comment restated the struct definition. Replaced with a concrete
construction example.
Co-Authored-By: Charon <charon@lethean.io>
AX principle 2 — comments show HOW with real values, not WHAT the
signature already says. Aligns with xmrig_stats.go and simulated_miner.go.
Co-Authored-By: Charon <charon@lethean.io>
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>
AX principle 2: comments show HOW with real values, not what the
signature already says. "unzip extracts a zip archive" restates the
name; replaced with concrete call-site examples.
Co-Authored-By: Charon <charon@lethean.io>
Replace fmt.Sprintf calls with string concatenation (+) and
strconv.FormatInt for integer formatting. fmt is a banned import
per AX conventions; all string formatting goes through Core primitives
or native concatenation.
Co-Authored-By: Charon <charon@lethean.io>