主题: design
-
流水线、扇出、编排器与评审小组:哪种多智能体模式适合哪类任务
流水线适合有固定处理步骤的任务;并行扇出适合彼此独立的子问题,或需要多次尝试后投票决定的场景;带工作者的编排器适合分解方式只有在运行时才能确定的任务;评审小组适合需要按多项标准审查的输出;这几种模式都会成倍增加 token 开销,并新增一个可能自身出错的协调层。
-
Event sourcing and CQRS: what they buy and what they cost
Event sourcing stores every state change as an immutable event and derives current state by replay; CQRS separates the write model from read models. Both add auditability and flexibility at the price of complexity and eventual consistency.
-
Technical debt as a metaphor and as a decision
Technical debt describes the future cost of a shortcut; the metaphor is useful when the debt is deliberate and tracked, and misleading when it excuses careless work or is used to describe every imperfection.
-
设计智能体记忆:保留什么、概括什么、忘记什么
智能体记忆分为三个层次:上下文窗口、任务工作笔记和跨会话持久存储。应逐项决定归属层次,让持久记忆保持精简、可审查,并删除不再真实的内容。
-
Privacy review checklist for a feature
Ten questions a reviewer answers before a feature ships: inventory of new personal data, minimisation decisions, retention job, access and access logging, export and deletion coverage, preference purposes, third-party flows, a short LINDDUN pass, test data, and a recorded result; engineering properties only, no legal assessment.
-
Dark mode with prefers-color-scheme, color-scheme and light-dark()
Dark mode has three parts: the prefers-color-scheme media query to detect the user's choice, the color-scheme property (and meta tag) to tell the browser which schemes the page supports so form controls, scrollbars and the canvas follow, and light-dark() or custom properties to swap palette values without duplicating rules.
-
The test-driven development loop
Write a failing test, make it pass with the simplest change, then refactor with the tests green; the loop keeps design decisions small and gives every line a reason to exist.
-
Dataclasses for plain records
dataclasses generate __init__, __repr__ and equality from annotated fields; frozen dataclasses give immutable value objects, slots reduce memory, and field(default_factory=...) avoids shared mutable defaults.
-
重构前识别代码异味
代码异味是表面症状(长方法、大类、依恋情结、霰弹式修改、基本类型偏执),提示可能存在更深层的设计问题;为其命名可以形成评审的共同词汇,并成为重构的触发点。
-
设计 Python 库的异常体系
为每个库定义一个异常基类,从中派生具体错误;抛出异常时提供上下文,用“raise ... from”连接原因,并只在能够处理失败的边界精确捕获相应异常。
-
Modelling states with Literal, Enum and TypedDict
Replace free strings and loose dictionaries with Literal unions, enumerations and TypedDicts so that impossible states are rejected by the type checker and documented in one place.
-
When should a team split a monolith into services?
Open question: which observable signals (deployment coupling, team boundaries, scaling needs, incident patterns) have preceded successful extractions of services from a monolith, and which extractions were later reversed?
-
Human approval gates in agent workflows: which actions need one
An approval gate pauses an agent before an action and lets a person allow or deny it; gate actions that are irreversible, externally visible, costly or privilege-changing, keep the rest automatic, and show the person exactly what would run.
-
Starting with a monolith beats starting with microservices
Hypothesis: new products that begin as a well-structured monolith reach a stable domain model faster and with fewer operational failures than those that begin as microservices; splitting later along proven boundaries is cheaper.
-
LINDDUN 隐私威胁建模概要
逐个检查数据流图元素,对照 LINDDUN 的七类威胁(关联、识别、不可否认性、检测、数据披露、不知情与无法干预、不合规),为每个元素记录场景,并从简短清单中选择缓解措施;这是参考 STRIDE 工作会的单次会议形式。
机器可读: JSON