[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74G61JEPDMAAVR8GA6XM5E4":3,"skill-same:01M74G61JEPDMAAVR8GA6XM5E4":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M74G61JEPDMAAVR8GA6XM5E4","event-driven-design",null,"Design an event-driven flow — event catalog, choreography vs orchestration, saga + compensation, the outbox pattern for dual-writes, idempotent consumers, and CQRS read models.","MohammadBafkar\u002Fpolymath","MohammadBafkar","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F34940462?v=4","01M74G540TQFZWK6KVAPKFVGNR","Mohammad Bafkar","01M74G541HG19QP9V5DQCJVKYE",0,"MIT","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-architecture\u002Fskills\u002Fevent-driven-design\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: event-driven-design\ndescription: Design an event-driven flow — event catalog, choreography vs orchestration, saga + compensation, the outbox pattern for dual-writes, idempotent consumers, and CQRS read models.\n---\n\n# event-driven-design\n\n> Events decouple services in space and time — and move every hard problem to delivery semantics. Design the failure paths first; the happy path is the easy 10%.\n\n**Mode:** analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked `[TBD]` or `[VERIFY]`, never filled in.\n\n## When to use\n\n- A business process spans services and you are choosing between synchronous calls and events.\n- A write must update the database *and* publish a message and you are about to do both in one block (the dual-write trap).\n- A workflow invokes `polymath-architecture:event-driven-design`.\n\nNot this when: the integration is two services and request\u002Fresponse is fine — that is `integration-design`. For the broker's partitioning\u002Fthroughput tuning, that is `polymath-streaming:streaming-design`.\nFor event schema compatibility and versioning, `polymath-streaming:event-schema-evolution`; for worker\u002Fqueue sizing, retries, and DLQs, `polymath-scalability:async-workload-design`.\n\n## Inputs\n\n- The end-to-end process and its steps, with which service owns each.\n- Consistency and ordering requirements; what \"must never happen\".\n\n## Procedure\n\n1. **Catalog the events** — past-tense, business-meaningful (`OrderPlaced`, `PaymentCaptured`), not CRUD (`OrderRowUpdated`). Each has an owner, a schema, and a versioning rule.\n2. **Choreography vs orchestration**: choreography (services react to events) for loose, simple flows; orchestration (a coordinator\u002Fsaga drives steps) when the process is long, needs status, or has complex compensation. State the choice and why.\n3. **Design the saga** for any multi-step process that can fail midway: list each step and its *compensating action* (refund, release, cancel). There is no distributed rollback — only compensation.\n4. **Kill the dual-write** with the *transactional outbox*: write the event to an outbox table in the same DB transaction as the state change; a relay publishes it. Never write DB + broker in two separate commits.\n5. **Make consumers idempotent**: dedupe on event id \u002F idempotency key; assume at-least-once delivery and out-of-order arrival. Define what a duplicate must do (nothing).\n6. **Decide ordering**: if order matters, partition by aggregate id so one entity's events are serialized; do not assume global ordering.\n7. **(CQRS)** if reads and writes diverge sharply, derive a read model from the events and state its staleness budget and rebuild path.\n8. **Name the observability**: a correlation id threaded through every event so a flow can be traced end to end.\n\n## Output\n\n```text\nEvent-driven design: order fulfillment\n\nEvents (past tense · owner · schema · version rule)\n  OrderPlaced        Ordering    orders.v3    additive-only; breaking → OrderPlaced.v4 dual-published 90 d\n  PaymentCaptured    Payments    payments.v2  additive-only\n  ShipmentCreated    Fulfillment fulfil.v1    additive-only\n\nCoordination: orchestration — a fulfillment saga (needs status + multi-step compensation)\n\nSaga\n  step                 compensation\n  reserve stock        release stock\n  capture payment      refund payment\n  create shipment      cancel shipment (cannot fail after carrier pickup → manual review queue)\n\nDual-write: transactional outbox in each service DB; Debezium relay → Kafka\nIdempotency: consumers dedupe on event_id (processed_events table, 7 d)\nOrdering: partition key = order_id (one order's events in order; no global order assumed)\nCorrelation: correlation_id on every event, propagated to traces\n```\n\nInline by default; when a workflow step or the user wants it kept, write it to `docs\u002Farchitecture\u002F\u003Cslug>-events.md` (slug from the system or context name, lowercased, non-`a-z0-9` runs → `-`).\n\n## Quality bar\n\n- No dual-write survives — every publish is outbox-backed or explicitly justified.\n- Every saga step has a compensating action or a documented \"cannot fail here\" reason.\n- Consumers are idempotent and tolerate reordering; the dedup key is named.\n- Events are business facts, not table change-logs.\n","# event-driven-design\n\n> Events decouple services in space and time — and move every hard problem to delivery semantics. Design the failure paths first; the happy path is the easy 10%.\n\n**Mode:** analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked `[TBD]` or `[VERIFY]`, never filled in.\n\n## When to use\n\n- A business process spans services and you are choosing between synchronous calls and events.\n- A write must update the database *and* publish a message and you are about to do both in one block (the dual-write trap).\n- A workflow invokes `polymath-architecture:event-driven-design`.\n\nNot this when: the integration is two services and request\u002Fresponse is fine — that is `integration-design`. For the broker's partitioning\u002Fthroughput tuning, that is `polymath-streaming:streaming-design`.\nFor event schema compatibility and versioning, `polymath-streaming:event-schema-evolution`; for worker\u002Fqueue sizing, retries, and DLQs, `polymath-scalability:async-workload-design`.\n\n## Inputs\n\n- The end-to-end process and its steps, with which service owns each.\n- Consistency and ordering requirements; what \"must never happen\".\n\n## Procedure\n\n1. **Catalog the events** — past-tense, business-meaningful (`OrderPlaced`, `PaymentCaptured`), not CRUD (`OrderRowUpdated`). Each has an owner, a schema, and a versioning rule.\n2. **Choreography vs orchestration**: choreography (services react to events) for loose, simple flows; orchestration (a coordinator\u002Fsaga drives steps) when the process is long, needs status, or has complex compensation. State the choice and why.\n3. **Design the saga** for any multi-step process that can fail midway: list each step and its *compensating action* (refund, release, cancel). There is no distributed rollback — only compensation.\n4. **Kill the dual-write** with the *transactional outbox*: write the event to an outbox table in the same DB transaction as the state change; a relay publishes it. Never write DB + broker in two separate commits.\n5. **Make consumers idempotent**: dedupe on event id \u002F idempotency key; assume at-least-once delivery and out-of-order arrival. Define what a duplicate must do (nothing).\n6. **Decide ordering**: if order matters, partition by aggregate id so one entity's events are serialized; do not assume global ordering.\n7. **(CQRS)** if reads and writes diverge sharply, derive a read model from the events and state its staleness budget and rebuild path.\n8. **Name the observability**: a correlation id threaded through every event so a flow can be traced end to end.\n\n## Output\n\n```text\nEvent-driven design: order fulfillment\n\nEvents (past tense · owner · schema · version rule)\n  OrderPlaced        Ordering    orders.v3    additive-only; breaking → OrderPlaced.v4 dual-published 90 d\n  PaymentCaptured    Payments    payments.v2  additive-only\n  ShipmentCreated    Fulfillment fulfil.v1    additive-only\n\nCoordination: orchestration — a fulfillment saga (needs status + multi-step compensation)\n\nSaga\n  step                 compensation\n  reserve stock        release stock\n  capture payment      refund payment\n  create shipment      cancel shipment (cannot fail after carrier pickup → manual review queue)\n\nDual-write: transactional outbox in each service DB; Debezium relay → Kafka\nIdempotency: consumers dedupe on event_id (processed_events table, 7 d)\nOrdering: partition key = order_id (one order's events in order; no global order assumed)\nCorrelation: correlation_id on every event, propagated to traces\n```\n\nInline by default; when a workflow step or the user wants it kept, write it to `docs\u002Farchitecture\u002F\u003Cslug>-events.md` (slug from the system or context name, lowercased, non-`a-z0-9` runs → `-`).\n\n## Quality bar\n\n- No dual-write survives — every publish is outbox-backed or explicitly justified.\n- Every saga step has a compensating action or a documented \"cannot fail here\" reason.\n- Consumers are idempotent and tolerate reordering; the dedup key is named.\n- Events are business facts, not table change-logs.\n",{"name":5,"description":7},"main","23f6e21841a39580c9da2b5ec941f39dda17cd86","plugins\u002Fpolymath-architecture\u002Fskills\u002Fevent-driven-design","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath","https:\u002F\u002Fgithub.com\u002FMohammadBafkar","2026-10-29 18:34:59",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add MohammadBafkar\u002Fpolymath --skill event-driven-design",{"tool":36,"command":37},"bunx","bunx skills add MohammadBafkar\u002Fpolymath --skill event-driven-design",{"tool":39,"command":40},"pnpm","pnpm dlx skills add MohammadBafkar\u002Fpolymath --skill event-driven-design","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-architecture\u002Fskills\u002Fevent-driven-design\u002FSKILL.md",true,[44],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"routing.yaml","REFERENCE","参考文档",480,"https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-architecture\u002Fskills\u002Fevent-driven-design\u002Frouting.yaml",[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M74GN87EBRHM9N87M7AP1HDD","runbook","Write or refresh an operational runbook for an alert\u002Fsymptom; structured as TL;DR + Pre-checks + Steps + Verification + Rollback + Escalation.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frunbook\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M74GN5GPKEC1JEKP2DFQNEQJ","rfc","Draft a lightweight design RFC to docs\u002Frfcs\u002F\u003Cslug>.md; Summary, Motivation, Detailed design, Drawbacks, Alternatives, Unresolved questions. A proposal to debate, not a recorded decision (adr).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frfc\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M74GN2F4CWPMV4X09TG4E304","editorial-pass","Review and tighten prose in a Markdown artifact for a target tone (terse, formal, friendly) without dropping information; preserve quotations and load-bearing constraints.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Feditorial-pass\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M74GMZWGYMZ37C4DYGT6P23G","architecture-review-facilitation","Run an architecture review as a process — entry criteria, reviewer checklist, decision log, and follow-up actions — pairing the design artifact with a red-team pass.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-review-facilitation\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M74GMXVX0YX3ETDXS527XDGM","architecture-doc","Write a C4-style architecture document; System Context + Containers (+ Components when interesting) with mermaid diagrams. Describes structure, not a decision (adr) or proposal (rfc).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-doc\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M74GMVG1WSMCK066S3KE6V5K","adr","Write an Architecture Decision Record (Michael Nygard format) to docs\u002Fadrs\u002FNNNN-\u003Cslug>.md; frontmatter validated by the ADR artifact schema. Records a made decision, not a proposal to debate (rfc).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Fadr\u002FSKILL.md",[],[]]