feat: record access decisions, not just denials

- add an outcome column and migration so allowed and denied decisions share one audit trail
- fail closed when an allowed decision cannot be recorded
- expose outcome filtering in the API and dashboard

Route chat through the recording authorizer so its decisions are audited too.
This commit is contained in:
sam committed 2026-11-23 01:00:46 +11:00
1 parent e1ada94d78
commit 60d9b6b7aa
17 files changed
+291 -98

No files matched your search

@@ -0,0 +1,16 @@
-- +goose Up
-- The table that held refusals now holds every authorization decision. A row
-- records one outcome, coalesced per minute with identical requests, so rows
-- that exist already are refusals.
ALTER TABLE governance.access_denials
ADD COLUMN outcome text NOT NULL DEFAULT 'denied' CHECK (outcome IN ('allowed', 'denied'));
DROP INDEX governance.idx_governance_access_denials_dedup;
CREATE UNIQUE INDEX idx_governance_access_denials_dedup
ON governance.access_denials (org_id, principal, action, resource_kind, resource_id, outcome, level, policies, minute_at);
-- +goose Down
DELETE FROM governance.access_denials WHERE outcome = 'allowed';
DROP INDEX governance.idx_governance_access_denials_dedup;
CREATE UNIQUE INDEX idx_governance_access_denials_dedup
ON governance.access_denials (org_id, principal, action, resource_kind, resource_id, level, policies, minute_at);
ALTER TABLE governance.access_denials DROP COLUMN outcome;