The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Treat zero lookback bounds as the defaults
Claude604eb63ed74b
diff --git a/cli/beacon/internal/gitlink/link.go b/cli/beacon/internal/gitlink/link.goindex 4821c1d0..2035122c 100644--- a/cli/beacon/internal/gitlink/link.go+++ b/cli/beacon/internal/gitlink/link.go@@ -26,7 +26,9 @@ type Options struct {// Rev is the commit to attribute, HEAD when empty.Rev string// LogPath is the runtime JSONL log to read sessions from.- LogPath string+ LogPath string+ // MinLookback and MaxLookback bound Window; zero means DefaultMinLookback and+ // DefaultMaxLookback.MinLookback time.DurationMaxLookback time.Duration// DryRun computes the links without writing the note.@@ -66,9 +68,14 @@ type Result struct {// commit can contain. The floor keeps work that straddled the parent, and the cap keeps a stale// parent from turning a hook into a scan of the endpoint's whole history.func Window(commit Commit, minLookback, maxLookback time.Duration) (since, until time.Time) {+ // Zero means the default, as it does in Options: a caller that sets neither gets the documented+ // window rather than one clamped to the floor.if minLookback <= 0 {minLookback = DefaultMinLookback}+ if maxLookback <= 0 {+ maxLookback = DefaultMaxLookback+ }if maxLookback < minLookback {maxLookback = minLookback}diff --git a/cli/beacon/internal/gitlink/link_test.go b/cli/beacon/internal/gitlink/link_test.goindex 2bc5d361..3e695cb9 100644--- a/cli/beacon/internal/gitlink/link_test.go+++ b/cli/beacon/internal/gitlink/link_test.go@@ -30,7 +30,9 @@ func TestWindow(t *testing.T) {{"root commit uses the cap", commit(0), DefaultMaxLookback},{"parent after the commit (clock skew) keeps the floor", Commit{CommitTime: t0, ParentTime: t0.Add(time.Hour)}, DefaultMinLookback},} {- since, until := Window(tc.commit, 0, DefaultMaxLookback)+ // Zero bounds mean the defaults, which is what a caller that sets neither -- the+ // post-commit hook -- passes.+ since, until := Window(tc.commit, 0, 0)if want := t0.Add(-tc.wantSince); !since.Equal(want) {t.Errorf("%s: since %v, want %v", tc.name, since, want)}@@ -305,3 +307,35 @@ func TestAttributeCapsTheNoteAcrossRuns(t *testing.T) {}}}++func TestWindowExplicitBounds(t *testing.T) {+ c := Commit{CommitTime: t0, ParentTime: t0.Add(-30 * 24 * time.Hour)}+ if since, _ := Window(c, time.Hour, 6*time.Hour); !since.Equal(t0.Add(-6 * time.Hour)) {+ t.Fatalf("max 6h: since %v", since)+ }+ // A max below the min is raised to it.+ if since, _ := Window(c, 3*time.Hour, time.Hour); !since.Equal(t0.Add(-3 * time.Hour)) {+ t.Fatalf("max < min: since %v", since)+ }+}++func TestAttributeZeroOptionsUseTheDefaultWindow(t *testing.T) {+ r := newTestRepo(t)+ ctx := context.Background()+ r.write("a.go", "1")+ r.commitAt("base", t0.Add(-48*time.Hour))+ root := r.open().Root+ logPath := filepath.Join(t.TempDir(), "runtime.jsonl")+ // Ten hours before the commit: past the 2h floor, inside the 24h default.+ writeLog(t, logPath, logEvent{at: t0.Add(-10 * time.Hour), harness: "codex_cli", session: "ten-hours", cwd: root,+ action: "file.modified", filePath: filepath.Join(root, "a.go"), operation: "modify"})+ r.write("a.go", "2")+ r.commitAt("change", t0)+ res, err := Attribute(ctx, r.open(), Options{LogPath: logPath, DryRun: true})+ if err != nil {+ t.Fatal(err)+ }+ if got := keys(res.Added); !reflect.DeepEqual(got, []string{"codex_cli/ten-hours"}) {+ t.Fatalf("links %v (window %v .. %v)", got, res.Since, res.Until)+ }+}