refactor(jobs): address code review feedback on fp.job
- Sequence: add noupdate="1" to fp_job_sequences.xml. Without it, every module update resets number_next to 1, corrupting the live job-number stream. Matches fp_sequence_data.xml convention. - action_cancel now raises UserError on an already-cancelled job instead of silently rewriting state. Audit-grade traceability expects explicit failures. - Added TODO marker for action_hold / action_resume / action_revert_to_confirmed so future authors don't bypass the state-machine guards. - Tests: added cannot_cancel_done (covers the dead-code UserError branch) and cannot_cancel_already_cancelled. Manifest version bumped 19.0.8.2.0 -> 19.0.8.2.1. Part of: native job model migration (spec 2026-04-25) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,3 +44,21 @@ class TestFpJobStateMachine(TransactionCase):
|
||||
job.action_cancel()
|
||||
with self.assertRaises(UserError):
|
||||
job.action_confirm()
|
||||
|
||||
def test_cannot_cancel_done(self):
|
||||
# Done jobs cannot be cancelled — covers the UserError branch in
|
||||
# action_cancel.
|
||||
job = self._make_job()
|
||||
job.action_confirm()
|
||||
# Force the state to 'done' for the test (no public action yet —
|
||||
# done is set by step-completion logic landing in Task 1.5+).
|
||||
job.state = 'done'
|
||||
with self.assertRaises(UserError):
|
||||
job.action_cancel()
|
||||
|
||||
def test_cannot_cancel_already_cancelled(self):
|
||||
# Idempotent re-cancel is now an explicit error.
|
||||
job = self._make_job()
|
||||
job.action_cancel()
|
||||
with self.assertRaises(UserError):
|
||||
job.action_cancel()
|
||||
|
||||
Reference in New Issue
Block a user