Repository navigation
feat(access): derive the routing mode on the server, so the widget stops taking it from the script URL - #774
Conversation
Path routing was configured by `?routing=` on the host's script tag, copied into the readiness marker, and read back out of `verified.routing` to shape public canonical URLs. That is circular: the widget was repeating what it had been asked to do, and nothing could verify it. The CMS now observes the fact instead. `probePathRouting` renders `<canonical.embed>/<random-token>` and, only when that carries the readiness marker, the control `<origin>/<random-token>`. A positive needs the marker under the prefix and its absence at the origin — the control is what a host mounting the widget on its own 404 page fails, which looks identical to a working rewrite until you ask for a path outside the mount. The verdict lands in `canonical.verification.pathProbe`, a sibling of `verified` rather than a key inside it: `verified` is null until the mount verification first succeeds, and a client should path-route as soon as its host serves the subtree, whether or not it is publishing canonical URLs yet. `effectiveRouting()` is the one reader, consumed by `canonicalOwnerFrom`, the admin picker's preview, and the widget through a virtual `canonical.effectiveRouting` field on the `canonical` group it already selects. `verified.routing` stays on the record, still written from the marker, and now shapes nothing. Two rules the ladder exists to keep: - Promote on one positive, demote only after PATH_PROBE_FAILURE_LIMIT consecutive negatives. A wrong `path` 404s every deep link; a wrong `query` only produces uglier URLs that work. - Its own counter, never `failureCount`. That one becomes `disable`, which switches canonical ownership off and emails the manager — and a routing negative means the embed is present and publishing, not gone. No migration: `pathProbe` is an optional key in the existing JSONB column and `effectiveRouting` is virtual. Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tg5Wb6XAiBgzxYFYRnpmia
…rdict Unit: the two probe URLs come off the mount key alone, a query-carrying mount is a negative with no render spent, the control render is spent only after a positive, and a control that also carries the marker refuses the promotion. Plus the ladder — promote on one, demote on the Nth, inconclusive is a no-op, and the probe's strikes move independently of `failureCount`. Integration: the job promotes, demotes without touching ownership, counts a negative without a render when the mount itself failed, and leaves everything alone on an inconclusive run. A row whose verification predates `pathProbe` still saves — the column is closed and validated on every save of the document. The on-demand endpoint is driven once so its wiring is exercised, not just its helpers. The three existing `path` fixtures now set `pathProbe`, because a `path` self- report no longer shapes a URL. `canonical-embed-picker` keeps a case for that directly: the picker previews `?atlas=` for a client whose marker claims path. Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tg5Wb6XAiBgzxYFYRnpmia
Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tg5Wb6XAiBgzxYFYRnpmia
…nvention Four findings from the review pass, applied as one: - `canonicalTargetForHost` takes `routing` as its own required argument. A `VerifiedEmbed` structurally satisfied its old `host` parameter, so `canonicalTargetForHost(verified)` compiled and shaped a public URL from the widget's self-report — the exact circularity this branch removes, held out only by comments at three call sites. Every caller now has to say where its verdict came from. - The probe's render classification delegates to `resultFromRender` instead of repeating its switch. The failed/inconclusive split is what the whole design rests on and is pinned by the live Cloudflare error-code fixtures; a parallel copy could drift from it with only one side under test. - `probeForOutcome` moves beside `probePathRouting` and is shared by the job and the on-demand endpoint. The endpoint had restated the gate as a ternary that already dropped the `detail` the job attaches. - The probe's reason is logged at the verdict-change site. It was constructed five times and read nowhere, and it is the one thing an operator would want when their URLs change shape. Also: drop the unused `PathProbe` alias, the endpoint's hand-drop of the virtual field (Payload ignores virtual fields on write — now pinned by the fixture that spreads a read `canonical` straight back into an update), and the single-use selector argument on the probe's render seam. Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tg5Wb6XAiBgzxYFYRnpmia
…L shape Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tg5Wb6XAiBgzxYFYRnpmia
|
🚅 Deployed to the SahajCloud-pr-774 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is no larger than #644 asks for. Its one edit beyond the ticket, a required routing argument on canonicalTargetForHost, earns its place: it makes the circularity a type error, not a comment. pathProbe as an optional sibling of verified is the right shape.
Unaddressed is the deploy. effectiveRouting defaults to query and nothing backfills, so every live canonical on path today reshapes to ?atlas= until that service is re-probed. The type contract is safe: ClientSchema is a non-strict z.object.
Findings
- should-fix — no backfill, so live
pathcanonicals flip on deploy (verification.ts:242) - should-fix — "Verify now" can exceed the edge's 100s ceiling (
verifyEmbed.ts:100) - consider — the picker's two sample branches disagree (
model.ts:183)
Checked — the diff; verification.ts, verifyEmbed.ts, regionOwners.ts, canonicalUrl.ts, VerifyEmbeds.ts, model.ts whole; #644; RENDER_TIMEOUT_MS; SahajAtlasWeb client.ts and mountDecision; SahajAtlasWordpress embed.php.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
"Verify now" ran three 45s renders end to end on the promote path — mount, probe, then control. Cloudflare abandons an origin response at 100s, and the row is written before the response, so the one press that actually promoted a service answered the operator with a 524 while the promotion had already landed. The old ceiling was one render. Starting the probe and control renders together puts the worst case at 90s, under that ceiling. The verdict logic is untouched: it still reads the probe first and returns its verdict unless positive, so promote-on-one and demote-after-N are byte-identical. Only the render spending changes — a host that fails the probe now costs the control render too, where it used to be skipped. #644 budgets three renders an enabled owner, and that is what this spends. The alternatives all cost more: leaving the control to the nightly job weakens the positive condition the ticket makes load-bearing, and a shorter probe timeout would permanently bar a slow-but-path-routing host from promotion. Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0121ycjeCPK3qtxWiQkqfhBJ
The picker's two sample branches answered different questions. The verified branch read the derived verdict; the provisional one still read `mount.routing`, the widget's report of its own script parameter. So an operator setting up a fresh embed on a host reporting `path` saw a path-routed sample, watched it flip to `?atlas=` the moment verification succeeded, then flip back after the first positive probe — three shapes for one unchanged host, none of them a promise. Reading `effectiveRouting(verification)` in both branches means the preview only ever moves when the verdict moves. It also removes the last read of a script-URL routing value left in this repo, which #644's first acceptance criterion asks for. `sampleIsProvisional` still marks this branch: nothing has verified the mount, which is a separate fact from which shape it will publish. Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0121ycjeCPK3qtxWiQkqfhBJ
`probePathRouting` no longer skips the control render on a negative probe, so the rule documented here — "only when that one carries the marker" — was stale. States the latency reason (Cloudflare's 100s origin ceiling against three sequential renders) and the render budget it now spends. Refs #644 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0121ycjeCPK3qtxWiQkqfhBJ
|
Addressed the review — two adopted, one question. Pushed 56084a4. Adopted
Asked
Lean gate green, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The reviewer settled the one open question on #774: do not backfill `canonical.verification.pathProbe`, because every existing embed has to be verified by hand again regardless. That decision has a consequence an operator must act on — a service publishing `path` canonicals today reshapes to `?atlas=` on the deploy, and the nightly job can be up to 8 days out in backoff. Left only in a resolved review thread, nobody deploying this would find it. So it goes where the last post-deploy step went: a DEPLOYMENT.md subsection, with a one-line pointer from the routing rule. No behaviour change. The code already does not backfill. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cj3GqVy64krrjw4C5gbJgJ
Ardnived
left a comment
There was a problem hiding this comment.
Instead of separating the path probe from the existing verification. Wouldn't it be cleaner and more efficient to do both of them together as one process?
|
The last open question is settled. Pushed d43cc56, documentation only. Settled
Lean gate green (1808 passed). No migration. Nothing is left to decide before merge. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Review: `verified.routing` duplicated the probe's verdict, and one question must have one answer on the record. The verifier no longer copies the readiness marker's `routing` into the verified snapshot. The routing answer is `routingProbe` alone. Nothing is lost: the widget's own report is still kept, as a report, per mount, in `embedMetadata` — which is where a self-report belongs. The schema key stays as an optional legacy property rather than being deleted. `verified` is a closed object that Payload validates on every save of the document, so removing it would make every row verified before this change unsaveable until the job rewrote its snapshot. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HL2PLXNziNz1N6T3ULwmRe
|
One adopted, three back to you. Pushed a030a1a — lean gate green (1809 passed). Adopted
Back to you — each is a call I should not make alone
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Nothing pushed. The one open thread is a call I should not make alone. Asked — Three call sites never read through Payload. They hold the verification object they are about to write — Say the word and I push that shape. Stored, not computed rests on the same answer. Branch unchanged at a030a1a. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Deletes `effectiveRouting` and inlines `?? 'query'` where each reader needs it, as the reviewer asked on #774. The default is not repeated needlessly: the `canonical.routing` `afterRead` hook is the only site on a read path, and it is what the widget reads. The rest hold a verification object they are about to write or have just written (`VerifyEmbeds`, the `verifyEmbed` endpoint), or read the row through their own `select`, which does not run the hook (`canonicalOwnerFrom`, the admin picker). No behaviour changes. The unit specs that asserted through the function now read the stored verdict directly; the read-path default stays pinned by `client-canonical.int.spec.ts`, which already asserts `canonical.routing` is `query` for an unprobed row. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SWGXpkqshwdPz7wWrC7ghG
|
Adopted and pushed 122d393. Lean gate green (1955 passed), Adopted — delete the function, inline the default (5bebd53). The same commit settles stored, not computed. Both threads resolved.
Still open, your call: should the probe and the mount verification be one process? 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
<canonical.embed>/<random-token>plus a control at the origin root.canonical.verification.routingProbe, and it is the record's only routing answer —verified.routingis no longer written at all.verification?.routingProbe?.verdict ?? 'query'. There is no accessor in between: the default is applied on the read path by thecanonical.routingafterReadhook, and by hand at the sites that never read through Payload.canonical.routingfield — no new endpoint, no newselectkey, no migration.Changes
src/lib/embedVerification/verifyEmbed.ts—routingProbeUrls(both URLs derived from the mount key, in one place) andprobeRouting, plus the sharedprobeForOutcomerender gate. The probe's two renders start together — see the review rounds below.src/lib/clients/verification.ts—nextRoutingProbeState(the ladder) andROUTING_PROBE_FAILURE_LIMIT, plus the doc block that states how to read the verdict.src/lib/atlas/canonicalUrl.ts—canonicalTargetForHosttakesroutingas a required second argument, so passing aVerifiedEmbedstraight in no longer compiles.src/jobs/VerifyEmbeds/VerifyEmbeds.ts,src/collections/Clients/endpoints/verifyEmbed.ts— both fold the verdict in through the same gate, in one pass and one write.src/components/admin/CanonicalEmbedPicker/model.ts— both sample branches read the derived verdict, so the picker's preview is the shape the resolver emits.DEPLOYMENT.md,docs/rules/api-clients.md— the post-deploy step the no-backfill decision needs, and where the default lives.Review round 3 — the reader (2026-09-13)
effectiveRoutingand move?? 'query'into the call sites (5bebd53). The function is gone. Six readers now spell the verdict out, and only one of them is on a read path: thecanonical.routingafterReadhook, which is what the widget reads. The rest hold the verification object they are about to write or have just written (VerifyEmbeds, theverifyEmbedendpoint), or read the row through their ownselect, which does not run the hook (canonicalOwnerFrom, the picker).canonicalOwnerFromnow readsverification.routingProbe.verdictwith nothing in between.No behaviour changed. The unit specs that asserted through the function read the stored verdict directly now; the read-path default stays pinned by
client-canonical.int.spec.ts, which already assertscanonical.routingisqueryfor an unprobed row.Review round 2 — naming (2026-09-12)
Three review comments, one commit each. All three are renames: no behaviour changed, and nothing carries the stored key yet, so no row is stranded and no migration appears.
strikesreads better asfailedAttempts(338e9dd). The counter now says what it counts, beside theattemptslog it is about.pathProbeshould name the question, not one answer (4dd1ac0). The stored key isroutingProbe, and the symbols follow:ROUTING_PROBE_FAILURE_LIMIT,RoutingProbeResult,RoutingProbeDeps,nextRoutingProbeState,routingProbeUrls, andprobeRouting— which answers which routing a host supports, not only whetherpathworks. A second routing shape can ride the same ladder without a third name.effectiveRoutingshould just berouting(e72b0ce). ⚠ The name was free but not unclaimed: feat(access): add embed metadata and canonical ownership to Clients #633 deleted a hand-typedroutingfield and a spec pinned its absence by name. That spec now pins what the deletion actually protected — the field isvirtual(no column for a write to land in), admin-readonly, and hook-computed. Verified by removingvirtualand watching it fail.verified.routing, soroutingProbeis the record's only routing answer. The key stays in the schema as an optional legacy property:verifiedis closed and validated on every save, so deleting it would strand every row verified before this change.Still open: should the probe and the mount verification be one process? Answered in a comment below rather than guessed at — they already share one pass and one write, and what is deliberately separate is the counter and the render gate. The one thing that would change is worth a decision, not an assumption.
Rebutted: a shared
ProbeResulttype.RoutingProbeResultis flat — a status plus a detail string.VerificationResultis a discriminated union whose arms carry different payloads. Only the wordinconclusiveis shared, and neither is generated.Review round 1 (2026-09-12)
The adversarial review left three findings, and the reviewer settled the one question they raised. One commit each.
mount.routing, so a fresh embed on a host reportingpathshowed three URL shapes for one unchanged host. Both branches now read the derived verdict. This also removes the last read of a script-URL routing value in the repo, which the first acceptance criterion asks for.pathtoday reshapes to?atlas=on the deploy and the nightly job can be 8 days out in backoff. That step is now aDEPLOYMENT.mdpost-deploy subsection, beside feat(translations): adopt availableLocales, per-locale publish status and the English merge for WeMeditate App #709's, with a one-line pointer fromdocs/rules/api-clients.md. No behaviour changed.Preview
sahajcloud-sahajcloud-pr-774deployed clean on 56084a4. The rename, theverified.routingremoval and the reader commit are behind it.Contract impact
src/payload-types.tsgainscanonical.routingandcanonical.verification.routingProbe, both additive.atlas-url-contract.jsonis byte-identical: this changes which value selects a URL shape, never the shapes themselves.The consumer half is named in #644's Downstream impact and is not filed — a ticket needs approval, and the trigger comment authorised one (SahajAtlasWordpress#20, below). sydevs/SahajAtlasWeb still has to drop
?routing=(src/loader/config.ts:99,167), addcanonical.routingtoClientSchema, and pass it tomountDecision; it runspnpm types:cmsagainstmain, so it is blocked on this merging.Filed per the trigger comment: sydevs/SahajAtlasWordpress#20 — a query-routed host's SEO takeover never engages, so core's
rel_canonicalemits a canonical contradicting the one we publish. Independent of this PR, and the strongest argument for promoting topathwherever the probe can see it.Migration
None, deliberately.
routingProbeis an optional key inside the existingcanonical_verificationJSONB column androutingis virtual. Verified:pnpm db:migrations:create … --skip-emptywrote nothing.There is a post-deploy step, though, and it is not a migration. No row carries
routingProbeyet, so every service readsqueryuntil it is probed. Press Verify now on each enabled canonical owner after this deploys —DEPLOYMENT.mdcarries the detail.Test results
pnpm lint,pnpm typecheck,pnpm typecheck:tests,pnpm test:unit(1955 passed) — re-run green on 122d393, after mergingmaininclient-canonical(37 passed), ✓region-canonical-url(24 passed)virtual: truefrom the field.Manual verification
path, and the picker's sample URL should lose its?atlas=.query. Three presses against a host that has stopped serving the subtree return a promoted service toquery.pnpm tsx scripts/verify-embed-live.ts --self-teststill drives all four mount outcomes — it is the only thing that exercises the real Cloudflare API, and every test here stubs the render.Notes for reviewer
canonicalTargetForHost's signature change is the one edit beyond the ticket's stated approach. The ticket saidbuildCanonicalUrlandcanonicalUrlBaseare untouched, and they are. But aVerifiedEmbedstructurally satisfied the oldhostparameter, so the circularity this ticket exists to remove still compiled and was held out only by comments. It is now a type error.nextVerifyAt. A separatenextRoutingProbeAtwatermark would cut steady-state probe renders several-fold, but it needs a stored column and therefore a migration, which this ticket explicitly rules out. Worth its own ticket.canonical.embed, which only exists once ownership is on. This PR delivers the narrower scope the ticket describes.Detail
Why the verdict is a sibling of
verified, not a key inside it.verifiedis null until the mount verification first succeeds, and the answer has to survive that null: a client should path-route as soon as its host serves the subtree, whether or not it is publishing canonical URLs yet.Why its own counter.
failureCountbecomesdisable, which switches canonical ownership off and emails the service's manager. A routing negative means the embed is present and publishing, in?atlas=shape — a real canonical, and what nearly every client publishes today. Sharing the counter would delete working public URLs over a URL-shape preference.Why the ladder is asymmetric. A wrong
path404s every deep link and puts dead URLs in the sitemap. A wrongqueryonly produces uglier URLs that work. So: promote on one positive, demote after three consecutive negatives.Where the
querydefault lives, now that nothing wraps it. On the read path, once: thecanonical.routingfield'safterReadhook, which is whatGET /api/clients/meserves the widget. The five other readers never read the field — two hold the verification object across their own raw UPDATE or their own response (VerifyEmbeds, theverifyEmbedendpoint), and two read the row with their ownselect, which does not run the hook (canonicalOwnerFrom, the admin picker's two branches).Render budget. Three per enabled owner (mount, token, control), and exactly one for an owner whose mount verification failed — the widget is not on the page at all, so the subtree cannot be serving it. The control render is no longer skipped on a negative probe: overlapping the two is what keeps "Verify now" under the edge's 100s response ceiling, and the ticket's budget is a ceiling of three either way. A mount carrying a query string is still a negative with no render spent, since
canonicalUrlBaserefuses that combination anyway. Aninconclusivemount render changes nothing and spends nothing.SSRF surface is unchanged. Both probe URLs come from
routingProbeUrls, which parses the stored mount key and rebuilds fromurl.origin+ its normalised pathname, behind the sameisFetchableMounthttp(s) guard the verifier already used. A unit case pins that no URL outside that derivation reaches the renderer, and another pins that the probed URL is byte-identical to what a promoted client would publish.Why the no-backfill decision is documented outside this thread. The consequence lands on whoever deploys, months from now, not on whoever reads the review.
DEPLOYMENT.mdalready holds one post-deploy step of this shape (#709's translations republish), so this one sits beside it rather than inventing a home.Review passes. Four cleanup lenses (reuse, simplification, efficiency, altitude) ran over the branch diff; their findings are the
refactor(access)commit. Dismissed: a suggestion to drop the endpoint's read-modify-write of the wholecanonicalgroup in favour of a two-key patch — the group's other keys areenabledandembed, and getting group-merge semantics wrong there would silently switch ownership off. Also dismissed: merging the two integration job-driver helpers, which would rewrite four passing tests for no behavioural gain.Closes #644
🤖 Generated with Claude Code
https://claude.ai/code/session_013Y24vyrpNax3tfBwQcKECR