ab-analysis-kit 0.2.0__tar.gz → 0.3.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 (169) hide show
  1. {ab_analysis_kit-0.2.0/ab_analysis_kit.egg-info → ab_analysis_kit-0.3.0}/PKG-INFO +7 -4
  2. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/README.md +6 -3
  3. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0/ab_analysis_kit.egg-info}/PKG-INFO +7 -4
  4. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/ab_analysis_kit.egg-info/SOURCES.txt +3 -0
  5. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/__init__.py +1 -1
  6. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/cli.md +7 -1
  7. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/experiments.md +17 -3
  8. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/explore.md +5 -0
  9. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/metrics.md +10 -5
  10. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/overview.md +8 -4
  11. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/plan.md +5 -2
  12. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/validate.md +12 -4
  13. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/skills/abk-explore/SKILL.md +6 -0
  14. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/skills/abk-new-metric/SKILL.md +6 -2
  15. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/skills/abk-plan/SKILL.md +6 -3
  16. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/skills/abk-setup-project/SKILL.md +5 -3
  17. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/skills/abk-validate/SKILL.md +8 -3
  18. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/explore.py +27 -2
  19. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/init.py +12 -3
  20. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/plan.py +70 -18
  21. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/run.py +12 -0
  22. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/validate.py +16 -4
  23. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/main.py +15 -2
  24. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/compute/recompute_backend.py +21 -2
  25. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/__init__.py +2 -0
  26. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/experiment_config.py +72 -0
  27. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/project_config.py +3 -1
  28. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/validator.py +24 -0
  29. ab_analysis_kit-0.3.0/abkit/core/exposure_counting.py +95 -0
  30. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_exposures.py +95 -53
  31. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/tables.py +12 -7
  32. ab_analysis_kit-0.3.0/abkit/loaders/__init__.py +47 -0
  33. ab_analysis_kit-0.3.0/abkit/loaders/exposure_copy.py +300 -0
  34. ab_analysis_kit-0.3.0/abkit/loaders/exposure_loader.py +96 -0
  35. ab_analysis_kit-0.3.0/abkit/loaders/exposure_source.py +290 -0
  36. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/loaders/query_template.py +53 -0
  37. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/loaders/templates/abkit_assignment.jinja +11 -6
  38. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/pipeline/_types.py +4 -0
  39. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/pipeline/driver.py +95 -30
  40. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/planning/__init__.py +1 -1
  41. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/planning/sizing.py +1 -1
  42. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/reporting/builder.py +39 -2
  43. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/server.py +8 -4
  44. ab_analysis_kit-0.2.0/abkit/loaders/__init__.py +0 -28
  45. ab_analysis_kit-0.2.0/abkit/loaders/exposure_loader.py +0 -121
  46. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/LICENSE +0 -0
  47. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/MANIFEST.in +0 -0
  48. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/ab_analysis_kit.egg-info/dependency_links.txt +0 -0
  49. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/ab_analysis_kit.egg-info/entry_points.txt +0 -0
  50. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/ab_analysis_kit.egg-info/requires.txt +0 -0
  51. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/ab_analysis_kit.egg-info/top_level.txt +0 -0
  52. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/__init__.py +0 -0
  53. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/_output.py +0 -0
  54. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/CLAUDE.section.md +0 -0
  55. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/methods.md +0 -0
  56. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/rules/project.md +0 -0
  57. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/skills/abk-feedback/SKILL.md +0 -0
  58. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/assets/claude/skills/abk-new-experiment/SKILL.md +0 -0
  59. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/__init__.py +0 -0
  60. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/_context.py +0 -0
  61. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/clean.py +0 -0
  62. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/init_claude.py +0 -0
  63. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/test_report.py +0 -0
  64. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/cli/commands/unlock.py +0 -0
  65. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/compute/__init__.py +0 -0
  66. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/discovery.py +0 -0
  67. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/method_config.py +0 -0
  68. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/metric_config.py +0 -0
  69. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/config/profile.py +0 -0
  70. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/core/__init__.py +0 -0
  71. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/core/interval.py +0 -0
  72. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/core/models.py +0 -0
  73. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/core/period_planner.py +0 -0
  74. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/__init__.py +0 -0
  75. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/_sql_manager.py +0 -0
  76. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/clickhouse_manager.py +0 -0
  77. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/__init__.py +0 -0
  78. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_aa_runs.py +0 -0
  79. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_base.py +0 -0
  80. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_experiments.py +0 -0
  81. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_maintenance.py +0 -0
  82. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_results.py +0 -0
  83. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_schema.py +0 -0
  84. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_tasks.py +0 -0
  85. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/_unit_state.py +0 -0
  86. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/internal_tables/manager.py +0 -0
  87. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/manager.py +0 -0
  88. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/mysql_manager.py +0 -0
  89. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/database/postgres_manager.py +0 -0
  90. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/loaders/metric_loader.py +0 -0
  91. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/__init__.py +0 -0
  92. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/base.py +0 -0
  93. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/branding.py +0 -0
  94. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/email.py +0 -0
  95. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/factory.py +0 -0
  96. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/mattermost.py +0 -0
  97. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/mock.py +0 -0
  98. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/slack.py +0 -0
  99. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/telegram.py +0 -0
  100. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/notify/webhook.py +0 -0
  101. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/pipeline/__init__.py +0 -0
  102. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/pipeline/analyze.py +0 -0
  103. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/pipeline/enrich.py +0 -0
  104. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/pipeline/readout.py +0 -0
  105. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/reporting/__init__.py +0 -0
  106. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/reporting/assets/report.js +0 -0
  107. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/reporting/calibration.py +0 -0
  108. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/reporting/html_report.py +0 -0
  109. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/__init__.py +0 -0
  110. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/accumulate.py +0 -0
  111. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/base.py +0 -0
  112. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/__init__.py +0 -0
  113. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/applier.py +0 -0
  114. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/bootstrap.py +0 -0
  115. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/ci.py +0 -0
  116. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/engine.py +0 -0
  117. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/paired_bootstrap.py +0 -0
  118. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/paired_post_normed_bootstrap.py +0 -0
  119. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/poisson_bootstrap.py +0 -0
  120. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/bootstrap/post_normed_bootstrap.py +0 -0
  121. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/correction.py +0 -0
  122. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/effects.py +0 -0
  123. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/exceptions.py +0 -0
  124. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/factory.py +0 -0
  125. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/parametric/__init__.py +0 -0
  126. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/parametric/cuped_ttest.py +0 -0
  127. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/parametric/paired_cuped_ttest.py +0 -0
  128. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/parametric/paired_ttest.py +0 -0
  129. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/parametric/ratio_delta.py +0 -0
  130. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/parametric/ttest.py +0 -0
  131. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/parametric/ztest.py +0 -0
  132. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/power.py +0 -0
  133. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/registry.py +0 -0
  134. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/result.py +0 -0
  135. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/rng.py +0 -0
  136. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/samples.py +0 -0
  137. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/sequential/__init__.py +0 -0
  138. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/sequential/apply.py +0 -0
  139. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/sequential/confidence_sequence.py +0 -0
  140. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/sequential/mixture.py +0 -0
  141. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/stats/srm.py +0 -0
  142. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/__init__.py +0 -0
  143. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/assets/explore.js +0 -0
  144. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/config_writer.py +0 -0
  145. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/html.py +0 -0
  146. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/payload.py +0 -0
  147. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/recompute.py +0 -0
  148. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/tuning/session.py +0 -0
  149. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/utils/__init__.py +0 -0
  150. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/utils/datetime_utils.py +0 -0
  151. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/utils/env_interpolation.py +0 -0
  152. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/utils/json_utils.py +0 -0
  153. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/__init__.py +0 -0
  154. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/_types.py +0 -0
  155. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/family.py +0 -0
  156. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/inject.py +0 -0
  157. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/load.py +0 -0
  158. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/panel.py +0 -0
  159. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/persistence.py +0 -0
  160. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/resample.py +0 -0
  161. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/result.py +0 -0
  162. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/run_id.py +0 -0
  163. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/runner.py +0 -0
  164. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/scoring.py +0 -0
  165. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/abkit/validate/vector_resample.py +0 -0
  166. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/pyproject.toml +0 -0
  167. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/requirements.txt +0 -0
  168. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/setup.cfg +0 -0
  169. {ab_analysis_kit-0.2.0 → ab_analysis_kit-0.3.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ab-analysis-kit
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,8 +76,9 @@ 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.2.0` (Alpha) — release-ready** (milestones **M1–M7**; `0.1.2` is the
80
- > latest published on PyPI, the `v0.2.0` tag/publish is the maintainer's pending step). The
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
81
82
  > statistical core, the declarative config / DB / pipeline layer, the explore cockpit +
82
83
  > self-contained reports, `abk validate` (now numpy-vectorized — minutes → sub-seconds),
83
84
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -90,7 +91,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
90
91
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
91
92
  ```
92
93
 
93
- (For `0.2.0` before its tag lands, install from source — `pip install -e ".[dev]"`.)
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:
96
+ `pip install -e ".[dev]"`.)
94
97
 
95
98
  `abk --version` and `abk --help` work with no database driver; you can even lint a
96
99
  config (`abk run --steps validate`) with no database at all. See the
@@ -11,8 +11,9 @@ 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.2.0` (Alpha) — release-ready** (milestones **M1–M7**; `0.1.2` is the
15
- > latest published on PyPI, the `v0.2.0` tag/publish is the maintainer's pending step). The
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
16
17
  > statistical core, the declarative config / DB / pipeline layer, the explore cockpit +
17
18
  > self-contained reports, `abk validate` (now numpy-vectorized — minutes → sub-seconds),
18
19
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -25,7 +26,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
25
26
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
26
27
  ```
27
28
 
28
- (For `0.2.0` before its tag lands, install from source — `pip install -e ".[dev]"`.)
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:
31
+ `pip install -e ".[dev]"`.)
29
32
 
30
33
  `abk --version` and `abk --help` work with no database driver; you can even lint a
31
34
  config (`abk run --steps validate`) with no database at all. See the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ab-analysis-kit
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,8 +76,9 @@ 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.2.0` (Alpha) — release-ready** (milestones **M1–M7**; `0.1.2` is the
80
- > latest published on PyPI, the `v0.2.0` tag/publish is the maintainer's pending step). The
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
81
82
  > statistical core, the declarative config / DB / pipeline layer, the explore cockpit +
82
83
  > self-contained reports, `abk validate` (now numpy-vectorized — minutes → sub-seconds),
83
84
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -90,7 +91,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
90
91
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
91
92
  ```
92
93
 
93
- (For `0.2.0` before its tag lands, install from source — `pip install -e ".[dev]"`.)
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:
96
+ `pip install -e ".[dev]"`.)
94
97
 
95
98
  `abk --version` and `abk --help` work with no database driver; you can even lint a
96
99
  config (`abk run --steps validate`) with no database at all. See the
@@ -53,6 +53,7 @@ abkit/config/profile.py
53
53
  abkit/config/project_config.py
54
54
  abkit/config/validator.py
55
55
  abkit/core/__init__.py
56
+ abkit/core/exposure_counting.py
56
57
  abkit/core/interval.py
57
58
  abkit/core/models.py
58
59
  abkit/core/period_planner.py
@@ -75,7 +76,9 @@ abkit/database/internal_tables/_tasks.py
75
76
  abkit/database/internal_tables/_unit_state.py
76
77
  abkit/database/internal_tables/manager.py
77
78
  abkit/loaders/__init__.py
79
+ abkit/loaders/exposure_copy.py
78
80
  abkit/loaders/exposure_loader.py
81
+ abkit/loaders/exposure_source.py
79
82
  abkit/loaders/metric_loader.py
80
83
  abkit/loaders/query_template.py
81
84
  abkit/loaders/templates/abkit_assignment.jinja
@@ -10,7 +10,7 @@ from __future__ import annotations
10
10
 
11
11
  from typing import Any
12
12
 
13
- __version__ = "0.2.0"
13
+ __version__ = "0.3.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.
@@ -70,7 +70,7 @@ to refresh this context.
70
70
 
71
71
  ```bash
72
72
  abk run [--select <exp>] [--exclude <sel>] [--steps validate,plan,load,compute] \
73
- [--from TS] [--to TS] [--full-refresh] [--workers N] \
73
+ [--from TS] [--to TS] [--full-refresh] [--resync-cohort] [--workers N] \
74
74
  [--report [PATH]] [--force] [--profile NAME]
75
75
  ```
76
76
 
@@ -88,6 +88,12 @@ are (re)computed, so re-running is idempotent.
88
88
  use with `--full-refresh`.
89
89
  - `--full-refresh` — re-open already-computed cutoffs in `[--from, --to)` and
90
90
  recompute them. Use after changing a metric query or a method param.
91
+ - `--resync-cohort` — copy mode only (`assignment.cohort_copy.enabled: true`):
92
+ delete the persisted `_ab_exposures` copy and rebuild it from the experiment
93
+ start through the same incremental engine — the recovery for late-arriving/
94
+ corrected assignment rows the watermark cannot heal. A documented no-op in
95
+ the direct (no-copy) default. Distinct from `--full-refresh` (results-window
96
+ recompute) — the two never overload each other.
91
97
  - `--workers N` (default 1) — worker threads across experiments (each gets its own
92
98
  DB connection).
93
99
  - `--report [PATH]` — after the run, emit a self-contained HTML readout per
@@ -31,6 +31,11 @@ assignment: # READ-ONLY exposure source — abkit never ran
31
31
  added_filters: "" # optional extra SQL fragment (must start with AND)
32
32
  variants: [control, treatment] # FIRST is control (name_1); >= 2, unique
33
33
  expected_split: {control: 0.5, treatment: 0.5} # must cover every variant, sum to 1.0; drives SRM
34
+ # cohort_copy: # opt-in (default OFF): persist an incremental,
35
+ # enabled: true # append-only _ab_exposures copy instead of
36
+ # update_column: exposure_ts # re-reading the live source every invocation
37
+ # batch_interval: 1d # (grid-anchored closed-interval batches;
38
+ # maturity_delay: 0 # batch_intervals_per_round_trip: 30 — intervals, not rows)
34
39
 
35
40
  alpha: 0.05 # experiment-level significance (unset -> project default)
36
41
  correction: bonferroni # none | bonferroni | benjamini_hochberg (unset -> project default)
@@ -68,9 +73,18 @@ comparisons: # required — each binds one library metric to
68
73
  line and no verdict is trusted. Check SRM before believing any effect; fix the
69
74
  assignment query or randomization first.
70
75
  - The assignment SQL is a **read-only** source: it SELECTs `unit_key`, `variant`,
71
- and an exposure timestamp — abkit persists it once per run into `_ab_exposures`
72
- and never randomizes. Use `added_filters` (must start with `AND`) as the only
73
- escape hatch for extra WHERE conditions.
76
+ and an exposure timestamp — abkit never randomizes. By default
77
+ (`assignment.cohort_copy` unset) nothing is persisted: every
78
+ `abk run`/`plan`/`validate`/`explore` invocation re-renders and validates the
79
+ assignment SQL live and metric queries join a deduping subquery over it (the
80
+ no-copy cost/freshness tradeoff — never a stale row, at a render+validate
81
+ query each time). Set `assignment.cohort_copy.enabled: true` to persist an
82
+ append-only incremental copy into `_ab_exposures` instead (worth it for a
83
+ heavy multi-join or a mutating source; in copy mode the assignment SQL must
84
+ reference `{{ ab_added_filters }}` — the copy engine injects batch bounds
85
+ through it, and `abk run --resync-cohort` rebuilds a poisoned copy). Use
86
+ `added_filters` (must start with `AND`) as the only escape hatch for extra
87
+ WHERE conditions.
74
88
 
75
89
  ## Cumulative window, cadence & data_lag
76
90
 
@@ -23,6 +23,11 @@ name a configured **comparison** of that experiment (default: the main metric).
23
23
  — it never runs the pipeline, takes **no pipeline lock**, and never writes to
24
24
  the warehouse. Run `abk run --select <exp>` **first**: no computed rows ⇒ a
25
25
  friendly noop telling you to run first.
26
+ - **A broken live assignment source blocks the cockpit too** (M8): at
27
+ session-load explore resolves the cohort through the same
28
+ `build_cohort_backend` factory as `abk run` (the SRM chip's count source) —
29
+ in the default no-copy mode a source that empties or corrupts fails with a
30
+ clean, actionable error naming the fix, never a raw traceback.
26
31
  - Freshness is whatever the last `abk run` produced; the header shows the latest
27
32
  `end_ts` / watermark so staleness is visible. It is a **retuning** surface, not
28
33
  a live monitor.
@@ -82,15 +82,20 @@ live there once, so metric SQL describes only its own aggregation:
82
82
  {% import 'abkit_assignment.jinja' as ab %}
83
83
  ```
84
84
 
85
- - `{{ ab.exposed_units() }}` — `INNER JOIN`s the persisted `_ab_exposures`
86
- cohort (loaded once per run, deduped per dialect), and applies both the coarse
87
- `event_date` predicate and the precise half-open `event_time` window. Optional
88
- args override the fact-side column names: `ab.exposed_units('dt', 'ts')`.
85
+ - `{{ ab.exposed_units() }}` — `INNER JOIN`s the ONE `ab_cohort_source`
86
+ builtin: by default (`assignment.cohort_copy` unset) a live deduping subquery
87
+ over the rendered assignment SQL (re-validated every invocation); with
88
+ `cohort_copy.enabled: true` the persisted, append-only-copied `_ab_exposures`
89
+ table (`FINAL` on ClickHouse). Metric authors never choose between the two.
90
+ Either mode applies both the coarse `event_date` predicate and the precise
91
+ half-open `event_time` window. Optional args override the fact-side column
92
+ names: `ab.exposed_units('dt', 'ts')`.
89
93
  - `{{ ab.variant_col() }}` — the arm label from the cohort (project it `AS
90
94
  variant` and reference it in `columns.variant`).
91
95
  - `{{ ab.stratum_col() }}` — the stratum label, when stratifying.
92
96
 
93
- Config-lint asserts the rendered SQL joins `_ab_exposures`; a metric authored
97
+ Config-lint asserts the rendered SQL joins the cohort through the macro
98
+ (present identically in both cohort modes); a metric authored
94
99
  without the macro fails. Never hand-roll the assignment join or the window
95
100
  filter. `{{ data_database }}` is the data-location built-in on **every** dialect
96
101
  (on Postgres it resolves to the profile's `data_schema` value); there is no
@@ -25,9 +25,13 @@ pointing a **metric** (a separate reusable YAML + SQL) at a statistical
25
25
 
26
26
  Every `abk run` executes three stages per experiment:
27
27
 
28
- 1. **load** — persists the assignment cohort ONCE into `_ab_exposures`, then runs
29
- each metric's SQL against the source DB over the cumulative window (the macro
30
- joins the cohort). One row per unit in, additive aggregates out.
28
+ 1. **load** — resolves the assignment cohort once per run: by default
29
+ (`assignment.cohort_copy.enabled: false`) the assignment SQL is re-rendered
30
+ and validated live and nothing is persisted; with `cohort_copy.enabled:
31
+ true` an append-only, watermark-resumed incremental copy lands in
32
+ `_ab_exposures`. Then each metric's SQL runs against the source DB over the
33
+ cumulative window (the macro joins the cohort either way). One row per unit
34
+ in, additive aggregates out.
31
35
  2. **compute** — runs the configured statistical method (t/z-test, CUPED,
32
36
  ratio-delta, bootstrap) at each planned cutoff, gates SRM, and writes rows to
33
37
  `_ab_results` (the BI contract). Idempotent: already-computed cutoffs are
@@ -64,7 +68,7 @@ profile's `internal_database` / `internal_schema`, separate from the
64
68
  | Table | Holds |
65
69
  |---|---|
66
70
  | `_ab_results` | **The BI contract.** One row per `(experiment, metric, variant-pair, method_config_id, end_ts)` cumulative cutoff: effect, CI, p-value, per-arm stats, SRM flag, `insufficient_data`, `ci_kind`, `is_horizon`. Point BI here. |
67
- | `_ab_exposures` | The persisted assignment cohort (unit → variant → exposure_ts), loaded once per run; joined by every metric query and the SRM count source. |
71
+ | `_ab_exposures` | **Optional** — the persisted assignment cohort copy (unit → variant → exposure_ts), created/written only when `assignment.cohort_copy.enabled: true` (an append-only incremental copy; a routine run never deletes — `--resync-cohort` is the one exception). On the default no-copy path the table does not exist: metric queries and the SRM counts read the live assignment source instead. |
68
72
  | `_ab_experiments` | Informational experiment catalog (descriptions, variants, split, alpha, cadence, tags) for BI joins; the pipeline never reads it back for decisions. |
69
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`. |
70
74
  | `_ab_tasks` | Pipeline run/lock bookkeeping — the atomic per-experiment lock (`abk unlock` clears a stale one). |
@@ -46,7 +46,7 @@ Without either, that comparison is reported **un-sizable — not guessed**. The
46
46
  | `--power 0.8` | Target power. Default: the project statistics default. |
47
47
  | `--alpha 0.05` | Experiment-level alpha *before* correction; the two-tier scheme still divides it. Default: experiment/project alpha. |
48
48
  | `--baseline <spec>` | Greenfield baseline moments (repeatable; see above). |
49
- | `--arrival-rate <units/day>` | Total units/day across arms, for the **runtime** (days-to-required-N) + always-valid **ASN** estimates. Default: derived read-only from `_ab_exposures`; without arrival data both are skipped. Must be `> 0`. |
49
+ | `--arrival-rate <units/day>` | Total units/day across arms, for the **runtime** (days-to-required-N) + always-valid **ASN** estimates. Default: derived read-only from the cohort source — the persisted `_ab_exposures` copy under `assignment.cohort_copy.enabled`, otherwise (the default) a fresh snapshot of the live assignment source re-executed at invocation time (the documented no-copy cost/freshness tradeoff); without arrival data both are skipped. Must be `> 0`. |
50
50
  | `--profile` | Profile name (default: `profiles.yml` `default_profile`). |
51
51
 
52
52
  ## What it refuses (honest, never invented math)
@@ -91,7 +91,10 @@ the false-positive rate (enable sequential or coarsen the cadence).
91
91
 
92
92
  The footer look-count + cost-shape line is the pre-launch timing/cost companion.
93
93
  **Runtime and ASN** ship too: given a **unit-arrival rate** — derived read-only from
94
- `_ab_exposures` (distinct units per observed day, whole-cohort window, split to the
94
+ the cohort source (the persisted `_ab_exposures` copy under
95
+ `assignment.cohort_copy.enabled: true`, otherwise a live re-render + re-validation
96
+ of the assignment SQL at invocation time — the default no-copy cost/freshness
97
+ tradeoff; distinct units per observed day, whole-cohort window, split to the
95
98
  control arm) or supplied with `--arrival-rate <units/day>` — each sizable comparison
96
99
  also reports **runtime** (`days-to-required-N = required_n / rate` plus the horizon
97
100
  length) and, for a `sequential.enabled`, sequential-eligible comparison, the **ASN**
@@ -130,8 +130,13 @@ abk validate --select <exp> [--method <m>]... [--metric <m>] [--iterations N] \
130
130
  serialize behind nightly runs.
131
131
  - **Exits non-zero** on any cell/harness failure; `--report` is the one best-effort
132
132
  exception (a bake failure yellow-skips, never fails validation).
133
- - Reads the experiment's persisted cohort — run `abk run --select <exp>` at least
134
- once first so there is data to resample.
133
+ - Resolves the cohort itself via `build_cohort_backend` each invocation — in the
134
+ default no-copy mode it renders and validates the LIVE assignment source
135
+ directly (no prior `abk run` needed for the cohort); with
136
+ `assignment.cohort_copy.enabled: true` it reads the persisted,
137
+ incrementally-copied `_ab_exposures` table, so a prior copy-mode run must have
138
+ populated it. Either way the metric event data must already exist in the
139
+ source DB.
135
140
 
136
141
  ## Reading the matrix — the three classic failures
137
142
 
@@ -217,8 +222,11 @@ A/A is the expensive corner**. So:
217
222
  - **Not a config lint.** `abk validate` = the A/A statistical matrix; `abk run
218
223
  --steps validate` = the config/schema/SQL gate. Different purpose, different lock,
219
224
  different stage names — never conflate.
220
- - **Run the pipeline first.** validate resamples the experiment's persisted cohort —
221
- `abk run --select <exp>` must have persisted data or there is nothing to split.
225
+ - **The cohort is resolved live, not read from a prior run.** In the no-copy
226
+ default validate re-renders/validates the live assignment source itself, so
227
+ `abk run` is not a prerequisite for the cohort (the metric event data must
228
+ still exist). Only in copy mode (`assignment.cohort_copy.enabled: true`) does
229
+ it read what previous runs copied into `_ab_exposures`.
222
230
  - **Peeking FPR is the hazard, not the verdict.** It deliberately measures the
223
231
  optional-stopping trap the readout's stabilization rule defends against; a high
224
232
  peeking FPR on a low single-look FPR means "enable `sequential`", not "the method
@@ -40,6 +40,12 @@ need an experiment that has run at least once:
40
40
  - **A project root** contains `abkit_project.yml` and `profiles.yml`. If
41
41
  `profiles.yml` is still the `abk init` placeholder, set up the DB first with
42
42
  **`abk-setup-project`**.
43
+ - **A broken assignment source blocks the cockpit too** (M8): at session-load
44
+ explore re-validates the live assignment SQL (the SRM chip's count source,
45
+ same `build_cohort_backend` factory as `abk run`); a validation failure
46
+ raises a clean error naming the fix — repair the assignment SQL, or set
47
+ `assignment.cohort_copy.enabled: true` to explore the last persisted cohort
48
+ instead of the live source.
43
49
  - **No experiment or metric yet?** Hand off to **`abk-new-experiment`** (and
44
50
  **`abk-new-metric`**) to design the config first — never fabricate YAML/SQL here.
45
51
  - **Compute a series** (more cutoffs ⇒ a richer stabilization curve):
@@ -86,8 +86,12 @@ hand-roll the assignment join.
86
86
  {% import 'abkit_assignment.jinja' as ab %}
87
87
  ```
88
88
 
89
- - `{{ ab.exposed_units() }}` — `INNER JOIN`s the persisted `_ab_exposures`
90
- cohort and applies the window + exposure filters and dedup. Override fact-side
89
+ - `{{ ab.exposed_units() }}` — `INNER JOIN`s the assignment cohort through the
90
+ `ab_cohort_source` builtin and applies the window + exposure filters and
91
+ dedup. By default (no `cohort_copy`) that is a live deduping subquery over
92
+ the assignment SQL — no `_ab_exposures` table involved; with
93
+ `assignment.cohort_copy.enabled: true` it joins the persisted copy instead.
94
+ Metric authors never choose between the two. Override fact-side
91
95
  column names with args if needed: `ab.exposed_units('dt', 'ts')`.
92
96
  - `{{ ab.variant_col() }}` — the arm label (project it `AS variant`).
93
97
  - `{{ ab.stratum_col() }}` — the stratum label, only when stratifying.
@@ -59,7 +59,7 @@ Flags (confirm the live set with `abk plan --help`):
59
59
  | `--power` | Target power (default: `statistics.power`, typically 0.8) |
60
60
  | `--alpha` | Experiment-level significance **before** correction (default: experiment/project alpha) |
61
61
  | `--baseline` | Baseline moments for a metric with no data (repeatable — Step 2) |
62
- | `--arrival-rate` | Total units/day across arms, for the runtime (days-to-N) + always-valid ASN estimates (default: derived read-only from `_ab_exposures`; must be `> 0`) |
62
+ | `--arrival-rate` | Total units/day across arms, for the runtime (days-to-N) + always-valid ASN estimates (default: derived read-only from the cohort source — the persisted `_ab_exposures` copy in copy mode, otherwise a fresh re-execution of the live assignment SQL at invocation time; must be `> 0`) |
63
63
  | `--profile` | Profile name (default: `profiles.yml` `default_profile`) |
64
64
 
65
65
  `--mde` and `--alpha` are in the comparison's own units: a `relative` test type reads
@@ -144,8 +144,11 @@ this; tell the user the true requirement is lower.
144
144
 
145
145
  `abk plan` is planning-only. Sizing (required-N / MDE / power) is the core; **runtime /
146
146
  ASN** ship alongside it. If the user asks "how long", `abk plan` reports **runtime**
147
- (days-to-required-N) from a unit-arrival rate — derived read-only from `_ab_exposures`
148
- or supplied with `--arrival-rate <units/day>` — and, for a `sequential.enabled`,
147
+ (days-to-required-N) from a unit-arrival rate — derived read-only by re-executing
148
+ the cohort source at invocation time (the live assignment SQL in the default
149
+ no-copy mode — the documented cost/freshness tradeoff — or the persisted
150
+ `_ab_exposures` copy in copy mode) or supplied with `--arrival-rate <units/day>` —
151
+ and, for a `sequential.enabled`,
149
152
  sequential-eligible comparison, the **ASN** (the always-valid design's average sample
150
153
  number: expected stopping N under H1/H0, horizon-capped). Without an arrival rate both
151
154
  are SKIPPED with a reason (never invented); a fixed-horizon/resampling design shows
@@ -83,9 +83,11 @@ profile already models this pattern.
83
83
  Point **both** at the user's real databases (the placeholder ships examples):
84
84
 
85
85
  - `internal_database` — a dedicated database for abkit's own `_ab_*` tables
86
- (`_ab_results`, `_ab_exposures`, `_ab_tasks`, `_ab_aa_runs`), created
87
- automatically on first run. Keep it **separate** from analytics data, e.g.
88
- `abkit_internal`.
86
+ (`_ab_results`, `_ab_tasks`, `_ab_aa_runs`), created automatically on first
87
+ run. `_ab_exposures` is created there too, but only when the experiment sets
88
+ `assignment.cohort_copy.enabled: true` — the (default) no-copy mode never
89
+ writes it; metric SQL joins the live assignment source instead. Keep it
90
+ **separate** from analytics data, e.g. `abkit_internal`.
89
91
  - `data_database` — where the source/fact tables your metric queries read from
90
92
  live (and where the seed dataset loads).
91
93
 
@@ -36,9 +36,14 @@ schema, the sequential/composed columns, budget-band resolution).
36
36
  - A project root has `abkit_project.yml`; `profiles.yml` must point at the real
37
37
  warehouse (if it's still the `abk init` placeholder, use **`abk-setup-project`**
38
38
  first).
39
- - **The pipeline must have run at least once.** validate resamples the
40
- experiment's **persisted** cohort — if nothing is loaded there is nothing to
41
- split. Run `abk run --select <exp>` first if needed.
39
+ - **In the (default) no-copy mode no prior `abk run` is required** — validate
40
+ re-renders and validates the live assignment source itself (the same
41
+ `build_cohort_backend` factory every command uses) and splits it in memory;
42
+ an empty/not-yet-launched cohort fails loudly with a reason. Only in copy
43
+ mode (`assignment.cohort_copy.enabled: true`) does validate read the
44
+ persisted `_ab_exposures` copy, so `abk run --select <exp>` must have
45
+ populated it first. The metric event data must exist in the source DB either
46
+ way.
42
47
 
43
48
  ## Step 1 — Run validate
44
49
 
@@ -48,8 +48,9 @@ def run_explore(
48
48
  no_serve: bool,
49
49
  no_open: bool,
50
50
  ) -> None:
51
- from abkit.compute.recompute_backend import RecomputeBackend
51
+ from abkit.core.period_planner import generate_grid
52
52
  from abkit.database.internal_tables import InternalTablesManager
53
+ from abkit.loaders.exposure_source import ExposureLoadError, build_cohort_backend
53
54
  from abkit.reporting import build_report_payload
54
55
  from abkit.tuning import (
55
56
  RecomputeEngine,
@@ -133,7 +134,27 @@ def run_explore(
133
134
  metric_sql_by_name = {
134
135
  name: metrics_by_name[name].get_query_text(context.root) for name in configured_metrics
135
136
  }
136
- backend = RecomputeBackend(manager, experiment)
137
+ # the WP4 factory (the same grid parameters load_session enumerates):
138
+ # copy mode joins the persisted cohort, direct mode the live source
139
+ grid = generate_grid(
140
+ experiment.start_date,
141
+ experiment.end_date,
142
+ experiment.cadence_segments(),
143
+ tz=experiment.timezone,
144
+ limit=context.project.limits.max_looks,
145
+ )
146
+ try:
147
+ backend, cohort_snapshot = build_cohort_backend(manager, experiment, context.root, grid)
148
+ except ExposureLoadError as exc:
149
+ # direct mode validates the LIVE source at startup — a source
150
+ # that emptied or corrupted since the last run must fail the
151
+ # house way (ClickException → clean non-zero exit), never a
152
+ # raw traceback (the module-docstring rule)
153
+ raise click.ClickException(
154
+ f"cohort source failed validation: {exc} — fix the assignment "
155
+ "source, or set assignment.cohort_copy.enabled to explore the "
156
+ "last persisted cohort"
157
+ ) from exc
137
158
  session = load_session(
138
159
  experiment,
139
160
  metrics_by_name,
@@ -150,6 +171,10 @@ def run_explore(
150
171
  project=context.project,
151
172
  metric_configs=metrics_by_name,
152
173
  generated_at=now_utc_naive().strftime("%Y-%m-%d %H:%M UTC"),
174
+ # direct mode: reuse the factory's validated snapshot for the SRM
175
+ # chip (no second source execution); copy mode reads the persisted
176
+ # table inside the builder (cohort_snapshot is None)
177
+ cohort_counts=None if cohort_snapshot is None else cohort_snapshot.counts,
153
178
  )
154
179
  payload = build_explore_payload(session, engine, report_payload)
155
180
  if metric is not None:
@@ -163,6 +163,11 @@ assignment: # READ-ONLY exposure source — abkit never randomiz
163
163
  query_file: sql/example_assignment.sql
164
164
  variants: [control, treatment] # FIRST is control (name_1)
165
165
  expected_split: {control: 0.5, treatment: 0.5} # drives the SRM gate
166
+ # cohort_copy: # opt-in: persist an incremental, append-only
167
+ # enabled: true # _ab_exposures copy instead of re-reading the
168
+ # update_column: exposure_ts # live source every run — worth it for a
169
+ # batch_interval: 1d # heavy multi-join or a mutating source; see
170
+ # maturity_delay: 0 # docs/guides/experiments.md ("Persisting the cohort")
166
171
 
167
172
  alpha: 0.05
168
173
  correction: bonferroni # two-tier: main metric vs the rest (inspectable at run)
@@ -193,7 +198,8 @@ sql: |
193
198
  -- The window is PINNED-START / MOVING-END: ab_start_date never moves,
194
199
  -- ab_end_ts advances per cutoff — so every run aggregates from experiment
195
200
  -- start through the cutoff (the stabilization chart's points).
196
- -- ab.exposed_units() joins the persisted cohort (_ab_exposures), applies
201
+ -- ab.exposed_units() joins the assignment cohort (the LIVE source by
202
+ -- default, the persisted _ab_exposures copy under cohort_copy), applies
197
203
  -- the window + exposure filters and dedup — never re-implement those.
198
204
  SELECT
199
205
  {{ ab.variant_col() }} AS variant,
@@ -230,8 +236,11 @@ sql: |
230
236
 
231
237
  ASSIGNMENT_SQL = """\
232
238
  -- The assignment (exposure) source: one row per unit with its variant and
233
- -- first-exposure timestamp. abkit persists this ONCE per run into
234
- -- _ab_exposures; every metric query joins that cohort via the packaged macro.
239
+ -- first-exposure timestamp. By default abkit never persists this — every
240
+ -- metric query joins the LIVE assignment cohort via the packaged macro.
241
+ -- Set assignment.cohort_copy.enabled: true in the experiment YAML to persist
242
+ -- an incremental, append-only copy into _ab_exposures instead (worth it for
243
+ -- a heavy multi-join or a mutating source).
235
244
  SELECT
236
245
  user_id,
237
246
  variant,
@@ -15,7 +15,9 @@ conservative upper bound. A genuine harness failure (bad selection / ``--baselin
15
15
  warehouse error) exits non-zero; a by-design refusal does not.
16
16
 
17
17
  Runtime / ASN (WP-A, m6-implementation-plan.md): each sizable comparison also reports
18
- days-to-required-N from a unit-arrival rate (derived read-only from ``_ab_exposures`` or
18
+ days-to-required-N from a unit-arrival rate (derived read-only from the cohort source —
19
+ the persisted ``_ab_exposures`` copy under ``assignment.cohort_copy.enabled``, otherwise
20
+ a fresh snapshot of the live assignment source re-executed at invocation time — or
19
21
  supplied via ``--arrival-rate``) and, for a ``sequential.enabled`` design, the
20
22
  always-valid average sample number. No arrival data ⇒ runtime SKIPPED, never invented.
21
23
  """
@@ -163,7 +165,9 @@ def _plan_one(
163
165
  try:
164
166
  tables = InternalTablesManager(manager)
165
167
  has_results = tables.results_table_exists()
166
- rate_control, rate_source = _resolve_arrival_rate(experiment, arrival_rate, tables)
168
+ rate_control, rate_source = _resolve_arrival_rate(
169
+ experiment, arrival_rate, tables, manager, context.root, grid
170
+ )
167
171
  for comparison in comparisons:
168
172
  plans.append(
169
173
  _plan_comparison(
@@ -186,14 +190,19 @@ def _plan_one(
186
190
  _emit_plan(experiment, project, alphas, power, looks, grid, rows_per_refresh, plans)
187
191
 
188
192
 
189
- def _resolve_arrival_rate(experiment, override: float | None, tables) -> tuple[float | None, str]:
193
+ def _resolve_arrival_rate(
194
+ experiment, override: float | None, tables, manager, project_root, grid
195
+ ) -> tuple[float | None, str]:
190
196
  """Control-arm units/day for the runtime/ASN axis (WP-A), or ``(None, reason)``.
191
197
 
192
198
  ``--arrival-rate`` is total traffic across all arms → split to the control arm by the
193
199
  normalized ``expected_split`` (so it lines up with required-N, which is per control
194
- arm). Absent an override the rate is derived read-only from ``_ab_exposures``; a
195
- never-run project (no exposures) or a backfilled cohort spanning ~one instant yields
196
- no rate — runtime is then SKIPPED with a reason, never guessed.
200
+ arm). Absent an override the rate is derived read-only from the cohort source: the
201
+ persisted ``_ab_exposures`` copy under ``assignment.cohort_copy.enabled``, otherwise
202
+ (the m8 WP4 no-copy default) a fresh in-memory snapshot of the live assignment
203
+ source — re-executed at invocation time, the documented cost/freshness tradeoff.
204
+ An empty cohort or a backfilled cohort spanning ~one instant yields no rate —
205
+ runtime is then SKIPPED with a reason, never guessed.
197
206
  """
198
207
  variants = experiment.assignment.variants
199
208
  control = variants[0]
@@ -208,21 +217,64 @@ def _resolve_arrival_rate(experiment, override: float | None, tables) -> tuple[f
208
217
  override * control_share,
209
218
  f"--arrival-rate {override:g}/day → {control_share:.0%} control",
210
219
  )
211
- if not tables.exposures_table_exists():
212
- return None, "no _ab_exposures yet — pass --arrival-rate <units/day>"
213
- arrivals = tables.get_arrival_rate(experiment.name, list(variants))
214
- if arrivals is None:
215
- # get_arrival_rate returns None for BOTH an empty cohort and a one-instant window;
216
- # disambiguate so the skip reason is truthful (a never-run experiment in a project
217
- # where OTHER experiments have run reaches here with zero rows for this one).
218
- if tables.count_exposures(experiment.name) == 0:
219
- return None, "no exposures for this experiment yet — pass --arrival-rate <units/day>"
220
- return None, "arrival rate underivable (exposures span ~one instant) — pass --arrival-rate"
221
- rates, window_days = arrivals
220
+
221
+ if experiment.assignment.cohort_copy.enabled:
222
+ # copy mode: the persisted-table derivation, unchanged
223
+ if not tables.exposures_table_exists():
224
+ return None, "no _ab_exposures yet — pass --arrival-rate <units/day>"
225
+ arrivals = tables.get_arrival_rate(experiment.name, list(variants))
226
+ if arrivals is None:
227
+ # get_arrival_rate returns None for BOTH an empty cohort and a one-instant
228
+ # window; disambiguate so the skip reason is truthful (a never-run experiment
229
+ # in a project where OTHER experiments have run reaches here with zero rows).
230
+ if tables.count_exposures(experiment.name) == 0:
231
+ return (
232
+ None,
233
+ "no exposures for this experiment yet — pass --arrival-rate <units/day>",
234
+ )
235
+ return (
236
+ None,
237
+ "arrival rate underivable (exposures span ~one instant) — pass --arrival-rate",
238
+ )
239
+ rates, window_days = arrivals
240
+ source = f"_ab_exposures over {window_days:.1f} observed days"
241
+ else:
242
+ # direct mode (m8 WP4): snapshot the live source; the SAME rate arithmetic
243
+ # through core.exposure_counting — the two modes can never drift. A genuine
244
+ # contract violation (missing columns, cross-variant) still fails the plan
245
+ # loudly; only the not-yet-launched empty source politely skips.
246
+ from abkit.core.exposure_counting import arrival_rate as shared_arrival_rate
247
+ from abkit.core.exposure_counting import bucket_timestamps
248
+ from abkit.loaders.exposure_source import (
249
+ EmptyCohortError,
250
+ render_assignment_sql,
251
+ validate_and_snapshot,
252
+ )
253
+
254
+ try:
255
+ rendered = render_assignment_sql(manager, experiment, project_root, grid)
256
+ snapshot = validate_and_snapshot(manager, experiment, rendered)
257
+ except EmptyCohortError:
258
+ return (
259
+ None,
260
+ "assignment source returned no rows yet — pass --arrival-rate <units/day>",
261
+ )
262
+ per_variant = bucket_timestamps(
263
+ ((variant, ts) for variant, ts, _ in snapshot.by_unit.values()), list(variants)
264
+ )
265
+ arrivals = shared_arrival_rate(per_variant, list(variants))
266
+ if arrivals is None:
267
+ return (
268
+ None,
269
+ "arrival rate underivable (exposures span ~one instant) — pass --arrival-rate",
270
+ )
271
+ rates, window_days = arrivals
272
+ source = f"assignment source over {window_days:.1f} observed days"
273
+
222
274
  rate_control = rates.get(control, 0.0)
223
275
  if rate_control <= 0.0:
224
276
  return None, "no control-arm exposures — pass --arrival-rate <units/day>"
225
- return rate_control, f"_ab_exposures over {window_days:.1f} observed days"
277
+ return rate_control, source
226
278
 
227
279
 
228
280
  def _plan_comparison(