Standards Mapping
This codebase is reviewed against the Bot Framework Engineering Standards. Its v1 scope is sections 1–8, 12, 13 (logging), 15, 21 (core), 22, 23, 31, 32, 34 and 35. This page maps those items to the code honestly: done, or deferred with the reason.
v1 items: done
| Standard | Where it lives |
|---|---|
| §1 Type safety | Dataclass models (rootbot.core.models) at every user-facing boundary; type hints across rootbot/; mypy strict-ish passes clean in CI. |
| §2 Design principles | Small single-purpose modules, no comments, readable-first code; the core depends only on the standard library. |
| §3 Architecture | Adapter isolation: all Root wire knowledge is in wire.py + client.py; the core (bot.py) never touches protobuf. |
| §4 Modularity | Commands, events, hooks and middleware are the extension points; examples prove the core is bot-agnostic (echo, mod, music). |
| §5 API design | One obvious way to do each thing: Bot, @bot.command, Context, RootApi. Models double as dicts during migration. |
| §6 Events & commands | Decorator registration, typed Context, argument converters (duration/int/float/bool/str), configurable prefix, aliases, per-user cooldowns, owner-only commands, auto-generated help from command metadata. |
| §7 Async | Single asyncio loop; blocking API calls are the client's concern; handlers are coroutines; the loop isolates handler failures. |
| §8 Error handling | RootBotError hierarchy; handler/command error isolation (a raising handler is logged and optionally answered, never fatal); bounded client retries with exponential backoff + jitter on transient failures; explicit 30 s request timeouts. |
| §12 Configuration | Env / .env / JSON layering in rootbot.config, validated up front, clear missing-token error with a hint. |
| §13 Logging | Stdlib logging via rootbot.logging; a redaction filter strips Bearer tokens and registered secrets from every record. |
| §15 Code quality | ruff (format + lint) and mypy configured in pyproject.toml and enforced by .github/workflows/ci.yml on every push. |
| §17 API reference | The full per-symbol API Reference is published. The standard tags the full reference set [Later]; the API reference was pulled forward from [Later] and delivered now. |
| §21 Networking (core) | Timeouts explicit, retries bounded, failures mapped to typed errors; unknown payload fields never crash parsing (tested). |
| §22 Middleware | bot.use(...) pipeline composing in registration order around dispatch; logging and rate-limit middleware included. |
| §23 Lifecycle | run() / start() / stop(), on_ready / on_shutdown events, graceful KeyboardInterrupt handling; systemd Restart=on-failure in deployment. |
| §31 Entities & cache | User / Channel / Community / Member / Role / Message models; bounded LRU EntityCache filled by discovery and dispatch, with API fallback lookup (fetch_channel). |
| §31 Outbound safety | Plain text only, the framework never generates mention markup; long replies split at a configurable limit (default 2000). |
| §32 Acceptance | Two stubbed suites, 232 checks, all green; quality gates in CI. |
| §34 Philosophy | Followed as written, including #21 (undocumented platform behaviour isolated in the adapter, surprises tolerated) and #22 (readable, straightforward code first). |
| §35 Definition of done | Applied per change: types, validation, tests, gates, docs, self-review. |
v1 items: deferred, with reasons
| Item | Status |
|---|---|
| Wait-for / conversation flows (§31 interaction management) | Deferred to Phase 3 of the standard's own roadmap; the music bot's search picker is a hand-rolled special case, not a framework flow engine. |
| Per-community prefix and settings (§31, marked [Later] in the standard) | Deferred, prefix is per-bot config in v1; no bot has needed per-community settings yet. |
| Plugin system (§33 Phase 3 / Milestone 2) | Deferred, examples + middleware are the extension story for v1. |
| Circuit breakers, dead-letter handling (§21 [Later] parts) | Deferred, bounded retries cover the observed failure modes; no evidence yet that more machinery is needed. |
| Option/Result types and exhaustive matching (§1, from the Rust-flavoured parts of the standard) | Not adopted, not idiomatic Python; typed exceptions (APIError hierarchy) carry the same information. |
| Record/replay payload fixtures (§37 defence, full version) | Partially landed: opt-in raw-payload debug logging (ROOTBOT_LOG_PAYLOADS=1) exists; a recorded-fixture replay suite is deferred until a Root update actually breaks field mapping. |
| Raw payload log as a default | Deliberately opt-in only, payloads can carry message content; logging them by default would be a privacy footgun. |
Section 37: risks, answered by recon
The standard's open questions were settled empirically while building the adapter:
- Authentication. A normal user account's Bearer token, captured once from the real client (grpc-web to
api.rootapp.com, no certificate pinning). There is no official bot token. - Token lifetime. Unknown, observed working for many hours; expiry shows up as poll
AuthErrors, and the fix is a ~2 minute recapture. Plan for recapture, not refresh. - Transport. No gateway or push channel exists for chat: the bot polls
MessageGrpcService/List(~2 s cadence) and diffs voice presence viaWebRtcGrpcService/List. Events are therefore polling-based and best-effort. - Rate limits. Undocumented. The one known validator: List's
limitmust be 10–50. The polling cadence is kept conservative (2 s, 20 messages per container per poll). - Message limits. Maximum length is undocumented; the framework splits at a configurable 2000 chars by default. A user account cannot send embeds or mention markup, plain text only.
- API stability. Root is pre-1.0 (client 0.9.167 at mapping time). Defence in depth: adapter isolation, unknown-field tolerance (tested), typed errors, and opt-in payload logging for re-mapping.
- Hosting. A VPS with systemd (
Restart=on-failure) plus the Lavalink sidecar for the music example; see the deployment guide. - Terms of service. Root's Terms of Use do not permit reverse engineering (Section 2.2) or automated use (Section 2.5) of the Service. The discipline this forces: the bot account is a throwaway alt with nothing paid attached, never a main account. Ban risk is real and accepted knowingly.