install

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package install provides the daemon's install identity: a plain UUID persisted once per boid installation and stamped as the boid.install_id label on every container/network/volume the daemon creates (docs/plans/phase6-container-backend.md §PR6, §決定6). It is not a secret — same non-secret, same-data-dir convention as web_secret (internal/dispatcher.LoadOrCreateKey) and the internal mTLS CA (internal/mtls.LoadOrCreate) — so LoadOrCreate mirrors both packages' load-or-generate-and-persist shape.

This value is deliberately NOT derived from anything host-identifying (hostname, MAC address, /etc/machine-id, ...): §決定6 calls for "平文 UUID を LoadOrCreate" specifically because boid has no existing notion of a machine id (2026-07-22 実査, plan doc §決定6) and a random UUID is sufficient to scope reap (§決定6's `boid reap`) to "resources this install created" without any host-fingerprinting privacy cost.

Index

Constants

View Source
const FileName = "install_id"

FileName is the file LoadOrCreate reads/writes under its dir argument.

Variables

This section is empty.

Functions

func LoadOrCreate

func LoadOrCreate(dir string) (string, error)

LoadOrCreate reads dir/install_id, or generates a fresh random UUID (v4) and persists it there if the file is missing or empty. dir is created (0700, matching mtls.LoadOrCreate's directory permissions) if needed.

The returned value is always the exact trimmed file contents on a successful read — this package treats it as an opaque label value (used verbatim as a docker `boid.install_id` label), not a UUID to be re-validated on every load. Only a missing or empty file triggers generation.

Concurrent-safe (Major 7, PR6 codex review): two LoadOrCreate calls racing on the same dir (e.g. two daemon instances starting at once against the same data dir) cannot both "win" and each persist a different UUID. The create path writes the full content to a temp file first, then publishes it onto path with os.Link — which fails with os.IsExist if path already exists, unlike os.Rename, which would silently replace it — so "path exists" only ever means "path already has complete content" (there is no observable window where a reader sees an empty, half-created file — the fatal gap in an O_CREATE|O_EXCL-then-separate-Write approach, where a losing goroutine can read the winner's file before the winner's own Write call has run and misidentify it as a crash-corrupted empty file needing repair). A losing caller re-reads the winner's now-guaranteed-complete file instead of silently returning its own freshly generated (and never-actually-persisted) id. §決定6 requires exactly one id per install, not "whichever caller's write happened to land last".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL