0002 — Working rules inside relaybay¶
- Status: 1.5a Implemented in v0.1.0 (behaviour in SPEC §6 and SPEC §3); 1.5b–c Implemented for 0.4.0 (SPEC §6, prompts).
- Size: 1.5a ~1–1.5 agent-days (done); 1.5b ~1.5; 1.5c ~1.5–2.
Goal¶
The rules for how agents (and people) work with tasks live in relaybay itself: any client gets them from the server, the server checks them, and they can be changed through MCP, instead of living only in each user's private agent setup.
Shipped in 1.5a¶
- The MCP
instructionsare the working contract (snapshot first, pick or create a task, keep next step / waiting on / progress current,state · size · gistreports,waiting_onfor decisions,task_patchfor missing fields, fixWarning (rules)lines). - Rules as structured JSON with a fixed set of keys (
report_format,stage_requirementswith kindsreport_since_stage_changeandfield_present,description_template,guidance). - Layers: defaults ⊕
[rules]inconfig.toml⊕project_rulesrow (migration0006, set by hand). Chosen over a separaterules.json: one config file. - A content hash stands in for version numbers;
project_snapshotstarts with the rules line. - Checks on stage moves only,
warn(default) andstrictmodes.
1.5b — versioning and changing rules¶
Model. rule_set (scope global or a project) and rule_version (number, body JSON, rendered
markdown, author session, reason, created_at, diff to the previous version). rule_proposal
(scope, patch, reason, author, status open / accepted / rejected).
API.
rules_update(scope, patch, reason): a new version; allowed directly only for coordinator sessions named in config (coordinators = ["…"], matched by desktop id, alias or name). Everyone else gets an error pointing torules_propose. With no coordinator configured every change is a proposal.rules_propose(scope, patch, reason): stored as a proposal for the owner.project_snapshotstarts with "Rules vN (global vG, project vP)"; when the version an agent last saw is older, tool responses add one line: "rules updated to vN — re-read relaybay://rules".report_addformat checks and therequire_tracker_log→donerule.
1.5c — Settings → Rules and prompts¶
UI. Settings → Rules: current version, history with author, reason and diff, Accept / Reject for proposals (they also appear in the Inbox, see 0004), "Roll back to vK" (creates a new version equal to vK).
MCP prompts. start_task and finish_stage (arguments: project, task) expand to the current
rules plus a checklist. Claude Code lists MCP prompts as slash commands
(/mcp__relaybay__start_task); to verify on the current client version before relying on it.
As built (1.5b–c)¶
Rules vNis the sum of the global and project version numbers, so it grows with a change of either; a project without its own rules isproject v0.project_rulesstays the row a project's rules are read from; a new version writes through to it. A hand edit applies at once and becomes a version at the next start.config.toml: the server remembers the hash of the raw[rules]table it last turned into a version (not merged with the defaults, so a release never replaces accepted rules). An unchanged table leaves accepted versions in force; a changed one wins with a new version byconfig. Comparing with the current version instead would have undone every accepted proposal on restart.- A broken version never stops the server: the newest valid one is in force, the error is shown in
Settings → Rules. Sets are found by project id;
project:globalreaches a project calledglobal. coordinatorsis a guard against mistakes, not access control (one shared token). Alocal_…entry needs the session's exact hook id from an earlier write; a direct update is a notice in the Inbox.- With no coordinator configured
rules_updaterefuses and points torules_propose(it does not store a proposal by itself), like for any non-coordinator. - Patches merge like
policy_propose, withnullremoving a key. rules_modeandrequire_tracker_logstay config keys outside the versioned document;require_tracker_logis also a requirement kind usable per scope.- Author of an accepted version:
<proposer>, accepted by <owner>. - The report structure is checked only for the standard
first_line. - Prompts checked with the MCP Python SDK client; Claude Code's listing is not verified.
Risks¶
| Risk | Mitigation |
|---|---|
| Agents ignore the rules | Warnings in every response, strict mode, the contract in the instructions |
| Rule churn confuses long-running sessions | Version line in the snapshot and a one-line "rules updated" hint |
| A non-coordinator rewrites the rules | Direct updates only for configured coordinators; proposals otherwise |