bitc

module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT

README

Run heavy commands on a shared machine without letting them knock it over. bitc queues them in named pools of slots on your machine, and can offload them to a remote provider (a RunPod pod, a machine you own over SSH, or a plugin of your own) under a daily spend cap. When a command cannot start in time, bitc exits 75, "try again later", and never pretends your command failed.

ci Go Reference Go Report Card Latest release Go version

$ bitc run heavy -- npm test               # waits for a free slot, then runs; exit code is npm's
$ bitc run --wait 1s heavy -- npm test     # from another terminal, while the first still runs
STARVED heavy
$ echo $?
75

bitc is a single static binary, built for machines shared by AI coding agents. It works the same for a person at a terminal.

Why it exists

Ten coding agents on one 16 GiB machine will each start a type checker, a browser suite and a database at the same moment, and the machine falls over. A lock alone does not fix that: the agents also need to know whether to wait, retry or give up, and remote compute needs a spending limit.

  • Slots and a queue. A pool with N slots runs N commands at a time, in FIFO order, with priority lanes, groups shared across pools and, for a pool that declares its memory, a memory floor that holds a job back instead of letting the kernel kill something (Linux only).
  • Exit codes callers can act on. 75 means wait and retry and 69 means stop and report; bitc's few other codes are in the table below, and anything else is your command's own. Agents follow a ten-rule guide.
  • No daemon. State is files and flock(2) locks. A caller that is killed releases everything it held, and the next caller cleans up after it.
  • Spend-capped offload (experimental). A daily cap per priced provider account, a live-job limit, a ledger and a circuit breaker bound what remote jobs can cost. A job that has not started remotely falls back to the next provider in the pool's list, often local.
  • A trust split. The host file sets capacities, spend caps and providers. A repository's .bitc.toml can only narrow those limits, never widen them.

The local gate is the mature part. Every remote provider is experimental and off by default; read Known issues before pointing one at a real account.

Install

Linux (amd64 or arm64) is the main platform. The macOS builds run local pools only (macOS status).

Download a release binary and check it against checksums.txt (docs/install.md has the commands and lists every asset), or build it with Go 1.26 or newer:

go install github.com/Exploded-views/bitc/cmd/bitc@v0.1.0

Quickstart (local, about two minutes)

No account or network needed. The test suite runs every block below as written; the outputs come from a real run, so paths, ids and memory figures will differ on your machine.

1. Describe your machine. One pool, heavy, with one slot:

mkdir -p ~/.config/bitc
cat > ~/.config/bitc/bitc.toml <<'EOF'
version = 1

[pools.heavy]
slots = 1
EOF
chmod 600 ~/.config/bitc/bitc.toml   # bitc refuses a group- or world-writable config
bitc config check
ok host /home/you/.config/bitc/bitc.toml repo (none)

2. Run a command through the pool. bitc waits for a free slot, runs the command and returns the command's own exit code. stdout is the command's; bitc writes only to stderr.

bitc run heavy -- echo hello
bitc status
hello
heavy: 0/1 slots held, 0 waiting
memory: 15350 MiB available (MemAvailable), floor 6144 MiB

3. See "try again later". While one command holds the only slot, a second caller waits up to the pool's wait (10 minutes by default; --wait shortens it here), then gives up with STARVED heavy and exit 75:

bitc run heavy -- sleep 3 &     # takes the only slot
sleep 1
bitc run --wait 1s heavy -- echo second || echo "exit $?"
bitc status
wait
STARVED heavy
exit 75
heavy: 1/1 slots held, 0 waiting
  slot 1  19e3b439  pid 10745  since 2026-10-27T18:15:22Z  sleep 3
  last STARVED: all slots busy at 2026-10-27T18:15:24.777Z
memory: 15354 MiB available (MemAvailable), floor 6144 MiB

4. Outlast a tool-call limit. A detached job returns at once; bitc wait blocks for up to 9 minutes per call by default (--timeout) and exits 124 while the job is still running, so an agent just calls it again:

bitc run --detach --name demo heavy -- sh -c 'echo hi'
bitc wait demo
started demo pid 14890 log /home/you/.local/state/bitc/jobs/22bb2cbb/demo/out.log
RESULT exit 0
--- last 60 lines of /home/you/.local/state/bitc/jobs/22bb2cbb/demo/out.log ---
hi
__EXIT__ 0

The other commands are logs, cancel, sweep, doctor and version; bitc alone prints the usage line. Next, add a repository file (configuration) or point your agents at the agent guide.

Offload to a provider (experimental)

[!WARNING] Remote providers are experimental and off by default, and their spend accounting is still being hardened. The experimental_remote switch below is new in the next release; v0.1.0 rejects it as an unknown key. See Known issues.

A pool can list providers in order of preference. The host file says which providers a pool may use, how much it may spend and which work trees may go remote:

# ~/.config/bitc/bitc.toml
version = 1

[host]
experimental_remote = true             # remote providers are off by default

[pools.heavy]
slots = 1
providers = ["runpod", "local"]        # preference order; local is the fallback
remote_limits = { size = { runpod = "cpu8" } }

[remote_limits]
worktrees = ["**/worktrees/agent-*"]   # only these work trees may go remote

[providers.runpod]
api_key_file = "~/.config/bitc/runpod.key"
daily_usd = 25                         # the spend cap for this provider account
image = "docker.io/library/debian:bookworm-slim"
sizes = { cpu8 = { cpu_type = "cpu3c", vcpu = 8, usd_per_hour = 0.24 } }
# The pod downloads the bitc agent from a URL you host. The default source, "release", needs a
# release build of bitc; this example uses a URL instead.
agent = { source = "url", url = "https://example.com/bitc_linux_{arch}", path = "/opt/bitc/bitc" }

The repository says what may leave the machine:

# .bitc.toml at the top of the work tree
version = 1

[pools.heavy.remote]
allow = [["npm", "run", "coverage", "--"]]   # only these argv prefixes may go remote
artifacts = [{ path = "coverage" }]          # copied back after the job
$ bitc run heavy -- npm run coverage --
bitc: runpod: heavy job heavy-3f2a91 on x7k2p0q9 (cpu8) at 9c1e5b0d4a77
...
$ bitc run heavy -- npm run coverage --        # later, near the cap: runs locally instead
bitc: runpod: running heavy locally: daily cap $25.00: spent $24.80 + committed $0.00 + this job $0.40
...

The output is shortened and the ids are examples; the shape of both bitc: lines is real (docs/exit-codes.md). Both files pass bitc config check on Linux. A real repository usually also needs a [remote] profile for setup steps (examples/ has complete files). Run bitc sweep from a timer (docs/sweep-timer.md) so a job that dies at the wrong moment does not leave a paid resource behind. docs/providers.md covers each provider and its state.

How it works

bitc run <pool> -- <command> walks the pool's providers list in order (a pool with no list is just local). Simplified:

flowchart TD
    start(["bitc run heavy -- cmd"]) --> next{"Next provider in<br/>the pool's list?"}
    next -- "remote" --> eligible{"Allowed to go remote?<br/>host opted in, work tree granted,<br/>repo allows this argv"}
    eligible -- "no" --> next
    eligible -- "yes" --> budget{"Under the daily cap and<br/>live-job limit, provider healthy?"}
    budget -- "no" --> next
    budget -- "yes" --> launch["Launch the remote job"]
    launch -- "failed before the job started" --> next
    launch -- "started" --> remote["Runs remotely. Exit code is the command's;<br/>an infrastructure failure from here on is 75"]
    next -- "local" --> slot{"Slot free (and memory floor met)<br/>within the pool's wait?"}
    slot -- "yes" --> local["Runs here in the slot.<br/>Exit code is the command's"]
    slot -- "no" --> starved["STARVED, exit 75: try again later"]
    next -- "none left" --> none["No provider left:<br/>75 (cap, busy) or 69 (unavailable)"]

Once a remote job has started it never falls back, so a half-started job never runs its load twice. Every rule is in docs/spec.md section 8.2.

Two files configure bitc, and they are trusted differently:

flowchart LR
    host["Host file<br/>~/.config/bitc/bitc.toml<br/>owned by the account"] -- "sets pools, slots, waits,<br/>memory floors, providers,<br/>spend caps, grants" --> eff(["Effective limits"])
    repo["Repo file<br/>.bitc.toml<br/>owned by the project"] -- "adds env, hooks, refuse rules,<br/>what may go remote;<br/>can only narrow limits" --> eff

Details are in docs/configuration.md and docs/concepts.md.

Exit codes

Code Meaning What to do
the command's own the command ran; 128+N if signal N killed it treat it as the real result
64 usage: bad arguments, unknown pool, refused by a rule or hook fix the call
66 no such detached job check the job name
69 unavailable: not Linux or macOS, a Linux-only feature on macOS, unusable hook, no usable provider, internal error stop and report; do not retry blindly
75 temporary failure: starved, or a remote infrastructure failure after the job started wait, then run again
78 invalid configuration fix the configuration
124 bitc wait only: the job is still running call wait again

A command that itself exits 75 shows up as RESULT exit 75 in bitc wait: read the first line, not only the code. The stderr lines are in docs/exit-codes.md; the rules for agents are in docs/agent-guide.md.

Documentation

Read For
docs/agent-guide.md the rules an AI agent follows when it runs commands through bitc
docs/concepts.md pools, slots, groups, tickets, nested holds, providers, state
docs/configuration.md, docs/config-reference.md the two config files, and every key with its class and default
docs/exit-codes.md exit codes, stderr lines, wait outcomes, result.json
docs/providers.md remote providers, their state, and running them safely
docs/install.md release assets, building from source, macOS status
docs/comparison.md, docs/faq.md bitc next to flock, GNU parallel and CI concurrency; common questions
docs/threat-model.md, docs/spec.md what bitc defends against; the full design

Status and roadmap

bitc is pre-1.0 (v0.1.0 release notes), so interfaces may still change.

  • Stable in intent: the local gate (pools, slots, groups, priority lanes, memory admission, nested holds, detached jobs, status, sweep, doctor), the exit codes and the config schema.
  • Experimental: every remote provider. runpod was proven live on CPU pods before v0.1.0; a live re-proof of the release path is pending. ssh and exec plugins are implemented, and the plugin protocol may still change.
  • macOS: local pools only (macOS status).
  • Next release: see CHANGELOG.md.

Open issues that make up the roadmap:

  • #3, #4, #5: macOS parity, macOS as a client to remote providers (planned for 0.1.2), macOS as a remote build target (design first)
  • #6: Sprites catch-all egress deny
  • #7, #8: RunPod ordered data-centre walk with a per-pool US-only option; fallback CPU types per size
  • #9: the launch lock must exclude across implementations during a mixed rollout (spend-cap safety)
  • #10: IO-pressure admission (io_pressure_max)

Later: signed checksums after 1.0, packages under the name bitc, and volume caches for remote jobs (spec.md section 16.1, not scheduled).

Known issues

  • Remote providers are experimental and off by default (experimental_remote): their spend accounting is still being hardened. In 0.1.0 specifically: same-named concurrent jobs in one pool can collide, and some interrupted-create paths can leave a resource unpriced until its expiry. Local pools are not affected.

    A host with unfinished remote jobs left by an earlier version and no flag gets one more line from every refused command: set the flag and run bitc sweep to clean up what is left. If you deleted a provider's table instead, bitc doctor and bitc sweep still point out its unfinished jobs.

  • The v0.1.0 release predates the experimental_remote switch: it rejects the key as unknown (exit 78) and runs configured remote providers without it, Sprites included. Configure remote providers on 0.1.0 only with the cautions above in mind.

  • Sprites jobs are refused in this release (exit 78, even with experimental_remote): its network policy does not restrict egress yet, and a job would receive the forwarded environment and the deploy key. Fix tracked in #6. To clean up Sprites left by 0.1.0, keep the [providers.sprites] table, set experimental_remote = true under [host] and run bitc sweep (the sweep timer keeps working): it only lists Sprites, checks their owner tag and deletes this install's.

  • In 0.1.0 the shipped example examples/config/repo.bitc.toml declares min_version = "1.0.0", so a 0.1.0 build refuses it (exit 78); set it to "0.1.0". Fixed in 0.1.1.

Sibling projects

  • crewkit: tools and practices for running a crew of Claude Code sessions against one repository and one host.
  • claude-utils: a fork of MarimerLLC/claude-utils, cross-workstation tooling for Claude Code (memory sync).
  • yo-human: the channel between a crew of AI agents and their human. The repository is private for now (design stage), so the link may not open yet.

Contributing

Bug reports and feature requests go to GitHub issues (use the issue templates). Pull requests are welcome; CONTRIBUTING.md covers building, make ci and the conformance register. Please follow the Code of Conduct, and report security problems privately as SECURITY.md describes, never in a public issue.

License

MIT. See LICENSE.

Directories

Path Synopsis
cmd
bitc command
Command bitc is a daemonless job gate for a shared Linux host.
Command bitc is a daemonless job gate for a shared Linux host.
conformance
harness
Package harness runs the built bitc binary in throwaway homes (spec 11).
Package harness runs the built bitc binary in throwaway homes (spec 11).
provider
Package provider is the provider conformance suite: one scenario set run against every provider's fake (spec 11).
Package provider is the provider conformance suite: one scenario set run against every provider's fake (spec 11).
examples
plugins/bitc-provider-fakex command
Command bitc-provider-fakex is the reference provider plugin for bitc (providers delta A.10.3).
Command bitc-provider-fakex is the reference provider plugin for bitc (providers delta A.10.3).
plugins/bitc-provider-fakex/fakeapi command
Command fakeapi is the loopback fake of the fakex API that the reference plugin talks to (providers delta A.10.2).
Command fakeapi is the loopback fake of the fakex API that the reference plugin talks to (providers delta A.10.2).
internal
admit
Package admit decides when a command may start (spec 6.2, 6.6).
Package admit decides when a command may start (spec 6.2, 6.6).
agent
Package agent is the remote side of a job (spec 8.4), the same binary as the host side.
Package agent is the remote side of a job (spec 8.4), the same binary as the host side.
agent/agenttest
Package agenttest is a fixture that drives agent.Run in-process as a plain user against a local git repository, for the agent's own tests and the conformance suite.
Package agenttest is a fixture that drives agent.Run in-process as a plain user against a local git repository, for the agent's own tests and the conformance suite.
classify
Package classify unwraps an argv into simple commands and applies refuse rules (spec 6.7).
Package classify unwraps an argv into simple commands and applies refuse rules (spec 6.7).
classify/classifytest
Package classifytest holds the classifier fixtures shared by unit and conformance tests.
Package classifytest holds the classifier fixtures shared by unit and conformance tests.
cli
Package cli dispatches bitc's subcommands.
Package cli dispatches bitc's subcommands.
config
Package config loads and merges bitc's TOML files (spec 5).
Package config loads and merges bitc's TOML files (spec 5).
config/gen command
Command gen prints the generated configuration reference.
Command gen prints the generated configuration reference.
exit
Package exit is bitc's exit-code contract (spec 4).
Package exit is bitc's exit-code contract (spec 4).
jobs
Package jobs is bitc's detached-job record (spec 7).
Package jobs is bitc's detached-job record (spec 7).
lock
Package lock wraps flock(2) on O_CLOEXEC files (spec 6.2, 9).
Package lock wraps flock(2) on O_CLOEXEC files (spec 6.2, 9).
proc
Package proc reads process ancestry and groups (spec 6.2, 6.6): /proc on Linux, sysctl kern.proc on darwin.
Package proc reads process ancestry and groups (spec 6.2, 6.6): /proc on Linux, sysctl kern.proc on darwin.
proctest
Package proctest tells tests whether a process is gone (standard library only).
Package proctest tells tests whether a process is gone (standard library only).
provider
Package provider is the interface every remote provider implements (spec 8.1).
Package provider is the interface every remote provider implements (spec 8.1).
provider/fake
Package fake is a test-only provider that runs the job as a local process.
Package fake is a test-only provider that runs the job as a local process.
provider/plugin
Package plugin is the adapter that runs an external provider executable (spec 8.5, providers delta A) behind the Provider interface: one pinned process per bitc process and type, NDJSON on its stdin and stdout, secrets on fd 3.
Package plugin is the adapter that runs an external provider executable (spec 8.5, providers delta A) behind the Provider interface: one pinned process per bitc process and type, NDJSON on its stdin and stdout, secrets on fd 3.
provider/plugin/pin
Package pin checks and opens a pinned provider plugin (providers delta A.2): an absolute path and a sha256, a regular ELF file owned by the user or root, no group or world write on it or any parent, no setuid or setgid bit, no file capabilities.
Package pin checks and opens a pinned provider plugin (providers delta A.2): an absolute path and a sha256, a regular ELF file owned by the user or root, no group or world write on it or any parent, no setuid or setgid bit, no file capabilities.
provider/plugin/stubplugin command
Command stubplugin is a minimal provider plugin for bitc's own tests (providers delta P.1): a protocol-1 peer with fault modes, driven by the `fault` key of its [providers.<t>] section (or STUB_HELLO_FAULT for faults before configure).
Command stubplugin is a minimal provider plugin for bitc's own tests (providers delta P.1): a protocol-1 peer with fault modes, driven by the `fault` key of its [providers.<t>] section (or STUB_HELLO_FAULT for faults before configure).
provider/runpod
Package runpod is the RunPod provider (spec 8.7): CPU pods over REST v2.
Package runpod is the RunPod provider (spec 8.7): CPU pods over REST v2.
provider/runpod/runpodfake
Package runpodfake is a fake RunPod REST v2 API for tests (spec 11): every created pod is a local `bitc __agent` process in its own process group, its stdout is the container log, and a second loopback server proxies /<pod>-<port>/v1/<file> to the agent's results server.
Package runpodfake is a fake RunPod REST v2 API for tests (spec 11): every created pod is a local `bitc __agent` process in its own process group, its stdout is the container log, and a second loopback server proxies /<pod>-<port>/v1/<file> to the agent's results server.
provider/sprites
Package sprites is the Fly Sprites client (sprites-provider.md): the REST calls a fresh-Sprite-per-job provider needs, the WebSocket exec channel, the error classes of 1.2 and the pre-attach / attached classification of 1.3.
Package sprites is the Fly Sprites client (sprites-provider.md): the REST calls a fresh-Sprite-per-job provider needs, the WebSocket exec channel, the error classes of 1.2 and the pre-attach / attached classification of 1.3.
provider/sprites/liveprobe
Package liveprobe is the Sprites probe kit: a scripted, capped runner that answers the open items of docs/design/sprites-provider.md section 9 against the live Sprites API.
Package liveprobe is the Sprites probe kit: a scripted, capped runner that answers the open items of docs/design/sprites-provider.md section 9 against the live Sprites API.
provider/sprites/spritesfake
Package spritesfake is a strict fake of the Fly Sprites API for tests (sprites-provider.md 8.1): an httptest REST server plus a WSS exec endpoint.
Package spritesfake is a strict fake of the Fly Sprites API for tests (sprites-provider.md 8.1): an httptest REST server plus a WSS exec endpoint.
provider/ssh
Package ssh is the fixed-capacity provider (providers delta C): jobs run on one host the owner already has, reached over the system OpenSSH client, with a number of slots instead of a price.
Package ssh is the fixed-capacity provider (providers delta C): jobs run on one host the owner already has, reached over the system OpenSSH client, with a number of slots instead of a price.
provider/ssh/sshfake
Package sshfake is the ssh provider's test double (providers delta C.11): a fake host gate.
Package sshfake is the ssh provider's test double (providers delta C.11): a fake host gate.
provider/ssh/sshfake/gate command
Command sshfakegate is the fake ssh host gate the conformance suite runs in place of ssh (providers delta C.11): `sshfakegate --root DIR -- <gate command line>`.
Command sshfakegate is the fake ssh host gate the conformance suite runs in place of ssh (providers delta C.11): `sshfakegate --root DIR -- <gate command line>`.
redact
Package redact keeps secret values out of every bitc log sink (spec 10).
Package redact keeps secret values out of every bitc log sink (spec 10).
remote
Package remote runs a job on a remote provider (spec 8.2-8.4) with the shared rails.
Package remote runs a job on a remote provider (spec 8.2-8.4) with the shared rails.
remote/artifacts
Package artifacts brings a remote job's declared paths back into the work tree (spec 8.4).
Package artifacts brings a remote job's declared paths back into the work tree (spec 8.4).
remote/gitref
Package gitref holds the git helpers of the git-push transport (spec 8.4): clone URL derivation, known hosts, and job-ref sweeping.
Package gitref holds the git helpers of the git-push transport (spec 8.4): clone URL derivation, known hosts, and job-ref sweeping.
remote/rails
Package rails is the shared remote safety rails (spec 8.3).
Package rails is the shared remote safety rails (spec 8.3).
remote/transport
Package transport is the git-push code transport stage (spec 8.4).
Package transport is the git-push code transport stage (spec 8.4).
run
Package run is the `bitc run` pipeline (spec 6) and the local runner.
Package run is the `bitc run` pipeline (spec 6) and the local runner.
state
Package state owns bitc's on-disk layout (spec 9).
Package state owns bitc's on-disk layout (spec 9).
status
Package status implements status, sweep and doctor (spec 3.3).
Package status implements status, sweep and doctor (spec 3.3).
version
Package version is stamped by the build (-ldflags -X).
Package version is stamped by the build (-ldflags -X).
wsmini
Package wsmini is the minimal RFC 6455 framing the Sprites exec channel needs, so the module takes no WebSocket dependency.
Package wsmini is the minimal RFC 6455 framing the Sprites exec channel needs, so the module takes no WebSocket dependency.

Jump to

Keyboard shortcuts

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