feat(skills,tools): schema↔serde roundtrip tests, triggers field, bus subscriber, registry integrity
Summary
Four independent, focused improvements that collectively close the parameters_schema()↔serde alignment gap and bring the skills event-trigger pipeline from stub to working.
1. Schedule serde roundtrip tests (tools/impl/cron/add.rs)
The CronAddTool deserializes its schedule argument with serde_json::from_value::<Schedule>. No test previously verified that the JSON shapes documented in parameters_schema() actually deserialize correctly — the same class of silent mismatch that caused issue #2252 (window_days).
Added 7 tests:
- Each
Schedulevariant (Cron,At,Every) deserializes from the schema-documented shape - Optional
tzfield round-trips correctly - Missing
kindfails with a clear error - Unknown
kindvalue fails with a clear error - Schema
requiredarray containsnameandschedule
2. triggers: field in SkillFrontmatter (skills/ops_types.rs)
Added pub triggers: Vec<String> between allowed_tools and extra. Each entry is a trigger pattern of the form "domain" or "domain/event_slug" (e.g. "composio", "cron", "channel/inbound_message"). A bare domain (no slash) matches any event in that domain. Fully documented with cross-references to skills::bus.
3. Full TriggeredSkillSubscriber implementation (skills/bus.rs)
Replaced the 17-line no-op stub with a complete implementation:
TriggerPattern— parses"domain"or"domain/event_slug"strings; normalises to lowercase;"domain/*"treated as bare domainTriggeredSkillIndex— built from&[Skill]at startup;matching_skills(&event)returns names of skills whose patterns match; entries sorted for deterministic loggingTriggeredSkillSubscriber—EventHandlerimpl that logs matched skills on eachDomainEvent; activation handoff left to the integration layer (no harness context needed here)register_triggered_skill_subscriber()— public API, returnsNonewhen no skills declare triggersregister_skill_cleanup_subscriber()— kept as a safe no-op for call-site backward compat
Includes 20+ unit tests covering parse edge cases, domain matching, index build/sort/dedup, and the matching logic.
4. Tool registry integrity test (tool_registry/ops.rs)
Added all_registry_entries_have_non_empty_name_and_description — asserts every entry produced by registry_entries() has a non-blank name and description. Catches silent metadata gaps (e.g. an MCP tool with an empty description) before they reach the LLM tool surface.
Testing
cargo check # clean (only pre-existing warnings in slack_backfill.rs)
cargo fmt # no diff
All new tests are in-module #[cfg(test)] blocks and run with cargo test.
🤖 Generated with Claude Code
Summary by CodeRabbit
-
New Features
- Skills can declare domain-based trigger patterns (domain or domain/event) to be matched against incoming events; the system builds a deterministic index and logs matched skills when events occur.
- Missing trigger declarations are treated as empty (no triggers).
-
Tests & Validation
- Added validation ensuring registry entries have non-empty names/descriptions.
- Expanded tests for cron schedule parameter parsing and schema requirements.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cdbd4967-14d0-4775-9b00-ab1d40a8412c
📥 Commits
Reviewing files that changed from the base of the PR and between de00aa288dbccb94ffa652a49008624fcc10cf27 and e920e5f54cc3a107e9a1a2b2c9eaf8fd88d861a1.
📒 Files selected for processing (2)
src/openhuman/skills/bus.rssrc/openhuman/tools/impl/cron/add.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- src/openhuman/skills/bus.rs
- src/openhuman/tools/impl/cron/add.rs
📝 Walkthrough
Walkthrough
Adds a triggers field to skill frontmatter, implements TriggerPattern parsing/matching and a deterministic TriggeredSkillIndex, registers a global event subscriber that logs matched skills per domain event, and adds unit tests plus registry and cron schema validation tests.
Changes
Triggered Skills Event Bus & Quality Improvements
| Layer / File(s) | Summary |
|---|---|
Skill trigger data model src/openhuman/skills/ops_types.rs |
SkillFrontmatter gains triggers: Vec<String> field with #[serde(default)], documented to accept domain or domain/slug patterns. |
Module docs and imports src/openhuman/skills/bus.rs |
Module-level docs and imports for the triggered-skill subscriber and supporting types. |
Trigger pattern parsing and matching src/openhuman/skills/bus.rs |
TriggerPattern parses and normalizes trigger strings into lowercase domain and optional slug, treats empty/* slug as domain-only, and exposes matches() (currently matches by domain only). |
Triggered skill indexing src/openhuman/skills/bus.rs |
TriggeredSkillIndex builds a sorted, deterministic index from skill triggers, exposes unique domains and matching skill-name queries for DomainEvent. |
Event handler and registration API src/openhuman/skills/bus.rs |
TriggeredSkillSubscriber implements EventHandler to compute matched skills and emit debug logs; register_triggered_skill_subscriber() builds the index, returns None when empty, logs metadata, and registers a global subscriber; register_skill_cleanup_subscriber() remains a safe no-op. |
TriggerPattern tests src/openhuman/skills/bus.rs |
Unit tests covering parsing normalization, wildcard/domain-only semantics, and slug-qualified pattern behavior. |
TriggeredSkillIndex tests src/openhuman/skills/bus.rs |
Tests for index building: skipping skills with no triggers, deterministic name sorting, unique sorted domains, and matching results across multiple skills/events. |
Register cleanup test src/openhuman/skills/bus.rs |
Test confirming repeated calls to register_skill_cleanup_subscriber() are side-effect-free. |
Tool registry name and description validation src/openhuman/tool_registry/ops.rs |
New test ensures each registry entry has a non-empty name and description after trimming. |
Cron tool schema and deserialization validation src/openhuman/tools/impl/cron/add.rs |
Tests that Schedule deserializes from schema-documented JSON shapes, rejects missing/unknown kind, and that the tool schema requires name and schedule. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Suggested labels
working
🐰 A skills bus comes to town,
Triggers parsed both up and down,
Domains sorted, matches logged bright,
Tests hop in to check the light,
Hooray, the rabbits code tonight! 🐇✨
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately and specifically summarizes the PR's main changes: schema-serde roundtrip tests, triggers field addition, bus subscriber implementation, and registry integrity testing. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
@zahica1234 unresolved review feedback — please address before we review.
Unresolved review feedback from coderabbitai[bot] — please address before we review.