log rotation implementation (and design)#5
Merged
pmonday merged 1 commit intoApr 29, 2026
Merged
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.
Summary
Implements audit log file rotation for regulatory compliance (FDA 21 CFR Part 11, SOX & 802, HIPAA § 164.312(b), GDPR Art. 30). Adds cryptographic cross-log chaining so rotated logs form an unbroken audit trail.
Resolves #2
Key Changes
Core rotation logic (
log.go,audit.go,foundation.go)Log.Rotate()— writes alog.terminusentry to the current log, then creates a new log with alog.genesisentry that cryptographically references the old logLog.Fingerprint()— SHA-256 hash of the entire log file, stored in both terminus and genesis entriesLog.IsTerminus()/Log.IsGenesis()— helper methods to inspect log roleVerifyChain()— validates cross-log integrity across all rotated logs in a directoryDefaultRotatePath()— generates next log path using zero-padded sequence (audit-log.000.jsonl,audit-log.001.jsonl, ...)RotationReason(size_threshold,time_threshold,manual) and library-internalEventTypeconstants (EventLogTerminus,EventLogGenesis)Foundationextended withLogRoleandLogReffields (omitted when empty viaomitempty)CLI (
cmd/sealcheck/main.go)verify-chain <dir> <base>subcommand for cross-log verificationTests (
audit_test.go)Docs (
docs/rotation.md)Files Changed (9 files, +918 / -4)
log.goVerifyChaindocs/rotation.mdaudit_test.gocmd/sealcheck/main.goverify-chainsubcommandaudit.gofoundation.goLogRole,LogReffieldsREADME.md.gitignoreVerification
go test -race ./... go build -o sealcheck ./cmd/sealcheck ./sealcheck verify-chain /tmp/testdir audit-log