Skip to content

refactor: extract AuditRecord Create method into sub-methods#1525

Open
AmanGIT07 wants to merge 2 commits intomainfrom
refactor/audit-record-create
Open

refactor: extract AuditRecord Create method into sub-methods#1525
AmanGIT07 wants to merge 2 commits intomainfrom
refactor/audit-record-create

Conversation

@AmanGIT07
Copy link
Copy Markdown
Contributor

Summary

  • Extract actor enrichment from Create into enrichActor dispatcher + dedicated methods: enrichSystemActor, enrichUserActor, enrichServiceUserActor, enrichPATActor
  • Extract idempotency check into checkIdempotency with clear return contract
  • Create is now a clean orchestrator: idempotency check → enrich actor → persist

Test plan

  • All existing audit record tests pass unchanged (19 tests)
  • No functional changes — pure refactor

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Apr 9, 2026 11:52am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 73001ee0-076b-45e1-8652-ac3f888dd655

📥 Commits

Reviewing files that changed from the base of the PR and between fb8d71d and ec3161a.

📒 Files selected for processing (1)
  • core/auditrecord/service.go
✅ Files skipped from review due to trivial changes (1)
  • core/auditrecord/service.go

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Internal improvements to audit record handling and actor enrichment logic to improve idempotency checks and actor population.

Note: These are backend refactors with no direct end-user visible changes.

Walkthrough

Refactored Service.Create in core/auditrecord/service.go: idempotency handling moved to checkIdempotency, actor enrichment extracted to enrichActor which dispatches to type-specific helpers, and Create now early-returns on idempotent replay before calling the repository.

Changes

Cohort / File(s) Summary
Service method refactoring
core/auditrecord/service.go
Extracted checkIdempotency helper to centralize idempotency key lookup, hash comparison, and conflict/replay behavior. Extracted enrichActor router and four type-specific enrichment helpers (enrichSystemActor, enrichUserActor, enrichServiceUserActor, enrichPATActor) to populate Actor fields and metadata; Create now uses these helpers and returns early on replay. No exported signatures changed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AmanGIT07 AmanGIT07 enabled auto-merge (squash) April 9, 2026 11:43
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 259519ef-2ef3-452b-851a-5a320b6944b8

📥 Commits

Reviewing files that changed from the base of the PR and between cde820a and fb8d71d.

📒 Files selected for processing (1)
  • core/auditrecord/service.go

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 9, 2026

Coverage Report for CI Build 24188676627

Coverage increased (+0.04%) to 41.328%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: 5 uncovered changes across 1 file (94 of 99 lines covered, 94.95%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
core/auditrecord/service.go 99 94 94.95%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
core/auditrecord/service.go 1 94.58%

Coverage Stats

Coverage Status
Relevant Lines: 36426
Covered Lines: 15054
Line Coverage: 41.33%
Coverage Strength: 11.88 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants