feat: add feature flag state change audit log for compliance traceability#915
Open
Xaxxoo wants to merge 1 commit into
Open
feat: add feature flag state change audit log for compliance traceability#915Xaxxoo wants to merge 1 commit into
Xaxxoo wants to merge 1 commit into
Conversation
…de#858) Introduce FeatureFlagAuditService that wraps runtime feature flag reads and writes with a full audit trail. - Initialises in-process flag state from environment variables at startup - setFlag() updates the runtime value and emits a CONFIG_CHANGED entry via AuditLogService (actor, old value, new value, timestamp) - Maintains a ring buffer of the last 100 changes (MAX_HISTORY) - Audit log failure is caught and logged so it never interrupts a toggle - Expose GET /feature-flags/audit (admin-only) returning the change history - Expose GET /feature-flags for a current-state snapshot - Expose PATCH /feature-flags/:key for runtime toggling with audit trail - Register FeatureFlagAuditModule in AppModule - 12 unit tests covering reads, writes, audit emission, failure isolation, ring-buffer capping, and snapshot immutability
|
@Xaxxoo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Great job so far There’s just one blocker — the workflow is failing. Could you take a look and fix it so all checks pass? Happy to review again once that’s done. |
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 #858
Summary
FeatureFlagAuditService(src/config/feature-flag-audit.service.ts) that wraps runtime flag reads and writes with a full audit trailloadFeatureFlags()setFlag(key, value, actor)updates the runtime value, records old→new diff, and emits aCONFIG_CHANGEDentry toAuditLogService(actor ID, email, entity typeFeatureFlag, diff payload)FeatureFlagAuditService.MAX_HISTORY)FeatureFlagAuditControllerexposes three admin-only endpoints:GET /feature-flags— current state snapshotGET /feature-flags/audit— last 100 changes for compliance reviewPATCH /feature-flags/:key— runtime toggle with immediate audit emissionFeatureFlagAuditModuleimportsAuditLogModuleand is registered inAppModuleTest plan
getFlagreturns initial value from env configsetFlagupdates runtime statesetFlagrecords change in audit history with old/new valueslogDataChangeis called on every toggleAuditLogServicefailsMAX_HISTORY(100) entriesgetAuditHistory()returns an immutable snapshotnpm test)