Skip to content

docs: settle what actually compiles vendor/chacha20; board hygiene for #264/#265 - #266

Merged
AdaWorldAPI merged 3 commits into
masterfrom
claude/tier-correction
Jul 29, 2026
Merged

docs: settle what actually compiles vendor/chacha20; board hygiene for #264/#265#266
AdaWorldAPI merged 3 commits into
masterfrom
claude/tier-correction

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Body rewritten after 35bc7db. The first version of this PR asserted that Dockerfile.avx512 compiles and ships vendor/chacha20's ndarray_simd backend. That was wrong — codex caught it. The corrected finding is below; the wrong version is preserved in the doc's own correction-history section rather than erased.

Operator correction that started this: cargo is CI is github needs V3; dockerfile is V4. That statement is right. What I then inferred from it was not.

A build claim has two axes

axis question where the answer lives
target-cpu which cfg-gated code is selected? .cargo/config*.toml, Dockerfile* RUSTFLAGS, workflow env: incl. per-job
package selection is that crate compiled at all? default-members, and the -p / --workspace flags on the actual command

I got each one wrong on a separate pass — the second while fixing the first.

Pass 1 (before this PR): "no default build runs ndarray_simd", reasoned only from .cargo/config.toml pinning v3. Right answer, incomplete reason.

Pass 2 (this PR's first commit): given the tier statement, I concluded Dockerfile.avx512 compiles and ships it. It does set -C target-cpu=x86-64-v4. It also runs a bare cargo build --release, which selects default-members — and crates/encryption is not among them:

$ for p in ndarray ndarray-rand ndarray-gen numeric-tests serialization-tests; do
      cargo tree -p "$p" -i chacha20; done
error: package ID specification `chacha20` did not match any packages   # ×5

$ cargo tree -p encryption -i chacha20
chacha20 v0.9.1 (vendor/chacha20)
└── chacha20poly1305 v0.10.1
    └── encryption v0.1.0 (crates/encryption)

encryption is a workspace member via crates/*, so --workspace or -p encryption reaches it. Neither Dockerfile passes either.

Settled: no image in this repo compiles the backend. ndarray_simd is reached only by an explicit -p encryption / --workspace build under an AVX-512 config, or by a wasm32+simd128 build.

tier target-cpu builds encryption? chacha20 backend
CI (ci.yaml) none globally no not compiled
CI tier4-avx512-check v4, per-job no — -p ndarray not compiled
Dockerfile v3 no — bare cargo build not compiled
Dockerfile.avx512 v4 no — bare cargo build not compiled
dev cargo build -p encryption v3 yes RustCrypto avx2/sse2
--config .cargo/config-avx512.toml sapphirerapids yes ndarray_simd
wasm32 + simd128 if selected ndarray_simd

The other correction still stands

The TD-T22 note filed "CI has been testing different machine code than anyone reviews" as a ⚠ defect. It is the design, and ci.yaml:17-22 says so in prose I hadn't read: a global target-cpu collides with the cross_test matrix (i686 is 32-bit, s390x isn't x86) and contradicts the one-binary + runtime LazyLock<Tier> intent. The v4 arm is covered per-job by tier4-avx512-check, deliberately via CARGO_TARGET_<triple>_RUSTFLAGS because plain RUSTFLAGS also reaches host build scripts, which SIGILL on a runner without AVX-512 silicon. That section is reframed from defect to design.

The manifest comment, settled rather than flipped again

Cargo.toml:481's parenthetical — "the workspace's target-cpu=x86-64-v4" — does name a real tier, so it's imprecise rather than false. But its main clause, "transitively accelerates the encryption crate's XChaCha20-Poly1305 keystream", holds only for a build that selects encryption, and none of the images do. Still not edited: manifest strings need a ruling. Recorded so the next reader isn't misled.

Board hygiene

Owed since #264 and #265, not paid at the time.

EPIPHANIES.md gains two entries. The build-tier one is written around the two-axis lesson above, and keeps the part I'd otherwise have been tempted to smooth: being handed the missing piece felt like completion, so the correction shipped faster and more confidently than the original claim, and was more wrong. A correction is a new claim and earns no discount on verification. It ends in the four commands that would have caught it.

The second entry records the BLAKE3 result (twelve of fifteen intrinsics already exist on U32x16; the transpose needs composition, not intrinsics) together with its own review catch — the first version rested on a single stage whose helpers cannot compose into a transpose, and the fix added a correctness check plus made run.sh actually execute the probe binary, since --emit asm links nothing and the assertion had never run.

AGENT_LOG.md gains the run entry for both PRs.

Still open

  1. Throughput. No benchmark for the ndarray lane vs rust_avx2.rs, or ndarray_simd vs upstream 0.10.1's own avx512.rs. This decides item 2.
  2. Fork vs vendored copy. AdaWorldAPI/stream-ciphers is a bare upstream mirror (same head sha, same chacha20/ tree hash, 0 commits ahead), so "track the fork" means "track upstream 0.10.1" — a cipher major from the vendored 0.9.1.
  3. Whether the chacha20 cfg gate should gain a runtime arm, matching ndarray's LazyLock<Tier> dispatch. Only worth it if (1) favours the ndarray lane.
  4. Whether the images should build encryption at all. Newly visible from the above, and genuinely a product question rather than a doc one — not answered here.

Docs and board only. No product code, no .cargo or manifest changes.

Operator correction: cargo is CI is github needs V3; dockerfile is V4.

Two conclusions published this week were scoped wrong. Both were built on
correct measurements and both attached a quantifier the evidence could not
support, because the audit read .cargo/config.toml and never enumerated the
Dockerfiles.

1. "No default build of any repo runs vendor/chacha20's ndarray_simd
   backend." True of `cargo build`, false about what ships.
   Dockerfile.avx512 pins target-cpu=x86-64-v4, so avx512f is present and the
   backend IS compiled. It is the deployed path on AVX-512 silicon, not dead
   code. The related filing against Cargo.toml:481 -- that "the workspace's
   target-cpu=x86-64-v4" is a factual error -- is withdrawn: that names a
   real tier, it just is not the one cargo build selects.

2. "CI has been testing different machine code than anyone reviews", filed
   as a defect in the TD-T22 note. It is the design. ci.yaml:17-22 records
   the reason -- a global pin collides with the cross_test matrix (i686 is
   32-bit, s390x is not x86) and contradicts the one-binary + runtime
   LazyLock<Tier> intent -- and the v4 arm is covered per-job by
   tier4-avx512-check, deliberately via CARGO_TARGET_<triple>_RUSTFLAGS
   because plain RUSTFLAGS also reaches host build scripts, which then SIGILL
   on a runner without AVX-512.

Both docs now carry the three-tier table (CI / Dockerfile v3 /
Dockerfile.avx512 v4) and a second-order note that matters when reasoning
about a deployed binary: ndarray's own SIMD upgrades at run time via
LazyLock<Tier> even in a v3 build, while vendor/chacha20's gate is
compile-time cfg with no runtime fallback. "This build is v3" therefore does
not settle what a given subsystem selects.

Board hygiene, owed since #264 and #265 and not paid at the time:

- EPIPHANIES gains two entries. One names the pattern behind both errors --
  a claim quantified over "every build" needs an enumeration of builds, and
  `find . -iname 'Dockerfile*'` is that enumeration. The other records the
  BLAKE3 result (twelve of fifteen intrinsics already exist on U32x16; the
  transpose needs composition, not intrinsics) together with the review catch
  that the first version of it rested on a single stage that could not
  compose into a transpose.
- AGENT_LOG gains the run entry for both PRs with commits, outcomes, review
  disposition, and the open items.
@cursor

cursor Bot commented Jul 29, 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_2ce33628-f3b5-4217-a877-9866e293bf4d)

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@AdaWorldAPI, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cd375b15-f0c0-4733-9d71-12c98532abc5

📥 Commits

Reviewing files that changed from the base of the PR and between a041a24 and 5f8f453.

📒 Files selected for processing (4)
  • .claude/board/AGENT_LOG.md
  • .claude/board/EPIPHANIES.md
  • .claude/knowledge/chacha20-vendoring-blast-radius.md
  • .claude/knowledge/td-t22-asm-investigation.md
📝 Walkthrough

Walkthrough

The PR updates investigation and knowledge documentation to correct chacha20 SIMD backend reachability, clarify CI and Docker target tiers, document BLAKE3 SIMD findings, and record validation results and remaining questions.

Changes

SIMD build and investigation audit

Layer / File(s) Summary
Backend reachability and SIMD findings
.claude/knowledge/chacha20-vendoring-blast-radius.md, .claude/board/EPIPHANIES.md
Documents v4 compilation and compile-time gating of the chacha20 ndarray_simd backend, while recording BLAKE3 SIMD implementation findings and unmeasured throughput.
CI tier interpretation
.claude/knowledge/td-t22-asm-investigation.md, .claude/board/AGENT_LOG.md
Corrects the CI analysis, distinguishes runtime-dispatch CI from Docker-pinned targets, and records the resulting conclusions and open questions.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • AdaWorldAPI/ndarray#262: Updates the related TD-T22 assembly and instruction-histogram investigation documentation.

Suggested reviewers: claude

Poem

I’m a rabbit with notes in a neat little row,
Chasing SIMD paths where the fast builds go.
CI hops one way, Docker hops two,
BLAKE3 leaves questions in morning dew.
The audit is patched, the findings are bright—
I nibble the logs and declare them just right! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the docs-only scope: clarifying vendor/chacha20 build behavior and updating board records for #264/#265.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a041a242be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +93 to +95
**So `ndarray_simd` is not dead code — `Dockerfile.avx512` is the tier that
compiles it.** The earlier headline here ("no default build of any repo runs
it") was true of `cargo build` and false as a statement about what ships,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Account for Docker's default-member selection

The AVX-512 Dockerfile invokes cargo build at the workspace root without --workspace or -p encryption, while Cargo.toml:436-443 omits crates/encryption from default-members; none of the selected default packages depends on ChaCha20. Consequently, setting the v4 RUSTFLAGS does not compile vendor/chacha20 at all, and the Dockerfile's later build/test commands do not add encryption either. The claim that this backend is compiled and shipped by Dockerfile.avx512 therefore reverses the earlier audit on an invalid premise; it is reached only by an explicit encryption/full-workspace build or the separate wasm vendor build.

Useful? React with 👍 / 👎.

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.

Confirmed and fixed in 35bc7db. You're right, and this PR's whole premise was wrong.

Verified per package rather than reasoned:

$ for p in ndarray ndarray-rand ndarray-gen numeric-tests serialization-tests; do
      cargo tree -p "$p" -i chacha20; done
error: package ID specification `chacha20` did not match any packages   # ×5

$ cargo tree -p encryption -i chacha20
chacha20 v0.9.1 (vendor/chacha20)
└── chacha20poly1305 v0.10.1
    └── encryption v0.1.0 (crates/encryption)

Both Dockerfiles run bare cargo build --release, default-members (Cargo.toml:436-443) omits crates/encryption, and nothing else in that set pulls chacha20. encryption is a member via crates/*, so --workspace or -p encryption reaches it — neither image passes either. So no image in this repo compiles the backend; it's reached only by an explicit -p encryption / --workspace build under an AVX-512 config, or by wasm32+simd128.

The tier statement I was given (cargo is CI is github needs V3; dockerfile is V4) was correct throughout. What it doesn't imply is that either image builds the crate that pulls chacha20 — that's the step I skipped.

The manifest-comment finding is re-settled rather than flipped again: Cargo.toml:481's parenthetical does name a real tier, so it's imprecise rather than false, but its main clause — "transitively accelerates the encryption crate's keystream" — holds only for a build that selects encryption, and none of the images do. Still not edited; manifest strings need a ruling.

The board entry is rewritten around the actual lesson, which is sharper than the one I'd written. A build claim has two axes — target-cpu decides which cfg-gated code is selected, package selection decides whether the crate is compiled at all — and I got each wrong on a separate pass, the second while fixing the first. The part worth keeping: being handed the missing piece felt like completion, so the correction shipped faster and more confidently than the original claim, and was more wrong. A correction is a new claim and earns no discount on verification.


Generated by Claude Code

codex on #266 caught that the previous commit's fix was itself wrong, and it
was right.

I claimed Dockerfile.avx512 compiles and ships vendor/chacha20's ndarray_simd
backend, on the strength of its RUSTFLAGS="-C target-cpu=x86-64-v4". It does
set v4. It also runs a bare `cargo build --release`, which selects
default-members -- ".", ndarray-rand, crates/ndarray-gen, crates/numeric-tests,
crates/serialization-tests -- and crates/encryption is not among them. Verified
per package:

  $ for p in ndarray ndarray-rand ndarray-gen numeric-tests \
             serialization-tests; do cargo tree -p "$p" -i chacha20; done
  error: package ID specification `chacha20` did not match any packages   # x5

  $ cargo tree -p encryption -i chacha20
  chacha20 v0.9.1 (vendor/chacha20)
  `-- chacha20poly1305 v0.10.1
      `-- encryption v0.1.0 (crates/encryption)

encryption IS a workspace member via crates/*, so --workspace or -p encryption
reaches it; neither Dockerfile passes either. So no image in this repo compiles
the backend. It is reached only by an explicit -p encryption / --workspace
build under an AVX-512 config, or by wasm32+simd128.

The operator's tier statement was correct throughout. What it does not imply is
that either image builds the crate that pulls chacha20 -- which is the step I
skipped.

The manifest-comment finding is re-settled rather than flipped a second time:
the parenthetical "the workspace's target-cpu=x86-64-v4" does name a real tier,
so it is imprecise rather than false, but the sentence's main clause -- "this
transitively accelerates the encryption crate's keystream" -- holds only for a
build that selects encryption, and none of the images do. Still not edited;
manifest strings need a ruling.

The EPIPHANIES entry is rewritten around the actual lesson. A build claim has
two axes -- target-cpu decides which cfg-gated code is selected, package
selection decides whether the crate is compiled at all -- and I got each wrong
on a separate pass, the second while fixing the first. The part worth keeping:
being handed the missing piece feels like completion, so the correction shipped
faster and more confidently than the original claim and was more wrong. A
correction is a new claim and earns no discount on verification. Entry now ends
in the four commands that would have caught it.
@AdaWorldAPI AdaWorldAPI changed the title docs: correct the build-tier scope error; board hygiene for #264/#265 docs: settle what actually compiles vendor/chacha20; board hygiene for #264/#265 Jul 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/knowledge/chacha20-vendoring-blast-radius.md:
- Around line 82-86: Update the CI tier documentation around the default CI row
and tier4-avx512-check to distinguish ordinary builds from the targeted ndarray
v4-only check using x86-64-v4 and simd-avx512/avx-512. If claiming chacha20
AVX-512 coverage, add a separate entry with an explicit command that compiles
vendor/chacha20; otherwise limit the coverage statement to ndarray’s v4 path.

In @.claude/knowledge/td-t22-asm-investigation.md:
- Around line 229-232: Revise the “TD-T22's measurement is baseline-scoped”
section to distinguish the generic x86-64/SSE2 baseline selected when no
target-cpu is specified from the instructions actually emitted. State that
emitted code may remain scalar depending on the source and optimizer, and avoid
claiming that the no-target-cpu build necessarily produces SSE2 instructions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 908d739b-ed11-405c-82bd-03f2611326e4

📥 Commits

Reviewing files that changed from the base of the PR and between 58521c3 and a041a24.

📒 Files selected for processing (4)
  • .claude/board/AGENT_LOG.md
  • .claude/board/EPIPHANIES.md
  • .claude/knowledge/chacha20-vendoring-blast-radius.md
  • .claude/knowledge/td-t22-asm-investigation.md

Comment thread .claude/knowledge/chacha20-vendoring-blast-radius.md Outdated
Comment thread .claude/knowledge/td-t22-asm-investigation.md Outdated
…r4 claim

Two CodeRabbit findings on #266.

1. VALID, and it is the same imprecision one more time. The TD-T22 note said
   "a build with no target-cpu gets SSE2 codegen from the same source." That
   conflates the baseline ISA rustc SELECTS with the instructions LLVM
   actually EMITS -- and the CI histogram sitting two paragraphs above in the
   same document contradicts it: arx_rounds_u32x16 came back 0 packed / 146
   scalar / 491 memory. No target-cpu selects the generic x86-64 baseline, on
   which SSE2 is available; it does not follow that SSE2 instructions appear.
   The available ISA is a ceiling, not a prediction. Reworded to say that,
   citing the measurement that falsifies the old phrasing.

2. PARTLY VALID. The finding quotes tier4-avx512-check as running
   `-p ndarray --features "simd-avx512,avx-512"`; it actually runs
   `--features approx,serde,rayon` and a second step adding hpc-extras, so
   that detail is wrong. The underlying point is right and 35bc7db had
   already answered it in the table ("no -- -p ndarray"), but only in a
   column. Now stated in prose with the real command: the job is
   package-scoped to ndarray, so crates/encryption and therefore
   vendor/chacha20 sit outside it, and NO CI job compiles the chacha20
   AVX-512 backend. Added the explicit command that would close the gap
   (`-p encryption` under the v4 per-target RUSTFLAGS) without adding it --
   a CI job is a product change and this is a docs PR.

Copy link
Copy Markdown
Owner Author

Both findings handled in 5f8f453.

The SSE2 one is right, and it's the same imprecision a third time. I wrote "a build with no target-cpu gets SSE2 codegen from the same source." That conflates the baseline ISA rustc selects with the instructions LLVM actually emits — and the histogram sitting two paragraphs above in the same document falsifies it: arx_rounds_u32x16 came back 0 packed / 146 scalar / 491 memory. No target-cpu selects the generic x86-64 baseline, on which SSE2 is available; it does not follow that SSE2 instructions appear. The available ISA is a ceiling, not a prediction. Reworded to say exactly that, citing the measurement that contradicts the old phrasing.

The tier4 one is partly right. The quoted command isn't accurate — the job runs --features approx,serde,rayon (and a second step adding hpc-extras), not --features "simd-avx512,avx-512". But the substance holds, and 35bc7db had only answered it inside a table column. Now stated in prose with the real command:

Both its steps are cargo check --target=x86_64-unknown-linux-gnu -p ndarray --features approx,serde,rayon (the second adding hpc-extras) — package-scoped to ndarray, so crates/encryption and therefore vendor/chacha20 are outside it. No CI job compiles the chacha20 AVX-512 backend.

Plus the explicit command that would close the gap:

$ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-Ctarget-cpu=x86-64-v4" \
      cargo check --target=x86_64-unknown-linux-gnu -p encryption

Not added — a CI job is a product change and this is a docs PR. It's recorded as open point 4 instead, alongside the related question of whether the Docker images should build encryption at all.

Worth noting for anyone reading the thread: the walkthrough above still summarizes this PR as "documents v4 compilation … of the chacha20 ndarray_simd backend." That was a041a24's claim and it was wrong — codex caught it, and 35bc7db reversed it. Current state: no image and no CI job compiles that backend.


Generated by Claude Code

@AdaWorldAPI
AdaWorldAPI merged commit 3951501 into master Jul 29, 2026
19 checks passed
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.

2 participants