fix(cli): materialize CSV redirects into the KV decofile snapshot - #548
Open
JonasJesus42 wants to merge 1 commit into
Open
JonasJesus42 wants to merge 1 commit into
JonasJesus42 wants to merge 1 commit into
Conversation
`readDecofileFromDir` promises a decofile "byte-identical to the bundled
blocks.gen snapshot", but `generate-blocks` also injects synthetic
`__csv_redirects__*` blocks via `buildCsvRedirectBlocks` and the KV writers
did not. So `decofile:<sha>` never carried CSV-backed redirects.
Today that is masked: the bundled snapshot is still resident, so the
redirects resolve from memory. The moment the bundle stops being the
fallback — `decoVitePlugin({ fastDeploy })` stubs it to `{}` — every
CSV-backed redirect disappears and bulk-migration 301s turn into silent
404s. Sites with tens of thousands of rules are exactly the ones that opt
into fast-deploy for the memory win.
Fixed in `readDecofileFromDir` rather than in each caller, so both
`sync-blocks-to-kv` and `migrate-blocks-to-kv` are covered and the stated
byte-identical invariant actually holds. Same precedence as the generator:
a curated CMS redirect wins over a CSV row.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Sep 14, 2026
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.
Problema
readDecofileFromDirdiz produzir um decofile "byte-identical to the bundledblocks.gensnapshot". Não produz:generate-blocksinjeta blocos sintéticos__csv_redirects__*viabuildCsvRedirectBlocks(scripts/generate-blocks.ts:183,288) e os escritores de KV liam os.deco/blocks/*.jsoncrus. Logodecofile:<sha>nunca teve os redirects vindos de CSV.Hoje isso está mascarado — o
blocks.genbundlado continua residente e os redirects resolvem da memória. No momento em que o bundle deixa de ser o fallback (decoVitePlugin({ fastDeploy })stuba pra{}), todo redirect de CSV some e os 301 de migração viram 404 silencioso. Justamente os sites com dezenas de milhares de regras são os que optam por fast-deploy pelo ganho de memória.Correção
Uma chamada a
buildCsvRedirectBlocksdentro dereadDecofileFromDir, não em cada caller — assimsync-blocks-to-kvemigrate-blocks-to-kvficam cobertos de uma vez e a invariante declarada passa a valer de fato. Mesma precedência do gerador ({ ...csv, ...blocks }): redirect curado no CMS ganha de linha de CSV.Testes
3 casos novos em
fast-deploy-kv.test.ts: loader de CSV aninhado emsite.routes[](a forma que quebrou em produção — invisível paraloadRedirects, que só varre o topo), colisão de chave com bloco real, e no-op quando não há CSV. O primeiro falha sem a correção.Primeiro de uma pilha; pré-requisito para ligar o stub do
blocks.gen.🤖 Generated with Claude Code
Summary by cubic
Fixes
readDecofileFromDirso the KV decofile snapshot includes CSV-backed__csv_redirects__*blocks, matching the bundledblocks.gensnapshot. Previously those redirects were missing, so fast-deploy sites lost them once the bundled snapshot stopped being the fallback, turning migration 301s into silent 404s.Notes
sync-blocks-to-kvandmigrate-blocks-to-kvare covered.Written for commit 82e78d0. Summary will update on new commits.