# Tighten bootstrap checkpoint boundary search

`76823bf`→[main](/content/gh/entireio/git-sync/commits/main/index.html)·

Soph·3mo ago·3 files·+223 added/-3 removed

## Sessions

407e0ab6035fView transcript

[?\
Can you take a look at the go code (wasm) in /Users/soph/Work/entire/devenv/entire-io-worktree1 based a bit on that I wonder if something like this can be build:Codex·GPT-5.4·1 step](/content/gh/entireio/git-sync/session/019d6d29-8cf7-7fe3-adc9-8c3e4d9d5603#timeline-407e0ab6035f/index.html)

## Changes

- docs
  - Mrewrite-issue-list.md+1

- internal/strategy/bootstrap
  - Mbootstrap.go+111/-3
  - Mbootstrap_test.go+111

```
324 unmodified lines
```

Current rewrite note:
- The rewrite adds an initial commit-count heuristic and memoizes repeated equivalent probe results within a planning run.
- Successful under-limit probe packs are now cached and reused during execution, which avoids a second fetch for selected checkpoints.
- Checkpoint selection now also keeps searching within known fit/too-large probe bounds so it can choose the largest fitting checkpoint once an upper bound is known, instead of stopping at the first fitting sample and leaving obvious headroom unused.
- The planner still relies on network probes for sizing, so this remains partial rather than fully solved.

### 15. Materialized fallback path does not scale to large repos
```
Mdocs/rewrite-issue-list.md+1
```

```
444 unmodified lines
```

```

if bestIdx != -1 {
    return bestIdx, nil
}
...
}
```

### Search Checkpoint Under Limit Function
```
func (p *checkpointPlanner) searchCheckpointUnderLimit(prevIdx int, prevHash plumbing.Hash, prevSpan int) (int, error) {
    lo := prevIdx + 1
    hi := len(p.chain) - 1

largestFit, smallestTooLarge := p.probeBounds(prevHash, lo, hi)
    if smallestTooLarge > hi {
        if largestFit >= lo {
            return largestFit, nil
        }
    }
    return -1, nil
}
```

### Example Tests
```
tests := []struct {
    name             string
    lo               int
    hi               int
    prevSpan         int
    largestFit       int
    smallestTooLarge int
    want             int
} {
    {
        name: "probes midpoint between known fit and too large bounds",
        lo: 0,
        hi: 19,
        prevSpan: 8,
        largestFit: 7,
        smallestTooLarge: 15,
        want: 11,
    },
}
```

### Additional Functions
```
func nextCheckpointProbeCandidate(lo, hi, prevSpan, largestFit, smallestTooLarge int) int {
   // some implementation...
}
```

### Test Function Implementation
```
func TestSearchCheckpointUnderLimitFindsLargestFittingCheckpoint(t *testing.T) {
    // Implementation of test...
}
```
