Repository navigation
feat(audit): tamper-evident log chaining for admin-sensitive actions (#2273) - #2313
Merged
github-actions[bot] merged 1 commit intoNov 24, 2026
Conversation
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.
Closes #2273
Summary
Implements tamper-evident log chaining for admin-sensitive actions under the exact Technical Scope paths (
backend/src/lib/tamperChain.ts,backend/src/services/audit.ts). No unrelated churn.backend/src/lib/tamperChain.ts— zero-I/O SHA-256 hash-chain primitive:prevHash; genesis anchor defaults to 64 zero chars.TamperChainErrorwith stable codes (HASH_MISMATCH,BROKEN_LINK,INVALID_SEQUENCE,INVALID_HASH,EMPTY_CHAIN,INVALID_GENESIS,INVALID_CONFIG).verifyChain()detects deletion, reordering, and content modification;resealChain()reconstructs a canonical chain after operator repair.backend/src/services/audit.ts— append-only audit log service:record()seals and persists admin actions via a minimal, adapter-agnosticAuditStore.verifyIntegrity()(with optionalstrictmode) verifies the persisted log and emits observability hooks.Tests
backend/src/lib/__tests__/tamperChain.test.ts— canonicalization, sealing/linking, happy-path verification, and every documented failure mode (content edit, broken link, sequence gap, malformed hash, empty chain, bad genesis, reseal).backend/src/services/__tests__/audit.test.ts— record/verify, typed actionkind, restart rehydration, backing-store tamper detection, strict-mode throw, metrics/logger hooks.All tests pass locally (standalone Node-26 type-stripping harness: 53 source assertions + 19 + 6 test-file assertions, 0 failures). CI uses the repo's existing jest configuration.
Observability
Metrics
audit.chain.append.total,audit.chain.verify.valid,audit.chain.verify.tampered,audit.chain.verify.empty,audit.chain.length,audit.record.total,audit.integrity.issues; structured logsaudit.chain.appended,audit.record.sealed,audit.integrity.violation,audit.integrity.ok,audit.chain.tamper_detected.Payout
0xC5dD2Ea54FF138bb3f71D3466092eA31eF115868DN3pfYEvdkoTBP4oaEVvemsr98fZPhDSAbfVfmewRGQ5ivanzenteno3@gmail.com