refactor(server): make group the source of truth in ResourceManager - #3569
Conversation
Introduce internal/group as the source of truth for a named collection of tools and prompts. Group.Initialize reuses the toolset/promptset Initialize logic; ToToolset/ToPromptset project the legacy views keyed by the group name. No existing behavior changes yet.
Embed the initialized Toolset and Promptset in Group instead of flattening their fields, so ToToolset/ToPromptset return the views with their lookup sets intact rather than rebuilding them per call.
Replace the toolset/promptset maps with an authoritative groups map and derive the toolset/promptset views from it via ToToolset/ToPromptset. Legacy kind: toolsets configs convert to tools-only groups at init, and the default nameless group holds all tools and prompts. No YAML surface change; kind: groups parsing is deferred to a follow-up.
There was a problem hiding this comment.
Code Review
This pull request refactors the codebase to replace the separate legacy toolsets and promptsets configurations with a unified groups concept. The ResourceManager now stores a groups map as the source of truth, from which toolset and promptset views are dynamically derived. Consequently, configuration structures, initialization functions (such as InitializeConfigs and InitializeOfflineConfigs), and numerous unit and integration tests across the server and command-line packages have been updated to use groups. There are no review comments to address.
Decouple Group from the legacy tools.Toolset/prompts.Promptset types per review feedback. Group now keeps its own O(1) tool/prompt membership sets and exposes ContainsTool/ContainsPrompt directly, instead of deriving and storing full toolset/promptset views. Per-tool and per-prompt manifests are generated on demand by callers from the resolved tools/prompts maps, so the group no longer needs serverVersion at Initialize.
…ring # Conflicts: # internal/group/group.go
Thank you for pointing this out. Currently I'm merging all the groups feat PRs into #3605. It will help us resolve any merge conflicts while also landing the complete feature in main at once. I will take care of any merge conflicts before merging the master PR: #3605 |
…3575) ## Description Adds parsing for `kind: group` configuration documents and wires the parsed groups through initialization. Groups are the source of truth from which toolset and promptset views are derived; this PR lets users declare them directly in config. - `UnmarshalResourceConfig` now parses both flat (`kind: group`) and nested (`groups:`) formats, returning a new `GroupConfigs` value. - Validation: rejects duplicate default (nameless) or named groups, and rejects a default group that declares `tools` or `prompts` (it always contains all configured tools and prompts). - `GroupConfigs` flows through config merge, dynamic reload, and `initializeGroups`; a `kind: group` definition overrides a same-named toolset (with a warning). - Mechanically updated all `UnmarshalResourceConfig` call sites for the new return arity. Stacked on #3569 --------- Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
|
🧨 Preview deployments removed. Cloudflare Pages environments for |
Description
Makes
internal/groupthe source of truth inResourceManagerand derives thetools.Toolset/prompts.Promptsetviews from it.Stacked on #3488