ab-analysis-kit 0.3.0__tar.gz → 0.4.0__tar.gz

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.
Files changed (174) hide show
  1. {ab_analysis_kit-0.3.0/ab_analysis_kit.egg-info → ab_analysis_kit-0.4.0}/PKG-INFO +9 -6
  2. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/README.md +8 -5
  3. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0/ab_analysis_kit.egg-info}/PKG-INFO +9 -6
  4. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/ab_analysis_kit.egg-info/SOURCES.txt +5 -0
  5. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/__init__.py +1 -1
  6. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/cli.md +39 -4
  7. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/experiments.md +4 -0
  8. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/explore.md +3 -3
  9. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/metrics.md +35 -0
  10. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/overview.md +1 -1
  11. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/project.md +5 -0
  12. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/clean.py +59 -2
  13. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/init.py +9 -0
  14. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/run.py +12 -0
  15. ab_analysis_kit-0.4.0/abkit/cli/commands/verify_incremental.py +160 -0
  16. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/main.py +47 -2
  17. ab_analysis_kit-0.4.0/abkit/compute/incremental_backend.py +439 -0
  18. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/compute/recompute_backend.py +53 -12
  19. ab_analysis_kit-0.4.0/abkit/compute/reconcile.py +372 -0
  20. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/experiment_config.py +6 -0
  21. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/metric_config.py +16 -0
  22. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/project_config.py +15 -0
  23. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/core/models.py +11 -0
  24. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/_sql_manager.py +64 -6
  25. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/clickhouse_manager.py +36 -1
  26. ab_analysis_kit-0.4.0/abkit/database/internal_tables/__init__.py +17 -0
  27. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_exposures.py +30 -0
  28. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_schema.py +10 -2
  29. ab_analysis_kit-0.4.0/abkit/database/internal_tables/_unit_state.py +429 -0
  30. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/manager.py +176 -1
  31. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/mysql_manager.py +10 -0
  32. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/postgres_manager.py +12 -0
  33. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/tables.py +8 -0
  34. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/loaders/exposure_source.py +46 -0
  35. ab_analysis_kit-0.4.0/abkit/loaders/state_loader.py +96 -0
  36. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/pipeline/_types.py +31 -0
  37. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/pipeline/driver.py +160 -33
  38. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/pipeline/enrich.py +4 -0
  39. ab_analysis_kit-0.4.0/abkit/pipeline/state.py +419 -0
  40. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/base.py +8 -0
  41. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/parametric/cuped_ttest.py +8 -0
  42. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/result.py +8 -0
  43. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/assets/explore.js +3 -3
  44. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/recompute.py +122 -24
  45. ab_analysis_kit-0.3.0/abkit/database/internal_tables/__init__.py +0 -6
  46. ab_analysis_kit-0.3.0/abkit/database/internal_tables/_unit_state.py +0 -148
  47. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/LICENSE +0 -0
  48. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/MANIFEST.in +0 -0
  49. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/ab_analysis_kit.egg-info/dependency_links.txt +0 -0
  50. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/ab_analysis_kit.egg-info/entry_points.txt +0 -0
  51. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/ab_analysis_kit.egg-info/requires.txt +0 -0
  52. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/ab_analysis_kit.egg-info/top_level.txt +0 -0
  53. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/__init__.py +0 -0
  54. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/_output.py +0 -0
  55. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/CLAUDE.section.md +0 -0
  56. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/methods.md +0 -0
  57. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/plan.md +0 -0
  58. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/rules/validate.md +0 -0
  59. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/skills/abk-explore/SKILL.md +0 -0
  60. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/skills/abk-feedback/SKILL.md +0 -0
  61. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/skills/abk-new-experiment/SKILL.md +0 -0
  62. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/skills/abk-new-metric/SKILL.md +0 -0
  63. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/skills/abk-plan/SKILL.md +0 -0
  64. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/skills/abk-setup-project/SKILL.md +0 -0
  65. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/assets/claude/skills/abk-validate/SKILL.md +0 -0
  66. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/__init__.py +0 -0
  67. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/_context.py +0 -0
  68. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/explore.py +0 -0
  69. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/init_claude.py +0 -0
  70. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/plan.py +0 -0
  71. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/test_report.py +0 -0
  72. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/unlock.py +0 -0
  73. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/cli/commands/validate.py +0 -0
  74. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/compute/__init__.py +0 -0
  75. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/__init__.py +0 -0
  76. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/discovery.py +0 -0
  77. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/method_config.py +0 -0
  78. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/profile.py +0 -0
  79. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/config/validator.py +0 -0
  80. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/core/__init__.py +0 -0
  81. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/core/exposure_counting.py +0 -0
  82. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/core/interval.py +0 -0
  83. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/core/period_planner.py +0 -0
  84. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/__init__.py +0 -0
  85. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_aa_runs.py +0 -0
  86. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_base.py +0 -0
  87. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_experiments.py +0 -0
  88. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_maintenance.py +0 -0
  89. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_results.py +0 -0
  90. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/_tasks.py +0 -0
  91. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/database/internal_tables/manager.py +0 -0
  92. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/loaders/__init__.py +0 -0
  93. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/loaders/exposure_copy.py +0 -0
  94. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/loaders/exposure_loader.py +0 -0
  95. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/loaders/metric_loader.py +0 -0
  96. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/loaders/query_template.py +0 -0
  97. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/loaders/templates/abkit_assignment.jinja +0 -0
  98. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/__init__.py +0 -0
  99. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/base.py +0 -0
  100. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/branding.py +0 -0
  101. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/email.py +0 -0
  102. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/factory.py +0 -0
  103. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/mattermost.py +0 -0
  104. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/mock.py +0 -0
  105. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/slack.py +0 -0
  106. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/telegram.py +0 -0
  107. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/notify/webhook.py +0 -0
  108. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/pipeline/__init__.py +0 -0
  109. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/pipeline/analyze.py +0 -0
  110. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/pipeline/readout.py +0 -0
  111. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/planning/__init__.py +0 -0
  112. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/planning/sizing.py +0 -0
  113. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/reporting/__init__.py +0 -0
  114. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/reporting/assets/report.js +0 -0
  115. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/reporting/builder.py +0 -0
  116. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/reporting/calibration.py +0 -0
  117. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/reporting/html_report.py +0 -0
  118. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/__init__.py +0 -0
  119. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/accumulate.py +0 -0
  120. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/__init__.py +0 -0
  121. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/applier.py +0 -0
  122. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/bootstrap.py +0 -0
  123. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/ci.py +0 -0
  124. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/engine.py +0 -0
  125. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/paired_bootstrap.py +0 -0
  126. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/paired_post_normed_bootstrap.py +0 -0
  127. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/poisson_bootstrap.py +0 -0
  128. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/bootstrap/post_normed_bootstrap.py +0 -0
  129. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/correction.py +0 -0
  130. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/effects.py +0 -0
  131. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/exceptions.py +0 -0
  132. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/factory.py +0 -0
  133. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/parametric/__init__.py +0 -0
  134. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/parametric/paired_cuped_ttest.py +0 -0
  135. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/parametric/paired_ttest.py +0 -0
  136. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/parametric/ratio_delta.py +0 -0
  137. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/parametric/ttest.py +0 -0
  138. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/parametric/ztest.py +0 -0
  139. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/power.py +0 -0
  140. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/registry.py +0 -0
  141. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/rng.py +0 -0
  142. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/samples.py +0 -0
  143. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/sequential/__init__.py +0 -0
  144. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/sequential/apply.py +0 -0
  145. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/sequential/confidence_sequence.py +0 -0
  146. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/sequential/mixture.py +0 -0
  147. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/stats/srm.py +0 -0
  148. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/__init__.py +0 -0
  149. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/config_writer.py +0 -0
  150. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/html.py +0 -0
  151. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/payload.py +0 -0
  152. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/server.py +0 -0
  153. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/tuning/session.py +0 -0
  154. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/utils/__init__.py +0 -0
  155. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/utils/datetime_utils.py +0 -0
  156. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/utils/env_interpolation.py +0 -0
  157. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/utils/json_utils.py +0 -0
  158. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/__init__.py +0 -0
  159. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/_types.py +0 -0
  160. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/family.py +0 -0
  161. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/inject.py +0 -0
  162. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/load.py +0 -0
  163. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/panel.py +0 -0
  164. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/persistence.py +0 -0
  165. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/resample.py +0 -0
  166. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/result.py +0 -0
  167. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/run_id.py +0 -0
  168. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/runner.py +0 -0
  169. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/scoring.py +0 -0
  170. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/abkit/validate/vector_resample.py +0 -0
  171. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/pyproject.toml +0 -0
  172. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/requirements.txt +0 -0
  173. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/setup.cfg +0 -0
  174. {ab_analysis_kit-0.3.0 → ab_analysis_kit-0.4.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ab-analysis-kit
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,9 +76,12 @@ stabilization chart), writes them to a clean warehouse table any BI can read, an
76
76
  gives you a local cockpit to tune the analysis and a harness to prove your method is
77
77
  actually calibrated.
78
78
 
79
- > **Status: `0.3.0` (Alpha) — release-ready; `0.2.0` is the latest on PyPI**
80
- > (milestones **M1–M8** shipped — M8 adds the no-copy assignment default + the
81
- > opt-in incremental `_ab_exposures` copy). The
79
+ > **Status: `0.4.0` (Alpha) — release-ready; `0.3.0` is the latest on PyPI**
80
+ > (milestones **M1–M9** shipped — M9 adds the additive compute engine: a STATE
81
+ > stage materializing per-(unit, day) moments, the opt-in
82
+ > `compute.incremental_reads` path that turns the O(D²) full-window rescan into
83
+ > a linear one, `abk verify-incremental` to prove it moved no number, and
84
+ > instant CUPED in the cockpit). The
82
85
  > statistical core, the declarative config / DB / pipeline layer, the explore cockpit +
83
86
  > self-contained reports, `abk validate` (now numpy-vectorized — minutes → sub-seconds),
84
87
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -91,8 +94,8 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
91
94
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
92
95
  ```
93
96
 
94
- (`0.3.0`'s M8 no-copy default lands with its tag; until then `pip install
95
- ab-analysis-kit` gets `0.2.0` — for the M8 behavior install from source:
97
+ (`0.4.0`'s M9 additive engine lands with its tag; until then `pip install
98
+ ab-analysis-kit` gets `0.3.0` — for the M9 behavior install from source:
96
99
  `pip install -e ".[dev]"`.)
97
100
 
98
101
  `abk --version` and `abk --help` work with no database driver; you can even lint a
@@ -11,9 +11,12 @@ stabilization chart), writes them to a clean warehouse table any BI can read, an
11
11
  gives you a local cockpit to tune the analysis and a harness to prove your method is
12
12
  actually calibrated.
13
13
 
14
- > **Status: `0.3.0` (Alpha) — release-ready; `0.2.0` is the latest on PyPI**
15
- > (milestones **M1–M8** shipped — M8 adds the no-copy assignment default + the
16
- > opt-in incremental `_ab_exposures` copy). The
14
+ > **Status: `0.4.0` (Alpha) — release-ready; `0.3.0` is the latest on PyPI**
15
+ > (milestones **M1–M9** shipped — M9 adds the additive compute engine: a STATE
16
+ > stage materializing per-(unit, day) moments, the opt-in
17
+ > `compute.incremental_reads` path that turns the O(D²) full-window rescan into
18
+ > a linear one, `abk verify-incremental` to prove it moved no number, and
19
+ > instant CUPED in the cockpit). The
17
20
  > statistical core, the declarative config / DB / pipeline layer, the explore cockpit +
18
21
  > self-contained reports, `abk validate` (now numpy-vectorized — minutes → sub-seconds),
19
22
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -26,8 +29,8 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
26
29
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
27
30
  ```
28
31
 
29
- (`0.3.0`'s M8 no-copy default lands with its tag; until then `pip install
30
- ab-analysis-kit` gets `0.2.0` — for the M8 behavior install from source:
32
+ (`0.4.0`'s M9 additive engine lands with its tag; until then `pip install
33
+ ab-analysis-kit` gets `0.3.0` — for the M9 behavior install from source:
31
34
  `pip install -e ".[dev]"`.)
32
35
 
33
36
  `abk --version` and `abk --help` work with no database driver; you can even lint a
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ab-analysis-kit
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,9 +76,12 @@ stabilization chart), writes them to a clean warehouse table any BI can read, an
76
76
  gives you a local cockpit to tune the analysis and a harness to prove your method is
77
77
  actually calibrated.
78
78
 
79
- > **Status: `0.3.0` (Alpha) — release-ready; `0.2.0` is the latest on PyPI**
80
- > (milestones **M1–M8** shipped — M8 adds the no-copy assignment default + the
81
- > opt-in incremental `_ab_exposures` copy). The
79
+ > **Status: `0.4.0` (Alpha) — release-ready; `0.3.0` is the latest on PyPI**
80
+ > (milestones **M1–M9** shipped — M9 adds the additive compute engine: a STATE
81
+ > stage materializing per-(unit, day) moments, the opt-in
82
+ > `compute.incremental_reads` path that turns the O(D²) full-window rescan into
83
+ > a linear one, `abk verify-incremental` to prove it moved no number, and
84
+ > instant CUPED in the cockpit). The
82
85
  > statistical core, the declarative config / DB / pipeline layer, the explore cockpit +
83
86
  > self-contained reports, `abk validate` (now numpy-vectorized — minutes → sub-seconds),
84
87
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -91,8 +94,8 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
91
94
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
92
95
  ```
93
96
 
94
- (`0.3.0`'s M8 no-copy default lands with its tag; until then `pip install
95
- ab-analysis-kit` gets `0.2.0` — for the M8 behavior install from source:
97
+ (`0.4.0`'s M9 additive engine lands with its tag; until then `pip install
98
+ ab-analysis-kit` gets `0.3.0` — for the M9 behavior install from source:
96
99
  `pip install -e ".[dev]"`.)
97
100
 
98
101
  `abk --version` and `abk --help` work with no database driver; you can even lint a
@@ -42,8 +42,11 @@ abkit/cli/commands/run.py
42
42
  abkit/cli/commands/test_report.py
43
43
  abkit/cli/commands/unlock.py
44
44
  abkit/cli/commands/validate.py
45
+ abkit/cli/commands/verify_incremental.py
45
46
  abkit/compute/__init__.py
47
+ abkit/compute/incremental_backend.py
46
48
  abkit/compute/recompute_backend.py
49
+ abkit/compute/reconcile.py
47
50
  abkit/config/__init__.py
48
51
  abkit/config/discovery.py
49
52
  abkit/config/experiment_config.py
@@ -81,6 +84,7 @@ abkit/loaders/exposure_loader.py
81
84
  abkit/loaders/exposure_source.py
82
85
  abkit/loaders/metric_loader.py
83
86
  abkit/loaders/query_template.py
87
+ abkit/loaders/state_loader.py
84
88
  abkit/loaders/templates/abkit_assignment.jinja
85
89
  abkit/notify/__init__.py
86
90
  abkit/notify/base.py
@@ -98,6 +102,7 @@ abkit/pipeline/analyze.py
98
102
  abkit/pipeline/driver.py
99
103
  abkit/pipeline/enrich.py
100
104
  abkit/pipeline/readout.py
105
+ abkit/pipeline/state.py
101
106
  abkit/planning/__init__.py
102
107
  abkit/planning/sizing.py
103
108
  abkit/reporting/__init__.py
@@ -10,7 +10,7 @@ from __future__ import annotations
10
10
 
11
11
  from typing import Any
12
12
 
13
- __version__ = "0.3.0"
13
+ __version__ = "0.4.0"
14
14
 
15
15
  #: Symbols re-exported lazily from ``abkit.stats`` (PEP 562) so importing
16
16
  #: ``abkit`` for ``__version__`` (the CLI path) stays numpy-free and fast.
@@ -17,6 +17,7 @@ task = one `abk` invocation), so a broken run fails the job instead of exiting 0
17
17
  | `abk plan --select <exp>` | Read-only pre-launch sizing: required-N / achievable-MDE / power (see `plan.md`) |
18
18
  | `abk unlock --select <exp>` | Clear a stuck pipeline / validate lock |
19
19
  | `abk clean --select <exp>` | Prune internal rows that no longer match the config |
20
+ | `abk verify-incremental --select <exp>` | Reconcile the incremental read path against full recompute across the whole computed series — the gate for `compute.incremental_reads`; read-only, no lock, non-zero exit on any divergence |
20
21
  | `abk test-report <exp>` | Send a **mock** WIN readout through the configured notification channels — a connectivity smoke test (no lock, no warehouse read); `--channel <name>` (repeatable) / `--profile`; non-zero exit if any channel fails. See `project.md` `notification_channels` |
21
22
  | `abk --version` | Show the installed abkit version |
22
23
 
@@ -69,17 +70,22 @@ to refresh this context.
69
70
  ## `abk run`
70
71
 
71
72
  ```bash
72
- abk run [--select <exp>] [--exclude <sel>] [--steps validate,plan,load,compute] \
73
+ abk run [--select <exp>] [--exclude <sel>] [--steps validate,plan,load,state,compute] \
73
74
  [--from TS] [--to TS] [--full-refresh] [--resync-cohort] [--workers N] \
74
75
  [--report [PATH]] [--force] [--profile NAME]
75
76
  ```
76
77
 
77
- The pipeline: **validate → plan → load → SRM → compute → persist**, streaming
78
- `VALIDATE → PLAN → LOAD → SRM → COMPUTE → RESULT`. It is incremental by
78
+ The pipeline: **validate → plan → load → SRM → state → compute → persist**,
79
+ streaming `VALIDATE → PLAN → LOAD → SRM → STATE → COMPUTE → RESULT` (`state`,
80
+ M9: materializes per-unit day moments into `_ab_unit_state` for closed-form
81
+ metrics; with the opt-in `compute.incremental_reads: true` those moments then
82
+ replace the full-window fact rescan on the compute path — any gap falls back
83
+ to recompute, and results math is unchanged either way).
84
+ It is incremental by
79
85
  an anti-join — only cutoffs past the `data_lag` watermark and not already computed
80
86
  are (re)computed, so re-running is idempotent.
81
87
 
82
- - `--steps` (default `validate,plan,load,compute`) — comma-separated steps.
88
+ - `--steps` (default `validate,plan,load,state,compute`) — comma-separated steps.
83
89
  **`--steps validate` alone is the config lint** (no DB, no lock): it parses the
84
90
  YAML, lints every metric SQL for the one-row-per-unit contract and the cohort
85
91
  macro, and instantiates each method. This is the ONLY meaning of "validate" on
@@ -100,6 +106,9 @@ are (re)computed, so re-running is idempotent.
100
106
  experiment (best-effort — never fails the run). Tri-state: bare `--report` →
101
107
  `reports/<exp>.html`; a directory → `<dir>/<exp>.html`; a `.html` path → that
102
108
  file. Reads persisted rows, so even a load-only run can produce one.
109
+ - `--cost-report` — print per-stage warehouse cost (wall-time, queries, rows returned,
110
+ rows scanned where the backend reports them). The evidence for turning
111
+ `compute.incremental_reads` on; unrelated to `--profile` (the DB connection).
103
112
  - `--force` — take over a held lock (prefer `abk unlock`; risky with concurrent runs).
104
113
  - `--profile` — override `profiles.yml`'s `default_profile` (e.g. run against staging).
105
114
 
@@ -216,6 +225,32 @@ default** — pass `--execute` to actually delete.
216
225
  - **GC mode** — `abk clean --orphaned-experiments`: purges all internal rows for
217
226
  experiment names present in the DB but no longer defined by any YAML (renamed or
218
227
  deleted experiments). Asks for confirmation on `--execute` unless `--yes`.
228
+ - **State sweep** — runs alongside drift mode, no flag: drops `_ab_unit_state`
229
+ series no live `(experiment, metric)` pair claims (a removed comparison, a renamed
230
+ metric, a deleted experiment, or a comparison that stopped being state-eligible).
231
+ A normal run only drops series superseded by an edit to a metric it still
232
+ materializes. Deliberately NOT narrowed by `--select` — state rows are keyed by
233
+ `(source_table, column_set_id)`, not by experiment.
234
+
235
+ ## `abk verify-incremental`
236
+
237
+ ```bash
238
+ abk verify-incremental [--select <exp>] [--metric <m>] [--rel-tol 1e-9] [--profile NAME]
239
+ ```
240
+
241
+ The gate before turning `compute.incremental_reads` on (and the drift detector
242
+ after). For EVERY already-computed cutoff of every state-eligible comparison it
243
+ loads the data both ways — `_ab_unit_state` day moments vs a full-window fact
244
+ rescan — and diffs the numbers field by field. Whole-series by design: a drift
245
+ that accumulates over many days cannot hide behind a green latest cutoff.
246
+
247
+ Read-only and lock-free; never part of `abk run` (it costs more than the run it
248
+ checks). Outcomes: **matched** (agree within `--rel-tol`), **DIVERGED** (prints
249
+ the offending fields, exits non-zero — usually an event backfilled into an
250
+ already-materialized day later than `data_lag`; heal with `abk run --full-refresh
251
+ --from/--to`), and **unverified** (the incremental read fell back to recompute for
252
+ that cutoff, so both sides ran the same code — reported separately, never counted
253
+ as a pass).
219
254
 
220
255
  ## Common workflows
221
256
 
@@ -40,6 +40,10 @@ assignment: # READ-ONLY exposure source — abkit never ran
40
40
  alpha: 0.05 # experiment-level significance (unset -> project default)
41
41
  correction: bonferroni # none | bonferroni | benjamini_hochberg (unset -> project default)
42
42
  sequential: {enabled: false, scheme: always_valid} # opt-in peeking-safe CIs (default OFF)
43
+ # incremental_reads: true # override project.compute.incremental_reads here (unset -> project
44
+ # default): eligible closed-form comparisons read `_ab_unit_state`
45
+ # day moments instead of re-scanning the fact window. Changes HOW a
46
+ # number is computed, never the number; any state gap falls back.
43
47
 
44
48
  readout: # READ-TIME verdict knobs — NEVER enter method_config_id
45
49
  stabilization_days: 7 # trailing elapsed-DAYS window for "persistent significance" (default 7)
@@ -62,10 +62,10 @@ DB round-trip** for a normal tune. Cost depends on which knob you turned:
62
62
 
63
63
  | Tier | Knob → | How it recomputes |
64
64
  |---|---|---|
65
- | **E** exact | `test_type`, most closed-form params | suffstats reconstructed from persisted rows, whole grid |
66
- | **α** | experiment-level `alpha` | alpha-inversion on closed-form rows (approx), whole grid |
65
+ | **E** exact | `test_type`, `alpha`, most closed-form params — incl. every CUPED knob except `covariate_lookback` (0.4.0) | suffstats reconstructed from persisted rows, whole grid |
66
+ | **α** | `alpha` on rows that cannot reconstruct (e.g. CUPED rows written before 0.4.0) | alpha-inversion on closed-form rows (approx), whole grid |
67
67
  | **S** session cache | needs raw samples (e.g. bootstrap) | `from_samples` over the bounded session cache (cached cutoffs) |
68
- | **R** reload | CUPED off→on with no cached covariate | flagged `R`; a serialized `/reload` re-reads the warehouse on demand |
68
+ | **R** reload | `covariate_lookback`, or CUPED off→on with no cached covariate | flagged `R`; a serialized `/reload` re-reads the warehouse on demand |
69
69
 
70
70
  The one session-load pass at startup (lock-free, read-only) fills a **bounded**
71
71
  Tier-S cache. Over budget ⇒ honest suffstats-only degradation (a smaller live
@@ -28,6 +28,9 @@ sql: | # inline SQL (or `query_file: sql/arpu.sql`)
28
28
  {% import 'abkit_assignment.jinja' as ab %}
29
29
  ...
30
30
  aa_fpr_budget: 0.07 # optional — per-metric A/A false-positive budget
31
+ state_additive: false # optional — declare that every role column is a plain
32
+ # sum()/count() over the window, so per-day partials add
33
+ # up to the window total (see below)
31
34
  ```
32
35
 
33
36
  Provide **exactly one** of `sql:` (inline; `query:` is an accepted alias) or
@@ -116,6 +119,38 @@ Set an explicit `columns.covariate` **only** when you compute a different
116
119
  covariate yourself (e.g. a snapshot column in your SQL); an explicit covariate
117
120
  role takes precedence and skips the second render.
118
121
 
122
+ ## `state_additive` (optional)
123
+
124
+ `state_additive: true` is your promise that this metric **splits by day**: every
125
+ role column is a plain `sum()`/`count()` over the window, so the per-day partials
126
+ add up to the whole-window total.
127
+
128
+ It gates the incremental compute engine. With it set, the `state` pipeline step
129
+ materializes this metric's per-(unit, day) moments into `_ab_unit_state`, and
130
+ `compute.incremental_reads: true` may then serve cutoffs from those moments
131
+ instead of re-scanning the fact window. Without it, the metric is always
132
+ recomputed over the whole window — always correct, just not cheap.
133
+
134
+ **Leave it off** for anything that does not split by day:
135
+
136
+ | Projection | Why it is not additive |
137
+ |---|---|
138
+ | `max(converted) AS converted` | summing daily maxima counts active days, not the window max |
139
+ | `1 AS visits` (a constant) | eleven daily renders sum to eleven, not one |
140
+ | `avg(x) AS x` | a mean of means is not the mean |
141
+ | `uniq(session_id)`, `count(DISTINCT …)` | daily distinct counts do not sum to the window's |
142
+ | `sum(x) / count(*) AS rate` | a ratio of aggregates; use a `ratio` metric instead |
143
+
144
+ abkit cannot read additivity off your SQL — a staging CTE, an outer
145
+ re-aggregation, a `UNION` branch or an identity `sum()` over a renamed per-unit
146
+ `max()` all look additive textually. It does refuse projections that visibly
147
+ contradict the promise (a bare `max()`, `DISTINCT`, a window function, a
148
+ multi-branch query), but that filter can only take eligibility away, never grant
149
+ it. The empirical check is
150
+ [`abk verify-incremental`](../reference/cli.md#abk-verify-incremental), which
151
+ reconciles both read paths across the whole computed series — run it before
152
+ turning `compute.incremental_reads` on.
153
+
119
154
  ## `aa_fpr_budget` (optional)
120
155
 
121
156
  A per-metric A/A false-positive budget (a fraction in `(0, 1]`) that `abk
@@ -72,7 +72,7 @@ profile's `internal_database` / `internal_schema`, separate from the
72
72
  | `_ab_experiments` | Informational experiment catalog (descriptions, variants, split, alpha, cadence, tags) for BI joins; the pipeline never reads it back for decisions. |
73
73
  | `_ab_aa_runs` | The `abk validate` A/A audit trail (per-cell FPR/power at the effective alpha); lights the explore calibration chip. Never pruned by `abk clean`. |
74
74
  | `_ab_tasks` | Pipeline run/lock bookkeeping — the atomic per-experiment lock (`abk unlock` clears a stale one). |
75
- | `_ab_unit_state` | A scalability seam (thin per-unit-moment materialization); v1 does NOT read it on the compute path. |
75
+ | `_ab_unit_state` | Per-(unit, day) cumulative moments, written by the `state` pipeline stage for eligible closed-form metrics. Read on the compute path only with `compute.incremental_reads: true` (opt-in, default off); any gap falls back to full recompute. Not a BI table. |
76
76
 
77
77
  ## Glossary
78
78
 
@@ -41,6 +41,11 @@ timeouts: # per-step, seconds
41
41
 
42
42
  compute:
43
43
  mode: recompute # v1: full-window recompute (the golden reference). Only value today.
44
+ incremental_reads: false # opt-in (M9): eligible closed-form comparisons read the `state`
45
+ # stage's `_ab_unit_state` day moments instead of re-scanning the
46
+ # fact window; any gap falls back to recompute. An experiment can
47
+ # override it with its own `incremental_reads:`. Changes HOW a
48
+ # number is computed, never the number.
44
49
  ```
45
50
 
46
51
  Everything except `name` and `default_profile` has a default — a minimal project
@@ -65,6 +65,56 @@ def _clean_drift(
65
65
  return experiments_touched, pruned
66
66
 
67
67
 
68
+ def _clean_state_series(
69
+ context: ProjectContext,
70
+ tables: InternalTablesManager,
71
+ execute: bool,
72
+ ) -> int:
73
+ """Prune ``_ab_unit_state`` series no live (experiment, metric) claims.
74
+
75
+ The STATE-side analogue of the drift sweep (m9 WP5). The per-run sweep in
76
+ ``pipeline/state.py`` already drops superseded ``column_set_id``s under a
77
+ source key it touches — this catches what a run can never revisit: a
78
+ comparison removed, a metric renamed, an experiment deleted, or a
79
+ comparison that stopped being STATE-eligible. Deliberately
80
+ selection-INDEPENDENT: state rows are not experiment-keyed, so the valid
81
+ set is computed from the WHOLE project (pruning by a narrow ``--select``
82
+ would delete another experiment's live series).
83
+ """
84
+ from abkit.pipeline.state import state_eligible_metrics, state_series_key
85
+
86
+ if not tables.unit_state_table_exists():
87
+ return 0
88
+
89
+ metrics_by_name = context.metrics_by_name
90
+ valid: dict[str, str] = {}
91
+ for _, experiment in context.experiments:
92
+ for metric, metric_sql in state_eligible_metrics(experiment, metrics_by_name, context.root):
93
+ source_id, series_id = state_series_key(experiment, metric, metric_sql, context.root)
94
+ valid[source_id] = series_id
95
+
96
+ dropped = 0
97
+ children: list[str] = []
98
+ for source_id in tables.list_state_sources():
99
+ live_series = valid.get(source_id)
100
+ for series_id in tables.list_state_column_sets(source_id):
101
+ if series_id == live_series:
102
+ continue
103
+ reason = "no live metric" if live_series is None else "superseded definition"
104
+ children.append(
105
+ f"{'pruned' if execute else 'would prune'} state {source_id} / "
106
+ f"{series_id[:12]}… ({reason})"
107
+ )
108
+ dropped += 1
109
+ if execute:
110
+ tables.delete_state_series(source_id, series_id)
111
+ if children:
112
+ echo_tree("_ab_unit_state", children)
113
+ else:
114
+ echo_noop("_ab_unit_state", "no orphaned state series")
115
+ return dropped
116
+
117
+
68
118
  def _clean_orphaned_experiments(
69
119
  context: ProjectContext,
70
120
  tables: InternalTablesManager,
@@ -122,10 +172,17 @@ def run_clean(
122
172
  return
123
173
 
124
174
  touched, pruned = _clean_drift(context, tables, select, execute)
175
+ state_dropped = _clean_state_series(context, tables, execute)
125
176
  if execute:
126
- echo_done(f"Pruned {pruned} row(s) across {touched} experiment(s).")
177
+ summary = f"Pruned {pruned} row(s) across {touched} experiment(s)."
178
+ if state_dropped:
179
+ summary += f" Dropped {state_dropped} orphaned state series."
180
+ echo_done(summary)
127
181
  else:
128
- echo_done(f"Dry run: {touched} experiment(s) have orphaned series.")
182
+ summary = f"Dry run: {touched} experiment(s) have orphaned series."
183
+ if state_dropped:
184
+ summary += f" {state_dropped} orphaned state series."
185
+ echo_done(summary)
129
186
  except Exception as exc:
130
187
  echo_error("clean", str(exc))
131
188
  raise SystemExit(1) from exc
@@ -206,6 +206,9 @@ sql: |
206
206
  user_id,
207
207
  max(signed_up) AS signed_up, -- converted within the window?
208
208
  1 AS visits -- one trial per exposed unit
209
+ -- NOT day-additive (max() and a constant), hence no `state_additive: true`
210
+ -- above: summing per-day partials would count one trial PER ACTIVE DAY.
211
+ -- This metric is always computed over the whole window.
209
212
  FROM {{ data_database }}.example_signup_events
210
213
  {{ ab.exposed_units() }}
211
214
  GROUP BY variant, user_id
@@ -220,6 +223,12 @@ tags: [example]
220
223
  columns:
221
224
  variant: variant
222
225
  value: gross_usd
226
+ # Every role column is a plain sum() over the window, so per-day partials add
227
+ # up to the window total — that promise is what lets the `state` step
228
+ # materialize this metric's day moments (and `compute.incremental_reads`
229
+ # serve them). Leave it off for max()/avg()/uniq()/DISTINCT metrics,
230
+ # constants and ratios of aggregates; `abk verify-incremental` checks it.
231
+ state_additive: true
223
232
  sql: |
224
233
  {% import 'abkit_assignment.jinja' as ab %}
225
234
  -- CUPED needs no extra SQL: with covariate_lookback set on the method,
@@ -125,6 +125,7 @@ def run_run(
125
125
  workers: int,
126
126
  report_path: str | None = None,
127
127
  resync_cohort: bool = False,
128
+ cost_report: bool = False,
128
129
  ) -> None:
129
130
  try:
130
131
  parsed_steps = PipelineStep.parse(steps)
@@ -237,6 +238,17 @@ def run_run(
237
238
  f"cutoffs planned: {outcome.cutoffs_planned}",
238
239
  f"results written: {outcome.results_written}",
239
240
  ]
241
+ if PipelineStep.STATE in parsed_steps:
242
+ children.insert(1, f"state days: {outcome.state_days_materialized}")
243
+ if cost_report:
244
+ # m9 WP5: the evidence for the incremental-reads
245
+ # default-flip decision. Counters are always collected;
246
+ # this flag only prints them.
247
+ children.append("cost:")
248
+ for stage in ("load", "state", "compute"):
249
+ cost = outcome.stage_costs.get(stage)
250
+ if cost is not None:
251
+ children.append(f" {stage}: {cost.describe()}")
240
252
  srm_warnings = [w for w in outcome.warnings if "SRM" in w]
241
253
  other_warnings = [w for w in outcome.warnings if "SRM" not in w]
242
254
  echo_tree(outcome.experiment, children, warnings=other_warnings)
@@ -0,0 +1,160 @@
1
+ """Implementation of ``abk verify-incremental`` — the reconciliation gate (m9 WP5).
2
+
3
+ The command that makes flipping ``compute.incremental_reads`` a data-driven
4
+ decision instead of a leap of faith: for every already-computed cutoff of
5
+ every STATE-eligible comparison it loads the data through BOTH backends and
6
+ diffs the results at the project's rel-1e-9 tolerance
7
+ (``abkit/compute/reconcile.py`` is the engine; cumulative-intervals.md §4
8
+ asks for the WHOLE series, not just the latest cutoff).
9
+
10
+ Posture (deliberately unlike ``abk validate``): **read-only, lock-free.** It
11
+ persists nothing, so it never races a running pipeline for the ``_ab_tasks``
12
+ lock; it also costs strictly more than the run it checks, so it is an
13
+ explicit on-demand maintainer command and never part of ``abk run``. Any
14
+ divergence — or any experiment that fails outright — exits NON-ZERO.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import click
20
+
21
+ from abkit.cli._output import echo_done, echo_error, echo_noop, echo_tree
22
+ from abkit.cli.commands._context import ProjectContext, load_project_context
23
+ from abkit.compute.reconcile import DEFAULT_REL_TOL, ReconcileOutcome, reconcile_experiment
24
+ from abkit.config import select_experiments
25
+ from abkit.config.experiment_config import ExperimentConfig
26
+
27
+ #: how many diverging cutoffs to print in full before summarising the rest
28
+ _MAX_REPORTED_MISMATCHES = 10
29
+
30
+
31
+ def run_verify_incremental(
32
+ select: tuple[str, ...],
33
+ metric: str | None,
34
+ rel_tol: float,
35
+ profile: str | None,
36
+ ) -> None:
37
+ context = load_project_context(require_profiles=True)
38
+ click.echo(f"Project root: {context.root}")
39
+
40
+ selected, selection_warnings = select_experiments(context.root, select)
41
+ for warning in selection_warnings:
42
+ click.echo(click.style(f" ⚠ {warning}", fg="yellow"))
43
+ if not selected:
44
+ echo_done("Nothing selected.")
45
+ return
46
+
47
+ failed = 0
48
+ diverged = 0
49
+ examined = 0
50
+ for _, experiment in selected:
51
+ outcome = _verify_one(experiment, context, profile, metric, rel_tol)
52
+ examined += len(outcome.verdicts)
53
+ if outcome.error is not None:
54
+ failed += 1
55
+ elif not outcome.ok:
56
+ diverged += 1
57
+
58
+ summary = f"{len(selected)} experiment(s) verified"
59
+ if diverged:
60
+ summary += f", {diverged} DIVERGED"
61
+ if failed:
62
+ summary += f", {failed} FAILED"
63
+ echo_done(summary)
64
+ if diverged or failed:
65
+ raise SystemExit(1)
66
+ if examined == 0:
67
+ # Nothing was actually compared — a `--metric` that matches no
68
+ # comparison, a project with no eligible comparison, a series never
69
+ # run. Exiting 0 there reads as "verified" and is the one outcome
70
+ # this command must never fake (an R2 review finding).
71
+ echo_error(
72
+ "verify-incremental",
73
+ "nothing was verified — no eligible comparison had computed cutoffs"
74
+ + (f" matching --metric '{metric}'" if metric else "")
75
+ + ". Run `abk run` (with the `state` step) first, or widen the selection.",
76
+ )
77
+ raise SystemExit(1)
78
+
79
+
80
+ def _verify_one(
81
+ experiment: ExperimentConfig,
82
+ context: ProjectContext,
83
+ profile: str | None,
84
+ metric: str | None,
85
+ rel_tol: float,
86
+ ) -> ReconcileOutcome:
87
+ # Manager construction is INSIDE the guard: a per-experiment connection
88
+ # failure (a bad profile override, a warehouse hiccup) must fail that one
89
+ # experiment, not abort the sweep — the same contract the comment on the
90
+ # except clause promises (an R1 review finding).
91
+ manager = None
92
+ try:
93
+ from abkit.database.internal_tables import InternalTablesManager
94
+
95
+ manager = context.manager_factory(profile)()
96
+ tables = InternalTablesManager(manager)
97
+ if not tables.results_table_exists():
98
+ echo_noop(experiment.name, "no _ab_results yet — run `abk run` first")
99
+ return ReconcileOutcome(experiment=experiment.name)
100
+ outcome = reconcile_experiment(
101
+ experiment,
102
+ context.metrics_by_name,
103
+ context.project,
104
+ manager,
105
+ tables,
106
+ project_root=context.root,
107
+ metric_filter=metric,
108
+ rel_tol=rel_tol,
109
+ )
110
+ except Exception as exc: # noqa: BLE001 - one bad experiment must not kill the sweep
111
+ echo_error(experiment.name, f"{type(exc).__name__}: {exc}")
112
+ return ReconcileOutcome(experiment=experiment.name, error=str(exc))
113
+ finally:
114
+ if manager is not None:
115
+ manager.close()
116
+
117
+ _render(outcome, rel_tol)
118
+ return outcome
119
+
120
+
121
+ def _render(outcome: ReconcileOutcome, rel_tol: float) -> None:
122
+ matched = outcome.matched
123
+ unverified = outcome.unverified
124
+ mismatches = outcome.mismatches
125
+
126
+ children = [
127
+ f"cutoffs checked: {outcome.cutoffs_checked}",
128
+ f"pair comparisons: {len(matched)} matched at rel_tol={rel_tol:g}",
129
+ ]
130
+ if unverified:
131
+ # An unverified cutoff is NOT a pass — the incremental read fell back,
132
+ # so both sides ran the same code and agreeing proves nothing.
133
+ children.append(
134
+ f"unverified: {len(unverified)} (the incremental read fell back to "
135
+ "recompute — run the `state` step so the series covers them)"
136
+ )
137
+ if mismatches:
138
+ children.append(click.style(f"DIVERGED: {len(mismatches)} pair comparison(s)", fg="red"))
139
+ for verdict in mismatches[:_MAX_REPORTED_MISMATCHES]:
140
+ head = (
141
+ f" {verdict.metric} {verdict.name_1}/{verdict.name_2} "
142
+ f"@ {verdict.end_ts:%Y-%m-%d %H:%M:%S}"
143
+ )
144
+ children.append(click.style(head, fg="red"))
145
+ for diff in verdict.diffs:
146
+ children.append(click.style(f" {diff.describe()}", fg="red"))
147
+ if len(mismatches) > _MAX_REPORTED_MISMATCHES:
148
+ children.append(
149
+ click.style(f" … and {len(mismatches) - _MAX_REPORTED_MISMATCHES} more", fg="red")
150
+ )
151
+ for skip in outcome.skipped:
152
+ children.append(f"skipped {skip.metric}: {skip.reason}")
153
+
154
+ if not outcome.verdicts and not outcome.skipped:
155
+ children.append("nothing to reconcile")
156
+
157
+ echo_tree(outcome.experiment, children)
158
+
159
+
160
+ __all__ = ["DEFAULT_REL_TOL", "run_verify_incremental"]