inspect: harden model component window bounds · Entire

inspect: harden model component window bounds

e8ccafemain·

dipree·4w ago·2 files·+19 added/-0 removed

modelComponentsMatch already calls componentsEqualAt only for offsets whose matched span is in bounds, but add a defensive bounds check inside componentsEqualAt so direct or future callers cannot overrun the long slice. Add a focused regression test for negative and overrun offsets.

Sessions

d9f07524da29View transcript

[?
Checkout the hand off doc that I just added.Pi·Opus 4.8·2 steps](/content/gh/entireio/cli/session/019eca64-8c2c-7b00-90c6-3aa49738c497#timeline-d9f07524da29/index.html)

Changes

2

520 unmodified lines

521
522
523
524
525
526
527
528
529

520 unmodified lines

}

func componentsEqualAt(long, short []string, i int) bool {
    if i < 0 || i+len(short) > len(long) {
        return false
    }
    for k := range short {
        if long[i+k] != short[k] {
            return false

Mcmd/entire/cli/review/manifest.go+3

806 unmodified lines

807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828

806 unmodified lines

// normalize identically (claude-sonnet:high / :low -> claude-sonnet), with
// sessions that start in the same second, must still link to distinct sessions
// rather than both grabbing the most recent match.
func TestComponentsEqualAtBoundsChecks(t *testing.T) {
    t.Parallel()
    long := []string{"claude", "sonnet"}
    short := []string{"sonnet", "4"}

if componentsEqualAt(long, short, -1) {
        t.Fatal("negative offset should not match")
    }
    if componentsEqualAt(long, short, 1) {
        t.Fatal("span that overruns long should not match")
    }
    if !componentsEqualAt(long, []string{"sonnet"}, 1) {
        t.Fatal("in-bounds span should match")
    }
}

func TestBuildLocalReviewManifestFromSummary_DisambiguatesSameModelDifferentThinking(t *testing.T) {
    started := time.Date(2026, 5, 7, 10, 0, 0, 0, time.UTC)
    summary := reviewtypes.RunSummary{