Skip to content

chore(contracts): re-sync copied contracts from SahajCloud - #484

Merged
sydevs-dispatcher[bot] merged 7 commits into
mainfrom
claude/chore-sync-contracts
Nov 25, 2026
Merged

sydevs-dispatcher[bot] merged 7 commits into
mainfrom
claude/chore-sync-contracts

Conversation

@sydevs-dispatcher

@sydevs-dispatcher sydevs-dispatcher Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Re-syncs the shared atlas-URL contract to version 2, and the generated SahajCloud types.
  • Version 2 percent-encodes a non-ASCII slug in a pathname, so routeFromPathname decodes first.
  • Joined: one decode rule in path.ts — isCanonicalPath goes through decodePath too.
  • Joined: the contract spec's docstring drops case counts its own assertions already pin.

Change outline

The contract bump is what a consumer sees. The decode is what this repo had to change to meet it.

Contract — the shared atlas-URL contract, version 1 → 2

One rule per line, paraphrased from $comment and slugPattern.

 atlas-url-contract.json                      src/lib/shape/atlas-url-contract.json
-  version 1
+  version 2
-  a slug is ASCII lowercase, digits and hyphen      ^(/[a-z0-9-]+)+$
+  a slug keeps its native letters, lowercased       \p{Ll}\p{Lm}\p{Lo}\p{M}\p{N}-
+  compile slugPattern with the `u` flag             (PHP: /u)
+  `webPath` carries those letters raw
+  the URL percent-encodes them (encodeURI)
+  so a parser decodes each segment before matching
   cases
+    path routing, a native-script slug         /bg/софия → /map/bg/%D1%81%D0%BE%D1%84%D0%B8%D1%8F
+    query routing, a Latin slug with a diacritic   ?atlas=/de/trier/universit%C3%A4t-trier/1998

Types — what the generated SahajCloud types gained

Additive only, and review: skip per .claude/workflow.json. Nothing here reads them yet.

 Page                                         src/types/payload/payload-types.ts
+  parent?: Page | number | null              # the page this one sits under
+  path?: string | null                       # where it is served, as of the last save
 WmWebConfig
+  indexPages?: { meditations?, lectures? }    # the parent page each index is shown under
 ContentIndexBlock
-  type: 'meditations' | 'pages' | 'songs' | 'lectures'
+  type: … | 'user-choices'
+  userChoiceTypeFilters?: ('mood' | 'goal' | 'duration')[]
+  userChoiceFeatured?: 'featured' | 'not-featured' | 'all'

Flow — routeFromPathname, the only consumer the new rule reaches

 routeFromPathname(pathname, prefix, search)    src/lib/shape/routing.ts
   prefix does not match, or not on a segment boundary → undefined
-  route = rest
+  route = decodePath(rest)                     # one route spelling out of both URL shapes
   safePath(route) === undefined → undefined    # the guard reads the DECODED route
   return route, with ?atlas='s own query appended

routeFromParam needed nothing: it reads through URLSearchParams, so query mode always handed
safePath decoded input. The standalone BrowserRouter build never calls routeFromPathname.

Behaviour — one decode rule in path.ts

 src/lib/shape/path.ts
   safeDecode(segment)                          # one segment, tolerating a bad escape
+  decodePath(pathname)                         # every segment, rejoined
   isCanonicalPath(pathname, target)
-    safeDecode(pathname) === target            # a bad escape anywhere kept every segment encoded
+    decodePath(pathname) === target            # it costs its own segment only
   resolvePath / resolveStack                   # unchanged, already per-segment

Test results

  • Lean gate: ✓ lint, typecheck, pnpm test:run (191 files, 2420 passed, 1 skipped)
  • Targeted specs: path.test.ts, routing.test.ts, atlas-url-contract.test.ts — all green
  • Build: N/A locally — CI runs build and pnpm size

Notes for reviewer

Opened by the dispatcher contract sync (contractSync in sydevs/claude-workflow
loop-config.json), not from a ticket. Two producer merges have synced into this branch:
sydevs/SahajCloud#1269, which bumped the atlas-URL contract to version 2,
and sydevs/SahajCloud#1254, which brought the generated types at HEAD. A
later producer merge adds its commit here while this PR is open.

The widened slugPattern is compiled nowhere in this repo — our half of the contract asserts the
version and the cases, never the pattern. So version 2's Unicode widening needed no code here;
only the encoding rule beside it did.

The two joined commits came from this PR's own adversarial review, not from a reviewer: the
Streamline thread on src/lib/shape/path.ts and the docstring thread on
src/lib/shape/atlas-url-contract.test.ts.

A branch-level /security-review ran, since src/lib/shape/path and src/lib/shape/routing are
securityReview.triggerPattern paths. No findings: decoding before safePath rejects
/%2F%2Fevil.example, /%5Cevil.example and /%09/evil.example, each of which passed the guard
encoded, so the accepted set is a subset of what main accepted.

@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 2

recent dispatches
  • 19:48Z fix-ci · attempt 1 · session · done
  • 19:48Z fix-ci · attempt 1 · session
  • 19:28Z address-review · attempt 1 · session · done
  • 19:28Z address-review · attempt 1 · session
  • 19:19Z review-pr · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 25, 2026
`atlas-url-contract.json` version 2 widens a slug to any lowercase Unicode
letter and states that a canonical URL percent-encodes it, so a parser decodes
each segment before matching. `routeFromPathname` returned the encoded form, so
`/map/bg/%D1%81%D0%BE%D1%84%D0%B8%D1%8F` was a different route from query mode's
`/bg/софия` for the same place, and the fixture's own path case went red.

`decodePath` (`path.ts`, beside `safeDecode`) decodes segment by segment, and
runs BEFORE `safePath`: an encoded `//`, backslash or TAB has to meet that guard
as what it decodes to, rather than as the `%` it arrives as.

The fixture's version and emitted-case count are re-pinned to what version 2
carries. Both new `routeFromPathname` assertions were watched failing against
the encoded form.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXCcWsqnwFhrGvPn2i
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 25, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Holistic assessment

The sync is clean: this repo's copy is byte-identical to SahajCloud@main:src/lib/atlas/atlas-url-contract.json, and version 2's one behaviour change — a non-ASCII slug travels percent-encoded in a pathname and raw in webPath — is met by exactly one adaptation, routeFromPathname decoding before safePath. That order is right, and routing.test.ts pins why. Query mode and the standalone build needed nothing, and the diff correctly adds nothing there. The weak part is the body, which still describes a generated-only change.

Findings

  • should-fix — the body says "with no hand edits" and writes fix-ci's adaptation as hypothetical, but the branch carries a hand-written routing change in routing.ts and path.ts that no ## Summary bullet names. It also cites SahajCloud#1269 while HEAD syncs #1254. (PR body — no inline thread.)
  • should-fix — Streamline: isCanonicalPath should decode through decodePath, leaving one decode rule in the file. src/lib/shape/path.ts:29
  • consider — the docstring's spelled-out case counts duplicate the two assertions below them. src/lib/shape/atlas-url-contract.test.ts:23

What was checked

  • Contract identity, against origin/main:src/lib/atlas/atlas-url-contract.json in the SahajCloud checkout: byte-identical.
  • Read whole on the branch: path.ts, routing.ts, atlas-url-contract.test.ts, query.ts, atlas-history.ts, router.tsx.
  • The consumer sides held for a reason: routeFromParam reads through URLSearchParams, so query mode's safePath always saw decoded input, and the standalone BrowserRouter build never calls routeFromPathname.
  • Ladder: one new piece, decodePath. Streamliner: 1 covered, 1 kept, 1 finding, which held.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/lib/shape/path.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
`isCanonicalPath` decoded the whole pathname at once, so a single
malformed escape anywhere in it left every segment encoded and the
canonicalize comparison came back false. `decodePath`, added on this
branch for `routeFromPathname`, already decodes segment by segment, so
pointing the predicate at it leaves the file with one decode rule and
gives `decodePath` the second caller that stops it being a middle layer.

The new assertion was watched failing against the whole-string decode.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMtpJ5wtbFhvtsUFk
The docstring spelled out how many cases refuse and how many emit, which
`expect(refused).toHaveLength(8)` and `expect(emitted).toHaveLength(15)`
already pin ten lines below it. Every contract bump had to hand-edit the
prose to keep it true, and the sync that bumped to version 2 did exactly
that. The ⚠ and the reason stay; the numerals go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMtpJ5wtbFhvtsUFk
@sydevs-bot

Copy link
Copy Markdown
Contributor

Three points from the adversarial review, all adopted. Pushed a27ee31.

  • Streamline — one decode rule in path.ts → 2a8299d. isCanonicalPath reads decodePath, which gains its second caller.
  • The docstring's spelled-out case counts → a27ee31. The numerals go; the ⚠ and the reason stay.
  • Review body: "the body says 'with no hand edits' … It also cites SahajCloud#1269 while HEAD syncs #1254." The body is rewritten. It now carries a Change outline, a Summary bullet per hand-written change, and both producer merges — #1269 bumped the contract to version 2, #1254 brought the generated types at HEAD.

Lean gate green: lint, typecheck, 2420 unit tests. /security-review ran on the branch and found nothing.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 25, 2026
@sydevs-dispatcher
sydevs-dispatcher Bot marked this pull request as ready for review November 25, 2026 19:43
@sydevs-dispatcher
sydevs-dispatcher Bot requested a review from Ardnived November 25, 2026 19:43
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 25, 2026
@sydevs-dispatcher

Copy link
Copy Markdown
Contributor Author

Not approved automatically: it changes more than the copied contract. It needs a person's review.

🤖 sydevs dispatcher

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 25, 2026
`sy-atlas-translations` no longer declares a `compact` group: sydevs/SahajCloud#1268
retired it with the compact card it labelled, and dropped its jsonb column. The
generated type arrived in this branch's last re-sync, so `WidgetTranslations`
`Pick`ed a key `SyAtlasTranslation` no longer has, and `pnpm typecheck` failed with
TS2344 — which took the build and, behind it, the preview the smoke lane reads.

The tab list is stated in three places that cannot import one another, and all
three lose the member: the constant, the SDK `select`, and the node script.
Requesting a field the global has dropped is also a read this widget no longer has
any answer for.

`translations.en.json` keeps `compact.open`, and the card keeps asking for it. The
snapshot is i18next's boot resource, so the one call site still resolves against
compiled English while the group is gone upstream. Regenerating it here would pull
in `common.map.expand`, `common.map.close` and `countries.place_title`, which
nothing in this repo references yet. #466 removes the card and
wires those three, running `pnpm sync:translations --write` itself.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX3jiAvDARU96rnGNV
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 25, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design a27ee31 Nov 25 2026, 07:40 PM

@sydevs-dispatcher
sydevs-dispatcher Bot added this pull request to the merge queue Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 25, 2026
Merged via the queue into main with commit 69d081c Nov 25, 2026
28 checks passed
@sydevs-dispatcher
sydevs-dispatcher Bot deleted the claude/chore-sync-contracts branch November 25, 2026 20:27
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants