Skip to content

Conversation

@dmartinol
Copy link
Collaborator

@dmartinol dmartinol commented Nov 13, 2025

Initial changes for #76

Summary

This PR uses the new unified registry model (UpstreamRegistry) that wraps the upstream Anthropic MCP format (ServerJSON) while maintaining backward compatibility with the existing ToolHive format. This is the first step in a multi-PR migration to adopt the upstream registry format internally.

What Changed

New Components

  • pkg/registry/: Temporary functions to convert UpstreamRegistry → ToolHive (for backward compatibility)
    • May be removed once the refactory is done and all the code works with the upstream data format

Updated Layers

  • Storage Layer (pkg/sources/storage_manager.go)
    • Interface now uses *toolhivetypes.UpstreamRegistry instead of *toolhivetypes.Registry
    • Data is persisted in the new unified format
  • Sources Layer (pkg/sources/)
    • All source handlers (Git, API, File) updated to work with UpstreamRegistry
    • Validators updated to parse both ToolHive and upstream formats into UpstreamRegistry
    • FetchResult type now contains UpstreamRegistry
  • Provider Layer (internal/service/file_provider.go)
    • Maintains backward compatibility: Still returns *toolhivetypes.Registry
    • Internally converts UpstreamRegistry → ToolHive before returning
    • This ensures no breaking changes to the service/API layers in this PR
  • Sync Manager (pkg/sync/manager.go)
    • Added round-trip conversions for filtering compatibility:
    • UpstreamRegistry → ToolHive (for filtering)
    • Filtered ToolHive → UpstreamRegistry (for storage)

Backward Compatibility

No breaking changes:

  • All public APIs remain unchanged
  • Provider layer still returns ToolHive format
  • Service and API layers unaware of internal format change
  • Existing clients continue to work without modifications

Testing

✅ All existing tests updated and passing
✅ New comprehensive unit tests for UpstreamRegistry
✅ Test coverage: 65.8%
✅ Zero linting issues

Migration Strategy

This is PR 1 of 3 in the format migration:

  • PR 1 (this PR): Introduce UpstreamRegistry, update storage/sources, maintain provider compatibility
  • PR 2 (next): Update provider layer to return UpstreamRegistry, update service/API layers
  • PR 3 (final): Cleanup

@dmartinol dmartinol requested review from blkt and rdimitrov November 13, 2025 09:11
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 74.30168% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.85%. Comparing base (347993f) to head (274b8d5).

Files with missing lines Patch % Lines
internal/sync/manager.go 39.13% 12 Missing and 2 partials ⚠️
internal/registry/temporary.go 59.09% 7 Missing and 2 partials ⚠️
internal/service/mocks/mock_service.go 0.00% 6 Missing ⚠️
internal/sources/api_toolhive.go 75.00% 3 Missing and 1 partial ⚠️
internal/sources/mocks/mock_storage_manager.go 0.00% 3 Missing ⚠️
internal/sources/types.go 87.50% 1 Missing and 2 partials ⚠️
internal/service/file_provider.go 75.00% 1 Missing and 1 partial ⚠️
internal/service/mocks/mock_provider.go 0.00% 2 Missing ⚠️
internal/sources/mocks/mock_source_handler.go 0.00% 2 Missing ⚠️
internal/service/service.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #104      +/-   ##
==========================================
- Coverage   64.07%   63.85%   -0.23%     
==========================================
  Files          49       50       +1     
  Lines        2895     2941      +46     
==========================================
+ Hits         1855     1878      +23     
- Misses        913      930      +17     
- Partials      127      133       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

blkt
blkt previously approved these changes Nov 13, 2025
@dmartinol dmartinol marked this pull request as draft November 17, 2025 07:39
@dmartinol dmartinol changed the title Introduced ServerRegistry type and converter functions. Introduced UpstreamRegistry and converter functions. Nov 17, 2025
@dmartinol dmartinol marked this pull request as ready for review November 17, 2025 18:11
@dmartinol
Copy link
Collaborator Author

@blkt @rdimitrov I re-opened this after integrating the UpstreamRegistry type

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
@dmartinol dmartinol merged commit 62edc50 into stacklok:main Nov 18, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants