Repository navigation
feat(routing): resolve Unicode place slugs from encoded and raw URLs - #483
Conversation
Slugs keep native letters now (SahajCloud#1269). Browsers hand the widget percent-encoded pathnames while webPath is raw Unicode, so every slug comparison decodes each segment and composes to NFC. - safeDecode: NFC, exported; isCanonicalPath and placePathsOf decode both sides - resolveStack: reserved words matched on the decoded segment - routeFromPathname: decodes pathname and prefix per segment (structural escapes such as %2F stay encoded) and returns the raw route - routeFromParam: NFC-normalises the route - useRecoveryOffer: home-path check uses isCanonicalPath - sync atlas-url-contract.json to version 2 (slugPattern needs the u flag) - docs/embedding.md and CHANGELOG.md: slugs may be non-ASCII, arrive encoded Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
|
Not fixable from this repo: the contract copy is ahead of its source.
Reverting the copy to version 1 would undo this PR and break The rest of the gate is green at This turns green once #1269 merges and CI runs again. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
CHANGELOG.md's Changed list conflicted: both sides added a new top entry. Kept both, newest first — this branch's Unicode slug note, then #482's map control column. docs/embedding.md took both sides without a conflict. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjY9msth6LhizDaTFBN
|
Merged
Lean gate green on the merge commit: lint, typecheck, 2458 unit tests.
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Nothing to fix here. The blocker is still the one in my earlier comment: New fact for whoever merges the pair: So merge #1269, and this gate should pass on its next run. Pushed nothing. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | f4c80d7 | Nov 25 2026, 08:39 PM |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of the problem. One decoder, NFC at the read boundaries, and the contract bump that forced it — nothing smuggled, and the use-recovery-offer.ts line falls out of isCanonicalPath changing. It leaves behind a second pathname decoder, a second decode pass, and two /^\d+$/ tests reading the raw segment while all around them reads the decoded one.
The contract holds from all three sides. Byte-identical to SahajCloud#1269's copy and to SahajAtlasWordpress#98's, which compiles slugPattern with /u.
One body claim does not. Only #98 exists — WeMeditateWeb has no such PR, and needs none: canonicalAtlasRoute on its main already decodes per segment and normalises (lib/atlas/route.ts:107).
Findings
should-fixpath.ts:334— a reachable second decode:/bg/%25D1%2581…resolves to софия.should-fixrouting.ts:331— Streamline: two pathname decoders; fold this one intosafeDecode.should-fixpath.ts:316— the event-id test reads the raw segment, diverging from both ports.considerpath.ts:24— NFC stops here;hierarchy.tsand SahajCloud's parser do not normalise.considerpath.ts:302— Streamline: one fact stated four times.
What was checked
Read whole: path.ts, routing.ts, hierarchy.ts, use-recovery-offer.ts, three specs. Consumers followed: WeMeditateWeb lib/atlas/route.ts, SahajCloud atlasRoute.ts and tests/contract.php in #98. Ladder walked for 2 new pieces; streamliner covered 2, kept 1; no new dependency. Reproduced the double decode from the branch's own safeDecode/placePathsOf. No previewUrl or fixture in .claude/workflow.json on main, and demo slugs are ASCII (src/mocks/sahajcloud-demo.ts:368), so "No preview surface" stands. A whole-file pass on path.ts found nothing else to fold.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`placePathsOf` decoded both the Map key and the lookup, so a slug spelling the literal percent-escapes of another resolved to that other place: `/bg/%25D1%2581%25D0%25BE%25D1%2584%25D0%25B8%25D1%258F` decoded once to `%D1%81%D0%BE%D1%84%D0%B8%D1%8F` and again to `софия`. Every caller reaches it through `placedPathname`, which takes the slug off a `StackEntry` — already decoded by `resolveStack`. So only the key side needs the decode, for the raw CMS slug it is built from. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZ1ZYcZ63TU2JMw2Ug
The malformed-escape branch skips the structural test the success branch runs, which is safe only because NFC cannot compose one of those characters. Nothing said so, and widening the class would make the omission load-bearing. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZ1ZYcZ63TU2JMw2Ug
|
Five threads adopted. Body refreshed.
Seven new cases, each watched failing. Gate and security clean. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Not this PR's failure, and the fix is already green in #484.
sydevs/SahajCloud#1268 merged at 19:34Z and dropped the This head's committed tree is clean — #484 already removes Merge #484, then merge 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
`main` solved the same decode through #484: a private segment decoder plus an exported `decodePath` wrapper. This branch's `safeDecode` already decodes a whole pathname segment by segment, so `decodePath` merged in as the same function twice over, and the branch's review had removed a second decoder once already. The survivor is `safeDecode`, carrying `decodePath`'s ordering warning, and `routeFromPathname` decodes once at the top, where it also reaches the mount prefix. `isCanonicalPath` keeps this branch's two-sided decode, which satisfies main's new segment-wise assertion as well. One assertion could not hold both ways. `safeDecode` refuses to decode a segment whose decoded form would carry `/`, `\`, `?`, `#`, `%` or a control character, so `//evil.example` can never be composed out of one slug and `safePath` is never handed a structural character — where main expected `routeFromPathname` to refuse the route outright. Both readings are safe and this one is the branch's, already pinned from the other side by `unicode-slugs.test.ts` ("encoded structure is never decoded"). The case stays, asserting what the merged decoder does; a review thread carries the choice. The contract fixture's docstring takes main's numeral-free refusal paragraph next to this branch's percent-encoding paragraph, so a contract bump no longer edits prose the assertions already pin. Lean gate: lint, typecheck, 2469 unit tests, green. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYKLbZvjAELQTMeE6C
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
Merged
One assertion could not hold both ways. The thread on Lean gate: lint, typecheck, 2469 unit tests, green. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Your answer settles the last open thread. Option A was the built one, so nothing was pushed.
No code changed this run, so CI on Body: one line under Notes for reviewer, recording that #484's refusal assertion was inverted by your answer. Nothing else in it was made false. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
There was a problem hiding this comment.
Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. 🤖 Written by the sydevs autonomous loop — see what this is
Two conflicts, both in the host-facing docs, and both only because #483 re-padded every Markdown table in `docs/embedding.md` while this branch was rewriting rows inside two of them. `docs/embedding.md` — the Parameters and Troubleshooting tables take this branch's rows. Normalising whitespace shows `main` changed nothing in either table but the separator width, so there was no second behaviour to keep. #483's own addition, the percent-encoded-slug bullet under indexing, merged on its own and stands. `CHANGELOG.md` — both entries stay, #483's first, where `main` has it. Also here: #483's entry carried no `([#483])` reference or link definition, which this file's preamble asks of every entry. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVmTA19YX1sUErABdU
… a Unicode slug #483's `indexRegions(...).bySlug` answers to a slug's raw and NFC spellings, and a slug decoded off the URL is NFC. The heading's own Map keyed the raw one, so a slug typed by hand in NFD named nothing. SahajCloud generates NFC slugs, so no live place was affected. Watched failing first: the new encoded and raw München cases, against the hand-rolled Map. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
/bg/софия,/de/trier/universität-trier). The widget resolves them from percent-encoded and raw URLs alike.atlas-url-contract.jsonto version 2, from feat(slugs)!: keep native letters in slugs, in every script SahajCloud#1269, which has merged — soContract checknow reads version 2 from both sides.Change outline
Behaviour — reading a URL into a place
src/lib/shape/path.ts safeDecode(pathname | segment) → exported; decodes each segment, + NFC. One decoding to / \ ? # % or a control char stays encoded, so `/a%2Fb` is one segment to every caller. resolveStack → RESERVED_SLUGS / search / calendar AND the event-id test all read the decoded segment resolvePath → same terminal rule, on the decoded segment isCanonicalPath(a, b) → compares both sides decoded placePathsOf → Map keyed by decoded NFC slug; the lookup does not decode again src/lib/shape/hierarchy.ts indexRegions → bySlug answers to both spellings of a slug src/lib/shape/routing.ts routeFromPathname(pathname, mount) → decodes both through safeDecode, returns the raw Unicode route routeFromParam(?atlas=) → + NFC src/hooks/use-recovery-offer.ts → home-path check uses isCanonicalPath, not !==One decoder, in
path.ts.routing.tsheld a second one until the review.Writing a URL (
hrefFor/pathHrefFor) already percent-encodes, which is what the contract expects.Preview
No preview surface: the fixture regions are ASCII, so the new paths are only exercised by the unit tests.
Contract impact
src/lib/shape/atlas-url-contract.jsonis now version 2: a UnicodeslugPattern, compiled withu, and two percent-encoded cases.docs/embedding.md("The URL") andCHANGELOG.mdnow say that a place slug may be non-ASCII and arrive percent-encoded.canonicalAtlasRouteon itsmainalready decodes per segment and normalises.Test results
check.sh): ✓ — lint, typecheck, 2464 unit tests, on the review commits.src/lib/shape/unicode-slugs.test.ts: 47 cases (Cyrillic, Latin with diacritics, Armenian), raw and encoded, plus NFD input and%2F/%5Cstaying encoded. Seven are the review's: the double decode, the encoded event id in both resolvers, the widened structural guard, a malformed escape, and the index answering to both spellings of a slug. Each was watched failing against its own defect.Notes for reviewer
indexRegionsnow keysbySlugby both spellings, so a hand-typed NFD CMS slug resolves from a URL and from the ancestry climb alike. The cross-repo half is open: SahajCloud'sparseAtlasRoutedecodes without composing, so an NFD address resolves here and 404s there. Tracked as fix(slugs): parseAtlasRoute decodes a route without composing to NFC SahajCloud#1274, which is not a blocker for this PR./bg/sofiya) stop resolving once SahajCloud renames its regions. The owner accepted this./map/%2F%2Fevil.exampleresolves to/%2F%2Fevil.examplewheremainreturnedundefinedafter chore(contracts): re-sync copied contracts from SahajCloud #484.safeDecode's guard is what keeps a separator out of the decoded route, androuting.test.ts:381pins it. Settled on the review thread.🤖 Generated with Claude Code