feat(reports): TSE compliance, audit & governance command center backend (#41) - #68
Closed
Villarley wants to merge 1 commit into
Closed
Conversation
…end (Velar-Bonds#41) Extends the party-side monthly report lifecycle (Velar-Bonds#40) with the TSE governance layer: a formally-specified workflow with dual-control approval and optimistic concurrency (extends the existing PATCH /reports/:id/review, doesn't replace it), an explainable/ versioned/backtestable rules engine, ABAC authorization with segregation-of-duties enforcement, a hash-chained tamper-evident audit log, an SLA/escalation engine, compliance analytics with forecasting, and streaming tamper-evident CSV/PDF exports. Backend-only by design: no frontend command center in this PR. Every DB-touching piece is exercised in tests via in-memory fake SupabaseService implementations — no VELAR credentials or live infra anywhere. See docs/TSE_GOVERNANCE_ARCHITECTURE.md for the full design. Closes Velar-Bonds#41 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
@mmongee is attempting to deploy a commit to the josueazc's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
Backend for issue #41 — VELAR's TSE compliance, audit & governance command center. Extends the existing party-side "Monthly report lifecycle" (#40) with the TSE governance layer:
PATCH /reports/:id/review(doesn't replace it) with an optionalexpectedVersionetag (409 on stale writes, fully backward-compatible when omitted), a newrechazadoterminal state, and a "four-eyes" dual-control gate on approvals over a configurable amount threshold, enforced with segregation-of-duties (second approver must differ from the first).reports/rules/) — typed, severity-scoredFindings (amount mismatch, missing/unknown bond refs, overdue, threshold breach) with a human-readable reasoning trace; versioned rule sets (v1/v2) with backtest diffing.reports/domain/reconciliation-window.ts) — confirmation/tolerance windows and re-check semantics on top of the existing purereconcile().auth/abac/) — attribute-based decisions covering role, delegated reviewer assignment, and segregation of duties, wired into the review flow.AuditService.emit()call is now chained (sha256 over canonicalized, key-sorted content) transparently, with a verifier that detects tampering and gaps.sla/) — idempotent, never-de-escalating breach detection against a configurable ladder.compliance-analytics/) — per-party compliance rate, reviewer workload/SLA attainment, and a deterministic overdue forecast (linear trend / moving average).reports/exports/) — CSV (genuine streaming via an async generator) and PDF (pdfkit), both hash-chained row-by-row with a tamper-evidence manifest.Full design in
docs/TSE_GOVERNANCE_ARCHITECTURE.md.Deliberately backend-only. The frontend command center (assignable queue, reconciliation workspace, audit-trail viewer, KPI/forecast charts, export UI) is out of scope for this PR — the HTTP surface and shared types are ready for a follow-up frontend PR to consume. No VELAR credentials or live infrastructure are used anywhere; every DB-touching piece is exercised only via in-memory fake
SupabaseServiceimplementations.Test plan
npm run build --workspace @velar/types— cleannpm run build --workspace apps/api— cleannpm run lint --workspace apps/api— 0 errors (pre-existingany/hook warnings on untouched files only)cd apps/api && npx jest— 36 suites, 331 tests passing, including property-based (fast-check) and concurrency-race tests for optimistic-concurrency rejection, dual-control/SoD, hash-chain tamper/gap detection, and rules-engine backtestingnpm run build/lint/test --workspace apps/web— unaffected (additive types only), confirmed no regressionssupabase/migrations/), not applied against any live database in this PRCloses #41