Good — repo.Storer.RemoveReference() is used in tests. For v2 refs (which are non-branch refs under refs/entire/checkpoints/v2/), this should work fine.
Now let me also check what ReadCommitted on v2 returns when metadata.json is corrupted (malformed JSON). Looking at v2_read.go line 58: it would return fmt.Errorf("failed to parse metadata.json: %w", err) — which is NOT ErrCheckpointNotFound or ErrNoTranscript, so it would propagate through ResolveCommittedReaderForCheckpoint at line 40-42.
For test 2, I need to corrupt the v2 /main ref's metadata.json. The simplest way: rewrite the metadata blob with garbage. But that's complex with go-git. A simpler approach: I can just make the /main ref point to a tree that doesn't have the checkpoint's directory structure — or even simpler, replace the /main ref's commit tree with a garbage tree.
Actually, the simplest approach for test 2: Looking at ReadCommitted in v2_read.go, if the metadata.json exists but contains invalid JSON, it returns fmt.Errorf("failed to parse metadata.json: ..."). I can achieve this by using UpdateCommitted to write corrupt data, or by directly manipulating the git tree.
Let me think about a simpler approach. For test 2, I could use checkpoint.CreateBlobFromContent to create a garbage blob, then rebuild the tree with that blob replacing metadata.json, and update the ref. But that's complex from outside the package.
Actually, the easiest approach: I'll use git update-ref -d via CLI to just delete the v2 /main ref entirely for test 1 (no v2 data at all, but v1 intact → should fall back). Wait, that's testing ErrCheckpointNotFound which already works.
Let me reconsider. For test 2, the point is that ReadCommitted returns a non-sentinel error (like a JSON parse error). The simplest way to get there from the integration test: I can write a v2 checkpoint normally, then use git CLI to corrupt the metadata.json blob in the v2 /main ref.
Actually, let me look at the problem from a different angle. Since these are integration tests that run the actual CLI binary, I need to set up the git state before invoking the CLI. Let me use a helper to corrupt the v2 /main ref.
For Test 1 (no /full/* transcript, compact transcript available):
- Write v2 checkpoint with
CompactTranscript set, then delete the /full/current ref
- Also corrupt v1 to ensure we're reading from v2 compact, not v1
For (malformed v2, fallback to v1):