ab-analysis-kit 0.6.0__tar.gz → 0.6.1__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.0/ab_analysis_kit.egg-info → ab_analysis_kit-0.6.1}/PKG-INFO +10 -8
  2. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/README.md +9 -7
  3. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1/ab_analysis_kit.egg-info}/PKG-INFO +10 -8
  4. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/__init__.py +1 -1
  5. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/plan.md +11 -5
  6. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/skills/abk-plan/SKILL.md +12 -6
  7. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/plan.py +77 -6
  8. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/planning/sizing.py +152 -21
  9. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/LICENSE +0 -0
  10. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/MANIFEST.in +0 -0
  11. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/ab_analysis_kit.egg-info/SOURCES.txt +0 -0
  12. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/ab_analysis_kit.egg-info/dependency_links.txt +0 -0
  13. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/ab_analysis_kit.egg-info/entry_points.txt +0 -0
  14. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/ab_analysis_kit.egg-info/requires.txt +0 -0
  15. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/ab_analysis_kit.egg-info/top_level.txt +0 -0
  16. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/__init__.py +0 -0
  17. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/_output.py +0 -0
  18. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/CLAUDE.section.md +0 -0
  19. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/cli.md +0 -0
  20. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/experiments.md +0 -0
  21. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/explore.md +0 -0
  22. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/methods.md +0 -0
  23. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/metrics.md +0 -0
  24. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/overview.md +0 -0
  25. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/project.md +0 -0
  26. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/rules/validate.md +0 -0
  27. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/skills/abk-explore/SKILL.md +0 -0
  28. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/skills/abk-feedback/SKILL.md +0 -0
  29. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/skills/abk-new-experiment/SKILL.md +0 -0
  30. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/skills/abk-new-metric/SKILL.md +0 -0
  31. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/skills/abk-setup-project/SKILL.md +0 -0
  32. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/assets/claude/skills/abk-validate/SKILL.md +0 -0
  33. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/__init__.py +0 -0
  34. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/_context.py +0 -0
  35. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/clean.py +0 -0
  36. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/dashboard.py +0 -0
  37. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/explore.py +0 -0
  38. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/init.py +0 -0
  39. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/init_claude.py +0 -0
  40. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/run.py +0 -0
  41. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/test_report.py +0 -0
  42. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/unlock.py +0 -0
  43. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/validate.py +0 -0
  44. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/commands/verify_incremental.py +0 -0
  45. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/cli/main.py +0 -0
  46. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/compute/__init__.py +0 -0
  47. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/compute/incremental_backend.py +0 -0
  48. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/compute/recompute_backend.py +0 -0
  49. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/compute/reconcile.py +0 -0
  50. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/__init__.py +0 -0
  51. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/discovery.py +0 -0
  52. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/experiment_config.py +0 -0
  53. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/method_config.py +0 -0
  54. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/metric_config.py +0 -0
  55. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/profile.py +0 -0
  56. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/project_config.py +0 -0
  57. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/config/validator.py +0 -0
  58. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/core/__init__.py +0 -0
  59. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/core/exposure_counting.py +0 -0
  60. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/core/interval.py +0 -0
  61. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/core/models.py +0 -0
  62. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/core/period_planner.py +0 -0
  63. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/__init__.py +0 -0
  64. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/_sql_manager.py +0 -0
  65. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/clickhouse_manager.py +0 -0
  66. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/__init__.py +0 -0
  67. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_aa_runs.py +0 -0
  68. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_base.py +0 -0
  69. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_experiments.py +0 -0
  70. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_exposures.py +0 -0
  71. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_maintenance.py +0 -0
  72. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_results.py +0 -0
  73. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_schema.py +0 -0
  74. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_tasks.py +0 -0
  75. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/_unit_state.py +0 -0
  76. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/internal_tables/manager.py +0 -0
  77. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/manager.py +0 -0
  78. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/mysql_manager.py +0 -0
  79. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/postgres_manager.py +0 -0
  80. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/database/tables.py +0 -0
  81. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/__init__.py +0 -0
  82. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/exposure_copy.py +0 -0
  83. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/exposure_loader.py +0 -0
  84. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/exposure_source.py +0 -0
  85. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/metric_loader.py +0 -0
  86. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/query_template.py +0 -0
  87. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/state_loader.py +0 -0
  88. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/loaders/templates/abkit_assignment.jinja +0 -0
  89. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/__init__.py +0 -0
  90. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/base.py +0 -0
  91. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/branding.py +0 -0
  92. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/email.py +0 -0
  93. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/factory.py +0 -0
  94. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/mattermost.py +0 -0
  95. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/mock.py +0 -0
  96. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/slack.py +0 -0
  97. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/telegram.py +0 -0
  98. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/notify/webhook.py +0 -0
  99. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/pipeline/__init__.py +0 -0
  100. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/pipeline/_types.py +0 -0
  101. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/pipeline/analyze.py +0 -0
  102. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/pipeline/driver.py +0 -0
  103. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/pipeline/enrich.py +0 -0
  104. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/pipeline/readout.py +0 -0
  105. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/pipeline/state.py +0 -0
  106. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/planning/__init__.py +0 -0
  107. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/reporting/__init__.py +0 -0
  108. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/reporting/assets/report.js +0 -0
  109. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/reporting/builder.py +0 -0
  110. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/reporting/calibration.py +0 -0
  111. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/reporting/html_report.py +0 -0
  112. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/__init__.py +0 -0
  113. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/accumulate.py +0 -0
  114. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/base.py +0 -0
  115. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/__init__.py +0 -0
  116. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/applier.py +0 -0
  117. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/bootstrap.py +0 -0
  118. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/ci.py +0 -0
  119. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/engine.py +0 -0
  120. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/paired_bootstrap.py +0 -0
  121. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/paired_post_normed_bootstrap.py +0 -0
  122. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/poisson_bootstrap.py +0 -0
  123. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/bootstrap/post_normed_bootstrap.py +0 -0
  124. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/correction.py +0 -0
  125. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/effects.py +0 -0
  126. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/exceptions.py +0 -0
  127. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/factory.py +0 -0
  128. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/parametric/__init__.py +0 -0
  129. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/parametric/cuped_ttest.py +0 -0
  130. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/parametric/paired_cuped_ttest.py +0 -0
  131. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/parametric/paired_ttest.py +0 -0
  132. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/parametric/ratio_delta.py +0 -0
  133. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/parametric/ttest.py +0 -0
  134. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/parametric/ztest.py +0 -0
  135. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/power.py +0 -0
  136. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/registry.py +0 -0
  137. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/result.py +0 -0
  138. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/rng.py +0 -0
  139. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/samples.py +0 -0
  140. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/sequential/__init__.py +0 -0
  141. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/sequential/apply.py +0 -0
  142. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/sequential/confidence_sequence.py +0 -0
  143. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/sequential/mixture.py +0 -0
  144. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/stats/srm.py +0 -0
  145. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/__init__.py +0 -0
  146. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/assets/dashboard.js +0 -0
  147. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/assets/explore.js +0 -0
  148. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/config_writer.py +0 -0
  149. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/dashboard_server.py +0 -0
  150. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/html.py +0 -0
  151. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/jobs.py +0 -0
  152. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/overview.py +0 -0
  153. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/payload.py +0 -0
  154. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/recompute.py +0 -0
  155. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/server.py +0 -0
  156. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/tuning/session.py +0 -0
  157. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/utils/__init__.py +0 -0
  158. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/utils/datetime_utils.py +0 -0
  159. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/utils/env_interpolation.py +0 -0
  160. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/utils/json_utils.py +0 -0
  161. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/utils/warn_scope.py +0 -0
  162. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/__init__.py +0 -0
  163. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/_types.py +0 -0
  164. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/family.py +0 -0
  165. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/inject.py +0 -0
  166. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/load.py +0 -0
  167. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/panel.py +0 -0
  168. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/persistence.py +0 -0
  169. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/resample.py +0 -0
  170. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/result.py +0 -0
  171. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/run_id.py +0 -0
  172. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/runner.py +0 -0
  173. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/scoring.py +0 -0
  174. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/abkit/validate/vector_resample.py +0 -0
  175. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/pyproject.toml +0 -0
  176. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/requirements.txt +0 -0
  177. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/setup.cfg +0 -0
  178. {ab_analysis_kit-0.6.0 → ab_analysis_kit-0.6.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ab-analysis-kit
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,14 +76,17 @@ 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.0` (Alpha) — release-ready; `0.5.0` is the latest on PyPI**
80
- > (milestones **M1–M11** shipped — M11 adds **`abk dashboard`**, the
79
+ > **Status: `0.6.1` (Alpha) — release-ready; `0.6.0` is the latest on PyPI**
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). The statistical core, the
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
87
90
  > declarative config / DB / pipeline layer, the explore cockpit +
88
91
  > self-contained reports, `abk validate` (numpy-vectorized — minutes → sub-seconds),
89
92
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -96,10 +99,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
96
99
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
97
100
  ```
98
101
 
99
- (`0.6.0`'s `abk dashboard` lands with its tag; until then
100
- `pip install ab-analysis-kit` gets `0.5.0`, which has the M10 window fields
101
- (`start_ts`/`horizon_ts`) but no dashboard — for the M11 behavior install from
102
- source: `pip install -e ".[dev]"`.)
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]"`.)
103
105
 
104
106
  `abk --version` and `abk --help` work with no database driver; you can even lint a
105
107
  config (`abk run --steps validate`) with no database at all. See the
@@ -11,14 +11,17 @@ 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.0` (Alpha) — release-ready; `0.5.0` is the latest on PyPI**
15
- > (milestones **M1–M11** shipped — M11 adds **`abk dashboard`**, the
14
+ > **Status: `0.6.1` (Alpha) — release-ready; `0.6.0` is the latest on PyPI**
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). The statistical core, the
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
22
25
  > declarative config / DB / pipeline layer, the explore cockpit +
23
26
  > self-contained reports, `abk validate` (numpy-vectorized — minutes → sub-seconds),
24
27
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -31,10 +34,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
31
34
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
32
35
  ```
33
36
 
34
- (`0.6.0`'s `abk dashboard` lands with its tag; until then
35
- `pip install ab-analysis-kit` gets `0.5.0`, which has the M10 window fields
36
- (`start_ts`/`horizon_ts`) but no dashboard — for the M11 behavior install from
37
- source: `pip install -e ".[dev]"`.)
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]"`.)
38
40
 
39
41
  `abk --version` and `abk --help` work with no database driver; you can even lint a
40
42
  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.0
3
+ Version: 0.6.1
4
4
  Summary: A/B experiment analysis as declarative YAML + SQL
5
5
  Author: ab-analysis-kit authors
6
6
  License: MIT
@@ -76,14 +76,17 @@ 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.0` (Alpha) — release-ready; `0.5.0` is the latest on PyPI**
80
- > (milestones **M1–M11** shipped — M11 adds **`abk dashboard`**, the
79
+ > **Status: `0.6.1` (Alpha) — release-ready; `0.6.0` is the latest on PyPI**
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). The statistical core, the
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
87
90
  > declarative config / DB / pipeline layer, the explore cockpit +
88
91
  > self-contained reports, `abk validate` (numpy-vectorized — minutes → sub-seconds),
89
92
  > opt-in sequential analysis + `abk plan`, and the DX layer (`abk init-claude`, docs site,
@@ -96,10 +99,9 @@ pip install ab-analysis-kit # Python 3.10+; add a DB extra for real dat
96
99
  pip install "ab-analysis-kit[clickhouse]" # or [postgres] / [mysql] / [all-db]
97
100
  ```
98
101
 
99
- (`0.6.0`'s `abk dashboard` lands with its tag; until then
100
- `pip install ab-analysis-kit` gets `0.5.0`, which has the M10 window fields
101
- (`start_ts`/`horizon_ts`) but no dashboard — for the M11 behavior install from
102
- source: `pip install -e ".[dev]"`.)
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]"`.)
103
105
 
104
106
  `abk --version` and `abk --help` work with no database driver; you can even lint a
105
107
  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.0"
13
+ __version__ = "0.6.1"
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.
@@ -60,10 +60,15 @@ power formula:
60
60
  `abk validate --inject-effect` instead → SKIPPED.
61
61
  - **paired** designs — SKIPPED.
62
62
 
63
- **CUPED** (`cuped-t-test`) *is* sized, but on the **raw** persisted variance (the
64
- covariate correlation ρ is not persisted per row). This is a **conservative upper
65
- bound** on required-N — the real CUPED-deflated N is lower; the plan flags this
66
- with a `⚠ sized on RAW variance` note.
63
+ **CUPED** (`cuped-t-test`) is sized on its **own covariate correlation**: rows have
64
+ persisted `corr_coef_1/2` since `0.4.0`, so required-N is `(1 − ρ²)×` the
65
+ raw-variance number and the note names the ρ it used. Three cases fall back to the
66
+ raw variance, each saying which: **no ρ on the row** (written before `0.4.0` — the
67
+ number is then a conservative upper bound), **ρ = 0** (a measurement: this covariate
68
+ reduces nothing), and **`1 − ρ² < 1e-12`** (the covariate reproduces the metric — a
69
+ leak or a synthetic fixture; a deflated N would be rounding noise). Pass
70
+ `corr=` inside `--baseline` to size a never-run experiment; it is accepted only on a
71
+ comparison whose method actually applies a covariate.
67
72
 
68
73
  ## Reading the output
69
74
 
@@ -78,7 +83,8 @@ than crashing the plan.
78
83
  │ target MDE 5.00% → required 25,580/arm ✗ underpowered · power@MDE 0.06 · achievable MDE 49.26%
79
84
  │ example_arpu [secondary · cuped-t-test · relative] — baseline mean=62.86 std=42 · n=300/300 (persisted @ …)
80
85
  │ target MDE 5.00% → required 2,804/arm ✗ underpowered · power@MDE 0.15 · achievable MDE 15.31%
81
- │ ⚠ sized on RAW variance — CUPED (ρ not persisted) lowers required-N further
86
+ │ ⚠ sized on RAW variance — ρ = 1 leaves no usable residual variance (the covariate
87
+ │ reproduces the metric), so a deflated required-N would be rounding noise
82
88
  └─ looks: 14 planned · cadence 1d · horizon 2024-07-15 · ~28 _ab_results rows/full-refresh
83
89
  ```
84
90
 
@@ -94,8 +94,8 @@ Per comparison the tree prints a line like:
94
94
 
95
95
  ```
96
96
  arpu [main · cuped-t-test · relative] — baseline mean=12.5 std=8 · n=5000/5000 (persisted @ 2024-07-14…)
97
- target MDE 3.00% → required 7,842/arm ✗ underpowered · power@MDE 0.62 · achievable MDE 4.10%
98
- ⚠ sized on RAW variance — CUPED (ρ not persisted) lowers required-N further
97
+ target MDE 3.00% → required 5,885/arm ✗ underpowered · power@MDE 0.73 · achievable MDE 3.25%
98
+ ⚠ sized on CUPED-deflated variance (ρ = 0.42) — required-N is 0.824× the raw-variance bound
99
99
  ```
100
100
 
101
101
  Interpret it:
@@ -126,10 +126,16 @@ is omitted and only the achievable MDE is shown — pass `--mde` or set `min_eff
126
126
  | **paired design** | Paired methods aren't sized here | Size the unpaired analogue as a bound |
127
127
  | **no baseline** | No persisted rows and no `--baseline` | Run `abk run` first, or pass `--baseline` (Step 2) |
128
128
 
129
- **CUPED caveat:** a `cuped-t-test` is sized on the **raw** persisted variance (the
130
- covariate correlation ρ isn't stored per row), so its required-N is a *conservative
131
- upper bound* — real CUPED needs fewer units. The `⚠ sized on RAW variance` note flags
132
- this; tell the user the true requirement is lower.
129
+ **CUPED sizing (0.6.x):** a `cuped-t-test` is sized on its **own** covariate
130
+ correlation — rows have persisted `corr_coef_1/2` since `0.4.0` — so required-N is
131
+ `(1 − ρ²)×` the raw-variance number and the note names the ρ. Read the fallback notes
132
+ literally, they mean different things: *no ρ on the row* (a pre-`0.4.0` row ⇒ the
133
+ number is a conservative upper bound, tell the user the true requirement is lower),
134
+ *ρ = 0* (a real measurement — this covariate reduces nothing), and *ρ leaves no usable
135
+ residual variance* (the covariate reproduces the metric — a leak or a synthetic
136
+ fixture; investigate the covariate rather than trusting either number). For a never-run
137
+ experiment you can supply it: `--baseline <metric>:mean=..,std=..,n=..,corr=0.6` —
138
+ accepted only on a comparison whose method actually applies a covariate.
133
139
 
134
140
  ## Step 5 — Act on the result
135
141
 
@@ -10,9 +10,10 @@ achieved-power at the effective two-tier alpha.
10
10
  Strictly read-only (D11): no lock, no ``_ab_*`` writes; its own manager is closed in a
11
11
  ``finally``. Honest refusals (D10): ratio metrics and resampling (bootstrap) methods
12
12
  have no versioned power formula → SKIPPED with a reason, never sized with invented math;
13
- CUPED is sized on the raw persisted variance (ρ is not persisted) and flagged as a
14
- conservative upper bound. A genuine harness failure (bad selection / ``--baseline`` /
15
- warehouse error) exits non-zero; a by-design refusal does not.
13
+ CUPED is sized on the variance its own persisted ``corr_coef_1`` deflates (PLAN-1), and
14
+ the plan line always names which variance that was — raw or deflated, and why. A genuine
15
+ harness failure (bad selection / ``--baseline`` / warehouse error) exits non-zero; a
16
+ by-design refusal does not.
16
17
 
17
18
  Runtime / ASN (WP-A, m6-implementation-plan.md): each sizable comparison also reports
18
19
  days-to-required-N from a unit-arrival rate (derived read-only from the cohort source —
@@ -37,6 +38,7 @@ from abkit.pipeline import comparison_alpha, effective_alphas
37
38
  from abkit.planning.sizing import (
38
39
  FRACTION,
39
40
  SAMPLE,
41
+ SUSPICIOUS_RESIDUAL_VARIANCE_SHARE,
40
42
  AsnResult,
41
43
  BaselineMoments,
42
44
  ComparisonPlan,
@@ -337,7 +339,7 @@ def _plan_comparison(
337
339
  target_mde=target_mde,
338
340
  )
339
341
  if method_cls.requires_covariate:
340
- notes.append("sized on RAW variance — CUPED (ρ not persisted) lowers required-N further")
342
+ notes.append(_covariate_note(moments))
341
343
 
342
344
  plan_ratio = _plan_ratio(experiment)
343
345
  result = size_comparison(
@@ -458,14 +460,78 @@ def _resolve_moments(
458
460
  ) -> BaselineMoments | None:
459
461
  if override is not None:
460
462
  try:
461
- return moments_from_override(kind, override)
463
+ moments = moments_from_override(kind, override)
462
464
  except ValueError as exc:
463
465
  raise click.BadParameter(str(exc), param_hint="--baseline") from exc
466
+ if (
467
+ moments.corr_coef is not None
468
+ and not get_method_class(comparison.method.name).requires_covariate
469
+ ):
470
+ # Deflating a method that will not run CUPED promises a variance reduction
471
+ # the analysis cannot deliver — refuse where it was typed rather than print
472
+ # an under-stated required-N.
473
+ raise click.BadParameter(
474
+ f"--baseline {comparison.metric}: 'corr' sizes a covariate method, but "
475
+ f"{comparison.metric} is planned with '{comparison.method.name}' — drop "
476
+ "'corr' or plan a cuped-t-test comparison",
477
+ param_hint="--baseline",
478
+ )
479
+ return moments
464
480
  if tables is None:
465
481
  return None
466
482
  return _moments_from_results(experiment, comparison, kind, tables)
467
483
 
468
484
 
485
+ def _covariate_note(moments: BaselineMoments) -> str:
486
+ """The one line a CUPED plan states about the variance it was sized on (PLAN-1).
487
+
488
+ Every branch names what it used, because "required-N" without its variance basis
489
+ is the number an operator would then plan a launch around. The pre-PLAN-1 note
490
+ said the correlation "is not persisted", which M9 WP1 made false for every row
491
+ written since ``0.4.0``.
492
+ """
493
+ rho = moments.usable_corr
494
+ if rho is None:
495
+ if moments.corr_coef is None:
496
+ # Two different causes, two different fixes: a hand-typed baseline simply
497
+ # omitted `corr=`, while a persisted one predates the 0.4.0 column. Naming
498
+ # the wrong one sends the operator to re-run an experiment that would not
499
+ # have helped (or to look for a flag that would not have applied).
500
+ if moments.source.startswith("--baseline"):
501
+ return (
502
+ "sized on RAW variance — the --baseline override carries no 'corr', "
503
+ "so required-N is an upper bound (add corr=<ρ> to size on CUPED)"
504
+ )
505
+ return (
506
+ "sized on RAW variance — no covariate correlation on the baseline row "
507
+ "(rows written before 0.4.0 carry none), so required-N is an upper bound"
508
+ )
509
+ return (
510
+ f"sized on RAW variance — ρ = {moments.corr_coef:.6g} leaves no usable "
511
+ "residual variance (the covariate reproduces the metric), so a deflated "
512
+ "required-N would be rounding noise"
513
+ )
514
+ if rho == 0.0:
515
+ return (
516
+ "sized on RAW variance — the baseline's covariate correlation is ρ = 0, "
517
+ "so CUPED reduces no variance here (this is a measurement, not a missing value)"
518
+ )
519
+ share = 1.0 - rho * rho
520
+ note = (
521
+ f"sized on CUPED-deflated variance (ρ = {rho:.4g}) — required-N is "
522
+ f"{share:.3g}× the raw-variance bound"
523
+ )
524
+ if share < SUSPICIOUS_RESIDUAL_VARIANCE_SHARE:
525
+ # Computable, so we compute it — but a >100× reduction is far more often a
526
+ # covariate derived from the metric than a real one, and this is the number
527
+ # someone sizes a launch on. Say so on the line, do not silently under-size.
528
+ note += (
529
+ f" — that is a {1.0 / share:,.0f}× reduction; check that the covariate is "
530
+ "not derived from the metric"
531
+ )
532
+ return note
533
+
534
+
469
535
  def _moments_from_results(experiment, comparison, kind: str, tables) -> BaselineMoments | None:
470
536
  """Latest usable persisted control/treatment moments for the first-pair series."""
471
537
  variants = experiment.assignment.variants
@@ -508,7 +574,12 @@ def _moments_from_results(experiment, comparison, kind: str, tables) -> Baseline
508
574
  std_1 = _num(latest.get("std_1"))
509
575
  if std_1 is None or std_1 <= 0:
510
576
  return None
511
- return BaselineMoments(SAMPLE, value_1, float(size_1), float(size_2), std_1, source)
577
+ # M9 WP1 persists the control arm's value↔covariate correlation beside its std, and
578
+ # the rows are already filtered to THIS comparison's method_config_id — so a non-NULL
579
+ # corr_coef_1 is this method's own CUPED correlation, never another method's.
580
+ # `_num` maps NULL/NaN/inf to None; `usable_corr` makes the final call.
581
+ corr_1 = _num(latest.get("corr_coef_1"))
582
+ return BaselineMoments(SAMPLE, value_1, float(size_1), float(size_2), std_1, source, corr_1)
512
583
 
513
584
 
514
585
  def _num(value) -> float | None:
@@ -11,10 +11,14 @@ Scope boundary (honest refusal, D10): only the closed-form families in ``power.p
11
11
  sized — continuous (``t-test`` / CUPED) via the standardized-effect solve and
12
12
  proportions (``z-test``) via Cohen's h. Ratio metrics and resampling (bootstrap)
13
13
  methods have **no versioned power formula**, so the caller refuses them rather than
14
- invent math. CUPED is sized on the **raw** persisted variance (the covariate
15
- correlation is not persisted per ``_ab_results`` row — see ``cuped_ttest.py``: per-arm
16
- ``std`` reports the *original* std): a conservative upper bound on required-N, which the
17
- caller flags.
14
+ invent math. **CUPED is sized on the deflated variance when the row carries a
15
+ correlation** (PLAN-1): per-arm ``std`` still reports the *original* std (see
16
+ ``cuped_ttest.py``), but M9 WP1 persists ``corr_coef_1/2`` beside it, so
17
+ ``BaselineMoments.corr_coef`` routes the solves through ``power.get_cuped_ttest_*`` —
18
+ the same ``cuped_adjusted_std`` deflation ``validate/scoring.py`` already uses, never a
19
+ second formula. Without a usable ρ (a pre-``0.4.0`` row, a non-CUPED method, a
20
+ degenerate ``|ρ| ≥ 1``) the raw-variance bound stands unchanged and the caller flags it
21
+ as the upper bound it is.
18
22
 
19
23
  **Runtime / ASN (WP-A, m6-implementation-plan.md).** Two forward-looking timing
20
24
  answers layered on the sizing solves, both keyed on a unit-arrival rate the caller
@@ -44,6 +48,10 @@ from dataclasses import dataclass, field
44
48
  import numpy as np
45
49
 
46
50
  from abkit.stats.power import (
51
+ cuped_adjusted_std,
52
+ get_cuped_ttest_mde,
53
+ get_cuped_ttest_power,
54
+ get_cuped_ttest_sample_size,
47
55
  get_fraction_mde,
48
56
  get_fraction_power,
49
57
  get_fraction_sample_size,
@@ -58,6 +66,38 @@ from abkit.stats.sequential import mixture_tau2, sequentialize
58
66
  SAMPLE = "sample"
59
67
  FRACTION = "fraction"
60
68
 
69
+ #: PLAN-1: the smallest residual variance share ``1 − ρ²`` a CUPED deflation may use.
70
+ #: Below it the deflation factor is decided by rounding noise in the persisted ρ (a
71
+ #: Float64 carries ~1e-16 of absolute slack, and the factor is ``2·(1−ρ)``), not by the
72
+ #: data — so a required-N derived from it is an artifact, not a smaller experiment. It
73
+ #: is also the shape a *leaking* covariate takes: the covariate IS the metric. The
74
+ #: project ``abk init`` scaffolds is exactly this case — its synthetic pre-period value
75
+ #: is a linear function of the same generator as the experiment value, so ρ rounds to 1
76
+ #: and an ungated deflation printed "required 10/arm" for a series whose raw-variance
77
+ #: requirement is five orders of magnitude larger.
78
+ MIN_RESIDUAL_VARIANCE_SHARE = 1e-12
79
+
80
+ #: PLAN-1: below this residual variance share the deflation is still computed, but the
81
+ #: plan line flags it — a >100× reduction in required-N is far more often a covariate
82
+ #: derived from the metric than a real one, and it is the number someone sizes a launch
83
+ #: on. Disclosure, not refusal: the measurement stands, the operator gets to check it.
84
+ SUSPICIOUS_RESIDUAL_VARIANCE_SHARE = 0.01
85
+
86
+
87
+ def corr_is_usable(corr_coef: float | None) -> bool:
88
+ """True iff ``corr_coef`` can deflate a variance without inventing precision.
89
+
90
+ The ONE predicate behind both gates — :attr:`BaselineMoments.usable_corr` (what the
91
+ solves read) and ``--baseline corr=``'s parse-time validation — so a correlation the
92
+ planner would silently ignore can never be accepted at the door.
93
+ """
94
+ if corr_coef is None:
95
+ return False
96
+ rho = float(corr_coef)
97
+ if not math.isfinite(rho):
98
+ return False
99
+ return 1.0 - rho * rho >= MIN_RESIDUAL_VARIANCE_SHARE
100
+
61
101
 
62
102
  @dataclass(frozen=True)
63
103
  class BaselineMoments:
@@ -67,6 +107,12 @@ class BaselineMoments:
67
107
  ``fraction`` (inverted from the persisted proportion SE ``sqrt(p(1−p)/nobs)`` —
68
108
  the same inversion the readout MDE fallback uses). ``std`` is ``None`` for a
69
109
  ``fraction`` (the proportion carries its own variance).
110
+
111
+ ``corr_coef`` is the control arm's value↔covariate correlation (PLAN-1) — the
112
+ persisted ``corr_coef_1`` for a ``cuped-t-test`` row, or the ``--baseline
113
+ corr=`` override. It is appended LAST deliberately: every existing positional
114
+ construction (``BaselineMoments(SAMPLE, mean, n1, n2, std, source)``) must keep
115
+ meaning what it meant.
70
116
  """
71
117
 
72
118
  kind: str # SAMPLE | FRACTION
@@ -75,12 +121,46 @@ class BaselineMoments:
75
121
  n_other: float # treatment-arm N (same unit)
76
122
  std: float | None = None # control std (sample only)
77
123
  source: str = "" # human label — "persisted @ <ts>" or "--baseline override"
124
+ corr_coef: float | None = None # CUPED value↔covariate correlation (sample only)
78
125
 
79
126
  @property
80
127
  def observed_ratio(self) -> float:
81
128
  """treatment:control allocation actually observed (for the retrospective bounds)."""
82
129
  return self.n_other / self.n if self.n > 0 else 1.0
83
130
 
131
+ @property
132
+ def usable_corr(self) -> float | None:
133
+ """``corr_coef`` when it can deflate this baseline's variance, else ``None``.
134
+
135
+ The single gate every deflation decision reads, so the solves, the ASN's
136
+ base variance and the CLI's note can never disagree about whether this plan
137
+ line is a CUPED-sized one.
138
+
139
+ Refused: a ``fraction`` (proportions carry their own variance and
140
+ ``power.py`` has no CUPED proportion solve), a missing/NaN value (a pre-M9
141
+ row persisted no correlation), and a residual variance share below
142
+ :data:`MIN_RESIDUAL_VARIANCE_SHARE` — a (near-)perfect correlation deflates
143
+ the std to rounding noise, which is not "no sample needed" but a degenerate
144
+ input. ``ρ = 0`` IS usable: it is a real measurement of "this covariate
145
+ buys nothing", and it reproduces the raw-variance numbers exactly.
146
+ """
147
+ if self.kind != SAMPLE or not corr_is_usable(self.corr_coef):
148
+ return None
149
+ assert self.corr_coef is not None
150
+ return float(self.corr_coef)
151
+
152
+ @property
153
+ def sizing_std(self) -> float | None:
154
+ """The std the solves actually use — deflated iff :attr:`usable_corr`.
155
+
156
+ Exposed for the CLI's note and for the ASN's base variance so neither
157
+ re-implements ``cuped_adjusted_std``.
158
+ """
159
+ if self.std is None:
160
+ return None
161
+ rho = self.usable_corr
162
+ return self.std if rho is None else cuped_adjusted_std(self.std, rho)
163
+
84
164
 
85
165
  @dataclass(frozen=True)
86
166
  class SizingResult:
@@ -165,29 +245,55 @@ def size_comparison(
165
245
  )
166
246
  return SizingResult(required, achievable, achieved)
167
247
 
168
- # SAMPLE (t-test / CUPED on the raw std)
248
+ # SAMPLE (t-test, or CUPED deflated by a persisted ρ — PLAN-1)
169
249
  assert moments.std is not None
170
250
  mean, std = moments.baseline, moments.std
251
+ rho = moments.usable_corr
171
252
  # A zero standardized effect (a relative MDE on a zero baseline mean) has no finite N
172
253
  # — statsmodels raises "Cannot detect an effect-size of 0". Report ∞ instead of
173
254
  # aborting the plan (mirrors get_ttest_mde's own size≤1/std=0 → inf convention).
255
+ # The guard reads the RAW std on purpose: `|adjusted − mean| / std` is zero iff its
256
+ # numerator is, and CUPED scales the denominator by a strictly positive factor
257
+ # (`|ρ| ≥ 1` never reaches here — `usable_corr` refuses it), so the deflated solve
258
+ # answers "no finite N" on exactly the same inputs.
174
259
  if magnitude is None:
175
260
  required = None
176
261
  elif _sample_effect_size(mean, std, magnitude, test_type) == 0.0:
177
262
  required = float("inf")
178
- else:
263
+ elif rho is None:
179
264
  required = get_ttest_sample_size(
180
265
  mean, std, magnitude, test_type=test_type, alpha=alpha, power=power, ratio=plan_ratio
181
266
  )
182
- achievable = get_ttest_mde(
183
- mean, std, n, test_type=test_type, alpha=alpha, power=power, ratio=obs_ratio
184
- )
267
+ else:
268
+ required = get_cuped_ttest_sample_size(
269
+ mean,
270
+ std,
271
+ rho,
272
+ magnitude,
273
+ test_type=test_type,
274
+ alpha=alpha,
275
+ power=power,
276
+ ratio=plan_ratio,
277
+ )
278
+ if rho is None:
279
+ achievable = get_ttest_mde(
280
+ mean, std, n, test_type=test_type, alpha=alpha, power=power, ratio=obs_ratio
281
+ )
282
+ else:
283
+ achievable = get_cuped_ttest_mde(
284
+ mean, std, rho, n, test_type=test_type, alpha=alpha, power=power, ratio=obs_ratio
285
+ )
185
286
  # get_ttest_power tolerates a zero effect (power → alpha), so no guard is needed here.
186
- achieved = (
187
- get_ttest_power(mean, std, n, magnitude, test_type=test_type, alpha=alpha, ratio=obs_ratio)
188
- if magnitude is not None
189
- else None
190
- )
287
+ if magnitude is None:
288
+ achieved = None
289
+ elif rho is None:
290
+ achieved = get_ttest_power(
291
+ mean, std, n, magnitude, test_type=test_type, alpha=alpha, ratio=obs_ratio
292
+ )
293
+ else:
294
+ achieved = get_cuped_ttest_power(
295
+ mean, std, rho, n, magnitude, test_type=test_type, alpha=alpha, ratio=obs_ratio
296
+ )
191
297
  return SizingResult(required, achievable, achieved)
192
298
 
193
299
 
@@ -300,12 +406,20 @@ def _absolute_effect(moments: BaselineMoments, magnitude: float, test_type: str)
300
406
 
301
407
 
302
408
  def _base_variance(moments: BaselineMoments) -> float:
303
- """Per-unit variance of one arm: ``σ²`` (sample) or the null ``p(1−p)`` (fraction)."""
409
+ """Per-unit variance of one arm: ``σ²`` (sample) or the null ``p(1−p)`` (fraction).
410
+
411
+ **Reads the SIZING std, not the raw one** (PLAN-1 step 3): required-N and the ASN
412
+ must describe the same design. A CUPED line whose required-N was deflated by ρ but
413
+ whose ASN simulated the raw variance would be internally inconsistent — it would
414
+ report an expected stopping size ABOVE a requirement computed for a lower-variance
415
+ estimator, on one line, with nothing saying why.
416
+ """
304
417
  if moments.kind == FRACTION:
305
418
  p = moments.baseline
306
419
  return p * (1.0 - p)
307
- assert moments.std is not None
308
- return moments.std * moments.std
420
+ std = moments.sizing_std
421
+ assert std is not None
422
+ return std * std
309
423
 
310
424
 
311
425
  def asn_for(
@@ -413,10 +527,12 @@ def parse_baseline_overrides(specs: tuple[str, ...]) -> dict[str, dict[str, floa
413
527
 
414
528
  Grammar: ``<metric>:<field>=<value>[,<field>=<value>...]`` — e.g.
415
529
  ``arpu:mean=12.5,std=8,n=5000`` (sample) or ``signup:prop=0.1,n=10000`` (fraction).
416
- Optional ``n_other`` overrides the treatment-arm size (defaults to ``n``). Raises
417
- :class:`ValueError` on a malformed spec so the CLI can exit non-zero with a hint.
530
+ Optional ``n_other`` overrides the treatment-arm size (defaults to ``n``); optional
531
+ ``corr`` is the CUPED value↔covariate correlation for the greenfield path (PLAN-1),
532
+ validated to ``|ρ| < 1``. Raises :class:`ValueError` on a malformed spec so the CLI
533
+ can exit non-zero with a hint.
418
534
  """
419
- known = {"mean", "std", "n", "n_other", "prop"}
535
+ known = {"mean", "std", "n", "n_other", "prop", "corr"}
420
536
  out: dict[str, dict[str, float]] = {}
421
537
  for spec in specs:
422
538
  if ":" not in spec:
@@ -462,7 +578,13 @@ def moments_from_override(kind: str, fields: dict[str, float]) -> BaselineMoment
462
578
  n_other = fields.get("n_other", n)
463
579
  if n_other <= 0:
464
580
  raise ValueError("--baseline 'n_other' must be positive")
581
+ corr = fields.get("corr")
465
582
  if kind == FRACTION:
583
+ if corr is not None:
584
+ raise ValueError(
585
+ "--baseline 'corr' applies to a sample metric (CUPED); a fraction "
586
+ "carries its own variance and has no CUPED solve"
587
+ )
466
588
  prop = fields.get("prop", fields.get("mean"))
467
589
  if prop is None or not 0.0 < prop < 1.0:
468
590
  raise ValueError("--baseline for a fraction metric needs 'prop' in (0, 1)")
@@ -471,4 +593,13 @@ def moments_from_override(kind: str, fields: dict[str, float]) -> BaselineMoment
471
593
  std = fields.get("std")
472
594
  if mean is None or std is None or std <= 0:
473
595
  raise ValueError("--baseline for a sample metric needs 'mean' and a positive 'std'")
474
- return BaselineMoments(SAMPLE, mean, n, n_other, std, "--baseline override")
596
+ if corr is not None and not corr_is_usable(corr):
597
+ # A (near-)perfect correlation deflates the std to rounding noise, which reads
598
+ # as "no sample needed" rather than the degenerate input it is — refuse it at
599
+ # the door, where the operator typed it, instead of silently ignoring it
600
+ # downstream (the persisted path can only NOTE its refusal; here we can error).
601
+ raise ValueError(
602
+ "--baseline 'corr' must satisfy |corr| < 1 and leave a usable residual "
603
+ f"variance (1 − corr² ≥ {MIN_RESIDUAL_VARIANCE_SHARE:g})"
604
+ )
605
+ return BaselineMoments(SAMPLE, mean, n, n_other, std, "--baseline override", corr)
File without changes