Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -38,9 +38,13 @@ eventHash_n = HMAC-SHA-256(AUDIT_CHAIN_SECRET, eventHash_{n-1} || canonicalJSON(
`canonicalJSON` is the JSON encoding produced by
`canonicalizeAuditPayload` in
`packages/db/src/audit-hash.ts`: object keys sorted recursively,
`undefined` dropped, arrays preserve order. Without
`AUDIT_CHAIN_SECRET` the helper falls back to plain SHA-256 — still
tamper-evident for read-only attackers but trivially forgeable.
`undefined` dropped, arrays preserve order. Production fails closed unless
`AUDIT_CHAIN_SECRET` contains at least 32 UTF-8 bytes. Local development and
tests may use the explicit SHA-256 fallback, but it is never an accepted
production configuration. New `v2:` hashes bind the persisted event ID and
creation timestamp; the verifier retains dual compatibility with unversioned
legacy hashes. Concurrent writers serialize through a per-chain PostgreSQL
advisory transaction lock and an HMAC-authenticated O(1) chain-head row.
`verifyAuditChain(events, { secret })` walks the chain oldest → newest
and returns the first break with one of:
@@ -116,15 +120,14 @@ join with `|`; JSON metadata is stringified.
`apps/worker/src/jobs/audit-retention.ts` exposes `runAuditRetentionJob`
which the worker host wires to a daily cron.
Plan-based defaults (`resolveAuditRetentionPolicy`):
The retention window is fixed at ten calendar years for every tenant chain and
the platform chain. Tenant discovery uses one aggregate query. Deletes run in
bounded, keyset-ordered batches; before each batch is deleted, the same
transaction writes an append-only HMAC-authenticated checkpoint that binds the
last removed event hash and the previous checkpoint MAC. Verifiers and exports
authenticate this checkpoint before accepting the retained suffix.
| Regulatory scope on tenant events | Retention |
| --------------------------------- | --------- |
| `soc2` or `hipaa` | 7 years |
| `gdpr` | 6 years |
| none | 1 year |
Every non-empty sweep emits a meta-audit (`audit.retention.swept`) so
Every non-empty sweep emits a meta-audit (`audit.retention.pruned`) so
the cleanup itself is traceable.
## Operator Procedures
@@ -134,8 +137,8 @@ the cleanup itself is traceable.
1. Generate a secret: `openssl rand -base64 32`.
2. Set `AUDIT_CHAIN_SECRET=<value>` in Coolify (platform-wide, never
per-tenant).
3. Apply the Prisma migration
`20260517180000_10_audit_event_compliance`.
3. Apply the migration that creates `AuditChainHead` and
`AuditChainCheckpoint` before deploying the new writers.
### Self-service export (tenant admin)