<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Moshe Berdugo on Medium]]></title>
        <description><![CDATA[Stories by Moshe Berdugo on Medium]]></description>
        <link>https://medium.com/@mosheberdugo?source=rss-7a67307753d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Kzj0CXqQILPjPgWe.</url>
            <title>Stories by Moshe Berdugo on Medium</title>
            <link>https://medium.com/@mosheberdugo?source=rss-7a67307753d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 11:08:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mosheberdugo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How We Made Business Logic Fast to Change and Boring to Maintain]]></title>
            <link>https://medium.com/riskified-technology/how-we-made-business-logic-fast-to-change-and-boring-to-maintain-0fad281dad92?source=rss-7a67307753d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fad281dad92</guid>
            <category><![CDATA[softeare-engineering]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[business-logic-flaw]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Moshe Berdugo]]></dc:creator>
            <pubDate>Tue, 30 Jun 2026 12:08:45 GMT</pubDate>
            <atom:updated>2026-06-30T12:08:45.524Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2CfyMwVFkycdaxbSKSp9QA.png" /></figure><h4>How trading compile-time safety for strict runtime validation helped us eliminate deployment bottlenecks and empower business teams.</h4><p>Our event-driven Chargeback Management System (CBMS) gets complicated fast. Chargebacks arrive through multiple gateways, each with its own quirks, and while the core lifecycle is similar, edge cases pile up quickly.</p><p>Most clients accept a standard flow, but some require highly customized behavior. Supporting those variations exposed a painful feedback loop: even a one-line rule change required PRs, deployments, testing, and production rollouts — making simple business adjustments slow, costly, and engineer-dependent.</p><p>This is the story of how we stopped rebuilding rule engines in every team, accepted some uncomfortable trade-offs, and built a centralized Decision Context platform that made business logic fast to change, safe to run, and boring to maintain.</p><h3>Single-Purpose Service Approach</h3><p>The default solution for new requirements is often to build another single-purpose microservice, which does work. The temptation to build laser-focused decision services is strong because this approach offers perceived benefits: simplicity, blazing performance due to tailored data models, complete team autonomy, and quick wins.</p><p>However, at scale, this siloed approach brings hidden costs. The <strong>Infrastructure Tax</strong> requires constant rebuilding of complex, dedicated infrastructure (databases, validation, versioning, auditing, UIs), leading to high-maintenance systems. <strong>Semantic Confusion</strong> arises when teams use similar logic but develop conflicting definitions of core concepts (e.g., “priority”), complicating cross-domain debugging. Finally, <strong>Knowledge Walls</strong> silo expertise, preventing teams from leveraging shared knowledge and spotting common patterns.</p><p>We will explore the pros and cons of centralizing all global decision-making and the ultimate decision to build a dedicated platform.</p><h3>The Solution: A Centralized Decision Context Platform</h3><p>Think of each decision as a journey. This framework gives it a specific <em>context</em> and sets up <em>decision nodes</em>- crucial crossroads on the path. At each crossroad, the system evaluates specific information and rules to plot the next step. Architecturally, the Decision Context framework is not just a bespoke tool for one team — it’s a <strong>platform service</strong>. It’s a complete, stand-alone app ready to serve the entire organization.</p><h3>The Decision-Making Hierarchy</h3><p>This navigator organizes its map into three vital layers, like an inverted tree structure:</p><ol><li><strong>The Decision Context:</strong> This is the master container, defining the unique world (domain) of the decision- say, all decisions related to “choosing a document template”. It holds the ultimate goal (<em>Decision Strategy</em>): does the process stop as soon as it finds a winning rule (<em>FirstWins</em>), or does it gather all positive recommendations before concluding (<em>AllWins</em>)? It also holds the fallback plan- a default outcome for a colossal failover.</li><li><strong>The Decision Group:</strong> This layer acts as a filter, grouping rules by priority. It uses a key to decide if the rules are <em>Global</em> (apply to all customers) or <em>Account-designated</em> (specific to one merchant).</li><li><strong>The Decision Node (The Rule Itself):</strong> These are the individual leaves on the tree. Each node has a defined <em>criterion</em> (“When to match?” - e.g., “Transaction amount &gt; $10,000”) and a corresponding <em>outcome</em> (“What to return?” - e.g., “Document Template Id: ‘template-123’”).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdlfWbkkhRnvp_7OgkVx2g.png" /></figure><p>Every root node branches out into 1 or many children-nodes. When incoming data meets a rule’s criteria, the corresponding outcomes are instantly collected and sent to the next step, where they are applied to the final decision.</p><p>How we evaluate context outcome:</p><ol><li>Sort the group decision by GroupsPriority order. By doing this, we ensure Riskified business rules (Global Prioritized) are the top boss. If they aren’t there, the master account rules kick in, and those override individual account definitions if they exist. If we’re missing crucial info, we follow a simple safety net: first, the merchant’s fallback; then the master account’s; and finally, the Riskified global safety net.</li><li>Perform a Depth-First Search (DFS) on the node tree for each group. The root node, defined by the group’s key and account ID, is structured like any other node, with the child node list determining the tree’s layout.</li><li>Evaluate node criteria against input data via the rule Engine (rule engine can be injected as a library into the framework)</li><li>Return outcome from matching leaf node (or parent’s fallback outcome)</li><li>Apply strategy: stop at first match (FirstWins) or continue (AllWins)</li><li>Fall back to rootNode’s defaultOutcome if no nested nodes match.</li></ol><p>Riskified’s UI manages a complex, prioritized rule structure, showing both account-specific and global contexts. While authorized users can easily modify rule criteria, outcomes, and execution order, this accessibility poses a risk of product damage by inexperienced users, making robust validation essential.</p><h3>The Platformic Approach</h3><p>Choosing a general-purpose platform, like the Decision Context framework, means accepting some more hassle for a potential payoff down the road. When we did it, the initial cost proved immediately substantial, while the return was always uncertain.</p><p>A platform is central. Its speed, reliability, and accuracy affect every using team — a failure is felt by all (operational coupling). This critical role creates <strong>intense performance pressure</strong>. We must ensure the platform is “right” for all, requiring extreme measures: much tougher testing (beyond regular services), plus extensive auditing and logging.</p><p>For the platform to become a real platform rather than just a trans-team shared service, we needed to <strong>get everyone on board. </strong>This meant lots of talking with different teams to agree on the core idea, the API, and the compromises we were all willing to make.</p><p>Our main challenge was finding the ideal “sweet spot,” which involved navigating constant dilemmas around ambiguous tradeoffs. A key question was whether our solution was <strong>too abstract</strong>: adopting generic modeling sacrifices valuable compile-time checks and necessitates a heavy reliance on runtime correctness. Moving from typed classes and DTOs to an abstract data structure (plain JSON with strict validation) meant losing the comfort of type-safety. We had to compensate. With validations. A lot of them.</p><h3><strong>The Great Trade-off: Why we killed type-safety to save the business</strong></h3><p>We prioritized runtime adaptability over compile-time safety, accepting that frequently changing, non-engineer-modified decision logic makes compile-time guarantees impractical. This flexibility enabled immediate, system-wide changes without redeployment.</p><p>To mitigate risk, we enforced strict guardrails: JSON was strictly schema-validated on write; rule changes were auditable and deterministic; and failures defaulted to a safe state. We maintained hard constraints -rejecting untyped expressions, dynamic code, implicit defaults, and “best effort” parsing -ensuring invalid rules are synchronously rejected (fail-fast).</p><p>This traded compile-time certainty for tightly controlled runtime behavior, guaranteeing loud, early failures. Framework protections include <strong>Tree Cycle detection</strong>, <strong>Criteria scheme validation</strong> for rule structure, and <strong>Managed Group Key Authorization</strong> for internal key protection. All synchronous validations ensured every stored decision context was structurally sound, semantically correct, and authorized, providing instant user feedback</p><h3>The Payoff Is Finally Here</h3><p>Yeah, it costs a bit upfront, but honestly, ditching those custom, siloed solutions for a proper platform service gives us some seriously sweet benefits-benefits we should have been enjoying ages ago:</p><p><strong>“So long, and thanks for all the fish”.</strong> When <em>our</em> business analysts need to tweak a decision (like case routing or document picking), they use <em>one</em> consistent dashboard and mental model. That means <em>we</em> (the engineers) are no longer getting bugged every time some tiny rule changes. It instantly frees up a significant number of valuable story points in our quarterly dev capacity. They have now become self-sufficient.</p><p><strong>Unified, but <em>our</em> way:</strong> The shared DecisionContextEvaluatorService library makes this bulletproof. Whether the request is for a dispute action or compelling evidence, the core evaluation logic-priority, deep dives (DFS), and strategy application are always the same. We fix a bug or make an improvement once, and <em>everyone</em> gets it instantly. Think of the time we save! If, for some reason, they don’t like our proposed evaluation flow? Fine, the evaluation is local on each platform caller. They can just replace <em>their</em> engine, but they still benefit from our infrastructure.</p><p><strong>Schema Changes are a complete non-issue:</strong> Criteria and outcome fields are flexible (using Record&lt;string,any&gt;). <em>We</em> can roll out new criteria schemas or operators without consumer teams having to scramble, upgrade libraries, or deploy new code. It’s simple. We own the complexity, so they don’t have to.</p><p><strong>Safety is a Shared Investment:</strong> We built expensive safety nets — like cycle detection via DFS, criteria schema validation, and rigorous authorization checks — once into the DecisionContextValidator. That means every single platform service is automatically protected from their mistakes. You’re welcome.</p><h3><strong>Platform Service: The Right Choice for Your Next Task?</strong></h3><p>Often, the answer is no. That feeling of déjà vu -”I’ve done this,” or “This is just copy-paste”- may signal a need for refactoring, not a whole new system. Developing a new platform is a major undertaking, demanding deep engineering, trade-off consideration, organizational research, and high cost and effort. It should not be taken lightly. A platform is only worthwhile when:</p><ul><li>Multiple teams require the exact same functionality.</li><li>Changes are frequent and urgent.</li><li>Inconsistencies or duplication are causing real incidents or measurable monetary loss.</li></ul><p>If the change serves only one team or domain, and platform-like usage is rare (e.g., once a quarter), stick to a domain-scoped solution.</p><p>For senior developers considering similar architectural patterns, the Decision Context framework offers several transferable lessons:</p><ol><li><strong>Invest in Hierarchy</strong>: Flat rule systems quickly become unmanageable. A hierarchical approach (contexts → groups → nodes) provides natural organization and enables sophisticated priority handling.</li><li><strong>Platform Over Library</strong>: For cross-cutting concerns like decision management, a platform service provides stronger consistency guarantees and easier evolution than distributed libraries.</li><li><strong>Validate Aggressively</strong>: When configuration can affect business outcomes, comprehensive validation isn’t optional. Cycle detection, schema validation, and authorization checks prevent entire categories of production incidents.</li><li><strong>Design for Multiple Strategies</strong>: The FirstWins vs AllWin strategies demonstrate that evaluation semantics should be configurable, not hard-coded. Different use cases require different approaches.</li><li><strong>Embrace Explicit Priority</strong>: Rather than implicit ordering based on insertion time or database IDs, explicit priority keys make behavior predictable and debuggable.</li><li><strong>Separate Criteria from Outcome</strong>: The clean separation between “when does this rule match” (criteria) and “what should happen” (outcome) enables reuse and makes rules self-documenting.</li></ol><p>The evolution from rigid, code-embedded rules to a unified Decision Context framework represents more than a technical improvement-it’s a fundamental shift in how the organization manages business logic, enabling agility without sacrificing safety.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fad281dad92" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riskified-technology/how-we-made-business-logic-fast-to-change-and-boring-to-maintain-0fad281dad92">How We Made Business Logic Fast to Change and Boring to Maintain</a> was originally published in <a href="https://medium.com/riskified-technology">Riskified Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>