شعار Hor Execution Placement Pattern

Hor Execution Placement Pattern

مؤسسة
openreachtech
hor-execution-placement-pattern

Decide where a piece of processing (especially a write / state change) should be implemented in a web system: as a synchronous GraphQL / REST API operation, or as a renchan-job-bullmq background worker triggered from an API handler, from a post-worker after the response, or on a schedule. Use this skill whenever the user is turning a requirement into an implementation and needs to choose the execution location, including where an external-integration write belongs.

نظرة عامة

الناشرopenreachtech
المستودعhora-skills-ort-renchan
اسم المهارةhor-execution-placement-pattern
النجوم
32
التفريعات
0
الملفات المرفقة
تعليمات فقط
الترخيصApache-2.0
الروابط
  • تعليمات بصيغة Markdown

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

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

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

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

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

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

التثبيت

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

1

التثبيت في TypingMind

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

  1. افتح التطبيق وانتقل إلى الإضافات → المهارات.
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-execution-placement-pattern
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات → المهارات → إضافة مهارة → من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

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

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

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openreachtech/hora-skills-ort-renchan.git /tmp/hora-skills-ort-renchan
mkdir -p .claude/skills
cp -r /tmp/hora-skills-ort-renchan/kit/skills/hor-execution-placement-pattern .claude/skills/hor-execution-placement-pattern
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

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

يُحمّل النموذج Hor Execution Placement Pattern تلقائيًا بمجرد ورود طلب ذي صلة بها.

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

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

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

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

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

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

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

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

Execution Placement Pattern (deciding where processing lives)

A skill for deciding, the moment you receive a requirement, where that processing should be implemented. Before diving into the implementation details (how to write the job, how to write the resolver, etc.), first lock down the "placement". Once the placement is decided, you can hand it off to the individual implementation skills (hor-renchan-job-bullmq, etc.).

Grand principle: write processing lives in only two places — "API" or "Worker"

In a web system, processing that changes state (writes) only ever happens in one of two places. Every requirement must resolve into this binary choice. The deciding axis is how heavy / how long-running the processing is.

PlacementExecution modelWhat it holds
APIResponds synchronously to the requestThings that are light and finish quickly
WorkerRuns asynchronously in the backgroundThings that are heavy and take time
  • Why only two places: a write can only originate from "an external request (API)" or "processing the system drives on its own (Worker)". Creating a third place scatters responsibility, monitoring, and retry paths so they can no longer be traced.
  • Why split by weight: a request must return quickly. If you run heavy processing inside the API, the response never comes back and it times out; if it is cut off midway, it cannot recover. Push it to a Worker and the API can respond immediately, while retries, progress notifications, and scaling work independently.
  • When the boundary is unclear, lean toward Worker. Why: if "probably fast" processing turns out slow at production data volumes, an API implementation becomes a timeout incident. A Worker does not break when it gets slow. As a rule of thumb, anything involving external I/O, AI calls, large record counts, or file generation counts as the heavy side.

Read-only (non-state-changing) processing is not the main subject of this skill. As a rule it just returns synchronously via the API (GraphQL query / REST GET) and is not turned into a Worker.

Decision flow

  1. Is it a write? If read-only, return it via an API query / GET and you're done.
  2. Is it light & short-lived? → API (1).
  3. Is it heavy / time-consuming / uncertain due to external dependencies? → Worker (2).
  4. What triggers the Worker?
    • User actions, external integrations, etc. — request-based → enqueue from inside the API handler (2.1).
    • A side effect unrelated to the main processing, run after the response → dispatch from a post-worker (2.2).
    • Automatic, by time / interval → schedule-based (2.3).
Nature of the processingPlacementConcretely
Light, short-lived, needs a synchronous responseAPIGraphQL resolver / REST renderer
Heavy, time-consuming, request-basedWorker (API-triggered)renchan-job-bullmq (enqueue from resolver/renderer)
A side effect unrelated to main processing, run after the responseWorker (post-worker-triggered)post-worker only dispatches (e.g. sending an email after signup)
Heavy, automatic by interval/timeWorker (scheduled)renchan-job-bullmq (cron / interval scheduler)

1. Put it in the API (light, short-lived)

The API has two families: GraphQL and REST API. Choose based on the caller in the requirement.

  • GraphQL — resolvers under server/graphql/resolvers/<role>/actual/{mutations,queries}/. Ordinary reads/writes from your own frontend default to this.
  • REST API (renderer) — renderers under server/restfulapi/renderers/v1/{post,get}/*Renderer.js. Use for file uploads, endpoints hit by external systems, and non-GraphQL clients.

Rule of thumb for what goes here: simple CRUD against the DB, input validation, and short aggregations/updates that complete within a single request.

  • Why the API: for short processing where the user waits for the result immediately, responding synchronously is the shortest path. Turning it into a job instead introduces the complexity of enqueue → progress notification → polling/subscription, which isn't worth it.
js
// Good: a short DB update is handled synchronously inside the resolver and returned immediately
const updated = await context.share.transaction(async tx => this.updateProfile({ input, tx }))
return { profile: updated }
js
// Avoid: running even heavy processing synchronously inside the resolver → the response never returns and times out
const content = await generateContentWithAi({ accessToken }) // takes tens of seconds
return { content }

2. Put it in a Worker (heavy, time-consuming)

Workers are implemented with @openreachtech/renchan-job-bullmq. Place the Manifest / Worker / Dispatcher under app/jobs/<kebab-name>/. Follow the hor-renchan-job-bullmq skill for how to write them.

They split into three kinds by trigger (2.1 request-based / 2.2 post-worker / 2.3 schedule). In all three, the shape is the same: "the real work is in the Worker, the trigger is elsewhere" — don't put logic beyond dispatch in the trigger.

2.1 Request-based

The pattern of enqueuing from inside the API handler. Triggered by a user action or external integration, the API (resolver / renderer) only enqueues and responds immediately, while the real work is handled by a Worker in the Daemon. Progress is returned via a subscription or similar.

  • Examples (this repo): heavy AI content generation = app/jobs/content-generation-internal / app/jobs/content-generation-public-lp; report email sending = app/jobs/send-report-email. They enqueue with dispatchJob from a resolver/renderer.

  • Why enqueue: running heavy processing inside the API means it can't return. Enqueue instead and the API can respond immediately, while the Worker side handles retry / progress notification / concurrency control. The API side sticks to "just enqueuing" (no real work).

js
// Good: heavy processing is enqueued and the response returns immediately (the real work is in the Worker)
await context.share.jobDispatcherProvider.dispatchJob({
  DispatcherCtor: ContentGenerationPublicLpJobDispatcher,
  body: {
    accessToken,
  },
})
return { accepted: true }

2.2 post-worker

renchan's post-worker (BaseGraphqlPostWorker) is the mechanism for running side effects unrelated to the API's main processing, after the response. It fires as an onResolved hook per GraphQL operation, running after the main resolver has returned.

A post-worker holds only the dispatch to the Worker. Don't put complex logic here (the real work always belongs on the Worker side).

  • Why dispatch only: a post-worker is a thin hook that runs after the response. If you write heavy processing or complex logic here, logic accumulates in a place where neither retry, progress notification, nor monitoring apply, and failures get swallowed. Keep it to dispatch and the real work rides on the Worker's machinery (retries, observability), while the post-worker stays predictably thin — "just enqueuing" (the same principle as "the trigger only enqueues" in 2.1).
  • Choosing between 2.1 and this: if the user is requesting that processing (waits for the result, or it's part of the response), enqueue inside the handler (2.1). If you only want to run a side effect unrelated to the main processing afterward without making the response wait, use a post-worker.
  • Example: dispatch sending a welcome email after signup from a post-worker (the signup response isn't kept waiting; the email send is streamed to a Worker afterward).
  • Current state of this repo: the server engine has postWorkersPath: null (not wired). To use it, set the engine's postWorkersPath and place a post-worker that extends BaseGraphqlPostWorker.
js
// Good: a post-worker only dispatches (the real work of the side effect is on the Worker side)
/** @override */
async onResolved ({ variables, context, response: { output, error } }) {
  if (error) {
    return
  }

  await context.share.jobDispatcherProvider.dispatchJob({
    DispatcherCtor: SendWelcomeEmailJobDispatcher,
    body: {
      customerId: output.customer.id,
    },
  })
}
js
// Avoid: writing email-body assembly or sending logic directly in the post-worker
//   → real work accumulates in a post-response place where failures get swallowed, and neither retry nor monitoring apply. Put the real work in the Worker.

2.3 Schedule-based

Processing that starts automatically by time / interval rather than from a user. Register a cron / interval scheduler (*CronJobScheduler.js / *IntervalJobScheduler.js, hor-renchan-job-bullmq skill).

  • Example (this repo): cleaning up expired sessions = app/jobs/purge-expired-content-sessions (PurgeExpiredContentSessionsCronJobScheduler.js).

  • Why a scheduler: periodic batches, cleanups, reminders, re-aggregations, and the like need to run even without an external request. They don't ride the API path, so start them from a scheduler.

js
// Avoid: substituting a periodic cleanup with "an admin presses a button and the resolver runs a long loop"
//   → forgotten presses, double execution, and timeouts occur. Put periodic processing in a scheduler.

3. Placement of external integrations

Integrations with external systems must also ride on one of the two places above (API / Worker). Organize them by direction.

  • inbound (receiving calls from outside): often a REST API (renderer), but not necessarily (it can be received via GraphQL). Choose the receiving method based on the other system's constraints. If the processing after receiving is heavy, the renderer sticks to enqueuing and hands the real work to a Worker (2.1).

    • Example: server/restfulapi/renderers/v1/post/IntegrationReportPostRenderer.js.
  • outbound (calling an external API): call it via the rocket-client Launcher (hor-external-api-client skill). External calls are slow and uncertain, so call them from a Worker if they would block the user's response.

  • Why "not necessarily REST": the integration method (REST / GraphQL / Webhook, etc.) is usually decided by the other system and won't always match our default (REST renderer). The receiving method follows the other party's spec, and the placement (API or Worker) follows this skill's weight criterion — decide the two axes separately.

Finishing checklist

  • Is this processing a write? (If a read, return it via query/GET and you're done.)
  • Did you resolve it into the binary of light → API / heavy → Worker, leaning toward Worker when unsure?
  • If placing it in the API, did you choose GraphQL resolver or REST renderer based on the caller?
  • If placing it in a Worker, did you choose one of request-based (enqueue) / post-worker / schedule-based by trigger?
  • For the request-based case, does the API side only enqueue (no real work written in the resolver/renderer)?
  • If running a side effect unrelated to main processing after the response, did you write only a dispatch in the post-worker and keep the real work in the Worker?
  • For external integrations, did you decide the receiving method (other party's constraints) and the placement (weight criterion) separately?

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

ماذا تفعل مهارة الذكاء الاصطناعي Hor Execution Placement Pattern؟

Decide where a piece of processing (especially a write / state change) should be implemented in a web system: as a synchronous GraphQL / REST API operation, or as a renchan-job-bullmq background worker triggered from an API handler, from a post-worker after the response, or on a schedule. Use this skill whenever the user is turning a requirement into an implementation and needs to choose the execution location, including where an external-integration write belongs.

لماذا تستخدم Hor Execution Placement Pattern على TypingMind؟

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

كيف أثبّت Hor Execution Placement Pattern في TypingMind؟

افتح الإضافات → المهارات → التثبيت من GitHub في TypingMind والصق https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-execution-placement-pattern. يقرأ TypingMind ملف SKILL.md الخاص بها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Hor Execution Placement Pattern؟

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

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Hor Execution Placement Pattern؟

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

هل مهارة الذكاء الاصطناعي Hor Execution Placement Pattern مجانية؟

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

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

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

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

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

عرض الكل

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

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