Feat v0.8.2 capability negotiation #69

Merged
xcaliber merged 2 commits from feat/v0.8.2-capability-negotiation into main 2026-04-03 09:14:00 +00:00
2 changed files with 26 additions and 32 deletions
Showing only changes of commit 301b7e0d02 - Show all commits

View File

@@ -158,9 +158,9 @@ func TestBundledInstall_EmptyDir(t *testing.T) {
InstallBundledPackages(bundledDir, "", "", stores, nil, nil)
}
// TestBundledInstall_DormantPackage verifies that bundled packages with
// unmet requires are marked dormant.
func TestBundledInstall_DormantPackage(t *testing.T) {
// TestBundledInstall_SkippedOnUnmetRequiredCaps verifies that bundled
// packages with unmet capabilities.required are skipped (not registered).
func TestBundledInstall_SkippedOnUnmetRequiredCaps(t *testing.T) {
stores := newTestStores(t)
ctx := context.Background()
@@ -168,24 +168,21 @@ func TestBundledInstall_DormantPackage(t *testing.T) {
packagesDir := t.TempDir()
buildTestPkg(t, bundledDir, map[string]any{
"id": "dormant-pkg",
"title": "Dormant Package",
"type": "extension",
"hooks": []string{"on_install"},
"requires": []string{"chat"},
"id": "needs-pgvector",
"title": "Needs pgvector",
"type": "extension",
"hooks": []string{"on_install"},
"capabilities": map[string]any{
"required": []string{"pgvector"},
},
})
// No capabilities detected → pgvector is unavailable
InstallBundledPackages(bundledDir, packagesDir, "*", stores, nil, nil)
pkg, err := stores.Packages.Get(ctx, "dormant-pkg")
if err != nil || pkg == nil {
t.Fatal("dormant package not found after install")
}
if pkg.Status != "dormant" {
t.Errorf("status = %q, want %q", pkg.Status, "dormant")
}
if pkg.Enabled {
t.Error("dormant package should not be enabled")
pkg, _ := stores.Packages.Get(ctx, "needs-pgvector")
if pkg != nil {
t.Error("package with unmet required capabilities should not be registered")
}
}

View File

@@ -438,7 +438,7 @@ func TestUpgrade_BundledSkipExistingOnRestart(t *testing.T) {
}
}
func TestUpgrade_PackageDormantOnUnmetRequires(t *testing.T) {
func TestUpgrade_PackageSkippedOnUnmetRequiredCaps(t *testing.T) {
stores := newTestStores(t)
ctx := context.Background()
@@ -447,25 +447,22 @@ func TestUpgrade_PackageDormantOnUnmetRequires(t *testing.T) {
// Package requires a capability that doesn't exist
buildTestPkg(t, bundledDir, map[string]any{
"id": "future-pkg",
"title": "Future",
"type": "extension",
"version": "1.0.0",
"hooks": []string{"on_install"},
"requires": []string{"kernel>=99.0.0"},
"id": "future-pkg",
"title": "Future",
"type": "extension",
"version": "1.0.0",
"hooks": []string{"on_install"},
"capabilities": map[string]any{
"required": []string{"pgvector"},
},
})
// No capabilities detected → pgvector is unavailable
InstallBundledPackages(bundledDir, packagesDir, "*", stores, nil, nil)
pkg, _ := stores.Packages.Get(ctx, "future-pkg")
if pkg == nil {
t.Fatal("package should still be registered")
}
if pkg.Status != "dormant" {
t.Errorf("status = %q, want %q", pkg.Status, "dormant")
}
if pkg.Enabled {
t.Error("dormant package should not be enabled")
if pkg != nil {
t.Error("package with unmet required capabilities should not be registered")
}
}