Skip to content

Commit 670a242

Browse files
Sophclaude
andcommitted
test: add v1 and v2 store tests for commits.jsonl
Verify CommitLog bytes are written to and readable from both v1 (entire/checkpoints/v1) and v2 (refs/entire/checkpoints/v2/main) checkpoint trees. Also test that empty CommitLog produces no blob. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: a5ebd5630a65
1 parent eb04925 commit 670a242

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

cmd/entire/cli/checkpoint/checkpoint_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4288,3 +4288,29 @@ func TestWriteTemporaryTask_ExcludesGitIgnoredFiles(t *testing.T) {
42884288
t.Error("SECURITY: gitignored file .env leaked into task checkpoint tree — secrets exposed on shadow branch via subagent")
42894289
}
42904290
}
4291+
4292+
func TestV1CommitLog_WrittenAndReadable(t *testing.T) {
4293+
t.Parallel()
4294+
repo, _ := setupBranchTestRepo(t)
4295+
store := NewGitStore(repo)
4296+
cpID := id.MustCheckpointID("c1c2c3c4c5c6")
4297+
ctx := context.Background()
4298+
4299+
commitLog := []byte(`{"hash":"abc","short_hash":"abc1234","subject":"Test commit","checkpoint_id":"c1c2c3c4c5c6","session_id":"s1"}` + "\n")
4300+
4301+
err := store.WriteCommitted(ctx, WriteCommittedOptions{
4302+
CheckpointID: cpID,
4303+
SessionID: "s1",
4304+
Strategy: "manual-commit",
4305+
Transcript: redact.AlreadyRedacted([]byte(`{"message": "hello"}`)),
4306+
AuthorName: "Test",
4307+
AuthorEmail: "test@test.com",
4308+
CommitLog: commitLog,
4309+
})
4310+
require.NoError(t, err)
4311+
4312+
content, err := store.ReadSessionContent(ctx, cpID, 0)
4313+
require.NoError(t, err)
4314+
require.NotNil(t, content)
4315+
require.Equal(t, commitLog, content.CommitLog)
4316+
}

cmd/entire/cli/checkpoint/v2_read_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,60 @@ func TestV2UpdateSummary_NotFound(t *testing.T) {
367367
err := store.UpdateSummary(ctx, id.MustCheckpointID("000000000000"), &Summary{Intent: "x"})
368368
require.ErrorIs(t, err, ErrCheckpointNotFound)
369369
}
370+
371+
func TestV2CommitLog_WrittenAndReadable(t *testing.T) {
372+
t.Parallel()
373+
repo := initTestRepo(t)
374+
store := NewV2GitStore(repo, "origin")
375+
cpID := id.MustCheckpointID("c1c2c3c4c5c6")
376+
ctx := context.Background()
377+
378+
commitLog := []byte(`{"hash":"abc","short_hash":"abc1234","subject":"Test commit","checkpoint_id":"c1c2c3c4c5c6","session_id":"s1"}` + "\n")
379+
380+
err := store.WriteCommitted(ctx, WriteCommittedOptions{
381+
CheckpointID: cpID,
382+
SessionID: "s1",
383+
Strategy: "manual-commit",
384+
Transcript: redact.AlreadyRedacted([]byte(`{"message": "hello"}`)),
385+
AuthorName: "Test",
386+
AuthorEmail: "test@test.com",
387+
CommitLog: commitLog,
388+
})
389+
require.NoError(t, err)
390+
391+
// Read via ReadSessionContent
392+
content, err := store.ReadSessionContent(ctx, cpID, 0)
393+
require.NoError(t, err)
394+
require.NotNil(t, content)
395+
assert.Equal(t, commitLog, content.CommitLog)
396+
397+
// Read via ReadSessionMetadataAndPrompts
398+
metaContent, err := store.ReadSessionMetadataAndPrompts(ctx, cpID, 0)
399+
require.NoError(t, err)
400+
require.NotNil(t, metaContent)
401+
assert.Equal(t, commitLog, metaContent.CommitLog)
402+
}
403+
404+
func TestV2CommitLog_EmptyWhenNotSet(t *testing.T) {
405+
t.Parallel()
406+
repo := initTestRepo(t)
407+
store := NewV2GitStore(repo, "origin")
408+
cpID := id.MustCheckpointID("d1d2d3d4d5d6")
409+
ctx := context.Background()
410+
411+
err := store.WriteCommitted(ctx, WriteCommittedOptions{
412+
CheckpointID: cpID,
413+
SessionID: "s1",
414+
Strategy: "manual-commit",
415+
Transcript: redact.AlreadyRedacted([]byte(`{"message": "hello"}`)),
416+
AuthorName: "Test",
417+
AuthorEmail: "test@test.com",
418+
// No CommitLog
419+
})
420+
require.NoError(t, err)
421+
422+
content, err := store.ReadSessionContent(ctx, cpID, 0)
423+
require.NoError(t, err)
424+
require.NotNil(t, content)
425+
assert.Empty(t, content.CommitLog)
426+
}

0 commit comments

Comments
 (0)