38 lines
2 KiB
Go
38 lines
2 KiB
Go
package pipeline
|
||
|
||
import (
|
||
"testing"
|
||
|
||
"textmachine/backend/internal/store"
|
||
)
|
||
|
||
// TestBaseEnrichedMemoryVersionSplit pins the WS1 §1в per-wave bank-version mechanism: the BASE
|
||
// version (draft wave / draft-wave snapshot) excludes Source:"mined" rows, so adding a mined approved row
|
||
// after the draft wave moves ONLY the ENRICHED version (edit wave / snapshot_W2) — keeping the draft wave checkpoints valid
|
||
// («переоплата ОДНА»). A broken split (base folding mined) would move draft-wave snapshot and re-bill the draft wave.
|
||
func TestBaseEnrichedMemoryVersionSplit(t *testing.T) {
|
||
seedRows := []store.GlossaryEntry{
|
||
{Src: "方源", Dst: "Фан Юань", Status: "approved", Source: "seed"},
|
||
{Src: "古月", Dst: "Гу Юэ", Status: "approved", Source: "ruby"},
|
||
}
|
||
base0 := materializeMemory(seedRows, false)
|
||
// Same rows PLUS a mined approved row (as a the draft wave.5 pass would add).
|
||
enrichedRows := append([]store.GlossaryEntry{}, seedRows...)
|
||
enrichedRows = append(enrichedRows, store.GlossaryEntry{Src: "蛊", Dst: "гу", Status: "approved", Source: "mined"})
|
||
bank1 := materializeMemory(enrichedRows, false)
|
||
|
||
// 1) Base version is UNCHANGED by the mined addition (draft wave stays valid).
|
||
if base0.BaseVersion() != bank1.BaseVersion() {
|
||
t.Fatalf("base version moved on a mined-row addition — draft-wave snapshot would re-bill the draft wave:\n before %s\n after %s",
|
||
base0.BaseVersion(), bank1.BaseVersion())
|
||
}
|
||
// 2) Enriched version DID move (edit wave sees the new mined canon).
|
||
if base0.Version() == bank1.Version() {
|
||
t.Fatalf("enriched version did NOT move on a mined-row addition — the edit wave would miss the mined canon")
|
||
}
|
||
// 3) Base ≠ enriched even before any mined row (domain-separated), so a the draft wave job can never
|
||
// accidentally content-address to a the edit wave checkpoint.
|
||
if base0.BaseVersion() == base0.Version() {
|
||
t.Fatalf("base and enriched versions collide over identical rows — they must be domain-separated")
|
||
}
|
||
}
|