Repository navigation
TCB: dispatch each function's implementations in the order its file lists them - #4685
Merged
Merged
Conversation
This was referenced Nov 8, 2026
|
This pull request has conflicts with Posted by |
…ists them A dispatcher's implementations were the artifacts of a module whose names extend the base's with `_<suffix>`, with its signature and documentation (`Rust.groupsOf`), tried in the order the untrusted `Dispatch.lean` ranked their suffixes, a suffix of several parts parsed back into ranked parts (`partsOf`, `lexLe`). The emitter found the generic callers and variants whose instances made those suffixes by their files' paths. Now: * `Artifact.base` is the name of the function an artifact implements, its `Api`'s (`Api.artifact`; by default its own name), and a function's implementations are the artifacts of its base (`groupsOf`), each with the `Api`'s signature and documentation (`checkGroups`); * its dispatcher tries them in the order its registration file lists them: every implementation of a function is in one registration file (`Emit.checkSources`, from the driver's list of each module's artifacts), and the tables of functions in the order the artifacts list them (`fnTables`, no longer sorted by name); * one it would never choose (it needs every feature of one before it, or more) fails the emitter, rather than being left out (`armsOf`); * the emitter no longer finds variants and generic files (`Emit.grouped`, `genericGroups`, `instances`, `allOf`: the registration files apply generic callers to lists of variants themselves), nor ranks suffixes (`Rank`, `rankOf`, `partsOf`, `lexLe`, `checkRanks` and `Dispatch.lean` are gone), nor emits an artifact as another name of one with the same code (`alias`, `sameKey`). What the dispatchers call is unchanged but for five on x86-64, whose implementations come from two lists (a caller of two variants' functions: Ed25519's three functions, by SHA-512 and field arithmetic, and AES-GCM's two streaming ones, by CTR and GHASH): they now try them by the first list, then the second, which differs from the old order only between implementations whose features no CPU tells apart (SHA-512's extensions without ADX, VAES without VPCLMULQDQ). Every dispatcher's documentation now says it tries them in the order its registration file lists them. Part of #4548. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFjAR7Byf513R4zuFy
alex
force-pushed
the
claude/vg-dispatch-by-api
branch
from
November 8, 2026 20:43
c4cdac8 to
abf6ffa
Compare
alex
enabled auto-merge
November 8, 2026 20:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #4548. This PR changes trusted code. It only removes trusted machinery or makes it stricter: no ISA model, contract or
Verifiedchanges. It is stacked on #4682, which orders every list and registration file best first.Trusted changes
TCB/Registration.lean:Artifact.base: the name of the function an artifact implements, which is itsApi's name.Api.artifactsets it. An artifact built directly defaults to its own name, so it is a function of its own, as before.TCB/Rust.lean:base(groupsOf). They are no longer found by the name prefix_<suffix>together with an equal signature and documentation. Every implementation must have its base's signature and documentation, otherwise the emitter fails (checkGroups).fnTablesno longer sorts tables by name. Deleted:Rank,Ranking,rankOf,partsOf,lexLe,checkRanks, therankingparameter offilesand of the dispatcher builders, andDispatch.lean.armsOf). It used to be dropped silently.alias,sameKeyandaliasKeyare gone, along with the alias check incheckFnTables. Every artifact is now emitted as its own function. Variants and registrations list their implementations best first #4682 removed the only duplicates.TCB/Emit.lean:variantDir,genericDir,groupOf,grouped,variantOf,interfacesOf,genericGroups,allOf,varName,instances). Since Variants are lists; generic callers are ordinary registration files #4654, registration files apply generic callers to lists of variants themselves.runchecks that all the implementations of a function are in one registration file (checkSources), so their order there is the order the dispatcher tries them in.qualifiedNamestays as a naming helper; its uniqueness is checked bycheckUnique.Untrusted changes:
lean/Emit.leanandEmitOne.leanno longer pass groups of variants or generic files.VerifiedGarbageTest/Dispatch.leanandEmit.lean) now check the list order, the never-chosen error, the signature and documentation check,checkSources, and table groups in list order.lean/README.mdand theadding-a-primitiveskill are updated.Generated crates
Every dispatcher's documentation now says it tries its implementations "in the order its registration file lists them". Otherwise, what the dispatchers call is unchanged, except for five dispatchers on x86-64. Each of those chooses among implementations built from two variant lists, and now tries them by the first list, then the second:
_shaniis now tried before_avx2_ifma_shani_adxfirst either way_vaes(VAES without VPCLMULQDQ) is now tried before_aesni_vpclmulI compared every dispatcher with the base branch's; these five are the only differences. They choose the same implementation on every real CPU.
Checks
lake build, including the golden tests, passes.Emit.leanpasses, with every audit.check_lean_public_imports.pypasses.cargo clippy --all-targets -- -D warnings,cargo fmt --checkandcargo testpass.Generated by Claude Code