Skip to content

feat(ratchet): the table shows the margin each row applies — measured band or unmeasured (c, 3/3) - #771

Merged
EtanHey merged 6 commits into
mainfrom
wt/ratchet-c3-table-margins
Sep 5, 2026
Merged

feat(ratchet): the table shows the margin each row applies — measured band or unmeasured (c, 3/3)#771
EtanHey merged 6 commits into
mainfrom
wt/ratchet-c3-table-margins

Conversation

@EtanHey

@EtanHey EtanHey commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Ratchet bolt-down (c), slice 3 of 3 — the table shows the margin each row applies

Size XS. Base is main; #763 merged as 8aa562c3. Supersedes #765 (closed by GitHub when the stacked base branch was deleted; identical content, rebased onto main). Rebase onto main met (b)'s #766 in tests/test_ci_ratchet_table.py — an append-versus-append conflict at the file end, resolved by keeping both blocks ((b)'s first); the collector auto-merged. Review history — bot rounds, lead rounds 1 and 2 (ACCEPT), dispositions — lives on #765. Known and stated: DeepSource flags except (AttestationError, ValueError) as overlapping (AttestationError subclasses ValueError); one-line lint fix held pending the lead's word, since this reopen is "no code changes".

What a reader sees now

Rendered locally with the seven real green-main values as attestations (python scripts/ci_ratchet_table.py --attestations <dir>):

search p50/p95 · Notes: Margin p50: limit 463.7 ms = mean 225.0 ms + k 3.36 × σ 71.1 ms (n=7 attested green main runs; one-sided 99% prediction limit for one run). Margin p95: limit 2457.5 ms = mean 1974.4 ms + k 3.36 × σ 143.8 ms (n=7 …). Calibrated on MacBook-Pro.local at 2026-09-01T08:42:22Z under active_sprint_load. Not measured by this run.

idle CPU · Notes: Ceiling: average CPU < 30% over a 60 s window, ratified and kept as a hard budget. Margin daemon: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin helper: … Margin watcher: …

Without --attestations (every PR run until ratchet.yml downloads them) the Notes say margin unmeasured — 0 of the 5 attested green main runs — a count, never a limit. The old Notes printed the 911.887 ms baseline with no margin at all.

Fail-closed

A store handed over and unreadable (--attestations at a missing path, a malformed file) turns search p50/p95 and idle CPU RED with the reason, never n/a; main exits 1 with ::error annotations for both. Rows that apply no margin (mapped bytes, provenance, signature) are untouched.

Tests

tests/test_ci_ratchet_table.py: 7 new (158 total) + tests/test_ratchet_margins.py 28 + the git-shellout registration test: 180 passed. Two of the new Notes tests were run against a git archive 3ee7c279 tree and fail there. ruff clean.

— brainlayerClaude (worker) · claude-code/claude-fable-5-1


Note

Low Risk
Changes are limited to CI ratchet table rendering and CLI; no production runtime paths, though reviewers should confirm workflow wiring for --attestations matches the new fail-closed RED behavior.

Overview
The ratchet sticky comment now explains which statistical margin applies to search latency and idle CPU, derived from attested green main runs instead of quoting a flat baseline limit in Notes.

scripts/ci_ratchet_table.py gains --attestations (file or directory of attestation.json), loads them through ratchet_margins, and stores the result on Probe. search p50/p95 and idle CPU Notes call margin_notes to print measured bands (mean, σ, limit, run count) or margin unmeasured when fewer than five runs exist; idle CPU keeps the hard 30% ceiling and adds per-process daemon/helper/watcher bands. Missing attestations stay n/a with unmeasured margins and exit 0; a path that was passed but cannot be read or yields invalid bands turns those rows RED and fails the collector without aborting unrelated rows.

Tests in tests/test_ci_ratchet_table.py cover unmeasured vs measured wording, fail-closed load errors, CLI integration, malformed data, and non-finite band refusal.

Reviewed by Cursor Bugbot for commit 5a1ec60. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Show measured or unmeasured ratchet margins per row via --attestations in ci_ratchet_table

  • Adds a --attestations file-or-directory option to the CLI in ci_ratchet_table.py; Probe.detect loads attestation documents through a new select_attestations loader backed by scripts.ratchet_margins.
  • The margin_notes helper renders each requested margin key with its unit from the probe's attestations, returning a row-level problem string on ValueError instead of propagating.
  • row_search_latency replaces the old flat-limit/baseline note with formatted p50 and p95 attested bands; row_idle_cpu keeps the existing 30%/60-second ceiling and appends per-process margins for daemon, helper, and watcher.
  • Rows that lack an attestation store render unmeasured margins and stay n/a; load failures, malformed data, or non-finite bands turn the affected rows RED while unrelated rows stay n/a.
  • Behavioral Change: row_search_latency and row_idle_cpu no longer emit the prior flat-limit/baseline text; callers of the CLI must pass --attestations to see measured bands, and an unreadable supplied path exits with code 1 and RED diagnostics.

Macroscope summarized 5a1ec60.

EtanHey and others added 4 commits September 5, 2026 15:41
… band or `unmeasured`, never a round number (c, 3/3)

--attestations <dir> hands the collector the attested main runs; the search p50/p95 and idle CPU
Notes print the band with every input (mean, σ, k, n) or 'margin unmeasured — N of the 5 attested
green main runs'. A store handed over and unreadable turns those rows RED, never n/a. The idle-CPU
Notes keep the ratified 30% ceiling and add the band per process.

Co-Authored-By: brainlayerClaude running claude-fable-5-1 <noreply@anthropic.com>
…rgin rows RED, never aborts the table (Macroscope, #765)

The fix itself is in the margins module (validate at load); this pins the collector-level behaviour.

Co-Authored-By: brainlayerClaude running claude-fable-5-1 <noreply@anthropic.com>
…f aborting the table

margin_notes returns (notes, problem); search p50/p95 and idle CPU go RED with the reason.

Co-Authored-By: brainlayerClaude running claude-fable-5-1 <noreply@anthropic.com>
…d store, and describe() under the never-abort rule (lead review r2 lows)

Co-Authored-By: brainlayerClaude running claude-fable-5-1 <noreply@anthropic.com>
@EtanHey EtanHey added the XS Extra-small change (400 lines or fewer) label Sep 5, 2026
@EtanHey

EtanHey commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

— brainlayerClaude (worker) · claude-code/claude-fable-5-1

@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_ef76202c-4c2d-440a-88d4-85f1116cb528)

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 44761b50-cc24-45b3-b9c6-8f958a3047fb

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa562c and 5a1ec60.

📒 Files selected for processing (2)
  • scripts/ci_ratchet_table.py
  • tests/test_ci_ratchet_table.py

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.

@deepsource-io

deepsource-io Bot commented Sep 5, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 8aa562c...5a1ec60 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Python Sep 5, 2026 12:47p.m. Review ↗
Swift Sep 5, 2026 12:47p.m. Review ↗
JavaScript Sep 5, 2026 12:47p.m. Review ↗
Shell Sep 5, 2026 12:47p.m. Review ↗
Secrets Sep 5, 2026 12:47p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

@EtanHey I will review pull request #771.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

BrainLayer ratchet

Every Value below was measured by this run. A row this machine cannot measure says n/a — <reason> instead of a number; baselines in Notes name their own machine, method and date and were not measured here.

Row Status Value (measured by this run) Method Notes
commit provenance 🔴 RED checkout 47133a95bcef is neither 5a1ec60b5c31 nor a merge of it — this run was triggered for a commit it does not have checked out commit graph + live PR head · in-process · runner Which commit this whole table is about. On a pull_request event the checkout is GitHub's synthetic merge ref, whose sha is not on the PR — #759's table printed 13fa724278bf while that PR's head was 4632f979 — so this row names the PR-head parent instead, the sha a reviewer can actually see. The comparison sha is read live from repos/{owner}/{repo}/pulls/{n} when the table is collected, not taken from the event payload, because the payload cannot know the run has been overtaken. Residual window, stated rather than papered over: a push landing between that read and the comment being posted is not caught here — the run for that push refreshes the table.
provenance 🟢 GREEN stamped 47133a95bcef == HEAD, tree clean wheel stamp · in-process · runner Sha half of #749 keg-mode provenance: a keg built from this wheel can answer __build_sha__. The helper-age and served-process predicates need a running BrainBar and are measured only by scripts/sprint_gate.py on an installed Mac. The sha here is the checkout's — the merge ref on a PR — because that is what publish.yml stamps at release time; the PR-head sha this table describes is the one in commit provenance above.
mapped bytes ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would socket · installed Mac Baseline 26.2 GB — installed Mac, socket, 2026-09-03, after R2 drained 15,070 → 0. Up from 16.8 GB because the drain left more vectors mapped under the same cap: the change is the drain, not a leak. Not measured by this run.
search p50/p95 ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would socket · installed Mac Margin p50: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin p95: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Calibrated on MacBook-Pro.local at 2026-09-01T08:42:22Z under active_sprint_load (tests/fixtures/sprint_gate/corpus.json). Not measured by this run.
idle CPU ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would ps sampling · installed Mac Ceiling: average CPU < 30% over a 60 s window (resource_budget in scripts/sprint_gate.py), ratified and kept as a hard budget. Margin daemon: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin helper: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin watcher: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Needs the BrainBar daemon, helper and watcher actually running. Not measured by this run.
signature_valid ⚪ n/a n/a — the macOS signature-parity job is trigger-gated and did not run on this PR: it touches no release or signing path (pyproject.toml, scripts/release-*, scripts/brainlayer-version-check.sh, publish.yml, ratchet.yml) and carries no ratchet:signatures label — a GitHub macOS runner bills at ~10× Linux minutes and rebuilds the keg venv from source codesign · installed keg scripts/release-verify-signatures.sh <keg> codesign-verifies every *.so/*.dylib under libexec/venv. The macOS parity job installs the published tap formula (etanhey/layers/brainlayer), so this row measures the release path — formula, published sdist and Homebrew's relocation — and not this PR's tree. Release-time baseline for the same keg on a different machine: 442 valid / 0 invalid — installed Mac (M4 Max), brew --prefix brainlayer 1.5.11, 2026-09-03.

🟢 GREEN measured, within budget · 🔴 RED measured, out of budget — a finding to clear before merge · ⚪ n/a not measurable on this machine, never guessed.

1 RED row(s) to clear: commit provenance.

Measured on Linux/x86_64 · measured 5a1ec60b5c31 · PR head 5a1ec60b5c31 · checkout 47133a95bcef · run · updated 2026-09-05 17:03:28 UTC

@EtanHey

EtanHey commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Supersedes #765 (closed by GitHub when its base branch wt/ratchet-c1-margins-module was deleted at the #763 merge). Same patch series, rebased onto main past 8aa562c3.

— brainlayer lead (brainlayerClaude-3303a978, claude-fable-5-1)

…after the rebase onto main

Whitespace only.

Co-Authored-By: brainlayerClaude running claude-fable-5-1 <noreply@anthropic.com>
Comment thread scripts/ci_ratchet_table.py Outdated
try:
margin = margins.margin_for(list(probe.attestations or ()), key)
sentences.append(f"Margin {name}: {margins.describe(margin, unit=unit)}.")
except (margins.AttestationError, ValueError) as error:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overlapping exceptions (ValueError is an ancestor class of margins.AttestationError)


Two or more exceptions in the same exception handler clause that are identical or parts of the same inheritance hierarchy (i.e. overlapping). It is recommmend to refactor this.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real, and fixed in 5a1ec60: margins.AttestationError subclasses ValueError, so except ValueError alone covers both the refused-band path and describe()'s refusal. Behaviour identical; the same two tests (test_a_band_that_cannot_be_formed_turns_its_row_red_not_the_collector_dead, test_a_describe_failure_is_a_row_problem_not_a_collector_abort) pass unchanged.

— brainlayerClaude (worker) · claude-code/claude-fable-5-1

@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_ca049f2d-c7ca-4300-9be0-288061b3d86a)

… (DeepSource overlapping-exceptions)

Same two paths covered by the same two tests; behaviour identical.

Co-Authored-By: brainlayerClaude running claude-fable-5-1 <noreply@anthropic.com>
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_e5e2df43-911d-47cb-810e-f29b1a595091)

@EtanHey
EtanHey merged commit 47133a9 into main Sep 5, 2026
18 checks passed
@EtanHey
EtanHey deleted the wt/ratchet-c3-table-margins branch September 5, 2026 13:04
@EtanHey EtanHey added the size:M Tight-loop PR size: 101-400 hand-written lines changed label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Tight-loop PR size: 101-400 hand-written lines changed XS Extra-small change (400 lines or fewer)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant