feat(server): wire collection.* and rpc.examplesPath in JSON-RPC dispatch #48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_mik"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes the dispatcher-vs-schema gap surfaced during session 85's hero_slides#47 validation.
Bug
The OpenRPC schema (
openrpc.json), generated client, and JS dashboard all referencedcollection.list/get/register/unregister/rescanandrpc.examplesPath, butcrates/hero_slides_server/src/rpc.rs'smatch req.method.as_str()had no arms for them. Result: every collection-CRUD entry point in the UI ("Open Example Deck", "+ New Collection", Rescan, Unregister) silently no-op'd because the JS catch swallowed the-32000 Method not founderror.Fix
Added six handlers wired to the existing
state.registry(CollectionRegistry) plus thehero_slides_lib::scan_collection/deck_infohelpers:rpc.examplesPathHERO_SLIDES_EXAMPLES_DIRenv var, then aCARGO_MANIFEST_DIR-relative fallback.collection.listwarningwhen scan fails.collection.getdecks: [DeckSummary].collection.registerregistry.register_collection, returns resulting deck list.collection.unregisterregistry.unregister_collection, returns{ removed: bool }.collection.rescanVerification
Full stack-up validated locally: proc → router → db → mycelium → aibroker → slides.
collection.*methods + negative case smoke clean via curl onrpc.sock.http://127.0.0.1:9988/hero_slides/admin:hero_slides_examplesregistered with 2 decks (hero_slides_intro+sample_deck), navigation to deck route works, all dashboard counters update (Decks 2, Slides Total 12 / Generated 6 / Pending 6), console 0 messages.No schema changes, no breaking changes — wires up methods the schema already declared.
Refs:
The OpenRPC schema (openrpc.json), generated client (openrpc.client.generated.rs), and JS dashboard all referenced collection.list / collection.get / collection.register / collection.unregister / collection.rescan and rpc.examplesPath, but the dispatcher in rpc.rs had no match arms for them. Result: every collection-CRUD entry point in the UI ("Open Example Deck", "+ New Collection", Rescan, Unregister) silently no-op'd because the JS catch swallowed the -32000 "Method not found" error. Adds: - rpc.examplesPath — returns the bundled examples directory. Resolves via HERO_SLIDES_EXAMPLES_DIR env var (operator override) then a CARGO_MANIFEST_DIR-relative path. - collection.list — returns name + root + registered_at (epoch seconds, parsed from the registry's RFC3339) + deck_count, with a per-collection `warning` field when scan fails. - collection.get — same shape plus the full DeckSummary list. - collection.register — wraps registry.register_collection and returns the resulting deck list. - collection.unregister — wraps registry.unregister_collection, returns { removed: bool }. - collection.rescan — looks up the registered root and re-scans, no registry write. Verified end-to-end on the local stack: service_proc → service_router → service_db → service_mycelium → service_aibroker → service_slides Hero Browser MCP smoke against http://127.0.0.1:9988/hero_slides/admin (Open Example Deck → Collections counter 0→1, hero_slides_examples appears with 2 decks, console clean, all five collection.* methods return correct shapes). Refs: - #47 Signed-off-by: mik-tf