Skip to content

fix(plugins): record execution history for every plugin job run - #112

Merged
fronzec merged 1 commit into
mainfrom
fix/plugin-execution-audit
Oct 17, 2026
Merged

fronzec merged 1 commit into
mainfrom
fix/plugin-execution-audit

Conversation

@fronzec

@fronzec fronzec commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Attach JobExecutionAuditListener to every job in PluginRegistryService
before registration, so synchronous, asynchronous, and run-all launches
all write exactly one job_executions_audit row. Remove the after-run
saveAudit path in JobsManagerService, which only covered the
synchronous single-job launch.

The listener now records the raw BatchStatus as outcome, clears a stale
audit id from the execution context, and never fails a job when audit
persistence fails. Jobs without a job_definitions row stay unaudited.

Closes #111

Summary by CodeRabbit

  • New Features
    • Job executions now record audit details, including start and finish times, duration, and the final batch status, for registered jobs with a definition.
    • Auditing covers synchronous and asynchronous launches, including individual and batch launches.
  • Bug Fixes
    • Audit recording failures no longer interrupt job execution.
    • Jobs without a matching definition are not audited; unsupported job types can still be registered.
  • Documentation
    • Updated developer and architecture documentation with audit behavior and limitations.

Attach JobExecutionAuditListener to every job in PluginRegistryService
before registration, so synchronous, asynchronous, and run-all launches
all write exactly one job_executions_audit row. Remove the after-run
saveAudit path in JobsManagerService, which only covered the
synchronous single-job launch.

The listener now records the raw BatchStatus as outcome, clears a stale
audit id from the execution context, and never fails a job when audit
persistence fails. Jobs without a job_definitions row stay unaudited.

Closes #111

fronzec commented Oct 17, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 012f42cc-8787-4357-9232-a5d2318d538c
📥 Commits

Reviewing files that changed from the base of the PR and between febb06d and 11cd7c9.

📒 Files selected for processing: 9
  • fr-batch-service/docs/ADR/001-dynamic-job-loading-system.md
  • fr-batch-service/docs/job-plugins/developer-guide.md
  • fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/JobsManagerService.java
  • fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/plugins/PluginRegistryService.java
  • fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/plugins/listener/JobExecutionAuditListener.java
  • fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/JobsManagerServiceTest.java
  • fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/plugins/PluginRegistryServiceTest.java
  • fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/plugins/listener/JobExecutionAuditListenerTest.java
  • fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/plugins/loader/DynamicJobLoadingIntegrationTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Plugin registration now attaches JobExecutionAuditListener to supported jobs. The listener writes execution audit rows and records completion metadata. The synchronous launch path no longer writes a separate audit row. Tests cover listener registration and synchronous and asynchronous executions.

Changes: Plugin execution audit

Layer / File(s) Summary
Attach listener during registration
fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/plugins/PluginRegistryService.java, fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/plugins/PluginRegistryServiceTest.java, fr-batch-service/docs/ADR/001-dynamic-job-loading-system.md
Static and dynamic registration attaches the shared listener to AbstractJob instances before registry entry. Other Job implementations still register without the listener and produce a warning. Tests cover listener ordering, duplicate attachment, and warning behavior.
Persist execution audit lifecycle
fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/plugins/listener/JobExecutionAuditListener.java, fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/JobsManagerService.java, fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/plugins/listener/JobExecutionAuditListenerTest.java, fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/JobsManagerServiceTest.java, fr-batch-service/docs/ADR/001-dynamic-job-loading-system.md, fr-batch-service/docs/job-plugins/developer-guide.md
The listener creates an audit row when a matching job definition exists and records finish time, duration, and raw BatchStatus. Runtime persistence failures do not propagate from listener callbacks. JobsManagerService no longer saves a separate audit row.
Verify synchronous and asynchronous executions
fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/plugins/loader/DynamicJobLoadingIntegrationTest.java
Integration tests check that synchronous and asynchronous executions each have one audit row with completion metadata. The asynchronous test also checks the final execution status.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant PluginRegistryService
  participant AbstractJob
  participant JobExecutionAuditListener
  participant JobDefinitionRepository
  participant JobExecutionAuditRepository
  PluginRegistryService->>AbstractJob: attach listener before registration
  AbstractJob->>JobExecutionAuditListener: beforeJob
  JobExecutionAuditListener->>JobDefinitionRepository: find matching definition
  JobExecutionAuditListener->>JobExecutionAuditRepository: save audit row
  AbstractJob->>JobExecutionAuditListener: afterJob
  JobExecutionAuditListener->>JobExecutionAuditRepository: update completion metadata
Loading
Merge Risk: ⚪ Minimal · up to 11cd7

The change is mergeable after normal checks. No unresolved issue was established that should block the new audit coverage.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #111 requires every plugin execution to create exactly one job_executions_audit row. The listener is attached only when a job is an AbstractJob; PluginRegistryService.attachAuditListener r… Ensure every executable plugin job receives the audit lifecycle callbacks, or reject unsupported job implementations instead of registering them. Define and implement handling that satisfies issue #111 for executions without a `job_definiti…
Docstring Coverage Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 54 functions across 7 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: recording execution history for plugin job runs.
Out of Scope Changes check Passed The changed listener behavior, registry wiring, removal of JobsManagerService.saveAudit, tests, and documentation all concern plugin execution audit history. The changes do not alter DELETE semantic…
Full details: Out of Scope Changes check

Explanation

The changed listener behavior, registry wiring, removal of JobsManagerService.saveAudit, tests, and documentation all concern plugin execution audit history. The changes do not alter DELETE semantics or definition replacement behavior excluded by issue #111.

Full details: Linked Issues check

Explanation

Issue #111 requires every plugin execution to create exactly one job_executions_audit row. The listener is attached only when a job is an AbstractJob; PluginRegistryService.attachAuditListener registers other Job implementations without a listener, so their executions are unaudited. JobExecutionAuditListener.beforeJob also skips executions when JobDefinitionRepository.findByJobName returns no definition. The changes do provide one listener writer, remove the synchronous saveAudit path, and add synchronous and asynchronous integration coverage for definition-backed jobs, but those exceptions leave the absolute acceptance criterion unmet.

Resolution

Ensure every executable plugin job receives the audit lifecycle callbacks, or reject unsupported job implementations instead of registering them. Define and implement handling that satisfies issue #111 for executions without a job_definitions row, or narrow the issue requirement explicitly. Add tests for each supported plugin job type and for the definitionless case.

Full details: Docstring Coverage

Explanation

Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 54 functions across 7 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@fronzec
fronzec merged commit 691f343 into main Oct 17, 2026
8 checks passed
@fronzec
fronzec deleted the fix/plugin-execution-audit branch October 17, 2026 04:45
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.

fix(plugin): record execution history for every plugin job run

1 participant