3.3 KiB
3.3 KiB
New Appeal Refactor Guardrails
Purpose
These guardrails apply to all AI-assisted and human-assisted work on the refactor branch for the new appeal flow.
Critical Rule
Preserve the current live S78 behaviour unless the task explicitly requires a behaviour change.
Do not assume a cleaner implementation is allowed to alter behaviour.
Protected Areas
Treat the following as protected flow files:
pages/newappeal/index.jspages/newappeal/[appealtypes].jscomponents/newappeal/buildsection.jscomponents/newappeal/buildchecksection.jscomponents/newappeal/buildrow.jscomponents/newappeal/buildfield.jscomponents/newappeal/buildcheckrow.jscomponents/newappeal/complete.jscomponents/newappeal/aboutyou.jscomponents/newappeal/createCase.js- any helpers or service modules used directly by save/progress/upload/submit/finalise logic
Protected Behaviour
The following must not regress:
- Start a new S78 appeal
- Create case / initial journey entry
- Section rendering from form definition
- Section progression
- Save and exit
- Resume saved appeal
- File/document upload behaviour
- Check answers page
- Appeal PDF generation/download path
- Final submit/finalisation
- Confirmation page behaviour
- Email/notification side effects
- English/Welsh parity for touched areas
Required Refactor Approach
When refactoring:
- Understand current behaviour first
- Identify the smallest safe boundary
- Prefer extraction of pure/helper logic
- Keep public interfaces stable where possible
- Avoid changing UI, business rules, and structure in one step
- Keep each slice easy to review and revert
Required Testing Mindset
Before changing critical flow behaviour, add or update protection such as:
- characterization tests for current behaviour
- targeted integration/service tests
- journey-level regression checks
- payload-shape assertions for save/submit/finalise paths
If automation is not practical yet, include an explicit manual verification matrix.
Payload/Integration Safety
Do not change without explicit need:
- CRM payload field names or structure
- boolean/value normalization behaviour
- document/file metadata shape
- save/resume payload expectations
- PDF generation inputs
- notification template selection or personalisation structure
i18n / Accessibility Safety
For touched user-facing behaviour:
- keep EN/CY behaviour aligned
- keep labels, messages, and route behaviour consistent
- preserve semantic structure, focus behaviour, and validation messaging
Delivery Safety
Preferred pattern for each change:
- protect current behaviour
- extract one concern
- run focused validation
- keep rollback straightforward
- merge only when safe
What To Avoid
Do not:
- perform broad rewrites
- mix feature delivery with refactor work
- replace dynamic/config-driven logic with one-off hardcoding
- move many responsibilities at once
- introduce new dependencies unless clearly justified
- silently change business rules while “cleaning up”
Refactor Success Criteria
A refactor slice is successful when it:
- preserves behaviour
- reduces complexity or coupling
- improves readability or testability
- keeps regression risk controlled
- remains small enough to merge safely into
SIPS-Development