@trazum/core 1.55.0 → 1.56.1

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.
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Which rules actually recover anything, and how much.
3
+ *
4
+ * The README says plainly that the deterministic rules recover about one per
5
+ * cent, and that is the fair complaint about this tool. It is also an
6
+ * **aggregate**, and an aggregate is where a distribution goes to hide: seven
7
+ * rules recovering one per cent between them could be seven rules each doing a
8
+ * seventh of the work, or two rules doing all of it beside five that have never
9
+ * changed a byte of anybody's prompt.
10
+ *
11
+ * Nobody here had measured which. That is the wrong place to start an arc
12
+ * about raising the ceiling — what to add on the model's side of the line is a
13
+ * question about what the dictionary side already covers, and "about one per
14
+ * cent" does not answer it.
15
+ *
16
+ * **Two numbers per rule, and they are not the same number.**
17
+ *
18
+ * - **Alone** is what the rule saves when it is the only one running.
19
+ * - **Marginal** is what the whole set loses when the rule is removed.
20
+ *
21
+ * They diverge exactly where rules overlap, which is most of the interesting
22
+ * cases: `duplicate-lines` and `duplicate-blocks` both find a repeated stanza,
23
+ * so each has a real `alone` and a `marginal` near zero. Reporting either
24
+ * figure by itself would be wrong in a different direction — `alone` alone
25
+ * makes an overlapping rule look load-bearing, and `marginal` alone makes it
26
+ * look inert. The report carries both and **never reconciles them into one**,
27
+ * for the same reason a measurement and a projection are never added here.
28
+ *
29
+ * **Inert is a fact about the corpus, never about the rule.** A rule that finds
30
+ * nothing across twenty-one files has not been shown to be useless; it has been
31
+ * shown that these twenty-one files do not contain what it looks for. The
32
+ * distinction is the whole difference between "delete this rule" and "measure
33
+ * it on something else", and this module refuses to make the first claim.
34
+ *
35
+ * Browser-safe: prompts in, arithmetic out, no filesystem.
36
+ */
37
+ import type { OptimizeOptions, RuleId } from './types.js';
38
+ export interface RuleYield {
39
+ id: RuleId;
40
+ /** Tokens saved when this rule is the only one running, across every prompt. */
41
+ alone: number;
42
+ /**
43
+ * Tokens the full set loses when this rule is removed.
44
+ *
45
+ * Zero with a non-zero `alone` means every token it finds is found by
46
+ * something else too — an overlap, not a defect, and not a reason to delete
47
+ * anything without knowing which rule is the better one to keep.
48
+ */
49
+ marginal: number;
50
+ /** How many prompts it changed at all, running alone. */
51
+ prompts: number;
52
+ }
53
+ export interface RuleYieldReport {
54
+ schemaVersion: 1;
55
+ /** Prompts measured. */
56
+ prompts: number;
57
+ /** Tokens across every prompt before any rule ran. */
58
+ tokensBefore: number;
59
+ /**
60
+ * Tokens **the rules** save across every prompt.
61
+ *
62
+ * The whole run's saving minus the floor below, because they are not the
63
+ * same thing and the first version of this module reported the difference as
64
+ * if it were the rules' work. Run over a corpus the rules do not touch, that
65
+ * version said the optimiser saved twenty-one tokens and every rule was
66
+ * redundant — a sentence assembled out of somebody else's arithmetic.
67
+ */
68
+ tokensSaved: number;
69
+ /**
70
+ * Tokens the optimiser saves with **every rule disabled**.
71
+ *
72
+ * Normalisation the optimiser does regardless of the rule set. Named rather
73
+ * than folded in: it is a real saving and it is not a rule's, and a report
74
+ * that credited it to the rules would be flattering exactly the thing this
75
+ * measurement exists to be honest about.
76
+ */
77
+ floor: number;
78
+ /** Per rule, largest `marginal` first, then largest `alone`. */
79
+ rules: RuleYield[];
80
+ /**
81
+ * `alone` summed over every rule.
82
+ *
83
+ * Stated beside `tokensSaved` and deliberately not reconciled with it: the
84
+ * gap between them **is** the overlap, and a single "total" would be the one
85
+ * number that cannot be true. Larger than `tokensSaved` means rules are
86
+ * finding the same tokens; equal means they are disjoint on this corpus.
87
+ */
88
+ sumOfAlone: number;
89
+ /**
90
+ * Rules that save something alone and nothing at the margin — every token
91
+ * they find, another rule finds too. On **this corpus**.
92
+ */
93
+ redundantHere: RuleId[];
94
+ /**
95
+ * Rules that changed nothing at all — they never fired. On **this corpus**,
96
+ * which is the only claim the arithmetic supports: a rule that finds nothing
97
+ * in these files has not been shown to find nothing anywhere.
98
+ */
99
+ inertHere: RuleId[];
100
+ /**
101
+ * Rules that **fired and recovered nothing**: they changed the prompt and
102
+ * the token count did not move.
103
+ *
104
+ * Kept apart from `inertHere`, because the two look identical in a saving
105
+ * column and mean opposite things. A rule that never fires has not been
106
+ * exercised; a rule that fires and saves nothing has been exercised and is
107
+ * altering somebody's prompt for no measured benefit — which is a finding
108
+ * about the rule rather than about the corpus, and the one this measurement
109
+ * was least likely to produce and most worth producing.
110
+ *
111
+ * `emphasis` lands here on a prompt whose shouted words it lowercases: same
112
+ * words, same count, different instruction.
113
+ */
114
+ firedWithoutSavingHere: RuleId[];
115
+ /**
116
+ * How the tokens were counted, so the reader knows the margin.
117
+ *
118
+ * `heuristic` carries the estimator's documented band, and every figure here
119
+ * inherits it — a rule whose marginal yield is a handful of tokens is inside
120
+ * the noise, and the report says which counter it used rather than leaving
121
+ * somebody to assume an exact one.
122
+ */
123
+ tokenSource: 'heuristic' | 'external';
124
+ }
125
+ /**
126
+ * Measures each rule's yield over a set of prompts.
127
+ *
128
+ * `rules` is the full set to measure — the caller passes it rather than this
129
+ * module reaching for the catalogue, so a subset can be measured and so the
130
+ * list has one home. Every run uses the same options, so the level and the
131
+ * token counter are the caller's and not this module's assumption.
132
+ */
133
+ export declare function ruleYield(prompts: string[], rules: readonly RuleId[], options?: OptimizeOptions): RuleYieldReport;
134
+ //# sourceMappingURL=rule-yield.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-yield.d.ts","sourceRoot":"","sources":["../src/rule-yield.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,CAAC,CAAC;IACjB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;;;;OAIG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;;;;;;;;;;OAaG;IACH,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC;;;;;;;OAOG;IACH,WAAW,EAAE,WAAW,GAAG,UAAU,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,GAAE,eAAoB,GAC5B,eAAe,CA+DjB"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Which rules actually recover anything, and how much.
3
+ *
4
+ * The README says plainly that the deterministic rules recover about one per
5
+ * cent, and that is the fair complaint about this tool. It is also an
6
+ * **aggregate**, and an aggregate is where a distribution goes to hide: seven
7
+ * rules recovering one per cent between them could be seven rules each doing a
8
+ * seventh of the work, or two rules doing all of it beside five that have never
9
+ * changed a byte of anybody's prompt.
10
+ *
11
+ * Nobody here had measured which. That is the wrong place to start an arc
12
+ * about raising the ceiling — what to add on the model's side of the line is a
13
+ * question about what the dictionary side already covers, and "about one per
14
+ * cent" does not answer it.
15
+ *
16
+ * **Two numbers per rule, and they are not the same number.**
17
+ *
18
+ * - **Alone** is what the rule saves when it is the only one running.
19
+ * - **Marginal** is what the whole set loses when the rule is removed.
20
+ *
21
+ * They diverge exactly where rules overlap, which is most of the interesting
22
+ * cases: `duplicate-lines` and `duplicate-blocks` both find a repeated stanza,
23
+ * so each has a real `alone` and a `marginal` near zero. Reporting either
24
+ * figure by itself would be wrong in a different direction — `alone` alone
25
+ * makes an overlapping rule look load-bearing, and `marginal` alone makes it
26
+ * look inert. The report carries both and **never reconciles them into one**,
27
+ * for the same reason a measurement and a projection are never added here.
28
+ *
29
+ * **Inert is a fact about the corpus, never about the rule.** A rule that finds
30
+ * nothing across twenty-one files has not been shown to be useless; it has been
31
+ * shown that these twenty-one files do not contain what it looks for. The
32
+ * distinction is the whole difference between "delete this rule" and "measure
33
+ * it on something else", and this module refuses to make the first claim.
34
+ *
35
+ * Browser-safe: prompts in, arithmetic out, no filesystem.
36
+ */
37
+ import { optimize } from './optimize.js';
38
+ /**
39
+ * Measures each rule's yield over a set of prompts.
40
+ *
41
+ * `rules` is the full set to measure — the caller passes it rather than this
42
+ * module reaching for the catalogue, so a subset can be measured and so the
43
+ * list has one home. Every run uses the same options, so the level and the
44
+ * token counter are the caller's and not this module's assumption.
45
+ */
46
+ export function ruleYield(prompts, rules, options = {}) {
47
+ const run = (disableRules) => prompts.map((prompt) => optimize(prompt, { ...options, disableRules }));
48
+ const whole = run([]);
49
+ const tokensBefore = whole.reduce((sum, result) => sum + result.tokensBefore, 0);
50
+ const wholeSaved = whole.reduce((sum, result) => sum + result.tokensSaved, 0);
51
+ /**
52
+ * What the optimiser saves with every rule off.
53
+ *
54
+ * Whitespace normalisation and the like happen either way, and crediting
55
+ * them to the rules is how "the rules recover about one per cent" survives
56
+ * on a corpus where the rules recover nothing.
57
+ */
58
+ const floorResults = run([...rules]);
59
+ const floor = floorResults.reduce((sum, result) => sum + result.tokensSaved, 0);
60
+ const tokensSaved = Math.max(0, wholeSaved - floor);
61
+ const measured = rules.map((id) => {
62
+ // Alone: everything else off.
63
+ const only = run(rules.filter((other) => other !== id));
64
+ const alone = Math.max(0, only.reduce((sum, result) => sum + result.tokensSaved, 0) - floor);
65
+ // Changed against the floor's own output, not against the original: the
66
+ // normalisation changes every prompt, and counting that as this rule
67
+ // having fired is how every rule came back as touching every file.
68
+ const changed = only.filter((result, index) => result.optimized !== floorResults[index]?.optimized).length;
69
+ // Marginal: everything on but this one.
70
+ const without = run([id]);
71
+ const withoutSaved = without.reduce((sum, result) => sum + result.tokensSaved, 0);
72
+ return {
73
+ id,
74
+ alone,
75
+ // Never negative: removing a rule cannot make the set save more, and a
76
+ // rounding artefact that said it did would be a finding nobody could act
77
+ // on. Clamped rather than reported, because the clamp is the honest
78
+ // reading of a difference inside the counter's own noise.
79
+ marginal: Math.max(0, wholeSaved - withoutSaved),
80
+ prompts: changed,
81
+ };
82
+ });
83
+ measured.sort((a, b) => b.marginal - a.marginal || b.alone - a.alone);
84
+ return {
85
+ schemaVersion: 1,
86
+ prompts: prompts.length,
87
+ tokensBefore,
88
+ tokensSaved,
89
+ floor,
90
+ rules: measured,
91
+ sumOfAlone: measured.reduce((sum, rule) => sum + rule.alone, 0),
92
+ redundantHere: measured.filter((rule) => rule.alone > 0 && rule.marginal === 0).map((rule) => rule.id),
93
+ inertHere: measured.filter((rule) => rule.prompts === 0).map((rule) => rule.id),
94
+ firedWithoutSavingHere: measured
95
+ .filter((rule) => rule.prompts > 0 && rule.alone === 0)
96
+ .map((rule) => rule.id),
97
+ tokenSource: whole[0]?.tokenSource ?? 'heuristic',
98
+ };
99
+ }
100
+ //# sourceMappingURL=rule-yield.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-yield.js","sourceRoot":"","sources":["../src/rule-yield.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AA4FzC;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,OAAiB,EACjB,KAAwB,EACxB,OAAO,GAAoB,EAAE;IAE7B,MAAM,GAAG,GAAG,CAAC,YAAsB,EAAE,EAAE,CACrC,OAAO,C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,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACtG,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/E,sBAAsB,EAAE,QAAQ;aAC7B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;aACtD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,IAAI,WAAW;KAClD,CAAC;AACJ,CAAC"}
package/dist/rules.d.ts CHANGED
@@ -1,5 +1,23 @@
1
1
  import type { Rule } from './types.js';
2
- /** Every rule, in the order they must run. */
2
+ /**
3
+ * Every rule, in the order they must run.
4
+ *
5
+ * **The order decides what the reader is told, not just how fast this runs.**
6
+ * A repeated stanza is a repeated *block* and also a set of repeated *lines*,
7
+ * so all three of the deletion rules can find it and whichever runs first
8
+ * takes it. Coarsest first means the report says "one repeated paragraph"
9
+ * rather than "three repeated lines" for the same saving — the same number
10
+ * attached to a sentence somebody can act on instead of three they have to
11
+ * reassemble.
12
+ *
13
+ * That was an unstated consequence until `rules --measure` made the overlap
14
+ * visible: the leave-one-out measurement credits each of the three with the
15
+ * whole saving, because each of them *would* have caught it alone. The applied
16
+ * run credits exactly one, and this list is what picks which.
17
+ *
18
+ * `rules.test.js` pins both facts, so a reorder that quietly changes the
19
+ * attribution fails the build rather than changing what users read.
20
+ */
3
21
  export declare const RULES: readonly Rule[];
4
22
  export declare function getRule(id: string): Rule | undefined;
5
23
  //# sourceMappingURL=rules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAiSvC,8CAA8C;AAC9C,eAAO,MAAM,KAAK,EAAE,SAAS,IAAI,EAgBhC,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAEpD"}
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAiSvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,IAAI,EAiBhC,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAEpD"}
package/dist/rules.js CHANGED
@@ -255,9 +255,28 @@ const nearDuplicateBlocksRule = {
255
255
  return { text: kept.join('\n\n'), hits };
256
256
  },
257
257
  };
258
- /** Every rule, in the order they must run. */
258
+ /**
259
+ * Every rule, in the order they must run.
260
+ *
261
+ * **The order decides what the reader is told, not just how fast this runs.**
262
+ * A repeated stanza is a repeated *block* and also a set of repeated *lines*,
263
+ * so all three of the deletion rules can find it and whichever runs first
264
+ * takes it. Coarsest first means the report says "one repeated paragraph"
265
+ * rather than "three repeated lines" for the same saving — the same number
266
+ * attached to a sentence somebody can act on instead of three they have to
267
+ * reassemble.
268
+ *
269
+ * That was an unstated consequence until `rules --measure` made the overlap
270
+ * visible: the leave-one-out measurement credits each of the three with the
271
+ * whole saving, because each of them *would* have caught it alone. The applied
272
+ * run credits exactly one, and this list is what picks which.
273
+ *
274
+ * `rules.test.js` pins both facts, so a reorder that quietly changes the
275
+ * attribution fails the build rather than changing what users read.
276
+ */
259
277
  export const RULES = [
260
- // Whole-block deletions first, so the rest works over less text.
278
+ // Whole-block deletions first: less text for the rest to walk, and the
279
+ // coarsest description of what was removed.
261
280
  duplicateBlocksRule,
262
281
  nearDuplicateBlocksRule,
263
282
  duplicateLinesRule,
package/dist/rules.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,MAAM,EACN,MAAM,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,kEAAkE;AAClE,SAAS,QAAQ,CAAC,OAAe;IAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,MAAc,EAAE,KAAK,GAAG,KAAK;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,OAAO,IAAI,MAAM,CAAC,uBAAuB,IAAI,qBAAqB,EAAE,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,qFAAqF;AACrF,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,CACL,IAAI;QACF,iEAAiE;SAChE,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC;QACpC,uDAAuD;SACtD,OAAO,CAAC,qBAAqB,EAAE,IAAI,CAAC;QACrC,oCAAoC;SACnC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC;QAC1B,2CAA2C;SAC1C,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;QACnC,kEAAkE;SACjE,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC;QACjD,8EAA8E;SAC7E,OAAO,CAAC,wBAAwB,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K,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;IAC3C,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAoB;IACpC,uEAAuE;IACvE,4CAA4C;IAC5C,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;IAClB,+BAA+B;IAC/B,kBAAkB;IAClB,cAAc;IACd,UAAU;IACV,UAAU;IACV,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,wEAAwE;IACxE,cAAc;IACd,cAAc;CACf,CAAC;AAEF,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trazum/core",
3
- "version": "1.55.0",
3
+ "version": "1.56.1",
4
4
  "description": "Trazum core: priced advisories for LLM prompts (caching, model tier, batching, schemas), plus deterministic trimming, token counting and pricing.",
5
5
  "license": "MIT",
6
6
  "author": "David Mu\u00f1oz Rey",
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Did the things that are supposed to run, run?
3
+ *
4
+ * `watch --once` is designed for a scheduler: it pulls, stores, evaluates and
5
+ * saves state, so a cron entry is the whole daemon. Its state file records the
6
+ * last cycle precisely so a restart is honest about the stretch it did not
7
+ * watch — and that file is read by exactly one thing, which is the next cycle.
8
+ *
9
+ * **So nothing can tell you the watcher stopped, because the thing that would
10
+ * tell you is the thing that stopped.** A dead cron produces silence, and
11
+ * silence is what a watcher with nothing to report produces too. That is
12
+ * `not-recorded is not not-happened` one layer up from where this repository
13
+ * usually meets it: not a missing record, a missing *run*.
14
+ *
15
+ * This module is the arithmetic for saying so. The caller reads the state file
16
+ * and the store; this turns instants into ages and ages into a verdict, which
17
+ * is what makes the rule testable without waiting a week for a cron to die.
18
+ *
19
+ * **Three refusals shape it:**
20
+ *
21
+ * - **Something that never ran cannot be stale.** A repository where nobody
22
+ * has ever started a watcher is not a repository whose watcher is late; it
23
+ * has no cadence to be late against. `never-run` is its own verdict and it
24
+ * never gates, because a gate that fires on "you have not adopted this
25
+ * feature" is a tool nagging rather than measuring.
26
+ * - **No limit, no verdict.** Without a stated threshold the ages are reported
27
+ * and nothing is judged. How stale is too stale is a policy, and this
28
+ * product does not write somebody's policy for them.
29
+ * - **How far the measurements reach is not a run.** A store whose newest
30
+ * record covers up to yesterday is a provider reporting on its own schedule,
31
+ * not a job that failed. It is reported beside the runs and deliberately
32
+ * never judged by the same threshold: merging "nothing ran" with "the
33
+ * provider is a day behind" would produce a red build for somebody else's
34
+ * latency.
35
+ */
36
+
37
+ const HOUR_MS = 3_600_000;
38
+
39
+ export type HeartbeatKind =
40
+ /** The last `watch` cycle, from its state file. */
41
+ | 'watch-cycle'
42
+ /** The last time a connector wrote a record into the store. */
43
+ | 'store-pull'
44
+ /** How far the stored measurements reach — a fact, never a run. */
45
+ | 'store-coverage';
46
+
47
+ export type HeartbeatVerdict =
48
+ /** It has never happened here. Not late; there is no cadence to be late against. */
49
+ | 'never-run'
50
+ /** It happened, and no threshold was stated, so nothing is judged. */
51
+ | 'not-judged'
52
+ /** Within the stated threshold. */
53
+ | 'within'
54
+ /** Past the stated threshold. */
55
+ | 'stale';
56
+
57
+ export interface Heartbeat {
58
+ kind: HeartbeatKind;
59
+ /** When it last happened, or null when it never has. */
60
+ lastMs: number | null;
61
+ /**
62
+ * Whole hours since, or null when it never happened.
63
+ *
64
+ * Hours rather than days because the schedules this is about are hourly as
65
+ * often as daily, and a cron that died twenty hours ago is zero days old.
66
+ * Floored, so an age this reports as six hours is at least six hours.
67
+ */
68
+ ageHours: number | null;
69
+ verdict: HeartbeatVerdict;
70
+ }
71
+
72
+ export interface HeartbeatReport {
73
+ schemaVersion: 1;
74
+ nowMs: number;
75
+ /** The threshold the caller stated, or null when none was. */
76
+ maxStaleHours: number | null;
77
+ beats: Heartbeat[];
78
+ /**
79
+ * True when something that has run before is past the threshold.
80
+ *
81
+ * Never true for a `never-run` beat, and never true for `store-coverage`,
82
+ * which is not a run.
83
+ */
84
+ stale: boolean;
85
+ }
86
+
87
+ /** What the caller found on disk. Nulls are absences, never zero. */
88
+ export interface HeartbeatInput {
89
+ /** `lastCycleMs` from the watch state file, or null when there is none. */
90
+ watchCycleMs: number | null;
91
+ /** The newest `pulledAtMs` in the store, or null when the store is empty. */
92
+ storePulledMs: number | null;
93
+ /** The furthest `toMs` in the store, or null when the store is empty. */
94
+ storeCoveredToMs: number | null;
95
+ }
96
+
97
+ /** Whole hours between two instants, floored and never negative. */
98
+ const hoursSince = (fromMs: number, nowMs: number): number =>
99
+ Math.max(0, Math.floor((nowMs - fromMs) / HOUR_MS));
100
+
101
+ /** Kinds that answer "did something run", as opposed to "how far does it reach". */
102
+ const IS_A_RUN: Record<HeartbeatKind, boolean> = {
103
+ 'watch-cycle': true,
104
+ 'store-pull': true,
105
+ 'store-coverage': false,
106
+ };
107
+
108
+ export function heartbeats(
109
+ input: HeartbeatInput,
110
+ options: { nowMs: number; maxStaleHours?: number },
111
+ ): HeartbeatReport {
112
+ const { nowMs } = options;
113
+ const maxStaleHours =
114
+ typeof options.maxStaleHours === 'number' && Number.isFinite(options.maxStaleHours)
115
+ ? options.maxStaleHours
116
+ : null;
117
+
118
+ const build = (kind: HeartbeatKind, lastMs: number | null): Heartbeat => {
119
+ if (lastMs === null) {
120
+ return { kind, lastMs: null, ageHours: null, verdict: 'never-run' };
121
+ }
122
+ const ageHours = hoursSince(lastMs, nowMs);
123
+ if (maxStaleHours === null || !IS_A_RUN[kind]) {
124
+ return { kind, lastMs, ageHours, verdict: 'not-judged' };
125
+ }
126
+ return { kind, lastMs, ageHours, verdict: ageHours > maxStaleHours ? 'stale' : 'within' };
127
+ };
128
+
129
+ const beats: Heartbeat[] = [
130
+ build('watch-cycle', input.watchCycleMs),
131
+ build('store-pull', input.storePulledMs),
132
+ build('store-coverage', input.storeCoveredToMs),
133
+ ];
134
+
135
+ return {
136
+ schemaVersion: 1,
137
+ nowMs,
138
+ maxStaleHours,
139
+ beats,
140
+ stale: beats.some((beat) => beat.verdict === 'stale'),
141
+ };
142
+ }