Repository navigation
feat(audit): coverage policy, space-scoped visibility, retention enforcement (#151) - #155
Draft
LeoStehlik wants to merge 1 commit into
Draft
LeoStehlik wants to merge 1 commit into
LeoStehlik wants to merge 1 commit into
Conversation
…rcement Audit-log reliability review for #151: - Publish docs/audit-coverage.md: coverage matrix across UI/API/MCP/ background paths, explicit policy for reads, exports, denied attempts and failures, reliability model and remaining limitations. - Enforce audit visibility server-side: workspace owners/admins keep workspace-wide access; space administrators (direct or via group) now see only events scoped to spaces they administer, applied inside the SQL query so filters, pagination and spaceId selection cannot widen the scope; everyone else is rejected. Actor join is constrained to the event workspace. - Add POST /audit/access so the client shows the Audit log entry based on the server-side decision instead of a client role guess. - Record the actual actor on public login routes (user.login previously stored a NULL actor). - Record audit.retention_updated when retention changes. - Enforce workspaces.auditRetentionDays with a daily cleanup job and a (workspace_id, created_at) index; previously the setting was stored but never applied. - DatabaseAuditService logs a warning when an event is dropped for missing request context instead of dropping it silently. Refs #151 Signed-off-by: Leo Stehlik <[email protected]>
LeoStehlik
marked this pull request as draft
November 21, 2026 17:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review status: held from deployment. The proposed automatic deletion of audit records is outside this data-preserving update. Space-scoped queries must honour restricted-page access before expanding audit visibility. Missing event coverage and fire-and-forget delivery also remain unresolved; #151 must stay open.
Refs #151 (audit-log reliability and access scoping; incomplete)
Kept separate from the smaller #148/#149/#150 fixes as requested. This is the reliability + server-side-scoping subset of the broader #151 review; the full coverage matrix and recording policy are documented so the log is never mistaken for a complete activity record.
What changed
docs/audit-coverage.md: per-action recording matrix across UI/API/MCP/background paths, explicit policy for reads / exports / denied attempts / failures, reliability model, and an explicit list of remaining gaps.core/audit):spaceIdis a space they administer — enforced inside the SQL query, so filters, pagination cursors and a chosenspaceIdcan never widen the scope; aspaceIdoutside scope is rejected. Workspace-level events (nospaceId) are excluded from space scope.POST /audit/accessreturns the server's decision; the client sidebar shows the Audit log entry from that response instead of a client-side role guess.user.loginno longer stores a NULL actor.workspaces.auditRetentionDaysis now enforced by a daily cleanup job (previously stored/displayed but never applied → unbounded table). Added a(workspace_id, created_at desc)index to support the deletes and time filters. Retention changes are themselves audited (audit.retention_updated).DatabaseAuditServicelogs a warning when an event is dropped for missing request context instead of dropping silently.Tests
spaceIdrejected, retention cleanup honours per-workspace days and skips unset,DatabaseAuditServicecontext/exclusion/drop-warning behaviour, login sets actor. Full server suite: 33 suites / 235 tests pass; servertscclean.Remaining limitations (documented in
docs/audit-coverage.md, not closed here)Denied attempts other than MFA challenges, failed logins, human collab edits, scheduled trash purge, zip-import per-page outcomes, AI admin and untracked settings changes are not recorded; reads are excluded by policy; HTTP-path writes are fire-and-forget with no retry/outbox;
ipAddressis header-derived. These are listed explicitly rather than presented as covered.No cross-workspace disclosure was established before this change; the scoping above is a hardening requirement from #151, now enforced server-side and tested.