roster-engine
by skupriienko
README.md
# `roster-engine`
Multi-agent pipelines fail from conflicting writes, runaway token spend, and unguarded irreversible actions. **`roster-engine`** is a dependency-free Python library, with an optional pure-Rust worker, for deterministic roster governance, taxonomy routing, compute and bloat guards, dialectical arbitration, visual diffing, and host configuration exporting.
---
## Core Capabilities
- **Composable Registry (`RosterRegistry`)**: Typed CRUD for `AgentProfile`, `SkillSpec`, `RuleSpec`, and `PackageTarget` with immutable cloning (`clone_with_overrides`) and deterministic JSON persistence.
- **6-Scheme Taxonomy & Combinators (`TaxonomyEngine`)**: Set intersection/union/difference squad composition, BM25 prompt routing, LOC-weighted package packing (`>=2000` solo, `600..1999` paired, `<600` 4-packed), and Bernstein-disjoint wave scheduling.
- **Compute, Bloat & Readiness Guards**:
- `ScoutDownshiftGuard`: Downshifts scout/recon dispatches to `flash` tier, bounds fact sheets (`max_chars=2000`), and evaluates `PreToolUse` hook payloads.
- `ConductorBloatBreaker`: Blocks excessive direct reads in root orchestrators (`max_reads=4`) and parses provider quota JSON into `QuotaSnapshot` downshift signals (`used_pct >= 80.0`).
- `PreStageReadinessGate`: Verifies required binaries (`shutil.which`), local scripts/schemas, and HTTP(S) URLs before stage execution.
- **Dialectical Arbitration (`DialecticalArbiter`)**: Enforces `READ_ONLY`, `TWO_WAY_DOOR`, and `ONE_WAY_DOOR` reversibility gates with bounded round escalation (`AUTO_RESOLVED` vs `WAITING_HUMAN`).
- **Visual Regression Diffing (`visual_diff`)**: Pure-Python and Rust-accelerated RGBA buffer and binary P6 PPM comparison with bounded `VisualDiffReceipt` summaries (`<= 1500` chars) and shell-free Playwright capture (`run_playwright_pair`).
- **Multi-Host Exporters (`export_bundle`)**: Deterministic config generation for `antigravity`, `claude_code`, `codex`, `cursor`, and `json_bundle` with path-traversal confinement.
- **12-Tool Stdio MCP Server**: Built-in line-delimited JSON-RPC 2.0 server (`2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05`) requiring zero third-party packages.
---
## Six Taxonomy Grouping Schemes
`TaxonomyEngine.group_by(scheme)` organizes the active roster under six orthogonal views:
| Scheme | Grouped Entities | Bucket / Key Structure | Primary Use Case |
| :--- | :--- | :--- | :--- |
| `echelon` | `AgentProfile` | `Echelon` values (`conductor`, `architect`, `senior_builder`, `junior_patcher`, `scout_researcher`, `tdd_tester`, `skeptic_reviewer`, `dialectical_arbiter`, `visual_ui_reviewer`, `quartermaster`) | Command-chain auditing and role balance |
| `domain` | `AgentProfile`, `SkillSpec`, `RuleSpec` | Domain identifiers (e.g., `software_engineering`, `security_supply_chain`, `portfolio_ops`) | Cross-functional capability mapping |
| `stage` | `AgentProfile`, `SkillSpec`, `RuleSpec` | `PipelineStage` values (`stage_0_prep` through `stage_5_arbitrate_attest`) | Stage-by-stage execution readiness |
| `priority_risk` | `AgentProfile`, `RuleSpec`, `PackageTarget` | Composite `<PriorityTier>:<RiskDoor>` keys (e.g., `P0_CRITICAL:ONE_WAY_DOOR`) | Risk-tiered escalation & SLA triage |
| `package_topology` | `PackageTarget` | LOC weight buckets: `heavy_solo` (`>=2000`), `medium_paired` (`600..1999`), `light_quad` (`<600`) | Parallel repository wave sizing |
| `combinator_presets` | `SQUAD_PRESETS` | 7 named presets (`lean_coding_5`, `autonomous_overnight_goal`, `multi_repo_portfolio_wave`, `ui_frontend_visual_gate`, `deep_research_synthesis`, `security_red_blue_triad`, `venture_prototype_factory`) | Rapid pre-tuned squad instantiation |
---
## Installation
`roster-engine` requires **Python >= 3.10** and has **zero runtime dependencies**:
```bash
pip install -e .
```
Optional pure-Rust worker binary (`#![forbid(unsafe_code)]`, zero Cargo dependencies) for accelerated routing, wave conflict checking, and block-SSIM RGBA diffing:
```bash
cargo build --release --manifest-path rust/Cargo.toml
```
---
## CLI Quickstart (`roster-engine`)
Every subcommand supports `--json` for machine-readable output and `--registry <path.json>` for custom registries:
```bash
# 1. Inspect default roster and group by taxonomy scheme
roster-engine --json list --kind agents
roster-engine --json group echelon
# 2. Route a natural-language task prompt to top-K agents and skills
roster-engine --json route "security audit python subprocess" --top-k 3
# 3. Mutate a custom registry file (register / get / update / remove)
roster-engine --json --registry /tmp/roster.json mutate \
--action get --kind agent --id scout-codebase
# 4. Compose a squad from a preset or combinator filters
roster-engine --json squad --preset lean_coding_5
roster-engine --json squad --domain security_supply_chain --door READ_ONLY --tag-mode union
# 5. Plan Bernstein-disjoint task waves or LOC-weighted package waves
roster-engine --json waves --mode tasks \
--tasks-json '[{"id":"a","reads":["x.py"],"writes":["y.py"]},{"id":"b","reads":["z.py"],"writes":["w.py"]}]'
roster-engine --json waves --mode packages --max-parallel 4
# 6. Verify pre-stage dependencies
roster-engine --json readiness --binary python3 --url https://example.com
# 7. Evaluate runtime guards (pretooluse, scout_model, fact_sheet, bloat_breaker, quota)
roster-engine --json hook --guard scout_model --agent-type researcher --requested-model opus --file-count 12
roster-engine --json hook --guard bloat_breaker --tool-name read_file --direct-reads 6 --max-reads 4
roster-engine --json hook --guard quota --raw-json '{"provider":"anthropic","model":"sonnet","used_pct":84.0}'
# 8. Arbitrate proposals against risk-door policies
roster-engine --json arbitrate "Drop legacy table" --objection "Irreversible data loss" --door ONE_WAY_DOOR
# 9. Compare P6 PPM visual frames
roster-engine --json visual-diff before.ppm after.ppm --threshold 0.01
# 10. Export host configuration bundles
roster-engine --json export claude_code --output-dir /tmp/bundle
# 11. Run in-process latency benchmark
roster-engine --json benchmark --iterations 200
# 12. Start the 12-tool Stdio MCP server
roster-engine mcp
```
---
## Python SDK Quickstart
```python
from roster_engine import (
DialecticalArbiter,
RiskDoor,
ScoutDownshiftGuard,
TaxonomyEngine,
build_default_registry,
export_bundle,
)
registry = build_default_registry()
engine = TaxonomyEngine(registry)
# Route a task prompt to top agents/skills
matches = engine.route("supply chain audit and security review", top_k=3)
# Plan Bernstein-disjoint execution waves (no RAW/WAR/WAW hazards in a wave)
waves = engine.plan_waves([
{"id": "scan_auth", "reads": ["auth.py"], "writes": ["reports/auth.json"], "depends_on": []},
{"id": "scan_api", "reads": ["api.py"], "writes": ["reports/api.json"], "depends_on": []},
{"id": "merge", "reads": ["reports/auth.json", "reports/api.json"], "writes": ["summary.md"], "depends_on": ["scan_auth", "scan_api"]},
])
# Enforce scout model downshift and one-way-door arbitration
downshift = ScoutDownshiftGuard.enforce_scout_model("researcher", "deep_pro", file_count=15)
decision = DialecticalArbiter.arbitrate("Deploy schema migration", ["Needs downtime"], RiskDoor.ONE_WAY_DOOR)
# Render host configs in memory (or write to output_dir)
claude_files = export_bundle(registry, "claude_code")
```
---
## 12-Tool Stdio MCP Server
Launch `roster-engine mcp` (or `python -m roster_engine.cli mcp`) and configure any MCP client over stdio:
```json
{
"mcpServers": {
"roster-engine": {
"command": "roster-engine",
"args": ["mcp"]
}
}
}
```
Exposed MCP tools:
1. `roster_list`: List registered agents, skills, rules, and package targets.
2. `roster_group`: Group roster entities under any of the 6 taxonomy schemes.
3. `roster_route`: Rank top-K matching agents and skills for a natural-language prompt.
4. `roster_mutate`: Register, update, remove, or inspect an agent, skill, rule, or package.
5. `roster_compose_squad`: Compose a squad from a preset or combinator filters (`domains`, `stages`, `echelons`, `max_cost_tier`, `door`, `tags`, `exclude_tags`, `tag_mode`).
6. `roster_plan_waves`: Schedule Bernstein-disjoint `tasks` waves or LOC-weighted `packages` waves.
7. `roster_check_readiness`: Verify required binaries, scripts, schemas, and URLs before a stage.
8. `roster_guard_hook`: Evaluate `pretooluse`, `scout_model`, `fact_sheet`, `bloat_breaker`, or `quota` guards.
9. `roster_arbitrate`: Arbitrate a proposal against objections using `RiskDoor` reversibility policies.
10. `roster_visual_diff`: Compare two P6 binary PPM frames against a pixel-diff ratio threshold.
11. `roster_export_host`: Export config bundles for `antigravity`, `claude_code`, `codex`, `cursor`, or `json_bundle`.
12. `roster_benchmark`: Measure in-process latency across routing, wave planning, and arbitration.
---
## When NOT to Use
Do **not** adopt `roster-engine` if your workload falls into any of these categories:
- **Single-agent scripts or linear prompt chains**: If one model call or sequential script solves the task without parallel subagents, taxonomies, risk gates, or host exports add unnecessary ceremony.
- **Distributed multi-node job scheduling**: `roster-engine` is a single-process deterministic governance and planning engine; it does not provide distributed locks, message queues, worker heartbeats, or container orchestration (use Temporal, Celery, Ray, or Kubernetes for distributed execution).
- **Semantic vector search or LLM-as-judge routing**: `TaxonomyEngine.route` uses deterministic lexical BM25 (`k1=1.5, b=0.75`) over registered metadata rather than dense embeddings or neural rerankers; if routing requires deep semantic paraphrase matching across unindexed prose, pair with an embedding retriever.
- **Compressed image formats (`PNG`, `JPEG`, `WebP`) in pure stdlib**: `visual_diff` intentionally supports raw RGBA buffers and binary P6 PPM without external imaging dependencies; raster decoding of PNG/JPEG requires an external tool (such as Playwright or ImageMagick) to convert to PPM/RGBA first.
- **Concurrent multi-writer database persistence**: `RosterRegistry` persists to local JSON files; high-concurrency multi-tenant state belongs in an ACID database.
---
## Documentation & Examples
- [Skill Guide (`SKILL.md`)](https://github.com/skupriienko/roster-engine/blob/main/SKILL.md): Agent triggers, safety gates, and operational workflow.
- [Specification and Limitations](https://github.com/skupriienko/roster-engine/blob/main/docs/SPECIFICATION_AND_LIMITATIONS.md): Normative data model, invariants, wire protocol, and limits.
- [Architecture & Rationale](https://github.com/skupriienko/roster-engine/blob/main/docs/ARCHITECTURE_AND_RATIONALE.md): Five-layer engineering rationale from CS fundamentals to edge cases.
- [Usage & Examples Guide](https://github.com/skupriienko/roster-engine/blob/main/docs/USAGE_AND_EXAMPLES.md): Detailed Python SDK, CLI, and MCP reference.
- [Runnable Examples](https://github.com/skupriienko/roster-engine/blob/main/examples/README.md): Standalone scripts covering quickstart, end-to-end pipelines, and edge-case benchmarks.
- [Changelog](https://github.com/skupriienko/roster-engine/blob/main/CHANGELOG.md): Release history and added capabilities.
## License
Apache-2.0 (see [LICENSE](https://github.com/skupriienko/roster-engine/blob/main/LICENSE) and [NOTICE](https://github.com/skupriienko/roster-engine/blob/main/NOTICE)).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues