refactor: simplify SesState::reset and prefer vec![] in bedrock#312
Merged
vieiralucas merged 1 commit intomainfrom Apr 12, 2026
Merged
refactor: simplify SesState::reset and prefer vec![] in bedrock#312vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
- ``SesState::reset`` was open-coding what amounts to "reinit every field except account_id and region" as a twenty-five-line mirror of ``SesState::new``. Delegate by swapping out ``account_id``/``region`` with ``mem::take`` and reassigning ``*self = Self::new(...)``. The reset logic can no longer drift from ``new`` by accident. - ``bedrock::list_foundation_models`` used an explicit ``let mut model_summaries: Vec<Value> = Vec::new();``. Replaced with ``vec![]`` for consistency with the rest of the crate and to let inference pick up the type. Other audit-flagged "inconsistent idiom" sites were inspected and left alone — they turn out to be necessary for lock scoping, async-move closure captures, or semantic distinctions (``Option<String>`` vs ``String`` with a default) rather than real inconsistency. 1102 unit tests still pass.
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
Two small idiom-consistency fixes:
SesState::resetopen-coded "reinit every field except account_id and region" as a 25-line mirror ofSesState::new. Delegates by swapping outaccount_id/regionwithmem::takeand reassigning*self = Self::new(...). The reset path can no longer silently drift fromnewwhen new state fields are added.bedrock::list_foundation_modelsused an explicitlet mut model_summaries: Vec<Value> = Vec::new();. Replaced withvec![]for consistency with the rest of the crate.Scope note: several other audit-flagged "inconsistent idiom" sites were inspected and intentionally left alone — they turn out to be necessary (lock-scope clones, async-move captures,
Option<String>vsString-with-default semantic distinctions) rather than real inconsistency.Test plan
cargo build --workspacecargo fmt --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance— 1102 passed, 0 failedSummary by cubic
Simplifies
fakecloud-sesSesState::resetby reusingnew, avoiding field-by-field resets and preventing drift; keepsaccount_idandregionintact. Also updatesfakecloud-bedrocklist_foundation_modelsto usevec![]instead ofVec::new()for consistency.Written for commit a627835. Summary will update on new commits.