Repository navigation
fix(reader-access): atomic code consume, Mailgun auth, retention and chapter route - #652
Conversation
PR #635 (spec 006) rewrote netlify/lib/reader-access/store.ts for email + device sessions and removed the verification-code exports. reader-code-request, reader-verify and reader-chapter stopped bundling, reader-session called the new two-argument API with one argument (sign-out left the server session alive), and no test failed because handlers were never bundled. - Add netlify/lib/reader-access/code-store.ts for codes, sessionId access sessions and recovery attempts, under key prefixes distinct from spec 006. - Consume codes once with a Blobs onlyIfNew marker (RA-002); upgrade @netlify/blobs 6.5 -> 11.1.6 for conditional writes. - Store the hash of the code that is emailed; previously a second, unrelated code was hashed so no emailed code could verify. - Use timing-safe hash comparison; hash readerId with SHA-256. - Mailgun client: add username 'api' so sends authenticate. - Return contract states: 502 provider-failure, 429 limited, 401 request-pending; stop echoing internal error text. - reader-retention: use the store API and run @daily. - Route /api/reader/chapters/:chapterId to reader-chapter in public/_redirects (it fell through to index.html) and netlify.toml. - Add a test that bundles every function and checks redirect targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CADHZdpaiuKYHLz2mX9por
|
Deployment failed for project thisonetimeonacidcom with the following error: Learn More: https://vercel.com/lightspeedwp?upgradeToPro=build-rate-limit |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit details
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
✅ PR Template RoutingBranch prefix: This PR's template has been automatically routed based on the canonical branching strategy defined in lightspeedwp/.github. 📋 Template routing rules:
✨ Automatic routing ensures all PRs follow the organization-wide governance structure. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CADHZdpaiuKYHLz2mX9por
|
Deployment failed for project thisonetimeonacidcom with the following error: Learn More: https://vercel.com/lightspeedwp?upgradeToPro=build-rate-limit |
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
|
CI notes on this PR:
Generated by Claude Code |
📋 Changelog Quality Validation
Status✅ Validation PASSED - No new failures introduced by this PR. No action required. |
|
No new test failures: the 66 "new" failures already exist on
Running Vitest on a clean checkout of The proposed fix is to run Vitest on base as well in Generated by Claude Code |
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
|
Queue requested — the merge queue status continues in this comment ↓. |
PR #653 (spec 006 US1) restored code storage in store.ts, unified sessions behind a token index, hashed the emailed code and fixed sign-out. Take main's version of the six conflicting files and drop code-store.ts and its test, which that design supersedes. Keep only what main still lacks: - Atomic consume-once (RA-002): store.consumeCode writes a code-consumed:<sha256> marker with onlyIfNew; session creation uses it instead of delete-first. The in-memory test store honours onlyIfNew, and a race test shows exactly one of two concurrent submissions wins (it fails against delete-first). - Mailgun username 'api'. - reader-retention store API and @daily schedule. - /api/reader/chapters/:chapterId in public/_redirects, passing the id through as netlify.toml does. - The function bundle and redirect-target guard test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CADHZdpaiuKYHLz2mX9por
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
The comparison job ran Jest on the PR base and Vitest on the head. Jest's testMatch only covers *.test.js, so TypeScript suites never ran on base and every failure in them was reported as new on each PR (e.g. 66 "new" failures on #652 that already existed on main). main now passes the full Vitest suite (1060 passed, 0 failed locally), so the Jest baseline the cutover comment relied on is no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CADHZdpaiuKYHLz2mX9por
Signed-off-by: Ash Shaw <ashley@lightspeedwp.agency>
Drift Detection ✅✅ No drift detected. Configuration is canonical. Canonical governance files are correctly centralized in lightspeedwp/.github. |
|
@Mergifyio queue |
✅ Merged into
|
Summary
This PR originally restored spec 005's code storage after PR #635 broke the reader functions. Since then, lightspeedwp/ThisOneTimeOnAcidCom#653 (spec 006 US1) landed on
mainwith its own fix. It restored codes instore.ts, put sessions behind a token index, hashed the emailed code and fixed sign-out.06621b6mergesmainand adopts that design. The six conflicting files takemain's version, and my separatecode-store.tsand its test are removed. What's left is only whatmainstill lacks:mainsession-service.tssays it is "not a true atomic consume")store.consumeCode()writes acode-consumed:<sha256>marker withonlyIfNew, and session creation uses it; the losing request gets401 verification_failedusername: 'api'reader-retention.tsimportslist/get/delete, which@netlify/blobsdoesn't export, and has no scheduleconfig.schedule = '@daily'; its skipped test is enabled (9 tests)/api/reader/chapters/:chapterIdmissing frompublic/_redirects(applied beforenetlify.toml)index.htmlnetlify.tomldoestests/reader-access/functions-build.test.tsbundles every function and checks every redirect target existsChanges
netlify/lib/blobs.ts:BlobStore.setaccepts{ onlyIfNew }and returns the write result.netlify/lib/reader-access/store.ts:consumeCode(email, codeHash).netlify/lib/reader-access/session-service.ts:createSessionFromVerificationusesconsumeCodein place ofdeleteCode.@netlify/blobs^6.2.0→^11.1.6(conditional writes; needs Node ≥ 22.12, deploys use 24).esbuild0.28.2added as an exact devDependency for the guard test.tests/reader-access/us1-test-helpers.ts: the in-memory store honoursonlyIfNew, so every US1 test runs the real consume path.consume-code.test.ts(3) and a concurrency case insession-create.test.ts.Testing
npx vitest run: 1092 passed, 0 failed (main: 1060 passed, 0 failed).main's delete-first logic (both requests get a 201), and passes withconsumeCode.npm run buildpasses;dist/_redirectscontains the chapter route.Follow-ups (not in this PR)
rate-limiter.tsis in-memory, so limits reset across function instances.createSession's device-limit check is serialised only within one function instance (noted insession-service.ts). AnonlyIfMatchcounter could close that using the same Blobs 11 upgrade.docs/reader-access-spec-005-reconcile.🤖 Generated with Claude Code
https://claude.ai/code/session_01CADHZdpaiuKYHLz2mX9por