Documentation
¶
Overview ¶
Package conformancetest exposes the canonical correctness suite every `memory.MemoryStore` driver must pass.
The suite lives in a subpackage so the production-code path `internal/memory` does not import the standard library `testing` package (precedent: `internal/identity/conformancetest`, `internal/state/conformancetest`).
Downstream drivers (SQLite + Postgres) consume it via:
import "github.com/hurtener/Harbor/internal/memory/conformancetest"
func TestMyDriver_Conformance(t *testing.T) {
conformancetest.Run(t, func() conformancetest.Harness {
// ... build store + bus + cleanup ...
})
}
The factory returns a fresh `Harness` per top-level subtest. The `Harness.Bus` field is the bus the driver was wired to so the test can subscribe and assert audit emits without injecting a fake. The cleanup closure releases everything.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run executes the canonical correctness suite. Subtests are strategy-aware via `Harness.Strategy`: identity / cross-isolation / Close / lifecycle subtests run unconditionally, while strategy-specific subtests fork on the configured strategy.
Strategy-agnostic subtests:
- GetLLMContext_EmptyByDefault (Strategy on the patch matches the configured one)
- Flush_NoOp (Flush succeeds on a fresh store)
- Health_ReturnsHealthy (initial state is healthy for every strategy)
- Snapshot_Empty (initial snapshot is consistent with the strategy)
- Restore_RoundTripsEmptySnapshot
- Identity_Mandatory_AddTurn
- Identity_Mandatory_GetLLMContext
- Identity_Mandatory_AllMethods
- CrossTenant_Isolation
- CrossSession_Isolation
- Concurrent_AllMethods_NoRace
- Close_Idempotent
- AfterClose_OperationsError
Strategy=none-specific subtests:
- None_AddTurn_IsNoOp
- None_EstimateTokens_IsZero
- None_Restore_RejectsNonEmpty
Strategy=truncation-specific subtests:
- Truncation_AddTurn_PersistsAndAccumulates
- Truncation_EnforcesBudget
- Truncation_SnapshotRestore_RoundTripsBuffer
Strategy=rolling_summary-specific subtests:
- RollingSummary_AddTurn_TriggersSummarisation
- RollingSummary_SnapshotRestore_RoundTripsSummary
Types ¶
type Factory ¶
type Factory func() Harness
Factory builds a fresh Harness. Called once per top-level subtest; the test invokes Cleanup() when it returns.
type Harness ¶
type Harness struct {
Store memory.MemoryStore
Bus events.EventBus
Strategy memory.Strategy
Retrieval memory.RetrievalMode
// BudgetTokens is the per-key token budget the Store was wired
// with. When > 0 the strategy-budget subtests assert the assembled
// GetLLMContext patch never exceeds it. Zero skips those assertions
// (a harness wired with no budget).
BudgetTokens int
Cleanup func()
}
Harness bundles the per-subtest fixture.
- `Store` is the MemoryStore under test, freshly constructed.
- `Bus` is the EventBus the Store was wired to so the test can Subscribe and observe audit emits without injecting a fake.
- `Strategy` is the strategy the Store is configured for; the suite forks its strategy-specific subtests on this value. Defaults to `StrategyNone` when zero — preserving the original callers (which had no Strategy field on Harness).
- `Cleanup` releases the harness (store.Close + bus.Close + any caller-owned tear-down).
Drivers MUST register their bus subscription identity to a fixed triple under their control; the suite uses a known identity for happy-path assertions and a partial / empty identity to drive rejection paths.
- `Retrieval` is the retrieval mode the Store is configured for. Zero (the default mode) makes the suite assert `SearchTurns` fails loudly with `ErrSemanticDisabled`; `RetrievalSemantic` forks the semantic-retrieval subtests (similarity ranking, vector isolation, flush). A semantic harness must be wired with a deterministic embedder (e.g. `embeddingstest.New()`).