Skip to content
jedardenPublic

About

Task-coordination store for agent fleets — a dependency graph of beads in SQLite, one unblocked bead per request via an atomic single-transaction claim, and a git-tracked checkpoint for recovery. Rust.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

bead-rs

CI

bead-rs is a clean-room Rust task-coordination system for agent fleets. It keeps a dependency graph of work items ("beads") in SQLite, hands out exactly one unblocked bead per request through an atomic claim, and checkpoints the whole workspace to deterministic JSONL that Git can track.

The installed binary is named bead.

Six stages of the bead-rs lifecycle. Three beads are created; a blocks edge makes store wait on design; design and docs are ready while store is blocked; a worker claims design, which becomes in progress; closing design satisfies the edge and store becomes ready; every successful mutation publishes the checkpoint automatically, and the closing command is the idempotent check.

The animation plays twice and stops. If your system asks for reduced motion you get the static storyboard instead, which shows the same six stages.

Work items form a directed acyclic graph. The ready frontier is the set of beads with nothing left blocking them — open, unassigned, not manually blocked, and with every blocks edge already closed. Agents call bead claim, which selects from that frontier and assigns the bead in a single transaction, so concurrent claimants never receive the same bead. Closing a bead can expose its dependents, which advances the frontier.

Install

# One-line installer (recommended) — Linux x86_64 / aarch64
curl -fsSL https://github.com/jedarden/bead-rs/releases/latest/download/install.sh | bash
bead --version

# Any other platform, or the current main tip (requires Rust 1.85+)
cargo install --git https://github.com/jedarden/bead-rs --bin bead

# From a local clone
cargo install --path .

SQLite is bundled; there is no system dependency and no network access at runtime. The installer downloads the latest release — Linux x86_64 and aarch64 binaries only, so on macOS or anything else use the cargo install --git line, which builds from source wherever Rust runs. main can be ahead of the latest release; the quick start below is verified against both.

⚠️ Warning: cargo install bead installs a different, unrelated crate (an OCI container runtime). Use --bin bead or the one-liner above.

Build from source

Building from source needs Rust 1.85+ (edition 2024): cargo build --release --bin bead puts the binary at target/release/bead (/build/bead-rs/release/bead on fleet hosts that pin a per-repo cargo target directory). The full procedure — pinned-commit builds, byte-reproducibility, build artifacts, feature flags, and verifying a pinned build — is in BUILD_PROCEDURE.md.

Build artifacts

The fleet build hosts run a cargo wrapper (~/.local/bin/cargo) that enforces one cargo target directory per repository — CARGO_TARGET_DIR=/build/<repo>, where <repo> is the origin URL's basename (needle-d6b685b4). A --target-dir outside that directory is refused, and a foreign CARGO_TARGET_DIR is overridden. On such a host the binaries land at:

  • bead binary: /build/bead-rs/release/bead
  • Man page generator: /build/bead-rs/release/generate-man-pages

On a host without /build the wrapper leaves cargo's default in place, and the same binaries sit at target/release/bead and target/release/generate-man-pages relative to the repository root.

Verifying the build

After building, verify the installation:

# Hosts with /build (enforced per-repo target directory):
/build/bead-rs/release/bead --version
/build/bead-rs/release/bead capabilities

# Hosts without /build (cargo's default target directory):
target/release/bead --version
target/release/bead capabilities

Quick start

bead init --prefix demo

design=$(bead create --title "Design schema" --priority 1)
store=$(bead create --title "Implement store" --priority 2)
bead create --title "Write docs" --priority 3

# `store` cannot start until `design` is closed.
bead dep add "$store" "$design"

bead list --ready                       # design + docs; store is blocked
bead claim --assignee worker-1          # atomically takes the highest-priority ready bead
# closing a claimed bead needs its claim-epoch credential; the first claim of
# a fresh workspace is epoch 1 (`bead show "$design" --json` projects it)
bead close "$design" --reason "Schema agreed" --fencing-token 1
bead list --ready                       # store has now joined the frontier

bead sync flush-only                    # idempotent check; publishes nothing new

Terminal recording of the quick start: init, three beads, a dependency, the ready frontier, a claim, a close, and a checkpoint flush

That recording is the sequence above, run against the real binary — note that store is absent from the first list --ready because it is blocked, and present in the second because closing design satisfied its only edge.

bead why --id <ID> explains any bead's state: whether it is ready, what is blocking it, how it ranks for claiming, and which operations are currently legal.

State model

Two artifacts, with different jobs:

Path Role Committed
.beads/beads.db SQLite, authoritative live state No
.beads/checkpoint/ Deterministic JSONL checkpoint Yes

The checkpoint carries issues, the event history, provenance receipts, and the dependency and label graph. Every successful mutation publishes it automatically after its transaction commits, so it is never silently behind the database and a clone of the repository reproduces the current state. bead sync flush-only remains an explicit idempotent check — against a current checkpoint it publishes nothing and exits 0 — and --no-auto-flush or checkpoint.auto_flush: false in .beads/config.json suppresses automatic publication, leaving the checkpoint to be advanced by that explicit command.

Checkpoint layout (checkpoint-set-v2). Adaptive mode — the default — publishes the incremental set-v2 layout. The first set-v2 publication of an existing monolithic or sharded-v1 workspace is a one-time full rewrite of the checkpoint set, with cost proportional to store size; bead sync status reports the pending upgrade (current mode → target mode) before it happens. The rewrite is crash-safe: the set/ tree is written and verified before the pointer swap, and the old generation stays restorable via previous.json until the next publication reaps it.

Recovering a fresh clone, which arrives with a checkpoint but no database:

generation=$(jq -r .generation_id .beads/checkpoint/current.json)
bead restore --source .beads/checkpoint --generation "$generation" --actor "$USER"
bead doctor

bead restore verifies the named pointer, content-addressed root, sharded closure (when present), counts, event continuity, and graph before initializing or changing the target. It refuses a non-empty target unless --allow-non-empty is explicit, writes an actor-attributed provenance receipt, and reports the exact generation and record counts restored. Bare forensic.jsonl and checkpoint-archaeology views are not recovery sources. sync import-only remains the lower-level interchange/merge primitive, not the doctor-recommended disaster-recovery path.

Taking another machine's advancement, after git pull delivers a newer checkpoint over your live database:

bead sync status        # Relationship: remote-advanced
bead sync reconcile --actor "$USER"
bead sync status        # Relationship: aligned, ready to commit

remote-advanced is a store relationship, observed from the workspace artifacts alone: the pulled pointer verifies, stages, and carries this workspace's UUID, every live event appears in it with identical content, and the recorded state claims no more history than the database holds. bead sync reconcile merges that checkpoint through the same machinery as sync import-only --merge — one transaction, conflict detection, an actor-attributed merge receipt — and, under the automatic publication default, the post-commit chokepoint publishes the generation covering the merge. Nothing is reconciled blind: sync flush-only refuses to publish over a remote-advanced checkpoint (exit 4, naming reconcile) so the pulled advancement cannot be discarded, --dry-run previews the merge without mutating anything, and bead doctor reports the state with its remedy rather than as a failure. Every other checkpoint-ahead-of-live shape — a tampered root, a foreign store UUID, a live event the pulled checkpoint lacks or contradicts — stays a fail-closed covered-ahead-integrity-failure (exit 5) that names the failed qualifier; mutate only after reconciling, because a local change made while remote-advanced leaves exactly that divergence. The workflow is pull, reconcile, then work.

For read-only historical inspection, use checkpoint archaeology rather than importing a generation:

bead query --checkpoint .beads/checkpoint/previous.json --file open-work.json
bead sync diff .beads/checkpoint/previous.json .beads/checkpoint/current.json
bead sync bisect --checkpoint old/current.json --checkpoint new/current.json --file query.json

Each command verifies the retained pointer and its complete object closure before serving an ephemeral view. A monolithic root, sharded manifest, or set-v2 manifest is accepted only when current.json or previous.json selects it. Archaeology JSON is explicitly non-importable; it is useful evidence, never a recovery source.

bead doctor runs read-only integrity checks across store, backup, schema, dependencies, and comments; --repair performs only safe, non-speculative repairs, and --rehearse proves the recovery path by restoring into a throwaway workspace and comparing the result for semantic equivalence.

Output contracts

  • bead list --json emits one JSON array, including [] for an empty result. bead list --jsonl emits one object per line and no bytes for an empty result.
  • bead show ID --json and bead create --json each emit one issue object. Plain bead create prints only the new bead ID and a newline.
  • --json and --format json select byte-identical output wherever a command offers JSON results, including capabilities, schema, manifest, and sync status. query --json DOCUMENT is the inline query input; use query --format json or query --output-json for JSON results.
  • bead claim on an empty frontier is success, not failure: exit 0 with {}.
  • bead capabilities emits a machine-readable contract document for feature negotiation.

Exit codes are stable across every command:

Code Meaning
0 Success
1 Internal failure
2 CLI usage or validation error
3 Workspace, issue, or file not found
4 Conflict — invalid transition, revision guard, dependency cycle, single-claim refusal
5 Malformed input or integrity failure
6 Mutation committed; checkpoint publication failed — the command's own output was already printed, and bead sync flush-only publishes what is missing

Coordinating a fleet

Many agents claiming from one ready frontier, backed by SQLite and a checkpoint

  • Atomic claim. Selection and assignment share one transaction under the fifo-v1 policy (priority ASC, created_at ASC, id ASC). aging-v1, impact-v1, rotation-v1, and balanced-v1 are also available via --policy.
  • Leases. bead claim --lease-ttl SECONDS issues a lease with a monotonically increasing fencing token, so a crashed or partitioned worker cannot mutate work that has since been reassigned. Lease rows are retained per claim epoch; release and close leave the audit history intact, and a later leased claim appends a new row. The highest token is the latest epoch.
  • Single-claim guard. bead claim --single-claim refuses the claim when the assignee already holds an in_progress issue in the workspace, failing with exit 4 and reason code assignee_has_active_claim naming the blocking issue. Opt-in per call, like --lease-ttl; it bounds claim accumulation but does not detect stale claims — combine it with a lease TTL to bound how long an abandoned claim can persist.
  • Workspace-local resource locks. Declare keys with bead create --resource-key KEY or bead resource add ID --key KEY. A claim acquires all declared keys atomically; release, close, and lease expiry return them, and bead why --json reports resource_conflict when another issue holds a needed key. These are scheduling exclusions in one native workspace, never distributed locks or coordination between separate stores.
  • Revision guards. --if-revision N on update, release, close, and reopen gives optimistic concurrency control; a stale revision fails with exit 4 rather than silently losing an update.
  • Inspect without reserving. bead list --ready uses the same ordering as claim but takes nothing off the frontier.
  • Change feed. bead changes --since <CURSOR> lets a consumer catch up incrementally instead of rescanning.

Interoperability

bead-rs keeps a private native schema. Per ADR-002 it does not parse or transform another tool's checkpoint format:

  • native-v1 — full fidelity, the default; the only supported recovery format
  • needle-v1 — NEEDLE subprocess compatibility

bead compare --id <ID> --source <P> --target <P> reports which fields a given profile pair preserves, transforms, omits, or cannot represent, scoped to these two profiles. Moving existing work from another tracker is agent-guided rehydration, not import: an agent reads the source repository read-only and recreates work through public bead commands, producing a reconciliation report rather than a synthesized checkpoint. See interoperability notes and NEEDLE compatibility.

CLI conventions worth knowing

bead-rs is an independent implementation, not a drop-in replacement for any other task tracker. These conventions catch people out:

The binary is bead not the crate name bead-rs
create takes a flag bead create --title "Title", not a positional title
Ready work is a filter bead list --ready
flush-only is a subcommand bead sync flush-only, not bead sync --flush-only
Issue JSON transports list --json is an array, list --jsonl is a stream, and show --json and create --json are objects
Manual blocking bead list --blocked shows manually blocked open issues; --status blocked is an alias
Effective status JSON output includes manual_blocked (bool) and effective_status (shows "blocked" when manually blocked)

Documentation

  • bead --help for the command inventory; bead <COMMAND> --help for the full description, examples, and semantics of any command.
  • Man pages covering the whole command tree (45 pages, named bead.1, bead-create.1, bead-sync-flush-only.1, …) are generated with cargo run --bin generate-man-pages. See MAN_PAGES.md.
  • The 0.1 implementation plan defines the native schema, lifecycle, dependency, checkpoint, CLI, and verification design.
  • Post-0.1 candidates and rejected alternatives live in the ideas ledger.

Both animations are generated from committed sources, so they can be refreshed rather than redrawn:

# lifecycle animation (needs cairosvg + Pillow)
python3 docs/img/generate-lifecycle-animation.py

# terminal screencast (needs vhs, which needs ttyd + ffmpeg)
cargo install --path . && vhs docs/img/bead-workflow.tape

The screencast drives the real binary, so it cannot quietly disagree with the CLI: if behaviour changes, re-running the tape either shows the change or visibly fails.

The lifecycle animation is timed against the classical animation principles, used to carry meaning rather than decoration — the claim fires in 0.2s against 0.4–0.6s elsewhere because atomicity is the point, and closing design sends a ripple along the edge so that store turning ready reads as a consequence rather than a coincidence.

It also targets WCAG 2.1 AA. Every colour holding text clears 4.5:1 and every meaningful graphic clears 3:1, asserted at generation time so the palette cannot regress; state is never colour-only, since each bead carries a text tag; the animation plays a fixed number of times rather than looping forever; and a prefers-reduced-motion source serves the static storyboard instead. Emphasis is carried by scale and stroke weight rather than by dimming, because a dim deep enough to read as staging takes text below the contrast floor. The generator documents both mappings in full.

Every bead ... example printed in the help text is parsed by the real CLI in the test suite, so a documented invocation cannot drift from the interface it documents.

Project status

The core CLI is implemented and in use: workspace lifecycle, issue CRUD, labels, the dependency graph, atomic and leased claims, checkpoint flush and restore, diagnostics, the query language, the change feed, profiles, and migration. It has been exercised end to end by building a real multi-bead project through it.

Treat it as young software rather than settled: it is a 0.1, its history includes bugs that a green test suite did not catch, and it is worth running bead doctor and a hands-on smoke test of the path you care about before depending on it for anything critical.

Independence

bead-rs has an independent Git history and is implemented from the specifications committed to this repository. Clean-room contributors must follow AGENTS.md and PROVENANCE.md.

bead-rs is not affiliated with or endorsed by any other bead implementation.

License

Apache License 2.0. See LICENSE and NOTICE.


Part of jedarden.com · Read the write-up: jedarden.com/guides/workflow/#s07-atomic-claims

This GitHub repo is a read-only mirror of git.ardenone.com/jedarden/bead-rs — issues and PRs are welcome here either way.

About

Task-coordination store for agent fleets — a dependency graph of beads in SQLite, one unblocked bead per request via an atomic single-transaction claim, and a git-tracked checkpoint for recovery. Rust.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages