AtlatestRepositoryapiary
1
# Apiary — AI Worker Instructions3
Apiary is an MCP server for Enclave-based agent coordination. Read this file before making changes.5
## Define ordering discipline7
Every Sigil library file in apiary follows this order inside `(begin ...)`:9
1. Type / struct definitions10
2. Constants11
3. Pure helpers (no upward references)12
4. Internal procedures (may call helpers)13
5. Public entry points14
6. Tool registration functions LAST (they reference everything above)16
Forward references from tool-registration functions to helpers defined later in the file have caused silent crashes in related Sigil work. With this discipline, those bugs cannot recur — the offending code wouldn't compile.18
## Trusted set filter20
Every bot applies the same channel-message filter:22
```23
trusted_set = {owner} ∪ {reports-to} ∪ {subordinates} ∪ {listened peers}25
IF sender ∈ trusted_set THEN26
IF message starts with "@<my-nick>: " → deliver as mention27
IF message starts with "@<other-nick>: " → ignore28
ELSE → deliver as broadcast29
ELSE30
ignore31
```33
A bot does NOT receive its own messages — apiary suppresses self-echo before MCP delivery.35
## Mention syntax37
Strict `@<nick>: <body>` in IRC. The `@` is mandatory and disambiguates from any colon use in bodies. Apiary adds the `@` automatically when an agent calls `send-channel mention: "<nick>"`. MCP-delivered messages do NOT use `@` — they use `<sender>: <body>` format because apiary controls that side end-to-end.39
## Build conventions41
- `sigil build apiary -c release --backend bytecode` for releases (the native backend currently breaks on a sigil-crypto ABI drift; bytecode-release is the workaround until that's fixed).42
- Always force-rebuild with `--force` when changing code that may be cached: `sigil build apiary -c release --backend bytecode --force`.43
- Confirm the build touched changed files: look for `COMPILE apiary/<file>.sgl` in the build output.45
## Testing47
Local smoke harness at `test/smoke.sh` boots a throwaway local enclave server, runs apiary against it, and exercises:48
- Bridge connect + reconnect presence49
- Trusted-set filtering (broadcast / mention to me / mention to other / non-trusted sender)50
- listen-peer / unlisten-peer mechanics51
- Group-based voicing52
- MCP sender-mention rewriting53
- Self-echo suppression54
- Tool registration completeness for both leader and worker modes56
Unit tests in `test/*.sgl` for individual module behavior.58
## License & Copyright60
BSD-3-Clause.