Skip to content

feat!: stop routine events from rotating machine IDs (D2) - #19

Merged
christiangda merged 1 commit into
mainfrom
feat/stable-identifiers
Sep 19, 2026
Merged

christiangda merged 1 commit into
mainfrom
feat/stable-identifiers

Conversation

@christiangda

Copy link
Copy Markdown
Contributor

Summary

Implements decision D2 from the Go 1.27 review: four inputs that rotated machine IDs on routine events are now excluded from the hash. This changes IDs on affected machines, deliberately, and ships in v0.2.0 with a migration note in the README ("ID compatibility across versions").

Input Before After Who is affected
Linux WithCPU() processor:vendor:model:flags vendor:model[:hardware], first core Every Linux machine using the CPU component (kernel/microcode updates and VM resizes no longer rotate the ID; aarch64 now yields real data instead of N:::)
WithMAC() physical filter Hyper-V/WSL vEthernet, Bluetooth PAN, Wi-Fi Direct, VirtualBox/VMware host adapters, Npcap, awdl/llw/ap/anpi, tailscale/zerotier/cni/flannel/calico counted as physical classified as virtual Machines with any of those interfaces up
WithDisk() USB / removable / optical devices counted fixed disks only (lsblk TYPE=disk RM=0, sysfs removable, wmic/PowerShell InterfaceType and MediaType) Machines with a USB drive, SD card or DVD attached at generation time

Everything else is unchanged: default CLI flags (-cpu -motherboard -uuid) on macOS and Windows produce the same IDs as v0.1.3.

Details worth a look

  • Windows friendly names vs kernel names. Names with a space or parenthesis are matched only against Windows rules (vethernet, bluetooth, npcap, vmware, virtualbox, hyper-v, tap-windows prefixes; virtual, wi-fi direct, loopback, * substrings). Kernel-style names use the prefix list plus an exact loopback rule. The first draft used one flat list and the lo prefix misclassified Local Area Connection; the table test caught it and now pins lom1, logical0, Local Area Connection, Ethernet 2 as physical.
  • Older wmic output without InterfaceType/MediaType fields is still accepted (instances without type fields are kept).
  • A property test asserts that adding a CPU flag or changing the processor index leaves the Linux identifier byte-identical.

Verification

gofmt, vet, golangci-lint (0 issues), go test -race ./... on darwin; vet and test binaries compile for linux and windows; modernize and betteralign clean. The Linux and Windows suites run in this PR's CI.

🤖 Generated with Claude Code

Four inputs that changed on ordinary maintenance are now excluded from
the hash. This changes IDs on affected machines; see the README section
"ID compatibility across versions" for the migration note.

Linux CPU (WithCPU)
- The identifier is now "vendor:model[:hardware]" from the first core.
  The kernel's "flags" line gained entries after kernel and microcode
  updates and the processor index changed when a VM was resized; both
  rotated the ID on routine maintenance.
- aarch64 kernels have no vendor_id or model name; "CPU implementer",
  "CPU part", "CPU variant", "CPU revision" and "Hardware" are used
  instead of the previous empty fields.

Network (WithMAC, physical filter)
- Hyper-V and WSL switches ("vEthernet (...)"), Bluetooth PAN, Wi-Fi
  Direct, VirtualBox and VMware host adapters, Npcap and TAP-Windows on
  Windows; awdl, llw, ap and anpi on macOS; tailscale, zerotier, cni,
  flannel, calico, dummy, vxlan and other overlay names on Linux are now
  classified as virtual.
- Windows friendly names (with spaces) use their own rules so the
  kernel prefix "lo" cannot misclassify "Local Area Connection".
  Loopback is matched exactly (lo, lo0, ...).

Disks (WithDisk)
- Linux: lsblk is queried with -P -o NAME,TYPE,RM,SERIAL and only
  TYPE=disk RM=0 devices count; /sys/block skips removable=1 and the
  loop/ram/zram/dm-/md/sr/fd/nbd/mtd families.
- Windows: USB interfaces and Removable/External media are excluded in
  both the wmic and the PowerShell path.
- Plugging in a USB drive, SD card or DVD no longer changes the ID.

README: stability table rewritten, MAC filter table updated, migration
paragraph added. Table tests cover every new classification and the
"flags added / index changed => same identifier" property.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@christiangda christiangda self-assigned this Sep 19, 2026
@christiangda
christiangda merged commit 68799ea into main Sep 19, 2026
8 checks passed
@christiangda
christiangda deleted the feat/stable-identifiers branch September 19, 2026 18:37
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