شعار Edge Canary Split

Edge Canary Split

المجتمع
Innei
edge-canary-split

استخدم هذه المهارة عند إطلاق موقع أعيدت كتابته تدريجيًا، بإطار عمل جديد ومشروع Vercel جديد، خلف نطاق إنتاج قائم. تعتمد على توزيع الزيارات بين مصدرين بنسبة مئوية باستخدام ملف تعريف ارتباط ثابت عبر Cloudflare Worker على مسار النطاق، مع نقل ملفات البناء ذات الأسماء المشفّرة إلى R2 كي لا تمر حركة الملفات عبر العامل. تشرح أسباب تعطّل تخزين CDN المؤقت عند استخدام عمليات النشر التجريبية المعتمدة على الوسيط البرمجي، ومشكلة طلبات HTTP الفرعية ضمن المنطقة نفسها، وتسميم ذاكرة التخزين المؤقت بين الحاويات، وتصميم R2 الذي يدعم إصدارات عديدة متزامنة.

Add to TypingMind

نظرة عامة

الناشرInnei
المستودعSKILL
اسم المهارةedge-canary-split
النجوم
81
التفريعات
2
الملفات المرفقة
3
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • الملفات المرفقة: 3

    نصوص برمجية وقوالب ومراجع يمكن للنموذج قراءتها أثناء عمله. الملفات للقراءة فقط ولا تُنفّذ أبدًا.

  • مفتوحة المصدر

    نشرها Innei على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Edge Canary Split في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/Innei/SKILL/tree/main/skills/infrastructure/edge-canary-split
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Innei/SKILL.git /tmp/SKILL
mkdir -p .claude/skills
cp -r /tmp/SKILL/skills/infrastructure/edge-canary-split .claude/skills/edge-canary-split
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Edge Canary Split في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Edge Canary Split تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Edge Canary Split بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

edge-canary-split

Route a fraction of production traffic to a parallel rewrite of the same site without touching DNS or the stable deployment. A ~130-line Cloudflare Worker mounted on <zone>/* assigns each visitor a sticky bucket cookie, proxies documents to one of two Vercel origins, and falls back to stable on canary 5xx. Static assets are removed from the equation entirely: both builds upload hashed assets to one R2 bucket behind a cookie-less CDN hostname, so ~98% of per-pageview requests never reach the worker (its request-count billing) and old HTML can never 404 on purged chunks.

The worker exists because the obvious alternative fails: a Vercel-middleware dice canary runs behind the CDN cache, so both variants share one cache key per URL and the only safe posture is CDN-Cache-Control: no-store on everything — a canary that uncaches your whole site. Workers run before the cache, and their fetch() subrequests are cached keyed by the subrequest URL, which gives each origin its own cache partition for free.

When to use

  • Migrating a production domain to a rewritten app (e.g. Next.js → React Router) and you need percentage rollout, stickiness, and instant rollback.
  • The zone fronting the domain is Cloudflare; variants are separate origins.
  • NOT for per-feature flags inside one app — this splits whole origins.
  • NOT needed if the new app ships behind the same deployment (use a framework-level rewrite instead).

Inputs

  • Cloudflare zone for the public host; permission to deploy Workers + KV.
  • Two Vercel projects: stable (current prod) and canary (rewrite), and their canonical *.vercel.app production aliases.
  • An R2 bucket with a custom domain on the same zone (e.g. web-assets.<zone>), CORS configured, and a cache rule granting a long edge TTL.
  • If the domain already runs an older canary mechanism (middleware dice, edge-config flags), retire it first — two dice systems re-mix each other's buckets and caches.

Files provided

  • references/worker.example.ts — the full worker: cookie bucket, KV-driven percent, forced ?_canary=1|0 switch, 5xx/error fallback, cache handling.
  • references/wrangler.example.jsonc — routes, KV binding, origin vars, with the load-bearing comments preserved.
  • scripts/upload-static-assets.ts — zero-dependency Bun script that mirrors a build dir into R2; STATIC_CDN_URL acts as the master switch.

Workflow

text
[1] Assets to R2 (both projects)   vite `base` / next `assetPrefix` ← STATIC_CDN_URL
[2] Worker on a staging hostname   rehearse on a real zone host, never workers.dev
[3] Bucket-side config             CORS (every page origin!), cache rule, lifecycle
[4] Mount worker on the prod route KV percent set BEFORE deploying the route
[5] Verify as a real browser       forced cookie both ways, zero failed CDN loads
[6] Ramp via KV                    percent change is live ≤60s, no deploy

[1] Assets to R2

Key the whole feature off one env var. STATIC_CDN_URL unset → build prefix and upload both no-op (assets stay same-origin); set without S3 credentials → fail the build, because shipping HTML that references an unpopulated CDN is worse than either working state. Vite: base (build-only). Next: assetPrefix (does not touch /_next/image or public/). With assets on the CDN, deployment-skew protection for assets (Vercel ?dpl= rewriting) becomes dead weight — gate it off the same variable.

R2 layout: <project>/<prod|preview>/... — project × environment only, no version directories. Hashed filenames already content-address versions; all deployments' assets coexist in one flat namespace and each HTML references exactly its own set. A version directory would change every URL every deploy and destroy browser/edge cache reuse. Re-upload everything on every build (overwrites are content no-ops) so object age means "time since last referenced by any build" — then R2 lifecycle rules (*/preview/ 30d, */prod/ 180d) are a correct GC.

[2] Worker on staging

Rehearse on a real hostname of the zone — workers.dev has no zone, so subrequest caching never HITs there and the rehearsal proves nothing about cache behavior. The worker: read canary_bucket cookie → else roll percent (KV percent key, cacheTtl: 60, env var only as fallback) → rewrite subrequest host to the chosen origin → append the cookie on first assignment. Canary GET/HEAD that 5xx or throw are retried against stable and the user is re-bucketed to stable.

Three non-negotiable details in fetchOrigin:

  • originUrl.host = ..., never originUrl.hostname (hostname drops the port and breaks local wrangler dev origins).
  • originUrl.protocol = 'https:' — under Flexible SSL the worker sees request.url as http://, and an http subrequest makes Vercel answer an infinite 308-to-https loop for every document.
  • Origins should be cross-zone *.vercel.app hosts. Same-zone subrequests skip the worker (platform recursion prevention) but can reach the origin over plain HTTP — same 308 loop, verified live. Do NOT write your own loop guards: the platform already prevents recursion, and a host-equality guard silently disables bucketing the day the mounted host equals an origin (it did, in production config).

Documents need cache eligibility on the subrequest. Zone cache rules DO evaluate worker subrequests (verified live: a rule keyed on the origin's full_uri turns MISS→HIT with no cf options), but rules written against the public hostname never match the subrequest's origin host — so either add rules keyed on each origin URL, or ship cf: { cacheEverything: true } so the worker is self-contained and independent of dashboard state. Prefer the latter. TTL still comes from the origin's Cloudflare-CDN-Cache-Control. And force browser cache-control on canary HTML/.data to public, max-age=0, must-revalidate: the zone's Browser Cache TTL otherwise stamps ~4h of browser cache on documents and percent changes take hours to reach returning visitors.

[3] Bucket-side config

  • CORS: allow every origin pages are served from — production apex, www, staging host, and *.vercel.app (previews live there). Vite emits crossorigin module scripts: one missing origin means a blank page the moment canary reaches that host.
  • Cache rule: R2 custom domains are NOT edge-cached by default; add a rule (hostname match → eligible, long edge TTL, consider overriding browser TTL — objects uploaded via S3 API may carry no Cache-Control; Bun's S3 client cannot set it).

[4] Mount on production

Set KV percent BEFORE deploying the route change, or the env-var fallback takes the first minutes of traffic. Keep the staging route mounted as a permanent rehearsal surface; staging vs prod then differ by route pattern only.

[5] Verify as a real browser

curl lies here — see pitfalls. Drive a real browser: force ?_canary=1, assert the canary DOM is the new app, count CDN asset loads and failures via performance.getEntriesByType('resource'), check the console, then ?_canary=0 back. Measure worker load as requests-per-pageview grouped by host — documents only, single digits.

[6] Ramp

wrangler kv key put percent <n> --namespace-id <id> --remote. Sticky cookies mean existing users don't flap; only fresh rolls see the new percent. percent=0 stops new assignments but existing canary cookies stick for their lifetime — full rollback also means swapping CANARY_ORIGIN or removing the route. Structural changes (origins, routes) stay config-on-deploy deliberately: they deserve a deployment record.

Common pitfalls

MistakeFix
Canary via Vercel middlewareRuns behind the CDN cache; needs no-store on everything to avoid variant mixing. Split before the cache (Worker) instead.
Worker subrequest to a same-zone hostnameCan arrive at the origin over plain HTTP → Vercel 308-to-https infinite loop. Use cross-zone *.vercel.app origins.
Inheriting the eyeball scheme from request.urlUnder Flexible SSL the worker sees http:// — force originUrl.protocol = 'https:'.
Hand-written recursion guardsThe platform already prevents same-zone worker recursion; a host-equality guard silently passes through 100% of traffic when the mounted host equals an origin. Delete them.
originUrl.hostname = xDrops the port; breaks non-443 origins in wrangler dev. Set .host.
Concluding "cache rules don't apply to subrequests" from a curl ablationThey do apply — but host-scoped expressions never match the origin host, and plain-curl probes can hit bot-bypass rules (cache:false), poisoning the experiment. Test with GET + browser UA and a rule keyed on the origin full_uri before believing any "rules don't work" conclusion.
Letting zone Browser Cache TTL reach canary documentsReturning visitors keep old HTML for hours after a percent change. Stamp max-age=0, must-revalidate on HTML/.data in the worker.
Trusting curl -I for cache checksHEAD reports DYNAMIC even for cached objects; plain curl UA may match bot-bypass cache rules. Probe with GET + a browser UA.
Version directories in the R2 layoutEvery deploy changes every asset URL → total cache bust. Hashes are the version; directories are project × env only.
Skip-if-exists uploads + age-based lifecycleA chunk unchanged for months gets GC'd while still live. Full re-upload every build makes object age = last-referenced.
CORS allowlist missing one page originWorks on staging, blank page on prod (crossorigin module scripts). Enumerate apex + www + staging + *.vercel.app, or use *.
Two canary systems alive at onceThe old middleware dice re-buckets worker-assigned users and skews ratios. Retire the old one (revert + flag cleanup) before mounting the route.
Rehearsing on workers.devNo zone → no subrequest cache → the rehearsal proves nothing. Use a staging hostname on the real zone.
Judging the split from a browser that visited pre-cutoverStale local HTML replays (deliveryType: "cache", transferSize: 0) and mimics a routing bug. Re-fetch with cache: 'no-store' before diagnosing.
Asset responses carrying Set-Cookie / consuming a rollUncacheable and skews stats. Better: move hashed assets off the worker entirely (R2).
Reading percent from env onlyEvery change needs a deploy. KV + cacheTtl: 60; env stays as fallback.
Deleting a "stray" branch on a transferred GitHub repoThe old-org remote is a redirect to the same repo — the delete kills the PR's head branch. Check remotes before cleanup.

Rules

  • One env var (STATIC_CDN_URL) is the master switch for the CDN path; half-configured states must fail the build, not ship.
  • Documents through the worker: browser max-age=0; edge caching only via origin-host-partitioned subrequests.
  • The worker never buffers bodies — new Response(response.body, response) pipes streams; streaming wall-clock costs no CPU billing.
  • Watch canary_5xx_fallback / canary_fetch_error_fallback events before every ramp step.

Verification

  • Fresh visitor gets set-cookie: canary_bucket=...; distribution over ~30 cookie-less requests matches the KV percent (0 and 100 exact).
  • ?_canary=1 → 302, cookie, new-app DOM on the prod domain; ?_canary=0 reverts.
  • Canary documents MISS → HIT with growing age on repeat GETs; assets untouched (immutable intact).
  • All CDN asset loads succeed in a real browser on the prod domain (zero performance entries with responseStatus >= 400).
  • CDN objects: HIT on second GET (browser UA), correct Content-Type for .js and fonts, ACAO present for every page origin.
  • Canary 5xx (forced or observed) → stable response + re-bucket cookie.
  • KV percent flip reaches fresh visitors without a deploy (≤60s).
  • Per-pageview worker hits in single digits, grouped by host.

الملفات المرفقة

يقرأ النموذج هذه الملفات عند الحاجة ما دامت المهارة محمّلة. وهي متاحة للقراءة ولا تُنفّذ أبدًا.

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Edge Canary Split؟

استخدم هذه المهارة عند إطلاق موقع أعيدت كتابته تدريجيًا، بإطار عمل جديد ومشروع Vercel جديد، خلف نطاق إنتاج قائم. تعتمد على توزيع الزيارات بين مصدرين بنسبة مئوية باستخدام ملف تعريف ارتباط ثابت عبر Cloudflare Worker على مسار النطاق، مع نقل ملفات البناء ذات الأسماء المشفّرة إلى R2 كي لا تمر حركة الملفات عبر العامل. تشرح أسباب تعطّل تخزين CDN المؤقت عند استخدام عمليات النشر التجريبية المعتمدة على الوسيط البرمجي، ومشكلة طلبات HTTP الفرعية ضمن المنطقة نفسها، وتسميم ذاكرة التخزين المؤقت بين الحاويات، وتصميم R2 الذي يدعم إصدارات عديدة متزامنة.

لماذا تستخدم Edge Canary Split على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Edge Canary Split عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Edge Canary Split في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/Innei/SKILL/tree/main/skills/infrastructure/edge-canary-split. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة، ويجمع ملفاتها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Edge Canary Split؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Edge Canary Split؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Edge Canary Split معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Edge Canary Split مجانية؟

نشرها Innei على GitHub. راجع المستودع للاطلاع على شروط الترخيص. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇