Skip to content

chore: branch-wide audit sweep (style + dedup + cmdline test)#55

Merged
CMGS merged 8 commits into
masterfrom
audit/code-sweep
May 18, 2026
Merged

chore: branch-wide audit sweep (style + dedup + cmdline test)#55
CMGS merged 8 commits into
masterfrom
audit/code-sweep

Conversation

@CMGS
Copy link
Copy Markdown
Contributor

@CMGS CMGS commented May 18, 2026

Summary

Two-phase audit pass against current SKILL.md, applied across the whole tree.

Phase 1 — style sweep (53 files, mostly comments)

  • Drop caller-attribution godoc lines (`Used by GC to...`, `Was added to...`).
  • Collapse 70 two-line wrapped godocs into single lines (60 + 10 in two passes).
  • Enforce public-above-private file order in `cmd/core/helpers.go` (`resolveOwner`) and `cmd/vm/lifecycle.go` (`streamLog` / `seekToLastNLines`).
  • Lowercase `VM`/`CNI` in two `fmt.Errorf` messages to match the dominant lowercase style.

Phase 2 — dedup

  • Extract `hypervisor.BuildBaseCmdline` so CH and FC share the boot/layers/cow body and per-NIC `ip=` block; each backend's `buildCmdline` shrinks to a single call with its kernel-quirk prefix.
  • Add `configJSONName` / `stateJSONName` / `memoryRangeFile` consts in `cloudhypervisor`, replacing 9 hard-coded magic strings across clone / direct / helper / restore / snapshot.
  • Lock the new builder with a table-driven test that asserts byte-exact CH and FC cmdlines, including the with-NIC path.

No behavior change: cmdline strings remain byte-identical for both backends.

Test plan

  • `make lint` — 0 issues on GOOS=darwin and GOOS=linux
  • `make vet` — clean on both platforms
  • `make fmt-check` — clean
  • `make test` (race + cover) — all packages green
  • `TestBuildBaseCmdline` covers CH no-net / FC no-net / CH with NIC+DNS, locking byte-exact output

CMGS added 8 commits May 18, 2026 14:52
Per feedback memory: don't reference callers/tasks in godoc. Removed
"Used by GC to..." / "Used by both backends..." tails from 4 utility
funcs in utils/file.go + hypervisor/utils.go. The functions are
caller-agnostic; the attribution would rot when call sites change.
Sweep across 39 files: any 2-line // block above a top-level
declaration where line1 doesn't end with terminal punctuation and
line2 starts lowercase (i.e. a wrapped sentence, not "summary . why
clause") was joined into one line. Genuine summary-then-WHY 2-liners
were left alone.

Sibling style in cocoon already accepts long 1-line godocs (see e.g.
hypervisor/state.go IsAPISocketLive); these joins just remove
mechanical line breaks that hide the godoc's start.
Aggressive sweep extended to:
- line 2 starting with non-letter continuation chars (/, (, <, *, digits)
- "This eliminates...", "Was added to..."-style history phrases
  belonging in commit log, not godoc

10 godocs trimmed across types/storage.go, images/, utils/, storage/,
metadata/, hypervisor/.
Move resolveOwner (cmd/core/helpers.go) and streamLog +
seekToLastNLines (cmd/vm/lifecycle.go) below the exported
declarations so each file follows the project's public-above-private
ordering. No semantic change.
Aligns 'VM %s' / 'CNI backend ...' with the dominant lowercase
'vm %s' / 'cni ...' style used across the codebase. No behaviour
change.
…on constants

- Add hypervisor.BuildBaseCmdline so CH and FC buildCmdline share the
  boot/layers/cow body and per-NIC ip= block; backend-specific kernel
  quirks become a single prefix string.
- Add stateJSONName/configJSONName consts in cloudhypervisor and use
  them across clone/direct/helper/restore/snapshot; six magic strings
  collapse to two named constants.
…RangeFile const

Three sites in helper.go / direct.go hard-coded the snapshot file
prefix; one named constant prevents drift if CH ever renames the
per-region file pattern.
Locks the cmdline byte format (prefix + layers/cow body + ip= params)
for both CH and FC prefixes so a future refactor can't silently shift
boot args.
@CMGS CMGS merged commit 65ec0e6 into master May 18, 2026
4 checks passed
@CMGS CMGS deleted the audit/code-sweep branch May 18, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant