Repository navigation
refactor(audit): centralize all 61 existing event names - #358
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Deep review — P2-2a audit-event closed set (head
|
ec32ccc to
47264ca
Compare
voidvec
left a comment
There was a problem hiding this comment.
Final review passed on this exact head. The event vocabulary now includes all61 existing production actions, including four omitted branch outcomes; ten unrelated JSON keys are restored to literals. All19 production files are byte-identical to current master after reversing same-value constant references/removing the include, preserving the existing #346/#357/#356 behavior. Public API drift is only the additive new header. Independent final review, five new common cases, complete679 CTest and main764/62870 passed locally. Current exact-head CI and manually dispatched client-SDK checks all pass; configured strict/nightly skips and baseline #365/#366 limits remain disclosed. No unresolved blocking code findings. A genuine external approval is still required; this author-account COMMENT does not satisfy approval protection.
The ~57 audit action names lived as scattered string literals across 20+ emitter files. P2-2's webhook subscriptions need them as a CLOSED, spellable set (event filters validate against exactly these constants) -- drift between emitters and filters would be silent. - new common-layer header AuditActions.h: one inline constexpr per event + kAllEvents (byte-sorted closed set, 57 entries) + isKnownEvent() membership check; common layer on purpose -- the upcoming webhook delivery service has no Drogon dep - all 19 emitter files now use the constants (byte-identical values -- the audit_logs.action column and every existing query are unchanged) - SOCIAL_LOGIN_TOKEN_ISSUED keeps its historical uppercase casing verbatim (v1.6.0 stored data; normalizing is a v2.0 migration) - AuditActionsTest: distinctness, sort order, snake_case grammar, v1-trail spot pins, isKnownEvent membership - api-diff baseline ratified (237 headers, additive)
Register four omitted emitted actions without changing stored values, restore ten unrelated JSON keys, and strengthen registry tests and contract wording. Keep the public-header baseline additive against master.
47264ca to
0ea92ff
Compare
voidvec
left a comment
There was a problem hiding this comment.
Review — P2: registry completeness is still unenforced (at 0ea92ffc)
Independent verification first, so the scope of this finding is clear. At head 0ea92ffc I re-ran the checks this PR exists for:
- 61 constants, 61 unique values,
kAllEventsbyte-sorted and covering every declared constant (scripted, not eyeballed). - Per-line pairing of all 70 single-line replacements: constant value appears in the removed literal — 0 deviations, including the ternary rewrites.
- Zero remaining action literals in
libs/+apps/non-test code; all 61 constants have production call sites. The four events missed in the previous round (client_resumed,org_consent_request_approved,social_account_link_failed,social_account_unlink_blocked) are present and emitted. The JSON-field coupling from the previous round is reverted (kMfaEnabled/kMfaVerifiednow only at the four audit sites).
The remaining P2
kAllEvents's static_assert only pins the array size. Two drift paths stay invisible to every gate in this PR:
- Add
inline constexpr char kNewEvent[] = "new_event";and forget the array entry — size is still 61,static_assertpasses, and all five unit tests stay green (they only inspectkAllEventsmembers). - Add a new emitter that passes a string literal (or a plain
std::string) — nothing detects it; the sink continues to accept arbitrary strings by design.
This is the same defect class as the four missed events in the previous review round, so the recurrence risk is demonstrated rather than hypothetical. Once the webhook filters validate against this set, either path yields silently unnotifiable/unsubscribable events — exactly the emitter/filter drift this PR is meant to stop.
Suggested fix (pick one, or combine)
- Single source of truth: X-macro so each event is declared and array-registered in one place (removes path 1 structurally).
- Test-side coverage: assert that every declared
k*constant is a member ofkAllEvents(cheap, closes path 1; keeps a manually maintained list in the test, but a miss there is at least a visible diff). - CI source scan: parse every audit emission site (
logFromRequest,audit*helpers,.action =assignments) and require the action argument to be a registry constant (closes path 2). For reference, a balanced-paren scan overlibs/+apps/at this head finds 48 call sites with 0 literal action arguments today, so it would pass immediately and act as a ratchet; it fits next totools/arch-guardin the static-checks job.
Not a runtime correctness issue — the emitted bytes are unchanged — but I would not want to rely on human review for registry completeness given the previous round. Tracking this as a follow-up issue with one of the above gates is acceptable; merging without either gate would leave the "closed set" claim unenforced.
The audit registry is a contract, but neither the compiler nor the unit tests catch two drift paths: a declared k* constant missing from kAllEvents (the array-size static_assert still passes), and an emitter passing a bare action string literal (the sink interface is string-based by design). audit_event_guard.py closes both: it cross-checks declarations against kAllEvents (membership both ways, uniqueness, byte order, assert count, value grammar) and flags string literals only in the action argument of the known audit helpers, so legitimate literal target/outcome arguments stay legal. It ships with a selftest and runs in the static-checks job next to double_move_guard.
The fully qualified ::fulla::common::observability::audit_events:: prefix pushed audit call sites past the 100-column limit in ten translation units. A file-scope `namespace ae = ...` alias (the same pattern as the existing `namespace openapi` alias) keeps the constants explicit while fitting the formatter budget. No behavior change.
The header claimed webhook event filters and a subscription validator consume kAllEvents; no such consumer exists. State what actually holds: the set is closed and enforced by AuditActionsTest plus the new audit_event_guard, and isKnownEvent has no production caller yet. Comments only -- api-diff strips comments, so the SDK baseline is unchanged (verified).
Summary
Centralize all 61 existing audit action values in a common C++17 header, with a registered value array and exact membership helper. Replace existing emitter strings with same-value constants; preserve stored values, event timing, resources, details and the historical uppercase SOCIAL_LOGIN_TOKEN_ISSUED value.
The original 57-value proposal omitted four real branch outcomes: client_resumed, social_account_link_failed, social_account_unlink_blocked and org_consent_request_approved. The follow-up review fix registers those existing actions and restores ten ordinary JSON field names that had been accidentally coupled to event constants. The legitimate email-template action-query predicate continues to use the constant. No runtime event filtering, webhook delivery or sink-interface change is introduced.
Scope and integration review
Two commits, 23 files: original vocabulary extraction plus a separate review correction. Rebased onto master
c736e35dafter #348, #362 and #363. The only rebase conflict was the TokenEndpoint include block; TokenGrantResponse, TokenSuccessPayload and AuditActions headers are all retained. Master's password-login session extraction and require_pkce behavior remain intact.For all 19 production files, replacing each constant with its declared original string and removing the new include yields a byte-for-byte copy of current master. This verifies that only vocabulary spelling references change; no current controller/service logic was overwritten. The original rebase patch-id changes only with the include context; the separate correction intentionally changes the patch.
The new public-header API baseline is additive against actual master (134 added lines, no removed existing declarations); it was regenerated without force. No DB schema, endpoint, errors, configuration, client SDK or frontend changes.
The registry does not make the existing string-based sink type-safe. Tests check registered values; future emitter/registration completeness still requires review. Tests assert nonempty values before front/back access, require a lowercase initial letter except the pinned historical outlier, check uniqueness/order, all registered memberships, rejected unknown values and exact stored-value pins.
Validation
-O1 -DNDEBUG, examples OFF. Full rebuild passed.324fdf16(before integrating refactor(drogon): share client-credentials and device token payloads #348): complete CTest 679 passed, zero failures/errors/skipped testcases; all five added common tests were actually discovered and ran.6bc5807e76d546ae7ed42eeedefa8d484958a743matches exactly. Reviewed 23-file source-manifest SHA256676d77ab00031c44037f40f05e8325e82c2f9b0dc9d11fefb6889a482c523f20; raw JUnit/LastTest evidence preserved.The existing CSP broker-profile branch and wrapper's second memory-config round remain internally skipped; JUnit zero skipped is not a claim that those branches ran. No capacity, #300 lifecycle, scheduled strict-coverage #365 or TSan #366 fix is claimed. Fresh three-platform/SDK-consumer/security/ASan checks and manually dispatched client-SDK drift are required on updated head
0ea92ffcbefore rebase merge. The maintainer explicitly authorized administrator bypass of the independent-approval requirement on 2026-11-22.Checklist
Rebase integration verification (2026-11-22)
Independent rebase review passed: the exact current 23-file source manifest matches the reviewed integration version; all19 production files still equal new master after restoring same-value literal spellings/removing the new include. #348's scope commit/rollback and payload code/tests are preserved. Frontend-only base updates introduce no further C++ changes. Fresh current-head CI is running; no old test result is reported as a new-head pass. Administrator approval bypass is authorized; merge still waits for current-head verification.