mirror reconciled metadata refs · Entire
mirror reconciled metadata refs
5c0219a→main·
pfleidi·1mo ago·3 files·+66 added/-1 removed
Refresh the configured committed metadata mirror when reconciliation advances the v1 metadata branch.
This keeps v1.1 reads aligned even if push-time sync returns before a later success-path mirror call.
Sessions
8dd71c02ade6View transcript
[?
Centralize Checkpoint Metadata Mirror UpdatesCodex·GPT-5.5·1 step](/content/gh/entireio/cli/session/019e89b2-44f8-7393-aa5f-ca3123a80a76#timeline-8dd71c02ade6/index.html)
Changes
3
cmd/entire/cli/strategy
Mmetadata_reconcile.go+2
Mmetadata_reconcile_test.go+63
docs/architecture
Msessions-and-checkpoints.md+1/-1
182 unmodified lines
183
184
185
186
187
188
189
10 unmodified lines
200
201
202
203
204
205
206
182 unmodified lines
if err := repo.Storer.SetReference(ref); err != nil {
return fmt.Errorf("failed to reset metadata branch to remote: %w", err)
}
MirrorCommittedMetadataRefBestEffort(ctx, repo)
fmt.Fprintln(w, "[entire] Done — local had no checkpoint data, reset to remote")
return nil
}
10 unmodified lines
if err := repo.Storer.SetReference(ref); err != nil {
return fmt.Errorf("failed to update metadata branch: %w", err)
}
MirrorCommittedMetadataRefBestEffort(ctx, repo)
fmt.Fprintln(w, "[entire] Done — all local and remote checkpoints preserved")
return nil
Mcmd/entire/cli/strategy/metadata_reconcile.go+2
239 unmodified lines
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
239 unmodified lines
}
}
// Not parallel: uses t.Chdir().
func TestReconcileDisconnected_MirrorsV1CustomRefAfterRepair(t *testing.T) {
tests := []struct {
name string
setup func(t *testing.T, dir string, run func(args ...string))
}{
{
name: "empty orphan reset",
setup: func(t *testing.T, _ string, run func(args ...string)) {
t.Helper()
run("checkout", "--orphan", "temp-orphan")
run("rm", "-rf", ".")
run("commit", "--allow-empty", "-m", "empty orphan init")
run("branch", "-f", paths.MetadataBranchName, "temp-orphan")
run("checkout", "main")
},
},
{
name: "local checkpoint replay",
setup: func(t *testing.T, dir string, run func(args ...string)) {
t.Helper()
run("checkout", "--orphan", "temp-orphan")
run("rm", "-rf", ".")
localDir := filepath.Join(dir, "ab", "cdef012345")
require.NoError(t, os.MkdirAll(localDir, 0o755))
require.NoError(t, os.WriteFile(
filepath.Join(localDir, "metadata.json"),
[]byte(`{"checkpoint_id":"abcdef012345"}`),
0o644,
))
run("add", ".")
run("commit", "-m", "Checkpoint: abcdef012345")
run("branch", "-f", paths.MetadataBranchName, "temp-orphan")
run("checkout", "main")
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
bareDir := initBareWithMetadataBranch(t)
cloneDir, run := cloneWithConfig(t, bareDir)
tt.setup(t, cloneDir, run)
enableV1CustomRefMirror(t, cloneDir)
t.Chdir(cloneDir)
repo, err := git.PlainOpen(cloneDir)
require.NoError(t, err)
_, ok := v1CustomRefHash(t, repo)
require.False(t, ok, "custom ref should not exist before reconciliation")
require.NoError(t, ReconcileDisconnectedMetadataBranch(t.Context(), repo, metadataOriginRemoteRef(), io.Discard))
localRef, err := repo.Reference(plumbing.NewBranchReferenceName(paths.MetadataBranchName), true)
require.NoError(t, err)
got, ok := v1CustomRefHash(t, repo)
require.True(t, ok, "expected %s to exist", paths.MetadataRefName)
assert.Equal(t, localRef.Hash(), got)
})
}
}
func TestReconcileDisconnected_MultipleLocalCheckpoints(t *testing.T) {
t.Parallel()