dotmem 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.cjs CHANGED
@@ -68,7 +68,7 @@ if (!localPkg && typeof process__default.default.env.npm_package_version === "st
68
68
  var resolveEffectiveInstallation = /* @__PURE__ */ __name(() => {
69
69
  const local = {
70
70
  origin: localPkg ? detectOrigin(localPkg.dir) : "app",
71
- version: localPkg?.version ?? "unknown",
71
+ version: localPkg?.version ?? "any",
72
72
  dir: localPkg?.dir ?? "",
73
73
  cliPath: localCliPath
74
74
  };
package/bin/cli.js CHANGED
@@ -59,7 +59,7 @@ if (!localPkg && typeof process.env.npm_package_version === "string" && process.
59
59
  var resolveEffectiveInstallation = /* @__PURE__ */ __name(() => {
60
60
  const local = {
61
61
  origin: localPkg ? detectOrigin(localPkg.dir) : "app",
62
- version: localPkg?.version ?? "unknown",
62
+ version: localPkg?.version ?? "any",
63
63
  dir: localPkg?.dir ?? "",
64
64
  cliPath: localCliPath
65
65
  };
@@ -66,10 +66,9 @@ function toFiniteNumber(value) {
66
66
  __name(toFiniteNumber, "toFiniteNumber");
67
67
 
68
68
  // core/burst-stats/bursts.ts
69
- function tsMs(ev) {
69
+ var tsMs = /* @__PURE__ */ __name((ev) => {
70
70
  return normalizeTimestamp(ev.timestamp);
71
- }
72
- __name(tsMs, "tsMs");
71
+ }, "tsMs");
73
72
  function sortEvents(events) {
74
73
  const valid = [];
75
74
  let invalid = 0;
@@ -124,7 +123,7 @@ function partitionIntoBursts(events, opts) {
124
123
  __name(partitionIntoBursts, "partitionIntoBursts");
125
124
 
126
125
  // core/burst-stats/adapters.ts
127
- function getField(obj, candidates) {
126
+ var getField = /* @__PURE__ */ __name((obj, candidates) => {
128
127
  if (!obj || typeof obj !== "object") return void 0;
129
128
  for (const c of candidates) {
130
129
  if (c.includes(".")) {
@@ -144,13 +143,11 @@ function getField(obj, candidates) {
144
143
  }
145
144
  }
146
145
  return void 0;
147
- }
148
- __name(getField, "getField");
149
- function isDotmemToolName(name) {
146
+ }, "getField");
147
+ var isDotmemToolName = /* @__PURE__ */ __name((name) => {
150
148
  return typeof name === "string" && /dotmem/i.test(name);
151
- }
152
- __name(isDotmemToolName, "isDotmemToolName");
153
- function parseOutputTooLarge(text) {
149
+ }, "isDotmemToolName");
150
+ var parseOutputTooLarge = /* @__PURE__ */ __name((text) => {
154
151
  const m = text.match(/Output too large \(([\d.]+)\s*(KB|MB|B)?\)/i);
155
152
  if (!m) return null;
156
153
  const n = Number(m[1]);
@@ -159,8 +156,7 @@ function parseOutputTooLarge(text) {
159
156
  if (unit === "MB") return Math.round(n * 1024 * 1024);
160
157
  if (unit === "KB") return Math.round(n * 1024);
161
158
  return Math.round(n);
162
- }
163
- __name(parseOutputTooLarge, "parseOutputTooLarge");
159
+ }, "parseOutputTooLarge");
164
160
  var GenericJsonlAdapter = class {
165
161
  static {
166
162
  __name(this, "GenericJsonlAdapter");
@@ -296,22 +292,19 @@ __name(isDotmemToolNamePublic, "isDotmemToolNamePublic");
296
292
 
297
293
  // core/burst-stats/metrics.ts
298
294
  var DOTMEM = /* @__PURE__ */ __name((name) => isDotmemToolNamePublic(name), "DOTMEM");
299
- function isUserEvent(ev) {
295
+ var isUserEvent = /* @__PURE__ */ __name((ev) => {
300
296
  const t = (ev.eventType || "").toLowerCase();
301
297
  return t.includes("user");
302
- }
303
- __name(isUserEvent, "isUserEvent");
304
- function isToolCallEvent(ev) {
298
+ }, "isUserEvent");
299
+ var isToolCallEvent = /* @__PURE__ */ __name((ev) => {
305
300
  const t = (ev.eventType || "").toLowerCase();
306
301
  return t.includes("tool") && t.includes("call");
307
- }
308
- __name(isToolCallEvent, "isToolCallEvent");
309
- function isToolResultEvent(ev) {
302
+ }, "isToolCallEvent");
303
+ var isToolResultEvent = /* @__PURE__ */ __name((ev) => {
310
304
  const t = (ev.eventType || "").toLowerCase();
311
305
  return t.includes("tool") && t.includes("result");
312
- }
313
- __name(isToolResultEvent, "isToolResultEvent");
314
- function pickBestTokenEvent(group) {
306
+ }, "isToolResultEvent");
307
+ var pickBestTokenEvent = /* @__PURE__ */ __name((group) => {
315
308
  let best = group[0];
316
309
  let bestScore = -1;
317
310
  for (const ev of group) {
@@ -326,8 +319,7 @@ function pickBestTokenEvent(group) {
326
319
  }
327
320
  }
328
321
  return best;
329
- }
330
- __name(pickBestTokenEvent, "pickBestTokenEvent");
322
+ }, "pickBestTokenEvent");
331
323
  function computeBurstMetrics(events, opts) {
332
324
  const groups = /* @__PURE__ */ new Map();
333
325
  const noId = [];
@@ -436,7 +428,7 @@ function computeBurstMetrics(events, opts) {
436
428
  };
437
429
  }
438
430
  __name(computeBurstMetrics, "computeBurstMetrics");
439
- function computeActiveMinExport(events, capMin) {
431
+ var computeActiveMinExport = /* @__PURE__ */ __name((events, capMin) => {
440
432
  const stamped = events.map((ev) => normalizeTimestamp(ev.timestamp)).filter((t) => t !== null).sort((a, b) => a - b);
441
433
  const capMs = capMin * 60 * 1e3;
442
434
  let total = 0;
@@ -446,8 +438,7 @@ function computeActiveMinExport(events, capMin) {
446
438
  total += Math.min(delta, capMs);
447
439
  }
448
440
  return total / 6e4;
449
- }
450
- __name(computeActiveMinExport, "computeActiveMinExport");
441
+ }, "computeActiveMinExport");
451
442
  function classifyBurst(activeMin, opts) {
452
443
  if (activeMin < opts.shortMax) return "SHORT";
453
444
  if (activeMin <= opts.longMax) return "MEDIUM";
@@ -496,7 +487,7 @@ function reconstructBursts(events, opts) {
496
487
  return result;
497
488
  }
498
489
  __name(reconstructBursts, "reconstructBursts");
499
- function percentile(sorted, p) {
490
+ var percentile = /* @__PURE__ */ __name((sorted, p) => {
500
491
  if (sorted.length === 0) return null;
501
492
  if (sorted.length === 1) return sorted[0];
502
493
  const arr = [...sorted].sort((a, b) => a - b);
@@ -505,13 +496,11 @@ function percentile(sorted, p) {
505
496
  const hi = Math.ceil(rank);
506
497
  if (lo === hi) return arr[lo];
507
498
  return arr[lo] + (arr[hi] - arr[lo]) * (rank - lo);
508
- }
509
- __name(percentile, "percentile");
510
- function median(arr) {
499
+ }, "percentile");
500
+ var median = /* @__PURE__ */ __name((arr) => {
511
501
  return percentile(arr, 50);
512
- }
513
- __name(median, "median");
514
- function sumNumbers(arr) {
502
+ }, "median");
503
+ var sumNumbers = /* @__PURE__ */ __name((arr) => {
515
504
  let total = 0;
516
505
  let has = false;
517
506
  for (const v of arr) {
@@ -521,9 +510,8 @@ function sumNumbers(arr) {
521
510
  }
522
511
  }
523
512
  return has ? total : null;
524
- }
525
- __name(sumNumbers, "sumNumbers");
526
- function aggregateOne(bursts) {
513
+ }, "sumNumbers");
514
+ var aggregateOne = /* @__PURE__ */ __name((bursts) => {
527
515
  const n = bursts.length;
528
516
  const activeArr = bursts.map((b) => b.activeMin);
529
517
  const wallArr = bursts.map((b) => b.wallMin);
@@ -591,8 +579,7 @@ function aggregateOne(bursts) {
591
579
  available: bursts.some((b) => b.hasCacheReadTokens)
592
580
  }
593
581
  };
594
- }
595
- __name(aggregateOne, "aggregateOne");
582
+ }, "aggregateOne");
596
583
  function aggregateBursts(bursts, opts) {
597
584
  const ro = resolveOptions(opts);
598
585
  const stats = aggregateOne(bursts);
@@ -616,7 +603,7 @@ function analyzeEvents(events, opts, source) {
616
603
  const global = aggregateBursts(bursts, ro);
617
604
  const byProject = /* @__PURE__ */ new Map();
618
605
  for (const ev of filteredEvents) {
619
- const key = ev.projectId ?? "unknown";
606
+ const key = ev.projectId ?? "any";
620
607
  if (!byProject.has(key)) byProject.set(key, []);
621
608
  byProject.get(key).push(ev);
622
609
  }
@@ -816,14 +803,14 @@ async function runBurstStatsCli(argv = process.argv.slice(2)) {
816
803
  if (opts.output) fs__namespace.writeFileSync(opts.output, json);
817
804
  else process.stdout.write(json + "\n");
818
805
  } else {
819
- const text = renderText(result);
806
+ const text = renderText(result, opts);
820
807
  if (opts.output) fs__namespace.writeFileSync(opts.output, text);
821
808
  else process.stdout.write(text);
822
809
  }
823
810
  return 0;
824
811
  }
825
812
  __name(runBurstStatsCli, "runBurstStatsCli");
826
- function renderText(result, _opts) {
813
+ var renderText = /* @__PURE__ */ __name((result, _opts) => {
827
814
  const g = result.global;
828
815
  const lines = [];
829
816
  lines.push("Dotmem Burst Stats");
@@ -851,13 +838,11 @@ function renderText(result, _opts) {
851
838
  lines.push(`Output tokens: ${g.outputTokens.total ?? 0}`);
852
839
  lines.push("");
853
840
  return lines.join("\n");
854
- }
855
- __name(renderText, "renderText");
856
- function fmt(n) {
841
+ }, "renderText");
842
+ var fmt = /* @__PURE__ */ __name((n) => {
857
843
  if (n === null || n === void 0) return "n/a";
858
844
  return Number(n).toFixed(1);
859
- }
860
- __name(fmt, "fmt");
845
+ }, "fmt");
861
846
 
862
847
  // bin/dotmem-burst-stats.ts
863
848
  void (async () => {
@@ -43,10 +43,9 @@ function toFiniteNumber(value) {
43
43
  __name(toFiniteNumber, "toFiniteNumber");
44
44
 
45
45
  // core/burst-stats/bursts.ts
46
- function tsMs(ev) {
46
+ var tsMs = /* @__PURE__ */ __name((ev) => {
47
47
  return normalizeTimestamp(ev.timestamp);
48
- }
49
- __name(tsMs, "tsMs");
48
+ }, "tsMs");
50
49
  function sortEvents(events) {
51
50
  const valid = [];
52
51
  let invalid = 0;
@@ -101,7 +100,7 @@ function partitionIntoBursts(events, opts) {
101
100
  __name(partitionIntoBursts, "partitionIntoBursts");
102
101
 
103
102
  // core/burst-stats/adapters.ts
104
- function getField(obj, candidates) {
103
+ var getField = /* @__PURE__ */ __name((obj, candidates) => {
105
104
  if (!obj || typeof obj !== "object") return void 0;
106
105
  for (const c of candidates) {
107
106
  if (c.includes(".")) {
@@ -121,13 +120,11 @@ function getField(obj, candidates) {
121
120
  }
122
121
  }
123
122
  return void 0;
124
- }
125
- __name(getField, "getField");
126
- function isDotmemToolName(name) {
123
+ }, "getField");
124
+ var isDotmemToolName = /* @__PURE__ */ __name((name) => {
127
125
  return typeof name === "string" && /dotmem/i.test(name);
128
- }
129
- __name(isDotmemToolName, "isDotmemToolName");
130
- function parseOutputTooLarge(text) {
126
+ }, "isDotmemToolName");
127
+ var parseOutputTooLarge = /* @__PURE__ */ __name((text) => {
131
128
  const m = text.match(/Output too large \(([\d.]+)\s*(KB|MB|B)?\)/i);
132
129
  if (!m) return null;
133
130
  const n = Number(m[1]);
@@ -136,8 +133,7 @@ function parseOutputTooLarge(text) {
136
133
  if (unit === "MB") return Math.round(n * 1024 * 1024);
137
134
  if (unit === "KB") return Math.round(n * 1024);
138
135
  return Math.round(n);
139
- }
140
- __name(parseOutputTooLarge, "parseOutputTooLarge");
136
+ }, "parseOutputTooLarge");
141
137
  var GenericJsonlAdapter = class {
142
138
  static {
143
139
  __name(this, "GenericJsonlAdapter");
@@ -273,22 +269,19 @@ __name(isDotmemToolNamePublic, "isDotmemToolNamePublic");
273
269
 
274
270
  // core/burst-stats/metrics.ts
275
271
  var DOTMEM = /* @__PURE__ */ __name((name) => isDotmemToolNamePublic(name), "DOTMEM");
276
- function isUserEvent(ev) {
272
+ var isUserEvent = /* @__PURE__ */ __name((ev) => {
277
273
  const t = (ev.eventType || "").toLowerCase();
278
274
  return t.includes("user");
279
- }
280
- __name(isUserEvent, "isUserEvent");
281
- function isToolCallEvent(ev) {
275
+ }, "isUserEvent");
276
+ var isToolCallEvent = /* @__PURE__ */ __name((ev) => {
282
277
  const t = (ev.eventType || "").toLowerCase();
283
278
  return t.includes("tool") && t.includes("call");
284
- }
285
- __name(isToolCallEvent, "isToolCallEvent");
286
- function isToolResultEvent(ev) {
279
+ }, "isToolCallEvent");
280
+ var isToolResultEvent = /* @__PURE__ */ __name((ev) => {
287
281
  const t = (ev.eventType || "").toLowerCase();
288
282
  return t.includes("tool") && t.includes("result");
289
- }
290
- __name(isToolResultEvent, "isToolResultEvent");
291
- function pickBestTokenEvent(group) {
283
+ }, "isToolResultEvent");
284
+ var pickBestTokenEvent = /* @__PURE__ */ __name((group) => {
292
285
  let best = group[0];
293
286
  let bestScore = -1;
294
287
  for (const ev of group) {
@@ -303,8 +296,7 @@ function pickBestTokenEvent(group) {
303
296
  }
304
297
  }
305
298
  return best;
306
- }
307
- __name(pickBestTokenEvent, "pickBestTokenEvent");
299
+ }, "pickBestTokenEvent");
308
300
  function computeBurstMetrics(events, opts) {
309
301
  const groups = /* @__PURE__ */ new Map();
310
302
  const noId = [];
@@ -413,7 +405,7 @@ function computeBurstMetrics(events, opts) {
413
405
  };
414
406
  }
415
407
  __name(computeBurstMetrics, "computeBurstMetrics");
416
- function computeActiveMinExport(events, capMin) {
408
+ var computeActiveMinExport = /* @__PURE__ */ __name((events, capMin) => {
417
409
  const stamped = events.map((ev) => normalizeTimestamp(ev.timestamp)).filter((t) => t !== null).sort((a, b) => a - b);
418
410
  const capMs = capMin * 60 * 1e3;
419
411
  let total = 0;
@@ -423,8 +415,7 @@ function computeActiveMinExport(events, capMin) {
423
415
  total += Math.min(delta, capMs);
424
416
  }
425
417
  return total / 6e4;
426
- }
427
- __name(computeActiveMinExport, "computeActiveMinExport");
418
+ }, "computeActiveMinExport");
428
419
  function classifyBurst(activeMin, opts) {
429
420
  if (activeMin < opts.shortMax) return "SHORT";
430
421
  if (activeMin <= opts.longMax) return "MEDIUM";
@@ -473,7 +464,7 @@ function reconstructBursts(events, opts) {
473
464
  return result;
474
465
  }
475
466
  __name(reconstructBursts, "reconstructBursts");
476
- function percentile(sorted, p) {
467
+ var percentile = /* @__PURE__ */ __name((sorted, p) => {
477
468
  if (sorted.length === 0) return null;
478
469
  if (sorted.length === 1) return sorted[0];
479
470
  const arr = [...sorted].sort((a, b) => a - b);
@@ -482,13 +473,11 @@ function percentile(sorted, p) {
482
473
  const hi = Math.ceil(rank);
483
474
  if (lo === hi) return arr[lo];
484
475
  return arr[lo] + (arr[hi] - arr[lo]) * (rank - lo);
485
- }
486
- __name(percentile, "percentile");
487
- function median(arr) {
476
+ }, "percentile");
477
+ var median = /* @__PURE__ */ __name((arr) => {
488
478
  return percentile(arr, 50);
489
- }
490
- __name(median, "median");
491
- function sumNumbers(arr) {
479
+ }, "median");
480
+ var sumNumbers = /* @__PURE__ */ __name((arr) => {
492
481
  let total = 0;
493
482
  let has = false;
494
483
  for (const v of arr) {
@@ -498,9 +487,8 @@ function sumNumbers(arr) {
498
487
  }
499
488
  }
500
489
  return has ? total : null;
501
- }
502
- __name(sumNumbers, "sumNumbers");
503
- function aggregateOne(bursts) {
490
+ }, "sumNumbers");
491
+ var aggregateOne = /* @__PURE__ */ __name((bursts) => {
504
492
  const n = bursts.length;
505
493
  const activeArr = bursts.map((b) => b.activeMin);
506
494
  const wallArr = bursts.map((b) => b.wallMin);
@@ -568,8 +556,7 @@ function aggregateOne(bursts) {
568
556
  available: bursts.some((b) => b.hasCacheReadTokens)
569
557
  }
570
558
  };
571
- }
572
- __name(aggregateOne, "aggregateOne");
559
+ }, "aggregateOne");
573
560
  function aggregateBursts(bursts, opts) {
574
561
  const ro = resolveOptions(opts);
575
562
  const stats = aggregateOne(bursts);
@@ -593,7 +580,7 @@ function analyzeEvents(events, opts, source) {
593
580
  const global = aggregateBursts(bursts, ro);
594
581
  const byProject = /* @__PURE__ */ new Map();
595
582
  for (const ev of filteredEvents) {
596
- const key = ev.projectId ?? "unknown";
583
+ const key = ev.projectId ?? "any";
597
584
  if (!byProject.has(key)) byProject.set(key, []);
598
585
  byProject.get(key).push(ev);
599
586
  }
@@ -793,14 +780,14 @@ async function runBurstStatsCli(argv = process.argv.slice(2)) {
793
780
  if (opts.output) fs.writeFileSync(opts.output, json);
794
781
  else process.stdout.write(json + "\n");
795
782
  } else {
796
- const text = renderText(result);
783
+ const text = renderText(result, opts);
797
784
  if (opts.output) fs.writeFileSync(opts.output, text);
798
785
  else process.stdout.write(text);
799
786
  }
800
787
  return 0;
801
788
  }
802
789
  __name(runBurstStatsCli, "runBurstStatsCli");
803
- function renderText(result, _opts) {
790
+ var renderText = /* @__PURE__ */ __name((result, _opts) => {
804
791
  const g = result.global;
805
792
  const lines = [];
806
793
  lines.push("Dotmem Burst Stats");
@@ -828,13 +815,11 @@ function renderText(result, _opts) {
828
815
  lines.push(`Output tokens: ${g.outputTokens.total ?? 0}`);
829
816
  lines.push("");
830
817
  return lines.join("\n");
831
- }
832
- __name(renderText, "renderText");
833
- function fmt(n) {
818
+ }, "renderText");
819
+ var fmt = /* @__PURE__ */ __name((n) => {
834
820
  if (n === null || n === void 0) return "n/a";
835
821
  return Number(n).toFixed(1);
836
- }
837
- __name(fmt, "fmt");
822
+ }, "fmt");
838
823
 
839
824
  // bin/dotmem-burst-stats.ts
840
825
  void (async () => {
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "format": "dotmem.built-in-context",
3
3
  "formatVersion": 1,
4
- "sourceVersion": "0.3.2",
4
+ "sourceVersion": "0.3.3",
5
5
  "buildFormatVersion": 1,
6
6
  "documents": [
7
7
  {
8
8
  "id": "ADR",
9
9
  "file": "ADR.md",
10
10
  "path": "ADR.md",
11
- "content": "# ADR\n\nAn **Architecture Decision Record (ADR)** is a concise document that captures and explains a single architectural decision relevant to a product or digital ecosystem. Ideally kept to one or two pages, it covers three core elements: **the context**, **the decision made**, and **its significant consequences**. A foundational rule is immutability: once accepted, an ADR is never modified if the decision changes—instead, a new ADR is created to supersede it, with a clear link connecting the two.\n\n---\n\n## Why Write ADRs?\n\nWriting ADRs serves two complementary purposes:\n\n* **Institutional Memory:** It allows engineers joining months or years later to understand *why* the system was built a certain way, preventing teams from repeating past mistakes or revisiting settled debates without context.\n* **Clarity and Alignment:** The act of writing forces structured thinking. Putting a consequential decision on paper surfaces conflicting perspectives early, encouraging constructive debate and alignment before a single line of code is written.\n\n---\n\n## Structure and Writing Style\n\nTo ensure ADRs are actually read and remain useful over time, follow a few proven practices:\n\n* **Inverted Pyramid Style:** Borrowing from journalism, put the most critical information (the problem and the decision) right at the top, pushing deep technical details and supporting analysis further down.\n* **Radical Brevity:** Keep it sharp and to the point—ideally within a single page. Link out to benchmarks, complex diagrams, or lengthy discussions rather than bloating the record.\n* **Rationale, Forces, and Alternatives:** Summarize the problem, the underlying constraints (\"forces\"), and the trade-offs evaluated. Explicitly list the serious alternatives considered alongside their pros and cons.\n* **Consequences and Confidence Level:** Spell out the real-world impact of the choice (costs, technical debt, operational overhead). Because decisions are made under uncertainty, it is good practice to record a **confidence level** and specify which changes in product or technical context should trigger a re-evaluation.\n\n---\n\n## Lifecycle and Statuses\n\nEvery record moves through a clear, auditable lifecycle:\n\n| Status | Meaning |\n| --- | --- |\n| **Proposed** | The decision is currently under discussion and open for feedback. |\n| **Accepted** | The team has approved the decision, and it is actively governing work. |\n| **Superseded** | The decision has been replaced by a newer one. The original file remains untouched, linking to the new ADR. |\n| **Deprecated** | The decision is no longer applicable (e.g., the system was retired) without being replaced. |\n\n---\n\n## Storage and Organization\n\n* **Repository and Format:** Standard practice is to store ADRs directly in the codebase repository (e.g., `docs/adr/`), written in **Markdown**. This allows teams to review them via Pull Requests, track history in Git, and automatically publish them to internal developer portals (such as Backstage, Docusaurus, or MkDocs).\n* **Naming Convention:** Each decision lives in its own file, numbered sequentially with a descriptive slug (e.g., `0001-use-htmx-for-active-web-pages.md`).\n* **Beyond a Single Repository:** For decisions spanning a broader ecosystem—or when non-engineers like Product Managers and business stakeholders need to collaborate—a single service repository can create friction. In those cases, teams often use a centralized architecture repository or sync Markdown files with more accessible documentation tools.\n\n---\n\n## ADRs in Modern Decision-Making\n\nIn modern engineering organizations, ADRs are a cornerstone of the **Advice Process**: anyone can make a decision, provided they first seek input from domain experts and the people who will be affected by it. In this model, an ADR is not just a passive log—it is the active vehicle used to gather, synthesize, and document advice before finalizing a choice.\n\nWhile rooted in software architecture, the broader concept of lightweight **Decision Records** works equally well across product, design, and organizational domains, building a transparent historical log of how and why things evolved.\n",
12
- "digest": "sha256:1d10b9632e52a9278ebf707ef626a2478de1773090ae90b608a044c95fabbe00",
13
- "size": 4171,
11
+ "content": "# ADR\n\nAn **Architecture Decision Record (ADR)** is a concise document that captures and explains a single architectural decision relevant to a product or digital ecosystem. Ideally kept to one or two pages, it covers three core elements: **the context**, **the decision made**, and **its significant consequences**. A foundational rule is immutability: once accepted, an ADR is never modified if the decision changes-instead, a new ADR is created to supersede it, with a clear link connecting the two.\n\n---\n\n## Why Write ADRs?\n\nWriting ADRs serves two complementary purposes:\n\n* **Institutional Memory:** It allows engineers joining months or years later to understand *why* the system was built a certain way, preventing teams from repeating past mistakes or revisiting settled debates without context.\n* **Clarity and Alignment:** The act of writing forces structured thinking. Putting a consequential decision on paper surfaces conflicting perspectives early, encouraging constructive debate and alignment before a single line of code is written.\n\n---\n\n## Structure and Writing Style\n\nTo ensure ADRs are actually read and remain useful over time, follow a few proven practices:\n\n* **Inverted Pyramid Style:** Borrowing from journalism, put the most critical information (the problem and the decision) right at the top, pushing deep technical details and supporting analysis further down.\n* **Radical Brevity:** Keep it sharp and to the point-ideally within a single page. Link out to benchmarks, complex diagrams, or lengthy discussions rather than bloating the record.\n* **Rationale, Forces, and Alternatives:** Summarize the problem, the underlying constraints (\"forces\"), and the trade-offs evaluated. Explicitly list the serious alternatives considered alongside their pros and cons.\n* **Consequences and Confidence Level:** Spell out the real-world impact of the choice (costs, technical debt, operational overhead). Because decisions are made under uncertainty, it is good practice to record a **confidence level** and specify which changes in product or technical context should trigger a re-evaluation.\n\n---\n\n## Lifecycle and Statuses\n\nEvery record moves through a clear, auditable lifecycle:\n\n| Status | Meaning |\n| --- | --- |\n| **Proposed** | The decision is currently under discussion and open for feedback. |\n| **Accepted** | The team has approved the decision, and it is actively governing work. |\n| **Superseded** | The decision has been replaced by a newer one. The original file remains untouched, linking to the new ADR. |\n| **Deprecated** | The decision is no longer applicable (e.g., the system was retired) without being replaced. |\n\n---\n\n## Storage and Organization\n\n* **Repository and Format:** Standard practice is to store ADRs directly in the codebase repository (e.g., `docs/adr/`), written in **Markdown**. This allows teams to review them via Pull Requests, track history in Git, and automatically publish them to internal developer portals (such as Backstage, Docusaurus, or MkDocs).\n* **Naming Convention:** Each decision lives in its own file, numbered sequentially with a descriptive slug (e.g., `0001-use-htmx-for-active-web-pages.md`).\n* **Beyond a Single Repository:** For decisions spanning a broader ecosystem-or when non-engineers like Product Managers and business stakeholders need to collaborate-a single service repository can create friction. In those cases, teams often use a centralized architecture repository or sync Markdown files with more accessible documentation tools.\n\n---\n\n## ADRs in Modern Decision-Making\n\nIn modern engineering organizations, ADRs are a cornerstone of the **Advice Process**: anyone can make a decision, provided they first seek input from domain experts and the people who will be affected by it. In this model, an ADR is not just a passive log-it is the active vehicle used to gather, synthesize, and document advice before finalizing a choice.\n\nWhile rooted in software architecture, the broader concept of lightweight **Decision Records** works equally well across product, design, and organizational domains, building a transparent historical log of how and why things evolved.\n",
12
+ "digest": "sha256:2f8f2e64daceebb4bd7425a9a33670602fd32db68dae9540decf09e0dab667fb",
13
+ "size": 4161,
14
14
  "classification": "reference"
15
15
  },
16
16
  {
@@ -158,7 +158,7 @@
158
158
  "classification": "normative"
159
159
  }
160
160
  ],
161
- "manifestDigest": "sha256:08252706522dd233c77a6f93a5dc53db3a5567b46a2110e2cf3c4019c2348acb",
162
- "aggregateDigest": "sha256:6016fbf066ed22107bd72a206464deb1eb56d5ecf1c4db89ca91493ec851f989",
161
+ "manifestDigest": "sha256:e087a6fa4a8b9a4afd7f85243c6cc40c09672d3bdced02bcaa0f50e70e8cfd3a",
162
+ "aggregateDigest": "sha256:e3ca5ea76f8033453235b29eefb5a0a48224332f315e296e2f0f284da86a718e",
163
163
  "documentCount": 17
164
164
  }