P3.1: batch processing foundation — BatchService + auto-attach + 3 enum cases + 13 tests#116
Draft
sjelfull wants to merge 1 commit into
Draft
P3.1: batch processing foundation — BatchService + auto-attach + 3 enum cases + 13 tests#116sjelfull wants to merge 1 commit into
sjelfull wants to merge 1 commit into
Conversation
…um cases + 13 tests
Owner
Author
This was referenced May 14, 2026
Draft
49bb901 to
fe6c741
Compare
f80a04b to
baada5e
Compare
fe6c741 to
49bb901
Compare
baada5e to
f80a04b
Compare
This was referenced May 15, 2026
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.
P3.1: BatchService foundation — open/close/run API for grouping audit rows
Adds
BatchService, the core infrastructure for grouping related audit rows under a parent record. A "batch" is an audit row with eventBatchStarted/BatchCompleted/BatchFailedthat acts as a parent for all rows recorded while the batch is open. The service is the foundation for P3.2 (ResaveElements), P3.3 (CP UI), and P3.4 (Feed Me).Auto-attachment is wired into
AuditRecorder::record(): after the overrides loop and beforeEVENT_BEFORE_RECORD, ifBatchService::currentBatchId()is non-null and$record->parentIdis null, the recorder sets the parent automatically. Callers don't need to know about batches — any audit row recorded while a batch is open inherits the parent ID.What changed
src/services/BatchService.php(new, 243 LOC) —open(string $title, array $metadata = [])opens a batch and returns its ID;close(int $batchId, ?string $summary, bool $failed)closes it;run(string $title, callable $callback)wraps open/close around a callback;currentBatchId()returns the active batch ID or null.src/events/BatchStartedEvent.php(new, 20 LOC) — event fired after a batch row is persisted. Observational only (not cancellable).src/events/BatchEndedEvent.php(new, 25 LOC) — event fired after a batch is closed. Carries$failedflag.src/enums/AuditEvent.php(+5 LOC) — addsBatchStarted,BatchCompleted,BatchFailedcases.src/services/AuditRecorder.php(+9 LOC) — auto-attach hook: sets$record->parentIdfromcurrentBatchId()when not already set.src/Audit.php(+3 LOC) — registersBatchServicein the service container.src/translations/en/audit.php(+5 entries) — batch state labels.tests/Feature/BatchServiceTest.php(new, 304 LOC, +13 tests) — covers open/close/run, auto-attach, nested batch behavior, event firing, and failure path.tests/Feature/EnumCoverageTest.php— updated to include the 3 new enum cases.Tests
Stacked on
p2.9-real-api-tests(#115)