refactor(a2a,index): pre-hash auth token at startup; add NodeKind and Lang newtypes#4438
Merged
Merged
Conversation
d6cc81c to
7a9f449
Compare
7a9f449 to
029f6c3
Compare
… Lang newtypes Closes #4389, Closes #4390 zeph-a2a: AuthConfig now stores token_hash: Option<blake3::Hash> computed once at construction via AuthConfig::new(). auth_middleware compares hashes with subtle::ConstantTimeEq instead of re-hashing on every request. Raw token string is not retained in memory after startup. zeph-index: Add NodeKind(pub String) newtype for tree-sitter node kinds with Display, AsRef<str>, From<String>, From<&str>. Add Lang::from_id to parse language from stored &str. SearchHit::node_type is now NodeKind and SearchHit::language is now Lang, making invalid states unrepresentable.
11071b8 to
e10dbb1
Compare
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.
Summary
AuthConfignow pre-hashes the bearer token once at construction using BLAKE3.auth_middlewarecompares 32-byte digests viasubtle::ConstantTimeEq. The raw token string is not retained in memory after startup — consistent withzeph-gateway.NodeKind(pub String)newtype for tree-sitter node kinds (withDisplay,AsRef<str>,From<String>,From<&str>). AddedLang::from_idfor parsing language from stored&str.SearchHit::node_typeis nowNodeKindandSearchHit::languageis nowLang, making invalid states unrepresentable at the type level.Test plan
cargo +nightly fmt --check— cleancargo clippy --workspace -- -D warnings— cleancargo nextest run -p zeph-a2a -p zeph-index --lib— 204/204 passCloses #4389
Closes #4390