Skip to content

Make activity logs append-only at the model layer - #2568

Open
lancepioch wants to merge 1 commit into
mainfrom
w6/activity-log-append-only
Open

Make activity logs append-only at the model layer#2568
lancepioch wants to merge 1 commit into
mainfrom
w6/activity-log-append-only

Conversation

@lancepioch

@lancepioch lancepioch commented Sep 12, 2026

Copy link
Copy Markdown
Member

Adds updating/deleting guards to ActivityLog::boot() that throw, so audit entries can't be tampered with through the model. Pruning is unaffected because MassPrunable deletes through the query builder without firing model events; a comment documents that coupling. The activity_log_subjects FK already cascades, so pruning leaves no orphans.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4a7e96ef-022b-446d-a5c0-dc0a5e2d7d36

📥 Commits

Reviewing files that changed from the base of the PR and between fdb519e and fc31ba4.

📒 Files selected for processing (2)
  • app/Models/ActivityLog.php
  • tests/Integration/ActivityLogImmutabilityTest.php

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Activity logs now reject model updates and deletes. Integration tests verify append-only behavior and confirm that mass pruning still removes old logs while preserving recent logs.

Changes

Activity Log Immutability

Layer / File(s) Summary
Append-only enforcement and pruning validation
app/Models/ActivityLog.php, tests/Integration/ActivityLogImmutabilityTest.php
ActivityLog throws LogicException when updated or deleted through model events. Integration tests cover both restrictions and verify that model:prune still deletes old logs while retaining recent logs.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to fc31b

Activity logs reject model-level updates and deletes while aged records remain removable through the supported pruning path. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description accurately summarizes the append-only model guards, pruning behavior, foreign-key cascade, and related tests.
Title check ✅ Passed The title clearly and concisely identifies the main change: making activity logs append-only at the model layer.
  • Fix all pre-merge checks with AI

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.

@lancepioch lancepioch self-assigned this Sep 12, 2026
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.

1 participant