3.7 KiB
3.7 KiB
Refactor Backlog (Maintainability + System Integrity)
Last updated: 2026-03-12
Priority 1 — Split actions/index.js by concern
- Problem: Single high-coupling module mixes API clients, hash/token helpers, logging, file/email/domain operations.
- Why it matters: Hard to reason about changes; high regression risk from unrelated edits.
- Target outcome: Small modules with explicit boundaries (e.g.
relayClient,fileClient,notifyClient,caseService,authService). - Initial scope: create façade layer first, then migrate call sites incrementally.
- Detailed plan:
memory-bank/refactor-plan-actions-index.md - Test gate: add unit regression tests + coverage reporting as part of this refactor.
Priority 2 — Centralize relay/hash/token forwarding logic
- Problem:
pages/api/endpoint/**and related routes duplicate request-signing + token + forwarding behavior. - Why it matters: Security-sensitive drift and inconsistent error handling.
- Target outcome: Shared relay utility enforcing one signing contract, one timeout/retry policy, one error map, one redacted logging strategy.
- Initial scope: pilot on a small endpoint group, then roll out pattern.
Priority 3 — Extract breadcrumb/back-link route-state rules
- Problem: Navigation logic in
components/breadcrumbs.jsand case summary is branch-heavy and query-dependent. - Why it matters: Frequent regressions in search -> case -> myportal paths.
- Target outcome: Pure route-state helpers with table-driven tests; UI component mainly renders output.
- Initial scope: isolate
va/adv/ads/keydecision matrix first.
Priority 4 — Standardize security guards in pages/api/file/**
- Problem: Hash/guard enforcement appears inconsistent across file endpoints.
- Why it matters: Uneven protection for document upload/download/delete paths.
- Target outcome: Shared guard middleware for hash/auth/input validation + consistent negative-path responses.
- Initial scope: enforce a common pre-handler contract on high-risk routes first.
Priority 4 — Current slice status (2026-03-23)
- Completed on
TASK22224-file-endpoint-contract-bundle:pages/api/file/downloadblob.jshardening + hotfix closure- path normalization compatibility (filename-only + prefixed path)
- encoded/raw hash validation compatibility guard
- Confirmed outcome:
- user-reported download failures resolved
- phase21 file + combined contract suites passing
Priority 4 — Next recommended slice on this branch
- Target routes:
pages/api/file/deleteblob.jspages/api/file/deleteblobcase.jspages/api/file/deleteblobrep.js
- Scope:
- align hash canonicalization strategy with
downloadblob.js - enforce explicit
respondErrorcontracts (MISSING_REQUIRED_QUERY,INVALID_HASH, route-specific*_FAILED) - preserve existing success payload shapes
- extend
tests/phase21/file-handler-contract.test.cjswith mixed encoded/raw hash variants and negative paths
- align hash canonicalization strategy with
Priority 5 — Establish minimum automated regression baseline
- Problem: Limited automated tests for high-risk logic.
- Why it matters: Repeated regressions and heavy manual verification burden.
- Target outcome: Focused test suite for pure logic and high-risk decisions.
- Initial scope:
- breadcrumb decision matrix
- representation eligibility/date windows
- hash utility behavior
- locale rewrite mapping sanity checks
Sequencing recommendation
- Priorities 2 + 4 (security/integrity foundation)
- Priority 3 (high-change regression hotspot)
- Priority 1 (structural maintainability)
- Priority 5 (continuous safety net, starts early and expands)