Skip to content

Add employee status transition tests (issue #249) - #327

Open
d3vobed wants to merge 1 commit into
zkpayroll:devfrom
d3vobed:feat/249-employee-status-transition-tests
Open

Add employee status transition tests (issue #249)#327
d3vobed wants to merge 1 commit into
zkpayroll:devfrom
d3vobed:feat/249-employee-status-transition-tests

Conversation

@d3vobed

@d3vobed d3vobed commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a tests/employees crate that pins down the employee status lifecycle and its interaction with payroll execution, per issue #249.

  • Status transition matrix: status_transitions.rs drives the documented EmpStatus machine (IncompleteActiveInactive/Removed, with the Removed terminal cleanup) and asserts the contract rejects illegal transitions.
  • Payroll eligibility gate: payroll_eligibility.rs verifies that payment_executor::execute_payment / execute_batch_payroll block employees that are not Active (EmployeeIneligible), and that the registry remove_employee clears the stored status.
  • Contract changes (minimal, required to make the behaviour observable/testable):
    • payment_executor: added EmployeeIneligible error and an is_eligible check before any transfer.
    • payroll_registry: remove_employee now clears EmpStatus.

Also adds docs/employees.md and fixtures/state-machine/employee-status-machine.json.

This supersedes the previously opened PR #322 (which targeted main; the repo requires PRs against dev).

Note on CI

The upstream workspace currently fails cargo clippy --workspace --all-targets -D warnings due to unrelated pre-existing breakage (audit_module is missing the initialize method required by tests/migrations). That is out of scope for this issue; this PR keeps employee_status_tests clippy-clean with all 26 tests passing.

Closes #249

…l#249)

Add a dedicated integration suite, contract enforcement, and documentation
for the employee status lifecycle.

Contract changes
- payment_executor: add PaymentError::EmployeeIneligible and gate
  execute_payment / execute_batch_payroll on payroll_registry::is_eligible.
  Inactive, incomplete, removed, and unregistered employees are now blocked
  before proof verification or any token transfer.
- payroll_registry: remove_employee now also clears the EmpStatus key so a
  removed employee reads back as Incomplete and can never be eligible again.

Tests (tests/employees/)
- status_transitions.rs: all six allowed transitions, idempotent same-status
  no-ops, unauthorized / unknown company / unknown employee rejections,
  removal semantics, and lifecycle event payloads.
- payroll_eligibility.rs: active employees are paid; inactive, incomplete,
  removed, and unregistered addresses are blocked with no transfer;
  reactivation and record correction restore payability; batches reject
  ineligible entries.

Docs
- docs/employees.md: status table, allowed/blocked transition matrices,
  payroll enforcement, and test coverage map.
- fixtures/state-machine/employee-status-machine.json: machine-readable mirror.

Closes zkpayroll#249
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

@d3vobed this PR currently has merge conflicts.

Please resolve the conflicts before it can be merged automatically.

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.

Add contract employee status transition tests

2 participants