CrowdControl.Backend.Local (crowd_control v0.1.0)

Copy Markdown View Source

Runs the CLI as a local subprocess via NetRunner.

This is the default backend and it is behaviour-preserving: every mechanism here — the env-file indirection, the reap-probe/SIGTERM/SIGKILL escalation, the blocking reader loop — moved out of CrowdControl.Session unchanged when the CrowdControl.Backend behaviour was introduced.

Env vars never appear in argv

Environment variables are written to a 0600 file in a 0700 directory, sourced by a wrapper shell, and rm'd before the CLI is exec'd. Passing them on the command line instead would expose secrets — ANTHROPIC_API_KEY among them — to any user who can run ps. Remote backends have first-class env injection and no local ps to hide from, so only this backend uses the env-file mechanism.

No reattach

A local subprocess dies with the VM that spawned it, so there is nothing to reattach to: list_live/1 returns {:ok, []} and reattach/2 returns {:error, :not_supported}. CrowdControl.Session consequently skips all CrowdControl.Store writes for this backend — see CrowdControl.Backend.reattachable?/1.

Summary

Types

t()

@type t() :: %CrowdControl.Backend.Local{
  env_dir: Path.t() | nil,
  env_file: Path.t() | nil,
  opts: keyword(),
  proc: pid() | nil
}