Skip to content

refactor: simplify SesState::reset and prefer vec![] in bedrock#312

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+idiom-consistency
Apr 12, 2026
Merged

refactor: simplify SesState::reset and prefer vec![] in bedrock#312
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+idiom-consistency

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 12, 2026

Summary

Two small idiom-consistency fixes:

  • SesState::reset open-coded "reinit every field except account_id and region" as a 25-line mirror of SesState::new. Delegates by swapping out account_id / region with mem::take and reassigning *self = Self::new(...). The reset path can no longer silently drift from new when new state fields are added.
  • 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.

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> vs String-with-default semantic distinctions) rather than real inconsistency.

Test plan

  • cargo build --workspace
  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance — 1102 passed, 0 failed
  • CI green

Summary by cubic

Simplifies fakecloud-ses SesState::reset by reusing new, avoiding field-by-field resets and preventing drift; keeps account_id and region intact. Also updates fakecloud-bedrock list_foundation_models to use vec![] instead of Vec::new() for consistency.

Written for commit a627835. Summary will update on new commits.

- ``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.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@vieiralucas vieiralucas merged commit f0d1036 into main Apr 12, 2026
22 of 23 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+idiom-consistency branch April 12, 2026 23:05
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