Agile Principles and Empirical Process Control
Agile ليست مرادفًا لعدم التخطيط أو كتابة كود بلا documentation. هي طريقة للتعامل مع عدم اليقين عبر delivery increments قصيرة، feedback متكرر، تعاون مع stakeholders، والاستعداد لتعديل الخطة بناءً على evidence. الهدف تسليم value وتقليل risk مبكرًا.
Empirical process control يعتمد على transparency و inspection و adaptation. اجعل العمل مرئيًا، افحص النتائج والعملية بانتظام، ثم غيّر ما يلزم. لا تقيس نجاح الفريق بعدد ساعات العمل أو عدد story points؛ قِس value، quality، flow، و predictability.
Empiricism بمثال: الفريق اللي «ماشي على الخطة»
فريق خطط 6 شهور لـ «AI assistant» بـ Gantt chart. في الشهر الرابع اكتشفوا إن الـ retrieval على مستندات العملاء العربي ضعيف جدًا (OCR سيء). كل الخطة اتبنت على افتراض ما اتختبرش. الفريق التجريبي كان هيعمل في أول أسبوعين: 20 مستند حقيقي ← retrieval ← 30 سؤال eval ← يشوف المشكلة ← يعدّل الخطة. Transparency, inspection, adaptation مش طقوس؛ هي إنك تختبر أخطر افتراض بدري.
Sprint في رسمة
Scrum: Accountabilities, Events and Artifacts
Scrum يحدد Product Owner و Scrum Master و Developers ضمن Scrum Team. Product Backlog هو ordered list للعمل المطلوب، Sprint Backlog هو Sprint Goal + selected items + plan، و Increment هو usable result يحقق Definition of Done. Events: Sprint، Planning، Daily Scrum، Review، Retrospective.
Sprint Planning يجيب لماذا هذا Sprint ذو قيمة؟ ماذا يمكن إنجازه؟ وكيف سينفذ العمل؟ Daily Scrum للـ Developers لفحص التقدم نحو Sprint Goal وتعديل الخطة، وليس status report للمدير. Review تفحص increment مع stakeholders، و Retrospective تحسن طريقة العمل.
إمتى Scrum مناسب وإمتى لأ
| السياق | الأنسب غالبًا |
|---|---|
| فريق منتج بيبني features بأولويات بتتغير كل أسابيع | Scrum أو sprints خفيفة |
| Platform/SRE شغلهم interrupts وتذاكر | Kanban بـ WIP limits |
| فريق صغير جدًا (2–3) بيشحن يوميًا | Kanban + weekly planning |
Daily standup بقى 40 دقيقة «تقرير للمدير». النتيجة: الناس بتكره الـ process والمعلومات المهمة (الـ blockers) بتضيع. الصيغة الأحسن: 15 دقيقة على الـ board (من اليمين لليسار: إيه اللي قريب يخلص وإيه المعطّل)، والنقاشات التفصيلية بعده مع اللي يهمهم بس.
Backlog Refinement, User Stories and Slicing
Backlog refinement نشاط مستمر لتوضيح items وترتيبها وتقدير حجمها. Story جيدة لها user/value، acceptance criteria، dependencies، risks، و test notes. INVEST checklist مفيد كإشارة: Independent، Negotiable، Valuable، Estimable، Small، Testable.
قسّم vertical slices تحقق قيمة end-to-end بدل تقسيم حسب layers فقط. مثال “إضافة tenant invitation” قد يشمل API و DB و email و UI لكن slice واحدة قابلة للاختبار. تجنب tasks ضخمة مثل “اعمل AI integration”؛ قسمها إلى provider adapter، prompt contract، retrieval, evaluation, telemetry, rollout.
ticket = {
'title': 'Invite a member to the current tenant',
'value': 'Tenant admin can onboard a teammate safely',
'acceptance': ['membership is tenant-scoped', 'duplicate invite rejected', 'audit event recorded'],
'test_notes': ['cross-tenant attempt', 'expired invitation', 'quota reached'],
}
print(ticket['title'])Vertical slicing بمثال AI
Story ضخمة: «AI assistant يجاوب من مستندات الشركة». تقسيم أفقي غلط: (1) DB schema، (2) ingestion، (3) API، (4) UI — ولا واحدة فيهم بتدي قيمة لوحدها، والمخاطرة بتتأجل للآخر. تقسيم رأسي:
- رفع PDF واحد ← سؤال ← إجابة بـ citation (tenant واحد، من غير ACL) — demo لـ 5 مستخدمين داخليين.
- + ACL قبل الـ retrieval + أنواع ملفات أكتر.
- + eval set و gate في CI.
- + streaming وحالات الـ UX.
- + multi-tenant و quotas.
كل slice قابل للعرض والقياس، وأكبر مخاطرة (جودة الإجابة) اتقاست في الـ slice الأول. ده بالظبط منطق الـ 7 milestones في الـ Capstone.
Estimation, Capacity and Forecasting
Story points تقيس relative size/complexity/uncertainty داخل فريق واحد، وليست ساعات ولا أداة لمقارنة الأفراد أو الفرق. Throughput هو عدد items المكتملة خلال فترة، cycle time هو الزمن من بدء العمل إلى انتهائه، lead time من الطلب إلى التسليم. استخدم historical data للتنبؤ بنطاق احتمالي بدل تحويل velocity إلى deadline دقيق.
Capacity تأخذ في الاعتبار vacations، support duty، meetings، incidents، و dependencies. لا تخطط 100% من الوقت؛ work in progress غير المرئي والـ interruptions يسببان missed commitments. إذا item كبير أو غامض، قلل uncertainty عبر spike أو prototype أو split.
ليه التقدير بالنقاط بيفشل… وبديله
Story points بتتحول لوعود بالأيام، والفرق بتتلاعب بيها لما تبقى KPI. البديل العملي: throughput (عدد العناصر اللي بتخلص في الأسبوع) + cycle time، ومع ذلك تقسيم العناصر لأحجام متقاربة. وبعدين Monte Carlo من البيانات التاريخية (الـ lab في v2-forecast) بيطلع «85% احتمال نخلص قبل 12 مارس» بدل رقم واحد كاذب.
الشغل البحثي (هل الـ retrieval هيوصل لـ recall كافي؟) ما بيتقدرش بنفس الطريقة. اعمل timebox: «أسبوعين لنعرف إذا الـ approach ده بيوصل لـ 0.8 recall على الـ golden set»، والنتيجة قرار (نكمل/نغير/نوقف) مش «خلّصنا 70%».
Kanban, WIP Limits and Flow Efficiency
Kanban visualizes workflow stages مثل Ready → In Progress → Review → Test → Done. WIP limits تحدد أقصى عدد items داخل stage لتقليل multitasking وكشف bottlenecks. إذا Review queue تتراكم، إضافة feature جديدة تزيد inventory لا throughput؛ ساعد في إزالة bottleneck.
راقب cycle time distribution و throughput و work item age و blocked time. Classes of service قد تميز expedite عن standard work لكن expedite lane يجب أن يكون محدودًا حتى لا يتحول كل شيء إلى urgent. سياسات الانتقال بين الأعمدة يجب أن تكون واضحة.
kanban = {
'Ready': 5,
'In Progress': 3,
'Code Review': 2,
'Testing': 2,
}
print('Total WIP limit:', sum(kanban.values()))WIP بالأرقام: Little's Law
Cycle time = WIP / Throughput. فريق بيخلص 10 عناصر في الأسبوع وعنده 30 عنصر شغالين = متوسط 3 أسابيع لكل عنصر. لو قلّلوا الـ WIP لـ 10 من غير ما يتغير الـ throughput، المتوسط يبقى أسبوع. نفس الناس، نفس المجهود، تسليم أسرع 3 مرات — لأن الـ context switching والانتظار قلّوا. ده مش رأي؛ ده علاقة رياضية (في نظام مستقر).
Flow efficiency = وقت الشغل الفعلي ÷ وقت الدورة كله. في فرق كتير بيطلع 15–25%: العنصر بيقضي أغلب وقته مستني review أو QA أو deploy. التحسين بيبدأ من طوابير الانتظار مش من «اشتغلوا أسرع».
Definition of Ready, Definition of Done and Quality Gates
Definition of Done معيار مشترك للـ Increment: code reviewed، tests passed، security checks، documentation/API updates، observability، migrations safe، و deployable. لا تجعل Done تعني “الكود عند المطور يعمل”. Definition of Ready قد تساعد في refinement لكنها لا ينبغي أن تصبح bureaucratic gate تمنع التعلم.
Quality gates تختلف حسب risk؛ AI feature قد تحتاج golden eval، prompt injection tests، citation validation، cost budget، و human fallback. Feature flag قد يسمح release تدريجيًا، لكن لا يلغي مسؤولية tests أو rollback plan.
Definition of Done لـ feature فيها AI
A change is DONE when:
- [ ] Code reviewed and merged to main behind a feature flag (default off)
- [ ] Unit + integration tests green; isolation matrix updated for new endpoints
- [ ] OpenAPI updated; breaking changes = new version or deprecation plan
- [ ] Telemetry: spans + metrics + structured logs with tenant id; dashboard panel exists
- [ ] For AI changes: eval smoke gate green; release manifest version bumped; security suite green
- [ ] UX: loading / empty / error / forbidden / degraded states implemented (Arabic + English, RTL checked)
- [ ] Runbook entry for new failure modes; alert thresholds set
- [ ] Docs/ADR updated if a decision was madeالـ DoD ده هو الـ «quality gates» بشكل مكتوب ومتفق عليه، وبيمنع «خلصت بس فاضل الـ tests».
Pull Requests, Code Reviews and Technical Collaboration
PR صغير يشرح problem، approach، alternatives، tests، screenshots/logs عند الحاجة، migration impact، و rollout/rollback. Reviewer يراجع correctness، security، performance، API compatibility، error handling، observability، و test coverage. لا تستخدم code review لإعادة كتابة style preferences الشخصية؛ automated formatter/linter يقلل الضوضاء.
Review feedback يجب أن يكون محددًا ومحترمًا ويفرق بين blocker و suggestion. صاحب PR يرد ويحدث tests. لا تدمج تغييرات كبيرة غير مفهومة لمجرد إغلاق ticket. استخدم CODEOWNERS أو reviewers حسب domain/security sensitivity.
Code review بيعلّم مش بيحاكم
- PR صغير: أقل من ~400 سطر تغيير. الـ PR الكبير بياخد «LGTM» من غير قراءة.
- الوصف: ليه (المشكلة)، إيه (الحل)، إزاي اتختبر، إيه المخاطر، screenshots للـ UI.
- التعليقات بمستويات:
blocking:(bug/أمان)،suggestion:،nit:،question:. ده بيوضح للكاتب إيه الإجباري. - المراجِع بيدوّر على: صحة السلوك، الحالات الحدية، الأمان (tenant isolation!)، قابلية القراءة، الـ tests بتختبر الحاجة الصح.
## Why
<!-- the problem / ticket link -->
## What changed
## How I tested it
<!-- commands, screenshots, eval report link for AI changes -->
## Risk & rollback
<!-- flag name, migration reversibility, blast radius -->
## Checklist
- [ ] Tenant isolation considered (new queries, caches, jobs, vectors)
- [ ] No secrets / PII in logsADRs, RFCs and Blameless Postmortems
ADR يسجل context، decision، alternatives، consequences، و status لقرار معماري مهم. RFC/design doc يناقش problem/options قبل التنفيذ ويتيح review متعدد التخصصات. لا توثق كل سطر؛ وثّق القرارات التي يصعب عكسها أو تؤثر على عدة فرق مثل tenant isolation model أو vector store choice.
Blameless postmortem يركز على system conditions لا لوم شخص. سجّل impact/timeline/detection/response/root contributing factors، ثم action items لها owner و due date و success signal. “كن أكثر حرصًا” ليس action item؛ “أضف integration test يمنع cross-tenant cache key collision” قابل للتحقق.
مثال ADR قصير + postmortem blameless
# ADR-0007: Use PostgreSQL + pgvector as the vector store
Status: Accepted (2026-10-20) · Deciders: backend lead, AI lead · Supersedes: —
## Context
RAG over tenant documents. Expected 2–20M chunks in year 1, hybrid search, strict tenant isolation (RLS),
team already operates PostgreSQL; no dedicated search/infra team.
## Options
1. pgvector in the existing PostgreSQL 2. Managed vector DB 3. Search engine with vector support
## Decision
Option 1. Measured on our golden set: recall@10 0.86 (hybrid) at p95 180 ms with HNSW (m=16, ef_search=80).
## Consequences
+ One database, transactions with metadata, RLS reused, fewer components.
− Large-tenant filtered search needs partial indexes; revisit if chunks > 50M or p95 > 400 ms.
Exit plan: retrieval behind IRetriever; export script tested.Postmortem blameless بيسأل «إيه اللي في النظام سمح للغلطة دي تحصل وتعدي؟» مش «مين غلط؟». لأن لو الناس خافت، هتخبي المعلومات، والحادثة الجاية هتبقى أسوأ. مثال كامل ومحاكاة (drill) في Engineering Leadership.
Team Communication and Async Collaboration
التواصل الجيد يوضح: ما الذي أنجز؟ ما التالي؟ ما العائق؟ ما القرار المطلوب ومن صاحبه؟ في async teams اكتب context وروابط ومخرجات واضحة بدل رسائل “مش شغال”. Daily Scrum ليس بديلًا عن التواصل المستمر، ولا يجب أن يصبح اجتماعًا لمحاسبة الأفراد.
عند handoff بين Backend و AI/Data و Frontend، اتفقوا على API contracts و error cases و sample payloads و ownership. استخدم decision log و ticket links و trace IDs. ارفع المخاطر مبكرًا بدل إخفائها حتى نهاية Sprint.
Async collaboration: كتابة بتوفر اجتماعات
الرسالة الكويسة في Slack/Teams بتبقى مفهومة من غير ما حد يسألك: السياق في سطر، السؤال المحدد، الخيارات اللي فكرت فيها، الموعد اللي محتاج فيه الرد. «سؤال صغير؟» من غير محتوى = مقاطعة من غير فايدة.
Context: eval gate failed on PR #482 (answer_correct dropped 3.1 pts on the Arabic slice only).
Question: do we block the release planned for Thursday?
Options: (a) block and fix chunking for Arabic tables (~2 days), (b) ship behind flag for English tenants only.
I recommend (b). Need a decision by Wed 12:00 to keep the release window.التقدير بالبيانات: Monte Carlo Forecast وأثر الـ WIP
«هتخلص إمتى؟» أصعب سؤال في المهنة، والإجابة الشائعة — جمع تقديرات المهام أو القسمة على المتوسط — بتطلع متفائلة بشكل منتظم: بتنسى إن الأسابيع مش زي بعض، وإن الشغل بيكبر في النص. البديل إنك تستخدم اللي حصل فعلًا: كام مهمة الفريق قفّل كل أسبوع، وتحاكي المستقبل آلاف المرات وتطلّع احتمال بدل تاريخ واحد.
import random, statistics
random.seed(21)
# ---------- 1) forecast: when will 40 remaining items be done? ----------
history = [4, 7, 3, 6, 5, 2, 8, 5, 4, 6, 3, 5] # items finished per week, last 12 weeks (measured, not estimated)
remaining, scope_growth = 40, 0.15 # 15% more work is usually discovered along the way
def simulate_weeks():
left, weeks = remaining * (1 + scope_growth), 0
while left > 0:
left -= random.choice(history) # replay a random past week
weeks += 1
return weeks
runs = sorted(simulate_weeks() for _ in range(10_000))
naive = remaining / statistics.mean(history)
print(f"naive answer (remaining / average throughput): {naive:.1f} weeks")
print("Monte Carlo forecast (10,000 simulated futures):")
for confidence in (50, 70, 85, 95):
print(f" {confidence}% likely to finish within {runs[int(len(runs) * confidence / 100) - 1]} weeks")
print(f" chance of finishing within the naive {round(naive)} weeks: {sum(r <= round(naive) for r in runs) / len(runs):.0%}")
# ---------- 2) WIP: same team, same work, different number of items in progress ----------
def run_team(wip_limit, items=60, people=4):
"""All open items share the team's effort; every extra open item per person costs context-switching time."""
rng = random.Random(5) # identical work for every WIP setting
todo = [rng.uniform(3, 9) for _ in range(items)] # 3-9 person-days of real work each
doing, cycle_times, day = [], [], 0 # doing: [remaining effort, start day]
while todo or doing:
while todo and len(doing) < wip_limit:
doing.append([todo.pop(0), day])
day += 1
tax = 1 / (1 + 0.15 * max(0, len(doing) / people - 1))
share = people * tax / len(doing)
for item in doing:
item[0] -= share
for item in [i for i in doing if i[0] <= 0]:
cycle_times.append(day - item[1]); doing.remove(item)
return cycle_times, day
print("\nsame team of 4, same 60 items — only the WIP limit changes:")
print(f"{'WIP limit':>10}{'median cycle time':>19}{'85th percentile':>17}{'first item done':>17}{'all 60 done':>13}")
for wip in (4, 8, 16, 32):
cycle, total = run_team(wip)
s = sorted(cycle)
first = min(c for c in cycle[:wip])
print(f"{wip:>10}{statistics.median(cycle):>17.0f} d{s[int(len(s) * 0.85) - 1]:>15} d{first:>15} d{total:>11} d")naive answer (remaining / average throughput): 8.3 weeks
Monte Carlo forecast (10,000 simulated futures):
50% likely to finish within 10 weeks
70% likely to finish within 10 weeks
85% likely to finish within 11 weeks
95% likely to finish within 12 weeks
chance of finishing within the naive 8 weeks: 7%
same team of 4, same 60 items — only the WIP limit changes:
WIP limit median cycle time 85th percentile first item done all 60 done
4 6 d 9 d 7 d 98 d
8 14 d 20 d 8 d 108 d
16 29 d 48 d 18 d 131 d
32 77 d 128 d 50 d 176 dالإجابة «البديهية» كانت 8 أسابيع، واحتمال تحققها 7%. القسمة على المتوسط بتتجاهل حاجتين: الـ scope بيزيد (هنا 15%)، والتباين بين الأسابيع. الـ forecast بيقول: 50% خلال 10 أسابيع، و85% خلال 11. الرقم اللي تلتزم بيه قدام العميل هو الـ 85% مش الـ 50% — والفرق بينهم هو «الـ buffer» محسوب بدل ما يكون مخمَّن.
ليه ده أحسن من story points × velocity؟ مش محتاج تقدير لكل مهمة أصلًا: بيعتمد على عدد المهام المقفولة فعليًا. شرطه إن المهام تكون متقاربة الحجم تقريبًا وإن الـ history يمثّل الفريق الحالي. ولازم يتحدّث كل أسبوع — الـ forecast بيضيق كل ما الشغل المتبقي يقل.
جدول الـ WIP هو أهم درس في Kanban: نفس الفريق ونفس الشغل. بـ 4 مهام مفتوحة (واحدة لكل شخص) المهمة بتاخد 6 أيام وأول نتيجة بتوصل للمستخدم بعد أسبوع. بـ 32 مهمة مفتوحة، المهمة الواحدة بتاخد 77 يوم، وأول حاجة بتخلص بعد 50 يوم — والمشروع كله بيخلص أبعد بـ 80%. «نبدأ كل حاجة عشان نبان شغالين» بيأخّر كل حاجة.
السبب مش الـ context switching بس: حتى من غير أي ضريبة تبديل، توزيع المجهود على مهام كتير بيأخّر كل المهام لآخر المدة — مفيش حاجة بتتسلّم بدري، فمفيش feedback بدري، والمخاطر بتتكشف متأخر. ضريبة التبديل (15% لكل مهمة زيادة للشخص في النموذج ده — رقم افتراضي) بتزوّد الطين بلة.
حدود النموذج: المهام هنا مستقلة والمجهود بيتوزع بالتساوي. في الواقع فيه dependencies وانتظار reviews وتخصصات — ودول بيخلّوا أثر الـ WIP العالي أسوأ مش أحسن.
| المقياس | بيقيس إيه | بتستخدمه في |
|---|---|---|
| Throughput | عدد المهام المقفولة في فترة | الـ forecast (زي فوق) |
| Cycle time | من بداية الشغل على المهمة لحد ما تخلص | الوعد لمهمة واحدة: «85% من المهام بتخلص في X يوم» |
| Lead time | من الطلب لحد التسليم (شامل الانتظار في الـ backlog) | تجربة العميل الفعلية |
| WIP | عدد المهام المفتوحة دلوقتي | مؤشر مبكر: لو بيزيد، الـ cycle time هيزيد بعده |
| Velocity (story points) | مجموع تقديرات اللي اتقفل | تخطيط sprint لنفس الفريق بس — ما يتقارنش بين فرق وما يبقاش هدف |
مديرك عايز تاريخ تسليم واحد. الـ forecast: 50% خلال 10 أسابيع، 85% خلال 11، 95% خلال 12. تقول إيه؟
الفريق عنده 25 مهمة «in progress» لـ 5 أشخاص، والـ cycle time بيزيد كل sprint. أول إجراء؟
اختبر فهمك
هل story points تمثل ساعات عمل؟
ما فائدة WIP limits؟
ما الذي يجعل postmortem blameless مفيدًا؟
تمارين محلولة
1: الفريق بيخلص 8 عناصر/أسبوع وعنده 24 شغالين. المدير عايز تسليم أسرع. اقتراحك؟
الحل: Little's Law: cycle time ≈ 3 أسابيع. حط WIP limit (مثلًا 10)، وركّز على إنهاء الموجود قبل البدء في جديد، وقِس الطوابير (review، QA). المتوقع cycle time حوالي أسبوع ونص من غير زيادة مجهود.
2: قسّم story «فوترة حسب الاستخدام» لـ vertical slices
الحل: (1) تسجيل usage events لـ feature واحدة + صفحة تعرضها للـ admin. (2) حد شهري + رسالة لما يتخطى. (3) حساب فاتورة تجريبية (من غير دفع). (4) ربط مع payment provider في sandbox + webhooks idempotent. (5) proration و dunning. كل خطوة تتعرض وتتقاس.
أسئلة إنترفيو: Junior → Senior → Staff
(Junior) إيه هو Definition of Done؟
(Senior) إزاي تقدّر شغل AI غير مؤكد؟
(Staff) الـ org كلها بتشتكي إن الـ delivery بطيء. تبدأ منين؟
المراجع والقراءة الإضافية
الدرس بيشرح الفكرة نفسها؛ الروابط دي للتحقق والتعمق والرجوع لتفاصيل الـ API. (محتاجة إنترنت.)
التوثيق الرسمي — Official documentation
مصادر تعليمية ومتقدمة — Third-party & advanced reading
خريطة التغطية: 21 عنصر من الـ Roadmap ومكان شرحه في الدرس
خلصت الدرس وحليت الأسئلة؟ علّم عليه عشان يتحسب في تقدّمك.