Skip to content

[live-proof only — will be closed] ratchet (b) combined: renders the baseline-attestation row on a real pull_request run - #768

Closed
EtanHey wants to merge 1 commit into
mainfrom
wt/ratchet-b-attestation
Closed

[live-proof only — will be closed] ratchet (b) combined: renders the baseline-attestation row on a real pull_request run#768
EtanHey wants to merge 1 commit into
mainfrom
wt/ratchet-b-attestation

Conversation

@EtanHey

@EtanHey EtanHey commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Not for review or merge. The real PRs are #766 (store) and #767 (row, stacked on #766). ratchet.yml only runs on PRs against main, so #767 cannot render its own row until it is retargeted after #766 merges. This draft carries the same code (954e102f) so the row's live output exists before the report claims done. Closed as soon as the table renders.

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

Note

Add baseline-attestation row to ratchet table using main workflow artifact

  • Adds .github/workflows/ratchet-attest.yml to publish a ratchet-attestation artifact on pushes to main containing the baseline fields (queries, latency_baseline_ms, thresholds), commit SHA, and run identity.
  • Updates .github/workflows/ratchet.yml to fetch the latest successful main attestation artifact and pass it to the collector in PR runs.
  • Extends scripts/ci_ratchet_table.py to evaluate the PR corpus against the attested main baseline. A PR is GREEN when the baseline matches the attestation or changes only to values recorded as measured by the main run.
  • Adds a bootstrap fallback for the first workflow-adding PR, which compares the baseline against the merge-base commit via Git.
  • Risk: Malformed, missing, or inconsistent attestation artifacts are now treated as a RED finding rather than ignored. A RED collector row in main runs prevents the artifact from being published.
📊 Macroscope summarized 954e102. 3 files reviewed, 6 issues evaluated, 0 issues filtered, 4 comments posted

🗂️ Filtered Issues

… against a number the PR wrote

The reference the table measures against is now the `ratchet-attestation`
artifact of the latest successful push run of ratchet-attest.yml on main, read
through the Actions API and bound to its run, never from the PR tree. A baseline
field that differs is RED ("changed by hand; no CI attestation for these
values") unless that main run measured the new value. Bootstrap (no attest run
on main yet) compares against the base tip via git and says so. Configuration
fields stay ordinary review; only queries / latency_baseline_ms / thresholds
are the baseline. Boundary stated, not overclaimed: inputs are outside the PR
tree, the comparator is not.

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

coderabbitai Bot commented Sep 5, 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

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 3ee7c27...954e102 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 11:35a.m. Review ↗
Swift Sep 5, 2026 11:35a.m. Review ↗
JavaScript Sep 5, 2026 11:35a.m. Review ↗
Shell Sep 5, 2026 11:35a.m. Review ↗
Secrets Sep 5, 2026 11:35a.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.


def attest_refusal(args: argparse.Namespace, probe: Probe, rows: list[Row]) -> str | None:
"""Why this run may NOT publish an attestation. None means it may."""
flags = (args.attest_out, args.main_sha, args.run_id, args.run_attempt)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium scripts/ci_ratchet_table.py:1305

attest_refusal allows --run-id 0 and negative --run-attempt values, so the writer publishes an artifact that read_attestation() rejects as naming no honest run. That leaves every PR's baseline-attestation row RED until another valid attestation replaces it; validate both values with honest_run_number before allowing publication.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @scripts/ci_ratchet_table.py around line 1305:

`attest_refusal` allows `--run-id 0` and negative `--run-attempt` values, so the writer publishes an artifact that `read_attestation()` rejects as naming no honest run. That leaves every PR's baseline-attestation row `RED` until another valid attestation replaces it; validate both values with `honest_run_number` before allowing publication.

# The API filters by branch; the event filter is in jq because the endpoint takes one
# `event` value and two (push, workflow_dispatch) are legitimate writers.
for attempt in 1 2 3; do
if gh api "repos/${REPO}/actions/workflows/ratchet-attest.yml/runs?branch=main&exclude_pull_requests=true&per_page=30" > "$runs_path" 2> "$err_path"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium workflows/ratchet.yml:441

After 30 newer failed or cancelled runs, this request treats the first page as having no successful attestation and emits --attestation-bootstrap, allowing the collector to use a green base-commit fallback even though a successful writer exists on a later page. Paginate the run list and search all returned pages before deciding that bootstrap applies.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @.github/workflows/ratchet.yml around line 441:

After 30 newer failed or cancelled runs, this request treats the first page as having no successful attestation and emits `--attestation-bootstrap`, allowing the collector to use a green base-commit fallback even though a successful writer exists on a later page. Paginate the run list and search all returned pages before deciding that bootstrap applies.

ATTESTATION_METHOD,
ATTESTATION_NOTES,
)
by_hand = [(path, old, new) for path, old, new in changes if attestation.measured.get(path, _UNMEASURED) != new]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium scripts/ci_ratchet_table.py:872

A PR can change a measured numeric 0 or 1 to False or True and still receive GREEN, even though the baseline value and type changed. This check uses equality alone, so Python treats 0 == False and 1 == True; include a type comparison here, matching baseline_changes, before authorizing the change.

-    by_hand = [(path, old, new) for path, old, new in changes if attestation.measured.get(path, _UNMEASURED) != new]
+    by_hand = [(path, old, new) for path, old, new in changes if (measured := attestation.measured.get(path, _UNMEASURED)) != new or type(measured) is not type(new)]
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @scripts/ci_ratchet_table.py around line 872:

A PR can change a measured numeric `0` or `1` to `False` or `True` and still receive `GREEN`, even though the baseline value and type changed. This check uses equality alone, so Python treats `0 == False` and `1 == True`; include a type comparison here, matching `baseline_changes`, before authorizing the change.

if probe.attestation is None:
reason = probe.attestation_unavailable or ATTESTATION_UNAVAILABLE_DEFAULT
return Row("baseline attestation", NA, f"n/a — {reason}", ATTESTATION_METHOD, ATTESTATION_NOTES)
return attested_row(probe.attestation, corpus, base_tip_of(probe.head_lineage))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium scripts/ci_ratchet_table.py:951

Deleting an attested baseline field whose value is JSON null renders the baseline attestation row GREEN instead of detecting a hand edit. baseline_changes uses dict.get() for both sides, so a present null and an absent path both become None; compare presence separately (for example, with a sentinel) so missing fields remain distinguishable from measured null values.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @scripts/ci_ratchet_table.py around line 951:

Deleting an attested baseline field whose value is JSON `null` renders the `baseline attestation` row GREEN instead of detecting a hand edit. `baseline_changes` uses `dict.get()` for both sides, so a present `null` and an absent path both become `None`; compare presence separately (for example, with a sentinel) so missing fields remain distinguishable from measured `null` values.

@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 🟢 GREEN measured 954e102f19e7 == PR head · checkout f4fff7d3645c 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.
baseline attestation 🟢 GREEN bootstrap: ratchet-attest.yml is not a registered workflow on main yet (HTTP 404); baseline 39152e4f0568 unchanged from base 3ee7c2795a73 by git — attestation begins with the first main run of .github/workflows/ratchet-attest.yml base commit via git (bootstrap) · in-process · runner What every comparison is measured AGAINST, and who says so. The baseline fields of tests/fixtures/sprint_gate/corpus.json (queries, latency_baseline_ms, thresholds) are compared to the ratchet-attestation artifact of the latest successful push run of ratchet-attest.yml on main, fetched through the Actions API — a PR run cannot write to another run's artifacts. A field that differs is RED unless that main run measured the new value; today no runner-side collector measures any baseline field, so today the baseline cannot move by PR at all, and this row says so instead of a hand edit passing. Boundary: the comparator is this PR's checkout of ci_ratchet_table.py, diff-reviewable, not tamper-proof.
provenance 🟢 GREEN stamped f4fff7d3645c == 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 Baseline p50 911.887 ms / p95 3167.985 ms, captured 2026-09-01T08:42:22Z on MacBook-Pro.local 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 Budget: average CPU < 30% over a 60 s window (resource_budget in scripts/sprint_gate.py). Needs the BrainBar daemon, helper and watcher actually running. Not measured by this run.
signature_valid 🟢 GREEN 442 valid / 0 invalid · brainlayer 1.5.13 · macos-15/ARM64 · brew install exited non-zero (outcome: failure); the keg installed and the sweep ran after it codesign · brew keg · GitHub macOS runner 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.

No RED rows.

Measured on Linux/x86_64 · measured 954e102f19e7 · PR head 954e102f19e7 · checkout f4fff7d3645c · run · updated 2026-09-05 11:42:02 UTC

@EtanHey

EtanHey commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Rendered. Run 33963754466 posted baseline attestation 🟢 bootstrap: ratchet-attest.yml is not a registered workflow on main yet (HTTP 404); baseline 39152e4f0568unchanged from base3ee7c27 by git, commit provenance 🟢 on 954e102f, no RED rows. This draft served its one purpose; the reviewable slices are #766 and #767.

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

@EtanHey EtanHey closed this Sep 5, 2026
@EtanHey
EtanHey deleted the wt/ratchet-b-attestation branch September 5, 2026 13:02
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