detectkit 0.67.1__tar.gz → 0.67.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 (172) hide show
  1. {detectkit-0.67.1/detectkit.egg-info → detectkit-0.67.2}/PKG-INFO +1 -1
  2. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/__init__.py +1 -1
  3. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/rules/cli.md +7 -3
  4. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/rules/metrics.md +28 -1
  5. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/autotune.py +15 -3
  6. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/run.py +78 -1
  7. {detectkit-0.67.1 → detectkit-0.67.2/detectkit.egg-info}/PKG-INFO +1 -1
  8. {detectkit-0.67.1 → detectkit-0.67.2}/LICENSE +0 -0
  9. {detectkit-0.67.1 → detectkit-0.67.2}/MANIFEST.in +0 -0
  10. {detectkit-0.67.1 → detectkit-0.67.2}/README.md +0 -0
  11. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/__init__.py +0 -0
  12. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/__init__.py +0 -0
  13. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/base.py +0 -0
  14. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/branding.py +0 -0
  15. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/discord.py +0 -0
  16. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/email.py +0 -0
  17. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/factory.py +0 -0
  18. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/googlechat.py +0 -0
  19. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/mattermost.py +0 -0
  20. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/ntfy.py +0 -0
  21. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/slack.py +0 -0
  22. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/teams.py +0 -0
  23. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/telegram.py +0 -0
  24. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/channels/webhook.py +0 -0
  25. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/__init__.py +0 -0
  26. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/_base.py +0 -0
  27. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/_cooldown.py +0 -0
  28. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/_decision.py +0 -0
  29. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/_dispatch.py +0 -0
  30. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/_recovery.py +0 -0
  31. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/_replay.py +0 -0
  32. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/_types.py +0 -0
  33. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/alerting/orchestrator/orchestrator.py +0 -0
  34. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/__init__.py +0 -0
  35. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/_base.py +0 -0
  36. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/_types.py +0 -0
  37. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/autotuner.py +0 -0
  38. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/axis_spec.py +0 -0
  39. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/config_emitter.py +0 -0
  40. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/crossval.py +0 -0
  41. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/detector_select.py +0 -0
  42. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/distribution.py +0 -0
  43. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/grid_search.py +0 -0
  44. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/labels.py +0 -0
  45. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/result.py +0 -0
  46. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/runner.py +0 -0
  47. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/scoring.py +0 -0
  48. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/seasonality_search.py +0 -0
  49. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/settings.py +0 -0
  50. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/autotune/window_select.py +0 -0
  51. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/__init__.py +0 -0
  52. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/_output.py +0 -0
  53. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/CLAUDE.section.md +0 -0
  54. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/rules/alerting.md +0 -0
  55. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/rules/autotune.md +0 -0
  56. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/rules/detectors.md +0 -0
  57. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/rules/overview.md +0 -0
  58. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/rules/project.md +0 -0
  59. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/skills/dtk-autotune/SKILL.md +0 -0
  60. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/skills/dtk-feedback/SKILL.md +0 -0
  61. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/skills/dtk-new-metric/SKILL.md +0 -0
  62. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/skills/dtk-setup-project/SKILL.md +0 -0
  63. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/assets/claude/skills/dtk-tune/SKILL.md +0 -0
  64. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/__init__.py +0 -0
  65. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/clean.py +0 -0
  66. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/init.py +0 -0
  67. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/init_claude.py +0 -0
  68. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/mcp.py +0 -0
  69. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/osi.py +0 -0
  70. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/test_alert.py +0 -0
  71. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/tune.py +0 -0
  72. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/ui.py +0 -0
  73. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/commands/unlock.py +0 -0
  74. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/cli/main.py +0 -0
  75. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/config/__init__.py +0 -0
  76. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/config/metric_config.py +0 -0
  77. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/config/metric_io.py +0 -0
  78. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/config/profile.py +0 -0
  79. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/config/project_config.py +0 -0
  80. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/config/validator.py +0 -0
  81. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/core/__init__.py +0 -0
  82. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/core/interval.py +0 -0
  83. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/core/models.py +0 -0
  84. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/__init__.py +0 -0
  85. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/_sql_manager.py +0 -0
  86. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/bigquery_manager.py +0 -0
  87. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/clickhouse_manager.py +0 -0
  88. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/duckdb_manager.py +0 -0
  89. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/__init__.py +0 -0
  90. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_alert_states.py +0 -0
  91. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_autotune_runs.py +0 -0
  92. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_base.py +0 -0
  93. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_datapoints.py +0 -0
  94. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_detections.py +0 -0
  95. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_maintenance.py +0 -0
  96. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_metrics.py +0 -0
  97. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_schema.py +0 -0
  98. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/_tasks.py +0 -0
  99. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/internal_tables/manager.py +0 -0
  100. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/manager.py +0 -0
  101. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/mysql_manager.py +0 -0
  102. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/postgres_manager.py +0 -0
  103. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/snowflake_manager.py +0 -0
  104. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/source_manager.py +0 -0
  105. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/database/tables.py +0 -0
  106. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/__init__.py +0 -0
  107. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/base.py +0 -0
  108. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/factory.py +0 -0
  109. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/seasonality.py +0 -0
  110. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/statistical/__init__.py +0 -0
  111. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/statistical/_windowed.py +0 -0
  112. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/statistical/autoreg.py +0 -0
  113. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/statistical/iqr.py +0 -0
  114. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/statistical/mad.py +0 -0
  115. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/statistical/manual_bounds.py +0 -0
  116. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/detectors/statistical/zscore.py +0 -0
  117. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/loaders/__init__.py +0 -0
  118. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/loaders/errors.py +0 -0
  119. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/loaders/metric_loader.py +0 -0
  120. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/loaders/query_template.py +0 -0
  121. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/mcp/__init__.py +0 -0
  122. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/mcp/context.py +0 -0
  123. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/mcp/errors.py +0 -0
  124. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/mcp/serialize.py +0 -0
  125. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/mcp/server.py +0 -0
  126. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/mcp/tools.py +0 -0
  127. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/__init__.py +0 -0
  128. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/error_dispatch.py +0 -0
  129. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/task_manager/__init__.py +0 -0
  130. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/task_manager/_alert_step.py +0 -0
  131. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/task_manager/_base.py +0 -0
  132. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/task_manager/_detect_step.py +0 -0
  133. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/task_manager/_load_step.py +0 -0
  134. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/task_manager/_types.py +0 -0
  135. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/orchestration/task_manager/manager.py +0 -0
  136. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/reporting/__init__.py +0 -0
  137. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/reporting/assets/report.js +0 -0
  138. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/reporting/builder.py +0 -0
  139. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/reporting/html_report.py +0 -0
  140. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/semantic/__init__.py +0 -0
  141. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/semantic/errors.py +0 -0
  142. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/semantic/exporter.py +0 -0
  143. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/semantic/importer.py +0 -0
  144. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/semantic/osi_model.py +0 -0
  145. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/semantic/query_gen.py +0 -0
  146. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/tuning/__init__.py +0 -0
  147. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/tuning/assets/tune.js +0 -0
  148. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/tuning/config_writer.py +0 -0
  149. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/tuning/html.py +0 -0
  150. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/tuning/payload.py +0 -0
  151. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/tuning/server.py +0 -0
  152. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/ui/__init__.py +0 -0
  153. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/ui/assets/ui.js +0 -0
  154. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/ui/html.py +0 -0
  155. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/ui/jobs.py +0 -0
  156. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/ui/metric_files.py +0 -0
  157. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/ui/overview.py +0 -0
  158. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/ui/server.py +0 -0
  159. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/utils/__init__.py +0 -0
  160. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/utils/datetime_utils.py +0 -0
  161. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/utils/env_interpolation.py +0 -0
  162. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/utils/json_utils.py +0 -0
  163. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit/utils/stats.py +0 -0
  164. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit.egg-info/SOURCES.txt +0 -0
  165. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit.egg-info/dependency_links.txt +0 -0
  166. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit.egg-info/entry_points.txt +0 -0
  167. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit.egg-info/requires.txt +0 -0
  168. {detectkit-0.67.1 → detectkit-0.67.2}/detectkit.egg-info/top_level.txt +0 -0
  169. {detectkit-0.67.1 → detectkit-0.67.2}/pyproject.toml +0 -0
  170. {detectkit-0.67.1 → detectkit-0.67.2}/requirements.txt +0 -0
  171. {detectkit-0.67.1 → detectkit-0.67.2}/setup.cfg +0 -0
  172. {detectkit-0.67.1 → detectkit-0.67.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: detectkit
3
- Version: 0.67.1
3
+ Version: 0.67.2
4
4
  Summary: Metric monitoring with automatic anomaly detection
5
5
  Author: detectkit team
6
6
  License: MIT
@@ -4,7 +4,7 @@ detectk - Anomaly Detection for Time-Series Metrics
4
4
  A Python library for data analysts and engineers to monitor metrics with automatic anomaly detection.
5
5
  """
6
6
 
7
- __version__ = "0.67.1"
7
+ __version__ = "0.67.2"
8
8
 
9
9
  from detectkit.core.interval import Interval
10
10
  from detectkit.core.models import ColumnDefinition, TableModel
@@ -49,9 +49,13 @@ schedulers and CI to gate on:
49
49
  | `1` | Failure — any metric failed, the run aborted early, a startup/config/DB error occurred, or the selector matched no metrics. |
50
50
  | `2` | Usage error — bad CLI arguments. |
51
51
 
52
- On `dtk autotune`, a metric that's disabled in its config counts as **skipped**,
53
- not failed, and doesn't turn the exit code non-zero by itself. Other commands
54
- keep Click's default behavior (0 on success, non-zero on any exception).
52
+ A **skipped** metric never turns the exit code non-zero by itself — a skip is a
53
+ config choice, not a failure. Both switches skip: `enabled: false` on the metric
54
+ (skipped by `dtk run` *and* `dtk autotune` — no load, detect, alert or tuning) and
55
+ `autotune.enabled: false` (skipped by `dtk autotune` only). A run whose every
56
+ selected metric is disabled still exits `0`; only a selector matching **no metric
57
+ at all** is the exit-1 case. Other commands keep Click's default behavior (0 on
58
+ success, non-zero on any exception).
55
59
 
56
60
  ## `dtk run`
57
61
 
@@ -12,7 +12,7 @@ name: api_response_time # required, unique across the project
12
12
  description: API p95 latency # optional, shown in alerts
13
13
  profile: prod # optional, overrides project default_profile
14
14
  source_profile: warehouse # optional — hybrid mode: source-DB profile for THIS metric's SQL (see below)
15
- enabled: true # optional, false → skipped by `dtk run`
15
+ enabled: true # optional, false → whole metric skipped (see "Turning a metric off")
16
16
  tags: [critical, api] # optional, used by `--select tag:<t>`
17
17
  ai_context: # optional — OSI-compatible grounding (descriptive only)
18
18
  instructions: "p95 API latency, ms; user-facing"
@@ -166,6 +166,33 @@ columns and bakes the best grouping into the tuned config (see `autotune.md`).
166
166
  real-outage detection time, and it reduces but doesn't eliminate the race
167
167
  (repair a bucket that slipped through with `dtk run --from <date>`).
168
168
 
169
+ ## Turning a metric off
170
+
171
+ Three switches, from broadest to narrowest — pick by what you want to stop:
172
+
173
+ | Want to stop | Set | Effect |
174
+ |---|---|---|
175
+ | Everything | `enabled: false` (metric top level) | `dtk run` skips the metric: no load, no detect, no alert, no pipeline lock. `dtk autotune` skips it too. |
176
+ | Only notifications | `alerting.enabled: false` | Load + detect keep running (history stays continuous); nothing is sent. |
177
+ | Notifications, temporarily | `alerting.suppress_until: "2026-09-01"` | Same, until the deadline passes. |
178
+ | Only automatic tuning | `autotune.enabled: false` | Metric stays fully live; `dtk autotune` refuses it. |
179
+
180
+ `enabled: false` is visible, not silent — `dtk run` prints
181
+ `• <metric>: disabled in config (enabled: false) — skipped`, `dtk run --json`
182
+ reports the metric with `"status": "skipped"` and counts it in `totals.skipped`,
183
+ and the exit code stays **0** (a config choice is not a failure; a run whose every
184
+ selected metric is disabled still exits 0).
185
+
186
+ A disabled metric is **not** deleted: its stored history is untouched and
187
+ `dtk clean --orphaned-metrics` leaves it alone (it is still defined in YAML).
188
+ `dtk tune`, `dtk ui` (dimmed, sorted last) and `dtk mcp` still see it — that's how
189
+ you inspect a metric you just turned off before deciding to fix or delete it. Its
190
+ `_dtk_metrics` registry row is still refreshed, so that table's `enabled` column
191
+ tracks the YAML.
192
+
193
+ Prefer `enabled: false` over deleting the file when you may want the metric back:
194
+ deleting orphans every `_dtk_*` row under that name.
195
+
169
196
  ## Editing a metric that already has data
170
197
 
171
198
  - **Changing the `query`** changes what's loaded but not the stored history;
@@ -319,11 +319,23 @@ def _tune_one(
319
319
  """Tune one metric end to end.
320
320
 
321
321
  Returns:
322
- ``"ok"`` on success, ``"skipped"`` when autotune is disabled for this
323
- metric (an explicit config choice, not a failure), or ``"failed"``
324
- (no datapoints, a validation/engine error, or an unexpected exception).
322
+ ``"ok"`` on success, ``"skipped"`` when the metric itself is disabled
323
+ (``enabled: false``) or autotuning is refused for it
324
+ (``autotune.enabled: false``) — both explicit config choices, not
325
+ failures — or ``"failed"`` (no datapoints, a validation/engine error,
326
+ or an unexpected exception).
325
327
  """
326
328
  name = config.name
329
+ # Two independent switches, checked broadest-first. `enabled: false` retires
330
+ # the whole metric (`dtk run` skips it too), so tuning it would persist
331
+ # detections and emit a `__tuned_<id>.yml` for something deliberately taken
332
+ # out of production. `autotune.enabled: false` keeps the metric live but
333
+ # opts it out of automatic tuning. Either way it counts as skipped, not
334
+ # failed — the exit code stays 0. `dtk tune` is deliberately NOT gated: the
335
+ # interactive cockpit is how you inspect a disabled metric to decide its fate.
336
+ if not config.enabled:
337
+ echo_noop(name, "metric disabled in config (enabled: false)")
338
+ return "skipped"
327
339
  autotune_cfg = config.autotune or AutoTuneConfig()
328
340
  if not autotune_cfg.enabled:
329
341
  echo_noop(name, "autotune disabled in config")
@@ -13,6 +13,7 @@ from typing import Any
13
13
 
14
14
  import click
15
15
 
16
+ from detectkit.cli._output import echo_noop
16
17
  from detectkit.config.metric_config import MetricConfig, resolve_source_profile
17
18
  from detectkit.config.profile import ProfilesConfig
18
19
  from detectkit.config.project_config import ProjectConfig
@@ -169,6 +170,59 @@ def _status_str(status: Any) -> str:
169
170
  return status.value if isinstance(status, TaskStatus) else str(status)
170
171
 
171
172
 
173
+ def _skipped_metric_entry(name: str) -> dict[str, Any]:
174
+ """A JSON-summary entry for a metric the run did not process.
175
+
176
+ Shaped exactly like a processed metric's entry (the key set is part of the
177
+ ``schema_version: 1`` contract) with every counter at zero and no error —
178
+ a skip is a deliberate outcome, not a failure.
179
+ """
180
+ return {
181
+ "name": name,
182
+ "status": "skipped",
183
+ "steps_completed": [],
184
+ "datapoints_loaded": 0,
185
+ "anomalies_detected": 0,
186
+ "alerts_sent": 0,
187
+ "error": None,
188
+ }
189
+
190
+
191
+ def _refresh_disabled_registry(
192
+ internal_manager: InternalTablesManager,
193
+ project_config: ProjectConfig,
194
+ disabled_metrics: list[tuple[Path, MetricConfig]],
195
+ ) -> None:
196
+ """Refresh ``_dtk_metrics`` for the metrics this run skipped.
197
+
198
+ ``_dtk_metrics`` is the informational mirror of each metric's config and
199
+ carries an ``enabled`` column, so a skipped metric must still refresh its
200
+ row — otherwise the registry (and any dashboard built on it) would keep
201
+ reporting a just-disabled metric as enabled forever. This is the *only*
202
+ database write a disabled metric gets: no lock, no datapoints, no
203
+ detections, no alerts. Informational, so a failure here is a warning and
204
+ never the run's exit code.
205
+ """
206
+ table_override = None
207
+ if project_config is not None and hasattr(project_config, "tables"):
208
+ table_override = project_config.tables.metrics
209
+
210
+ for metric_path, config in disabled_metrics:
211
+ try:
212
+ internal_manager.upsert_metric_config(
213
+ metric_config=config,
214
+ file_path=str(metric_path),
215
+ table_name_override=table_override,
216
+ )
217
+ except Exception as exc: # never fail a run over the informational mirror
218
+ click.echo(
219
+ click.style(
220
+ f" │ Registry refresh skipped for {config.name}: {exc}",
221
+ fg="yellow",
222
+ )
223
+ )
224
+
225
+
172
226
  def _finish_summary(summary: dict[str, Any], started_at: datetime, rc: int) -> None:
173
227
  """Fill in totals, timing and the final status, keyed off the per-metric entries."""
174
228
  finished_at = now_utc_naive()
@@ -296,6 +350,23 @@ def _run_impl(
296
350
  summary["error"] = f"No metrics found matching selector: {select}"
297
351
  return 1
298
352
 
353
+ # `enabled: false` takes the metric out of the pipeline entirely — no load,
354
+ # no detect, no alert, no lock. The skip happens HERE, in the runner, not in
355
+ # discovery/`select_metrics`, for two reasons: (1) observability — a disabled
356
+ # metric stays visible as one `•` line in the log and a `skipped` entry in
357
+ # the --json summary instead of silently vanishing; (2) every other command
358
+ # shares `select_metrics`, and they must keep seeing it — `dtk tune`/`dtk ui`
359
+ # are exactly how you inspect a disabled metric to decide its fate, and its
360
+ # `_dtk_*` rows must not read as orphaned to `dtk clean --orphaned-metrics`.
361
+ # A skip is a config choice, never a failure: it does not affect the exit
362
+ # code (a run whose every selected metric is disabled still exits 0).
363
+ disabled_metrics = [(path, cfg) for path, cfg in metrics if not cfg.enabled]
364
+ if disabled_metrics:
365
+ metrics = [(path, cfg) for path, cfg in metrics if cfg.enabled]
366
+ for _path, disabled_config in disabled_metrics:
367
+ echo_noop(disabled_config.name, "disabled in config (enabled: false) — skipped")
368
+ summary["metrics"].append(_skipped_metric_entry(disabled_config.name))
369
+
299
370
  click.echo(f"Found {len(metrics)} metric(s) to process")
300
371
  click.echo()
301
372
 
@@ -330,7 +401,8 @@ def _run_impl(
330
401
  # mode) must name a real profile. This is a cheap name check — no
331
402
  # connections opened — so a typo'd source_profile fails the whole run
332
403
  # up front instead of surfacing deep inside whichever metric's LOAD step
333
- # happens to hit it first.
404
+ # happens to hit it first. Disabled metrics are already out of `metrics`,
405
+ # so a typo in one of them can't fail a run that would never have used it.
334
406
  source_profile_error = _validate_source_profiles(metrics, project_config, profiles_config)
335
407
  if source_profile_error:
336
408
  # A config typo, not an outage: exit 1 without paging error_alerting,
@@ -397,6 +469,11 @@ def _run_impl(
397
469
  summary["error"] = f"Error initializing internal tables: {e}"
398
470
  return 1
399
471
 
472
+ # Disabled metrics run no pipeline step, but their config mirror stays
473
+ # truthful so `_dtk_metrics.enabled` reflects the YAML that was just read.
474
+ if disabled_metrics:
475
+ _refresh_disabled_registry(internal_manager, project_config, disabled_metrics)
476
+
400
477
  # The active STATE profile's actual name (mirrors ProfilesConfig.get_profile's
401
478
  # own None -> default_profile resolution) — lets the task manager recognize
402
479
  # a metric's source_profile that happens to name the state profile itself,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: detectkit
3
- Version: 0.67.1
3
+ Version: 0.67.2
4
4
  Summary: Metric monitoring with automatic anomaly detection
5
5
  Author: detectkit team
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes