Use this repository as a template to create your own swarm of judges for Zerocracy.
A judge is a Ruby script that processes facts stored in a
Factbase (.fb file).
Each judge reads existing facts via S-expression queries and creates new facts
based on business rules. Judges run in cycles until no new facts are produced.
judges/<name>/<name>.rb — judge implementation, auto-discovered
judges/<name>/<name>.yml — YAML test for the judge (data-driven)
lib/ — shared Ruby libraries
test/test_*.rb — Minitest unit tests
entry.sh — Docker entry point
You will need Ruby 3.4+ and Bundler installed.
bundle install
bundle exec rake- Create a directory for your judge:
mkdir judges/hello-world- Write the judge logic in
judges/hello-world/hello-world.rb:
# frozen_string_literal: true
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 Zerocracy
# SPDX-License-Identifier: MIT
require 'fbe/fb'
Fbe.fb.query('(and (exists hi) (absent hello))').each do |f|
f.hello = say('Hello, {name}!')
end- Write a YAML test in
judges/hello-world/hello-world.yml:
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 Zerocracy
# SPDX-License-Identifier: MIT
---
runs: 2
input:
-
_id: 1
what: something-else
when: 2024-05-12T23:54:24Z
hi: 'How are you?'
expected:
- /fb[count(f)=1]
- /fb/f[_id=1]/hello- Run the judge YAML tests:
bundle exec judges test --no-log --disable live --lib lib judges- Run the full build:
bundle exec rakeIf everything is clean, your judge is ready.
| Command | Purpose |
|---|---|
bundle exec rake |
Full build (test + judges + rubocop) |
bundle exec rake test |
Ruby unit tests only |
bundle exec judges test --no-log --disable live --lib lib judges |
Judge YAML tests |
bundle exec rubocop |
Code style check |
docker build -t swarm . |
Build Docker image (requires Dockerfile) |
Read these guidelines. Make sure your build is green before you submit your pull request.