Skip to content

feat(payroll): emit per-employee failure events in batch claims (#505) - #693

Closed
jjb9707 wants to merge 6 commits into
Stellopay:mainfrom
jjb9707:feat/batch-claim-failure-events
Closed

feat(payroll): emit per-employee failure events in batch claims (#505)#693
jjb9707 wants to merge 6 commits into
Stellopay:mainfrom
jjb9707:feat/batch-claim-failure-events

Conversation

@jjb9707

@jjb9707 jjb9707 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #505. Emits a BatchClaimFailedEvent for every failed entry in batch_claim_payroll and batch_claim_milestones, so off-chain indexers and dashboards can surface partial-batch failures without re-simulating the batch.

What changed

  • events.rs: new BatchClaimFailedEvent { agreement_id, employee, entry_id, error_code } with emit_batch_claim_failed helper.
  • payroll.rs: emit the event in all 8 batch_claim_payroll failure branches and all 5 batch_claim_milestones failure branches (duplicate / out-of-bounds / not-approved / already-claimed / not-found / unauthorized / no-periods / insufficient-escrow).
  • The existing BatchPayrollResult / BatchMilestoneResult return values are untouched and the batch still continues after a failure (no early abort).

Security

Each event reveals only the claimant (employee/contributor) and the error code for that entry — never another employee's balance.

Tests added (test_batch_claim_failure_events.rs)

  • Mixed payroll batch (1 success + 2 failures) asserts exactly 2 batch_claim_failed_event and that the valid employee is paid.
  • Mixed milestone batch (1 success + 2 failures) asserts exactly 2 failure events.
  • All-fail batch asserts 2 events and that no tokens move.

…lopay#505)

Off-chain indexers currently cannot tell which employees/milestones
failed in batch_claim_payroll / batch_claim_milestones without re-simulating
the batch. Emit a BatchClaimFailedEvent per failed entry (employee/claimant,
entry id, error code) so partial-batch failures are observable.

The BatchPayrollResult / BatchMilestoneResult return values are unchanged and
the batch still continues after a failure. Events reveal only the claimant and
error code, never another party's balance.
@jjb9707
jjb9707 requested a review from Jagadeeshftw as a code owner July 7, 2026 05:33
@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Closing since this PR isn't linked to an issue you're assigned to. Please get assigned to an open issue first, then feel free to open a fresh PR referencing it. Thanks for understanding!

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.

Emit per-employee failure events in batch_claim_payroll and batch_claim_milestones

2 participants