Draft: feat(minder): upload spooled policy decisions as audit events

Description

This MR makes glab minder audit sync upload the spooled policy matches of a Claude Code session as ai_tool_call_policy_matched audit events, for https://gitlab.com/gitlab-org/gitlab/-/work_items/634683. GitLab stores the events once gitlab!272022 (merged) is merged. Until then GitLab drops the unknown event type without an error, so sending early is safe.

The sync first posts the transcript events and saves its place in the transcript, and only then posts the decisions in their own requests. A decision that GitLab refuses therefore never stops or repeats the transcript upload. If GitLab refuses an event for good, glab posts the rest of the request again without it, with at most 20 extra requests per sync. After a failure that can pass, glab keeps the session's decisions for the next sync. When the periodic sync is installed, the session is not marked as completed until its decisions are posted. A session with new matches syncs even when its transcript has nothing new. Spools of sessions that no hook recorded are deleted after 30 days. Each event has a stable ID, so an event sent twice is stored once. gaig.DeterministicUUID moves to the shared gaig package so the hook can derive event IDs the same way.

The event details have these keys: policy_id, policy_version, policy_name, policy_mode, policy_action, policy_decision, rule_index, tool_name, tool_call_id, target, file_operation, mcp_server, mcp_tool, input, input_truncated, and agent_name. Keys without a value are left out.

It is stacked on !4475. Its tests write spool records directly, and the next MR makes the hook write them.

How has this been tested?

Sync tests run against a fake GitLab and check the event names, details and IDs, removal after success, and that only the decision GitLab refuses for good is dropped while the other decisions and the transcript still upload. They also check that decisions are kept after server errors, rate limits and refused tokens, and when a session is completed. Further cases cover a GitLab that refuses every request, decisions posted again after a failure, a match recorded during the upload, uploads without new transcript entries, the age limit, and the removal of spools of forgotten sessions.

Merge request reports

Loading
Loading