Skip to content

Add keeper-stress-analysis skill for Keeper PR validation - #104118

Merged
fm4v merged 38 commits into
ClickHouse:masterfrom
zlareb1:feature/keeper-stress-analysis-skill
May 7, 2026
Merged

fm4v merged 38 commits into
ClickHouse:masterfrom
zlareb1:feature/keeper-stress-analysis-skill

Conversation

@zlareb1

@zlareb1 zlareb1 commented May 5, 2026 •

Copy link
Copy Markdown
Member

A new Claude Code skill that captures the workflow for validating Keeper PRs against the keeper-stress test framework — pulling per-nightly metrics from play.clickhouse.com / keeper_stress_tests.keeper_metrics_ts, computing per-PR and per-window deltas, and producing report summaries with the documented confounds and noise floor baked in.

The skill auto-triggers on terms like keeper stress, keeper PR, keeper p99, keeper memory, keeper validation, or any reference to the keeper-stress Grafana dashboard.

How a user invokes it:

  • PR-set validation. "Validate these PRs against the stress dashboard: Keeper object-based snapshots #99651 Reduce Keeper memory usage with compact children set #99860 ..." — the skill builds pr_meta.tsv via gh pr view, runs the full pipeline, and emits a per-PR markdown table plus a high-level summary.
  • Date-range window. "What changed in Keeper between 2026-04-01 and 2026-05-01?" — runs the cumulative-gains pipeline and flags every in-window confound from known_confounds.md.
  • Single-PR drill-down. "Did PR #X cause any Keeper regression?" — adjacent-nightly Δ + PR-branch isolation card, with the four hard-failure counters (KeeperCommitsFailed, KeeperSnapshotCreationsFailed, KeeperSnapshotApplysFailed, KeeperRequestRejectedDueToSoftMemoryLimitCount) checked across follow-on nightlies.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.369

Captures the workflow used to validate Keeper PRs against the keeper-stress
Grafana dashboard (sourced from play.clickhouse.com / keeper_stress_tests).
Without this skill, every Keeper-stress validation question re-derives
methodology, data sources, and known confounds from scratch.

The skill bundles:
  - 6 SQL queries for the staging tables (bench / prom rates / prom gauges /
    mntr / container / pr_branches), with a {{TS_FILTER}} placeholder for
    arbitrary date windows
  - 7 Python scripts that join the staging files into per-PR + per-nightly
    delta tables, cumulative window-vs-window gains, and PR-branch isolation
  - rebuild.sh orchestrator that fetches data and runs the pipeline end-to-end
  - 4 reference docs (methodology, known_confounds, metric_glossary,
    slack_templates) carrying the hard-earned lessons:
      * KeeperApproximateDataSize is the right Keeper memory metric, NOT
        container_memory_bytes (cgroup includes page cache)
      * ClickHouse#100670 keeper-bench:go-faster (bench harness PR, not Keeper) caused
        the 2026-04-04 step in cgroup memory and bench-counted error rates
      * ClickHouse#101801 keeper-bench:more-features caused the 2026-04-11 rocks-side
        write-multi memory step
      * Per-PR effects below ±5 % rps are below the dataset's noise floor
        (typos PR ClickHouse#102739 measures at -5 % via PR-branch isolation)
      * p95_cpu_cores is the right CPU metric, not max_cpu_cores
        (which has counter discontinuities)
  - 4 sample outputs (PERFORMANCE_GAINS.md, PR_PERF_TABLE.md, PR_PROGRESS.md,
    INDEX.md) showing the expected deliverable formats

Triggers on terms like "keeper stress", "keeper PR", "keeper p99", "keeper
memory", "keeper validation", or any mention of the keeper-stress Grafana
dashboard.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0287c26]

Summary: ✅


AI Review

Summary

This PR adds a comprehensive keeper-stress-analysis skill (workflow, SQL extracts, scripts, references, and examples) and the current head is internally consistent: the documented pipeline matches shipped files, edge-case handling for empty windows/unmerged PR rows is present, and the helper test suite passes. High-level verdict: approve.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ➖
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 5, 2026
@zlareb1
zlareb1 marked this pull request as draft May 5, 2026 15:10
…refs

- Drop 3 sample outputs (INDEX.md, PR_PROGRESS.md, PERFORMANCE_GAINS.md)
  which overlap with PR_PERF_TABLE.md and references/slack_templates.md.
  The pipeline regenerates equivalent content on demand from cumulative_gains_summary.tsv
  and per_pr_metrics_long.tsv.

- Keep PR_PERF_TABLE.md as the canonical example — it uniquely demonstrates
  data-backed per-PR table format, co-merge attribution, and the §"Honest
  limitations" section that captures key methodology lessons.

- Fix SKILL.md references that pointed to files not in the install (REPORT.md,
  PER_PR_METRICS.md were trimmed before initial commit but still referenced)
  and to the now-dropped samples. Replace the templates table with explicit
  guidance to build write-ups from the pipeline-produced TSVs using
  references/slack_templates.md.

Net: 23 → 20 files / -45 KB. No functional change to the skill.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The skill shipped with three correctness bugs that silently broke for
any PR set other than the original 33-PR validation:

1. `scripts/build_per_pr_metrics.py` carried a hardcoded
   `PR_MANUAL_VERDICT` dict (verdicts for 21 specific PRs) and prose
   referencing specific commits — wrong output for every other input.
   Deleted; the per-PR markdown matrix is now composed by Claude
   directly from `per_pr_metrics_long.tsv` using `PR_PERF_TABLE.md` as
   the structural template, which is what `SKILL.md` already said the
   workflow does.

2. `scripts/build_pr_branch_isolated.py` had hardcoded `PR_BRANCHES`
   and `PR_NAMES` dicts; the branch filter `if r["branch"] not in
   PR_BRANCHES.values()` produced an empty file for every other PR
   set. Rewritten to read `(pr, title, branch)` tuples from
   `pr_to_nightly.tsv` (which now carries the `branch` column), so it
   works for any PR list.

3. `THRESHOLD = 2026-03-25` was hardcoded in `build_pr_nightly_map.py`
   and `compute_deltas.py`, even though `rebuild.sh` already accepts a
   TS-filter argument. Both Python scripts now read
   `KEEPER_SKILL_THRESHOLD` from env (default `2026-03-25`);
   `rebuild.sh` exports it from `$2`.

Also dropped dead `pr_out_of_window.tsv` write (never consumed),
removed unused `import os` in `build_pr_nightly_map.py`, and updated
SKILL.md to drop the deleted script from Phase 3 and document the
`headRefName` requirement in `pr_meta.tsv`.

Smoke test: `cumulative_gains.tsv` md5 is byte-identical to the
pre-optimisation baseline; `pr_branch_isolated.tsv` for `ClickHouse#99651`
(`keeper-object-based-snapshots`) reproduces the canonical
validation point (5764 rps, 544.8 ms p99) end-to-end without any
hardcoded mappings.
The PR-branch staging query had a `branch IN (<20 hardcoded names>)`
filter — same silent-failure mode that affected
`build_pr_branch_isolated.py`: any branch outside the original
33-PR validation set is dropped at the SQL layer, so the
pool-median baseline shrinks (or vanishes) for new analyses.

The data warehouse `keeper_stress_tests.keeper_metrics_ts` is
already scoped to keeper-stress runs, so `branch != 'master'`
plus the timestamp filter is sufficient to bound the result.

Smoke test for the original 33-PR window: branch pool grows
from 15 hardcoded → 49 actual branches; weekly pool size for
`ClickHouse#99651` rises from 10 → 26-28 runs (tighter weekly baseline).
The canonical validation point (5764 rps, 544.8 ms p99) still
reproduces.
The widen-to-±1-week fallback in `build_pr_branch_isolated.py` did
week-number arithmetic on the formatted string:

    new_wk = f"{yr}-W{int(wn)+delta:02d}"

For a PR HEAD landing in W01 of any year, this produces `W00`
(invalid); for W52 in a 52-week year, it produces `W53` (invalid).
Neither key exists in the pool dict, so the widening silently
returns an empty list and the row is dropped without warning.

Replace with date arithmetic on the actual `datetime`, then format
the resulting iso-week — handles year and W52/W53 boundaries
naturally.

Also dropped a pointless `import_statistics()` wrapper around
`import statistics` and moved the import to module scope where it
belongs.

Smoke test: cumulative_gains.tsv byte-identical to baseline; the
canonical `ClickHouse#99651` validation point (5764 rps, 544.8 ms p99, pool
26-28 runs) reproduces unchanged.
zlareb1 added 3 commits May 6, 2026 05:31
`build_pr_nightly_map.py:134` and `compute_deltas.py:315` both used
`list(rows[0].keys())` to derive the field list for `csv.DictWriter`.
That raises `IndexError` when the input is empty:

- `build_pr_nightly_map.py`: no PRs merged after `KEEPER_SKILL_THRESHOLD`
  (e.g. analysing a future window or a PR set that's all out-of-window).
- `compute_deltas.py`: `TS_FILTER` set to a date with no master
  nightlies after it (e.g. a very recent or future window).

The crash leaves the downstream pipeline mid-run with some outputs
written and others missing.

Move both schemas to module-level `*_FIELDS` constants and let the
writer always emit a header-only TSV when there's nothing to write.
Print a clear stderr message in the empty case so users know the
output is intentionally empty rather than truncated.

Verified end-to-end with `KEEPER_SKILL_THRESHOLD=2030-01-01`: pipeline
now completes cleanly with header-only `pr_to_nightly.tsv` and
`per_nightly_summary.tsv`. Pre-existing 33-PR smoke test:
`cumulative_gains.tsv` md5 unchanged at
`c03b62474b0dbaad218dffc8b7c43f07`.

Addresses review comments
ClickHouse#104118 (comment)
and
ClickHouse#104118 (comment).
`build_pr_branch_isolated.py` excluded the PR HEAD row from the
weekly pool by filtering on `rps != head["rps_v"]`. Two distinct
PR-branch runs that happen to share the same rounded `rps` were
both filtered out, biasing the pool median.

The probability of a value collision rises with pool size — and
since we just dropped the hardcoded branch list (`5e2f9db2eea`),
pools now carry ~30 runs/scenario/week instead of ~10.

Carry `(sha8, run_ended)` through the pool tuples and exclude head
by that identity. The same-week filter and the ±1-week widening
filter both switch from value comparison to identity comparison.

Smoke test: the canonical `ClickHouse#99651` validation point still
reproduces (5764 rps / 544.8 ms p99); pool sizes for prod-mix
went from 26 to 27 (one extra row recovered that was previously
mistakenly dropped on rps collision); cumulative_gains.tsv md5
unchanged at `c03b62474b0dbaad218dffc8b7c43f07`.

Addresses review comment
ClickHouse#104118 (comment).
The `FULL OUTER JOIN mem_agg ⋈ cpu_agg` projected
`m.scenario, m.backend, m.commit_sha` directly. For commits with
CPU samples but no memory samples (or vice-versa), those keys come
out as `NULL`. Downstream `build_metrics_table.py` joins on
`(scenario, backend, commit_sha)`, so NULL-keyed rows can't be
matched and the asymmetric-side metrics are silently dropped from
`merged_metrics.tsv`.

Project keys via `coalesce(m.X, c.X)` so either side carries the
identifiers; order by the coalesced columns.

Current keeper master commits all produce both CPU and memory
samples, so the bug is latent on today's data. The fix is
defensive — if a future scrape misses one source, the row is
still recoverable.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added 2 commits May 6, 2026 05:39
The `fetch()` helper used `curl -sG` without `--fail` /
`--fail-with-body`, so any HTTP 4xx (rate-limit, malformed query)
or 5xx (server outage) returned by `play.clickhouse.com` produced
exit code 0 with the error body written into the staging TSV.
The pipeline's `set -euo pipefail` only catches non-zero exits,
not happy curl runs that yield garbage.

Switch to `curl -sS --fail-with-body -G`. `--fail-with-body`
exits non-zero on HTTP >=400 but still writes the body to the
output file (so the user can see the server's error message);
combined with `set -e` this halts the pipeline on the first
failed fetch.

Addresses review comment
ClickHouse#104118 (comment).
`05_container.sql` projects six container metrics (`peak_mem_gb`,
`avg_mem_gb`, `avg_cpu_cores`, `p95_cpu_cores`, `max_cpu_cores`),
but `load_container` in `build_metrics_table.py` only copied three
of them. The miss matters for `avg_mem_gb`, which is referenced as
a tracked metric in `build_cumulative_gains.py:31`
(`"avg_mem_gb": "↓"`).

Result: every cumulative-gains report silently produced zero
`avg_mem_gb` delta rows, even though the SQL had pulled the data
from `keeper_metrics_ts`. Verified post-fix: 62 `avg_mem_gb`
rows now appear in `cumulative_gains.tsv` for the 33-PR window.
The canonical `ClickHouse#99651` PR-branch isolation point still
reproduces unchanged (5764 rps / 544.8 ms p99) since it doesn't
touch container metrics.

`avg_cpu_cores` is added for symmetry — the SQL emits it; the
loader should populate it. No downstream consumer references it
yet, but loading it costs one line and avoids the same drift
the next time someone wires it up.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added 2 commits May 6, 2026 06:06
When `deltas_rows` is empty (e.g. every PR is `not-yet-tested`
because no comparable pre/post nightly exists in the window), the
writer block previously skipped the file entirely but still
printed `Wrote ... (0 rows)`. Downstream consumers expecting a
file got a missing one — inconsistent with the pr_to_nightly /
per_nightly_summary empty-output handling added in `df5d3bf3b58`.

Pull the static base columns out as `base_cols` and always emit a
TSV. When there are rows, extend with the dynamic per-row metric
keys; when empty, write `base_cols` as a header-only line.

Verified with `KEEPER_SKILL_THRESHOLD=2030-01-01`: pre-fix the file
was missing; post-fix it's present with one header row.

Addresses review comment
ClickHouse#104118 (comment).
`compute_deltas.classify` used uniform 5/15 thresholds for every
lower-better metric. The rubric in references/methodology.md
specifies wider bands for tail latency and memory because they
are documented as noisier than throughput:

    rps:                         clean ≥ −5%, watch −5..−15%, regression < −15%
    read_p99_ms / write_p99_ms:  clean ≤ +10%, watch +10..+30%, regression > +30%
    peak_mem_gb:                 clean ≤ +10%, watch +10..+30%, regression > +30%

The 5/15 code over-reports `watch` / `regression` verdicts on p99
and peak-mem in `per_pr_summary.tsv` compared to the documented
rubric.

Hoist the bands into a `CLASSIFY_BANDS` table indexed by metric
name, with `DEFAULT_BANDS = (5, 15)` as the fallback for metrics
not in the table. `classify` reads `(clean_band, watch_band)` from
the table and applies the same comparison as before.

`error_pct` already uses the documented absolute-PP bands at the
top of `classify` and is unchanged.

Smoke test: cumulative_gains.tsv md5 unchanged
(`e5a27e01008ef7e23597ee041f68103b`); ClickHouse#99651 isolation row
unchanged (5764 rps / 544.8 ms p99). Verdict counts on the 33-PR
window happen not to shift in this dataset because the worst
metric per PR is dominated by metrics still on the 5/15 default
bands (`FileSync_us_per_s_avg`, `OutstandingRequests_max`,
`StorageLockWait_us_per_s_avg`, etc.); the fix is still
correct — it only relaxes the bands the methodology documents
as noisier.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added 2 commits May 6, 2026 06:17
`06_pr_branch.sql` filtered by `name='error_pct'`, but the bench
source schema in `keeper_metrics_ts` only emits `error_rate`
(raw 0..1 fraction); `error_pct` is the column **alias** the
canonical `01_bench_summary.sql` projects, not a source-metric
name. So `pr_branches.tsv` always carried `error_pct = 0`,
silently dropping all branch-side error signals from the
PR-branch isolation pipeline.

Switch to `name='error_rate'` to match `01_bench_summary.sql`
(the `*100` factor and the `error_pct` alias stay the same).

Smoke test: `pr_branches.tsv` now has 336 non-zero `error_pct`
rows for the 33-PR window (was 0 pre-fix). `cumulative_gains.tsv`
md5 unchanged (it doesn't depend on `pr_branches.tsv`); ClickHouse#99651
isolation row unchanged (the script keys on rps/p99, not
error_pct).

Addresses review comment
ClickHouse#104118 (comment).
The Phase-3 table directed users running a date-range analysis
to invoke `compute_deltas.py + build_cumulative_gains.py`. But
`compute_deltas.py:114` opens `pr_to_nightly.tsv` unconditionally
inside `load_pr_map`, and that file is only created when
`build_pr_nightly_map.py` runs (which requires `pr_meta.tsv`).
So a user following the docs literally for a pure date-range
analysis hits `FileNotFoundError: pr_to_nightly.tsv`.

The actual date-range workflow (per `rebuild.sh:64`) only needs
`build_cumulative_gains.py` — that script reads `merged_metrics.tsv`
and produces the cumulative-gains output without touching
`pr_to_nightly.tsv`. `compute_deltas.py` belongs in the PR-set
row alongside `build_pr_nightly_map.py`.

Update the table to match the orchestrator's actual behaviour:
date-range = `build_cumulative_gains.py` only; PR-set row gains
`compute_deltas.py`.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added 2 commits May 6, 2026 08:35
Two related future-Claude friction points the audit caught:

1. The default `"2026-03-25"` literal was duplicated across
   `rebuild.sh`, `build_pr_nightly_map.py`, and `compute_deltas.py`.
   Bumping one without the others would silently make scripts
   disagree on which PRs are in-window. Hoist the parsed
   `THRESHOLD` `datetime` into `_common.py` so both Python scripts
   share one definition. The bash-side default in `rebuild.sh`
   stays as-is — it sets the env var, which is a separate
   contract Python only consumes.

2. `compute_pr_deltas` and `compute_nightly_summary` both opened
   PR-set artefacts (`pr_to_nightly.tsv` and `pr_meta.tsv`)
   unconditionally. Today the orchestrator wraps them in PR mode,
   but a future Claude (or any user) running
   `python3 keeper_stress.py deltas` directly without
   `pr_meta.tsv` hits `FileNotFoundError`. The script's name says
   "deltas", not "PR-set", so the missing file looks like a bug.

   Guard both functions:
   - `compute_pr_deltas`: skip cleanly with a stderr note when
     `pr_to_nightly.tsv` is absent.
   - `compute_nightly_summary`: read `pr_meta.tsv` only when it
     exists; emit nightlies with empty `prs_landed` cells when
     it's not (date-range-only mode).

Verified end-to-end: 33-PR smoke test still produces
`cumulative_gains.tsv` md5 `e5a27e01008ef7e23597ee041f68103b` and
unchanged `ClickHouse#99651` PR-branch isolation row; standalone
`keeper_stress.py deltas` without `pr_meta.tsv` now writes a
`per_nightly_summary.tsv` with 39 nightlies and empty `prs_landed`
instead of crashing; 18 unit tests still pass.
Two future-Claude friction points the audit caught — both
SKILL.md gaps where existing skill behavior was undocumented.

1. Phase 5's noise-floor section described the ±5 % rps-via-typos
   noise floor but said nothing about the pool-widening logic in
   `build_pr_branch_isolated.py` (same-branch exclusion + ±1-week
   widening + date arithmetic for year boundaries). A future
   Claude asked "why did this PR's pool size shrink to 4?" had to
   grep the script. Add a one-paragraph cross-reference pointing
   at `methodology.md` Method C and the script's docstring.

2. Phase 4 listed the four canonical deliverable shapes (Slack /
   per-PR table / cumulative gains / mover matrix / full report)
   but no "free-form recipe" patterns, even though the audit's
   use-case-coverage analysis flagged several common requests
   (fault-scenario drill-down, single-scenario filter, co-merge
   diagnosis) as "supported via free-form awk". Add a "Free-form
   recipes" subsection with three one-liners covering those three
   patterns. Future Claude reaches for a working `awk` instead of
   re-deriving the column index each time.

No code changes; SKILL.md only.
Two small future-Claude friction points that survived the cleanup
pass:

1. SKILL.md never mentioned `tests/test_common.py`. A future
   Claude tweaking `_common.py` (e.g. nudging a band, adjusting
   `iso_week`) wouldn't know there's a unittest harness gating
   the change. Added a short "Editing this skill" section at the
   bottom of SKILL.md pointing at the harness and stating the
   binding contract: methodology rubric is the source of truth;
   if tests fail, fix code or rubric so they agree.

2. `methodology.md` Significance bands table listed 5/15 % for
   rps and 10/30 % for p99/mem with no calibration source. A
   reviewer asked "where do these numbers come from?" had nothing
   to point at. Added one paragraph: PR `ClickHouse#102739` (typos-only,
   cannot affect Keeper performance) shows ~5 % rps and ~10 %
   p99 swing under PR-branch isolation; clean = noise floor,
   watch = 3× noise floor. So if the dataset's noise
   characteristics change, recalibrate against the next
   clean-PR control rather than guessing.

Doc-only; tests still pass.
zlareb1 added 3 commits May 6, 2026 08:58
Closes a use-case gap previously declared "deferred": comparing
two arbitrary commit SHAs directly. The PR-set workflow already
handles pre/post for a merge boundary, but ad-hoc questions like
"compare 740b4a5 vs e02b59d" needed an awk one-liner that
re-derived the per-metric Δ formula every time.

`scripts/build_commit_diff.py` reads `merged_metrics.tsv`,
indexes by (8-char SHA, scenario, backend), and for each
(scenario, backend) shared by both SHAs emits one row per
HEADLINE_METRIC with `value_a`, `value_b`, `delta_abs`,
`delta_pct`, and a `verdict` from `_common.classify`. Output
`commit_diff.tsv` shape mirrors `per_pr_scenario_deltas.tsv` so
future Claude has one schema to learn.

Failure modes handled:
- Either SHA missing → exit non-zero with stderr listing nearby
  SHAs in the dataset.
- One SHA has scenarios the other doesn't → emit only the
  intersection; print stderr note about the asymmetric pairs.

`scripts/keeper_stress.py`: extend dispatch to accept argv[2:]
trailing args; new `diff` subcommand wraps `build_commit_diff.main`.

`SKILL.md` Phase 3: new "Two-commit Δ" row in the intent table.

Smoke test: `keeper_stress.py diff fdf46ee e02b59d` (the
canonical `ClickHouse#99651` pre/post boundary) emits 20 (scenario, backend)
pairs; `prod-mix-no-fault[default] / rps` shows `5067.3 → 4971.1`
(`-1.90 %`, `clean`), matching the existing `per_pr_scenario_deltas.tsv`
row for `ClickHouse#99651` exactly. Pipeline parity holds:
`cumulative_gains.tsv` md5 stays at `e5a27e01008ef7e23597ee041f68103b`.
Closes the remaining two use-case gaps from the prior critical pass:

1. **Per-scenario noise characterization.** `methodology.md` claims a
   ~5 % rps and ~10 % p99 noise floor; until now we had no in-skill
   way to verify those claims against the live dataset.
   `scripts/build_noise_stats.py` reads `merged_metrics.tsv`, groups
   by `(scenario, backend)`, and for each headline metric emits
   `n_runs`, `median`, `stddev`, `cv = stddev / |median|`, and `p95`.
   Output: `noise_stats.tsv`, one row per `(scenario, backend, metric)`.
   Skips groups with `< 3` runs (stddev needs ≥ 3 points).

   Smoke test on the current dataset confirms the rubric:
   - `rps` cv across no-fault scenarios is 0.21–4.43 % — under the
     documented 5 % floor on every one.
   - `prod-mix-no-fault[default]`: rps cv 1.31 %, read_p99_ms cv
     3.99 %. p99 is 3× noisier than rps, validating the 10/30 vs
     5/15 per-metric band split.

2. **Per-commit time-series via free-form recipe.** Added an awk
   one-liner to the `SKILL.md` Phase 4 "Free-form recipes" block
   that emits `(run_ended, sha8, value)` rows for one
   `(scenario, backend, metric)` triple. No code; the data is
   already in `merged_metrics.tsv`.

`keeper_stress.py`: new `noise` subcommand wraps
`build_noise_stats.main` (no args). `SKILL.md` Phase 3: new
"Noise calibration" row in the intent table.

Pipeline parity preserved: `cumulative_gains.tsv` md5 still
`e5a27e01008ef7e23597ee041f68103b`; 18 unit tests still pass.
Three independent silent-failure / lossy-output modes flagged in
review while the prior round was being pushed:

1. **`compute_deltas.py:291`** — `kind` collapsed to `"fault"`
   when *any* scenario in a nightly was a fault sweep, conflating
   single-kind nightlies with mixed nightlies. Today's schedule
   runs single-kind sweeps per commit (verified: 18 fault + 21
   no-fault, 0 mixed across the 33-PR window), but the field
   pretended to encode the kind union. Now emits one of
   `"fault"` / `"no-fault"` / `"mixed"` based on the actual set,
   so downstream consumers (e.g. kind-matched baseline picking
   in `build_per_pr_metrics_tsv`) won't be silently misled if
   the schedule ever changes.

2. **`build_cumulative_gains.py:148`** — early `return` when no
   `(scenario, backend)` had `>= 2*WINDOW_SIZE` runs left
   `cumulative_gains_summary.tsv` missing entirely. Inconsistent
   with the header-only-on-empty pattern used for
   `pr_to_nightly.tsv`, `per_pr_scenario_deltas.tsv`, and
   `per_nightly_summary.tsv`. Now writes a header-only file with
   the canonical column list whenever the result is empty;
   downstream consumers see one stable schema regardless of
   window size. Verified against `KEEPER_SKILL_THRESHOLD=2030-01-01`:
   file is written with one header line, no crash.

3. **`build_pr_branch_isolated.py:126`** — when a PR had a head
   value but no usable comparison pool (empty same-week pool, or
   widening produced nothing usable), the script `continue`d and
   silently dropped that `(PR, scenario)` from
   `pr_branch_isolated.tsv`. A PR could look cleaner than it was
   simply because the hard cases vanished. Now emits an explicit
   "no-baseline" row (head value present; `pool_med_*` /
   `iso_d_*` empty; `n_pool=0`) so summaries can treat the case
   as `no-baseline` rather than absent data.

Smoke-test parity preserved: `cumulative_gains.tsv` md5 stays at
`e5a27e01008ef7e23597ee041f68103b`; the canonical `ClickHouse#99651` row
is bit-identical (`5764 / 170169 / 7582` rps; `544.8 / 10.7 /
904.6` ms p99); 18 unit tests pass.

Addresses review comments
ClickHouse#104118 (comment) ,
ClickHouse#104118 (comment) ,
ClickHouse#104118 (comment) .
zlareb1 added 2 commits May 6, 2026 09:20
Two reviewer comments on `182355c9595`:

1. **`compute_deltas.py:183`** — `compute_pr_deltas` assigned the
   PR's overall verdict by inspecting `scenario_verdicts`. When
   the PR's `pre_sha` and `post_sha` are both present but share
   no `(scenario, backend)` pair (e.g. partial scenario coverage
   on one side), `scenario_verdicts` was empty, the
   `regression`/`watch` checks didn't fire, and the `else` branch
   silently labeled the PR `clean`. That's a false negative —
   the case is `not-yet-tested`, not `clean`.

   Verified against the 33-PR window: 6 PRs flipped from
   `clean` (false negative) → `not-yet-tested` (correct).
   Regression count is unchanged at 15.

2. **`build_noise_stats.py:51`** — the value filter `v > 0`
   dropped legitimate zero observations. For `error_pct` the
   dominant value is exactly zero (healthy nightlies have no
   client-observed errors), so the filter was excluding the
   baseline and biasing stddev/p95 of `error_pct` upward —
   making a uniformly-stable metric look noisy.

   Switch to `v >= 0` for non-negative metrics; only `None`
   (parse failure / missing column) is dropped. `cv` is now
   emitted as empty string when median is exactly zero (the
   coefficient of variation is undefined against a zero base);
   stddev / p95 are unaffected. Verified `error_pct` rows now
   appear in `noise_stats.tsv` (62 rows across all
   (scenario, backend) pairs) with median `0.0000` and
   meaningful stddev / p95 reflecting the actual error
   distribution.

Smoke parity: `cumulative_gains.tsv` md5 unchanged at
`e5a27e01008ef7e23597ee041f68103b`; canonical `ClickHouse#99651` row
bit-identical; 18 unit tests pass.

Addresses review comments
ClickHouse#104118 (comment) ,
ClickHouse#104118 (comment) .
Four findings from a critical re-read of the recently-added
scripts. None are bugs in the strict sense, but each makes the
code easier for a future reader (or a future Claude editing it)
to understand without re-deriving intent.

1. `build_commit_diff.py:50` — when a SHA isn't found, the error
   suggestion was `sorted(by_sha8.keys())[:8]` (alphabetically-first
   8 SHAs). For a typo like `fdf46xxx → fdf46ee`, the user got a
   list of `00..` / `01..` SHAs and had to spot the close match
   themselves. Switch to longest-common-prefix ranking via a small
   `_common_prefix` helper, so the actual close match floats to
   the top. Verified: `diff fdf46xxx zzzz0000` now suggests
   `fdf46ee1` first for the typo and falls back to alphabetical
   for the no-prefix-match input.

2. `build_commit_diff.py:60` — `delta_pct` had four distinct
   semantics (missing data, 0→0, 0→positive, normal) implemented
   correctly but unexplained. Add a 4-line comment so a future
   editor doesn't "fix" the 0→0 → "" branch into a 0.

3. `build_noise_stats.py:55` — `statistics.stdev(values) if
   len(values) >= 2 else 0.0` had a dead `else` branch, since
   the outer `if len(values) < MIN_RUNS: continue` already
   guaranteed `len(values) >= 3`. Drop the conditional and add a
   one-line comment naming the invariant.

4. `build_noise_stats.py:57` — `statistics.quantiles(values, n=20)[18]`
   is the 95th percentile, but a future reader had to know that
   `n=20` returns 19 cut points and that index 18 is the 95 % mark.
   Add a 3-line comment explaining the magic number and the
   `< 4` fallback to `max`.

No behavior change for any well-formed input. Smoke parity
preserved: `cumulative_gains.tsv` md5 unchanged at
`e5a27e01008ef7e23597ee041f68103b`; `ClickHouse#99651` row bit-identical;
18 unit tests pass.
zlareb1 added 3 commits May 6, 2026 10:09
The skill is invoked via the Claude Code CLI; the templates produce
monospace text reports that render the same in any monospace context
(terminal, GitHub PR comments, design docs, team-chat code blocks).
Calling them "Slack templates" was a leftover from the original
internal-team framing and reads as Slack-specific in a public repo.

- `git mv` the file to `report_templates.md`.
- Inside the file: drop "Slack message templates" / "Slack rendering
  tips" / `#keeper-dev` channel framing; keep all the actual content
  (templates, placeholder conventions, monospace tips) as-is.
- `SKILL.md`: replace 6 cross-references and the "Make a Slack
  summary" example with neutral "summary report" framing. Skill
  frontmatter `description` updated so the trigger surface no
  longer says "Slack-ready".

No code or template content changed; this is a naming + framing
cleanup. Smoke-test parity is unaffected (no script reads the
file's name or content programmatically).
Companion to the prior rename commit (`e140a0ac655`), which only
moved the file but didn't catch the content edits I'd made. This
commit drops the actual Slack-isms inside both files:

- `SKILL.md`: 6 cross-references updated (`slack_templates.md` →
  `report_templates.md`); "Make a Slack summary of Keeper stress
  runs" → "Give me a summary report of Keeper stress runs";
  "Slack message" / "Slack post" framing in the deliverable table,
  references list, Example 3, and the closing "output discipline"
  paragraph all replaced with neutral wording. The frontmatter
  `description` (the trigger surface) drops "Slack-ready summary"
  in favour of "summary report".
- `references/report_templates.md`: title and section heading
  ("Slack message templates", "Slack rendering tips") become
  "Monospace report templates" and "Monospace rendering tips";
  the `#keeper-dev` channel framing in Template 1's heading
  becomes "release-readiness or broad audience"; the "Slack's
  monospace handles them well" rendering tip becomes
  "handles consistently across terminal, GitHub PR comments, and
  chat code blocks".

Template content (the actual ASCII boxes, placeholders, emoji
section markers) is unchanged. The skill is invoked via the
Claude Code CLI; the templates produce monospace text that
renders the same in any monospace consumer.
Three independent findings from a fresh self-review:

1. **`PR_PERF_TABLE.md:3` referenced a deleted file.** The
   sample-output template said "_Companion to
   `PERFORMANCE_GAINS.md`_", but `PERFORMANCE_GAINS.md` was
   removed in the slim-down round (`3ab7611e82b`). A future
   Claude reading the canonical per-PR template would chase a
   dangling reference. Drop the parenthetical; the rest of the
   sentence stands on its own.

2. **`_common_prefix` was a private helper in `build_commit_diff.py`
   with no test coverage.** It's a generic 5-line longest-common-
   prefix function used to rank SHA-typo suggestions. Move it to
   `_common.py` (rename: drop the leading underscore — it's now
   part of the shared API surface), import it from
   `build_commit_diff`, and add 5 unittest cases covering
   no-overlap / partial-overlap / identical / one-is-prefix /
   empty-input edges. A regression here would silently degrade
   suggestion quality without raising. Test count: 18 → 23.

3. **`diff` and `noise` subcommands weren't mentioned in
   `rebuild.sh`.** They're on-demand by design (you don't run
   them every pipeline pass), but a reader scanning the
   orchestrator's bottom would miss the broader skill surface.
   Add a 4-line trailing comment listing the on-demand
   subcommands so the CLI surface is discoverable from
   `rebuild.sh` alone.

Smoke parity: `cumulative_gains.tsv` md5 unchanged at
`e5a27e01008ef7e23597ee041f68103b`; `ClickHouse#99651` row bit-identical;
all 23 unit tests pass; SHA-typo path still ranks `fdf46xxx`
suggestions with `fdf46ee1` first.
zlareb1 and others added 2 commits May 6, 2026 10:27
Address review comment 3194583058: the date-range workflow promised
"between A and B" but only filtered ts >= '{{TS_FILTER}}', so a request
like "between 2026-04-01 and 2026-05-01" silently included every nightly
after 2026-05-01 and let cumulative deltas drift as new runs accumulated.

Add a parallel TS_FILTER_END / KEEPER_SKILL_THRESHOLD_END upper bound that
mirrors the existing lower bound at every layer:

  - All 6 staging SQL queries: append `AND ts < '{{TS_FILTER_END}}'`.
  - `rebuild.sh`: accept `$3` as the upper bound; sed-substitute both
    placeholders; export both env vars for the Python pipeline.
  - `_common.py`: parse `KEEPER_SKILL_THRESHOLD_END` (defaults to far-future
    sentinel `9999-12-31`) so unbounded callers keep today's behavior.
  - `build_pr_nightly_map.py` and `compute_deltas.py`: filter PRs against
    the half-open `[THRESHOLD, THRESHOLD_END)` interval.
  - `SKILL.md`: update Phase 2 invocation and Example 2 ("between
    2026-04-01 and 2026-05-01") to pass both bounds.
  - `tests/test_common.py`: 2 new cases for the `THRESHOLD_END` default
    and explicit-env-var parse path. 23 -> 25 cases, all pass.

Backward-compat regression contract: invoking `rebuild.sh ... 2026-03-25`
(no upper bound) still produces `cumulative_gains.tsv` md5
e5a27e01008ef7e23597ee041f68103b and the `ClickHouse#99651` PR-branch isolation row
bit-identical. Bounded smoke (`... 2026-03-25 2026-04-15`) verified to
produce strictly fewer rows in `bench_summary.tsv` and `merged_metrics.tsv`,
with max `run_ended` < `2026-04-15` and all `pr_to_nightly.tsv` `merged_at`
< `2026-04-15`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Address review comment 3194688968: `parse_pr_meta` and the nightly-summary
loader in `compute_deltas` both called `datetime.fromisoformat(r["mergedAt"])`
unconditionally. `gh pr list --state all` returns open PRs with empty
`mergedAt`, so the bare-empty-string would raise `ValueError` mid-load and
abort the whole pipeline.

Add a shared helper `parse_merged_at` in `_common.py` that returns `None`
for empty/whitespace `mergedAt`, and route both call-sites through it. Each
loader counts skipped rows and prints a one-line summary to stderr so the
caller can tell the difference between "no PRs in input" and "all PRs were
unmerged". `tests/test_common.py` gains 4 cases pinning the
empty/whitespace/missing-key/Z-suffix paths. 25 -> 29 cases, all pass.

Backward compat held: `cumulative_gains.tsv` md5 still
e5a27e01008ef7e23597ee041f68103b on the standard smoke input. Manually
verified that injecting a synthetic open-PR row (empty `mergedAt`) now
prints `parse_pr_meta: skipped 1 unmerged PR row(s) ...` and the pipeline
still produces `pr_to_nightly.tsv` instead of aborting.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zlareb1 zlareb1 added the pr-not-for-changelog This PR should not be mentioned in the changelog label May 6, 2026
The "18 cases" line in the editing-this-skill section pointed at the
original `test_common.py` count; the harness has since grown to 29 cases
(threshold-end default, SHA-prefix matcher, unmerged-PR guard). The
`merged_metrics.tsv` shape line said `1093+ rows × 95 cols`; the smoke
output is now 1155 rows × 97 cols, so phrase shape descriptively
("one row per scenario × backend × commit; ~95+ columns") to avoid
re-drifting on every staging change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot removed the pr-ci label May 6, 2026
@zlareb1
zlareb1 marked this pull request as ready for review May 7, 2026 04:04
@fm4v fm4v self-assigned this May 7, 2026
@fm4v
fm4v added this pull request to the merge queue May 7, 2026
Merged via the queue into ClickHouse:master with commit 5882a30 May 7, 2026
165 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants