Add direct relay decision coverage · Entire

Add direct relay decision coverage

f9170fc→main·

Soph·3mo ago·2 files·+103 added/-4

Sessions

1a1fb1d80eafView 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-1a1fb1d80eaf/index.html)

Changes

2

372 unmodified lines

### 19. Relay eligibility logic is only tested indirectly

Status: partial
Status: done

Missing direct tests include:
- `canIncrementalRelay`

- Strategy selection must be testable independently from network execution.

Current rewrite note:
- Relay logic moved into planner/strategy packages and is more directly testable, but the original acceptance wording implies more isolated decision tests than currently exist.
- Relay decision functions now have direct planner-level coverage in addition to higher-level execution-path tests.

### 20. Protocol v2 error handling is under-tested

### 22. No benchmark coverage for the expensive paths

Status: done
Status: partial

Rewrite requirement:
- Add benchmarks for relay path overhead, planning overhead, and fallback graph/object work.
- Logging is structured and concurrency-safe. Status: open
- Protocol parsing has explicit malformed-input tests. Status: done
- Rewrite passes `go test ./...` and `go test -race ./...`. Status: done
- Rewrite includes benchmarks for the critical planning and execution paths. Status: done
- Rewrite includes benchmarks for the critical planning and execution paths. Status: partial
- Rewrite branch can be compared against current behavior using the same integration scenarios. Status: done

Notes:

Mdocs/rewrite-issue-list.md+4/-4


733 unmodified lines

```go
func TestCanIncrementalRelayRejectsNoThin(t *testing.T) {
    plans := []BranchPlan{{
        Branch:     "main",
        SourceRef:  "refs/heads/main",
        TargetRef:  "refs/heads/main",
        SourceHash: plumbing.NewHash("1111111111111111111111111111111111111111"),
        TargetHash: plumbing.NewHash("2222222222222222222222222222222222222222"),
        Kind:       RefKindBranch,
        Action:     ActionUpdate,
    }}

advRefs := &packp.AdvRefs{}
    advRefs.Capabilities = capability.NewList()
    _ = advRefs.Capabilities.Set(capability.Capability("no-thin"))

ok, reason := CanIncrementalRelay(false, false, false, plans, advRefs)
    if ok {
        t.Fatal("expected CanIncrementalRelay=false when target advertises no-thin")
    }
    if reason != "incremental-target-no-thin" {
        t.Fatalf("unexpected reason: %s", reason)
    }
}

func TestCanIncrementalRelayRejectsBranchCreate(t *testing.T) {
    plans := []BranchPlan{{
        Branch:     "main",
        SourceRef:  "refs/heads/main",
        TargetRef:  "refs/heads/main",
        SourceHash: plumbing.NewHash("1111111111111111111111111111111111111111"),
        TargetHash: plumbing.ZeroHash,
        Kind:       RefKindBranch,
        Action:     ActionCreate,
    }}

advRefs := &packp.AdvRefs{}
    advRefs.Capabilities = capability.NewList()

ok, reason := CanIncrementalRelay(false, false, false, plans, advRefs)
    if ok {
        t.Fatal("expected CanIncrementalRelay=false for branch create")
    }
    if reason != "incremental-branch-action-not-update" {
        t.Fatalf("unexpected reason: %s", reason)
    }
}

func TestCanFullTagCreateRelay(t *testing.T) {
    plans := []BranchPlan{{
        Branch:     "v1.0",
        SourceRef:  "refs/tags/v1.0",
        TargetRef:  "refs/tags/v1.0",
        SourceHash: plumbing.NewHash("3333333333333333333333333333333333333333"),
        TargetHash: plumbing.ZeroHash,
        Kind:       RefKindTag,
        Action:     ActionCreate,
    }}

ok, reason := CanFullTagCreateRelay(plans)
    if !ok {
        t.Fatalf("expected CanFullTagCreateRelay=true, got reason=%s", reason)
    }
    if reason != "tag-create-full-pack" {
        t.Fatalf("unexpected reason: %s", reason)
    }
}

func TestRelayFallbackReason(t *testing.T) {
    tagCreate := []BranchPlan{{
        Branch:     "v1.0",
        SourceRef:  "refs/tags/v1.0",
        TargetRef:  "refs/tags/v1.0",
        SourceHash: plumbing.NewHash("3333333333333333333333333333333333333333"),
        TargetHash: plumbing.ZeroHash,
        Kind:       RefKindTag,
        Action:     ActionCreate,
    }}

advRefs := &packp.AdvRefs{}
    advRefs.Capabilities = capability.NewList()

if got := RelayFallbackReason(false, false, false, tagCreate, advRefs); got != "fast-forward-branch-or-tag-create" {
        t.Fatalf("expected fast-forward-branch-or-tag-create, got %s", got)
    }

unsupported := []BranchPlan{{
        Branch:     "main",
        SourceRef:  "refs/heads/main",
        TargetRef:  "refs/tags/main",
        SourceHash: plumbing.NewHash("1111111111111111111111111111111111111111"),
        TargetHash: plumbing.NewHash("2222222222222222222222222222222222222222"),
        Kind:       RefKindBranch,
        Action:     ActionUpdate,
    }}
    if got := RelayFallbackReason(false, false, false, unsupported, advRefs); got != "incremental-tag-relay-non-tag-plan" {
        t.Fatalf("unexpected fallback reason: %s", got)
    }
}

func TestObjectsToPush(t *testing.T) {
    repo, err := git.Init(memory.NewStorage(), nil)
    if err != nil {