Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

test(git-hooks): keep the abandoned-upload test off the note-write timer (#1152)

kyle-elliott-asymptotec5196281d6a2
diff --git a/cli/beacon/cmd/git_budget_test.go b/cli/beacon/cmd/git_budget_test.go
index 5687ff26..40ead302 100644
--- a/cli/beacon/cmd/git_budget_test.go
+++ b/cli/beacon/cmd/git_budget_test.go
@@ -68,11 +68,19 @@ var hookClockEpoch = time.Date(2026, 10, 14, 9, 0, 0, 0, time.UTC)
// stubGitHookTime makes each phase of the next hook runs take steps[phase] on the hook's clock, and
// ends the hook's time as phase expireIn begins (never, when expireIn is empty). The returned func
-// ends the latest run's time at once, for a test that has to end it mid-phase. The budgets are
-// the production ones; nothing here waits for them.
+// ends the latest run's time at once, for a test that has to end it mid-phase. The hooks' budgets
+// are the production ones; nothing here waits for them.
+//
+// A manual deadline reports no Deadline(), so the fresh real timers the pre-push hook writes notes
+// and pushes the notes ref on after its share phase (gitShareAfterContext) get only their floors,
+// gitShareNoteWriteBudget and gitShareNotesReserve, which a slow runner's git spawns can use up.
+// Those are a minute here.
func stubGitHookTime(t *testing.T, steps map[string]time.Duration, expireIn string) (expire func()) {
t.Helper()
prev := startGitHook
+ prevNoteWrite, prevNotesReserve := gitShareNoteWriteBudget, gitShareNotesReserve
+ gitShareNoteWriteBudget, gitShareNotesReserve = time.Minute, time.Minute
+ t.Cleanup(func() { gitShareNoteWriteBudget, gitShareNotesReserve = prevNoteWrite, prevNotesReserve })
var mu sync.Mutex
var latest *manualDeadline
startGitHook = func(parent context.Context, hook string, budget time.Duration) (*gitlink.HookRun, context.Context, context.CancelFunc) {
diff --git a/cli/beacon/cmd/git_share_sessions.go b/cli/beacon/cmd/git_share_sessions.go
index d7f220e5..94c6c41c 100644
--- a/cli/beacon/cmd/git_share_sessions.go
+++ b/cli/beacon/cmd/git_share_sessions.go
@@ -38,14 +38,15 @@ const (
gitShareMaxSessions = 10
// gitShareMaxCommits bounds how many pushed commits are read for links.
gitShareMaxCommits = 100
+)
+
+var (
// gitShareNotesReserve is the part of the pre-push budget kept for pushing the notes ref.
gitShareNotesReserve = 3 * time.Second
// gitShareNoteWriteBudget is the part kept, after the uploads, for writing the URLs they
- // returned into the local notes. It is local work, so a second is plenty.
+ // returned into the local notes. It is local work, so a second is plenty. Tests that stub the
+ // hook's clock replace both (stubGitHookTime).
gitShareNoteWriteBudget = time.Second
-)
-
-var (
// gitShareUpload is shareUpload; tests replace it.
gitShareUpload = shareUpload
// gitShareLogSessions lists the sessions in the runtime log; tests replace it to count reads.