ab-analysis-kit 0.6.1__tar.gz → 0.6.2__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 (178) hide show
  1. {ab_analysis_kit-0.6.1/ab_analysis_kit.egg-info → ab_analysis_kit-0.6.2}/PKG-INFO +11 -9
  2. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/README.md +10 -8
  3. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2/ab_analysis_kit.egg-info}/PKG-INFO +11 -9
  4. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/__init__.py +1 -1
  5. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/plan.md +11 -5
  6. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/skills/abk-plan/SKILL.md +2 -1
  7. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/plan.py +183 -5
  8. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/main.py +9 -1
  9. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/compute/recompute_backend.py +45 -1
  10. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/exposure_source.py +23 -0
  11. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/query_template.py +24 -1
  12. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/templates/abkit_assignment.jinja +5 -1
  13. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/power.py +3 -3
  14. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/LICENSE +0 -0
  15. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/MANIFEST.in +0 -0
  16. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/ab_analysis_kit.egg-info/SOURCES.txt +0 -0
  17. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/ab_analysis_kit.egg-info/dependency_links.txt +0 -0
  18. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/ab_analysis_kit.egg-info/entry_points.txt +0 -0
  19. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/ab_analysis_kit.egg-info/requires.txt +0 -0
  20. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/ab_analysis_kit.egg-info/top_level.txt +0 -0
  21. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/__init__.py +0 -0
  22. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/_output.py +0 -0
  23. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/CLAUDE.section.md +0 -0
  24. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/cli.md +0 -0
  25. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/experiments.md +0 -0
  26. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/explore.md +0 -0
  27. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/methods.md +0 -0
  28. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/metrics.md +0 -0
  29. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/overview.md +0 -0
  30. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/project.md +0 -0
  31. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/rules/validate.md +0 -0
  32. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/skills/abk-explore/SKILL.md +0 -0
  33. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/skills/abk-feedback/SKILL.md +0 -0
  34. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/skills/abk-new-experiment/SKILL.md +0 -0
  35. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/skills/abk-new-metric/SKILL.md +0 -0
  36. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/skills/abk-setup-project/SKILL.md +0 -0
  37. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/assets/claude/skills/abk-validate/SKILL.md +0 -0
  38. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/__init__.py +0 -0
  39. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/_context.py +0 -0
  40. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/clean.py +0 -0
  41. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/dashboard.py +0 -0
  42. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/explore.py +0 -0
  43. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/init.py +0 -0
  44. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/init_claude.py +0 -0
  45. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/run.py +0 -0
  46. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/test_report.py +0 -0
  47. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/unlock.py +0 -0
  48. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/validate.py +0 -0
  49. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/cli/commands/verify_incremental.py +0 -0
  50. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/compute/__init__.py +0 -0
  51. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/compute/incremental_backend.py +0 -0
  52. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/compute/reconcile.py +0 -0
  53. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/__init__.py +0 -0
  54. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/discovery.py +0 -0
  55. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/experiment_config.py +0 -0
  56. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/method_config.py +0 -0
  57. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/metric_config.py +0 -0
  58. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/profile.py +0 -0
  59. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/project_config.py +0 -0
  60. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/config/validator.py +0 -0
  61. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/core/__init__.py +0 -0
  62. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/core/exposure_counting.py +0 -0
  63. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/core/interval.py +0 -0
  64. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/core/models.py +0 -0
  65. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/core/period_planner.py +0 -0
  66. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/__init__.py +0 -0
  67. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/_sql_manager.py +0 -0
  68. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/clickhouse_manager.py +0 -0
  69. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/__init__.py +0 -0
  70. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_aa_runs.py +0 -0
  71. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_base.py +0 -0
  72. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_experiments.py +0 -0
  73. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_exposures.py +0 -0
  74. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_maintenance.py +0 -0
  75. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_results.py +0 -0
  76. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_schema.py +0 -0
  77. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_tasks.py +0 -0
  78. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/_unit_state.py +0 -0
  79. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/internal_tables/manager.py +0 -0
  80. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/manager.py +0 -0
  81. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/mysql_manager.py +0 -0
  82. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/postgres_manager.py +0 -0
  83. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/database/tables.py +0 -0
  84. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/__init__.py +0 -0
  85. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/exposure_copy.py +0 -0
  86. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/exposure_loader.py +0 -0
  87. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/metric_loader.py +0 -0
  88. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/loaders/state_loader.py +0 -0
  89. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/__init__.py +0 -0
  90. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/base.py +0 -0
  91. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/branding.py +0 -0
  92. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/email.py +0 -0
  93. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/factory.py +0 -0
  94. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/mattermost.py +0 -0
  95. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/mock.py +0 -0
  96. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/slack.py +0 -0
  97. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/telegram.py +0 -0
  98. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/notify/webhook.py +0 -0
  99. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/pipeline/__init__.py +0 -0
  100. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/pipeline/_types.py +0 -0
  101. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/pipeline/analyze.py +0 -0
  102. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/pipeline/driver.py +0 -0
  103. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/pipeline/enrich.py +0 -0
  104. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/pipeline/readout.py +0 -0
  105. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/pipeline/state.py +0 -0
  106. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/planning/__init__.py +0 -0
  107. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/planning/sizing.py +0 -0
  108. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/reporting/__init__.py +0 -0
  109. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/reporting/assets/report.js +0 -0
  110. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/reporting/builder.py +0 -0
  111. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/reporting/calibration.py +0 -0
  112. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/reporting/html_report.py +0 -0
  113. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/__init__.py +0 -0
  114. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/accumulate.py +0 -0
  115. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/base.py +0 -0
  116. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/__init__.py +0 -0
  117. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/applier.py +0 -0
  118. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/bootstrap.py +0 -0
  119. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/ci.py +0 -0
  120. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/engine.py +0 -0
  121. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/paired_bootstrap.py +0 -0
  122. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/paired_post_normed_bootstrap.py +0 -0
  123. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/poisson_bootstrap.py +0 -0
  124. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/bootstrap/post_normed_bootstrap.py +0 -0
  125. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/correction.py +0 -0
  126. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/effects.py +0 -0
  127. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/exceptions.py +0 -0
  128. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/factory.py +0 -0
  129. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/parametric/__init__.py +0 -0
  130. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/parametric/cuped_ttest.py +0 -0
  131. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/parametric/paired_cuped_ttest.py +0 -0
  132. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/parametric/paired_ttest.py +0 -0
  133. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/parametric/ratio_delta.py +0 -0
  134. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/parametric/ttest.py +0 -0
  135. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/parametric/ztest.py +0 -0
  136. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/registry.py +0 -0
  137. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/result.py +0 -0
  138. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/rng.py +0 -0
  139. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/samples.py +0 -0
  140. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/sequential/__init__.py +0 -0
  141. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/sequential/apply.py +0 -0
  142. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/sequential/confidence_sequence.py +0 -0
  143. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/sequential/mixture.py +0 -0
  144. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/stats/srm.py +0 -0
  145. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/__init__.py +0 -0
  146. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/assets/dashboard.js +0 -0
  147. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/assets/explore.js +0 -0
  148. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/config_writer.py +0 -0
  149. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/dashboard_server.py +0 -0
  150. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/html.py +0 -0
  151. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/jobs.py +0 -0
  152. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/overview.py +0 -0
  153. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/payload.py +0 -0
  154. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/recompute.py +0 -0
  155. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/server.py +0 -0
  156. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/tuning/session.py +0 -0
  157. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/utils/__init__.py +0 -0
  158. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/utils/datetime_utils.py +0 -0
  159. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/utils/env_interpolation.py +0 -0
  160. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/utils/json_utils.py +0 -0
  161. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/utils/warn_scope.py +0 -0
  162. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/__init__.py +0 -0
  163. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/_types.py +0 -0
  164. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/family.py +0 -0
  165. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/inject.py +0 -0
  166. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/load.py +0 -0
  167. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/panel.py +0 -0
  168. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/persistence.py +0 -0
  169. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/resample.py +0 -0
  170. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/result.py +0 -0
  171. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/run_id.py +0 -0
  172. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/runner.py +0 -0
  173. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/scoring.py +0 -0
  174. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/abkit/validate/vector_resample.py +0 -0
  175. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/pyproject.toml +0 -0
  176. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/requirements.txt +0 -0
  177. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/setup.cfg +0 -0
  178. {ab_analysis_kit-0.6.1 → ab_analysis_kit-0.6.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ab-analysis-kit
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,17 +76,19 @@ 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.6.1` (Alpha) — release-ready; `0.6.0` is the latest on PyPI**
79
+ > **Status: `0.6.2` (Alpha) — release-ready; `0.6.1` is the latest on PyPI**
80
80
  > (milestones **M1–M11** shipped — M11 added **`abk dashboard`**, the
81
81
  > project-level cockpit: one row per experiment with its headline verdict,
82
82
  > effect + CI, p/α and a sparkline of the cumulative series, plus buttons that
83
83
  > spawn real `abk` subprocesses (Run — for the whole experiment or one metric —
84
84
  > Unlock, Clean, Explore, Open report) and stream their logs. It is a
85
85
  > **launcher**: it computes no statistic and never takes the pipeline lock, so
86
- > every verdict on the page is the readout's own. `0.6.1` adds the first half of
87
- > the `abk plan` sizing interstitial: a CUPED comparison is sized on the
88
- > covariate correlation its own results row already persists, so required-N is
89
- > `(1 − ρ²)×` the old raw-variance bound). The statistical core, the
86
+ > every verdict on the page is the readout's own. The `0.6.x` interstitial then
87
+ > closed both `abk plan` sizing gaps: a CUPED comparison is sized on the covariate
88
+ > correlation its own results row already persists — required-N is `(1 − ρ²)×` the
89
+ > old raw-variance bound (`0.6.1`) — and `--from-history <N d>` gives an experiment
90
+ > that has **never run** a baseline from the days before its start, instead of
91
+ > `SKIPPED: no baseline` (`0.6.2`)). The statistical core, the
90
92
  > declarative config / DB / pipeline layer, the explore cockpit +
91
93
  > self-contained reports, `abk validate` (numpy-vectorized — minutes → sub-seconds),
92
94
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -99,9 +101,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
99
101
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
100
102
  ```
101
103
 
102
- (`pip install ab-analysis-kit` gets `0.6.0` — `abk dashboard` included. `0.6.1`'s
103
- CUPED-aware `abk plan` sizing lands with its tag; until then install from source
104
- for it: `pip install -e ".[dev]"`.)
104
+ (`pip install ab-analysis-kit` gets `0.6.1` — `abk dashboard` and CUPED-aware
105
+ `abk plan` sizing included. `0.6.2`'s `abk plan --from-history` lands with its tag;
106
+ until then install from source for it: `pip install -e ".[dev]"`.)
105
107
 
106
108
  `abk --version` and `abk --help` work with no database driver; you can even lint a
107
109
  config (`abk run --steps validate`) with no database at all. See the
@@ -11,17 +11,19 @@ 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.6.1` (Alpha) — release-ready; `0.6.0` is the latest on PyPI**
14
+ > **Status: `0.6.2` (Alpha) — release-ready; `0.6.1` is the latest on PyPI**
15
15
  > (milestones **M1–M11** shipped — M11 added **`abk dashboard`**, the
16
16
  > project-level cockpit: one row per experiment with its headline verdict,
17
17
  > effect + CI, p/α and a sparkline of the cumulative series, plus buttons that
18
18
  > spawn real `abk` subprocesses (Run — for the whole experiment or one metric —
19
19
  > Unlock, Clean, Explore, Open report) and stream their logs. It is a
20
20
  > **launcher**: it computes no statistic and never takes the pipeline lock, so
21
- > every verdict on the page is the readout's own. `0.6.1` adds the first half of
22
- > the `abk plan` sizing interstitial: a CUPED comparison is sized on the
23
- > covariate correlation its own results row already persists, so required-N is
24
- > `(1 − ρ²)×` the old raw-variance bound). The statistical core, the
21
+ > every verdict on the page is the readout's own. The `0.6.x` interstitial then
22
+ > closed both `abk plan` sizing gaps: a CUPED comparison is sized on the covariate
23
+ > correlation its own results row already persists — required-N is `(1 − ρ²)×` the
24
+ > old raw-variance bound (`0.6.1`) — and `--from-history <N d>` gives an experiment
25
+ > that has **never run** a baseline from the days before its start, instead of
26
+ > `SKIPPED: no baseline` (`0.6.2`)). The statistical core, the
25
27
  > declarative config / DB / pipeline layer, the explore cockpit +
26
28
  > self-contained reports, `abk validate` (numpy-vectorized — minutes → sub-seconds),
27
29
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -34,9 +36,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
34
36
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
35
37
  ```
36
38
 
37
- (`pip install ab-analysis-kit` gets `0.6.0` — `abk dashboard` included. `0.6.1`'s
38
- CUPED-aware `abk plan` sizing lands with its tag; until then install from source
39
- for it: `pip install -e ".[dev]"`.)
39
+ (`pip install ab-analysis-kit` gets `0.6.1` — `abk dashboard` and CUPED-aware
40
+ `abk plan` sizing included. `0.6.2`'s `abk plan --from-history` lands with its tag;
41
+ until then install from source for it: `pip install -e ".[dev]"`.)
40
42
 
41
43
  `abk --version` and `abk --help` work with no database driver; you can even lint a
42
44
  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.6.1
3
+ Version: 0.6.2
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,17 +76,19 @@ 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.6.1` (Alpha) — release-ready; `0.6.0` is the latest on PyPI**
79
+ > **Status: `0.6.2` (Alpha) — release-ready; `0.6.1` is the latest on PyPI**
80
80
  > (milestones **M1–M11** shipped — M11 added **`abk dashboard`**, the
81
81
  > project-level cockpit: one row per experiment with its headline verdict,
82
82
  > effect + CI, p/α and a sparkline of the cumulative series, plus buttons that
83
83
  > spawn real `abk` subprocesses (Run — for the whole experiment or one metric —
84
84
  > Unlock, Clean, Explore, Open report) and stream their logs. It is a
85
85
  > **launcher**: it computes no statistic and never takes the pipeline lock, so
86
- > every verdict on the page is the readout's own. `0.6.1` adds the first half of
87
- > the `abk plan` sizing interstitial: a CUPED comparison is sized on the
88
- > covariate correlation its own results row already persists, so required-N is
89
- > `(1 − ρ²)×` the old raw-variance bound). The statistical core, the
86
+ > every verdict on the page is the readout's own. The `0.6.x` interstitial then
87
+ > closed both `abk plan` sizing gaps: a CUPED comparison is sized on the covariate
88
+ > correlation its own results row already persists — required-N is `(1 − ρ²)×` the
89
+ > old raw-variance bound (`0.6.1`) — and `--from-history <N d>` gives an experiment
90
+ > that has **never run** a baseline from the days before its start, instead of
91
+ > `SKIPPED: no baseline` (`0.6.2`)). The statistical core, the
90
92
  > declarative config / DB / pipeline layer, the explore cockpit +
91
93
  > self-contained reports, `abk validate` (numpy-vectorized — minutes → sub-seconds),
92
94
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -99,9 +101,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
99
101
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
100
102
  ```
101
103
 
102
- (`pip install ab-analysis-kit` gets `0.6.0` — `abk dashboard` included. `0.6.1`'s
103
- CUPED-aware `abk plan` sizing lands with its tag; until then install from source
104
- for it: `pip install -e ".[dev]"`.)
104
+ (`pip install ab-analysis-kit` gets `0.6.1` — `abk dashboard` and CUPED-aware
105
+ `abk plan` sizing included. `0.6.2`'s `abk plan --from-history` lands with its tag;
106
+ until then install from source for it: `pip install -e ".[dev]"`.)
105
107
 
106
108
  `abk --version` and `abk --help` work with no database driver; you can even lint a
107
109
  config (`abk run --steps validate`) with no database at all. See the
@@ -10,7 +10,7 @@ from __future__ import annotations
10
10
 
11
11
  from typing import Any
12
12
 
13
- __version__ = "0.6.1"
13
+ __version__ = "0.6.2"
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.
@@ -26,14 +26,19 @@ from the *same* grid enumeration the pipeline uses.
26
26
 
27
27
  Sizing needs per-arm moments (mean+std for `sample`, proportion for `fraction`):
28
28
 
29
- 1. **Persisted** — the latest usable `_ab_results` row for the control/first-
29
+ 1. **`--baseline` override** (wins) — for a greenfield experiment with no data yet.
30
+ Grammar: `<metric>:mean=..,std=..,n=..` (sample) or `<metric>:prop=..,n=..`
31
+ (fraction). Optional `n_other=..` sets the treatment arm (defaults to `n`);
32
+ optional `corr=..` sizes CUPED.
33
+ 2. **`--from-history <N d>`** — the N whole days before the start, for an experiment
34
+ that has never run. **Population-wide** (there is no cohort yet), so `n` counts
35
+ everyone the metric SQL yields and `assignment.added_filters` cannot be applied —
36
+ both stated on the line. Tell the user it is indicative, not the experiment's own.
37
+ 3. **Persisted** — the latest usable `_ab_results` row for the control/first-
30
38
  treatment pair (source shown as `persisted @ <ts>`). Requires at least one
31
39
  `abk run` to have landed.
32
- 2. **`--baseline` override** — for a greenfield experiment with no data yet.
33
- Grammar: `<metric>:mean=..,std=..,n=..` (sample) or `<metric>:prop=..,n=..`
34
- (fraction). Optional `n_other=..` sets the treatment arm (defaults to `n`).
35
40
 
36
- Without either, that comparison is reported **un-sizable — not guessed**. The
41
+ Without any of them, that comparison is reported **un-sizable — not guessed**. The
37
42
  **target MDE** defaults to the comparison's `min_effect` (override with `--mde`).
38
43
 
39
44
  ## Flags
@@ -46,6 +51,7 @@ Without either, that comparison is reported **un-sizable — not guessed**. The
46
51
  | `--power 0.8` | Target power. Default: the project statistics default. |
47
52
  | `--alpha 0.05` | Experiment-level alpha *before* correction; the two-tier scheme still divides it. Default: experiment/project alpha. |
48
53
  | `--baseline <spec>` | Greenfield baseline moments (repeatable; see above). |
54
+ | `--from-history <N d>` | Population baselines from the N whole days before the start (see above). |
49
55
  | `--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
56
  | `--profile` | Profile name (default: `profiles.yml` `default_profile`). |
51
57
 
@@ -59,6 +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
+ | `--from-history <N d>` | Population baselines from the N whole days before the start — the pre-launch source (loses to `--baseline`, wins over persisted) |
62
63
  | `--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
64
  | `--profile` | Profile name (default: `profiles.yml` `default_profile`) |
64
65
 
@@ -124,7 +125,7 @@ is omitted and only the achievable MDE is shown — pass `--mde` or set `min_eff
124
125
  | **ratio metric** | No versioned closed-form power formula for `ratio-delta` | Size a related `sample`/`fraction` proxy, or measure empirically |
125
126
  | **resampling method** | Bootstrap methods have no closed-form power | Measure it with `abk validate --inject-effect` (empirical power) |
126
127
  | **paired design** | Paired methods aren't sized here | Size the unpaired analogue as a bound |
127
- | **no baseline** | No persisted rows and no `--baseline` | Run `abk run` first, or pass `--baseline` (Step 2) |
128
+ | **no baseline** | No persisted rows, no `--baseline` and no `--from-history` | Run `abk run` first, pass `--baseline` (Step 2), or `--from-history 14d` for a population baseline |
128
129
 
129
130
  **CUPED sizing (0.6.x):** a `cuped-t-test` is sized on its **own** covariate
130
131
  correlation — rows have persisted `corr_coef_1/2` since `0.4.0` — so required-N is
@@ -27,6 +27,7 @@ from __future__ import annotations
27
27
 
28
28
  import math
29
29
  from datetime import date, datetime, time
30
+ from typing import Any
30
31
 
31
32
  import click
32
33
 
@@ -60,6 +61,7 @@ def run_plan(
60
61
  power: float | None,
61
62
  alpha: float | None,
62
63
  baseline: tuple[str, ...],
64
+ from_history: str | None,
63
65
  arrival_rate: float | None,
64
66
  profile: str | None,
65
67
  ) -> None:
@@ -80,6 +82,8 @@ def run_plan(
80
82
  overrides = parse_baseline_overrides(baseline)
81
83
  except ValueError as exc:
82
84
  raise click.BadParameter(str(exc), param_hint="--baseline") from exc
85
+ if from_history is not None:
86
+ _validate_history_interval(from_history)
83
87
 
84
88
  selected, selection_warnings = select_experiments(context.root, select)
85
89
  for warning in selection_warnings:
@@ -92,7 +96,16 @@ def run_plan(
92
96
  for _, experiment in selected:
93
97
  try:
94
98
  _plan_one(
95
- experiment, context, profile, metric, mde, power, alpha, overrides, arrival_rate
99
+ experiment,
100
+ context,
101
+ profile,
102
+ metric,
103
+ mde,
104
+ power,
105
+ alpha,
106
+ overrides,
107
+ from_history,
108
+ arrival_rate,
96
109
  )
97
110
  except click.ClickException:
98
111
  raise
@@ -114,6 +127,7 @@ def _plan_one(
114
127
  power_opt,
115
128
  alpha_opt,
116
129
  overrides,
130
+ from_history,
117
131
  arrival_rate,
118
132
  ) -> None:
119
133
  from abkit.database.internal_tables import InternalTablesManager
@@ -165,6 +179,11 @@ def _plan_one(
165
179
  rate_control, rate_source = _resolve_arrival_rate(
166
180
  experiment, arrival_rate, tables, manager, context.root, grid
167
181
  )
182
+ history = (
183
+ _HistoryBaselines(experiment, context, manager, grid, from_history)
184
+ if from_history is not None
185
+ else None
186
+ )
168
187
  for comparison in comparisons:
169
188
  plans.append(
170
189
  _plan_comparison(
@@ -179,6 +198,7 @@ def _plan_one(
179
198
  rate_source,
180
199
  look_days,
181
200
  horizon_days,
201
+ history,
182
202
  )
183
203
  )
184
204
  finally:
@@ -286,6 +306,7 @@ def _plan_comparison(
286
306
  rate_source: str = "",
287
307
  look_days: list[float] | None = None,
288
308
  horizon_days: float = 0.0,
309
+ history: _HistoryBaselines | None = None,
289
310
  ) -> ComparisonPlan:
290
311
  role = (
291
312
  "main"
@@ -324,14 +345,14 @@ def _plan_comparison(
324
345
  target_mde = mde if mde is not None else comparison.min_effect
325
346
 
326
347
  notes: list[str] = []
327
- moments = _resolve_moments(experiment, comparison, kind, override, tables, notes)
348
+ moments = _resolve_moments(experiment, comparison, kind, override, tables, notes, history)
328
349
  if moments is None:
350
+ refusal = _no_baseline_refusal(comparison, history)
329
351
  return ComparisonPlan(
330
352
  comparison.metric,
331
353
  method_name,
332
354
  role,
333
- refused="no baseline — run `abk run` first, or pass "
334
- f"--baseline {comparison.metric}:...",
355
+ refused=refusal,
335
356
  kind=kind,
336
357
  test_type=test_type,
337
358
  alpha=alpha,
@@ -455,8 +476,152 @@ def _plan_ratio(experiment) -> float:
455
476
  return 1.0
456
477
 
457
478
 
479
+ class _HistoryBaselines:
480
+ """`--from-history`: population moments from the N whole days before the start.
481
+
482
+ Sizing needs per-unit moments, and before PLAN-2 they came only from a previous
483
+ ``abk run`` of this same experiment or a hand-typed ``--baseline`` — so the
484
+ pre-launch case, the one planning is actually for, read ``SKIPPED: no baseline``.
485
+
486
+ The read is deliberately POPULATION-wide: an experiment that has not launched has
487
+ no cohort to join, so the render measures everything the metric SQL yields over
488
+ ``[tz-midnight(start − interval), tz-midnight(start))``. That is a strictly better
489
+ input than a guess and strictly worse than a pilot run — the plan line says so,
490
+ especially when ``assignment.added_filters`` narrows the real cohort.
491
+
492
+ Lazy and cached per metric: a plan touches each metric once, and a comparison that
493
+ refuses (ratio/bootstrap) must not pay for a render it will never use.
494
+ """
495
+
496
+ def __init__(
497
+ self, experiment: Any, context: Any, manager: Any, grid: Any, interval: str
498
+ ) -> None:
499
+ self._experiment = experiment
500
+ self._context = context
501
+ self._manager = manager
502
+ self._grid = grid
503
+ self.interval = interval
504
+ self._backend: Any = None
505
+ self._cache: dict[str, BaselineMoments | None] = {}
506
+ self.failures: dict[str, str] = {}
507
+
508
+ @property
509
+ def label(self) -> str:
510
+ return f"history {self.interval}"
511
+
512
+ def moments(self, comparison: Any, kind: str) -> BaselineMoments | None:
513
+ """Population moments for one comparison, or ``None`` with a recorded reason.
514
+
515
+ A render failure refuses THAT comparison (the caller turns it into a SKIPPED
516
+ line naming the reason) rather than failing the command: one unreadable metric
517
+ must not cost the whole plan (the same discipline the row shaper uses).
518
+ """
519
+ metric_name = comparison.metric
520
+ if metric_name in self._cache:
521
+ return self._cache[metric_name]
522
+ try:
523
+ moments = self._load(metric_name, kind)
524
+ except Exception as exc: # a render/SQL/shape failure on ONE metric
525
+ self.failures[metric_name] = str(exc)
526
+ moments = None
527
+ self._cache[metric_name] = moments
528
+ return moments
529
+
530
+ def _load(self, metric_name: str, kind: str) -> BaselineMoments | None:
531
+ from abkit.loaders.exposure_source import build_population_backend
532
+ from abkit.loaders.query_template import POPULATION_VARIANT
533
+ from abkit.pipeline.analyze import build_container
534
+
535
+ metric = self._context.metrics_by_name.get(metric_name)
536
+ if metric is None:
537
+ raise ValueError(f"metric '{metric_name}' is not in the library")
538
+ if self._backend is None:
539
+ self._backend = build_population_backend(self._manager, self._experiment)
540
+ loaded = self._backend.load_population_window(
541
+ metric, metric.get_query_text(self._context.root), self.interval, self._grid
542
+ )
543
+ if POPULATION_VARIANT not in loaded.variants():
544
+ raise ValueError("the history window returned no rows")
545
+ # The pipeline's OWN container → suffstats path, never a hand-rolled np.std:
546
+ # `_ab_results.std_1` carries the legacy mixed-ddof convention, and two baseline
547
+ # sources that disagreed by a ddof would be quietly incomparable.
548
+ container = build_container(kind, POPULATION_VARIANT, loaded)
549
+ source = f"{self.label} @ {self._experiment.name}"
550
+ if kind == FRACTION:
551
+ return BaselineMoments(
552
+ FRACTION, container.prop, container.nobs, container.nobs, None, source
553
+ )
554
+ from abkit.stats import SufficientStats
555
+
556
+ stats = SufficientStats.from_sample(container)
557
+ if stats.sample_size < 2 or not stats.std > 0:
558
+ raise ValueError(
559
+ f"the history window yielded {stats.sample_size} unit(s) with no spread"
560
+ )
561
+ return BaselineMoments(
562
+ SAMPLE,
563
+ stats.mean,
564
+ float(stats.sample_size),
565
+ float(stats.sample_size),
566
+ stats.std,
567
+ source,
568
+ )
569
+
570
+
571
+ def _history_notes(experiment: Any, history: _HistoryBaselines) -> list[str]:
572
+ """What a population baseline is NOT, said on the line that uses it."""
573
+ notes = [
574
+ f"baseline from the {history.interval} before the start — POPULATION-wide "
575
+ "(the experiment has no cohort to read yet), so `n` counts everyone the metric "
576
+ "SQL yields, not the units this experiment will enroll"
577
+ ]
578
+ if experiment.assignment.added_filters:
579
+ notes.append(
580
+ "assignment.added_filters narrows the real cohort, and a population read "
581
+ "cannot apply it — treat this variance as indicative, not as this "
582
+ "experiment's own"
583
+ )
584
+ return notes
585
+
586
+
587
+ def _no_baseline_refusal(comparison: Any, history: _HistoryBaselines | None) -> str:
588
+ """The SKIPPED reason, naming the history render's own failure when there was one."""
589
+ if history is not None and comparison.metric in history.failures:
590
+ return (
591
+ f"no baseline — the {history.label} render failed: "
592
+ f"{history.failures[comparison.metric]}"
593
+ )
594
+ hint = "" if history is not None else ", or pass --from-history <N d>"
595
+ return "no baseline — run `abk run` first, or pass " f"--baseline {comparison.metric}:...{hint}"
596
+
597
+
598
+ def _validate_history_interval(raw: str) -> None:
599
+ """`--from-history` is whole days — the grain `covariate_lookback` already uses."""
600
+ from abkit.core.interval import Interval
601
+
602
+ try:
603
+ seconds = Interval(raw).seconds
604
+ except Exception as exc:
605
+ raise click.BadParameter(
606
+ f"--from-history '{raw}' is not an interval (e.g. 14d, 2w)",
607
+ param_hint="--from-history",
608
+ ) from exc
609
+ if seconds <= 0 or seconds % 86400 != 0:
610
+ raise click.BadParameter(
611
+ f"--from-history '{raw}' must be a positive WHOLE number of days "
612
+ "(the pre-period window is day-aligned in the experiment timezone)",
613
+ param_hint="--from-history",
614
+ )
615
+
616
+
458
617
  def _resolve_moments(
459
- experiment, comparison, kind: str, override, tables, notes: list[str]
618
+ experiment,
619
+ comparison,
620
+ kind: str,
621
+ override,
622
+ tables,
623
+ notes: list[str],
624
+ history: _HistoryBaselines | None = None,
460
625
  ) -> BaselineMoments | None:
461
626
  if override is not None:
462
627
  try:
@@ -477,6 +642,19 @@ def _resolve_moments(
477
642
  param_hint="--baseline",
478
643
  )
479
644
  return moments
645
+ # Precedence (contract step 3): an explicit --baseline wins, then --from-history,
646
+ # then the persisted rows. A hand-typed number is the operator's deliberate
647
+ # statement; a history render is a measurement of the wrong population; a
648
+ # persisted row is this experiment's own cohort and the most specific of all —
649
+ # but it only exists once the experiment has run, which is the case
650
+ # --from-history is for. Whichever wins names itself in the plan line.
651
+ if history is not None:
652
+ from_history = history.moments(comparison, kind)
653
+ if from_history is not None:
654
+ notes.extend(_history_notes(experiment, history))
655
+ return from_history
656
+ if comparison.metric in history.failures:
657
+ return None # the SKIPPED line names the render failure
480
658
  if tables is None:
481
659
  return None
482
660
  return _moments_from_results(experiment, comparison, kind, tables)
@@ -367,6 +367,13 @@ def validate(
367
367
  help="Baseline moments override for a metric with no persisted data: "
368
368
  "'<metric>:mean=..,std=..,n=..' (sample) or '<metric>:prop=..,n=..' (fraction); repeatable",
369
369
  )
370
+ @click.option(
371
+ "--from-history",
372
+ default=None,
373
+ help="Derive baseline moments for an experiment that has never run, by reading each "
374
+ "metric over the N whole days before its start (e.g. 14d) — POPULATION-wide (the "
375
+ "cohort does not exist yet). Loses to --baseline, wins over persisted rows",
376
+ )
370
377
  @click.option(
371
378
  "--arrival-rate",
372
379
  type=float,
@@ -383,6 +390,7 @@ def plan(
383
390
  power: float | None,
384
391
  alpha: float | None,
385
392
  baseline: tuple[str, ...],
393
+ from_history: str | None,
386
394
  arrival_rate: float | None,
387
395
  profile: str | None,
388
396
  ) -> None:
@@ -397,7 +405,7 @@ def plan(
397
405
  """
398
406
  from abkit.cli.commands.plan import run_plan
399
407
 
400
- run_plan(select, metric, mde, power, alpha, baseline, arrival_rate, profile)
408
+ run_plan(select, metric, mde, power, alpha, baseline, from_history, arrival_rate, profile)
401
409
 
402
410
 
403
411
  @cli.command(name="verify-incremental")
@@ -32,7 +32,12 @@ from abkit.loaders.metric_loader import (
32
32
  load_covariate_from_preperiod,
33
33
  load_metric,
34
34
  )
35
- from abkit.loaders.query_template import QueryTemplate, RenderWindow, build_builtins
35
+ from abkit.loaders.query_template import (
36
+ POPULATION_VARIANT,
37
+ QueryTemplate,
38
+ RenderWindow,
39
+ build_builtins,
40
+ )
36
41
 
37
42
 
38
43
  def dialect_of(manager: BaseDatabaseManager) -> str:
@@ -81,6 +86,7 @@ class RecomputeBackend:
81
86
  window: RenderWindow,
82
87
  apply_exposure_filter: bool = True,
83
88
  cov_window: RenderWindow | None = None,
89
+ apply_cohort_join: bool = True,
84
90
  ) -> dict[str, Any]:
85
91
  experiment = self._experiment
86
92
  return build_builtins(
@@ -97,6 +103,7 @@ class RecomputeBackend:
97
103
  cov_window=cov_window,
98
104
  direct_source_sql=self._direct_source_sql,
99
105
  has_stratum=self._has_stratum,
106
+ apply_cohort_join=apply_cohort_join,
100
107
  )
101
108
 
102
109
  def _preperiod_window(self, lookback: str | int, grid: Grid) -> RenderWindow:
@@ -176,6 +183,43 @@ class RecomputeBackend:
176
183
  self._covariate_cache[metric.name] = covariate
177
184
  return covariate
178
185
 
186
+ def load_population_window(
187
+ self,
188
+ metric: MetricConfig,
189
+ metric_sql: str,
190
+ lookback: str | int,
191
+ grid: Grid,
192
+ ) -> MetricLoadResult:
193
+ """A COHORT-FREE pre-period load — the PLAN-2 pre-launch baseline render.
194
+
195
+ Unlike :meth:`load_window` (the m9 STATE render, cohort-filtered by
196
+ design) this renders with ``apply_cohort_join=False``, so the macro
197
+ joins a one-row synthetic relation instead of the cohort and the query
198
+ measures the whole population the metric SQL yields. That is the ONLY
199
+ thing that can answer "size this experiment" before it has enrolled
200
+ anybody — an inner join to an empty cohort returns zero rows — and it is
201
+ why the plan line discloses that the baseline is population-wide rather
202
+ than the cohort ``added_filters`` will actually select.
203
+
204
+ Every row comes back under :data:`POPULATION_VARIANT`, which is passed as
205
+ the sole declared variant: ``load_metric`` validates observed variants
206
+ against that list, so a real arm label can never appear here.
207
+
208
+ It takes the LOOKBACK, not a window: the whole-day pre-period rule lives
209
+ in :meth:`_preperiod_window` and must have exactly one implementation
210
+ (the m10 ``ExperimentConfig.grid()`` discipline — a second copy of a
211
+ window rule is how a knob reaches none of its call sites).
212
+ """
213
+ window = self._preperiod_window(lookback, grid)
214
+ return load_metric(
215
+ self._manager,
216
+ metric,
217
+ metric_sql,
218
+ self._builtins(window, apply_exposure_filter=False, apply_cohort_join=False),
219
+ declared_variants=[POPULATION_VARIANT],
220
+ template=self._template,
221
+ )
222
+
179
223
  def load_cutoff(
180
224
  self,
181
225
  comparison: ComparisonConfig,
@@ -284,6 +284,29 @@ def load_variant_map(
284
284
  return variant_map
285
285
 
286
286
 
287
+ def build_population_backend(
288
+ manager: BaseDatabaseManager,
289
+ experiment: ExperimentConfig,
290
+ ) -> RecomputeBackend:
291
+ """A backend for the COHORT-FREE population render (PLAN-2), built here on purpose.
292
+
293
+ :func:`build_cohort_backend` is the ONE switch for every read that JOINS the
294
+ cohort (the binding m8 §0.5(e) contract). This read does not: the population
295
+ render swaps the cohort for a one-row synthetic relation, so there is no
296
+ copy-vs-direct branch to take — and taking it anyway would be actively wrong,
297
+ because direct mode renders and validates the assignment source, which for a
298
+ not-yet-launched experiment returns no rows and raises ``EmptyCohortError``.
299
+ That experiment is exactly the one ``abk plan --from-history`` exists for.
300
+
301
+ Constructing it HERE rather than at the call site keeps the contract's real
302
+ property — backend construction lives in this module, never scattered — and
303
+ makes the one cohort-free exception visible beside the rule it excepts.
304
+ """
305
+ from abkit.compute.recompute_backend import RecomputeBackend
306
+
307
+ return RecomputeBackend(manager, experiment, exposures_table=TABLE_EXPOSURES)
308
+
309
+
287
310
  def build_cohort_backend(
288
311
  manager: BaseDatabaseManager,
289
312
  experiment: ExperimentConfig,
@@ -35,6 +35,13 @@ class TemplateRenderError(Exception):
35
35
  _TS_FORMAT = "%Y-%m-%d %H:%M:%S"
36
36
  _DATE_FORMAT = "%Y-%m-%d"
37
37
 
38
+ #: The arm label the POPULATION render (``apply_cohort_join=False``, PLAN-2) stamps on
39
+ #: every row. It is deliberately NOT a declared variant name: a population baseline has
40
+ #: no arms, and ``load_metric`` validates observed variants against the declared list,
41
+ #: so a label that collided with one would let a cohort-free render masquerade as arm
42
+ #: data. Callers of the population path pass it as the sole declared variant.
43
+ POPULATION_VARIANT = "_abk_population"
44
+
38
45
 
39
46
  @dataclass(frozen=True)
40
47
  class RenderWindow:
@@ -84,13 +91,27 @@ def build_builtins(
84
91
  cov_window: RenderWindow | None = None,
85
92
  direct_source_sql: str | None = None,
86
93
  has_stratum: bool = True,
94
+ apply_cohort_join: bool = True,
87
95
  ) -> dict[str, Any]:
88
96
  """The authoritative ``ab_*`` built-ins dict (declarative-config.md §5).
89
97
 
90
98
  ``apply_exposure_filter=False`` is set by the loader's COVARIATE render:
91
99
  the pre-period window precedes exposure by construction, so the
92
100
  ``event_time >= exposure_ts`` predicate must be dropped there
93
- (statistics-changes.md §5 fixed-lookback mechanics).
101
+ (statistics-changes.md §5 fixed-lookback mechanics). It drops **only that
102
+ predicate** — the cohort INNER JOIN stays, which is exactly right for CUPED
103
+ (a covariate is per ENROLLED unit).
104
+
105
+ ``apply_cohort_join=False`` (PLAN-2) is the different thing: the POPULATION
106
+ render, for `abk plan --from-history` on an experiment that has not enrolled
107
+ anybody yet, where an inner join to the cohort would return zero rows. The
108
+ macro then swaps the cohort subquery for a **one-row synthetic relation**
109
+ (``CROSS JOIN (SELECT '<population>' AS _abk_variant, NULL AS _abk_stratum)
110
+ AS _abk_exposures``) rather than dropping the join: the ``_abk_exposures``
111
+ alias survives, so ``ab.variant_col()``/``ab.stratum_col()`` and the
112
+ loader's macro-usage runtime lint keep working on an UNCHANGED metric SQL,
113
+ and ``GROUP BY variant`` still groups by a relation's column instead of a
114
+ bare constant (which PostgreSQL rejects).
94
115
 
95
116
  ``ab_cohort_source`` (m8-implementation-plan.md WP3) is the ONE cohort
96
117
  fragment the packaged macro reads, built here in one of two modes:
@@ -141,6 +162,8 @@ def build_builtins(
141
162
  "ab_cohort_source": cohort_source,
142
163
  "ab_dialect": dialect,
143
164
  "ab_apply_exposure_filter": apply_exposure_filter,
165
+ "ab_apply_cohort_join": apply_cohort_join,
166
+ "ab_population_variant": POPULATION_VARIANT,
144
167
  }
145
168
  # Only present when a covariate window exists — otherwise a template
146
169
  # referencing ab_cov_* hard-fails under StrictUndefined instead of