Repository navigation
Re-embedding every page needs a bearer - #4
Merged
Merged
Conversation
POST /api/embeddings?refresh=1 (upstream's --refresh) re-embeds every page, billed to the owner's Workers AI. In baseline-v1 anyone who found the URL could trigger it. It now needs Authorization: Bearer <REINDEX_TOKEN>. - REINDEX_TOKEN is an optional Orun secret per environment (optionalSecretEnv). The build runs without it (env -u), and tooling/wire/worker-secrets.mjs hands it to the Worker as a Worker secret (wrangler secret bulk, value over stdin) on the deploy lane only. - With no token stored, refresh=1 answers 403. A missing bearer, a wrong one, or the token without "Bearer" also gets 403. Every refusal happens before the database or the model is reached. The bearer is compared in constant time over SHA-256 digests (lib/reindex.ts). - The plain POST, which the deploy's smoke calls, is unchanged and open: unchanged checksums make it skip every page, and the advisory lock keeps concurrent calls to one embedding. - tests/web asserts the 403s embed nothing and change no row, that the right bearer re-embeds the whole index, that the plain POST ignores any bearer, the constant-time compare, worker-secrets.mjs, and that the token is never a wrangler var (37 tests to 46). - The e2e gives the dev Worker a random token. It asserts three refusals that embed nothing and change no stored page, then one full re-embed with the right bearer. The stand-in's exact count of page embeddings goes from 3 to 4 to cover that one. - Placement holds REINDEX_TOKEN as web's optional, per-environment key. It is kept out of the bundle and handed to the product's own Worker, and every other key is still exactly the minted or published set. - The product README gains "Re-embedding every page" (store, redeploy, curl, turn off). The deployment record lists the secret. Risk DQ-E becomes "plain POST open by design, refresh gated". Departure 16 and task DQ-4 are recorded. Co-Authored-By: Claude <noreply@anthropic.com> Orun-Task: DQ-4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POST /api/embeddings?refresh=1 (upstream's --refresh) re-embeds every page, billed to the owner's Workers AI. In baseline-v1 anyone who found the URL could trigger it. It now needs Authorization: Bearer <REINDEX_TOKEN>.
🤖 Generated with Claude Code