ab-analysis-kit 0.0.1.dev0__py3-none-any.whl
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.
- ab_analysis_kit-0.0.1.dev0.dist-info/METADATA +126 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/RECORD +122 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/WHEEL +5 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/entry_points.txt +2 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/licenses/LICENSE +21 -0
- ab_analysis_kit-0.0.1.dev0.dist-info/top_level.txt +1 -0
- abkit/__init__.py +40 -0
- abkit/cli/__init__.py +1 -0
- abkit/cli/_output.py +111 -0
- abkit/cli/commands/__init__.py +1 -0
- abkit/cli/commands/_context.py +83 -0
- abkit/cli/commands/clean.py +133 -0
- abkit/cli/commands/explore.py +208 -0
- abkit/cli/commands/init.py +427 -0
- abkit/cli/commands/run.py +282 -0
- abkit/cli/commands/unlock.py +59 -0
- abkit/cli/commands/validate.py +264 -0
- abkit/cli/main.py +279 -0
- abkit/compute/__init__.py +5 -0
- abkit/compute/recompute_backend.py +140 -0
- abkit/config/__init__.py +51 -0
- abkit/config/discovery.py +168 -0
- abkit/config/experiment_config.py +511 -0
- abkit/config/method_config.py +80 -0
- abkit/config/metric_config.py +214 -0
- abkit/config/profile.py +301 -0
- abkit/config/project_config.py +244 -0
- abkit/config/validator.py +393 -0
- abkit/core/__init__.py +26 -0
- abkit/core/interval.py +148 -0
- abkit/core/models.py +121 -0
- abkit/core/period_planner.py +206 -0
- abkit/database/__init__.py +51 -0
- abkit/database/_sql_manager.py +432 -0
- abkit/database/clickhouse_manager.py +495 -0
- abkit/database/internal_tables/__init__.py +6 -0
- abkit/database/internal_tables/_aa_runs.py +53 -0
- abkit/database/internal_tables/_base.py +71 -0
- abkit/database/internal_tables/_experiments.py +82 -0
- abkit/database/internal_tables/_exposures.py +163 -0
- abkit/database/internal_tables/_maintenance.py +72 -0
- abkit/database/internal_tables/_results.py +231 -0
- abkit/database/internal_tables/_schema.py +23 -0
- abkit/database/internal_tables/_tasks.py +237 -0
- abkit/database/internal_tables/_unit_state.py +148 -0
- abkit/database/internal_tables/manager.py +30 -0
- abkit/database/manager.py +450 -0
- abkit/database/mysql_manager.py +175 -0
- abkit/database/postgres_manager.py +145 -0
- abkit/database/tables.py +326 -0
- abkit/loaders/__init__.py +28 -0
- abkit/loaders/exposure_loader.py +121 -0
- abkit/loaders/metric_loader.py +251 -0
- abkit/loaders/query_template.py +167 -0
- abkit/loaders/templates/abkit_assignment.jinja +62 -0
- abkit/pipeline/__init__.py +37 -0
- abkit/pipeline/_types.py +52 -0
- abkit/pipeline/analyze.py +223 -0
- abkit/pipeline/driver.py +477 -0
- abkit/pipeline/enrich.py +137 -0
- abkit/pipeline/readout.py +779 -0
- abkit/reporting/__init__.py +19 -0
- abkit/reporting/assets/report.js +138 -0
- abkit/reporting/builder.py +484 -0
- abkit/reporting/calibration.py +182 -0
- abkit/reporting/html_report.py +109 -0
- abkit/stats/__init__.py +94 -0
- abkit/stats/accumulate.py +82 -0
- abkit/stats/base.py +347 -0
- abkit/stats/bootstrap/__init__.py +69 -0
- abkit/stats/bootstrap/applier.py +81 -0
- abkit/stats/bootstrap/bootstrap.py +311 -0
- abkit/stats/bootstrap/ci.py +72 -0
- abkit/stats/bootstrap/engine.py +383 -0
- abkit/stats/bootstrap/paired_bootstrap.py +57 -0
- abkit/stats/bootstrap/paired_post_normed_bootstrap.py +81 -0
- abkit/stats/bootstrap/poisson_bootstrap.py +112 -0
- abkit/stats/bootstrap/post_normed_bootstrap.py +102 -0
- abkit/stats/correction.py +88 -0
- abkit/stats/effects.py +141 -0
- abkit/stats/exceptions.py +31 -0
- abkit/stats/factory.py +26 -0
- abkit/stats/parametric/__init__.py +10 -0
- abkit/stats/parametric/cuped_ttest.py +183 -0
- abkit/stats/parametric/paired_cuped_ttest.py +125 -0
- abkit/stats/parametric/paired_ttest.py +136 -0
- abkit/stats/parametric/ratio_delta.py +113 -0
- abkit/stats/parametric/ttest.py +105 -0
- abkit/stats/parametric/ztest.py +134 -0
- abkit/stats/power.py +278 -0
- abkit/stats/registry.py +111 -0
- abkit/stats/result.py +84 -0
- abkit/stats/rng.py +39 -0
- abkit/stats/samples.py +531 -0
- abkit/stats/sequential/__init__.py +18 -0
- abkit/stats/sequential/apply.py +37 -0
- abkit/stats/sequential/confidence_sequence.py +96 -0
- abkit/stats/sequential/mixture.py +70 -0
- abkit/stats/srm.py +221 -0
- abkit/tuning/__init__.py +59 -0
- abkit/tuning/assets/explore.js +173 -0
- abkit/tuning/config_writer.py +409 -0
- abkit/tuning/html.py +88 -0
- abkit/tuning/payload.py +122 -0
- abkit/tuning/recompute.py +1039 -0
- abkit/tuning/server.py +882 -0
- abkit/tuning/session.py +233 -0
- abkit/utils/__init__.py +27 -0
- abkit/utils/datetime_utils.py +97 -0
- abkit/utils/env_interpolation.py +50 -0
- abkit/utils/json_utils.py +38 -0
- abkit/validate/__init__.py +36 -0
- abkit/validate/_types.py +35 -0
- abkit/validate/inject.py +75 -0
- abkit/validate/load.py +160 -0
- abkit/validate/panel.py +59 -0
- abkit/validate/persistence.py +59 -0
- abkit/validate/resample.py +94 -0
- abkit/validate/result.py +60 -0
- abkit/validate/run_id.py +45 -0
- abkit/validate/runner.py +389 -0
- abkit/validate/scoring.py +544 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""The mixture-variance policy ``tau^2`` for the always-valid confidence sequence.
|
|
2
|
+
|
|
3
|
+
ONE source of ``tau^2`` (M5 decision D4, docs/specs/m5-implementation-plan.md): the
|
|
4
|
+
same helper feeds the pipeline activation (WP3) and the A/A validation column (WP2),
|
|
5
|
+
so the interval that ships is exactly the interval the A/A calibrates — otherwise the
|
|
6
|
+
"peeking FPR back to ~alpha" proof validates a different estimator (a WP2 byte-identity
|
|
7
|
+
test pins this).
|
|
8
|
+
|
|
9
|
+
``tau^2`` is **fixed-by-policy**, not user config, and anchored to a **reference look**:
|
|
10
|
+
the *first usable grid cutoff* (the earliest look with a finite positive SE). This is
|
|
11
|
+
the anchor decision (m5-implementation-plan.md D-Seq-anchor, maintainer-confirmed):
|
|
12
|
+
- it is **stable across runs** (the first cutoff is idempotent — same data every run),
|
|
13
|
+
- it is **computable live** during an ongoing experiment (the horizon is in the future
|
|
14
|
+
and cannot be seen pre-conclusion; the first look always exists),
|
|
15
|
+
- it makes the confidence sequence **tightest early**, which is exactly aligned with
|
|
16
|
+
the always-valid use-case (the impatient experimenter peeks early and often).
|
|
17
|
+
Crucially, **validity holds for ANY fixed positive ``tau^2``** — Ville's inequality only
|
|
18
|
+
needs a prior fixed in advance — so the choice affects tightness/power, never coverage;
|
|
19
|
+
that is why the anchor must be fixed at design time (the first look), never the current
|
|
20
|
+
look (which would make the mixing prior data-dependent and void the guarantee). A change
|
|
21
|
+
to this policy is a docs/specs/statistics-changes.md §4 event and triggers the
|
|
22
|
+
sequential-mode re-plan (D7), never a silent CI move. (Horizon-anchoring — statistically
|
|
23
|
+
tightest at the planned stop — is the M6 refinement once ``abk plan`` supplies a
|
|
24
|
+
planned-N; it is not live-computable today.)
|
|
25
|
+
|
|
26
|
+
Purity: plain primitives only.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import math
|
|
32
|
+
|
|
33
|
+
from scipy.optimize import brentq
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _optimal_ratio(alpha: float) -> float:
|
|
37
|
+
"""``u* = tau^2 / V_ref`` that minimises the CS width at the reference look.
|
|
38
|
+
|
|
39
|
+
Writing ``V = SE^2`` and ``u = tau^2 / V``, the mixture radius satisfies
|
|
40
|
+
``r(V)^2 / V = ((1 + u)/u) * (ln(1/alpha) + 0.5 * ln(1 + u))``. Minimising over
|
|
41
|
+
``u`` at the reference variance gives the stationarity condition
|
|
42
|
+
|
|
43
|
+
u = 2 * ln(1/alpha) + ln(1 + u)
|
|
44
|
+
|
|
45
|
+
(a scalar fixed point; e.g. ``u* ~= 8.2`` at ``alpha = 0.05``, where the
|
|
46
|
+
always-valid half-width is ``sqrt(2*h(u*))*SE ~= 3.04*SE`` at the reference look vs
|
|
47
|
+
the fixed ``1.96*SE`` — a ~1.55x anytime price at the anchor, ~1.6-1.9x at a later
|
|
48
|
+
look with more data — the honest cost of any-time peeking). Derivation recorded in
|
|
49
|
+
docs/specs/statistics-changes.md §4.
|
|
50
|
+
"""
|
|
51
|
+
two_ln_inv_alpha = 2.0 * (-math.log(alpha))
|
|
52
|
+
upper = 4.0 * (-math.log(alpha)) + 100.0 # f(upper) > 0 for any alpha in (0,1)
|
|
53
|
+
return float(brentq(lambda u: u - two_ln_inv_alpha - math.log1p(u), 1e-12, upper, xtol=1e-12))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def mixture_tau2(reference_variance: float, alpha: float) -> float:
|
|
57
|
+
"""``tau^2`` anchored to the reference-look estimator variance (D-Seq-anchor).
|
|
58
|
+
|
|
59
|
+
``reference_variance`` is ``Var(effect estimate) = SE^2`` at the first usable grid
|
|
60
|
+
cutoff; the pipeline and the A/A both compute it from the earliest usable look and
|
|
61
|
+
freeze it for the experiment. Returns ``u*(alpha) * reference_variance``. Any
|
|
62
|
+
positive ``tau^2`` is valid; this policy only sets where the sequence is tightest.
|
|
63
|
+
"""
|
|
64
|
+
if not 0.0 < alpha < 1.0:
|
|
65
|
+
raise ValueError(f"alpha must be in (0, 1), got {alpha!r}")
|
|
66
|
+
if not math.isfinite(reference_variance) or reference_variance <= 0.0:
|
|
67
|
+
raise ValueError(
|
|
68
|
+
f"reference_variance must be finite and positive, got {reference_variance!r}"
|
|
69
|
+
)
|
|
70
|
+
return _optimal_ratio(alpha) * reference_variance
|
abkit/stats/srm.py
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"""Sample-ratio-mismatch (SRM) gate.
|
|
2
|
+
|
|
3
|
+
The A/B data-integrity check detectkit has no analog for (architecture §5 step 4):
|
|
4
|
+
observed per-variant unit counts vs the declared ``expected_split``, checked BEFORE
|
|
5
|
+
any effect is computed. Failure is blocking-but-non-dropping — the pipeline still
|
|
6
|
+
writes the row with ``srm_flag=1`` and surfaces a loud red gate; it never silently
|
|
7
|
+
drops results.
|
|
8
|
+
|
|
9
|
+
Two gates, dispatched by cadence (data-contract-and-reporting.md §6,
|
|
10
|
+
cumulative-intervals.md §6.5):
|
|
11
|
+
|
|
12
|
+
- **daily & coarser** — :func:`srm_check`, a chi-square goodness-of-fit at the
|
|
13
|
+
strict ``DEFAULT_SRM_ALPHA``. A bounded daily look count on a 3.3σ hard gate
|
|
14
|
+
makes the peeking inflation negligible, so no anytime correction is needed.
|
|
15
|
+
- **sub-day** (``cadence < 1d``) — :func:`sequential_multinomial_srm`, an
|
|
16
|
+
anytime-valid Dirichlet-multinomial e-process (Lindon & Malek 2022) that is
|
|
17
|
+
valid at EVERY look by construction. A dense sub-day cadence would peek the
|
|
18
|
+
chi-square hard gate dozens of times a day → false alarms; the e-process is
|
|
19
|
+
the honest fix (statistics-changes.md §4.2).
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import math
|
|
25
|
+
from collections.abc import Mapping, Sequence
|
|
26
|
+
from dataclasses import dataclass, field
|
|
27
|
+
|
|
28
|
+
import numpy as np
|
|
29
|
+
import scipy.stats as sps
|
|
30
|
+
from scipy.special import gammaln
|
|
31
|
+
|
|
32
|
+
from abkit.stats.exceptions import SampleValidationError
|
|
33
|
+
|
|
34
|
+
#: SRM must be much stricter than the experiment alpha: a false SRM alarm is cheap,
|
|
35
|
+
#: a missed randomisation failure poisons every effect. 0.001 is the accepted default.
|
|
36
|
+
DEFAULT_SRM_ALPHA = 0.001
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass(frozen=True)
|
|
40
|
+
class SrmResult:
|
|
41
|
+
pvalue: float
|
|
42
|
+
srm_flag: bool
|
|
43
|
+
alpha: float
|
|
44
|
+
observed: dict[str, int] = field(default_factory=dict)
|
|
45
|
+
expected_share: dict[str, float] = field(default_factory=dict)
|
|
46
|
+
#: which gate produced this verdict — ``"chi2"`` (daily) or
|
|
47
|
+
#: ``"sequential_multinomial"`` (sub-day anytime-valid).
|
|
48
|
+
kind: str = "chi2"
|
|
49
|
+
#: the anytime-valid e-value (running max over looks) for the sequential
|
|
50
|
+
#: gate; ``None`` for chi-square. ``pvalue`` is its dual: ``min(1, 1/e_value)``.
|
|
51
|
+
e_value: float | None = None
|
|
52
|
+
|
|
53
|
+
def describe(self) -> str:
|
|
54
|
+
"""The loud one-liner for the CLI gate (data-contract-and-reporting.md §6)."""
|
|
55
|
+
total = sum(self.observed.values())
|
|
56
|
+
observed_shares = (
|
|
57
|
+
"/".join(f"{self.observed[v] / total:.2f}" for v in sorted(self.observed))
|
|
58
|
+
if total
|
|
59
|
+
else "n/a"
|
|
60
|
+
)
|
|
61
|
+
expected_shares = "/".join(
|
|
62
|
+
f"{self.expected_share[v]:.2f}" for v in sorted(self.expected_share)
|
|
63
|
+
)
|
|
64
|
+
if self.kind == "sequential_multinomial":
|
|
65
|
+
evid = f"anytime e={self.e_value:.3g} p={self.pvalue:.2g}"
|
|
66
|
+
else:
|
|
67
|
+
evid = f"chi2 p={self.pvalue:.2g}"
|
|
68
|
+
if self.srm_flag:
|
|
69
|
+
return (
|
|
70
|
+
f"SRM FAILED (observed {observed_shares} vs expected {expected_shares}, "
|
|
71
|
+
f"{evid}) — effects untrustworthy"
|
|
72
|
+
)
|
|
73
|
+
return f"SRM ok (observed {observed_shares} vs expected {expected_shares}, {evid})"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def srm_check(
|
|
77
|
+
observed_counts: Mapping[str, int],
|
|
78
|
+
expected_split: Mapping[str, float],
|
|
79
|
+
alpha: float = DEFAULT_SRM_ALPHA,
|
|
80
|
+
) -> SrmResult:
|
|
81
|
+
"""Chi-square goodness-of-fit of observed variant counts vs the expected split."""
|
|
82
|
+
if set(observed_counts) != set(expected_split):
|
|
83
|
+
raise SampleValidationError(
|
|
84
|
+
f"observed variants {sorted(observed_counts)} != expected_split variants {sorted(expected_split)}"
|
|
85
|
+
)
|
|
86
|
+
if len(observed_counts) < 2:
|
|
87
|
+
raise SampleValidationError("SRM check requires at least two variants")
|
|
88
|
+
|
|
89
|
+
variants = sorted(observed_counts)
|
|
90
|
+
counts = np.array([observed_counts[v] for v in variants], dtype=np.float64)
|
|
91
|
+
shares = np.array([expected_split[v] for v in variants], dtype=np.float64)
|
|
92
|
+
if np.any(counts < 0):
|
|
93
|
+
raise SampleValidationError("observed counts must be non-negative")
|
|
94
|
+
total = counts.sum()
|
|
95
|
+
if total <= 0:
|
|
96
|
+
raise SampleValidationError("observed counts must not all be zero")
|
|
97
|
+
if np.any(shares <= 0):
|
|
98
|
+
raise SampleValidationError("expected_split shares must be positive")
|
|
99
|
+
shares = shares / shares.sum()
|
|
100
|
+
|
|
101
|
+
_, pvalue = sps.chisquare(f_obs=counts, f_exp=total * shares)
|
|
102
|
+
return SrmResult(
|
|
103
|
+
pvalue=float(pvalue),
|
|
104
|
+
srm_flag=bool(pvalue < alpha),
|
|
105
|
+
alpha=alpha,
|
|
106
|
+
observed={v: int(observed_counts[v]) for v in variants},
|
|
107
|
+
expected_share={v: float(share) for v, share in zip(variants, shares, strict=True)},
|
|
108
|
+
kind="chi2",
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def sequential_multinomial_srm(
|
|
113
|
+
counts_stream: Sequence[Mapping[str, int]],
|
|
114
|
+
expected_split: Mapping[str, float],
|
|
115
|
+
prior: Mapping[str, float] | None = None,
|
|
116
|
+
alpha: float = DEFAULT_SRM_ALPHA,
|
|
117
|
+
) -> list[SrmResult]:
|
|
118
|
+
"""Anytime-valid sub-day SRM via a Dirichlet-multinomial mixture e-process.
|
|
119
|
+
|
|
120
|
+
Lindon & Malek, *Anytime-Valid Inference for Multinomial Count Data*
|
|
121
|
+
(NeurIPS 2022, arXiv:2011.03567 §2.2). The null ``M0`` is iid
|
|
122
|
+
``Multinomial(1, θ0)`` (``θ0 = expected_split``); the alternative ``M1``
|
|
123
|
+
mixes ``θ ~ Dirichlet(α0)``. By conjugacy the Bayes factor at cumulative
|
|
124
|
+
counts ``S = (S₁,…,S_d)`` is closed-form and depends on the data ONLY
|
|
125
|
+
through ``S`` (arrival order is irrelevant — so a stream of *cumulative*
|
|
126
|
+
per-variant count vectors is the exact input)::
|
|
127
|
+
|
|
128
|
+
BF₁₀ = Beta(α0 + S) / Beta(α0) · 1 / θ0^S
|
|
129
|
+
|
|
130
|
+
computed in log space with ``gammaln`` (never factorials — they overflow at
|
|
131
|
+
A/B N). With ``A0 = Σ α0,ᵢ`` and ``N = Σ Sᵢ``::
|
|
132
|
+
|
|
133
|
+
log BF = gammaln(A0) − gammaln(A0 + N)
|
|
134
|
+
+ Σᵢ [ gammaln(α0,ᵢ + Sᵢ) − gammaln(α0,ᵢ) − Sᵢ·log(θ0,ᵢ) ]
|
|
135
|
+
|
|
136
|
+
``{BFₙ}`` is a non-negative martingale under ``M0`` with ``BF₀ = 1``, so by
|
|
137
|
+
Ville's inequality ``P(supₙ BFₙ ≥ 1/α) ≤ α`` over ANY data-dependent look
|
|
138
|
+
schedule — the anytime-valid guarantee. The per-look verdict is therefore
|
|
139
|
+
the RUNNING maximum e-value; the anytime p-value is its dual
|
|
140
|
+
``pₙ = min(1, 1/ supₖ≤ₙ BFₖ)`` (non-increasing, so once the gate trips it
|
|
141
|
+
stays tripped). The guarantee is asymptotic-free and holds for ANY fixed
|
|
142
|
+
positive prior — only the stopping time (power) depends on ``α0``; the prior
|
|
143
|
+
must be fixed in advance, not tuned to the data (statistics-changes.md §4.2).
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
counts_stream: cumulative per-variant unit counts at each look, ascending
|
|
147
|
+
(``[{variant: count}, …]``); every dict must key exactly the
|
|
148
|
+
``expected_split`` variants (the pipeline zero-fills absent arms).
|
|
149
|
+
expected_split: the null multinomial ``θ0`` (weights; normalised here).
|
|
150
|
+
prior: per-variant Dirichlet concentration ``α0``. ``None`` ⇒ the paper's
|
|
151
|
+
named default, a uniform ``Dir(1,…,1)``. An explicit map (e.g.
|
|
152
|
+
``k·θ0`` for a mean-pinned concentration) trades power across the
|
|
153
|
+
departure size — correctness is unchanged.
|
|
154
|
+
alpha: the sequential level; the gate trips when ``e_value ≥ 1/alpha``.
|
|
155
|
+
Defaults to :data:`DEFAULT_SRM_ALPHA` (the same strict gate as χ²).
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
One :class:`SrmResult` per look (``kind="sequential_multinomial"``),
|
|
159
|
+
carrying the running e-value, its dual anytime p-value, the cumulative
|
|
160
|
+
counts, and the trip flag. Empty stream ⇒ ``[]``.
|
|
161
|
+
"""
|
|
162
|
+
variants = sorted(expected_split)
|
|
163
|
+
if len(variants) < 2:
|
|
164
|
+
raise SampleValidationError("SRM check requires at least two variants")
|
|
165
|
+
shares = np.array([expected_split[v] for v in variants], dtype=np.float64)
|
|
166
|
+
if np.any(shares <= 0):
|
|
167
|
+
raise SampleValidationError("expected_split shares must be positive")
|
|
168
|
+
shares = shares / shares.sum()
|
|
169
|
+
|
|
170
|
+
if prior is None:
|
|
171
|
+
# the paper's named default: a uniform Dirichlet, α0,ᵢ = 1 (Beta(1,1)
|
|
172
|
+
# for two variants). No magic concentration constant is invented.
|
|
173
|
+
alpha0 = np.ones(len(variants), dtype=np.float64)
|
|
174
|
+
else:
|
|
175
|
+
if set(prior) != set(variants):
|
|
176
|
+
raise SampleValidationError(
|
|
177
|
+
f"prior variants {sorted(prior)} != expected_split variants {variants}"
|
|
178
|
+
)
|
|
179
|
+
alpha0 = np.array([prior[v] for v in variants], dtype=np.float64)
|
|
180
|
+
if np.any(alpha0 <= 0):
|
|
181
|
+
raise SampleValidationError("prior concentrations must be positive")
|
|
182
|
+
|
|
183
|
+
log_shares = np.log(shares)
|
|
184
|
+
a0_total = float(alpha0.sum())
|
|
185
|
+
gammaln_a0_total = gammaln(a0_total)
|
|
186
|
+
gammaln_alpha0 = gammaln(alpha0)
|
|
187
|
+
log_reject = -math.log(alpha) # reject when log BF ≥ log(1/alpha)
|
|
188
|
+
|
|
189
|
+
results: list[SrmResult] = []
|
|
190
|
+
running_max_log_bf = -math.inf
|
|
191
|
+
expected_share = {v: float(s) for v, s in zip(variants, shares, strict=True)}
|
|
192
|
+
for look in counts_stream:
|
|
193
|
+
if set(look) != set(variants):
|
|
194
|
+
raise SampleValidationError(
|
|
195
|
+
f"look counts {sorted(look)} != expected_split variants {variants}"
|
|
196
|
+
)
|
|
197
|
+
counts = np.array([look[v] for v in variants], dtype=np.float64)
|
|
198
|
+
if np.any(counts < 0):
|
|
199
|
+
raise SampleValidationError("observed counts must be non-negative")
|
|
200
|
+
n_total = float(counts.sum())
|
|
201
|
+
log_bf = float(
|
|
202
|
+
gammaln_a0_total
|
|
203
|
+
- gammaln(a0_total + n_total)
|
|
204
|
+
+ np.sum(gammaln(alpha0 + counts) - gammaln_alpha0 - counts * log_shares)
|
|
205
|
+
)
|
|
206
|
+
running_max_log_bf = max(running_max_log_bf, log_bf)
|
|
207
|
+
# e-value ≥ 1 always (N=0 ⇒ BF=1); p = 1/sup(e), clipped to 1.
|
|
208
|
+
pvalue = math.exp(-max(running_max_log_bf, 0.0))
|
|
209
|
+
e_value = math.inf if running_max_log_bf > 709.0 else math.exp(running_max_log_bf)
|
|
210
|
+
results.append(
|
|
211
|
+
SrmResult(
|
|
212
|
+
pvalue=float(pvalue),
|
|
213
|
+
srm_flag=bool(running_max_log_bf >= log_reject),
|
|
214
|
+
alpha=alpha,
|
|
215
|
+
observed={v: int(look[v]) for v in variants},
|
|
216
|
+
expected_share=expected_share,
|
|
217
|
+
kind="sequential_multinomial",
|
|
218
|
+
e_value=float(e_value),
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
return results
|
abkit/tuning/__init__.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""The explore cockpit's server-side engine (m3-implementation-plan.md WP4+).
|
|
2
|
+
|
|
3
|
+
``session`` holds the one-load-pass state (persisted series + the bounded
|
|
4
|
+
Tier-S per-unit cache, D2); ``recompute`` answers knob changes from it
|
|
5
|
+
(Tiers E/α/S/R, D1) and carries the calibration lookup (D3). The localhost
|
|
6
|
+
server (WP6) and ``abk explore`` (WP8) bind these; nothing here touches the
|
|
7
|
+
DB after session load.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from abkit.tuning.config_writer import (
|
|
11
|
+
AppliedConfig,
|
|
12
|
+
OrphanedSeries,
|
|
13
|
+
TunedComparison,
|
|
14
|
+
apply_tuned_config,
|
|
15
|
+
)
|
|
16
|
+
from abkit.tuning.html import render_explore_html
|
|
17
|
+
from abkit.tuning.payload import build_explore_payload
|
|
18
|
+
from abkit.tuning.recompute import (
|
|
19
|
+
CalibrationStatus,
|
|
20
|
+
ExplorePoint,
|
|
21
|
+
KnobState,
|
|
22
|
+
PairRecompute,
|
|
23
|
+
RecomputeEngine,
|
|
24
|
+
RecomputeResult,
|
|
25
|
+
find_calibration,
|
|
26
|
+
resolve_fpr_budget,
|
|
27
|
+
)
|
|
28
|
+
from abkit.tuning.server import build_explore_server, serve_explore
|
|
29
|
+
from abkit.tuning.session import (
|
|
30
|
+
EXPLORE_CACHE_BUDGET,
|
|
31
|
+
ComparisonSeries,
|
|
32
|
+
ExploreSession,
|
|
33
|
+
backend_cutoff_loader,
|
|
34
|
+
load_session,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"EXPLORE_CACHE_BUDGET",
|
|
39
|
+
"AppliedConfig",
|
|
40
|
+
"CalibrationStatus",
|
|
41
|
+
"ComparisonSeries",
|
|
42
|
+
"ExplorePoint",
|
|
43
|
+
"ExploreSession",
|
|
44
|
+
"KnobState",
|
|
45
|
+
"OrphanedSeries",
|
|
46
|
+
"PairRecompute",
|
|
47
|
+
"RecomputeEngine",
|
|
48
|
+
"RecomputeResult",
|
|
49
|
+
"TunedComparison",
|
|
50
|
+
"apply_tuned_config",
|
|
51
|
+
"backend_cutoff_loader",
|
|
52
|
+
"build_explore_payload",
|
|
53
|
+
"build_explore_server",
|
|
54
|
+
"find_calibration",
|
|
55
|
+
"load_session",
|
|
56
|
+
"render_explore_html",
|
|
57
|
+
"resolve_fpr_budget",
|
|
58
|
+
"serve_explore",
|
|
59
|
+
]
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";(()=>{var xt={"--abk-page":"#f9f9f7","--abk-card":"#fcfcfb","--abk-ink":"#0b0b0b","--abk-ink-2":"#52514e","--abk-muted":"#898781","--abk-border":"#e1e0d9","--abk-chart-bg":"#1a1a19","--abk-chart-border":"#2c2c2a","--abk-chart-ink":"#c3c2b7","--abk-chart-grid":"#898781","--abk-series-1":"#3987e5","--abk-series-2":"#199e70","--abk-st-good":"#0ca30c","--abk-st-warn":"#fab219","--abk-st-serious":"#ec835a","--abk-st-critical":"#d03b3b","--abk-good-text":"#006300","--abk-explore-accent":"#2e7d5b"};function se(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()||xt[e]||"#888"}function hn(e){let i=e.replace("#","").trim();i.length===3&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]);let s=parseInt(i,16);return i.length!==6||Number.isNaN(s)?[137,135,129]:[s>>16&255,s>>8&255,s&255]}function ue(e,i){let[s,c,o]=hn(e);return`rgba(${s},${c},${o},${i})`}function Kt(e){let i=Math.max(1,window.devicePixelRatio||1),s=e.clientWidth||e.offsetWidth||0,c=e.clientHeight||e.offsetHeight||0;return e.width=Math.round(s*i),e.height=Math.round(c*i),i}function Xt(e,i,s,c){let o=()=>e.width-(i.l+i.r)*c,k=()=>e.height-(i.t+i.b)*c,h=()=>s.xmax-s.xmin||1,v=()=>s.vmax-s.vmin||1;return{px:R=>i.l*c+(R-s.xmin)/h()*o(),py:R=>e.height-i.b*c-(R-s.vmin)/v()*k(),xAt:R=>s.xmin+(R-i.l*c)/(o()||1)*h(),plotW:o,plotH:k}}function Ue(e,i,s){return{left:i.l*s,top:i.t*s,right:e.width-i.r*s,bottom:e.height-i.b*s}}var qe=Number.isFinite;function ot(e,i,s,c,o,k,h,v,x,$,d,R,w){let P=i.length,_=Math.max(1,Math.round(h)),L=o-c||1,H=0;for(let E=0;E<P;E++){let z=s[E];!qe(z)||i[E]<c||i[E]>o||H++}e.strokeStyle=$,e.lineWidth=d*R,e.lineJoin="round",w&&e.setLineDash(w.map(E=>E*R)),e.beginPath();let J=[];if(H<=_){let E=D=>D>=0&&D<P&&qe(s[D])&&i[D]>=c&&i[D]<=o,z=!1;for(let D=0;D<P;D++){if(!E(D)){z=!1;continue}let I=v(i[D]),j=x(s[D]);if(!E(D-1)&&!E(D+1)){J.push([I,j]),z=!1;continue}z?e.lineTo(I,j):(e.moveTo(I,j),z=!0)}}else{let E=new Array(_).fill(null),z=new Array(_).fill(null);for(let I=0;I<P;I++){let j=s[I],V=i[I];if(!qe(j)||V<c||V>o)continue;let q=Math.floor((V-c)/L*(_-1));q=q<0?0:q>_-1?_-1:q,(E[q]===null||j<E[q])&&(E[q]=j),(z[q]===null||j>z[q])&&(z[q]=j)}let D=!1;for(let I=0;I<_;I++){if(z[I]===null){D=!1;continue}let j=k+I,V=x(z[I]),q=x(E[I]);D?e.lineTo(j,V):(e.moveTo(j,V),D=!0),e.lineTo(j,q)}}if(e.stroke(),w&&e.setLineDash([]),J.length>0){e.fillStyle=$,e.beginPath();for(let[E,z]of J)e.moveTo(E+Math.max(1.5,d)*R,z),e.arc(E,z,Math.max(1.5,d)*R,0,Math.PI*2);e.fill()}}function Ge(e){let i=[],s=-1;for(let c=0;c<e.length;c++){let o=e[c];o.lo!==null&&o.hi!==null&&qe(o.lo)&&qe(o.hi)?s===-1&&(s=c):s!==-1&&(i.push([s,c-1]),s=-1)}return s!==-1&&i.push([s,e.length-1]),i}function Ee(e,i,s,c,o,k,h,v,x,$){e.fillStyle=ue(k,h);for(let[d,R]of s)if(d!==R){e.beginPath(),e.moveTo(c(i[d].x),o(i[d].hi));for(let w=d+1;w<=R;w++)e.lineTo(c(i[w].x),o(i[w].hi));for(let w=R;w>=d;w--)e.lineTo(c(i[w].x),o(i[w].lo));e.closePath(),e.fill()}e.strokeStyle=ue(k,v),e.lineWidth=1*x,$&&e.setLineDash($.map(d=>d*x));for(let[d,R]of s){if(d===R){let w=c(i[d].x),P=o(i[d].hi),_=o(i[d].lo),L=3*x;e.beginPath(),e.moveTo(w,P),e.lineTo(w,_),e.moveTo(w-L,P),e.lineTo(w+L,P),e.moveTo(w-L,_),e.lineTo(w+L,_),e.stroke();continue}for(let w of["hi","lo"]){e.beginPath();for(let P=d;P<=R;P++){let _=c(i[P].x),L=o(i[P][w]);P===d?e.moveTo(_,L):e.lineTo(_,L)}e.stroke()}}$&&e.setLineDash([])}function Vt(e,i,s,c,o,k,h,v,x,$,d,R){e.font=`${11*d}px ui-monospace, Menlo, Consolas, monospace`,e.textBaseline="middle";for(let P=0;P<=4;P++){let _=c.vmin+(c.vmax-c.vmin)*P/4,L=k(_);e.strokeStyle=ue(x,.1),e.lineWidth=1*d,e.beginPath(),e.moveTo(s.l*d,L),e.lineTo(i.width-s.r*d,L),e.stroke(),e.fillStyle=$,e.textAlign="right",e.fillText(le(_),(s.l-8)*d,L)}e.textBaseline="top";let w=v-h||1;for(let P=0;P<=5;P++){let _=h+w*P/5,L=o(_);e.fillStyle=$,e.textAlign=P===0?"left":P===5?"right":"center",e.fillText(R(_,w),L,i.height-(s.b-7)*d)}}function qt(e,i,s,c,o,k,h,v,x){let $=o(k),d=Ue(i,s,c);$<d.top-.5||$>d.bottom+.5||(e.strokeStyle=h,e.lineWidth=1.25*c,x&&e.setLineDash(x.map(R=>R*c)),e.beginPath(),e.moveTo(d.left,$),e.lineTo(d.right,$),e.stroke(),x&&e.setLineDash([]),v&&(e.fillStyle=h,e.textAlign="right",e.textBaseline="middle",e.font=`${10*c}px ui-monospace, Menlo, Consolas, monospace`,e.fillText(v,(s.l-8)*c,$)))}function Ut(e,i,s,c,o,k,h,v){let x=Ue(i,s,c),$=o(k);if($<x.left-1||$>x.right+1)return;e.save(),e.strokeStyle=ue(h,.7),e.lineWidth=1*c,e.setLineDash([4*c,4*c]),e.beginPath(),e.moveTo($,x.top),e.lineTo($,x.bottom),e.stroke(),e.setLineDash([]),e.fillStyle=ue(h,.95),e.font=`${10*c}px ui-monospace, Menlo, Consolas, monospace`;let d=$+6*c+e.measureText(v).width<=x.right;e.textAlign=d?"left":"right",e.textBaseline="top",e.fillText(v,d?$+6*c:$-6*c,x.top+5*c),e.restore()}function wt(e,i,s,c,o,k,h,v,x){let $=Ue(i,s,c),d=Math.max($.left,Math.min(o(k),$.right)),R=Math.max($.left,Math.min(o(h),$.right));R<=d&&R<$.left||(e.fillStyle=ue(v,x),e.fillRect(d,$.top,Math.max(R-d,1*c),$.bottom-$.top))}function le(e){let i=Math.abs(e);return i>=1e3?e.toFixed(0):i>=10?e.toFixed(1):i>=1?e.toFixed(2):i>=.001||i===0?e.toFixed(3):e.toExponential(1)}function Ne(e){return(e>0?"+":"")+le(e)}function Be(e){return e<.001?"<0.001":e.toFixed(3)}function Gt(e,i){if(i<=2)return`${Math.round(e*24)}h`;let s=Math.round(e*10)/10;return`${Number.isInteger(s)?s.toFixed(0):s.toFixed(1)}d`}function yt(e){return new Date(e).toISOString().slice(0,16).replace("T"," ")}function at(e){return new Date(e).toISOString().slice(0,10)}var r="abk-explore",ie={l:56,r:16,t:14,b:28},Qt=864e5,kn=130,X=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),rt=(e,i,s)=>Math.max(i,Math.min(s,e));function b(e,i,s){let c=document.createElement(e);return i&&(c.className=i),s!==void 0&&(c.textContent=s),c}var Yt=e=>e===null?NaN:e,gn=(e,i=le)=>e===null?"\u2014":i(e);function vn(e){return e%86400===0?e/86400+"d":e%3600===0?e/3600+"h":e%60===0?e/60+"min":e+"s"}var Ct=e=>Number(e.toPrecision(4)).toString();function xn(e,i,s,c,o){if(i!=="bonferroni")return e;let k=s*(s-1)/2;return k<=0?e:o||c===0?e/k:e/(k*c)}function lt(e,i,s){let c=b("div","abk-ctl-label"),o=b("span",void 0,e);i&&(o.title=i,o.appendChild(b("span","abk-hint"," \u24D8"))),c.appendChild(o);for(let k of s||[]){let h=b("span",`abk-knob-badge ${k.cls}`,k.text);h.title=k.hint,c.appendChild(h)}return c}function Ye(e,i,s,c,o,k){let h=b("div","abk-ctl");h.appendChild(lt(e,o,k));let v=b("div","abk-seg"),x=s,$=[],d=()=>{for(let R of $)R.classList.toggle("on",R.dataset.v===x)};for(let R of i){let w=document.createElement("button");w.type="button",w.className="abk-seg-btn",w.textContent=R.label,w.dataset.v=R.value,w.onclick=()=>{x!==R.value&&(x=R.value,d(),c(x))},$.push(w),v.appendChild(w)}return d(),h.appendChild(v),{row:h,get:()=>x,set:R=>{x=R,d()}}}function wn(e,i,s){let c=i.fmt||(x=>String(x)),o=b("div","abk-ctl"),k=b("div","abk-ctl-head");k.appendChild(lt(e,i.hint,i.badges));let h=b("span","abk-ctl-val",c(i.value));k.appendChild(h),o.appendChild(k);let v=document.createElement("input");return v.type="range",v.className="abk-range",v.min=String(i.min),v.max=String(i.max),v.step=String(i.step),v.value=String(i.value),v.oninput=()=>{h.textContent=c(Number(v.value))},v.onchange=()=>{h.textContent=c(Number(v.value)),s(Number(v.value))},o.appendChild(v),{row:o,get:()=>Number(v.value),set:x=>{v.value=String(x),h.textContent=c(x)},setMax:x=>{v.max=String(x),Number(v.value)>x&&(v.value=String(x),h.textContent=c(x))}}}function Zt(e,i,s){let c=b("div","abk-ctl");c.appendChild(lt(e,i.hint,i.badges));let o=document.createElement("input");o.type="number",o.className="abk-num",i.min!==void 0&&(o.min=String(i.min)),i.max!==void 0&&(o.max=String(i.max)),o.step=i.step!==void 0?String(i.step):"any",o.value=String(i.value);let k=i.value;return o.onchange=()=>{let h=Number(o.value);if(o.value.trim()===""||!Number.isFinite(h)||i.min!==void 0&&h<i.min||i.max!==void 0&&h>i.max){o.value=String(k);return}k=h,s(h)},c.appendChild(o),{row:c,get:()=>k,set:h=>{k=h,o.value=String(h)}}}function yn(e,i,s){let c=b("div","abk-ctl");c.appendChild(lt(e,i.hint,i.badges));let o=document.createElement("input");return o.type="text",o.className="abk-text",i.placeholder&&(o.placeholder=i.placeholder),o.value=i.value,o.onchange=()=>s(o.value.trim()),c.appendChild(o),{row:c,get:()=>o.value.trim(),set:k=>{o.value=k}}}function st(e,i,s,c,o){let k=b("div","abk-ctl abk-ctl-check"),h=document.createElement("label");h.className="abk-check";let v=document.createElement("input");v.type="checkbox",v.checked=i,v.onchange=()=>s(v.checked),h.appendChild(v);let x=b("span",void 0,e);c&&(x.title=c,x.appendChild(b("span","abk-hint"," \u24D8"))),h.appendChild(x);for(let $ of o||[]){let d=b("span",`abk-knob-badge ${$.cls}`,$.text);d.title=$.hint,h.appendChild(d)}return k.appendChild(h),{row:k,get:()=>v.checked,set:$=>{v.checked=$}}}function Cn(e,i){let s=[];return e.identity&&s.push({cls:"abk-badge-identity",text:"\u26A0 series",hint:"identity-bearing: a different value is a different method_config_id \u2014 Apply starts a NEW results series and orphans the persisted one"}),i==="R"&&s.push({cls:"abk-badge-reload",text:"\u21BB reload",hint:"Tier R: changing this re-renders the cached cutoffs from the warehouse (a confirm step, then POST /reload)"}),s}function $n(e,i,s,c){var x,$,d,R;let o=Cn(e,i),k=e.description;if(e.choices!==null){let w=e.choices.map(L=>({label:L,value:L})),P=s!=null?String(s):String((x=e.default)!=null?x:""),_=Ye(e.name,w,P,()=>c(),k,o);return{spec:e,row:_.row,get:()=>_.get(),set:L=>{var H;return _.set(L==null?String((H=e.default)!=null?H:""):String(L))}}}if(e.type==="bool"){let w=s!=null?!!s:!!e.default,P=st(e.name,w,()=>c(),k,o);return{spec:e,row:P.row,get:()=>P.get(),set:_=>P.set(_==null?!!e.default:!!_)}}if(e.type==="int"){let w=typeof s=="number"?Math.round(s):Number(($=e.default)!=null?$:1),P=Math.min(e.minimum!==null?e.minimum:1,w),_=e.maximum!==null?Math.max(e.maximum,w):Math.max(w*4,Number((d=e.default)!=null?d:0)*4,4e3),L=wn(e.name,{min:P,max:_,step:1,value:w,hint:k,badges:o},()=>c());return{spec:e,row:L.row,get:()=>L.get(),set:H=>{var E;let J=typeof H=="number"?Math.round(H):Number((E=e.default)!=null?E:P);L.setMax(Math.max(_,J)),L.set(J)}}}if(e.type==="float"){let w=typeof s=="number"?s:Number((R=e.default)!=null?R:0),P=e.exclusive_bounds?1e-9:0,_=Zt(e.name,{value:w,min:e.minimum!==null?e.minimum+P:void 0,max:e.maximum!==null?e.maximum-P:void 0,hint:k,badges:o},()=>c());return{spec:e,row:_.row,get:()=>_.get(),set:L=>{var H;return _.set(typeof L=="number"?L:Number((H=e.default)!=null?H:0))}}}let h=s==null?"":String(s),v=yn(e.name,{value:h,placeholder:e.default===null?"unset":String(e.default),hint:k,badges:o},()=>c());return{spec:e,row:v.row,get:()=>{let w=v.get();if(w!=="")return e.type.includes("int")&&/^-?\d+$/.test(w)?parseInt(w,10):w},set:w=>v.set(w==null?"":String(w))}}var $t=null;function Sn(e,i){Tn(),$t&&$t();let s=[];$t=()=>{for(let t of s)t();s.length=0},i.classList.add(r),i.innerHTML="";let c=b("div","abk-root");i.appendChild(c);let o=e.recompute_url!==null,k=e.save_url!==null,h=e.explore.metrics,v=e.explore.experiment,x=new Map;for(let t of e.metrics)x.has(t.name)||x.set(t.name,t);let $=[...x.keys()].filter(t=>t in h),d=e.explore.default_metric!==null&&$.includes(e.explore.default_metric)?e.explore.default_metric:$[0]||null,R=0,w=new Map,P=new Map;for(let t of $){let n=x.get(t);w.set(t,{main:n.main,guardrail:n.guardrail}),P.set(t,n.main)}let _=new Set,L=v.alpha,H=v.correction,J=!1,E=!1,z=new Map,D=new Set,I=new Map,j=new Map,V=new Set,q=()=>{let t=v.non_main_count;for(let[n,l]of w){let m=P.get(n)?0:1;t+=(l.main?0:1)-m}return Math.max(0,t)},oe=t=>{var n,l;return xn(L,H,v.groups_count,q(),(l=(n=w.get(t))==null?void 0:n.main)!=null?l:!1)},$e=t=>{let n=h[t];return{method:n.configured.method,params:{...n.configured.params}}};c.appendChild(Mn(e,o));let Se=[...e.warnings,...e.explore.warnings,...e.explore.cache.disabled_reason!==null?[e.explore.cache.disabled_reason]:[]];if(Se.length>0){let t=b("div","abk-warnings");for(let n of Se)t.appendChild(b("div","abk-warning",`\u26A0 ${n}`));c.appendChild(t)}if(d===null){c.appendChild(b("div","abk-empty","No comparisons to explore \u2014 run `abk run` first, then reopen."));return}let ze=b("div","abk-cockpit");c.appendChild(ze);let he=b("div","abk-stage");ze.appendChild(he);let Z=b("div","abk-hud"),W=b("div","abk-hud-chips"),Me=b("div","abk-modes");Z.appendChild(W),Z.appendChild(Me),he.appendChild(Z);let ke=b("div","abk-legend");he.appendChild(ke);let ee=b("div","abk-chart abk-chart-main"),Y=b("div","abk-spin","computing\u2026");ee.appendChild(Y),he.appendChild(ee);let U=b("div","abk-stagefoot"),Q=b("div","abk-readout","hover for a cutoff readout \xB7 scroll to zoom \xB7 drag to pan \xB7 double-click to reset"),N=b("div","abk-stat"),ae=b("div","abk-warnbar");ae.style.display="none",U.appendChild(Q),U.appendChild(ae),U.appendChild(N),he.appendChild(U);let de=b("div","abk-rail");ze.appendChild(de);let De=b("div","abk-railhead"),Je=b("div","abk-railtitle","Tune");De.appendChild(Je),de.appendChild(De);let pe=b("div","abk-controls");de.appendChild(pe);let Te=b("div","abk-rail-group"),ge=b("div","abk-rail-group"),te=b("div","abk-rail-group");pe.appendChild(Te),pe.appendChild(ge),pe.appendChild(te);let re=b("div","abk-railfoot");de.appendChild(re);let ve=Re("lift"),He=Re("\xB1CI"),Ie=Re("p"),xe=Re("power"),be=b("span","abk-chip abk-tier");be.style.display="none";let we=b("span","abk-chip abk-identity","\u26A0 different results series");we.title="the live knob state has a different method_config_id than the persisted series \u2014 Apply will start a new series and orphan the old rows",we.style.display="none";let O=b("span","abk-chip abk-calibration");W.appendChild(ve.chip),W.appendChild(He.chip),W.appendChild(Ie.chip),W.appendChild(xe.chip),W.appendChild(be),W.appendChild(we),W.appendChild(O),W.appendChild(Rn(e)),e.look!==null&&e.cadence_seconds<86400&&W.appendChild(b("span","abk-chip abk-look",`look ${e.look.n} / ~${e.look.planned} planned`));function Re(t){let n=b("span","abk-chip abk-live-chip");n.appendChild(b("span","abk-chip-l",t));let l=b("span","abk-chip-v","\u2014");return n.appendChild(l),{chip:n,set:m=>{l.textContent=m}}}function Ae(t){O.className="abk-chip abk-calibration",O.textContent=t.headline||t.state,t.state==="calibrated"&&t.over_budget?(O.classList.add("abk-cal-over"),O.setAttribute("data-abk-calibration","over-budget")):t.state==="calibrated"?(O.classList.add("abk-cal-ok"),O.setAttribute("data-abk-calibration","calibrated")):t.state==="alpha_mismatch"?(O.classList.add("abk-cal-mismatch"),O.setAttribute("data-abk-calibration","alpha-mismatch")):O.setAttribute("data-abk-calibration","uncalibrated")}(function(){let n=(l,m,S)=>{let M=b("span","abk-legend-item");M.appendChild(b("span",`abk-swatch ${l}`));let g=b("span",void 0,m);g.title=S,M.appendChild(g),ke.appendChild(M)};n("abk-sw-live","live effect \xB1 CI","the current knob state, recomputed server-side"),n("abk-sw-baseline","persisted baseline","what actually ran (_ab_results) \u2014 always visible"),n("abk-sw-approx","approx (\u03B1-only)","hatched: \u03B1-inverted from the stored CI, not recomputed"),n("abk-sw-prehorizon","pre-horizon (dashed)","fixed CIs before the planned horizon are not peeking-valid (\xA74)"),n("abk-sw-insufficient","insufficient data","greyed cutoffs: counts + SRM only, no inference")})();let a=null;function u(){var M,g;let t=x.get(d),n=t.pairs[R]||t.pairs[0];if(a==null||a.dispose(),(M=ee.querySelector("canvas"))==null||M.remove(),(g=ee.querySelector(".abk-chart-fallback"))==null||g.remove(),a=null,!n||n.series.length===0){ee.appendChild(b("div","abk-chart-fallback","no persisted cutoffs for this pair yet \u2014 run `abk run` first"));return}let l=document.createElement("canvas");ee.insertBefore(l,Y);let m=_n(l,n,e,F=>{Q.innerHTML=F});if(m===null){l.remove(),ee.appendChild(b("div","abk-chart-fallback","chart unavailable (no canvas 2D context)"));return}a=m,a.resize();let S=I.get(d);S&&a.setLive(f(S,n))}function f(t,n){let l=t.pairs.find(m=>m.name_1===n.c&&m.name_2===n.t);return l?l.points:null}let p=b("div","abk-notes");he.insertBefore(p,ee);function T(){p.textContent="",p.removeAttribute("data-abk-prehorizon");let t=x.get(d),n=t.pairs[R]||t.pairs[0];if(!n||n.series.length===0)return;let l=n.series,m=l[l.length-1],S=(e.period.horizon-e.period.start)/Qt;m.hz===0&&(p.setAttribute("data-abk-prehorizon","1"),p.appendChild(b("div","abk-note abk-prehorizon",`pre-horizon \u2014 fixed CIs are dashed/de-emphasized and not peeking-valid; planned horizon ${at(e.period.horizon)} (${le(S)}d)`)));let M=l.reduce((g,F)=>g+F.ins,0);M>0&&p.appendChild(b("div","abk-note abk-insufficient",`${M} insufficient-data cutoff${M===1?"":"s"} greyed \u2014 counts + SRM only`))}let C=Date.now(),A=null,y=0,B=(t,n="info")=>{N.textContent=t,N.classList.toggle("abk-stat-err",n==="err")};function Qe(){y&&window.clearTimeout(y),y=window.setTimeout(Ze,kn)}function Ze(){if(y&&(window.clearTimeout(y),y=0),!o||d===null)return;let t=fe();z.set(d,t),St(e.recompute_url,t,"recompute")}function St(t,n,l){let m=d;C+=1;let S=C;A==null||A.abort(),A=new AbortController,Y.classList.add("on");let M=JSON.stringify({metric:m,method:{name:n.method,params:mt(n.method,n.params)},alpha:oe(m),request_id:S});fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:M,signal:A.signal}).then(g=>{if(S===C){if(g.status===409){C=Math.max(C,Date.now()),Y.classList.remove("on"),B("another explore tab is ahead \u2014 turn a knob to retake this one");return}return g.ok?g.json().then(F=>{S===C&&(Y.classList.remove("on"),dt(F,n,l))}):g.text().then(F=>{throw new Error(F||`HTTP ${g.status}`)})}}).catch(g=>{g.name==="AbortError"||S!==C||(Y.classList.remove("on"),B(`${l} failed: ${g.message}`,"err"))})}function dt(t,n,l){var Wt;if(I.set(t.metric,t),j.set(t.metric,n),l==="reload"){Ce.delete(t.metric),t.metric===d&&(ye.style.display="none");let G=(Wt=h[t.metric])==null?void 0:Wt.methods.find(vt=>vt.name===t.method);G!=null&&G.needs_covariate&&V.add(t.metric)}if(t.metric!==d)return;let m=x.get(t.metric),S=m.pairs[R]||m.pairs[0],M=S?t.pairs.find(G=>G.name_1===S.c&&G.name_2===S.t):void 0,g=M?M.chips:null;ve.set(g===null||g.lift===null?"\u2014":Ne(g.lift)),He.set(g===null||g.ci_half===null?"\u2014":`\xB1${le(g.ci_half)}`),Ie.set(g===null||g.pvalue===null?"\u2014":Be(g.pvalue)),g!==null&&g.power!==null?(xe.set(`${(g.power*100).toFixed(0)}%`),xe.chip.title="achieved power to detect min_effect at the current knob state"):(xe.set("\u2014"),xe.chip.title=g&&g.power_note||"power unavailable"),g!==null&&g.tier!==null?(be.style.display="",be.textContent=`tier: ${g.tier}`,be.title=g.tier==="approx"?"the latest chip source point is \u03B1-inverted (approx), not recomputed":g.tier==="baseline"?"the latest chip source point is the persisted row passed through":"the latest chip source point was recomputed exactly"):be.style.display="none",we.style.display=t.identity_changed?"":"none",Ae(t.calibration),a&&M?a.setLive(M.points):a&&a.setLive(null);let F=S?S.series.length:0,me=M?M.points:[],gt={exact:0,approx:0,baseline:0};for(let G of me)gt[G.tier]+=1;let mn=["exact","approx","baseline"].filter(G=>gt[G]>0).map(G=>`${gt[G]} ${G}`).join(" \xB7 "),Ft=`${me.length}/${F} cutoffs at this knob state (${mn||"none"})`;t.identity_changed&&me.length<F&&(Ft+=" \u2014 gaps need a Tier-R reload or are not reconstructable"),B(Ft);let jt=new Set;for(let G of me)for(let vt of G.warnings)jt.add(vt);let Ot=[...t.warnings,...jt];ae.textContent="",ae.style.display=Ot.length>0?"":"none";for(let G of Ot)ae.appendChild(b("div","abk-warning",`\u26A0 ${G}`));Ve.textContent=en(t,n)}function en(t,n){let l=JSON.stringify(mt(n.method,n.params));return`// ${t.metric}: method=${t.method} params=${l} \u03B1=${Ct(t.alpha)} (effective; raw ${Ct(L)}, ${H}) id=${t.method_config_id.slice(0,12)}\u2026`}let et=null,ct=null,ut=[],Le=b("div"),tt=document.createElement("details");tt.className="abk-advanced",tt.appendChild(b("summary",void 0,"advanced knobs"));let Pe=b("div");tt.appendChild(Pe);let tn=new Set(["test_type"]);function _e(){return h[d]}function Fe(t){return _e().methods.find(n=>n.name===t)}function nn(t){let n=t.startsWith("cuped-")?t.slice(6):`cuped-${t}`;return Fe(n)!==void 0?n:null}function on(t,n,l){if(l&&l.method===n&&t.name in l.params)return l.params[t.name];let m=_e().configured;return m.method===n&&t.name in m.params?m.params[t.name]:t.default}function je(){Le.textContent="",Pe.textContent="",ut=[];let t=_e(),n=z.get(d),l=n?n.method:t.configured.method,m=Fe(l),S=t.methods.map(g=>({label:g.needs_covariate&&t.cache.covariate_cutoffs.length===0&&!V.has(d)?`${g.name} \u21BB`:g.name,value:g.name}));et=Ye("method",S,l,g=>Tt(g),"statistical method for this comparison \u2014 the full list valid for this metric type",m?[{cls:"abk-badge-identity",text:"\u26A0 series",hint:"switching methods changes method_config_id \u2014 a new results series"}]:[]),Le.appendChild(et.row);let M=nn(l);if(M!==null?(ct=st("CUPED",l.startsWith("cuped-"),g=>{let F=g?l.startsWith("cuped-")?l:M:l.startsWith("cuped-")?M:l;Tt(F)},"variance reduction via a pre-period covariate (switches to the cuped- method variant)",[{cls:"abk-badge-identity",text:"\u26A0 series",hint:"CUPED on/off changes method_config_id \u2014 a new results series"}]),Le.appendChild(ct.row)):ct=null,!!m){for(let g of m.params){if(!g.identity)continue;let F=m.tiers[g.name],me=$n(g,F,on(g,l,n),()=>ht());ut.push(me),(tn.has(g.name)?Le:Pe).appendChild(me.row)}Le.appendChild(an.row),Pe.appendChild(rn.row),Pe.appendChild(Mt),Pe.appendChild(b("div","abk-ctl-note","analysis unit \u2014 configured in the metric YAML (preview-only; not tunable here)")),Oe()}}let an=Zt("alpha (experiment)",{value:L,min:1e-9,max:1-1e-9,step:.001,hint:"raw experiment-level significance level; the correction resolves it to the effective per-comparison \u03B1 sent to /recompute. Identity-excluded (never enters method_config_id) but it re-keys the A/A calibration chip."},t=>{L=t,J=!0,Oe(),ht()}),rn=Ye("correction (experiment)",v.correction_choices.map(t=>({label:t==="benjamini_hochberg"?"BH":t,value:t})),H,t=>{H=t,E=!0,Oe(),ht()},"multiple-testing correction. bonferroni = the two-tier compute-time scheme; benjamini_hochberg is applied read-time (explore shows uncorrected per-comparison inference)"),Mt=b("div","abk-ctl-note");function Oe(){if(d===null)return;let t=oe(d),n=`effective \u03B1 for ${d}: ${Ct(t)}`;H==="bonferroni"&&(n+=" (two-tier bonferroni)"),H==="benjamini_hochberg"&&(n+=" (BH is read-time \u2014 raw \u03B1 at compute time)"),Mt.textContent=n}let ye=b("div","abk-reloadbar");ye.style.display="none";let Rt=b("div","abk-reloadbar-text"),pt=b("div","abk-reloadbar-btns"),We=document.createElement("button");We.type="button",We.className="abk-btn abk-btn-reload",We.textContent="\u21BB Reload cutoffs";let Ke=document.createElement("button");Ke.type="button",Ke.className="abk-btn abk-btn-ghost",Ke.textContent="Revert",pt.appendChild(We),pt.appendChild(Ke),ye.appendChild(Rt),ye.appendChild(pt);let Ce=new Map;function bt(t){Ce.set(d,t),Rt.textContent=t,ye.style.display=""}function ft(t){Ce.delete(t!=null?t:d),ye.style.display="none"}We.onclick=()=>{if(e.reload_url===null){B("reload is unavailable in this session (static preview / no warehouse)","err");return}if(d===null)return;let t=fe();z.set(d,t),St(e.reload_url,t,"reload")},Ke.onclick=()=>{if(d===null)return;let t=j.get(d)||$e(d);z.set(d,t),je(),ft(),Qe()};function _t(t,n=!1){let l=Fe(t.method);if(!l)return!1;let m=_e();if(n&&l.needs_covariate&&m.cache.covariate_cutoffs.length===0&&!V.has(d))return!0;let S=j.get(d)||$e(d),M=S.method===t.method?S.params:{};for(let[g,F]of Object.entries(l.tiers))if(F==="R"&&t.params[g]!==M[g])return!0;return!1}function fe(){let t=et?et.get():_e().configured.method,n={};for(let l of ut){let m=l.get();m!==void 0&&(n[l.spec.name]=m)}return{method:t,params:n}}function mt(t,n){let l=Fe(t),m={};for(let[S,M]of Object.entries(n)){let g=l==null?void 0:l.params.find(F=>F.name===S);g&&M===g.default||(m[S]=M)}return m}function ht(){if(d===null)return;D.add(d),nt();let t=fe();if(z.set(d,t),_t(t)){y&&(window.clearTimeout(y),y=0);let n=_e().cache.cutoffs.length;bt(`this change re-renders ${n||"the"} cached cutoff${n===1?"":"s"} from the warehouse (Tier R). If the metric has no covariate column, set covariate_lookback first.`);return}Ce.has(d)&&ft(d),Qe()}function Tt(t){if(d===null)return;D.add(d),nt();let n=z.get(d),l=j.get(d);z.set(d,{method:t,params:n&&n.method===t?n.params:l&&l.method===t?{...l.params}:{}}),je();let m=fe();if(z.set(d,m),_t(m,!0)){y&&(window.clearTimeout(y),y=0);let S=Fe(t);bt(`'${t}' needs a per-unit covariate the session cache does not hold \u2014 a warehouse reload re-renders the cached cutoffs${S&&S.params.some(M=>M.name==="covariate_lookback")?" (set covariate_lookback for a pre-period covariate)":""}.`);return}Ce.has(d)&&ft(d),Qe()}function At(){if(Te.textContent="",$.length>1){let n=Ye("comparison",$.map(l=>({label:l,value:l})),d,l=>sn(l),"each comparison tunes independently; Apply writes every dirty one");Te.appendChild(n.row)}let t=x.get(d);if(t.pairs.length>1){let n=Ye("pair",t.pairs.map((l,m)=>({label:`${l.c} vs ${l.t}`,value:String(m)})),String(R),l=>{R=Number(l),T(),u();let m=I.get(d);m&&dt(m,j.get(d)||fe(),"recompute")},"view a different variant pair \u2014 recomputes cover all pairs at once");Te.appendChild(n.row)}}function sn(t){if(d===t||d===null)return;y&&(window.clearTimeout(y),y=0),z.set(d,fe()),A==null||A.abort(),A=null,Y.classList.remove("on"),d=t,R=0,ye.style.display="none",At(),je(),T(),u(),Lt(),Oe(),Pt();let n=Ce.get(t);n!==void 0&&bt(n);let l=I.get(t);if(l&&dt(l,j.get(t)||fe(),"recompute"),o&&n===void 0){let m=fe(),S=j.get(t);l!==void 0&&S!==void 0&&l.alpha===oe(t)&&JSON.stringify(m)===JSON.stringify(S)||Ze()}}function Lt(){Ae(_e().calibration),ve.set("\u2014"),He.set("\u2014"),Ie.set("\u2014"),xe.set("\u2014"),be.style.display="none",we.style.display="none"}function Pt(){te.textContent="",te.appendChild(b("div","abk-ctl-note","mark each comparison's role \u2014 flips ride into Apply and re-tier the bonferroni budget (all calibration re-keys conservatively)"));for(let t of $){let n=w.get(t),l=b("div","abk-review-row");l.appendChild(b("div","abk-review-name",t));let m=st("main",n.main,F=>{let me=d===null?null:oe(d);n.main=F,_.add(t),nt(),Oe(),d!==null&&oe(d)!==me&&Qe()},"is_main_metric \u2014 the main tier gets the undivided bonferroni budget"),S=st("guardrail",n.guardrail,F=>{n.guardrail=F,_.add(t),nt()},"is_guardrail \u2014 regressions surface in the verdict rationale"),M=b("div","abk-review-checks");M.appendChild(m.row),M.appendChild(S.row),l.appendChild(M);let g=e.verdicts.find(F=>F.metric===t);g&&l.appendChild(b("div",`abk-review-verdict abk-verdict-${g.verdict.toLowerCase()}`,`${g.verdict} (${g.pair.c} vs ${g.pair.t})`)),te.appendChild(l)}}let ln=[{v:"tune",label:"Tune",hint:"turn method knobs, watch the windshield"},{v:"review",label:"Review",hint:"mark guardrail vs primary before applying (D9)"},{v:"auto",label:"Auto",hint:"run a reduced A/A validation server-side and green the calibration chip (a fast estimate \u2014 `abk validate` for the full run)"},{v:"segment",label:"Segment",hint:"heterogeneous effects \u2014 deferred (D9, ROADMAP)",inert:!0}],dn={tune:"Tune",review:"Review \u2014 roles",auto:"Auto",segment:"Segment"},Xe="tune",Et=[];for(let t of ln){let n=document.createElement("button");n.type="button";let l=t.inert||t.v==="auto"&&e.validate_url===null;n.className="abk-mode-btn"+(l?" abk-mode-disabled":""),n.textContent=t.label,n.title=t.hint,n.dataset.v=t.v,n.onclick=()=>{if(!t.inert){if(t.v==="auto"){cn();return}Nt(t.v)}},Et.push(n),Me.appendChild(n)}function Nt(t){Xe=t;for(let n of Et)n.classList.toggle("on",n.dataset.v===Xe);ge.style.display=Xe==="tune"?"":"none",te.style.display=Xe==="review"?"":"none",Je.textContent=dn[Xe]}function cn(){if(e.validate_url===null){B("Auto mode needs a served session \u2014 run `abk explore` without --no-serve");return}y&&(window.clearTimeout(y),y=0),C+=1;let t=C;A==null||A.abort(),A=new AbortController,Y.classList.add("on"),B("Auto: running a reduced A/A validation (fast estimate \u2014 `abk validate` for the full run)\u2026"),fetch(e.validate_url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({request_id:t}),signal:A.signal}).then(n=>{if(t===C){if(n.status===409){C=Math.max(C,Date.now()),Y.classList.remove("on"),B("another explore tab is ahead \u2014 turn a knob to retake this one");return}return n.ok?n.json().then(l=>{t===C&&(Y.classList.remove("on"),un(l))}):n.text().then(l=>{throw new Error(l||`HTTP ${n.status}`)})}}).catch(n=>{n.name==="AbortError"||t!==C||(Y.classList.remove("on"),B(`Auto validate failed: ${n.message}`,"err"))})}function un(t){let n=t.recommended||{};for(let[M,g]of Object.entries(n))M in h&&(h[M].calibration=g.calibration);let l=d,m=l!==null?n[l]:void 0;l!==null&&m!==void 0&&(z.set(l,{method:m.method.name,params:{...m.method.params}}),je(),Ae(m.calibration),Ze());let S=Object.entries(n).map(([M,g])=>`${M}: ${g.calibration.headline}`);B(S.length>0?`Auto \u2014 ${S.join(" \xB7 ")}`:"Auto: no method could be calibrated on this data")}let kt=b("div","abk-cfg-toggle","\u25B8 effective config"),Ve=b("div","abk-cfg-echo");Ve.style.display="none",kt.onclick=()=>{let t=Ve.style.display==="none";Ve.style.display=t?"":"none",kt.textContent=(t?"\u25BE":"\u25B8")+" effective config"},re.appendChild(ye),re.appendChild(kt),re.appendChild(Ve);let ne=document.createElement("button");ne.type="button",ne.className="abk-btn abk-btn-apply",ne.textContent="Apply",ne.title="validate + archive the prior YAML to experiments/.history/ and write the dirty comparisons back. Viewing a comparison never writes it \u2014 only tuned ones.";let K=b("div","abk-apply-msg"),ce=b("div","abk-confirm");ce.style.display="none",k?(re.appendChild(ne),re.appendChild(ce),re.appendChild(K)):re.appendChild(b("div","abk-preview-note","static preview \u2014 Apply is disabled. Run `abk explore` without --no-serve to tune and apply."));function nt(){K.textContent!==""&&(K.textContent="",K.className="abk-apply-msg"),ce.style.display!=="none"&&(ce.style.display="none",ne.disabled=!1)}function Bt(){d!==null&&(y&&(window.clearTimeout(y),y=0),D.has(d)&&z.set(d,fe()));let t=pn();return t.comparisons.length===0&&t.alpha===void 0&&t.correction===void 0?(K.className="abk-apply-msg info",K.textContent="nothing to apply \u2014 no knob has been tuned",null):Ce.size>0?(K.className="abk-apply-msg err",K.textContent=`a Tier-R change is pending on ${[...Ce.keys()].join(", ")} \u2014 reload or revert it before applying`,null):t}function pn(){let t=[],n=new Set([...D,..._]);for(let m of $){if(!n.has(m))continue;let S={metric:m};if(D.has(m)){let M=z.get(m)||$e(m);S.method={name:M.method,params:mt(M.method,M.params)}}if(_.has(m)){let M=w.get(m);S.is_main_metric=M.main,S.is_guardrail=M.guardrail}t.push(S)}let l={comparisons:t};return J&&(l.alpha=L),E&&(l.correction=H),l}function bn(){var n,l;let t=new Set([...D,..._]);if(J||E||_.size>0)for(let m of $)t.add(m);for(let m of t){let S=(l=(n=I.get(m))==null?void 0:n.calibration)!=null?l:h[m].calibration;if(S.state!=="calibrated"||S.over_budget)return!1}return!0}function fn(){var l,m;let t=[],n=new Set([...D,..._]);for(let S of n){let M=(m=(l=I.get(S))==null?void 0:l.calibration)!=null?m:h[S].calibration;(M.state!=="calibrated"||M.over_budget)&&t.push(`${S}: ${M.headline}`)}return t}function zt(t){ce.textContent="",ce.style.display="",ce.appendChild(b("div","abk-confirm-text",t));let n=b("div","abk-confirm-btns"),l=document.createElement("button");l.type="button",l.className="abk-btn abk-btn-danger",l.textContent="Apply anyway",l.onclick=()=>{ce.style.display="none";let S=Bt();if(S===null){ne.disabled=!1;return}Dt({...S,confirm_uncalibrated:!0})};let m=document.createElement("button");m.type="button",m.className="abk-btn abk-btn-ghost",m.textContent="Cancel",m.onclick=()=>{ce.style.display="none",ne.disabled=!1},n.appendChild(l),n.appendChild(m),ce.appendChild(n)}ne.onclick=()=>{let t=Bt();if(t!==null){if(ne.disabled=!0,!bn()){let n=fn();zt("these params have never passed `abk validate` \u2014 the real FPR is unknown and the nominal \u03B1 may understate it."+(n.length>0?` (${n.join("; ")})`:""));return}Dt(t)}};function Dt(t){K.className="abk-apply-msg info",K.textContent="Applying\u2026",ne.disabled=!0,fetch(e.save_url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(n=>n.ok?n.json():n.text().then(l=>{if(n.status===409&&!t.confirm_uncalibrated&&/confirm_uncalibrated/.test(l))return zt(l),K.textContent="",K.className="abk-apply-msg",null;throw new Error(l||`HTTP ${n.status}`)})).then(n=>{if(n===null)return;K.className="abk-apply-msg ok",K.textContent="",K.appendChild(b("div",void 0,`Applied \u2192 ${n.saved} (previous archived: ${n.archived}).`));let l=[];n.updated.length>0&&l.push(`updated: ${n.updated.join(", ")}`),n.preserved.length>0&&l.push(`preserved: ${n.preserved.join(", ")}`),n.experiment_fields.length>0&&l.push(`experiment fields: ${n.experiment_fields.join(", ")}`),l.length>0&&K.appendChild(b("div",void 0,l.join(" \xB7 "))),n.orphan_warning!==null&&K.appendChild(b("div","abk-orphan",`\u26A0 ${n.orphan_warning}`)),K.appendChild(b("div",void 0,`re-run \`abk run --select ${e.experiment}\` \u2014 you can close this tab.`))}).catch(n=>{ne.disabled=!1,K.className="abk-apply-msg err",K.textContent=`Apply failed: ${n.message}`})}if(!o){pe.classList.add("abk-rail-off");let t=b("div","abk-preview-note","knobs are read-only in this static page \u2014 the recompute endpoint is not available");pe.insertBefore(t,pe.firstChild)}ge.appendChild(Le),ge.appendChild(tt),At(),je(),Pt(),Nt("tune"),T(),u(),Lt(),o?Ze():B("static preview \u2014 knob recompute needs the live `abk explore` server");let it=0,Ht=()=>{it&&cancelAnimationFrame(it),it=requestAnimationFrame(()=>{it=0,a==null||a.resize()})},It=()=>Ht();if(window.addEventListener("resize",It),s.push(()=>window.removeEventListener("resize",It)),s.push(()=>a==null?void 0:a.dispose()),typeof ResizeObserver!="undefined"){let t=new ResizeObserver(Ht);t.observe(ee),s.push(()=>t.disconnect())}}function Mn(e,i){let s=b("div","abk-header"),c=b("div","abk-h-top"),o=b("h1","abk-title");o.innerHTML=e.project?`${X(e.project)} \xB7 ${X(e.experiment)}`:X(e.experiment),c.appendChild(o),c.appendChild(b("span",`abk-badge-page ${i?"abk-badge-live":"abk-badge-preview"}`,i?"explore":"preview")),s.appendChild(c);let k=e.period.end>0?`latest cutoff ${yt(e.period.end)} UTC (whatever the last \`abk run\` produced)`:"no persisted cutoffs yet",h=`${at(e.period.start)} \u2013 horizon ${at(e.period.horizon)} (UTC) \xB7 cadence ${vn(e.cadence_seconds)} \xB7 tz ${X(e.tz)} \xB7 arms: ${e.arms.map(X).join(" vs ")} (first = control) \xB7 ${X(k)}`,v=b("div","abk-meta");return v.innerHTML=h,s.appendChild(v),e.description&&s.appendChild(b("p","abk-desc",e.description)),s}function Rn(e){let i=e.srm,s=e.arms.reduce((o,k)=>o+(i.observed[k]||0),0),c=b("span","abk-chip abk-srm");if(i.flag){let o=e.arms.map(v=>s>0?((i.observed[v]||0)/s).toFixed(2):"0.00").join("/"),k=e.arms.map(v=>{var x;return((x=i.expected[v])!=null?x:0).toFixed(2)}).join("/"),h=i.pvalue===null?"p=\u2014":`p${i.pvalue<.001?"<0.001":"="+Be(i.pvalue)}`;c.classList.add("abk-srm-fail"),c.textContent=`SRM FAILED (observed ${o} vs expected ${k}, \u03C7\xB2 ${h}) \u2014 effects untrustworthy`,c.setAttribute("data-abk-srm","fail")}else s===0?(c.textContent="SRM \u2014 no exposure data",c.setAttribute("data-abk-srm","na")):(c.textContent=`SRM ok (p=${gn(i.pvalue,Be)})`,c.classList.add("abk-srm-ok"),c.setAttribute("data-abk-srm","ok"));return c}function _n(e,i,s,c){let o=e.getContext("2d");if(!o)return null;let k=[...i.series].sort((a,u)=>a.t-u.t),h=k.map(a=>a.ed===null?NaN:a.ed),v=k.map(a=>Yt(a.e)),x=(s.period.horizon-s.period.start)/Qt,$=a=>a.hz===1&&a.t>=s.period.horizon,d=k.findIndex($),R=d!==-1&&k[d].ed!==null?k[d]:void 0,w=R!==void 0?R.ed:x,P=d!==-1?k[d].t:null,_=a=>P===null?!0:a<P,L=[],H=[];k.forEach((a,u)=>{if(Number.isNaN(h[u]))return;let f={x:h[u],lo:a.lo,hi:a.hi};d===-1||u<d?L.push(f):H.push(f)}),d!==-1&&L.length>0&&H.length>0&&H.unshift(L[L.length-1]);let J=h.filter(a=>!Number.isNaN(a)),E=[];for(let a=1;a<J.length;a++)E.push(J[a]-J[a-1]);E.sort((a,u)=>a-u);let z=E.length>0?E[Math.floor(E.length/2)]:s.cadence_seconds/86400,D=a=>{let u=[];return k.forEach((f,p)=>{if(!a(f)||Number.isNaN(h[p]))return;let T=h[p]-z/2,C=h[p]+z/2,A=u[u.length-1];A&&T<=A[1]?A[1]=C:u.push([T,C])}),u},I=D(a=>a.ins===1),j=D(a=>a.blk===1&&a.ins===0),V=null,q=[],oe=[],$e=[],Se=k.filter(a=>a.ed!==null).map(a=>a.t);function ze(a,u){let f=0,p=Se.length-1;for(;f<=p;){let T=f+p>>1;Se[T]<=a?f=T+1:p=T-1}return f<Se.length&&Se[f]<u}function he(){if(q=[],oe=[],$e=[],V===null)return;let a=[...V].sort((p,T)=>p.end_ts-T.end_ts);oe=a.map(p=>p.elapsed_days===null?NaN:p.elapsed_days),$e=a.map(p=>Yt(p.effect));let u=null,f=null;a.forEach((p,T)=>{if(Number.isNaN(oe[T])){u=null;return}u!==null&&f!==null&&ze(f,p.end_ts)&&(u=null),f=p.end_ts;let C=p.tier==="approx",A=_(p.end_ts),y={x:oe[T],lo:p.left_bound,hi:p.right_bound};if(u===null||u.approx!==C||u.pre!==A){let B=u;u={approx:C,pre:A,band:[],xs:[],es:[]},B!==null&&B.band.length>0&&(u.band.push(B.band[B.band.length-1]),u.xs.push(B.xs[B.xs.length-1]),u.es.push(B.es[B.es.length-1])),q.push(u)}u.band.push(y),u.xs.push(oe[T]),u.es.push($e[T])})}let Z=0,W=Math.max(w,x,...J,1),Me=W-Z||1,ke=Math.min(Math.max(s.cadence_seconds/86400,Me/200),Me),ee=0,Y=1;(function(){let u=1/0,f=-1/0,p=C=>{C!==null&&Number.isFinite(C)&&(C<u&&(u=C),C>f&&(f=C))};for(let C of k)p(C.e),p(C.lo),p(C.hi);(!Number.isFinite(u)||!Number.isFinite(f))&&(u=-1,f=1),u>0&&(u=0),f<0&&(f=0),f<=u&&(f=u+1);let T=(f-u)*.06;ee=u-T,Y=f+T})();let U=Z,Q=W,N=1,ae=null,de=null,De=()=>({xmin:U,xmax:Q,vmin:ee,vmax:Y}),Je=()=>Xt(e,ie,De(),N);function pe(a){if(de!==null)return de;let u=document.createElement("canvas"),f=Math.max(6,Math.round(6*N));u.width=f,u.height=f;let p=u.getContext("2d");return p?(p.strokeStyle=a,p.globalAlpha=.3,p.lineWidth=Math.max(1,N),p.beginPath(),p.moveTo(0,f),p.lineTo(f,0),p.stroke(),de=o.createPattern(u,"repeat"),de):null}function Te(a,u,f){let p=pe(f),T=Ge(a.band);if(p!==null){o.fillStyle=p;for(let[C,A]of T)if(C!==A){o.beginPath(),o.moveTo(u.px(a.band[C].x),u.py(a.band[C].hi));for(let y=C+1;y<=A;y++)o.lineTo(u.px(a.band[y].x),u.py(a.band[y].hi));for(let y=A;y>=C;y--)o.lineTo(u.px(a.band[y].x),u.py(a.band[y].lo));o.closePath(),o.fill()}}Ee(o,a.band,T,u.px,u.py,f,0,.35,N,[3,3])}function ge(a,u){let f=u-a;if(f<ke){let p=(a+u)/2;a=p-ke/2,u=p+ke/2,f=ke}f>=Me&&(a=Z,u=W),a<Z&&(u+=Z-a,a=Z),u>W&&(a-=u-W,u=W),U=rt(a,Z,W),Q=rt(u,Z,W),ve()}let te=0;function re(){te===0&&(te=requestAnimationFrame(ve))}function ve(){if(te=0,e.width===0||e.height===0)return;let a=Je(),u=se("--abk-chart-grid"),f=se("--abk-chart-ink"),p=se("--abk-series-1");o.fillStyle=se("--abk-chart-bg"),o.fillRect(0,0,e.width,e.height),Vt(o,e,ie,De(),a.px,a.py,U,Q,u,se("--abk-muted"),N,Gt),qt(o,e,ie,N,a.py,0,ue(f,.6),""),o.save(),o.beginPath();let T=Ue(e,ie,N);o.rect(T.left,T.top,a.plotW(),a.plotH()),o.clip();for(let[C,A]of I)A<U||C>Q||wt(o,e,ie,N,a.px,C,A,se("--abk-muted"),.22);for(let[C,A]of j)A<U||C>Q||wt(o,e,ie,N,a.px,C,A,se("--abk-st-critical"),.05);if(V===null)Ee(o,L,Ge(L),a.px,a.py,p,.07,.28,N,[4,4]),Ee(o,H,Ge(H),a.px,a.py,p,.13,.4,N),ot(o,h,v,U,Q,T.left,a.plotW(),a.px,a.py,p,2,N);else{ot(o,h,v,U,Q,T.left,a.plotW(),a.px,a.py,ue(f,.55),1.25,N,[2,3]);for(let y of q){let B=Ge(y.band);y.approx?Te(y,a,p):y.pre?Ee(o,y.band,B,a.px,a.py,p,.07,.28,N,[4,4]):Ee(o,y.band,B,a.px,a.py,p,.13,.4,N)}for(let y of q)ot(o,y.xs,y.es,U,Q,T.left,a.plotW(),a.px,a.py,p,2,N,y.approx?[5,3]:void 0);let C=1/0,A=-1/0;for(let y of V)for(let B of[y.effect,y.left_bound,y.right_bound])B!==null&&Number.isFinite(B)&&(B<C&&(C=B),B>A&&(A=B));if(C!==1/0&&(C>Y||A<ee)){let y=C>Y;o.fillStyle=p,o.font=`${11*N}px ui-monospace, Menlo, Consolas, monospace`,o.textAlign="right",o.textBaseline=y?"top":"bottom",o.fillText(`live series off-scale ${y?"\u2191":"\u2193"} (${Ne(y?C:A)})`,T.right-8*N,y?T.top+6*N:T.bottom-6*N)}}Ut(o,e,ie,N,a.px,w,u,"planned horizon \u2192"),ae!==null&&Ie(a,T.top,a.plotH()),o.restore()}function He(a){let u=-1,f=1/0;for(let p=0;p<h.length;p++){if(Number.isNaN(h[p]))continue;let T=Math.abs(h[p]-a);T<f&&(f=T,u=p)}return u}function Ie(a,u,f){let p=He(ae);if(p<0)return;let T=h[p];if(T<U||T>Q)return;let C=a.px(T);o.strokeStyle=ue(se("--abk-chart-grid"),.45),o.lineWidth=1*N,o.setLineDash([2*N,2*N]),o.beginPath(),o.moveTo(C,u),o.lineTo(C,u+f),o.stroke(),o.setLineDash([]);let A=xe(k[p].t),y=A&&A.effect!==null?A.effect:v[p];if(Number.isFinite(y)){let B=a.py(y);o.fillStyle=se("--abk-chart-bg"),o.beginPath(),o.arc(C,B,4*N,0,Math.PI*2),o.fill(),o.strokeStyle=se("--abk-series-1"),o.lineWidth=2*N,o.beginPath(),o.arc(C,B,4*N,0,Math.PI*2),o.stroke()}be(p,A)}function xe(a){if(V===null)return null;for(let u of V)if(u.end_ts===a)return u;return null}function be(a,u){var C,A;let f=k[a],p=`<span class="abk-ro-t">${X(yt(f.t))} (${f.ed===null?"\u2014":le(f.ed)+"d"})</span>`;if(u!==null?u.insufficient:f.ins===1)p+=`<span class="abk-ro-flag abk-insufficient">insufficient data \u2014 n\u2081=${f.s1}, n\u2082=${f.s2} \xB7 SRM ${f.blk===1?"FAILED":"ok"}</span>`;else if(u!==null){p+=`<span>live ${u.effect===null?"\u2014":X(Ne(u.effect))}`,u.left_bound!==null&&u.right_bound!==null&&(p+=` [${X(le(u.left_bound))}, ${X(le(u.right_bound))}]`),p+=` <span class="abk-ro-tier">${X(u.tier)}</span></span>`,p+=`<span>p ${u.pvalue===null?"\u2014":X(Be(u.pvalue))}</span>`,p+=`<span>baseline ${f.e===null?"\u2014":X(Ne(f.e))}</span>`,p+=`<span>n\u2081=${(C=u.size_1)!=null?C:f.s1} n\u2082=${(A=u.size_2)!=null?A:f.s2}</span>`,u.warnings.length>0&&(p+=`<span class="abk-ro-flag">\u26A0 ${X(u.warnings.join(" \xB7 "))}</span>`);let y=[_(f.t)?"pre-horizon":"at horizon"];f.blk===1&&y.push("SRM-blocked"),p+=`<span class="abk-ro-flag">${X(y.join(" \xB7 "))}</span>`}else{p+=`<span>effect ${f.e===null?"\u2014":X(Ne(f.e))}`,f.lo!==null&&f.hi!==null&&(p+=` [${X(le(f.lo))}, ${X(le(f.hi))}]`),p+="</span>",p+=`<span>p ${f.p===null?"\u2014":X(Be(f.p))}</span>`,p+=`<span>n\u2081=${f.s1} n\u2082=${f.s2}</span>`;let y=[_(f.t)?"pre-horizon":"at horizon"];f.blk===1&&y.push("SRM-blocked"),p+=`<span class="abk-ro-flag">${X(y.join(" \xB7 "))}</span>`,V!==null&&(p+='<span class="abk-ro-flag">no live point at this cutoff (reload?)</span>')}c(p)}function we(a){let u=e.getBoundingClientRect(),f=(a-u.left-ie.l)/(u.width-(ie.l+ie.r)||1);return U+rt(f,0,1)*(Q-U)}e.addEventListener("wheel",a=>{a.preventDefault();let u=we(a.clientX),f=Q-U,p=rt(f*Math.pow(1.0015,a.deltaY),ke,Me),T=(u-U)/(f||1);ge(u-T*p,u-T*p+p)},{passive:!1});let O=null;e.addEventListener("mousedown",a=>{O={x:a.clientX,vMin:U,vMax:Q},e.style.cursor="grabbing"});let Re=a=>{if(!O)return;let u=e.getBoundingClientRect(),f=(O.vMax-O.vMin)/(u.width-(ie.l+ie.r)||1),p=(a.clientX-O.x)*f;ge(O.vMin-p,O.vMax-p)},Ae=()=>{O&&(O=null,e.style.cursor="crosshair")};return window.addEventListener("mousemove",Re),window.addEventListener("mouseup",Ae),e.addEventListener("mousemove",a=>{O||(ae=we(a.clientX),re())}),e.addEventListener("mouseleave",()=>{ae!==null&&(ae=null,c("hover for a cutoff readout \xB7 scroll to zoom \xB7 drag to pan \xB7 double-click to reset"),re())}),e.addEventListener("dblclick",()=>ge(Z,W)),e.style.cursor="crosshair",{resize(){N=Kt(e),de=null,ve()},setLive(a){V=a,he(),ve()},dispose(){window.removeEventListener("mousemove",Re),window.removeEventListener("mouseup",Ae),te&&(cancelAnimationFrame(te),te=0)}}}var Jt=!1;function Tn(){if(Jt)return;Jt=!0;let i=`
|
|
2
|
+
:where(:root){${Object.entries(xt).map(([c,o])=>`${c}:${o}`).join(";")};
|
|
3
|
+
--abk-sans:system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
|
|
4
|
+
--abk-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}
|
|
5
|
+
.${r}{font-family:var(--abk-sans);color:var(--abk-ink);background:var(--abk-page);}
|
|
6
|
+
.${r} *{box-sizing:border-box;}
|
|
7
|
+
.${r} .abk-root{height:100vh;display:flex;flex-direction:column;overflow:hidden;padding:14px 16px 10px;}
|
|
8
|
+
/* header ------------------------------------------------------------------ */
|
|
9
|
+
.${r} .abk-header{flex:none;margin-bottom:8px;padding-left:12px;border-left:3px solid var(--abk-explore-accent);}
|
|
10
|
+
.${r} .abk-h-top{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;}
|
|
11
|
+
.${r} .abk-title{font-size:19px;font-weight:700;margin:0;letter-spacing:-0.01em;}
|
|
12
|
+
.${r} .abk-badge-page{font-size:10px;font-family:var(--abk-mono);text-transform:uppercase;
|
|
13
|
+
letter-spacing:0.08em;padding:2px 8px;border-radius:8px;border:1px solid var(--abk-border);}
|
|
14
|
+
.${r} .abk-badge-live{border-color:var(--abk-explore-accent);color:var(--abk-explore-accent);}
|
|
15
|
+
.${r} .abk-badge-preview{color:var(--abk-muted);border-style:dashed;}
|
|
16
|
+
.${r} .abk-meta{font-size:11.5px;color:var(--abk-ink-2);font-family:var(--abk-mono);margin-top:2px;}
|
|
17
|
+
.${r} .abk-desc{margin:6px 0 0;font-size:12.5px;color:var(--abk-ink-2);max-width:820px;line-height:1.45;}
|
|
18
|
+
/* warnings / notes ---------------------------------------------------------- */
|
|
19
|
+
.${r} .abk-warnings{flex:none;margin:4px 0;}
|
|
20
|
+
.${r} .abk-warning{font-size:12px;color:var(--abk-ink);
|
|
21
|
+
background:color-mix(in srgb, var(--abk-st-warn) 14%, transparent);
|
|
22
|
+
border:1px solid var(--abk-st-warn);border-radius:8px;padding:4px 10px;margin:3px 0;}
|
|
23
|
+
.${r} .abk-notes{flex:none;}
|
|
24
|
+
.${r} .abk-note{font-size:11.5px;font-family:var(--abk-mono);border-radius:8px;
|
|
25
|
+
padding:4px 10px;margin:4px 0;border:1px dashed var(--abk-border);color:var(--abk-ink-2);}
|
|
26
|
+
.${r} .abk-note.abk-insufficient{background:color-mix(in srgb, var(--abk-muted) 12%, transparent);}
|
|
27
|
+
/* cockpit layout ------------------------------------------------------------- */
|
|
28
|
+
.${r} .abk-cockpit{flex:1;display:flex;gap:12px;min-height:0;}
|
|
29
|
+
.${r} .abk-stage{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0;}
|
|
30
|
+
.${r} .abk-hud{flex:none;display:flex;flex-wrap:wrap;align-items:center;
|
|
31
|
+
justify-content:space-between;gap:6px 12px;margin-bottom:6px;}
|
|
32
|
+
.${r} .abk-hud-chips{display:flex;flex-wrap:wrap;gap:6px;align-items:center;}
|
|
33
|
+
/* chips ---------------------------------------------------------------------- */
|
|
34
|
+
.${r} .abk-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;
|
|
35
|
+
background:var(--abk-card);border:1px solid var(--abk-border);border-radius:10px;
|
|
36
|
+
font-size:11.5px;font-family:var(--abk-mono);color:var(--abk-ink-2);}
|
|
37
|
+
.${r} .abk-chip-l{color:var(--abk-muted);}
|
|
38
|
+
.${r} .abk-chip-v{color:var(--abk-ink);font-weight:700;}
|
|
39
|
+
.${r} .abk-srm-ok{border-color:var(--abk-st-good);}
|
|
40
|
+
.${r} .abk-srm-fail{background:var(--abk-st-critical);border-color:var(--abk-st-critical);
|
|
41
|
+
color:var(--abk-card);font-weight:700;}
|
|
42
|
+
.${r} .abk-calibration{border-style:dashed;}
|
|
43
|
+
.${r} .abk-cal-ok{border-style:solid;border-color:var(--abk-st-good);color:var(--abk-good-text);}
|
|
44
|
+
.${r} .abk-cal-over{border-style:solid;background:var(--abk-st-critical);
|
|
45
|
+
border-color:var(--abk-st-critical);color:var(--abk-card);font-weight:700;}
|
|
46
|
+
.${r} .abk-cal-mismatch{border-style:solid;border-color:var(--abk-st-warn);}
|
|
47
|
+
.${r} .abk-identity{border-color:var(--abk-st-serious);color:var(--abk-st-serious);font-weight:600;}
|
|
48
|
+
.${r} .abk-tier{color:var(--abk-muted);}
|
|
49
|
+
/* modes ----------------------------------------------------------------------- */
|
|
50
|
+
.${r} .abk-modes{display:flex;gap:4px;}
|
|
51
|
+
.${r} .abk-mode-btn{font:600 11.5px var(--abk-mono);padding:5px 12px;border-radius:9px;
|
|
52
|
+
border:1px solid var(--abk-border);background:var(--abk-card);color:var(--abk-ink-2);cursor:pointer;}
|
|
53
|
+
.${r} .abk-mode-btn.on{border-color:var(--abk-explore-accent);color:var(--abk-explore-accent);}
|
|
54
|
+
.${r} .abk-mode-disabled{opacity:0.55;cursor:default;}
|
|
55
|
+
/* legend ----------------------------------------------------------------------- */
|
|
56
|
+
.${r} .abk-legend{flex:none;display:flex;flex-wrap:wrap;gap:5px 14px;margin-bottom:4px;}
|
|
57
|
+
.${r} .abk-legend-item{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;
|
|
58
|
+
color:var(--abk-ink-2);font-family:var(--abk-mono);}
|
|
59
|
+
.${r} .abk-swatch{width:14px;height:9px;border-radius:2px;display:inline-block;}
|
|
60
|
+
.${r} .abk-sw-live{background:var(--abk-series-1);}
|
|
61
|
+
.${r} .abk-sw-baseline{background:transparent;border-bottom:2px dashed var(--abk-chart-grid);height:5px;border-radius:0;}
|
|
62
|
+
.${r} .abk-sw-approx{background:repeating-linear-gradient(45deg,transparent,transparent 2px,var(--abk-series-1) 2px,var(--abk-series-1) 3px);}
|
|
63
|
+
.${r} .abk-sw-prehorizon{background:transparent;border:1px dashed var(--abk-series-1);}
|
|
64
|
+
.${r} .abk-sw-insufficient{background:color-mix(in srgb, var(--abk-muted) 40%, transparent);}
|
|
65
|
+
/* chart + stage foot ------------------------------------------------------------ */
|
|
66
|
+
.${r} .abk-chart{position:relative;background:var(--abk-chart-bg);
|
|
67
|
+
border:1px solid var(--abk-chart-border);border-radius:12px;overflow:hidden;}
|
|
68
|
+
.${r} .abk-chart-main{flex:1;min-height:220px;}
|
|
69
|
+
.${r} .abk-chart canvas{width:100%;height:100%;display:block;}
|
|
70
|
+
.${r} .abk-chart-fallback{color:var(--abk-chart-ink);font-size:12px;padding:20px;
|
|
71
|
+
font-family:var(--abk-mono);}
|
|
72
|
+
.${r} .abk-spin{display:none;position:absolute;top:10px;right:12px;
|
|
73
|
+
font:600 11px var(--abk-mono);color:var(--abk-chart-ink);background:color-mix(in srgb, var(--abk-chart-bg) 70%, transparent);
|
|
74
|
+
border:1px solid var(--abk-chart-border);border-radius:8px;padding:4px 10px;}
|
|
75
|
+
.${r} .abk-spin.on{display:inline-flex;}
|
|
76
|
+
.${r} .abk-stagefoot{flex:none;padding-top:5px;}
|
|
77
|
+
.${r} .abk-readout{min-height:18px;font-size:11px;color:var(--abk-ink-2);
|
|
78
|
+
font-family:var(--abk-mono);display:flex;flex-wrap:wrap;gap:3px 14px;align-items:center;}
|
|
79
|
+
.${r} .abk-ro-t{font-weight:700;color:var(--abk-ink);}
|
|
80
|
+
.${r} .abk-ro-flag{color:var(--abk-muted);}
|
|
81
|
+
.${r} .abk-ro-tier{color:var(--abk-muted);font-size:10px;text-transform:uppercase;letter-spacing:0.05em;}
|
|
82
|
+
.${r} .abk-readout .abk-insufficient{color:var(--abk-ink);
|
|
83
|
+
background:color-mix(in srgb, var(--abk-muted) 16%, transparent);border-radius:6px;padding:2px 6px;}
|
|
84
|
+
.${r} .abk-warnbar .abk-warning{margin:3px 0 0;}
|
|
85
|
+
.${r} .abk-stat{min-height:16px;margin-top:3px;font-size:11px;color:var(--abk-muted);
|
|
86
|
+
font-family:var(--abk-mono);}
|
|
87
|
+
.${r} .abk-stat-err{color:var(--abk-st-critical);}
|
|
88
|
+
/* rail --------------------------------------------------------------------------- */
|
|
89
|
+
.${r} .abk-rail{flex:none;width:330px;display:flex;flex-direction:column;min-height:0;
|
|
90
|
+
background:var(--abk-card);border:1px solid var(--abk-border);border-radius:12px;}
|
|
91
|
+
.${r} .abk-railhead{flex:none;padding:10px 14px 6px;border-bottom:1px solid var(--abk-border);}
|
|
92
|
+
.${r} .abk-railtitle{font:700 12px var(--abk-mono);letter-spacing:0.05em;text-transform:uppercase;
|
|
93
|
+
color:var(--abk-ink-2);}
|
|
94
|
+
.${r} .abk-controls{flex:1;overflow-y:auto;padding:10px 14px;min-height:0;}
|
|
95
|
+
.${r} .abk-rail-off{opacity:0.6;pointer-events:none;}
|
|
96
|
+
.${r} .abk-rail-group{margin-bottom:6px;}
|
|
97
|
+
.${r} .abk-ctl{margin:0 0 12px;}
|
|
98
|
+
.${r} .abk-ctl-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px;}
|
|
99
|
+
.${r} .abk-ctl-label{font-size:12px;color:var(--abk-ink);display:flex;align-items:baseline;
|
|
100
|
+
flex-wrap:wrap;gap:6px;margin-bottom:4px;}
|
|
101
|
+
.${r} .abk-hint{color:var(--abk-muted);font-size:10px;cursor:help;}
|
|
102
|
+
.${r} .abk-knob-badge{font:600 9.5px var(--abk-mono);padding:1px 6px;border-radius:7px;
|
|
103
|
+
border:1px solid var(--abk-border);color:var(--abk-muted);cursor:help;}
|
|
104
|
+
.${r} .abk-badge-identity{border-color:var(--abk-st-serious);color:var(--abk-st-serious);}
|
|
105
|
+
.${r} .abk-badge-reload{border-color:var(--abk-series-1);color:var(--abk-series-1);}
|
|
106
|
+
.${r} .abk-ctl-val{font:600 11.5px var(--abk-mono);color:var(--abk-ink-2);}
|
|
107
|
+
.${r} .abk-seg{display:flex;flex-wrap:wrap;gap:4px;}
|
|
108
|
+
.${r} .abk-seg-btn{font:600 11px var(--abk-mono);padding:4px 9px;border-radius:8px;
|
|
109
|
+
border:1px solid var(--abk-border);background:var(--abk-page);color:var(--abk-ink-2);cursor:pointer;}
|
|
110
|
+
.${r} .abk-seg-btn.on{border-color:var(--abk-explore-accent);color:var(--abk-explore-accent);
|
|
111
|
+
background:color-mix(in srgb, var(--abk-explore-accent) 8%, transparent);}
|
|
112
|
+
.${r} .abk-range{width:100%;accent-color:var(--abk-explore-accent);}
|
|
113
|
+
.${r} .abk-num,.${r} .abk-text{width:100%;font:12px var(--abk-mono);padding:5px 8px;
|
|
114
|
+
border:1px solid var(--abk-border);border-radius:8px;background:var(--abk-page);color:var(--abk-ink);}
|
|
115
|
+
.${r} .abk-check{display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;}
|
|
116
|
+
.${r} .abk-check input{accent-color:var(--abk-explore-accent);}
|
|
117
|
+
.${r} .abk-ctl-note{font-size:10.5px;color:var(--abk-muted);font-family:var(--abk-mono);
|
|
118
|
+
margin:0 0 10px;line-height:1.5;}
|
|
119
|
+
.${r} .abk-advanced{margin-top:2px;}
|
|
120
|
+
.${r} .abk-advanced summary{font:600 11.5px var(--abk-mono);color:var(--abk-ink-2);
|
|
121
|
+
cursor:pointer;margin-bottom:8px;}
|
|
122
|
+
/* review ---------------------------------------------------------------------------- */
|
|
123
|
+
.${r} .abk-review-row{border:1px solid var(--abk-border);border-radius:9px;
|
|
124
|
+
padding:8px 10px;margin-bottom:8px;}
|
|
125
|
+
.${r} .abk-review-name{font:700 12px var(--abk-mono);margin-bottom:5px;}
|
|
126
|
+
.${r} .abk-review-checks{display:flex;gap:16px;}
|
|
127
|
+
.${r} .abk-review-checks .abk-ctl{margin:0;}
|
|
128
|
+
.${r} .abk-review-verdict{margin-top:5px;font:600 10.5px var(--abk-mono);color:var(--abk-ink-2);}
|
|
129
|
+
.${r} .abk-verdict-win{color:var(--abk-good-text);}
|
|
130
|
+
.${r} .abk-verdict-lose{color:var(--abk-st-critical);}
|
|
131
|
+
/* rail foot ---------------------------------------------------------------------------- */
|
|
132
|
+
.${r} .abk-railfoot{flex:none;border-top:1px solid var(--abk-border);padding:10px 14px;}
|
|
133
|
+
.${r} .abk-cfg-toggle{font:600 10.5px var(--abk-mono);color:var(--abk-muted);cursor:pointer;
|
|
134
|
+
margin-bottom:6px;}
|
|
135
|
+
.${r} .abk-cfg-echo{font:10.5px var(--abk-mono);color:var(--abk-ink-2);
|
|
136
|
+
overflow-wrap:anywhere;margin-bottom:8px;line-height:1.5;}
|
|
137
|
+
.${r} .abk-btn{font:700 12px var(--abk-sans);padding:8px 14px;border-radius:9px;cursor:pointer;
|
|
138
|
+
border:1px solid var(--abk-border);background:var(--abk-page);color:var(--abk-ink);}
|
|
139
|
+
.${r} .abk-btn:disabled{opacity:0.5;cursor:default;}
|
|
140
|
+
.${r} .abk-btn-apply{width:100%;background:var(--abk-explore-accent);
|
|
141
|
+
border-color:var(--abk-explore-accent);color:var(--abk-card);}
|
|
142
|
+
.${r} .abk-btn-danger{background:var(--abk-st-critical);border-color:var(--abk-st-critical);
|
|
143
|
+
color:var(--abk-card);}
|
|
144
|
+
.${r} .abk-btn-ghost{background:transparent;}
|
|
145
|
+
.${r} .abk-btn-reload{border-color:var(--abk-series-1);color:var(--abk-series-1);}
|
|
146
|
+
.${r} .abk-apply-msg{margin-top:8px;font-size:11.5px;line-height:1.5;overflow-wrap:anywhere;}
|
|
147
|
+
.${r} .abk-apply-msg.ok{color:var(--abk-good-text);}
|
|
148
|
+
.${r} .abk-apply-msg.err{color:var(--abk-st-critical);}
|
|
149
|
+
.${r} .abk-apply-msg.info{color:var(--abk-ink-2);}
|
|
150
|
+
.${r} .abk-orphan{color:var(--abk-ink);margin-top:4px;
|
|
151
|
+
background:color-mix(in srgb, var(--abk-st-warn) 16%, transparent);border-radius:6px;padding:4px 8px;}
|
|
152
|
+
.${r} .abk-confirm{margin-top:8px;border:1px solid var(--abk-st-warn);border-radius:9px;
|
|
153
|
+
padding:8px 10px;background:color-mix(in srgb, var(--abk-st-warn) 10%, transparent);}
|
|
154
|
+
.${r} .abk-confirm-text{font-size:11.5px;line-height:1.5;margin-bottom:8px;}
|
|
155
|
+
.${r} .abk-confirm-btns{display:flex;gap:8px;}
|
|
156
|
+
.${r} .abk-reloadbar{border:1px solid var(--abk-series-1);border-radius:9px;
|
|
157
|
+
padding:8px 10px;margin-bottom:8px;background:color-mix(in srgb, var(--abk-series-1) 8%, transparent);}
|
|
158
|
+
.${r} .abk-reloadbar-text{font-size:11.5px;line-height:1.5;margin-bottom:8px;}
|
|
159
|
+
.${r} .abk-reloadbar-btns{display:flex;gap:8px;}
|
|
160
|
+
.${r} .abk-preview-note{font-size:11px;color:var(--abk-muted);font-family:var(--abk-mono);
|
|
161
|
+
line-height:1.5;margin-bottom:8px;}
|
|
162
|
+
/* empty states ---------------------------------------------------------------------------- */
|
|
163
|
+
.${r} .abk-empty{font-size:13px;color:var(--abk-ink-2);background:var(--abk-card);
|
|
164
|
+
border:1px dashed var(--abk-border);border-radius:10px;padding:14px;}
|
|
165
|
+
/* responsive fallback ----------------------------------------------------------------------- */
|
|
166
|
+
@media (max-width: 900px){
|
|
167
|
+
.${r} .abk-root{height:auto;overflow:visible;}
|
|
168
|
+
.${r} .abk-cockpit{flex-direction:column;}
|
|
169
|
+
.${r} .abk-chart-main{height:54vh;flex:none;}
|
|
170
|
+
.${r} .abk-rail{width:100%;}
|
|
171
|
+
.${r} .abk-controls{max-height:50vh;}
|
|
172
|
+
}
|
|
173
|
+
`,s=document.createElement("style");s.setAttribute("data-abk-explore",""),s.textContent=i,document.head.appendChild(s)}window.__ABK_EXPLORE__={render:Sn};})();
|