Files
yhh 2a62e704d3 refactor(sessionstore): a transcript's durable record leaves the agent
Session persistence moves from internal/runtime/agent to
internal/state/sessionstore: the Session type, its checkpoint and event
log, listing sidecars, branches, leases, recovery copies, migration, and
the compaction and subagent records saved beside a transcript. The agent
keeps the loop and imports the store; history, historycatalog, migration,
guardian, instanceid and sessiontool now reach the store instead of the
agent, which drops layer-order from 26 to 18.

Tests that exercise only store internals moved with it; the rest stay in
agent and qualify the moved names. DigestSessionMessages and
CompactionStateSchemaV1 are exported for the agent tests that build
legacy fixtures.

Baseline: carried with -allow-widen. The moved files bring their essay,
file-size, complexity and orphan debt unchanged under new paths, and
boot.go, acp/service.go, serve/serve.go, agent/task.go and
control/controller.go each gain the one import line the split costs.
2026-09-23 20:08:36 -07:00

45 lines
1.3 KiB
Go

package agent
import (
"reasonix/internal/state/sessionstore"
"testing"
"reasonix/internal/contract/provider"
)
func TestLineageKeyCompatibleNativeSuffix(t *testing.T) {
current := "ws|sess|model"
stored := current + "|context-editing-native-anthropic"
got, ok := lineageKeyCompatible(stored, current)
if !ok || got != current {
t.Fatalf("lineageKeyCompatible(%q,%q)=(%q,%v), want (%q,true)", stored, current, got, ok, current)
}
if _, ok := lineageKeyCompatible("other|sess|model", current); ok {
t.Fatal("foreign lineage must not match")
}
if got, ok := lineageKeyCompatible(current, current); !ok || got != current {
t.Fatalf("exact key: got (%q,%v)", got, ok)
}
}
func TestProjectionValidAcceptsLegacyNativeKey(t *testing.T) {
msgs := []provider.Message{
{Role: provider.RoleSystem, Content: "sys"},
{Role: provider.RoleUser, Content: "u"},
}
hash := sessionstore.CoveredPrefixHash(msgs, len(msgs))
st := sessionstore.CompactionState{
PromptCacheKey: "ws|s|m|context-editing-native-x",
Projection: sessionstore.ContextProjection{
Messages: msgs,
CoveredCount: len(msgs),
CoveredPrefixHash: hash,
ProjectionVersion: 1,
},
TranscriptVersion: 1,
}
if !projectionValid(st, msgs, "ws|s|m", nil) {
t.Fatal("projectionValid rejected legacy native lineage key")
}
}