Draft: feat(minder): spool policy decisions for upload

Description

This MR adds the policydecisions package, which keeps the policy matches that the Claude Code PreToolUse hook records until glab minder audit sync uploads them. It is the first MR for https://gitlab.com/gitlab-org/gitlab/-/work_items/634683, which reports each policy match to GitLab as an AI audit event so that local enforcement shows in the audit trail. The next MRs in the stack upload the records and make the hook write them.

Each session has a spool file of JSON lines in the glab configuration directory, under gaig/policy-decisions. The folder is readable only by the user. The hook appends to it in a single write per tool call and stops writing when a session's spool reaches 1 MiB. A record cut off by a full disk or a killed hook does not damage the next one. The sync renames the spool aside before reading it, so the hook never waits for the sync and matches recorded during an upload are kept for the next one.

It is stacked on !4474.

How has this been tested?

Spool tests cover appending, claims, releases, failed uploads, unreadable and cut off lines, the size cap, a full spool that a sync claims, matches recorded while one or two syncs run, and the removal of a session's spools and of stale spools.

Edited by Jean van der Walt

Merge request reports

Loading
Loading