Audit Is a Provenance Chain, Not a Log File
An audit is a provenance chain: what was stored, where each fact came from, and what was used for each decision. This explainer maps the three links that keep agent behavior traceable and fixable.
Stack OverflowVaishnavi KhoslaExplainer
Premature abstraction in frontend incurs higher coding and coordination costs because a wrong abstraction is harder to undo than duplication. The author’s three workflows—approval, change, and move—shared similar UI but differed in failure handling and auditing needs, leading to a component bloated with conditional flags. Any change to shared behavior required agreement from all three owners and exhaustive testing across all modes, slowing iteration. The Rule of Three advises duplicating code the first two times and only refactoring when the same pattern repeats with the same reason for change. Safe early abstractions include stable primitives, design tokens, accessibility patterns, and standard-driven code such as date formatting, which have externally determined shapes and a single reason to change.
The post challenges the frontend practice of early abstraction and uses a real-world component example to illustrate when duplication is preferable over premature reuse.
Follow the Rule of Three: duplicate code the first two times without abstraction; refactor only when the same pattern appears three times driven by the same reason for change. Stable primitives, design tokens, accessibility behavior, and standard-driven components can be shared immediately. If prematurely abstracted, inline the shared module back into call sites and remove unused branches.
Premature abstraction based on surface similarities introduces flags and increases coordination costs; it is safer to duplicate until the pattern repeats three times with the same reason for change.
The Rule of Three (from Don Roberts via Martin Fowler) advises against abstraction until the third occurrence of a pattern, as duplication is cheaper than a wrong abstraction.
Safe to abstract from day one: stable UI primitives (buttons, inputs), design tokens, accessibility patterns, and standard-driven code (date formatting, currency) because they have a single reason for change and externally defined shape.
Use the test of same reason to change: if a single decision by one person would change both pieces of code, they are true duplicates; otherwise they are coincidences. For example, date formatting changes affect all screens, while submit buttons look identical but belong to different owners with different validation rules.
Inline the shared module back into each call site, copy the code to each workflow, and remove branches that workflow never takes. This allows each copy to evolve independently. Later, extract only the small pieces that truly share the same reason for change.
Stable primitives like buttons and text inputs, design tokens for colors and spacing, accessibility behavior such as focus trapping and keyboard navigation, and anything driven by a standard like date formatting or currency formatting. These have externally determined shapes and a single reason for change.
Summaries are generated from the original by a language model. Check the original before relying on it.
See the idea
An audit is a provenance chain: what was stored, where each fact came from, and what was used for each decision. This explainer maps the three links that keep agent behavior traceable and fixable.
Keep reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
One useful email. Unsubscribe anytime.