Skip to content

feat(registry): provide directory to runtimes#71

Merged
feloy merged 1 commit intokortex-hub:mainfrom
feloy:runtime-dir
Mar 16, 2026
Merged

feat(registry): provide directory to runtimes#71
feloy merged 1 commit intokortex-hub:mainfrom
feloy:runtime-dir

Conversation

@feloy
Copy link
Contributor

@feloy feloy commented Mar 16, 2026

Optionally provide storage directory to runtimes

Fixes #66

Signed-off-by: Philippe Martin <phmartin@redhat.com>

Co-Authored-By: Claude Code (Claude Sonnet 4.5) <noreply@anthropic.com>
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 65.21739% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/runtime/registry.go 66.66% 3 Missing and 3 partials ⚠️
pkg/instances/manager.go 60.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@feloy feloy changed the title feat(registry): provide directory to runtimes feat(registry): provide directory to runtimes Mar 16, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

This pull request implements directory provisioning for runtimes by introducing a StorageAware interface that allows runtimes to receive and initialize with dedicated storage directories. NewRegistry is refactored to accept a storage directory parameter, create runtime-specific subdirectories, and invoke Initialize on StorageAware implementations during registration.

Changes

Cohort / File(s) Summary
Runtime Registry Core
pkg/runtime/registry.go, pkg/runtime/registry_test.go
Added StorageAware interface for runtimes to receive per-runtime storage directories. Changed NewRegistry signature to accept storageDir parameter and return error. Registry now creates runtime-type-specific subdirectories and invokes Initialize on StorageAware runtimes. Comprehensive tests validate storage directory creation, initialization behavior, error handling, and per-runtime directory structure.
Instance Manager Integration
pkg/instances/manager.go, pkg/instances/manager_test.go
Introduced RuntimesSubdirectory constant ("runtimes"). Updated NewManager to create runtimes subdirectory and instantiate registry with storage path. Test helper newTestRegistry refactored to accept storageDir parameter and initialize registry with correct storage layout.

Sequence Diagram

sequenceDiagram
    participant Manager as Manager.NewManager()
    participant Registry as Registry.NewRegistry()
    participant Storage as Storage Directory
    participant Runtime as Runtime.Register()
    
    Manager->>Manager: Construct runtimesDir<br/>(storageDir/runtimes)
    Manager->>Registry: NewRegistry(runtimesDir)
    activate Registry
    Registry->>Storage: Validate & create runtimesDir
    Storage-->>Registry: Directory ready
    Registry-->>Manager: Registry instance
    deactivate Registry
    
    Manager->>Runtime: Register(runtime)
    activate Runtime
    alt Runtime implements StorageAware
        Runtime->>Storage: Create runtimeType subdirectory
        Storage-->>Runtime: Subdirectory created
        Runtime->>Runtime: Initialize(runtimeTypeDir)
        Runtime-->>Manager: Initialization complete
    else Non-StorageAware runtime
        Runtime-->>Manager: Registration complete
    end
    deactivate Runtime
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat(registry): provide directory to runtimes' directly describes the main feature addition - providing storage directories to runtime implementations during registration.
Description check ✅ Passed The description 'Optionally provide storage directory to runtimes' with reference to issue #66 is directly related to the changeset, which implements this exact feature.
Linked Issues check ✅ Passed The PR fully implements issue #66 requirements: runtimes receive dedicated directories via new StorageAware interface [#66], directory structure follows STORAGE/runtimes/runtimeType pattern [#66], and storage directory is passed through the registry system [#66].
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the directory-provision feature: new RuntimesSubdirectory constant, updated NewRegistry with storage parameters, StorageAware interface, and corresponding test updates all directly support issue #66.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
pkg/runtime/registry_test.go (1)

342-376: Consider adding a compile-time interface check for storageAwareRuntime.

The storageAwareRuntime struct implements both Runtime and StorageAware interfaces. Following the Module Design Pattern used elsewhere in the codebase, consider adding compile-time checks.

🔧 Proposed addition after storageAwareRuntime definition
 type storageAwareRuntime struct {
 	typeID        string
 	storageDir    string
 	initializeErr error
 }
+
+// Compile-time checks
+var _ Runtime = (*storageAwareRuntime)(nil)
+var _ StorageAware = (*storageAwareRuntime)(nil)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/runtime/registry_test.go` around lines 342 - 376, Add compile-time
interface assertions to ensure storageAwareRuntime implements the expected
interfaces: add assertions referencing storageAwareRuntime, Runtime, and
StorageAware (e.g., assign (*storageAwareRuntime)(nil) to variables typed as
Runtime and StorageAware) immediately after the storageAwareRuntime definition
so the compiler will catch any future signature drift.
pkg/runtime/registry.go (1)

63-71: Consider adding a compile-time interface check for StorageAware.

The codebase follows the Module Design Pattern with compile-time interface checks (see line 81 for Registry). Consider adding a similar check for StorageAware to catch implementation mismatches early, especially since runtimes implementing this interface will be in separate packages.

🔧 Proposed addition after StorageAware definition
// Ensure storageAwareRuntime implements StorageAware at compile time (example for implementors)
// var _ StorageAware = (*yourRuntime)(nil)

Note: Since this is an optional interface for external implementors, the compile-time check would be in the implementing packages rather than here. This is acceptable as-is.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/runtime/registry.go` around lines 63 - 71, Add a compile-time interface
assertion for StorageAware by placing a var _ StorageAware = (*yourRuntime)(nil)
in the concrete runtime implementation package (not in this file); alternatively
add a short example comment immediately after the StorageAware type declaration
showing that pattern. Reference the StorageAware interface and the concrete
runtime type name (e.g., yourRuntime) so implementors get an early compile-time
failure if their type signature doesn't satisfy StorageAware.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/runtime/registry_test.go`:
- Around line 342-376: Add compile-time interface assertions to ensure
storageAwareRuntime implements the expected interfaces: add assertions
referencing storageAwareRuntime, Runtime, and StorageAware (e.g., assign
(*storageAwareRuntime)(nil) to variables typed as Runtime and StorageAware)
immediately after the storageAwareRuntime definition so the compiler will catch
any future signature drift.

In `@pkg/runtime/registry.go`:
- Around line 63-71: Add a compile-time interface assertion for StorageAware by
placing a var _ StorageAware = (*yourRuntime)(nil) in the concrete runtime
implementation package (not in this file); alternatively add a short example
comment immediately after the StorageAware type declaration showing that
pattern. Reference the StorageAware interface and the concrete runtime type name
(e.g., yourRuntime) so implementors get an early compile-time failure if their
type signature doesn't satisfy StorageAware.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 07e7b284-ae5b-45a8-85f7-f47a9f6af380

📥 Commits

Reviewing files that changed from the base of the PR and between 387bc82 and 8eef657.

📒 Files selected for processing (4)
  • pkg/instances/manager.go
  • pkg/instances/manager_test.go
  • pkg/runtime/registry.go
  • pkg/runtime/registry_test.go

@feloy feloy requested review from benoitf and jeffmaury March 16, 2026 09:37
}

// Create storage directory if it doesn't exist
if err := os.MkdirAll(absStorageDir, 0755); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do we need the execution bit ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the user to be able to 'cd' to it, yes

@feloy feloy merged commit 2f5c00b into kortex-hub:main Mar 16, 2026
6 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.

provide directory to runtimes

3 participants