GitLabgitlab-org

cli

main
ply9 git calls265 ms105 KiB7 cachedprotocol v2
786 lines36 KiBRaw
1//go:build !integration
3package sync
5import (
6 "bytes"
7 "context"
8 "encoding/json"
9 "errors"
10 "io"
11 "net/http"
12 "os"
13 "path/filepath"
14 "strings"
15 "testing"
16 "time"
18 "github.com/stretchr/testify/assert"
19 "github.com/stretchr/testify/require"
20 "go.uber.org/mock/gomock"
22 "gitlab.com/gitlab-org/cli/internal/commands/govern/internal/fallbacksync"
23 "gitlab.com/gitlab-org/cli/internal/commands/govern/internal/syncstate"
26// writesStdout mocks Executor.ExecWithIO for a command that prints out.
27func writesStdout(out string) func(context.Context, string, []string, []string, io.Reader, io.Writer, io.Writer) error {
28 return func(_ context.Context, _ string, _, _ []string, _ io.Reader, stdout, _ io.Writer) error {
29 _, err := io.WriteString(stdout, out)
30 return err
31 }
34// jsonLines encodes records as JSONL.
35func jsonLines(t *testing.T, records ...any) string {
36 t.Helper()
37 var b strings.Builder
38 for _, r := range records {
39 line, err := json.Marshal(r)
40 require.NoError(t, err)
41 b.Write(line)
42 b.WriteByte('\n')
43 }
44 return b.String()
47func codexSessionMetaLine(id, cwd, remote string) map[string]any {
48 payload := map[string]any{"id": id, "session_id": id, "timestamp": "2026-10-09T01:00:00Z", "cwd": cwd, "cli_version": "0.163.0"}
49 if remote != "" {
50 payload["git"] = map[string]any{"repository_url": remote}
51 }
52 return map[string]any{"timestamp": "2026-10-09T01:00:00Z", "type": "session_meta", "payload": payload}
55// recentTimestamp is within the 90 days GitLab accepts events from, for
56// tests that sync through --all.
57func recentTimestamp() string {
58 return time.Now().Add(-time.Hour).UTC().Format(time.RFC3339)
61func codexItem(ts string, payload map[string]any) map[string]any {
62 return map[string]any{"timestamp": ts, "type": "response_item", "payload": payload}
65// writeCodexRollout writes a Codex rollout under HOME/.codex/sessions and
66// returns its path.
67func writeCodexRollout(t *testing.T, home, id, content string) string {
68 t.Helper()
69 path := filepath.Join(home, ".codex", "sessions", "2026", "10", "09", "rollout-2026-10-09T01-00-00-"+id+".jsonl")
70 require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
71 require.NoError(t, os.WriteFile(path, []byte(content), 0o644))
72 return path
75func TestCodexTranscript_Read(t *testing.T) {
76 t.Parallel()
78 path := filepath.Join(t.TempDir(), "rollout.jsonl")
79 complete := jsonLines(t,
80 codexSessionMetaLine("th-1", "/work", ""),
81 codexItem("2026-10-09T01:00:01Z", map[string]any{"type": "message", "role": "user", "content": []any{map[string]any{"type": "input_text", "text": "# AGENTS.md instructions"}}}),
82 map[string]any{"timestamp": "2026-10-09T01:00:01Z", "type": "event_msg", "payload": map[string]any{"type": "user_message", "message": "fix the flaky test"}},
83 codexItem("2026-10-09T01:00:02Z", map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1", "arguments": "{}"}),
84 codexItem("2026-10-09T01:00:03Z", map[string]any{"type": "function_call_output", "call_id": "call_1"}),
85 codexItem("2026-10-09T01:00:04Z", map[string]any{"type": "custom_tool_call", "name": "apply_patch", "call_id": "call_2", "input": ""}),
86 codexItem("2026-10-09T01:00:05Z", map[string]any{"type": "local_shell_call", "id": "ls_1", "status": "completed"}),
87 )
88 partial := `{"timestamp":"2026-10-09T01:00:06Z","type":"response_item","payload":{"type":"function_call","name":"later","call_id":"call_3"`
89 require.NoError(t, os.WriteFile(path, []byte(complete+partial), 0o644))
91 src := codexTranscript{path: path}
92 data, offset, err := src.read(t.Context(), 0)
93 require.NoError(t, err)
94 assert.Equal(t, "fix the flaky test", data.Goal, "the typed prompt, not injected instructions")
95 assert.Equal(t, time.Date(2026, 10, 9, 1, 0, 0, 0, time.UTC), data.StartedAt)
96 require.Len(t, data.ToolCalls, 3)
97 assert.Equal(t, toolCall{ID: "call_1", Name: "exec_command", Input: json.RawMessage(`{}`), Timestamp: time.Date(2026, 10, 9, 1, 0, 2, 0, time.UTC), CWD: "/work"}, data.ToolCalls[0])
98 assert.Equal(t, "apply_patch", data.ToolCalls[1].Name)
99 assert.Equal(t, toolCall{ID: "ls_1", Name: "shell", Timestamp: time.Date(2026, 10, 9, 1, 0, 5, 0, time.UTC), CWD: "/work"}, data.ToolCalls[2])
100 assert.Equal(t, int64(len(complete)), offset, "a line still being written is left for the next read")
102 f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0o644)
103 require.NoError(t, err)
104 _, err = f.WriteString("}}\n")
105 require.NoError(t, err)
106 require.NoError(t, f.Close())
108 data, _, err = src.read(t.Context(), offset)
109 require.NoError(t, err)
110 require.Len(t, data.ToolCalls, 1)
111 assert.Equal(t, "call_3", data.ToolCalls[0].ID)
114func TestCursorTranscript_Read(t *testing.T) {
115 t.Parallel()
117 path := filepath.Join(t.TempDir(), "conv-1.jsonl")
118 content := jsonLines(t,
119 map[string]any{"role": "user", "message": map[string]any{"content": []any{map[string]any{"type": "text", "text": "<timestamp>Thursday</timestamp>\n<user_query>\nlist the files\n</user_query>"}}}},
120 map[string]any{"role": "assistant", "message": map[string]any{"content": []any{
121 map[string]any{"type": "text", "text": "Listing."},
122 map[string]any{"type": "tool_use", "name": "Shell", "input": map[string]any{"command": "ls"}},
123 map[string]any{"type": "tool_use", "name": "ReadFile", "input": map[string]any{}},
124 }}},
125 map[string]any{"type": "turn_ended", "status": "success"},
126 )
127 require.NoError(t, os.WriteFile(path, []byte(content), 0o644))
128 modified := time.Date(2026, 10, 9, 2, 0, 0, 0, time.UTC)
129 require.NoError(t, os.Chtimes(path, modified, modified))
131 src := cursorTranscript{sessionID: "conv-1", path: path}
132 data, offset, err := src.read(t.Context(), 0)
133 require.NoError(t, err)
134 assert.Equal(t, "list the files", data.Goal)
135 require.Len(t, data.ToolCalls, 2)
136 assert.Equal(t, "Shell", data.ToolCalls[0].Name)
137 assert.Equal(t, "ReadFile", data.ToolCalls[1].Name)
138 assert.NotEqual(t, data.ToolCalls[0].ID, data.ToolCalls[1].ID)
139 assert.True(t, modified.Equal(data.ToolCalls[0].Timestamp), "Cursor records no timestamps, so the transcript's modification time is used")
140 assert.Equal(t, int64(len(content)), offset)
142 again, _, err := src.read(t.Context(), 0)
143 require.NoError(t, err)
144 assert.Equal(t, data.ToolCalls[0].ID, again.ToolCalls[0].ID, "IDs are stable, so re-posting is idempotent")
147func TestWorkspaceCandidates(t *testing.T) {
148 t.Parallel()
150 root := t.TempDir()
151 for _, dir := range []string{"Users/jean/code/ai-tracking", "Users/jean/code/my.repo_v2", "Users/jean/other"} {
152 require.NoError(t, os.MkdirAll(filepath.Join(root, dir), 0o755))
153 }
155 got := workspaceCandidates(root, "Users-jean-code-ai-tracking")
156 require.Len(t, got, 1)
157 assert.Equal(t, filepath.Join(root, "Users", "jean", "code", "ai-tracking"), got[0])
159 got = workspaceCandidates(root, "Users-jean-code-my-repo-v2")
160 require.Len(t, got, 1, "dots and underscores are encoded as dashes")
161 assert.Equal(t, filepath.Join(root, "Users", "jean", "code", "my.repo_v2"), got[0])
163 assert.Empty(t, workspaceCandidates(root, "Users-jean-code-missing"))
166func TestWorkspaceCandidates_FollowsSymlinks(t *testing.T) {
167 t.Parallel()
169 root := t.TempDir()
170 require.NoError(t, os.MkdirAll(filepath.Join(root, "private", "var", "repo"), 0o755))
171 require.NoError(t, os.Symlink(filepath.Join(root, "private", "var"), filepath.Join(root, "var")))
173 got := workspaceCandidates(root, "var-repo")
174 require.Len(t, got, 1, "/var is a symlink on macOS")
175 assert.Equal(t, filepath.Join(root, "var", "repo"), got[0])
178func TestSyncAll_DiscoversCodexSession(t *testing.T) {
179 env := newSyncAllEnv(t, true)
180 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
181 path := writeCodexRollout(t, env.home, "th-1", jsonLines(t,
182 codexSessionMetaLine("th-1", "/work", "git@"+testHost+":my-group/my-project.git"),
183 codexItem(recentTimestamp(), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1"}),
184 ))
186 _, err := env.exec("--all")
187 require.NoError(t, err)
189 assert.Equal(t, []string{"th-1"}, env.fake.sessionsCreated)
190 assert.Equal(t, []string{"codex"}, env.fake.agentTypes)
191 require.Len(t, env.fake.sessionRequests, 1)
192 assert.Equal(t, "0.163.0", env.fake.sessionRequests[0].AgentVersion)
193 assert.Equal(t, 1, env.fake.eventsPosted)
194 meta, err := readSessionMeta("th-1")
195 require.NoError(t, err)
196 assert.Equal(t, sessionMeta{AgentType: "codex", PathWithNamespace: "my-group/my-project", Host: testHost, Transcript: path}, *meta)
198 _, err = env.exec("--all")
199 require.NoError(t, err)
200 assert.Len(t, env.fake.sessionsCreated, 1, "a discovered session is synced once")
203func TestSyncAll_CodexSessionWithoutRemoteUsesGit(t *testing.T) {
204 env := newSyncAllEnv(t, true)
205 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
206 for _, id := range []string{"th-1", "th-2"} {
207 writeCodexRollout(t, env.home, id, jsonLines(t,
208 codexSessionMetaLine(id, "/work/repo", ""),
209 codexItem(recentTimestamp(), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_" + id}),
210 ))
211 }
212 env.mExec.EXPECT().
213 ExecWithIO(gomock.Any(), "git", []string{"-C", "/work/repo", "config", "--get", "remote.origin.url"}, nil, nil, gomock.Any(), gomock.Any()).
214 DoAndReturn(writesStdout("https://" + testHost + "/my-group/my-project.git\n")).
215 Times(1)
217 _, err := env.exec("--all")
218 require.NoError(t, err)
220 assert.ElementsMatch(t, []string{"th-1", "th-2"}, env.fake.sessionsCreated, "git runs once for sessions in the same directory")
223func TestSyncAll_SkipsDiscoveredSessionsOnOtherHosts(t *testing.T) {
224 env := newSyncAllEnv(t, true)
225 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
226 writeCodexRollout(t, env.home, "th-gh", jsonLines(t,
227 codexSessionMetaLine("th-gh", "/work", "git@github.com:someone/repo.git"),
228 codexItem(recentTimestamp(), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1"}),
229 ))
231 _, err := env.exec("--all")
232 require.NoError(t, err)
234 assert.Empty(t, env.fake.projectLookups, "a repository on a host glab is not logged in to is not uploaded")
235 _, err = readSessionMeta("th-gh")
236 require.ErrorIs(t, err, errNoSessionMeta)
237 status := readStatus(t)
238 assert.Empty(t, status.Errors)
239 assert.Equal(t, []string{withoutRemoteReason("codex")}, status.Skipped)
242func TestSyncAll_DoesNotReportIdleDiscoveredSessionOnOtherHost(t *testing.T) {
243 env := newSyncAllEnv(t, true)
244 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
245 path := writeCodexRollout(t, env.home, "th-gh", jsonLines(t,
246 codexSessionMetaLine("th-gh", "/work", "git@github.com:someone/repo.git"),
247 codexItem(recentTimestamp(), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1"}),
248 ))
249 idle := time.Now().Add(-2 * idleCompleteAfter)
250 require.NoError(t, os.Chtimes(path, idle, idle))
252 _, err := env.exec("--all")
253 require.NoError(t, err)
255 assert.Empty(t, readStatus(t).Skipped, "a session discovered on every run is not reported once idle")
258func TestSyncAll_SkipsCodexSubagentThreads(t *testing.T) {
259 env := newSyncAllEnv(t, true)
260 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
261 meta := codexSessionMetaLine("th-child", "/work", "git@"+testHost+":my-group/my-project.git")
262 meta["payload"].(map[string]any)["parent_thread_id"] = "th-parent" //nolint:forcetypeassert // built above
263 writeCodexRollout(t, env.home, "th-child", jsonLines(t, meta))
265 _, err := env.exec("--all")
266 require.NoError(t, err)
268 _, err = readSessionMeta("th-child")
269 require.ErrorIs(t, err, errNoSessionMeta)
272func TestSyncAll_DoesNotDiscoverAgentsThatAreNotEnabled(t *testing.T) {
273 env := newSyncAllEnv(t, true)
274 writeCodexRollout(t, env.home, "th-1", jsonLines(t,
275 codexSessionMetaLine("th-1", "/work", "git@"+testHost+":my-group/my-project.git"),
276 codexItem(recentTimestamp(), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1"}),
277 ))
279 _, err := env.exec("--all")
280 require.NoError(t, err)
282 assert.Empty(t, env.fake.sessionsCreated)
283 _, err = readSessionMeta("th-1")
284 require.ErrorIs(t, err, errNoSessionMeta)
287func TestSyncAll_PausesDiscoveredAgentOnceDisabled(t *testing.T) {
288 env := newSyncAllEnv(t, true)
289 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
290 writeCodexRollout(t, env.home, "th-1", jsonLines(t,
291 codexSessionMetaLine("th-1", "/work", "git@"+testHost+":my-group/my-project.git"),
292 ))
293 _, err := env.exec("--all")
294 require.NoError(t, err)
295 _, err = readSessionMeta("th-1")
296 require.NoError(t, err, "recorded on the first run")
298 require.NoError(t, fallbacksync.SetDiscoveredAgents(nil))
299 _, err = env.exec("--all")
300 require.NoError(t, err)
302 assert.Equal(t, []string{"codex: codex is not enabled; run 'glab minder setup --agents codex' to enable it"}, readStatus(t).Paused)
305func TestSyncAll_DiscoversCursorSession(t *testing.T) {
306 env := newSyncAllEnv(t, true)
307 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"cursor"}))
309 workspace := filepath.Join(t.TempDir(), "my.repo")
310 require.NoError(t, os.MkdirAll(workspace, 0o755))
311 slug := nonAlphanumeric.ReplaceAllString(strings.TrimPrefix(workspace, string(filepath.Separator)), "-")
312 path := filepath.Join(env.home, ".cursor", "projects", slug, "agent-transcripts", "conv-1", "conv-1.jsonl")
313 require.NoError(t, os.MkdirAll(filepath.Join(filepath.Dir(path), "subagents"), 0o755))
314 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
315 map[string]any{"role": "user", "message": map[string]any{"content": []any{map[string]any{"type": "text", "text": "<user_query>list the files</user_query>"}}}},
316 map[string]any{"role": "assistant", "message": map[string]any{"content": []any{map[string]any{"type": "tool_use", "name": "Shell"}}}},
317 )), 0o644))
318 env.mExec.EXPECT().
319 ExecWithIO(gomock.Any(), "git", gomock.Any(), nil, nil, gomock.Any(), gomock.Any()).
320 DoAndReturn(func(_ context.Context, _ string, args, _ []string, _ io.Reader, stdout, _ io.Writer) error {
321 resolved, err := filepath.EvalSymlinks(args[1])
322 if err != nil {
323 return err
324 }
325 want, err := filepath.EvalSymlinks(workspace)
326 if err != nil || resolved != want {
327 return errors.New("not the workspace")
328 }
329 _, err = io.WriteString(stdout, "git@"+testHost+":my-group/my-project.git\n")
330 return err
331 })
333 _, err := env.exec("--all")
334 require.NoError(t, err)
336 assert.Equal(t, []string{"conv-1"}, env.fake.sessionsCreated)
337 assert.Equal(t, []string{"cursor"}, env.fake.agentTypes)
338 require.Len(t, env.fake.sessionRequests, 1)
339 assert.Empty(t, env.fake.sessionRequests[0].AgentVersion, "Cursor does not record its version")
340 assert.Equal(t, []string{eventUserInput, eventToolInvoked}, eventNames(env.fake.events))
343func TestCodexTranscript_NamespacedToolNames(t *testing.T) {
344 t.Parallel()
346 tests := []struct {
347 name string
348 item map[string]any
349 wantName string
350 wantSpace string
351 }{
352 {
353 name: "a built-in tool has no namespace and keeps its name",
354 item: map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1"},
355 wantName: "exec_command",
356 },
357 {
358 name: "an MCP tool is qualified the way Codex names it for the model",
359 item: map[string]any{"type": "function_call", "name": "click", "namespace": "mcp__computer_use", "call_id": "call_1"},
360 wantName: "mcp__computer_use__click",
361 wantSpace: "mcp__computer_use",
362 },
363 {
364 name: "older rollouts end the namespace with the separator, which both the name and the namespace drop",
365 item: map[string]any{"type": "function_call", "name": "js", "namespace": "mcp__node_repl__", "call_id": "call_1"},
366 wantName: "mcp__node_repl__js",
367 wantSpace: "mcp__node_repl",
368 },
369 {
370 name: "a server name that ends in an underscore keeps it",
371 item: map[string]any{"type": "function_call", "name": "js", "namespace": "mcp__foo_", "call_id": "call_1"},
372 wantName: "mcp__foo___js",
373 wantSpace: "mcp__foo_",
374 },
375 {
376 name: "older rollouts only lose the separator after such a server name",
377 item: map[string]any{"type": "function_call", "name": "js", "namespace": "mcp__foo___", "call_id": "call_1"},
378 wantName: "mcp__foo___js",
379 wantSpace: "mcp__foo_",
380 },
381 {
382 name: "a custom tool call carries its namespace too",
383 item: map[string]any{"type": "custom_tool_call", "name": "spawn_agent", "namespace": "collaboration", "call_id": "call_1", "input": ""},
384 wantName: "collaboration__spawn_agent",
385 wantSpace: "collaboration",
386 },
387 {
388 name: "a namespace that is only separators counts as none",
389 item: map[string]any{"type": "function_call", "name": "js", "namespace": "__", "call_id": "call_1"},
390 wantName: "js",
391 wantSpace: "",
392 },
393 }
395 for _, tt := range tests {
396 t.Run(tt.name, func(t *testing.T) {
397 t.Parallel()
399 path := filepath.Join(t.TempDir(), "rollout.jsonl")
400 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
401 codexSessionMetaLine("th-1", "/work", ""),
402 codexItem("2026-10-09T01:00:02Z", tt.item),
403 codexItem("2026-10-09T01:00:03Z", map[string]any{"type": "function_call_output", "call_id": "call_1"}),
404 )), 0o644))
406 data, _, err := codexTranscript{path: path}.read(t.Context(), 0)
407 require.NoError(t, err)
408 require.Len(t, data.ToolCalls, 1)
409 assert.Equal(t, tt.wantName, data.ToolCalls[0].Name)
410 assert.Equal(t, tt.wantSpace, data.ToolCalls[0].Namespace)
411 require.Len(t, data.ToolResults, 1)
412 assert.Equal(t, tt.wantName, data.ToolResults[0].Name, "the result names the call it answers")
413 assert.Equal(t, tt.wantSpace, data.ToolResults[0].Namespace)
414 })
415 }
418func TestCodexTranscript_RichEvents(t *testing.T) {
419 t.Parallel()
421 ts := func(s int) string { return time.Date(2026, 10, 9, 1, 0, s, 0, time.UTC).Format(time.RFC3339) }
422 path := filepath.Join(t.TempDir(), "rollout.jsonl")
423 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
424 codexSessionMetaLine("th-1", "/work", ""),
425 map[string]any{"timestamp": ts(0), "type": "turn_context", "payload": map[string]any{"model": "gpt-5.5-codex"}},
426 map[string]any{"timestamp": ts(1), "type": "event_msg", "payload": map[string]any{"type": "user_message", "message": "run the tests"}},
427 codexItem(ts(2), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1", "arguments": `{"cmd":"go test ./..."}`}),
428 codexItem(ts(5), map[string]any{"type": "function_call_output", "call_id": "call_1", "output": "ok"}),
429 codexItem(ts(6), map[string]any{"type": "custom_tool_call", "name": "apply_patch", "call_id": "call_2", "input": "*** Begin Patch"}),
430 map[string]any{"timestamp": ts(7), "type": "event_msg", "payload": map[string]any{"type": "token_count", "info": map[string]any{
431 "last_token_usage": map[string]any{"input_tokens": 120, "cached_input_tokens": 100, "output_tokens": 30},
432 }}},
433 map[string]any{"timestamp": ts(8), "type": "event_msg", "payload": map[string]any{"type": "token_count", "info": nil}},
434 )), 0o644))
436 data, _, err := codexTranscript{sessionID: "th-1", path: path}.read(t.Context(), 0)
437 require.NoError(t, err)
439 require.Len(t, data.Prompts, 1)
440 assert.Equal(t, "run the tests", data.Prompts[0].Text)
441 require.Len(t, data.ToolCalls, 2)
442 assert.JSONEq(t, `{"cmd":"go test ./..."}`, string(data.ToolCalls[0].Input))
443 assert.JSONEq(t, `{"input":"*** Begin Patch"}`, string(data.ToolCalls[1].Input), "custom tool input is free text")
444 require.Len(t, data.ToolResults, 1)
445 assert.Equal(t, toolResult{
446 CallID: "call_1", Name: "exec_command", Outcome: "completed",
447 Duration: 3 * time.Second, Timestamp: time.Date(2026, 10, 9, 1, 0, 5, 0, time.UTC), CWD: "/work",
448 }, data.ToolResults[0], "Codex does not record whether a call succeeded")
449 require.Len(t, data.Responses, 1, "a token count without usage is not a response")
450 assert.Equal(t, "gpt-5.5-codex", data.Responses[0].Model)
451 assert.Equal(t, tokenUsage{InputTokens: 120, OutputTokens: 30, CacheReadInputTokens: 100}, data.Responses[0].Usage)
454func TestCodexTranscript_Dirs(t *testing.T) {
455 t.Parallel()
457 ts := func(s int) string { return time.Date(2026, 10, 9, 1, 0, s, 0, time.UTC).Format(time.RFC3339) }
458 path := filepath.Join(t.TempDir(), "rollout.jsonl")
459 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
460 codexSessionMetaLine("th-1", "/work/a/", ""),
461 map[string]any{"timestamp": ts(1), "type": "event_msg", "payload": map[string]any{"type": "user_message", "message": "clone b"}},
462 codexItem(ts(2), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_abs", "arguments": `{"cmd":"git status","workdir":"/work/x/../b"}`}),
463 codexItem(ts(3), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_rel", "arguments": `{"cmd":"ls","workdir":"sub"}`}),
464 codexItem(ts(4), map[string]any{"type": "local_shell_call", "id": "ls_1", "action": map[string]any{"type": "exec", "working_directory": "/work/c"}}),
465 codexItem(ts(5), map[string]any{"type": "function_call_output", "call_id": "call_abs"}),
466 map[string]any{"timestamp": ts(6), "type": "turn_context", "payload": map[string]any{"model": "gpt-5.5-codex", "cwd": "/work/b/"}},
467 map[string]any{"timestamp": ts(7), "type": "event_msg", "payload": map[string]any{"type": "user_message", "message": "now in b"}},
468 map[string]any{"timestamp": ts(8), "type": "event_msg", "payload": map[string]any{"type": "token_count", "info": map[string]any{
469 "last_token_usage": map[string]any{"input_tokens": 1, "output_tokens": 1},
470 }}},
471 )), 0o644))
473 data, _, err := codexTranscript{sessionID: "th-1", path: path}.read(t.Context(), 0)
474 require.NoError(t, err)
476 require.Len(t, data.ToolCalls, 3)
477 assert.Equal(t, "/work/b", data.ToolCalls[0].CWD, "an absolute workdir, cleaned")
478 assert.Equal(t, "/work/a/sub", data.ToolCalls[1].CWD, "a workdir relative to the turn")
479 assert.Equal(t, "/work/c", data.ToolCalls[2].CWD, "a local shell call's working directory")
480 require.Len(t, data.ToolResults, 1)
481 assert.Equal(t, "/work/b", data.ToolResults[0].CWD, "a result runs where its call did")
482 require.Len(t, data.Prompts, 2)
483 assert.Equal(t, "/work/a", data.Prompts[0].CWD, "folders are cleaned, so a trailing slash makes no difference")
484 assert.Equal(t, "/work/b", data.Prompts[1].CWD, "a later turn's folder")
485 require.Len(t, data.Responses, 1)
486 assert.Equal(t, "/work/b", data.Responses[0].CWD)
489func TestCodexTranscript_DirUnknownBeforeTurnWhenReadingMidRollout(t *testing.T) {
490 t.Parallel()
492 path := filepath.Join(t.TempDir(), "rollout.jsonl")
493 head := jsonLines(t, codexSessionMetaLine("th-1", "/work/a", ""))
494 require.NoError(t, os.WriteFile(path, []byte(head+jsonLines(t,
495 map[string]any{"timestamp": "2026-10-09T01:00:01Z", "type": "event_msg", "payload": map[string]any{"type": "user_message", "message": "go on"}},
496 codexItem("2026-10-09T01:00:02Z", map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1", "arguments": `{"cmd":"ls","workdir":"sub"}`}),
497 )), 0o644))
499 data, _, err := codexTranscript{sessionID: "th-1", path: path}.read(t.Context(), int64(len(head)))
500 require.NoError(t, err)
502 require.Len(t, data.Prompts, 1)
503 assert.Empty(t, data.Prompts[0].CWD)
504 require.Len(t, data.ToolCalls, 1)
505 assert.Empty(t, data.ToolCalls[0].CWD, "a relative workdir without the turn's folder is no folder")
508func TestCodexTranscript_PaginatedPrompts(t *testing.T) {
509 t.Parallel()
511 meta := codexSessionMetaLine("th-1", "/work", "")
512 meta["payload"].(map[string]any)["history_mode"] = "paginated" //nolint:forcetypeassert // built above
513 user := func(text string) map[string]any {
514 return codexItem("2026-10-09T01:00:01Z", map[string]any{"type": "message", "role": "user", "content": []any{map[string]any{"type": "input_text", "text": text}}})
515 }
516 path := filepath.Join(t.TempDir(), "rollout.jsonl")
517 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
518 meta,
519 user("# AGENTS.md instructions for /work"),
520 user("<environment_context>\n<cwd>/work</cwd>\n</environment_context>"),
521 user("fix the flaky test"),
522 )), 0o644))
524 data, _, err := codexTranscript{sessionID: "th-1", path: path}.read(t.Context(), 0)
525 require.NoError(t, err)
527 require.Len(t, data.Prompts, 1, "paginated rollouts record prompts as user messages, after injected context")
528 assert.Equal(t, "fix the flaky test", data.Prompts[0].Text)
529 assert.Equal(t, "fix the flaky test", data.Goal)
532func TestCursorTranscript_RichEvents(t *testing.T) {
533 t.Parallel()
535 path := filepath.Join(t.TempDir(), "conv-1.jsonl")
536 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
537 map[string]any{"role": "user", "message": map[string]any{"content": []any{map[string]any{"type": "text", "text": "<user_query>list the files</user_query>"}}}},
538 map[string]any{"role": "assistant", "message": map[string]any{"content": []any{map[string]any{"type": "tool_use", "name": "Shell", "input": map[string]any{"command": "ls"}}}}},
539 map[string]any{"role": "user", "message": map[string]any{"content": []any{map[string]any{"type": "text", "text": "<user_query>now count them</user_query>"}}}},
540 )), 0o644))
542 data, _, err := cursorTranscript{sessionID: "conv-1", path: path}.read(t.Context(), 0)
543 require.NoError(t, err)
545 require.Len(t, data.Prompts, 2)
546 assert.Equal(t, "list the files", data.Prompts[0].Text)
547 assert.Equal(t, "now count them", data.Prompts[1].Text)
548 assert.NotEqual(t, data.Prompts[0].ID, data.Prompts[1].ID)
549 require.Len(t, data.ToolCalls, 1)
550 assert.JSONEq(t, `{"command":"ls"}`, string(data.ToolCalls[0].Input))
551 assert.Empty(t, data.ToolResults, "Cursor records no tool results")
554func TestSyncAll_CompletesOldSyncedSessionOnGitLab(t *testing.T) {
555 env := newSyncAllEnv(t, true)
556 path := env.writeClaudeSession(t, "sess-1", "my-group/my-project", "toolu_1", "toolu_2")
557 content, err := os.ReadFile(path)
558 require.NoError(t, err)
559 firstLine := int64(bytes.IndexByte(content, '\n') + 1)
560 require.NoError(t, syncstate.WritePosition("sess-1", firstLine))
561 old := time.Now().Add(-100 * 24 * time.Hour)
562 require.NoError(t, os.Chtimes(path, old, old))
564 _, err = env.exec("--all")
565 require.NoError(t, err)
567 assert.Equal(t, 1, env.fake.completed, "a session that already exists on GitLab is still completed there")
570func TestSyncAll_SkipsSessionsTooOldForGitLab(t *testing.T) {
571 env := newSyncAllEnv(t, true)
572 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
573 old := time.Now().Add(-100 * 24 * time.Hour)
574 path := writeCodexRollout(t, env.home, "th-old", jsonLines(t,
575 codexSessionMetaLine("th-old", "/work", "git@"+testHost+":my-group/my-project.git"),
576 codexItem(old.Format(time.RFC3339), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1"}),
577 ))
578 require.NoError(t, os.Chtimes(path, old, old))
580 _, err := env.exec("--all")
581 require.NoError(t, err)
583 assert.Empty(t, env.fake.sessionsCreated, "a session GitLab would accept no events for is not created empty")
584 meta, err := readSessionMeta("th-old")
585 require.NoError(t, err)
586 assert.NotNil(t, meta.CompletedAt, "it is not checked again")
589func TestWorkspaceCandidates_DotAndUnderscoreDirectories(t *testing.T) {
590 t.Parallel()
592 root := t.TempDir()
593 require.NoError(t, os.MkdirAll(filepath.Join(root, "Users", "jean", ".config", "proj"), 0o755))
594 require.NoError(t, os.MkdirAll(filepath.Join(root, "Users", "jean", "_work", "app"), 0o755))
596 got := workspaceCandidates(root, "Users-jean--config-proj")
597 require.Len(t, got, 1, "a leading dot inside the path is encoded as a dash")
598 assert.Equal(t, filepath.Join(root, "Users", "jean", ".config", "proj"), got[0])
600 got = workspaceCandidates(root, "Users-jean--work-app")
601 require.Len(t, got, 1, "so is a leading underscore")
602 assert.Equal(t, filepath.Join(root, "Users", "jean", "_work", "app"), got[0])
605func TestWorkspaceCandidates_Ambiguous(t *testing.T) {
606 t.Parallel()
608 root := t.TempDir()
609 require.NoError(t, os.MkdirAll(filepath.Join(root, "code", "cli", "docs"), 0o755))
610 require.NoError(t, os.MkdirAll(filepath.Join(root, "code", "cli-docs"), 0o755))
612 got := workspaceCandidates(root, "code-cli-docs")
613 assert.ElementsMatch(t, []string{filepath.Join(root, "code", "cli", "docs"), filepath.Join(root, "code", "cli-docs")}, got)
616// writeAmbiguousCursorSession creates code/cli/docs and code/cli-docs, which
617// Cursor encodes to the same folder name, and a session in that folder whose
618// tool call reads readPath. It returns the sibling directory, code/cli-docs.
619func (e *syncAllEnv) writeAmbiguousCursorSession(t *testing.T, readPath func(base string) string) string {
620 t.Helper()
621 base := t.TempDir()
622 nested := filepath.Join(base, "code", "cli", "docs")
623 sibling := filepath.Join(base, "code", "cli-docs")
624 require.NoError(t, os.MkdirAll(nested, 0o755))
625 require.NoError(t, os.MkdirAll(sibling, 0o755))
626 resolvedBase, err := filepath.EvalSymlinks(base)
627 require.NoError(t, err)
628 slug := nonAlphanumeric.ReplaceAllString(strings.TrimPrefix(filepath.Join(resolvedBase, "code", "cli-docs"), string(filepath.Separator)), "-")
630 path := filepath.Join(e.home, ".cursor", "projects", slug, "agent-transcripts", "conv-1", "conv-1.jsonl")
631 require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
632 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
633 map[string]any{"role": "user", "message": map[string]any{"content": []any{map[string]any{"type": "text", "text": "<user_query>update the docs</user_query>"}}}},
634 map[string]any{"role": "assistant", "message": map[string]any{"content": []any{map[string]any{"type": "tool_use", "name": "Read", "input": map[string]any{"path": readPath(resolvedBase)}}}}},
635 )), 0o644))
636 return filepath.Join(resolvedBase, "code", "cli-docs")
639func TestSyncAll_SkipsAmbiguousCursorWorkspace(t *testing.T) {
640 env := newSyncAllEnv(t, true)
641 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"cursor"}))
642 env.writeAmbiguousCursorSession(t, func(string) string { return "README.md" })
644 // The executor has no expectations: no remote is read for an ambiguous workspace.
645 _, err := env.exec("--all")
646 require.NoError(t, err)
648 assert.Empty(t, env.fake.sessionsCreated, "a session must not be uploaded to a project that may not be its own")
649 status := readStatus(t)
650 assert.Empty(t, status.Errors)
651 require.Len(t, status.Skipped, 1)
652 assert.Contains(t, status.Skipped[0], "matches 2 directories")
655func TestSyncAll_ConfirmsAmbiguousCursorWorkspaceFromToolPaths(t *testing.T) {
656 env := newSyncAllEnv(t, true)
657 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"cursor"}))
658 sibling := env.writeAmbiguousCursorSession(t, func(base string) string {
659 return filepath.Join(base, "code", "cli-docs", "README.md")
660 })
661 env.mExec.EXPECT().
662 ExecWithIO(gomock.Any(), "git", []string{"-C", sibling, "config", "--get", "remote.origin.url"}, nil, nil, gomock.Any(), gomock.Any()).
663 DoAndReturn(writesStdout("git@" + testHost + ":my-group/my-project.git\n"))
665 _, err := env.exec("--all")
666 require.NoError(t, err)
668 assert.Equal(t, []string{"conv-1"}, env.fake.sessionsCreated, "a path the session read confirms which directory it ran in")
671func TestSyncAll_AgentTypeNotSupportedByGitLab(t *testing.T) {
672 env := newSyncAllEnv(t, true)
673 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
674 // What GitLab versions without the agent type answer.
675 env.fake.identityStatus = http.StatusBadRequest
676 env.fake.identityBody = `{"error":"agent_type does not have a valid value"}`
677 for _, id := range []string{"th-1", "th-2"} {
678 writeCodexRollout(t, env.home, id, jsonLines(t,
679 codexSessionMetaLine(id, "/work", "git@"+testHost+":my-group/my-project.git"),
680 codexItem(recentTimestamp(), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_" + id}),
681 ))
682 }
684 _, err := env.exec("--all")
685 require.NoError(t, err)
687 status := readStatus(t)
688 assert.Empty(t, status.Errors, "an agent the GitLab version doesn't support yet is expected, not a failure")
689 assert.Equal(t, []string{"codex on " + testHost}, status.AgentTypeNotSupported)
690 assert.Equal(t, 1, env.fake.identityRequests)
691 for _, id := range []string{"th-1", "th-2"} {
692 meta, err := readSessionMeta(id)
693 require.NoError(t, err)
694 assert.NotNil(t, meta.CompletedAt, "the session is not retried")
695 }
697 _, err = env.exec("--all")
698 require.NoError(t, err)
699 assert.Equal(t, 1, env.fake.identityRequests, "and not uploaded in a burst after an upgrade")
702// writeCursorSessionFor writes a Cursor session for the workspace slug of
703// workspace, whose tool call reads readPath, after creating existing.
704func (e *syncAllEnv) writeCursorSessionFor(t *testing.T, workspace, existing, readPath string) {
705 t.Helper()
706 require.NoError(t, os.MkdirAll(existing, 0o755))
707 slug := nonAlphanumeric.ReplaceAllString(strings.TrimPrefix(workspace, string(filepath.Separator)), "-")
708 path := filepath.Join(e.home, ".cursor", "projects", slug, "agent-transcripts", "conv-1", "conv-1.jsonl")
709 require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
710 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
711 map[string]any{"role": "user", "message": map[string]any{"content": []any{map[string]any{"type": "text", "text": "<user_query>update the docs</user_query>"}}}},
712 map[string]any{"role": "assistant", "message": map[string]any{"content": []any{map[string]any{"type": "tool_use", "name": "Read", "input": map[string]any{"path": readPath}}}}},
713 )), 0o644))
716func TestSyncAll_SkipsCursorWorkspaceThatMoved(t *testing.T) {
717 env := newSyncAllEnv(t, true)
718 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"cursor"}))
719 base, err := filepath.EvalSymlinks(t.TempDir())
720 require.NoError(t, err)
721 // code/cli-docs was moved away; code/cli/docs, which encodes the same, remains.
722 moved := filepath.Join(base, "code", "cli-docs")
723 env.writeCursorSessionFor(t, moved, filepath.Join(base, "code", "cli", "docs"), filepath.Join(moved, "README.md"))
725 // The executor has no expectations: the remaining directory's remote is not read.
726 _, err = env.exec("--all")
727 require.NoError(t, err)
729 assert.Empty(t, env.fake.sessionsCreated, "the only matching directory is not the one the session used")
730 status := readStatus(t)
731 require.Len(t, status.Skipped, 1)
732 assert.Contains(t, status.Skipped[0], "may have moved")
735func TestSyncAll_SyncsCursorWorkspaceConfirmedByToolPaths(t *testing.T) {
736 env := newSyncAllEnv(t, true)
737 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"cursor"}))
738 base, err := filepath.EvalSymlinks(t.TempDir())
739 require.NoError(t, err)
740 workspace := filepath.Join(base, "code", "cli-docs")
741 env.writeCursorSessionFor(t, workspace, workspace, filepath.Join(workspace, "README.md"))
742 env.mExec.EXPECT().
743 ExecWithIO(gomock.Any(), "git", []string{"-C", workspace, "config", "--get", "remote.origin.url"}, nil, nil, gomock.Any(), gomock.Any()).
744 DoAndReturn(writesStdout("git@" + testHost + ":my-group/my-project.git\n"))
746 _, err = env.exec("--all")
747 require.NoError(t, err)
749 assert.Equal(t, []string{"conv-1"}, env.fake.sessionsCreated)
752func TestCodexTranscript_ObjectArguments(t *testing.T) {
753 t.Parallel()
755 path := filepath.Join(t.TempDir(), "rollout.jsonl")
756 require.NoError(t, os.WriteFile(path, []byte(jsonLines(t,
757 codexSessionMetaLine("th-1", "/work", ""),
758 codexItem("2026-10-09T01:00:02Z", map[string]any{"type": "tool_search_call", "call_id": "call_1", "execution": "client", "arguments": map[string]any{"query": "deploy"}}),
759 )), 0o644))
761 data, _, err := codexTranscript{sessionID: "th-1", path: path}.read(t.Context(), 0)
762 require.NoError(t, err)
764 require.Len(t, data.ToolCalls, 1, "a call whose arguments are an object is not dropped")
765 assert.Equal(t, "tool_search", data.ToolCalls[0].Name)
766 assert.JSONEq(t, `{"query":"deploy"}`, string(data.ToolCalls[0].Input))
769func TestSyncAll_CodexDiscoverySkipsUnreadableDirectories(t *testing.T) {
770 env := newSyncAllEnv(t, true)
771 require.NoError(t, fallbacksync.SetDiscoveredAgents([]string{"codex"}))
772 writeCodexRollout(t, env.home, "th-1", jsonLines(t,
773 codexSessionMetaLine("th-1", "/work", "git@"+testHost+":my-group/my-project.git"),
774 codexItem(recentTimestamp(), map[string]any{"type": "function_call", "name": "exec_command", "call_id": "call_1"}),
775 ))
776 unreadable := filepath.Join(env.home, ".codex", "sessions", "2026", "10", "08")
777 require.NoError(t, os.MkdirAll(unreadable, 0o755))
778 require.NoError(t, os.Chmod(unreadable, 0o000))
779 t.Cleanup(func() { _ = os.Chmod(unreadable, 0o755) })
781 _, err := env.exec("--all")
782 require.NoError(t, err)
784 assert.Equal(t, []string{"th-1"}, env.fake.sessionsCreated, "one unreadable directory does not stop discovery")
785 assert.Empty(t, readStatus(t).Errors)
Diagnostics9 git calls · 265 ms
CallStatusSizeTime0265 ms
discover200185 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=185
git.server.agent=git/2.56.g1891de4-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=185
git.pkt.payload.max=35
ls-refs20058 KiB · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:0 · deepen 1020032 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetchtree:02001.8 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=1857
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=dce174ff8c632a19d17eea99c8a9b7c37fb2b592
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1857
git.pkt.payload.max=1830
git.sideband.band1.bytes=1830
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=1830
git.pack.trailer=fb03183b7909876778f740d196d7516811003517
Open pack map
fetchtree:0200261 B · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=261
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=3bb9946301aa8c0dc8d202b83bc9f84bf0400f6d
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=261
git.pkt.payload.max=234
git.sideband.band1.bytes=234
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=234
git.pack.trailer=e0a52f164f79506da6b0dcc275ed62911f5383bf
Open pack map
fetchtree:0200139 B · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=139
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=f91da6c620e9fe39086f689d1ae91b87356cda50
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=139
git.pkt.payload.max=112
git.sideband.band1.bytes=112
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=112
git.pack.trailer=a35549813b2a01d473947912b5773e993ce7c2e2
Open pack map
fetchtree:0200638 B · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=638
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=02089b627a9895becfd23127f25e46df629ce9b2
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=638
git.pkt.payload.max=611
git.sideband.band1.bytes=611
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=611
git.pack.trailer=f2a6246e346c2fa34e54ecb04cb1dd1c524f65bc
Open pack map
fetch2007.0 KiB250 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=249
git.response.bytes=7191
git.response.cache=MISS
git.response.duration_ms=250
git.fetch.wants=4107027bf06d822d07edfc37a46289cff2b2666e
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=7191
git.pkt.payload.max=7164
git.sideband.band1.bytes=7164
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://gitlab.com/gitlab-org/cli
Ref
refs/heads/main
Commit
0dd7574dce9e385c5c30540e6c15657adc6bdce9
cf-ray
a5e2ee90bf6477be
Request
96881d56…
Protocol
v2 · sha1
Agent
git/2.56.g1891de4-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format