kanchi (感知 — "sensing / perception")
Typed environment-discovery primitive for the pleme-io fleet — the
shikumi discovered() tier made declarative.
Every GPU/terminal app faces the same domain: probe the host for the best-fit value, fall back to a documented default when it can't, expose the result as a discoverable tier. Hand-rolled, that's the same trio per axis, in every app:
pub const FALLBACK_X: T = ...;
kanchi collapses the whole domain into a declaration — and the platform FFI
(NSScreen, sysctl hw.memsize, /proc/meminfo, AppleInterfaceStyle) lives
once, in kanchi::probe:
defaxes!
Each line generates FALLBACK_<NAME> + detect_<name>() -> Option<T> +
detect_<name>_or_fallback() -> T. A probe is any no-arg callable returning
Option<T> (a fn path or a || … closure baking in args); use
[kanchi::none] for axes whose detection isn't wired yet.
probes (kanchi::probe)
| probe | source | None when |
|---|---|---|
screen_frac(frac, min, max) |
macOS NSScreen visible frame | off-main-thread / non-macOS |
dpr_font_size(hidpi, lodpi) |
macOS backing scale factor | off-main-thread / non-macOS |
appearance_dark() |
macOS AppleInterfaceStyle |
non-macOS (xdg-portal/OSC11 TODO) |
total_ram_gib() |
sysctl hw.memsize / /proc/meminfo |
unsupported OS |
Why it exists
The prime-directive case: the identical trio appears ~7× in mado and is needed
in tear / escriba / namimado / ayatsuri / seki — ~126 hand-authored items the
fleet would otherwise re-vendor, each a place for drift, a format!()
violation, or a divergent platform-FFI path. kanchi makes the discovered
tier as cheap to author as prescribed_default() is, with fallbacks meant to
be sourced from the same ishou::FleetDefaults the prescribed tier reads.
mado is the reference consumer (mado/src/auto_detect.rs).
License
MIT