Repository navigation
feat(core-ts): collection permalinks, step 2 — redirects, overlap checks, search - #73
Merged
Merged
Conversation
…cks, search RFC-0038 / ADR-0040, step 2: - Changing a collection's template adds a prefix redirect (old → new) in the same atomic batch as the site CAS, for the default locale and each other site locale; RedirectPlan collapses chains and drops a redirect that would point at itself. `OpBatch.anchorOn` anchors the redirect writes on the site's new hash; a failed op guard is a missed CAS. - A changed template must not overlap another collection's prefix, a taxonomy archive, a page at or under it, media, /search or a locale prefix (`path_conflict`, `reserved_path`), guarded on the CAS. - Pages and taxonomy archives can no longer move into a configured collection prefix (checks and guards on the site row). - Search rewrites every entry row when a published snapshot's templates differ from the indexed one. Tests run on sqlite, D1 and Durable Object SQLite; the renderer serves /blog/<slug> and redirects /posts/<slug>. Refs #50 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Madraka <[email protected]>
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.
RFC-0038 / ADR-0040, step 2 of 3. Refs #50.
Redirects on change
SiteEngine.update→store/site-permalinks.ts. For each collection whose effective template changes, aRedirectPlan.move(oldPrefix, newPrefix, { match: "prefix", reason: "slug-change" })is emitted into anOpBatchanchored on the site's new hash (OpBatch.anchorOn), in the same atomic batch as the site CAS (rule 4)./posts→/blog→/journalsends/posts/xstraight to/journal/x), and moving back to the default drops the self-redirect.ConflictErrorbefore planning. A failedop_guardsassertion counts as a missed CAS, so nothing is written.Overlap checks, both ways (
permalink-paths.ts)/search, or a locale prefix. The result ispath_conflict/reserved_path, guarded on the CAS (noArchiveOverlapping,noPageWithin)./<collection>prefix keeps today's rule, where a page wins.Search
planSearchrewrites every entry row when a published snapshot's templates differ from the indexed one.Tests (one package at a time)
testing-permalinks.tssuite runs on sqlite, Miniflare D1 and Durable Object SQLite. It covers the moves, chains, back to default, overlaps, the reverse checks, stale and racing writers, and search hrefs./blog/hello-worldand 301s/posts/hello-world?ref=x→/blog/hello-world?ref=x, on live and snapshot sources.taxonomy.tsshrank, so the size baseline is lowered.Open questions (follow-ups, not blockers)
/<collection>, and creating an entry in a new collection whose default prefix overlaps another collection's configured prefix is not refused. In that caseentryAtprefers the configured one.updateTaxonomywrite per-locale redirects too, so both behave the same?/posts→/posts/archive) is refused by RedirectPlan's loop check asinvalid_redirect, notpath_conflict.🤖 Generated with Claude Code