mirror of
https://github.com/syntrex-lab/gomcp.git
synced 2026-06-26 15:39:38 +02:00
chore: add copyright headers, CI tests, and sanitize gitignore
This commit is contained in:
parent
5cbb3d89d3
commit
d1f844235e
325 changed files with 2267 additions and 902 deletions
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// Package vectorstore implements persistent storage for intent vectors (DIP H2.1).
|
||||
//
|
||||
// Intent vectors are the output of the Intent Distiller (H0.2). Storing them
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package vectorstore
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package vectorstore_test
|
||||
|
||||
import (
|
||||
|
|
@ -5,9 +9,9 @@ import (
|
|||
"math"
|
||||
"testing"
|
||||
|
||||
"github.com/syntrex-lab/gomcp/internal/domain/vectorstore"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/syntrex-lab/gomcp/internal/domain/vectorstore"
|
||||
)
|
||||
|
||||
func TestFTS5Embedder_Interface(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// Package vectorstore — PolarQuant multi-bit vector compression.
|
||||
//
|
||||
// Based on Google's TurboQuant research (ICLR 2026, §3.2).
|
||||
|
|
@ -187,7 +191,7 @@ func (c *PolarQuantCodec) CompressedBytes() int {
|
|||
|
||||
// CompressionRatio returns the ratio of original to compressed size.
|
||||
func (c *PolarQuantCodec) CompressionRatio() float64 {
|
||||
origBytes := c.dim * 8 // float64
|
||||
origBytes := c.dim * 8 // float64
|
||||
compBytes := c.CompressedBytes() + 4 // + float32 radius
|
||||
return float64(origBytes) / float64(compBytes)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package vectorstore
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// Package vectorstore — QJL (Quantized Johnson-Lindenstrauss) 1-bit quantization.
|
||||
//
|
||||
// Based on Google's TurboQuant research (ICLR 2026, AAAI 2025).
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package vectorstore
|
||||
|
||||
import (
|
||||
|
|
@ -81,8 +85,8 @@ func TestQJL_PreservesOrdering(t *testing.T) {
|
|||
proj := NewQJLProjection(512, 128, 42)
|
||||
|
||||
query := randomVector(128, 1)
|
||||
close := perturbVector(query, 0.1, 2) // ~10% perturbation = close
|
||||
far := perturbVector(query, 0.9, 3) // ~90% perturbation = far
|
||||
close := perturbVector(query, 0.1, 2) // ~10% perturbation = close
|
||||
far := perturbVector(query, 0.9, 3) // ~90% perturbation = far
|
||||
|
||||
cosClose := CosineSimilarity(query, close)
|
||||
cosFar := CosineSimilarity(query, far)
|
||||
|
|
@ -114,8 +118,8 @@ func TestQJL_MemoryReduction(t *testing.T) {
|
|||
vec := randomVector(128, 1)
|
||||
sig := proj.Quantize(vec)
|
||||
|
||||
float64Bytes := 128 * 8 // 1024 bytes
|
||||
qjlBytes := len(sig) * 8 // 4 * 8 = 32 bytes
|
||||
float64Bytes := 128 * 8 // 1024 bytes
|
||||
qjlBytes := len(sig) * 8 // 4 * 8 = 32 bytes
|
||||
reduction := float64(float64Bytes) / float64(qjlBytes)
|
||||
|
||||
assert.Equal(t, 4, len(sig), "256 bits → 4 uint64 words")
|
||||
|
|
@ -286,7 +290,7 @@ func TestStore_PQ_DropFloat64(t *testing.T) {
|
|||
|
||||
// Original float64 vector should be nil'd out.
|
||||
assert.Nil(t, s.Get("r1").Vector, "Vector should be dropped to save memory")
|
||||
|
||||
|
||||
stats := s.GetStats()
|
||||
assert.True(t, stats.PQDropFloat64, "Stats should reflect drop float64 true")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// Package vectorstore implements persistent storage for intent vectors (DIP H2.1).
|
||||
//
|
||||
// Intent vectors are the output of the Intent Distiller (H0.2). Storing them
|
||||
|
|
@ -75,7 +79,7 @@ func DefaultConfig() Config {
|
|||
QJLProjections: 256,
|
||||
QJLSeed: 42,
|
||||
QJLVectorDim: 128,
|
||||
PQBitsPerDim: 0, // Disabled by default.
|
||||
PQBitsPerDim: 0, // Disabled by default.
|
||||
PQSeed: 7,
|
||||
}
|
||||
}
|
||||
|
|
@ -84,14 +88,14 @@ func DefaultConfig() Config {
|
|||
type Store struct {
|
||||
mu sync.RWMutex
|
||||
records []*IntentRecord
|
||||
signatures []QJLSignature // Parallel QJL signatures (same index as records)
|
||||
compressed []CompressedVector // Parallel PolarQuant codes (same index as records)
|
||||
index map[string]int // id → position in records
|
||||
signatures []QJLSignature // Parallel QJL signatures (same index as records)
|
||||
compressed []CompressedVector // Parallel PolarQuant codes (same index as records)
|
||||
index map[string]int // id → position in records
|
||||
capacity int
|
||||
nextID int
|
||||
qjl *QJLProjection // nil if QJL disabled
|
||||
pq *PolarQuantCodec // nil if PolarQuant disabled
|
||||
dropFloat bool // If true, clear rec.Vector after encoding
|
||||
qjl *QJLProjection // nil if QJL disabled
|
||||
pq *PolarQuantCodec // nil if PolarQuant disabled
|
||||
dropFloat bool // If true, clear rec.Vector after encoding
|
||||
}
|
||||
|
||||
// New creates a new vector store.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// Copyright 2026 Syntrex Lab. All rights reserved.
|
||||
// Use of this source code is governed by an Apache-2.0 license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package vectorstore
|
||||
|
||||
import (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue