TASK22224: complete documents + endpoint hygiene slices

This commit is contained in:
2026-03-24 06:12:04 +00:00
parent dfdfd3653c
commit fe394f3fa8
6 changed files with 221 additions and 189 deletions
+69
View File
@@ -620,3 +620,72 @@ Validation:
Follow-ups:
- Optional: run full repo lint in a separate pass for broader non-slice hygiene now that targeted contract suite is stable.
---
### CL-016: TASK22224 documents download contract slice
date: 2026-03-24
author: Cline
scope: `pages/api/documents/download/[id].js`, `tests/phase21/{documents-handler-contract,api-contract-slice1}.test.cjs`
type: change
rationale: Execute next aggressive slice by standardizing document download guard behavior and bringing the route under phase21 contract coverage.
impact: Improves reliability on invalid input and relay-failure paths while preserving existing user-visible fallback behavior (`/filenotavailable`) for download failures.
status: completed
Summary:
- `pages/api/documents/download/[id].js`
- added explicit required-query guard for `id` and `hash`
- unified fallback redirect path via constant (`/filenotavailable`)
- preserved streaming download behavior and retry flow
- added `tests/phase21/documents-handler-contract.test.cjs` covering:
- missing query -> redirect contract
- success -> attachment/content-type headers + stream pipe contract
- relay failure -> redirect contract
- updated combined runner (`tests/phase21/api-contract-slice1.test.cjs`) to include documents handler contract suite
Validation:
- `node tests/phase21/api-contract-slice1.test.cjs` -> pass
- helper: 4/4
- file-handler: 53/53
- email-handler: 12/12
- endpoint-handler: 152/152
- documents-handler: 3/3
Follow-ups:
- Optional future hardening: migrate documents route onto shared `respondError/respondSuccess` envelope if product requirements allow replacing redirect-style fallback.
---
### CL-017: TASK22224 endpoint legacy-comment hygiene slice
date: 2026-03-24
author: Cline
scope: `pages/api/endpoint/{createwatchedcases_api,getadvancedsearchpaged_api}.js`
type: change
rationale: Complete second requested slice with low-risk maintainability cleanup by removing large obsolete commented legacy handler blocks.
impact: Non-behavioral cleanup only; improves readability and reduces maintenance noise with no runtime contract changes.
status: completed
Summary:
- `createwatchedcases_api.js`
- removed obsolete commented promise-chain implementation block
- `getadvancedsearchpaged_api.js`
- removed obsolete commented legacy implementation block retained below active handler
Validation:
- `node tests/phase21/api-contract-slice1.test.cjs` -> pass
- helper: 4/4
- file-handler: 53/53
- email-handler: 12/12
- endpoint-handler: 152/152
- documents-handler: 3/3
Follow-ups:
- Optional further hygiene pass can target remaining oversized commented historical sections in non-sensitive handlers.