3.4 KiB
3.4 KiB
PEDW FrontEnd Guardrails
Purpose
This document is a fast pre-flight checklist to reduce regressions in high-risk areas. Use it before coding, before opening a PR, and before merge.
Non-Negotiable Guardrails
- Auth/session integrity
- Do not bypass
next-authflow inpages/api/auth/[...nextauth].js. - Preserve secure redirect behavior and cookie/session settings.
- Do not bypass
- Security headers and CSP
- Do not weaken
middleware.jsCSP/header behavior ornext.config.jssecurity headers without explicit rationale.
- Do not weaken
- Data model safety
- Treat
prisma/schema.prismaas source-of-truth for auth/account persistence.
- Treat
- Bilingual parity (EN/CY)
- Any user-facing route/content change must validate both locales.
- Keep
i18n.js,locales/, andnext.config.jsrewrites aligned.
- Public-service reliability
- Avoid breaking core flows: search, case, account, myportal, admin.
Sensitive Flow Protection
Apply extra checks for:
pages/api/auth/**pages/api/file/**pages/api/email/**pages/api/endpoint/*_api.jshandling account/user data
Relay Hash Integrity Rules (CRM-bound APIs)
Apply when changing relay-bound portal endpoints and helpers (notably pages/api/endpoint/** and actions/index.js):
- Keep relay endpoint configuration sourced from
API_ROOT. - Preserve path-hash generation behavior:
- hash input must be request path/query (excluding domain),
- appended hash parameter must remain compatible with relay expectations.
- Do not change hash algorithm/key usage contract without coordinated relay change.
- Treat hash validation failures as security-relevant negative paths; verify graceful rejection handling.
- Never log hash key material or sensitive request payloads.
Required for sensitive changes:
- Negative-path validation (unauthorized, invalid input, malformed payload).
- Safe logging (no secrets/tokens/personal data in cleartext).
- Explicit rollback steps.
Relay Policy Change Guardrail (timeouts/retries/logging)
When changing shared relay forwarding policy (for example in pages/api/middleware/relayForwarding.js), treat this as an operationally sensitive change even if endpoint contracts are unchanged.
Minimum required before merge:
- Complete the relay governance gate in
context/runbook.md(Relay Hardening Rollout Playbook). - Attach non-prod smoke evidence for:
- deterministic non-retry classes (
400,401,403,404) - transient retry classes (
429,503, timeout/network-transient)
- deterministic non-retry classes (
- Confirm structured redacted logging and duplicate-log suppression behavior.
- Provide fast mitigation + rollback path (
RELAY_RETRY_MAX=0and commit-revert path).
Pre-PR Quick Checklist
- Ran
npm run lint(or documented why unavailable) - Verified changed routes/APIs manually
- Verified EN + CY behavior for impacted user-facing flow
- Performed accessibility smoke checks (keyboard, focus, labels, headings)
- Added risk notes (auth/data/i18n/a11y)
- Updated
memory-bank/change-log.mdfor non-trivial changes
If Assumptions Are Unclear
- Record assumptions in PR notes.
- Add unresolved items to
memory-bank/open-questions.md. - Choose the safer behavior and clearly mark as temporary.
Related Docs
.clinerulesCONTRIBUTING_AI.mdcontext/implementation-governance.mdcontext/maintainability-adoption-programme.mdcontext/runbook.mdcontext/integration-map.mdmemory-bank/README.md