M1 slice 4: amicode service — paper library (GET/POST /amicode/library) - #469
Conversation
…fork-parity fixtures M1 slice 4 of #451: GET/POST /amicode/library — 2 more fork routes (15 of 31 total). library.ts ports verbatim (pure Node): listing with added_ms ordering, upload with filename sanitization (PDF-only, conservative charset, 120-char cap), size cap, %PDF- magic check, and the refreshed-listing return. Seeded papers get pinned mtime epochs; a route-WRITTEN paper's added_ms is wall-clock by nature (the write happens mid-arc), so the replay normalizes post-seed timestamps to <NOW> on both sides — the recorder now stamps meta.seededAt for exactly this. Golden fixtures: 35 → 40 entries (seeded listing, valid upload + refresh, bad_filetype refusal, missing-field refusal, post state). Contract suite 43/43; typecheck clean.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe extension adds PDF library listing and upload routes. It validates filenames and PDF data, limits uploads to 30 MB, seeds deterministic library fixtures, and normalizes replay timestamps. ChangesPDF library service
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The library routes are a localized change with clean contract and typecheck results; no actionable merge-blocking risk remains beyond normal checks. Sequence Diagram(s)sequenceDiagram
participant Client
participant AmicodeService
participant LibraryService
participant LibraryFilesystem
Client->>AmicodeService: GET or POST /amicode/library
AmicodeService->>LibraryService: listLibrary or saveLibraryFile
LibraryService->>LibraryFilesystem: read, validate, or write PDF data
LibraryFilesystem-->>LibraryService: files or write result
LibraryService-->>AmicodeService: JSON listing or error
AmicodeService-->>Client: HTTP response
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Part of #451 (M1 slice 4; not closing).
What's here
Two more fork routes ported (15 of 31 total): GET/POST
/amicode/library— the user's uploaded-paper library. Ported verbatim (pure Node): listing ordered byadded_ms, upload with PDF-only filename sanitization, 30 MB cap,%PDF-magic check, and the refreshed-listing return so the client renders in one round-trip.Parity proof
Golden fixtures grow 35 → 40 entries (seeded listing newest-first, valid upload + refreshed listing,
bad_filetyperefusal, missing-data_b64refusal, post-upload state). Seeded papers get pinned mtime epochs; a route-**written** paper'sadded_msis wall-clock by nature (the upload happens mid-arc), so the replay normalizes post-seed timestamps to<NOW>on both sides — the recorder stampsmeta.seededAtfor exactly this rule, mirroring the existing<ELAPSED>discipline.Verification
Contract suite 43/43; typecheck clean.
Summary by CodeRabbit
New Features
Bug Fixes