# checkpoint: route callers through domain stores

`887b239`·

pfleidi·4w ago·25 files·+164 added/-200 removed

Move committed checkpoint callers to the split checkpoint and session store surface.

GitStore keeps the low-level v1 methods internally, but production callers now depend on ReadCheckpoint, ReadSession, WriteSession, UpdateSession, and UpdateCheckpoint.

## Sessions

7319e37bab43View transcript

## Changes

25

- cmd/entire/cli

- Mattach.go+12/-8

- Mattribution.go+4/-9

- Mattribution\_test.go+6/-2

- benchutil

- Mbenchutil.go+1/-1

- checkpoint

- Mcommitted.go+5/-1

- Mcommitted\_domain.go+20/-1

- Mcommitted\_reader\_resolve.go+10/-30

- Mcommitted\_reader\_resolve\_test.go+6/-2

- Acheckpoint\_reader.go+8

- dispatch

- Mmode\_local.go+5/-6

- Mexplain.go+14/-10

- Mexplain\_export.go+7/-19

- Mexplain\_export\_test.go+5/-8

- Mexplain\_test.go+4/-4

- Mhead\_checkpoint\_flags.go+1/-1

- Mresume.go+7/-10

- Mresume\_test.go+12/-6

- Mreview\_context.go+6/-29

- Mreview\_context\_test.go+7/-23

- Mrewind.go+3/-1

- strategy

- Mcleanup.go+1/-1

- Mcommon.go+1/-1

- Mmanual\_commit\_condensation.go+4/-8

- Mmanual\_commit\_hooks.go+11/-15

- Mmanual\_commit\_rewind.go+4/-4

``
336 unmodified lines

337
338
339
340
340
341
342
343
26 unmodified lines

370
371
372
373
373
374
375
376
377
378
379
377
378
379
380
381
381
382
383
384
385
385
386
387
388
389
84 unmodified lines

474
475
476
476
477
478
479
480
481
482
483
484

336 unmodified lines

writeOpts.HasReview = true
	}

if err := store.WriteCommitted(ctx, writeOpts); err != nil {
		if err := store.WriteSession(ctx, cpkg.SessionIDRef(checkpointID, sessionID), writeOpts); err != nil {
			return fmt.Errorf("failed to write checkpoint: %w", err)
		}
	}

26 unmodified lines

if err != nil {
		return false, err
	}
	summary, err := store.ReadCommitted(ctx, checkpointID)
	summary, err := store.ReadCheckpoint(ctx, checkpointID)
	if err != nil {
		if errors.Is(err, cpkg.ErrCheckpointNotFound) {
			return false, nil
		}
		return false, fmt.Errorf("read checkpoint summary: %w", err)
	}
	if summary == nil {
		return false, nil
	}
	for i := range summary.Sessions {
		metadata, err := store.ReadSessionMetadata(ctx, checkpointID, i)
		content, err := store.ReadSession(ctx, cpkg.SessionIndexRef(checkpointID, i), cpkg.WithSessionMetadataOnly())
		if err != nil {
			return false, fmt.Errorf("read session %d metadata: %w", i, err)
		}
		if metadata != nil && metadata.SessionID == sessionID {
			metadata := content.Metadata
			if metadata.SessionID == sessionID {
				return true, nil
			}
		}
	}
84 unmodified lines

if err != nil {
		return false, err
	}
	summary, err := store.ReadCommitted(ctx, checkpointID)
	summary, err := store.ReadCheckpoint(ctx, checkpointID)
	if err != nil {
		if errors.Is(err, cpkg.ErrCheckpointNotFound) {
			return false, nil
		}
		return false, err //nolint:wrapcheck // Caller wraps with checkpoint ID context
	}
	return summary != nil, nil
``
