@uptimizr/db 2.0.1 → 2.1.0
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/AGENTS.md +228 -3
- package/README.md +13 -0
- package/dist/duckdb/migrations.d.ts.map +1 -1
- package/dist/duckdb/migrations.js +169 -0
- package/dist/duckdb/migrations.js.map +1 -1
- package/dist/duckdb/panelSpecs.d.ts +29 -0
- package/dist/duckdb/panelSpecs.d.ts.map +1 -0
- package/dist/duckdb/panelSpecs.js +104 -0
- package/dist/duckdb/panelSpecs.js.map +1 -0
- package/dist/duckdb/projectMetadata.d.ts +43 -0
- package/dist/duckdb/projectMetadata.d.ts.map +1 -0
- package/dist/duckdb/projectMetadata.js +222 -0
- package/dist/duckdb/projectMetadata.js.map +1 -0
- package/dist/duckdb/subscriptions.d.ts +45 -0
- package/dist/duckdb/subscriptions.d.ts.map +1 -0
- package/dist/duckdb/subscriptions.js +202 -0
- package/dist/duckdb/subscriptions.js.map +1 -0
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -3
- package/dist/index.js.map +1 -1
- package/dist/insights/anomalies.d.ts +213 -0
- package/dist/insights/anomalies.d.ts.map +1 -0
- package/dist/insights/anomalies.js +340 -0
- package/dist/insights/anomalies.js.map +1 -0
- package/dist/insights/baseline.d.ts +51 -0
- package/dist/insights/baseline.d.ts.map +1 -0
- package/dist/insights/baseline.js +48 -0
- package/dist/insights/baseline.js.map +1 -0
- package/dist/insights/buckets.d.ts +114 -0
- package/dist/insights/buckets.d.ts.map +1 -0
- package/dist/insights/buckets.js +220 -0
- package/dist/insights/buckets.js.map +1 -0
- package/dist/insights/changepoint.d.ts +130 -0
- package/dist/insights/changepoint.d.ts.map +1 -0
- package/dist/insights/changepoint.js +209 -0
- package/dist/insights/changepoint.js.map +1 -0
- package/dist/insights/evaluate.d.ts +63 -0
- package/dist/insights/evaluate.d.ts.map +1 -0
- package/dist/insights/evaluate.js +158 -0
- package/dist/insights/evaluate.js.map +1 -0
- package/dist/insights/health.d.ts +219 -0
- package/dist/insights/health.d.ts.map +1 -0
- package/dist/insights/health.js +349 -0
- package/dist/insights/health.js.map +1 -0
- package/dist/insights/index.d.ts +45 -0
- package/dist/insights/index.d.ts.map +1 -0
- package/dist/insights/index.js +40 -0
- package/dist/insights/index.js.map +1 -0
- package/dist/insights/measures.d.ts +222 -0
- package/dist/insights/measures.d.ts.map +1 -0
- package/dist/insights/measures.js +431 -0
- package/dist/insights/measures.js.map +1 -0
- package/dist/insights/movers.d.ts +123 -0
- package/dist/insights/movers.d.ts.map +1 -0
- package/dist/insights/movers.js +166 -0
- package/dist/insights/movers.js.map +1 -0
- package/dist/insights/significance.d.ts +221 -0
- package/dist/insights/significance.d.ts.map +1 -0
- package/dist/insights/significance.js +531 -0
- package/dist/insights/significance.js.map +1 -0
- package/dist/insights/stats.d.ts +104 -0
- package/dist/insights/stats.d.ts.map +1 -0
- package/dist/insights/stats.js +181 -0
- package/dist/insights/stats.js.map +1 -0
- package/dist/insights/windows.d.ts +95 -0
- package/dist/insights/windows.d.ts.map +1 -0
- package/dist/insights/windows.js +97 -0
- package/dist/insights/windows.js.map +1 -0
- package/dist/metadata.d.ts +178 -1
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +80 -0
- package/dist/metadata.js.map +1 -1
- package/dist/narrative/build.d.ts +78 -0
- package/dist/narrative/build.d.ts.map +1 -0
- package/dist/narrative/build.js +437 -0
- package/dist/narrative/build.js.map +1 -0
- package/dist/narrative/index.d.ts +14 -0
- package/dist/narrative/index.d.ts.map +1 -0
- package/dist/narrative/index.js +13 -0
- package/dist/narrative/index.js.map +1 -0
- package/dist/narrative/text.d.ts +25 -0
- package/dist/narrative/text.d.ts.map +1 -0
- package/dist/narrative/text.js +41 -0
- package/dist/narrative/text.js.map +1 -0
- package/dist/parity/cases.d.ts +3 -0
- package/dist/parity/cases.d.ts.map +1 -1
- package/dist/parity/cases.js +387 -7
- package/dist/parity/cases.js.map +1 -1
- package/dist/parity/compare.d.ts +19 -0
- package/dist/parity/compare.d.ts.map +1 -1
- package/dist/parity/compare.js +19 -0
- package/dist/parity/compare.js.map +1 -1
- package/dist/parity/fixtures.d.ts.map +1 -1
- package/dist/parity/fixtures.js +25 -0
- package/dist/parity/fixtures.js.map +1 -1
- package/dist/query/aggregations.d.ts +46 -1
- package/dist/query/aggregations.d.ts.map +1 -1
- package/dist/query/aggregations.js +86 -0
- package/dist/query/aggregations.js.map +1 -1
- package/dist/query/clickhouseDialect.d.ts.map +1 -1
- package/dist/query/clickhouseDialect.js +5 -1
- package/dist/query/clickhouseDialect.js.map +1 -1
- package/dist/query/customEventVocabulary.d.ts +46 -0
- package/dist/query/customEventVocabulary.d.ts.map +1 -0
- package/dist/query/customEventVocabulary.js +127 -0
- package/dist/query/customEventVocabulary.js.map +1 -0
- package/dist/query/dsl/builders.d.ts +38 -0
- package/dist/query/dsl/builders.d.ts.map +1 -0
- package/dist/query/dsl/builders.js +35 -0
- package/dist/query/dsl/builders.js.map +1 -0
- package/dist/query/dsl/compare.d.ts +167 -0
- package/dist/query/dsl/compare.d.ts.map +1 -0
- package/dist/query/dsl/compare.js +358 -0
- package/dist/query/dsl/compare.js.map +1 -0
- package/dist/query/dsl/compile.d.ts +89 -0
- package/dist/query/dsl/compile.d.ts.map +1 -0
- package/dist/query/dsl/compile.js +174 -0
- package/dist/query/dsl/compile.js.map +1 -0
- package/dist/query/dsl/explain.d.ts +115 -0
- package/dist/query/dsl/explain.d.ts.map +1 -0
- package/dist/query/dsl/explain.js +143 -0
- package/dist/query/dsl/explain.js.map +1 -0
- package/dist/query/dsl/generic.d.ts +127 -0
- package/dist/query/dsl/generic.d.ts.map +1 -0
- package/dist/query/dsl/generic.js +323 -0
- package/dist/query/dsl/generic.js.map +1 -0
- package/dist/query/dsl/index.d.ts +30 -0
- package/dist/query/dsl/index.d.ts.map +1 -0
- package/dist/query/dsl/index.js +23 -0
- package/dist/query/dsl/index.js.map +1 -0
- package/dist/query/dsl/order.d.ts +41 -0
- package/dist/query/dsl/order.d.ts.map +1 -0
- package/dist/query/dsl/order.js +55 -0
- package/dist/query/dsl/order.js.map +1 -0
- package/dist/query/dsl/significance.d.ts +130 -0
- package/dist/query/dsl/significance.d.ts.map +1 -0
- package/dist/query/dsl/significance.js +224 -0
- package/dist/query/dsl/significance.js.map +1 -0
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.d.ts.map +1 -1
- package/dist/query/index.js +8 -0
- package/dist/query/index.js.map +1 -1
- package/dist/query/summary/index.d.ts +4 -2
- package/dist/query/summary/index.d.ts.map +1 -1
- package/dist/query/summary/index.js +2 -1
- package/dist/query/summary/index.js.map +1 -1
- package/dist/query/summary/labels.d.ts +101 -0
- package/dist/query/summary/labels.d.ts.map +1 -0
- package/dist/query/summary/labels.js +261 -0
- package/dist/query/summary/labels.js.map +1 -0
- package/dist/query/summary/reading.d.ts.map +1 -1
- package/dist/query/summary/reading.js +21 -2
- package/dist/query/summary/reading.js.map +1 -1
- package/dist/query/summary/schema.d.ts +250 -20
- package/dist/query/summary/schema.d.ts.map +1 -1
- package/dist/query/summary/schema.js +135 -123
- package/dist/query/summary/schema.js.map +1 -1
- package/dist/query/summary/summarize.d.ts.map +1 -1
- package/dist/query/summary/summarize.js +91 -5
- package/dist/query/summary/summarize.js.map +1 -1
- package/dist/query/summary/types.d.ts +77 -2
- package/dist/query/summary/types.d.ts.map +1 -1
- package/dist/query/types.d.ts +47 -1
- package/dist/query/types.d.ts.map +1 -1
- package/dist/subscriptions.d.ts +208 -0
- package/dist/subscriptions.d.ts.map +1 -0
- package/dist/subscriptions.js +153 -0
- package/dist/subscriptions.js.map +1 -0
- package/llms.txt +9 -0
- package/package.json +8 -8
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Is this change real?** — the two significance tests `compare` can justify
|
|
3
|
+
* (ADR 0051 §4, design sketch §C.2).
|
|
4
|
+
*
|
|
5
|
+
* Pure functions over numbers: no registry, no store, no I/O. They exist here
|
|
6
|
+
* rather than inline in `compare.ts` so they can be unit-tested against
|
|
7
|
+
* textbook worked examples, which is the only way to be sure a statistic is
|
|
8
|
+
* right — a plausible-looking number is exactly the failure mode this file is
|
|
9
|
+
* meant to prevent, since a model will quote whatever it is handed.
|
|
10
|
+
*
|
|
11
|
+
* Two tests, because analytics produces two shapes of measure:
|
|
12
|
+
*
|
|
13
|
+
* - {@link twoProportionZ} — a **count or rate**. "Was 40/1000 this week
|
|
14
|
+
* different from 25/900 last week?" Pooled two-proportion z, two-sided normal
|
|
15
|
+
* p-value, plus a Wilson score interval on each proportion (which, unlike the
|
|
16
|
+
* Wald interval, stays inside 0..1 at the small counts a long tail produces —
|
|
17
|
+
* the same reason the summariser already uses it).
|
|
18
|
+
* - {@link welchT} — a **mean** over two samples of unequal size and variance.
|
|
19
|
+
* Welch's unequal-variance t-test with the Welch–Satterthwaite degrees of
|
|
20
|
+
* freedom. It applies where the two ranges really do give two *samples*: a
|
|
21
|
+
* `bucket`-grain metric compared range-over-range hands us one value per
|
|
22
|
+
* bucket on each side.
|
|
23
|
+
*
|
|
24
|
+
* Neither is applied speculatively. `compare.ts` computes a significance only
|
|
25
|
+
* when the registry says the measure supports it (`unit: count | sessions`, or a
|
|
26
|
+
* `rateOf` denominator) and the denominator clears the metric's
|
|
27
|
+
* `comparable.minSample`; otherwise the field is simply absent, because
|
|
28
|
+
* "no p-value" is a far better answer than a p-value computed from a
|
|
29
|
+
* denominator that cannot support one.
|
|
30
|
+
*
|
|
31
|
+
* ## Accuracy
|
|
32
|
+
*
|
|
33
|
+
* The normal CDF uses the Abramowitz & Stegun 7.1.26 rational approximation of
|
|
34
|
+
* `erf` (|error| < 1.5e-7). The Student-t CDF uses the regularised incomplete
|
|
35
|
+
* beta function via the Lentz continued fraction (Numerical Recipes §6.4),
|
|
36
|
+
* converged to 3e-16 or 300 iterations. Both are far tighter than the third
|
|
37
|
+
* significant figure anyone reads off a p-value.
|
|
38
|
+
*/
|
|
39
|
+
/** The default two-sided level. */
|
|
40
|
+
export const DEFAULT_ALPHA = 0.05;
|
|
41
|
+
/** z for a 95% two-sided interval. */
|
|
42
|
+
const Z_95 = 1.959963984540054;
|
|
43
|
+
/**
|
|
44
|
+
* `erf(x)` — Abramowitz & Stegun 7.1.26. |error| < 1.5e-7, which is three
|
|
45
|
+
* orders of magnitude finer than any p-value is read to.
|
|
46
|
+
*/
|
|
47
|
+
function erf(x) {
|
|
48
|
+
const sign = x < 0 ? -1 : 1;
|
|
49
|
+
const z = Math.abs(x);
|
|
50
|
+
const t = 1 / (1 + 0.3275911 * z);
|
|
51
|
+
const poly = t *
|
|
52
|
+
(0.254829592 + t * (-0.284496736 + t * (1.421413741 + t * (-1.453152027 + t * 1.061405429))));
|
|
53
|
+
return sign * (1 - poly * Math.exp(-z * z));
|
|
54
|
+
}
|
|
55
|
+
/** The standard normal CDF, Φ(x). */
|
|
56
|
+
export function normalCdf(x) {
|
|
57
|
+
return 0.5 * (1 + erf(x / Math.SQRT2));
|
|
58
|
+
}
|
|
59
|
+
/** `ln Γ(x)` — Lanczos approximation (g = 7, n = 9); exact to ~15 digits for x > 0. */
|
|
60
|
+
function logGamma(x) {
|
|
61
|
+
const coefficients = [
|
|
62
|
+
0.99999999999980993, 676.5203681218851, -1259.1392167224028, 771.32342877765313,
|
|
63
|
+
-176.61502916214059, 12.507343278686905, -0.13857109526572012, 9.9843695780195716e-6,
|
|
64
|
+
1.5056327351493116e-7,
|
|
65
|
+
];
|
|
66
|
+
if (x < 0.5) {
|
|
67
|
+
// Reflection, so the series stays in its convergent range.
|
|
68
|
+
return Math.log(Math.PI / Math.sin(Math.PI * x)) - logGamma(1 - x);
|
|
69
|
+
}
|
|
70
|
+
const z = x - 1;
|
|
71
|
+
let series = coefficients[0];
|
|
72
|
+
for (let i = 1; i < coefficients.length; i++)
|
|
73
|
+
series += coefficients[i] / (z + i);
|
|
74
|
+
const t = z + 7.5;
|
|
75
|
+
return 0.5 * Math.log(2 * Math.PI) + (z + 0.5) * Math.log(t) - t + Math.log(series);
|
|
76
|
+
}
|
|
77
|
+
/** Continued fraction for the incomplete beta function (Numerical Recipes §6.4). */
|
|
78
|
+
function betaContinuedFraction(x, a, b) {
|
|
79
|
+
const tiny = 1e-30;
|
|
80
|
+
const qab = a + b;
|
|
81
|
+
const qap = a + 1;
|
|
82
|
+
const qam = a - 1;
|
|
83
|
+
let c = 1;
|
|
84
|
+
let d = 1 - (qab * x) / qap;
|
|
85
|
+
if (Math.abs(d) < tiny)
|
|
86
|
+
d = tiny;
|
|
87
|
+
d = 1 / d;
|
|
88
|
+
let h = d;
|
|
89
|
+
for (let m = 1; m <= 300; m++) {
|
|
90
|
+
const m2 = 2 * m;
|
|
91
|
+
let numerator = (m * (b - m) * x) / ((qam + m2) * (a + m2));
|
|
92
|
+
d = 1 + numerator * d;
|
|
93
|
+
if (Math.abs(d) < tiny)
|
|
94
|
+
d = tiny;
|
|
95
|
+
c = 1 + numerator / c;
|
|
96
|
+
if (Math.abs(c) < tiny)
|
|
97
|
+
c = tiny;
|
|
98
|
+
d = 1 / d;
|
|
99
|
+
h *= d * c;
|
|
100
|
+
numerator = (-(a + m) * (qab + m) * x) / ((a + m2) * (qap + m2));
|
|
101
|
+
d = 1 + numerator * d;
|
|
102
|
+
if (Math.abs(d) < tiny)
|
|
103
|
+
d = tiny;
|
|
104
|
+
c = 1 + numerator / c;
|
|
105
|
+
if (Math.abs(c) < tiny)
|
|
106
|
+
c = tiny;
|
|
107
|
+
d = 1 / d;
|
|
108
|
+
const delta = d * c;
|
|
109
|
+
h *= delta;
|
|
110
|
+
if (Math.abs(delta - 1) < 3e-16)
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
return h;
|
|
114
|
+
}
|
|
115
|
+
/** The regularised incomplete beta function `I_x(a, b)`. */
|
|
116
|
+
function incompleteBeta(x, a, b) {
|
|
117
|
+
if (x <= 0)
|
|
118
|
+
return 0;
|
|
119
|
+
if (x >= 1)
|
|
120
|
+
return 1;
|
|
121
|
+
const front = Math.exp(logGamma(a + b) - logGamma(a) - logGamma(b) + a * Math.log(x) + b * Math.log(1 - x));
|
|
122
|
+
return x < (a + 1) / (a + b + 2)
|
|
123
|
+
? (front * betaContinuedFraction(x, a, b)) / a
|
|
124
|
+
: 1 - (front * betaContinuedFraction(1 - x, b, a)) / b;
|
|
125
|
+
}
|
|
126
|
+
/** The two-sided p-value of a Student-t statistic with `df` degrees of freedom. */
|
|
127
|
+
export function studentTTwoSided(t, df) {
|
|
128
|
+
if (!Number.isFinite(t) || !Number.isFinite(df) || df <= 0)
|
|
129
|
+
return 1;
|
|
130
|
+
const x = df / (df + t * t);
|
|
131
|
+
return incompleteBeta(x, df / 2, 0.5);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A Wilson score interval on `successes / trials`.
|
|
135
|
+
*
|
|
136
|
+
* The same interval the summary envelope reports, restated here so this module
|
|
137
|
+
* stays free of the summariser (and vice versa): both need it, neither should
|
|
138
|
+
* import the other.
|
|
139
|
+
*/
|
|
140
|
+
export function wilsonScoreInterval(successes, trials, z = Z_95) {
|
|
141
|
+
if (trials <= 0)
|
|
142
|
+
return { low: 0, high: 1 };
|
|
143
|
+
const p = successes / trials;
|
|
144
|
+
const denominator = 1 + (z * z) / trials;
|
|
145
|
+
const centre = p + (z * z) / (2 * trials);
|
|
146
|
+
const spread = z * Math.sqrt((p * (1 - p)) / trials + (z * z) / (4 * trials * trials));
|
|
147
|
+
return {
|
|
148
|
+
low: Math.max(0, (centre - spread) / denominator),
|
|
149
|
+
high: Math.min(1, (centre + spread) / denominator),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Pooled two-proportion z test: is `current.successes / current.trials`
|
|
154
|
+
* different from `previous.successes / previous.trials`?
|
|
155
|
+
*
|
|
156
|
+
* Returns `null` when either side has no trials — a proportion of nothing is not
|
|
157
|
+
* a proportion, and reporting `z = 0` for it would read as "no change" when the
|
|
158
|
+
* truth is "no data".
|
|
159
|
+
*/
|
|
160
|
+
export function twoProportionZ(current, previous, alpha = DEFAULT_ALPHA) {
|
|
161
|
+
if (current.trials <= 0 || previous.trials <= 0)
|
|
162
|
+
return null;
|
|
163
|
+
const p1 = current.successes / current.trials;
|
|
164
|
+
const p2 = previous.successes / previous.trials;
|
|
165
|
+
const pooled = (current.successes + previous.successes) / (current.trials + previous.trials);
|
|
166
|
+
const standardError = Math.sqrt(pooled * (1 - pooled) * (1 / current.trials + 1 / previous.trials));
|
|
167
|
+
// Two identical proportions at 0 or 1 give a zero standard error; the honest
|
|
168
|
+
// statistic there is z = 0 (no evidence of a difference), not a division by
|
|
169
|
+
// zero that would surface as NaN and be rendered as "null" downstream.
|
|
170
|
+
const z = standardError === 0 ? 0 : (p1 - p2) / standardError;
|
|
171
|
+
const pValue = 2 * (1 - normalCdf(Math.abs(z)));
|
|
172
|
+
return {
|
|
173
|
+
test: "two-proportion-z",
|
|
174
|
+
current: p1,
|
|
175
|
+
previous: p2,
|
|
176
|
+
diff: p1 - p2,
|
|
177
|
+
z,
|
|
178
|
+
pValue,
|
|
179
|
+
significant: pValue < alpha,
|
|
180
|
+
currentInterval: wilsonScoreInterval(current.successes, current.trials),
|
|
181
|
+
previousInterval: wilsonScoreInterval(previous.successes, previous.trials),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** Mean and unbiased variance of a list of observations; `null` below two. */
|
|
185
|
+
export function sampleOf(values) {
|
|
186
|
+
const finite = values.filter((value) => Number.isFinite(value));
|
|
187
|
+
if (finite.length < 2)
|
|
188
|
+
return null;
|
|
189
|
+
const mean = finite.reduce((sum, value) => sum + value, 0) / finite.length;
|
|
190
|
+
const variance = finite.reduce((sum, value) => sum + (value - mean) * (value - mean), 0) / (finite.length - 1);
|
|
191
|
+
return { mean, variance, n: finite.length };
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Welch's unequal-variance t test with the Welch–Satterthwaite degrees of
|
|
195
|
+
* freedom.
|
|
196
|
+
*
|
|
197
|
+
* Returns `null` when either sample has fewer than two observations (there is no
|
|
198
|
+
* variance to test) or when both variances are zero and the means are equal.
|
|
199
|
+
*/
|
|
200
|
+
export function welchT(current, previous, alpha = DEFAULT_ALPHA) {
|
|
201
|
+
if (current.n < 2 || previous.n < 2)
|
|
202
|
+
return null;
|
|
203
|
+
const sc = current.variance / current.n;
|
|
204
|
+
const sp = previous.variance / previous.n;
|
|
205
|
+
const denominator = Math.sqrt(sc + sp);
|
|
206
|
+
if (denominator === 0)
|
|
207
|
+
return null;
|
|
208
|
+
const t = (current.mean - previous.mean) / denominator;
|
|
209
|
+
const df = ((sc + sp) * (sc + sp)) / ((sc * sc) / (current.n - 1) + (sp * sp) / (previous.n - 1));
|
|
210
|
+
const pValue = studentTTwoSided(t, df);
|
|
211
|
+
return {
|
|
212
|
+
test: "welch-t",
|
|
213
|
+
current: current.mean,
|
|
214
|
+
previous: previous.mean,
|
|
215
|
+
diff: current.mean - previous.mean,
|
|
216
|
+
t,
|
|
217
|
+
df,
|
|
218
|
+
pValue,
|
|
219
|
+
significant: pValue < alpha,
|
|
220
|
+
currentSamples: current.n,
|
|
221
|
+
previousSamples: previous.n,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=significance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"significance.js","sourceRoot":"","sources":["../../../src/query/dsl/significance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAyDH,mCAAmC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC,sCAAsC;AACtC,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAE/B;;;GAGG;AACH,SAAS,GAAG,CAAC,CAAS;IACpB,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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AAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACvC,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI;QAClC,CAAC;QACD,EAAE;QACF,MAAM;QACN,WAAW,EAAE,MAAM,GAAG,KAAK;QAC3B,cAAc,EAAE,OAAO,CAAC,CAAC;QACzB,eAAe,EAAE,QAAQ,CAAC,CAAC;KAC5B,CAAC;AACJ,CAAC"}
|
package/dist/query/index.d.ts
CHANGED
|
@@ -19,7 +19,9 @@ export * from "./relational.js";
|
|
|
19
19
|
export * from "./postgresDialect.js";
|
|
20
20
|
export * from "./mssqlDialect.js";
|
|
21
21
|
export * from "./aggregations.js";
|
|
22
|
+
export * from "./customEventVocabulary.js";
|
|
22
23
|
export { toEventRow, formatUtcTimestamp, toNodeSampleRow, nodeSampleRowToEvent, } from "../events.js";
|
|
23
24
|
export type { EventRow, NodeSampleRow, SessionMeta } from "../events.js";
|
|
24
25
|
export { DUCKDB_MIGRATIONS } from "../duckdb/migrations.js";
|
|
26
|
+
export * from "./dsl/index.js";
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,cAAc,oBAAoB,CAAC;AAKnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,cAAc,oBAAoB,CAAC;AAKnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAKlC,cAAc,4BAA4B,CAAC;AAG3C,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK5D,cAAc,gBAAgB,CAAC"}
|
package/dist/query/index.js
CHANGED
|
@@ -26,6 +26,10 @@ export * from "./postgresDialect.js";
|
|
|
26
26
|
export * from "./mssqlDialect.js";
|
|
27
27
|
// Every `build*` aggregation (renders a QuerySpec for a given Dialect).
|
|
28
28
|
export * from "./aggregations.js";
|
|
29
|
+
// The custom-event vocabulary fold (ADR 0051 §5): the pure half of
|
|
30
|
+
// `buildCustomEventVocabulary`, which turns the sampled payloads into prop keys
|
|
31
|
+
// and coarse types. No I/O, no dialect — browser-safe like the builders.
|
|
32
|
+
export * from "./customEventVocabulary.js";
|
|
29
33
|
// Engine-neutral event → row mapping (isomorphic; imports only @uptimizr/schema).
|
|
30
34
|
export { toEventRow, formatUtcTimestamp, toNodeSampleRow, nodeSampleRowToEvent, } from "../events.js";
|
|
31
35
|
// The DuckDB schema DDL. `migrations.ts` only imports the `DuckdbClient` *type*
|
|
@@ -33,4 +37,8 @@ export { toEventRow, formatUtcTimestamp, toNodeSampleRow, nodeSampleRowToEvent,
|
|
|
33
37
|
// DuckDB-Wasm database. Re-exported here so the in-browser store stays a single
|
|
34
38
|
// source of truth with the Node store (no duplicated/drifting schema).
|
|
35
39
|
export { DUCKDB_MIGRATIONS } from "../duckdb/migrations.js";
|
|
40
|
+
// The delegated query-DSL compiler (ADR 0051 §3). Pure: it reads the metric
|
|
41
|
+
// registry and renders a `QuerySpec` through the same builders above, so it is
|
|
42
|
+
// browser-safe for the same reason they are.
|
|
43
|
+
export * from "./dsl/index.js";
|
|
36
44
|
//# sourceMappingURL=index.js.map
|
package/dist/query/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8DAA8D;AAC9D,cAAc,YAAY,CAAC;AAE3B,mDAAmD;AACnD,cAAc,cAAc,CAAC;AAE7B,+CAA+C;AAC/C,cAAc,oBAAoB,CAAC;AAEnC,+EAA+E;AAC/E,8EAA8E;AAC9E,kBAAkB;AAClB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,wEAAwE;AACxE,cAAc,mBAAmB,CAAC;AAElC,kFAAkF;AAClF,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,uEAAuE;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8DAA8D;AAC9D,cAAc,YAAY,CAAC;AAE3B,mDAAmD;AACnD,cAAc,cAAc,CAAC;AAE7B,+CAA+C;AAC/C,cAAc,oBAAoB,CAAC;AAEnC,+EAA+E;AAC/E,8EAA8E;AAC9E,kBAAkB;AAClB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,wEAAwE;AACxE,cAAc,mBAAmB,CAAC;AAElC,mEAAmE;AACnE,gFAAgF;AAChF,yEAAyE;AACzE,cAAc,4BAA4B,CAAC;AAE3C,kFAAkF;AAClF,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,uEAAuE;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,4EAA4E;AAC5E,+EAA+E;AAC/E,6CAA6C;AAC7C,cAAc,gBAAgB,CAAC"}
|
|
@@ -10,10 +10,12 @@ export { summarizeRows, tableResult } from "./summarize.js";
|
|
|
10
10
|
export type { ResultRow } from "./summarize.js";
|
|
11
11
|
export { clusterCells } from "./cluster.js";
|
|
12
12
|
export type { ClusterOptions, ClusterResult, GridCell } from "./cluster.js";
|
|
13
|
+
export { isWorldSpatialMetric, labelClusters, labelPoint, worldAxisMap } from "./labels.js";
|
|
14
|
+
export type { LabelOptions, LabelledClusters } from "./labels.js";
|
|
13
15
|
export { wilsonInterval, leastSquaresSlope, trendOf, Z_95 } from "./stats.js";
|
|
14
16
|
export { sampleSizeOf } from "./columns.js";
|
|
15
17
|
export { isAdditiveUnit } from "./format.js";
|
|
16
18
|
export { RESULT_FORMATS } from "./types.js";
|
|
17
|
-
export type { AppliedFilters, ClusterRest, ClusterSummary, DrillHints, RankedRow, RankedSummary, RecordSummary, ResolvedRate, RestBucket, ResultFormat, ResultLimits, ResultRange, ResultSummary, SampleSize, SeriesDigest, SeriesSummary, ShareInterval, SpatialCluster, SummaryBase, SummaryConfidence, SummaryContext, SummaryMeasure, TableMeta, TableResult, TrendDirection, } from "./types.js";
|
|
18
|
-
export { resultEnvelopeSchema, resultFormatSchema, resultSummarySchema, tableResultSchema, } from "./schema.js";
|
|
19
|
+
export type { AppliedFilters, ClusterRest, ClusterSummary, DrillHints, DrillQuery, RankedRow, RankedSummary, RecordSummary, ResolvedRate, RestBucket, ResultFormat, ResultLimits, ResultRange, ResultSummary, SampleSize, SeriesDigest, SeriesSummary, ShareInterval, SpatialCluster, SpatialLabel, SpatialScene, SummaryBase, SummaryConfidence, SummaryContext, SummaryMeasure, TableMeta, TableResult, TrendDirection, } from "./types.js";
|
|
20
|
+
export { comparisonResultSchema, moversSummarySchema, queryEnvelopeSchema, queryPlanSchema, resultEnvelopeSchema, resultFormatSchema, resultSummarySchema, tableResultSchema, } from "./schema.js";
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/query/summary/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,YAAY,EACV,cAAc,EACd,WAAW,EACX,cAAc,EACd,UAAU,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,i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ACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { summarizeRows, tableResult } from "./summarize.js";
|
|
10
10
|
export { clusterCells } from "./cluster.js";
|
|
11
|
+
export { isWorldSpatialMetric, labelClusters, labelPoint, worldAxisMap } from "./labels.js";
|
|
11
12
|
export { wilsonInterval, leastSquaresSlope, trendOf, Z_95 } from "./stats.js";
|
|
12
13
|
export { sampleSizeOf } from "./columns.js";
|
|
13
14
|
export { isAdditiveUnit } from "./format.js";
|
|
14
15
|
export { RESULT_FORMATS } from "./types.js";
|
|
15
|
-
export { resultEnvelopeSchema, resultFormatSchema, resultSummarySchema, tableResultSchema, } from "./schema.js";
|
|
16
|
+
export { comparisonResultSchema, moversSummarySchema, queryEnvelopeSchema, queryPlanSchema, resultEnvelopeSchema, resultFormatSchema, resultSummarySchema, tableResultSchema, } from "./schema.js";
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/query/summary/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/query/summary/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA+B5C,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Spatial labelling** of summary clusters (ADR 0051 §2, design sketch §B.2).
|
|
3
|
+
*
|
|
4
|
+
* A hotspot reported as "centred at (-6.2, 0, 8.4)" tells a language model
|
|
5
|
+
* nothing it can act on. The scene registry already knows the vocabulary that
|
|
6
|
+
* would: the proxy's per-mesh AABBs (ADR 0010/0014) name the geometry, and the
|
|
7
|
+
* scene's **regions** (`sceneRegionSchema`) name the places a developer cares
|
|
8
|
+
* about. This module joins the two onto a cluster so the same hotspot reads
|
|
9
|
+
* "near `checkout_button`, in region `counter`".
|
|
10
|
+
*
|
|
11
|
+
* Four fields are attached, and each is defensible on its own:
|
|
12
|
+
*
|
|
13
|
+
* | field | rule |
|
|
14
|
+
* | ------------- | ----------------------------------------------------------------- |
|
|
15
|
+
* | `region` | the **smallest** region (by volume) whose box contains the centroid |
|
|
16
|
+
* | `regions` | *every* containing region id, ascending — regions may overlap |
|
|
17
|
+
* | `nearestMesh` | a proxy box containing the centroid, else the nearest box centre |
|
|
18
|
+
* | `distance` | world units to that mesh's centre; `0` when the box contains it |
|
|
19
|
+
*
|
|
20
|
+
* A mesh match is only reported when it is close enough to mean something: a
|
|
21
|
+
* non-containing box must have its centre within `cellSize × 2` of the centroid,
|
|
22
|
+
* the width of the cell the hotspot was binned into either side. Beyond that the
|
|
23
|
+
* answer is `null` — "there is nothing here" is information, and a confidently
|
|
24
|
+
* wrong landmark is worse than none.
|
|
25
|
+
*
|
|
26
|
+
* ## Determinism
|
|
27
|
+
*
|
|
28
|
+
* Everything here is a pure function of the *sets* it is given. Ties are broken
|
|
29
|
+
* by id / name ascending (never by array order), volumes and distances are
|
|
30
|
+
* compared as plain numbers, and no accumulation happens across boxes — so the
|
|
31
|
+
* same scene and the same clusters always produce the same labels, whatever
|
|
32
|
+
* order the store, the registry table or the proxy listed their rows in.
|
|
33
|
+
*
|
|
34
|
+
* ## Cost
|
|
35
|
+
*
|
|
36
|
+
* `O(clusters × boxes)`, with an early exit: a box whose expanded bounds (its
|
|
37
|
+
* own box grown by the mesh threshold) do not contain the centroid can neither
|
|
38
|
+
* contain it nor have its centre within the threshold, so it is rejected after
|
|
39
|
+
* at most three comparisons without any distance math. With a summary capped at
|
|
40
|
+
* `maxSummaryRows` clusters and a proxy capped at `LIMITS.maxSceneProxyMeshes`
|
|
41
|
+
* boxes, the whole labelling pass is bounded — `__tests__/spatialLabels.test.ts`
|
|
42
|
+
* holds the largest shape to under 50 ms.
|
|
43
|
+
*
|
|
44
|
+
* Pure and browser-safe: no I/O, no `node:` import, no store reference. The
|
|
45
|
+
* collector loads the regions and the proxy once per request and hands them in.
|
|
46
|
+
*/
|
|
47
|
+
import type { MetricDefinition } from "@uptimizr/metrics";
|
|
48
|
+
import type { SpatialCluster, SpatialLabel, SpatialScene } from "./types.js";
|
|
49
|
+
/**
|
|
50
|
+
* Map a cluster summary's grid axes onto world axes, or `null` when the grid is
|
|
51
|
+
* not world-space. A 2-axis `gx`/`gz` grid maps to X and Z: the labelling then
|
|
52
|
+
* tests containment and distance **in the ground plane only**, which is what a
|
|
53
|
+
* ground-binned metric actually measured.
|
|
54
|
+
*/
|
|
55
|
+
export declare function worldAxisMap(axes: readonly string[]): (0 | 1 | 2)[] | null;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a metric summarises as clusters on a **world-space** grid, and so is
|
|
58
|
+
* worth loading a scene's regions and proxy for. Lets the collector skip the two
|
|
59
|
+
* registry reads for the grids that could never be labelled — the viewport
|
|
60
|
+
* pointer/UV bins and the angular view-direction grid — without teaching the
|
|
61
|
+
* Fastify layer which grids those are.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isWorldSpatialMetric(metric: MetricDefinition): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Label one world-space point against a scene's regions and proxy meshes.
|
|
66
|
+
*
|
|
67
|
+
* `point` carries one coordinate per entry of `axes`, already in world units.
|
|
68
|
+
* `meshThreshold` is how far a *non-containing* mesh box's centre may be and
|
|
69
|
+
* still be reported (the collector passes `cellSize × 2`); pass `0` to accept
|
|
70
|
+
* containment only.
|
|
71
|
+
*/
|
|
72
|
+
export declare function labelPoint(point: readonly number[], scene: SpatialScene, axes: readonly (0 | 1 | 2)[], meshThreshold: number): SpatialLabel;
|
|
73
|
+
/** What {@link labelClusters} produced: the labelled clusters and what it could not do. */
|
|
74
|
+
export interface LabelledClusters {
|
|
75
|
+
clusters: SpatialCluster[];
|
|
76
|
+
/** Caveats naming what the scene did not register; empty when both are present. */
|
|
77
|
+
caveats: string[];
|
|
78
|
+
/** Whether anything was actually labelled (false when the grid is not world-space). */
|
|
79
|
+
labelled: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Everything {@link labelClusters} needs about the request that produced them. */
|
|
82
|
+
export interface LabelOptions {
|
|
83
|
+
/** The metric's grid axis column names, in order (`["vx","vy","vz"]`). */
|
|
84
|
+
axes: readonly string[];
|
|
85
|
+
/** The effective world size of one cell (ADR 0040 §1). */
|
|
86
|
+
cellSize: number;
|
|
87
|
+
/** The scene's registered regions and proxy meshes. */
|
|
88
|
+
scene: SpatialScene;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Attach `region` / `regions` / `nearestMesh` / `distance` to each cluster, and
|
|
92
|
+
* upgrade the `drill.region` hint from an ad-hoc world box to the **region id**
|
|
93
|
+
* when a registered region contains the hotspot — the id is the shared name both
|
|
94
|
+
* a human and `?region=<id>` understand, so it is strictly the better hint.
|
|
95
|
+
*
|
|
96
|
+
* Returns the clusters untouched (and `labelled: false`) when the grid is not
|
|
97
|
+
* world-space or no cell size is known: a viewport-bin or angular grid has no
|
|
98
|
+
* world point to label, and saying so is the honest answer.
|
|
99
|
+
*/
|
|
100
|
+
export declare function labelClusters(clusters: readonly SpatialCluster[], options: LabelOptions): LabelledClusters;
|
|
101
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../../src/query/summary/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAsB7E;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAU1E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAItE;AAmED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK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