bitc

module
v0.1.0 Latest Latest
Warning

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

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

README

bitc

Offload heavy commands to pluggable cloud providers (RunPod, Sprites, SSH, or your own) under a spend cap, with local slot gating as the fallback. Built for machines shared by AI coding agents.

ci Go Reference Go Report Card Latest release Go version

bitc (big ideas, tiny computer) runs a heavy command (type check, test suite, browser tests) on a remote provider instead of your machine, as long as the pool's daily spend cap allows it. If the job cannot be offloaded, or the provider is down, it runs locally in a slot of a named pool. In the one case where it can do neither in time, it exits 75 ("try again later") and never pretends your command failed.

The host file says which providers a pool may use, how much it may spend and which work trees may go remote; the repository says what may leave the machine.

Host file, ~/.config/bitc/bitc.toml:

version = 1

[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, and none has been published yet.
agent = { source = "url", url = "https://example.com/bitc_linux_{arch}", path = "/opt/bitc/bitc" }

Repository file, .bitc.toml:

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 job and pod ids are examples; the shape of both bitc: lines is real (see docs/exit-codes.md). Complete files are in examples/; a repository usually also needs a [remote] profile for setup steps. Offload is experimental: see Providers below.

The other half is the shared-host story. 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 pool with N slots turns that into a queue, with or without a provider:

$ bitc run lint -- npm run lint        # holds the only slot of pool "lint" for the whole run
$ bitc run --wait 1s lint -- echo hi   # from a second terminal, while the first still runs
STARVED lint
$ echo $?
75
$ bitc status
lint: 1/1 slots held, 0 waiting
  slot 1  d0b9172c  pid 2306089  since 2026-10-25T06:38:03Z  npm run lint
  last STARVED: all slots busy at 2026-10-25T06:38:05.299Z
memory: 12230 MiB available (MemAvailable), floor 6144 MiB

Why it exists

  • Spend-capped offload. A daily cap per provider account, a live-job limit, a ledger and a circuit breaker bound what remote jobs can cost. A job that has not started falls back to the next provider and finally to local.
  • Pluggable. Built-in providers for RunPod, Sprites and SSH hosts, and an exec plugin protocol for anything else.
  • 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.
  • Exit codes callers can act on. 75 means wait and retry, 69 means stop and report, 64, 66, 78 and 124 are bitc's own (see the table below), and every other code is your command's. Agents get a small rule set (docs/agent-guide.md).
  • Admission, not just locking. FIFO tickets, priority lanes, groups shared across pools and a memory floor that holds a job back instead of letting the kernel kill something.
  • Two config layers with 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.

Maturity, plainly: the local gate is the mature part. Every remote provider is pre-release; read the Providers and Status sections before pointing one at a real account.

Install

bitc runs on Linux (amd64 or arm64). macOS (Apple silicon or Intel) gets a client build that runs local pools; the Linux-only features below are refused there. To install from source you need Go 1.26 or newer (CI tests 1.27.3):

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

Release tarballs for linux and darwin (amd64 and arm64), bare binaries and a checksums.txt are published at https://github.com/Exploded-views/bitc/releases once a release exists (no release has been tagged yet). Download the asset and checksums.txt into one directory and verify before use:

sha256sum -c --ignore-missing checksums.txt

Checksums are unsigned for now; signed checksums are planned after 1.0. docs/RELEASING.md describes what a release contains.

macOS client build

The darwin build runs local pools: slots, queues, groups, priority lanes, nested holds, detached jobs, status, wait, logs, cancel, doctor and config. These stay Linux-only; full parity is tracked in issue #3:

  • memory admission (a pool's memory key): a config error (78) on macOS;
  • remote providers (ssh, runpod, sprites and exec plugins, so sweep and doctor --remote have nothing to manage): any [providers.*] table is a config error (78);
  • the remote agent (bitc __agent) and the plugin exec shim: one bitc: ... runs on Linux only line and exit 69;
  • the parent-death signal: on macOS a command outlives a bitc that was killed with SIGKILL;
  • the inotify wake-up: a waiting caller re-checks every poll (5s by default) instead;
  • the read-only lock view (/proc/locks): status probes a lock with a brief non-blocking flock;
  • a detached job's log may have an empty line before its __EXIT__ line.

Quickstart

Write a host file with one pool, check it, run a command, then run a detached job. The block below is run by the test suite exactly as written.

mkdir -p ~/.config/bitc
printf 'version = 1\n[pools.lint]\nslots = 1\n' > ~/.config/bitc/bitc.toml
chmod 600 ~/.config/bitc/bitc.toml
bitc config check
bitc run lint -- echo hello
bitc run lint -- sleep 1 & bitc run lint -- echo second; wait
bitc status
bitc run --detach --name demo lint -- sh -c 'echo hi'
bitc wait demo

The pool lint has one slot, so two callers take turns: the second waits (up to the pool's wait, 10 minutes by default) and, if it cannot start in time, exits 75 with a STARVED lint line on stderr. bitc status shows holders, waiters and spend. A detached job returns at once with started demo pid <pid> log <path>; bitc wait demo waits (by default at most 9 minutes per call, detach.wait_timeout, or --timeout) and prints RESULT exit <code> and the last lines of the log.

Commands: run, status, wait, logs, cancel, sweep, doctor, config and version. bitc alone lists the commands; a bad flag prints that command's usage.

Configuration

There are two files, and both must start with version = 1, use strict decoding (an unknown key is an error) and not be group- or world-writable.

The host file (~/.config/bitc/bitc.toml, or --config, or BITC_CONFIG) belongs to the account:

version = 1

[host]
memory_floor = "6GiB"          # admission holds a job back below this much free memory

[pools.lint]
slots = 1

[pools.heavy]
slots = 1
wait = "1h"
memory = "8GiB"                # an admission reservation, not a limit on the command

The repo file (.bitc.toml at the top of a work tree) belongs to the project. It can add environment, hooks and refuse rules, and can only narrow what the host allows:

version = 1

[pools.heavy]
wait = "45m"                   # narrow only
env = { NODE_OPTIONS = "--max-old-space-size=8192" }

[pools.lint]
refuse = [{ tool = "tsc", reason = "typecheck runs in heavy" }]

bitc config check validates both. Every key, its class (host, repo, narrow) and its default is in docs/config-reference.md; worked examples are in examples/config/, examples/node-monorepo/ and examples/python-monorepo/. Concepts (pools, groups, tickets, nested holds, providers) are in docs/concepts.md.

Providers

A pool lists the providers it may use, in order, for example providers = ["runpod", "local"]. Remote jobs take no local slot, need the host to allow them, and share the same safety rails: a daily spend cap per provider account, a live-job limit, a ledger and a circuit breaker. Once a remote job has started it never falls back to another provider.

Provider Where the job runs State
local this machine, in a slot stable, built in
runpod a RunPod pod created for the job and deleted afterwards experimental: implemented and tested against a fake API; a live proof against the real service has not been run
sprites a fresh microVM (Fly Sprite) for every job, so many jobs run in parallel first-class scale-out provider, not enabled yet: the egress allow-list is not yet proven enforced and the WSS exec stream is not yet reliable. bitc does not refuse it yet, but do not configure it for real work until a release enables it: today a job would receive the forwarded environment and the deploy key
ssh a Linux machine you own, over ssh experimental: implemented and tested against fakes and, in maintainer-run tests, a real sshd; not yet proven on a live host. Host setup: docs/ssh-host.md
exec plugin anything, through an executable bitc-provider-<type> pinned by path and sha256 experimental: docs/writing-a-provider.md, docs/provider-author-guide.md

Remote providers leave resources that cost money if a job dies at the wrong moment, so run bitc sweep every 15 minutes from a timer (docs/sweep-timer.md) and check setup with bitc doctor --remote. docs/threat-model.md says what bitc defends against and what it does not.

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. Details and the stderr lines are in docs/exit-codes.md.

Comparison with alternatives

bitc flock GNU parallel / sem GitHub Actions concurrency
Where it works processes on one host (plus optional remote providers) processes on one host parallel: one invocation; sem: processes on one host jobs in one CI system
Counting semaphore (N slots) yes one lock per file; N needs N lock files yes (sem -j N) one running job per group
FIFO order, priority lanes yes no ordering guarantee parallel starts jobs in input order; sem does not guarantee FIFO; no priorities at most one pending run per group (GitLab resource_group and Buildkite concurrency groups differ)
Memory-aware admission yes (memory_floor) no --memfree in parallel no
Distinct "busy, retry" exit code 75 configurable with -E no not applicable
Per-slot environment yes ({slot}, BITC_SLOT) no job slot number via {%} / $PARALLEL_JOBSLOT no
Repo-supplied rules under host limits yes no no no
Remote execution with spend cap optional providers no parallel --sshlogin, no cap account-level spending limit, not per-pool
Install one static binary in util-linux Perl, GNU parallel built in

When not to use bitc:

  • You need one lock around a short critical section in a script. flock is simpler and already installed.
  • You are fanning a list of inputs out over cores in one command. Use parallel or xargs -P.
  • Your contention is between CI runs rather than processes on a machine. Use your CI system's concurrency controls.
  • You need Windows as the gate host, or macOS with memory admission or remote providers. bitc is Linux first; its macOS build runs local pools only.
  • You need a cluster scheduler with resource accounting across many machines. Use one.

FAQ

Is there a daemon or a server? No. Everything is files and flock(2) locks under the state directory, which must be on a local file system (not NFS).

Does exit 75 mean my command failed? No. It means the command did not get to run (or, for a remote job, that the infrastructure failed after it started; a remote job is not retried automatically). Run it again.

What happens when a caller is killed? The kernel drops its locks. The next caller reaps the tickets and slots it left behind.

Can a repository raise its own limits? No. A repo file can only narrow host limits; a host-only key in a repo file is an error (exit 78).

How does an agent wait for a job that outlasts its tool-call limit? Start it with bitc run --detach --name build ... and call bitc wait build repeatedly; wait returns 124 until the job ends. See docs/agent-guide.md.

Does it enforce a memory limit on my command? No. memory is an admission reservation.

Where is the full design? docs/spec.md. The machine-readable status format is docs/status.schema.json.

Status and roadmap

bitc is pre-1.0 and has not been tagged. Interfaces may still change before 1.0.

  • Stable in intent: the local gate (pools, slots, groups, priorities, memory admission, nested holds, detached jobs, status, sweep, doctor), the exit codes and the config schema.
  • Experimental / pre-release: every remote provider (see the table above): none has been proven live yet, and Sprites is not enabled yet (egress allow-list unproven, exec stream not yet reliable). The exec plugin protocol (docs/plugin-protocol.md) may also change.
  • Planned: a first tagged release, signed checksums, live proofs of the remote providers, and packages under the name bitc.

The changelog is CHANGELOG.md.

Contributing

Issues and pull requests are welcome. Start with CONTRIBUTING.md; it covers building, make ci, and the conformance register every behaviour must appear in. Please follow the Code of Conduct and report security problems privately as described in SECURITY.md.

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