Module fun

Module fun 

Source
Expand description

Fun mode — deterministically rename a JSON dump’s non-metric values to playful adjective-animal names (and hashed numeric IDs). Every non-metric value is funified by default: strings and integers under non-metric keys become a deterministic fun name, while values under metric-allowlisted keys (counts, rates, ratios, byte/duration units, structural enums) pass through unchanged. Structure and relationships are preserved — which keys nest where, which values co-refer — so agile-otter migrated from CPU 3 to CPU 7 reads the same, just with fun names. Deterministic per seed; a funify is a one-way rename.

§Polarity: metric allowlist

The walker funifies every value by default and passes through only the values whose containing key is a recognised metric (Funifier::is_metric_passthrough). This is the inverse of v1’s identifier deny-list. A novel identifier-shaped field added to a schema is hidden by default; only counts / rates / ratios / byte-and-duration units / structural enums survive funification. The suffix-based allowlist may over-match novel keys ending in structural-enum suffixes (_type, _kind, _state, _len, _offset) — schema-driven classification is a future direction that would remove the heuristic’s false positives.

§Surfaces

  • Funifier::petname_for turns a string identifier (cgroup name, process comm, scheduler name, …) into a deterministic adjective-animal pair like "agile-otter".
  • Funifier::numeric_id turns a u64 identifier (pid, tid, cpu, cgroup id, …) into another u64 via a SipHash-2-4 keyed permutation. The mapping is deterministic per (seed, category, n) so cross-references inside a dump survive.

Categories namespace the mapping: petname_for("pid", "42") and petname_for("cgroup", "42") produce different fun names because the category byte string is mixed into the keyed hash. The walker uses each non-metric key’s literal name as the namespace, so two values under the same key collide deterministically (intentional — cross-reference preservation) and two values under different keys don’t. Two pids with the same numeric value across two different dumps map to the same fun name only when both dumps share a --seed.

Determinism contract: given a fixed seed, the same input always produces the same fun output. With the default Funifier::ephemeral constructor a fresh random key is generated per process invocation; --seed on the CLI passes through to Funifier::with_seed so a user can correlate fun names across multiple funify runs of the same dump.

Structs§

Funifier
All-vCPU fun-mode key + petname dictionary handle. Cheap to clone (everything inside is Copy or 'static); typically constructed once per CLI invocation and reused for every identifier in the dump.

Functions§

funify_json
Recursively walk a serde_json::Value and funify every value whose containing key is NOT in Funifier::is_metric_passthrough. Returns the funified value — input is consumed (cheaper than cloning a deep tree).