Skip to content

Git designed for AI agents.

hook: an update the policy allows is logged at DEBUG

Federico Eliaae938c3d6429
diff --git a/internal/gitaly/hook/referencetransaction.go b/internal/gitaly/hook/referencetransaction.go
index 198f680..9e0f4cb 100644
--- a/internal/gitaly/hook/referencetransaction.go
+++ b/internal/gitaly/hook/referencetransaction.go
@@ -472,7 +472,9 @@ func (m *GitLabHookManager) enforceGraftPolicy(ctx context.Context, env []string
}
// Each decision names the policy that took it, so that an operator can tell which generation
- // decided an update while policies are reloaded.
+ // decided an update while policies are reloaded: a denial at INFO, as before, and an allowed
+ // update at DEBUG, since agents land many times a second and the changelog already records
+ // who landed what.
meta, _ := gitcmd.ChangelogMetaFromEnv(env)
fields := log.Fields{
"actor": meta.Actor,
@@ -485,7 +487,7 @@ func (m *GitLabHookManager) enforceGraftPolicy(ctx context.Context, env []string
return structerr.NewPermissionDenied("%s", message)
}
- m.logger.WithFields(fields).InfoContext(ctx, "agent reference update allowed by the policy")
+ m.logger.WithFields(fields).DebugContext(ctx, "agent reference update allowed by the policy")
return nil
}
diff --git a/internal/gitaly/service/operations/land_policy_reload_test.go b/internal/gitaly/service/operations/land_policy_reload_test.go
index 84009a5..c45cb7f 100644
--- a/internal/gitaly/service/operations/land_policy_reload_test.go
+++ b/internal/gitaly/service/operations/land_policy_reload_test.go
@@ -20,6 +20,7 @@ import (
"github.com/feder-cr/git-ai/internal/testhelper"
"github.com/feder-cr/git-ai/internal/testhelper/testserver"
"github.com/feder-cr/git-ai/proto/go/gitalypb"
+ "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
@@ -186,7 +187,8 @@ func testUserLandPolicyReloadsDuringConcurrentLands(t *testing.T, ctx context.Co
denyAgent0 := denyMainFor("agent-0")
versions := []any{policystore.Hash(allowAll), policystore.Hash(denyAgent0)}
- logger := testhelper.NewLogger(t)
+ // The allowed updates are logged at DEBUG.
+ logger := testhelper.NewLogger(t, testhelper.WithLevel(logrus.DebugLevel))
logs := testhelper.AddLoggerHook(logger)
ctx, cfg, client, reloader := setupPolicyReload(t, ctx, unbatchedGraft(allowAll), testserver.WithLogger(logger))
repo, repoPath, _, change := policyReloadRepo(t, ctx, cfg)