Trim compact-transcript format assertions from store tests · Entire

Trim compact-transcript format assertions from store tests

c4b837b→main·

computermode·3w ago·1 file·+3 added/-44

The store-layer tests re-validated the compact line format (v, agent slug, per-line type), which transcript/compact already covers. Drop those assertions and the parseCompactLines helper so the tests assert only the store's own behavior: that transcript.jsonl is written, scoped, and the metadata pointer stays on full.jsonl. Also drop the now-unused agent blank imports and encoding/json.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Sessions

716059686529View transcript

Changes

1

1 unmodified line

2
3
4
5
5
6
7
1 unmodified line

9
10
11
13
14
15
16
17
12
13
14
27 unmodified lines

42
43
44
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
45
46
47
21 unmodified lines

69
70
71
100
72
73
74
75
76
77
78
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
79
80
81

1 unmodified line

import (
    "context"
    "encoding/json"
    "strings"
    "testing"

1 unmodified line

"github.com/entireio/cli/cmd/entire/cli/checkpoint/id"
    "github.com/entireio/cli/cmd/entire/cli/paths"
    "github.com/entireio/cli/redact"

// Registers the Claude Code and Codex agents so compactAgentName resolves
    // their slugs instead of falling back to the raw agent type.
    _ "github.com/entireio/cli/cmd/entire/cli/agent/claudecode"
    _ "github.com/entireio/cli/cmd/entire/cli/agent/codex"
)

// claudeStyleTranscript returns a Claude Code-format JSONL transcript with two
27 unmodified lines

return content, true
}

// compactTranscriptLine is the subset of the compact transcript line format
// asserted in these tests.
type compactTranscriptLine struct {
    V       int             `json:"v"`
    Agent   string          `json:"agent"`
    Type    string          `json:"type"`
    Content json.RawMessage `json:"content"`
}

func parseCompactLines(t *testing.T, content string) []compactTranscriptLine {

t.Helper()
    var lines []compactTranscriptLine
    for _, raw := range strings.Split(strings.TrimSpace(content), "\n") {
        var line compactTranscriptLine
        if err := json.Unmarshal([]byte(raw), &line); err != nil {
            t.Fatalf("compact transcript line is not valid JSON: %v\nline: %s", err, raw)
        }
        lines = append(lines, line)
    }
    return lines
}

func TestWriteCommitted_WritesCompactTranscript(t *testing.T) {

t.Parallel()
    repo, _ := setupTestRepo(t)
21 unmodified lines

t.Error("full.jsonl missing from checkpoint tree")
    }

// transcript.jsonl holds the compact format.
    // transcript.jsonl is written with compact content derived from the
    // transcript. The compact format itself is covered by transcript/compact;
    // here we only assert the store persisted non-empty derived content.
    compactContent, ok := readBranchFile(t, store, sessionPath+paths.CompactTranscriptFileName)
    if !ok {
        t.Fatal("transcript.jsonl missing from checkpoint tree")
    }
    lines := parseCompactLines(t, compactContent)
    if len(lines) != 4 {
        t.Fatalf("compact transcript line count = %d, want 4\ncontent: %s", len(lines), compactContent)
    }
    for i, line := range lines {
        if line.V != 1 {
            t.Errorf("line %d: v = %d, want 1", i, line.V)
        }
        if line.Agent != "claude-code" {
            t.Errorf("line %d: agent = %q, want %q", i, line.Agent, "claude-code")
        }
    }
    if lines[0].Type != "user" || lines[1].Type != "assistant" {
        t.Errorf("unexpected line types: %q, %q", lines[0].Type, lines[1].Type)
    }
    if !strings.Contains(compactContent, "reply two") {
        t.Error("compact transcript missing assistant content")
    }

Mcmd/entire/cli/checkpoint/committed_compact_transcript_test.go+3/-44