Skip to content

chore(xtest): measure benchmark cells over a tuple of arms - #669

Draft
dmihalcik-virtru wants to merge 1 commit into
mainfrom
DSPX-4372-s3-arm-tuple
Draft

dmihalcik-virtru wants to merge 1 commit into
mainfrom
DSPX-4372-s3-arm-tuple

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Part 3a of the DSPX-4372-t1 plan, split out of #658. Based on main: stage 3 changes only xtest and imports nothing from stage 2, so it can be reviewed alongside #626.

What it does

The runner, statistics and report take a tuple of arms with a reference instead of a baseline/candidate pair. Options and arm selection still produce two arms, so a run measures what it measured before. #658 adds more.

  • runner: arms are keyed by id (the installed dist tag), not by role. CellResult records arm_ids, arm_labels and the reference. A round is recorded only once every arm completes, and the precision rule stops only when every candidate's gated intervals are narrow enough. analyze() makes one contrast per candidate against the reference, keyed by contrast_key().
  • stats: worst_control_key() takes the least reassuring of a control's A/A contrasts as the noise floor. With two arms there is exactly one.
  • report: the JSON artifact is schema 2: samples keyed by arm id, each cell's arms and reference, per-candidate contrasts, and nothing_measured. Two-arm cells keep the baseline/candidate labels. The step summary has one row per candidate and metric.
  • fixtures: build_arms names each arm after its build and numbers the control's two copies of the baseline.
  • feat(xtest): compare up to four benchmark arms in one run #621 finding kept: analyze() registers control keys before RSS censoring, so a censored control-only run is still NOTHING MEASURED.

Changes from #658 as it was

  • Output names keep the version's dots. build_arms called with_suffix(".tdf") on names that now end in a version, which turned v0.29.0 into v0.29.tdf. Both copies of a release in the control cell, or two releases such as v0.29.0 and v0.29.1, wrote one output file. It now appends the suffix. A new test with a release baseline caught this; the old tests used dot-free names.
  • No unconditional output cleanup. run_cell deleted every arm's output in a finally. feat(xtest): benchmark payloads up to 1 GiB, with per-dispatch budget #622, now on main, made that cleanup opt-in through --bench-prune-scratch so that local runs keep their outputs to inspect, and the unconditional delete contradicted it (and re-indented most of run_cell).

Compatibility

  • JSON consumers must check schema. Version 1's per-cell metrics block is now contrasts.
  • Existing two-arm invocations behave as before.

Validation

  • uv run pytest test_bench_*.py: 256 passed. ruff, ruff format and pyright are clean.
  • Runner tests drive 2, 3 and 4 arms directly: every arm once per completed round, seeded order, a partial round discarded at K=3, a warm-up failure, a regression in any candidate, CPU staying ungated, the worst-control floor, and the censored control-only run.

Stack (DSPX-4372-t1 plan)

Two parallel tracks from main; they share no imports and meet in stage 5.

Part PR Base
2a: bare-repo and js install fixes #667 main
2b: manifest contract #668 2a
2c: install benchmark #626 2b
2d: otdf-local env exports #642 2c
3a: arms as a tuple #669 (this PR) main
3b: two to four arms #658 3a
3c: pytest reads the manifest #670 3b
4: candidate-to-candidate conclusions #659 3c
5, 6: CI and report #660, #661 not yet moved onto these stacks

The runner, statistics and report take a tuple of arms with a reference
instead of a baseline/candidate pair. Option handling and arm selection
still produce two arms, so a run measures what it measured before; part
3b adds more.

- runner: Arm.name is the arm's id -- the installed dist tag -- rather than
  its role. CellResult records arm_ids, arm_labels and the reference;
  samples are keyed by arm id. run_cell checks for two or more arms with
  unique ids, records a round only once every arm has completed, and
  stops on precision only when every candidate's gated intervals are
  narrow enough. analyze() makes one contrast per candidate against the
  reference, keyed by contrast_key().
- stats: worst_control_key() picks the least reassuring of a control's
  A/A contrasts as the noise floor, ties broken by order. With two arms
  there is exactly one.
- report: the JSON artifact is schema 2. Each cell names its arms and
  reference, and its statistics are under contrasts, one per candidate;
  a two-arm cell keeps the baseline/candidate labels. nothing_measured is
  recorded. The step summary has one row per candidate and metric.
- fixtures: build_arms names each arm after its build and numbers the
  control's two copies of the baseline, since ids key the sample vectors.
  Output names append their suffix rather than using with_suffix, which
  would turn v0.29.0 into v0.29 and give two builds one output file.

Part 3a of the DSPX-4372-t1 plan.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

dmihalcik-virtru added a commit that referenced this pull request Oct 23, 2026
…pted js installs (#667)

Part 2a of the [DSPX-4372-t1
plan](#657), split out of #626:
fixes the benchmark needs, which every `otdf-sdk-mgr` install benefits
from. **Based on `main`.**

### What it does
- **Bare repos refresh their branches.** `git clone --bare` records no
fetch refspec, so the `fetch --all --tags` before every checkout
refreshed tags only. Every branch stayed where the first clone found it,
and `install tip main` or `--platform main` built that stale commit.
`checkout.BARE_REFRESH` now fetches origin's branches into
`refs/remotes/origin/*` with `--prune`, for the SDK and platform bare
repos alike, and `checkout.upstream_ref` maps a branch name onto them.
Fetching into the bare repo's own `refs/heads/*` instead would move
branches that other worktrees have checked out, leaving their HEAD ahead
of their files, and would fail for good once upstream replaced a branch
`foo` with `foo/bar`.
- **Worktrees are detached** and reset to the refreshed ref. A branch
origin no longer has is refused rather than built from the clone's stale
copy, and `HEAD` means origin's default branch as of the clone; a
platform `HEAD` worktree used to reset to itself.
- **Go source rebuilds work a second time.** `checkout_go_from_platform`
reset an existing worktree to a `FETCH_HEAD` fetched into the bare repo,
which no worktree can see, so every rebuild after the first failed with
`pathspec 'FETCH_HEAD' did not match`. It now resets to the refreshed
ref, like the SDK and platform paths.
- **`install tip` reports checkout failures as errors.** A refused
branch, or a failed git command with git's stderr, now prints `Error: …`
and exits 1 for go, js and java, as the platform path already did,
instead of a traceback.
- **An interrupted js install leaves nothing behind.** #663 already
removes a partial `dist/` when npm fails. A Ctrl-C mid-install still
left a directory holding only `cli.sh`, which `install_release` then
skipped as installed from then on. Both js install paths now remove it
unless the install finished.
- `AGENTS.md` claimed the bare clone mapped `refs/heads/*`, which is
what hid the first bug. It and the code comments also said `git pull`
fails in a worktree; it merges origin's default branch into whatever is
checked out.

### Validation
- `uv run pytest` in `otdf-sdk-mgr`: 207 passed, and 321 at the top of
this track (#642). ruff, ruff format and pyright are clean.
- `test_checkout.py` runs real git against a local origin. Every shared
behaviour is parametrized over the SDK, go and platform entry points:
new and existing worktrees follow their branch, `HEAD` (including beside
a tag named `main`), a deleted branch is refused, tags and SHAs are
checked out and then reused, and a force-pushed `refs/pull/N/head` is
followed. This replaces the stubbed command-string test for platform PR
refs. SDK-only tests guard other worktrees, force pushes and `x` → `x/y`
renames; platform-only tests cover the helper-scripts worktree. A
`CliRunner` test covers the `install tip` error path.
- Mutation-checked: `symbolic-ref --short`, treating every non-origin
name as a deleted branch, dropping go's explicit PR-ref fetch or its
`+`, swallowing go's refusal, and dropping the `install tip` catch each
fail a test.
- Two new tests interrupt each js install path.
- `isolated_git` keeps those tests off the developer's git config, any
inherited `GIT_DIR`, and the network (`GIT_ALLOW_PROTOCOL=file`).

### Follow-ups
Older problems found while reviewing this PR are fixed in a stack of
drafts based on it: #673 (don't reset a directory that isn't a worktree)
→ #674 (branch names vs versions) → #675 (tags moved upstream) → #676
(`checkout go` / `--all`).

### Stack ([DSPX-4372-t1
plan](#657))

Two parallel tracks from `main`; they share no imports and meet in stage
5.

| Part | PR | Base |
|---|---|---|
| 2a: bare-repo and js install fixes | **#667 (this PR)** | `main` |
| 2b: manifest contract | #668 | 2a |
| 2c: `install benchmark` | #626 | 2b |
| 2d: `otdf-local env` exports | #642 | 2c |
| 3a: arms as a tuple | #669 | `main` |
| 3b: two to four arms | #658 | 3a |
| 3c: pytest reads the manifest | #670 | 3b |
| 4: candidate-to-candidate conclusions | #659 | 3c |
| 5, 6: CI and report | #660, #661 | not yet moved onto these stacks |



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* SDK and platform worktrees now follow updated branches and pull
request refs, including after force-pushes. Missing branches produce a
clear error instead of a traceback.
* Interrupted JavaScript installations no longer leave partial
distribution files behind.

* **Documentation**
* Updated platform installation guidance for branch refreshes, detached
worktrees, and pull request refs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant