feat: add governance approval audit backend#7
Merged
Conversation
e437fa3 to
61a7920
Compare
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.
Summary
Changed files
src/modules/permissions/governance.ts— server-side role/action/risk permission matrix.src/modules/approvals/*— approval types, governance derivation, queue/detail queries, approve/reject service.src/modules/audit/*— sanitized audit metadata, audit filters/query contract, append-only write behavior.src/app/api/approvals/*— queue/detail/decide API routes.src/app/api/audit/route.ts— audit filter API route.src/modules/workflows/incident-response/service.tsandsrc/lib/demo/northstar-seed.ts— approval metadata/action semantics for seeded and Phase 5 approvals.scripts/governance-audit-smoke.ts— opt-in DB smoke for unauthorized direct calls, approve side effects, and audit filters.tests/governance-audit.test.ts— permission matrix, decision side effects, audit filter/sanitize coverage.docs/governance-audit-contract.md— Pixel service/data contract.Verification
npm installnpm run lintnpm run typechecknpm test— 6 files passed, 26 tests passed, 3 skippednpm run buildnpm run cf:buildnpm run demo:resetnpm run governance:audit-smoke—governance_audit_smoke ok=true approvals=1 decisions=1 audit=1 unauthorized_blocked=true continuation=resumednpm run demo:resetafter smoke to restore demo datanpm run db:checkAcceptance checklist
403.Pixel service/data contract
docs/governance-audit-contract.md.GET /api/approvals?role=<demo-role>&status=pending&limit=50.GET /api/approvals/:id?role=<demo-role>.POST /api/approvals/:id/decidewith{ role, decision: "approved" | "rejected", rationale }.GET /api/audit?role=<demo-role>&actorRole=&action=&actionType=&incidentId=&status=&outcome=&search=&limit=.metadataSummary; do not render raw metadata.Risks / notes
writeAuditLognow usesonConflictDoNothing()to preserve append-only behavior; new governance events use unique IDs.