# Plumb SourceHEAD through bridge + render in human output

`6a04be3`·  
  
Soph·2mo ago·3 files·+13 added/-2 removed

internalbridge.ProbeResult adds a SourceHEAD field; bridge.SyncResult's  
ExecutionSummary gets one too. CLI JSON output picks them up  
automatically through the From* conversions.

Result.Lines() and ProbeResult.Lines() emit a "source-head: <ref>" line  
when non-empty, matching the existing "source: <url>" / "ref-prefixes"  
style. The line gives users a quick way to see the source's default  
branch alongside the other discovery metadata.

Refs #45.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

## Sessions

e81d5fee3471View transcript

## Changes

3

- internal/syncer
  
  - Mintegration_test.go+3/-2
  
  - Msyncer.go+6

- internalbridge
  
  - Mmodel.go+4

```
4096 unmodified lines

4097
4098
4099
4100
4100
4101
4102
4103
4104
4105
4106
4106
4107
4108
4109
4110

4096 unmodified lines

// lsRefsCoversHead returns true when prefixes is empty (matches everything)
// or any prefix is a prefix of "HEAD".
// or any prefix is "HEAD" itself (the only way ref-prefix syntax selects HEAD,
// since "H", "HE" etc. aren't valid ref names a client would use).
func lsRefsCoversHead(prefixes []string) bool {
	if len(prefixes) == 0 {
		return true
	}
	for _, p := range prefixes {
		if strings.HasPrefix("HEAD", p) {
			if p == "HEAD" {
				return true
			}
		}
	}
}
```

Minternal/syncer/integration_test.go+3/-2

```
180 unmodified lines

181
182
183
184
185
186
187
188
189
21 unmodified lines

211
212
213
214
215
216
217
218
219

180 unmodified lines

if r.Batching && len(r.TempRefs) > 0 {
		lines = append(lines, "batching: temp-refs="+strings.Join(r.TempRefs, ","))
	}
	if r.SourceHEAD != "" {
		lines = append(lines, "source-head: "+r.SourceHEAD.String())
	}
	return lines
}

21 unmodified lines

if len(r.RefPrefixes) > 0 {
		lines = append(lines, "ref-prefixes: "+strings.Join(r.RefPrefixes, ", "))
	}
	if r.SourceHEAD != "" {
		lines = append(lines, "source-head: "+r.SourceHEAD.String())
	}
	if len(r.Capabilities) > 0 {
		lines = append(lines, "source-capabilities: "+strings.Join(r.Capabilities, ", "))
	}
```

Minternal/syncer/syncer.go+6

```
86 unmodified lines

87
88
89
90
91
92
93
20 unmodified lines

114
115
116
117
118
119
120
17 unmodified lines

138
139
140
141
142
143
144
21 unmodified lines

166
167
168
169
170
171
172

86 unmodified lines

Capabilities  []string    `json:"sourceCapabilities"`
	TargetCaps    []string    `json:"targetCapabilities,omitempty"`
	Refs          []RefInfo   `json:"refs"`
	SourceHEAD    string      `json:"sourceHead,omitempty"`
	Stats         Stats       `json:"stats"`
	Measurement   Measurement `json:"measurement"`
}
20 unmodified lines

TransferMode       string       `json:"transferMode"`
	Reason             string       `json:"reason"`
	BootstrapSuggested bool         `json:"bootstrapSuggested"`
	SourceHEAD         string       `json:"sourceHead,omitempty"`
	Batch              BatchSummary `json:"batch"`
}

17 unmodified lines

Capabilities:  append([]string(nil), result.Capabilities...),
		TargetCaps:    append([]string(nil), result.TargetCaps...),
		Refs:          make([]RefInfo, 0, len(result.Refs)),
		SourceHEAD:    result.SourceHEAD.String(),
		Stats:         FromStats(result.Stats),
		Measurement:   FromMeasurement(result.Measurement),
	}
21 unmodified lines

TransferMode:       result.RelayMode,
		Reason:             result.RelayReason,
		BootstrapSuggested: result.BootstrapSuggested,
		SourceHEAD:         result.SourceHEAD.String(),
		Batch: BatchSummary{
			Enabled: result.Batching,
			Planned: result.PlannedBatchCount,
```
