WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestMoveKnowledgeReuseVectors_CrossStoreRejected verifies the defense-in-depth
|
||||
// guard: a reuse_vectors move whose source and target KBs are bound to different
|
||||
// vector stores must be rejected before any index copy runs. The guard fires at
|
||||
// the top of moveKnowledgeReuseVectors, so an empty knowledgeService (no repos)
|
||||
// is sufficient — the function returns before touching any dependency.
|
||||
func TestMoveKnowledgeReuseVectors_CrossStoreRejected(t *testing.T) {
|
||||
s := &knowledgeService{}
|
||||
ctx := context.WithValue(context.Background(), types.TenantIDContextKey, uint64(1))
|
||||
|
||||
storeA, storeB := "store-a", "store-b"
|
||||
tests := []struct {
|
||||
name string
|
||||
srcStore *string
|
||||
dstStore *string
|
||||
}{
|
||||
{"both bound, different stores", &storeA, &storeB},
|
||||
{"source bound, target env-store", &storeA, nil},
|
||||
{"source env-store, target bound", nil, &storeB},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
src := &types.KnowledgeBase{ID: "kb-src", VectorStoreID: tt.srcStore}
|
||||
dst := &types.KnowledgeBase{ID: "kb-dst", VectorStoreID: tt.dstStore}
|
||||
kn := &types.Knowledge{ID: "k1", EmbeddingModelID: "m1"}
|
||||
|
||||
err := s.moveKnowledgeReuseVectors(ctx, kn, src, dst)
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "different vector stores")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestSharesStoreWith_GuardSemantics pins the same/cross-store classification the
|
||||
// move gate relies on, including the env-store (nil) normalization, so a change
|
||||
// to SharesStoreWith that would silently re-open the cross-store reuse_vectors
|
||||
// hole fails here.
|
||||
func TestSharesStoreWith_GuardSemantics(t *testing.T) {
|
||||
storeA, storeB, empty := "store-a", "store-b", ""
|
||||
|
||||
same := func(a, b *string) bool {
|
||||
return (&types.KnowledgeBase{VectorStoreID: a}).
|
||||
SharesStoreWith(&types.KnowledgeBase{VectorStoreID: b})
|
||||
}
|
||||
|
||||
assert.True(t, same(nil, nil), "both env-store → same")
|
||||
assert.True(t, same(&empty, nil), "empty string normalizes to env-store")
|
||||
assert.True(t, same(&storeA, &storeA), "same UUID → same")
|
||||
assert.False(t, same(&storeA, &storeB), "different UUID → cross-store")
|
||||
assert.False(t, same(&storeA, nil), "bound vs env-store → cross-store")
|
||||
}
|
||||
Reference in New Issue
Block a user