Skip to content

Commit 62d908a

Browse files
JAORMXclaude
andcommitted
Address PR feedback on RFC THV-0032
- Add note clarifying operator independence is out of scope (RunConfig format stability would need separate consideration) - Add future sharing opportunities: pkg/oauth refactoring, pkg/networking patterns (HTTP builder, endpoint validation) - Add guiding principle about packages being genuinely reusable - Add pkg/recovery to Tier 1 immediate graduation candidates - Add auth/metadata to Tier 2 for protected resource metadata extraction - Add registry/types, container/verifier, and cache to Tier 3 - Add cache consolidation opportunity note Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent cb55ce2 commit 62d908a

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

rfcs/THV-0032-toolhive-core-shared-library.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- **Status**: Draft
44
- **Author(s)**: Juan Antonio Osorio (@JAORMX)
55
- **Created**: 2026-01-29
6-
- **Last Updated**: 2026-01-29
6+
- **Last Updated**: 2026-01-30
77
- **Target Repository**: multiple (new repository: `toolhive-core`)
88
- **Related Issues**: N/A
99

@@ -19,6 +19,8 @@ The ToolHive ecosystem spans multiple Go repositories:
1919
- **toolhive-registry-server** - Registry API server
2020
- **dockyard** - Container packaging for MCP servers
2121

22+
> **Note**: This RFC focuses on shared library extraction. While a stable core library could eventually enable components like the operator to be versioned independently, that would require additional considerations (e.g., RunConfig format stability, API versioning) beyond the scope of this proposal.
23+
2224
Additionally, TypeScript projects exist (toolhive-studio, toolhive-cloud-ui) but are out of scope for a Go shared library.
2325

2426
**Current state of code sharing:**
@@ -29,6 +31,8 @@ Additionally, TypeScript projects exist (toolhive-studio, toolhive-cloud-ui) but
2931
| **toolhive-registry** | `pkg/logger`, `pkg/permissions`, `pkg/registry/*`, `pkg/container/verifier` | Aligned - heavily uses toolhive utilities |
3032
| **toolhive-registry-server** | Only `pkg/versions` + `pkg/registry` types | Uses stdlib `log/slog` instead of toolhive's zap logger; custom error handling |
3133

34+
> **Future sharing opportunities**: Beyond the packages listed above, `pkg/auth` contains OAuth-related utilities (protected resource metadata, auth middleware) that could be refactored into a standalone `pkg/oauth` package. Similarly, `pkg/networking` has HTTP builder patterns and endpoint validation utilities that could benefit multiple projects.
35+
3236
**Current limitations:**
3337

3438
1. **No stability guarantees**: Projects like dockyard import toolhive's `pkg/` packages directly, but these are internal packages with no API stability commitment. A breaking change in toolhive could break dockyard unexpectedly.
@@ -93,6 +97,8 @@ flowchart TB
9397

9498
### Package Graduation Criteria
9599

100+
**Guiding Principle**: Packages graduating to `toolhive-core` must provide genuinely reusable value and be designed as reusable from the start. This means they should not be tied to the inner workings of toolhive in either their API surface or internal logic. A package that requires knowledge of toolhive internals to use correctly is not a good candidate for graduation.
101+
96102
Packages can graduate via two tracks depending on complexity:
97103

98104
#### Fast Track (Simple Packages)
@@ -178,6 +184,7 @@ These packages meet all graduation criteria (zero ToolHive-specific coupling, we
178184
| **permissions** | `pkg/permissions/` | Beta | Container permission profiles, stdlib-only, security validations |
179185
| **validation** | `pkg/validation/` | Beta | RFC 7230 HTTP header validation, security-focused |
180186
| **versions** | `pkg/versions/` | Beta | Build metadata, User-Agent generation |
187+
| **recovery** | `pkg/recovery/` | Beta | Panic recovery middleware, zero deps |
181188

182189
> **Note**: All packages start as Beta in v0.x releases. Once the library reaches v1.0.0, packages meeting all graduation criteria will be promoted to Stable.
183190
@@ -190,6 +197,7 @@ These packages have solid implementations but need minor changes to remove ToolH
190197
| **healthcheck** | `pkg/healthcheck/` | Beta | Remove unused logger import |
191198
| **logger** | `pkg/logger/` | Beta | Remove `viper.GetBool("debug")` coupling; accept config via parameters |
192199
| **auth/tokenexchange** | `pkg/auth/tokenexchange/` | Beta | Split core RFC 8693 logic from ToolHive middleware |
200+
| **auth/metadata** | `pkg/auth/` (to extract) | Beta | Refactor protected resource metadata into standalone package for reuse |
193201
| **networking** | `pkg/networking/` | Beta | Replace ToolHive logger with slog or interface |
194202
| **lockfile** | `pkg/lockfile/` | Beta | Accept logger interface instead of importing pkg/logger |
195203

@@ -203,6 +211,16 @@ These packages have useful components but require significant refactoring or are
203211
| **secrets** | `pkg/secrets/` | Beta | Multiple providers, needs interface review |
204212
| **transport/types** | `pkg/transport/types/` | Beta | Middleware abstraction, widely used but coupled |
205213
| **mcp** | `pkg/mcp/` | Beta | MCP primitives, protocol-specific |
214+
| **registry/types** | `pkg/registry/` | Beta | Registry types already imported by toolhive-registry and toolhive-registry-server |
215+
| **container/verifier** | `pkg/container/verifier/` | Beta | Sigstore verification, already used by toolhive-registry |
216+
| **cache** | multiple locations | Beta | Generic cache abstraction (see note below) |
217+
218+
> **Cache Consolidation Opportunity**: The codebase has several bespoke cache implementations that could be consolidated into a generic, configurable cache package:
219+
> - `TokenCache` interface in `pkg/vmcp/cache/cache.go` (planned memory/Redis implementations)
220+
> - `CachedAPIRegistryProvider` in `pkg/registry/provider_cached.go` (in-memory registry cache)
221+
> - `DefaultManager` cache in `pkg/vmcp/discovery/manager.go` (capability discovery cache with TTL)
222+
>
223+
> Consolidating on a generic cache implementation would improve testability, simplify application code (e.g., the cache handles synchronization instead of requiring mutexes in each consumer), reduce cognitive load, and enable reuse of backend implementations (e.g., a Redis-backed cache could be shared across all use cases).
206224
207225
#### Not Recommended for Extraction
208226

0 commit comments

Comments
 (0)