// WARNING: This pattern is INTENTIONALLY non-idempotent. // It exists to test detectNonIdempotent() diagnosis tooling. // Do NOT use as a reference for correct pattern development. import { computed, Default, pattern, UI, Writable } from "commonfabric"; export default pattern<{ value: Writable>; }>(({ value }) => { // Anti-pattern: Appending to an array instead of replacing — grows infinitely const log = new Writable([]); computed(() => { const current = log.get(); log.set([...current, `${value.get()} at run #${current.length + 1}`]); }); return { $NAME: "Non-Idempotent Accumulator", [UI]: (

Non-Idempotent Accumulator

Input value: {value}
Log (growing rapidly):
    {log.map((entry) =>
  • {entry}
  • )}
Entry count: {computed(() => `${log.get().length}`)}
Anti-pattern:{" "} Reading and appending to the same Writable in computed() — each run reads a longer array and writes an even longer one.
Fix:{" "} Derive the full value from inputs instead of appending incrementally.
), }; });