Skip to content

feat(facade): make defaults lightweight and add consumer-shaped smoke coverage#241

Merged
EffortlessSteven merged 3 commits into
mainfrom
slim-facade-defaults
Mar 12, 2026
Merged

feat(facade): make defaults lightweight and add consumer-shaped smoke coverage#241
EffortlessSteven merged 3 commits into
mainfrom
slim-facade-defaults

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

This changes the uselesskey facade to be lightweight by default and adds narrow consumer-shaped smoke coverage around that surface.

Public surface changes

  • change crates/uselesskey default features from ["rsa"] to []
  • add Seed::from_text(&str)
  • add Factory::deterministic_from_str(&str)

Why

The token path was already lightweight. The real issue was facade ergonomics:

  • bare uselesskey implied RSA
  • token-only consumers had to know to opt out of defaults
  • deterministic text seeds required more ceremony than they should for test helpers

This keeps token APIs feature-gated, removes the RSA-shaped default path, and adds a cleaner deterministic text-seed helper.

Guards

  • add a token-only fixture using:
    • default-features = false
    • features = ["token"]
  • add governance checks proving:
    • token-only facade usage compiles
    • the resolved graph does not include uselesskey-rsa
    • the resolved graph does not include rsa

Dogfooding

  • add facade-level order-independent determinism smoke
  • add facade-level X.509 smoke
  • add a downstream-style published_facade_smoke integration test
  • add a matching public X.509 doctest

Testing

  • cargo test -p uselesskey-core-seed
  • cargo test -p uselesskey-core --test factory_text_seed
  • cargo test --manifest-path tests/fixtures/token_only_facade/Cargo.toml --quiet
  • cargo test -p uselesskey-integration-tests --test governance
  • cargo test -p uselesskey-integration-tests --features api-surface --test api_surface
  • cargo test -p uselesskey-integration-tests --features builder-patterns --test builder_patterns
  • cargo test -p uselesskey --features full --test facade
  • cargo test -p uselesskey-integration-tests --features determinism --test published_facade_smoke
  • cargo test -p uselesskey --doc --features full -j 1
  • cargo test -p uselesskey --doc --no-default-features --features token
  • cargo test -p uselesskey --no-default-features --features token --test feature_combinations --test feature_isolation
  • cargo xtask gate

Release note

This is a consumer-visible feature-surface change and should ship as the next minor pre-1.0 release, not a patch release.

@coderabbitai

coderabbitai Bot commented Mar 12, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

Release Notes

  • New Features

    • Added from_text() and deterministic_from_str() methods for simplified seed and factory initialization from text input.
    • Created token-only usage configuration option.
  • Documentation

    • Updated guides to reflect empty default feature set.
    • Clarified feature selection and enabling instructions.
  • Tests

    • Added comprehensive tests for deterministic initialization and feature combinations.
    • Added smoke tests validating facade functionality.

Walkthrough

This PR introduces text-based seed constructors (Seed::from_text and Factory::deterministic_from_str), disables RSA as a default feature, and adds comprehensive tests, fixtures, and documentation to support feature-gated usage patterns.

Changes

Cohort / File(s) Summary
Core Seed API
crates/uselesskey-core-seed/src/lib.rs
Added Seed::from_text(text: &str) constructor that hashes input verbatim with BLAKE3. Modified Seed::from_env_value to delegate non-64-char hex inputs to from_text. Includes unit tests verifying verbatim hashing and hex non-parsing behavior.
Core Factory API
crates/uselesskey-core/src/factory.rs
Added Factory::deterministic_from_str(text: &str) constructor that hashes text via Seed::from_text and delegates to existing deterministic path. Documented behavior regarding whitespace and hex interpretation.
Feature Configuration
crates/uselesskey/Cargo.toml
Changed default features from ["rsa"] to [], making RSA opt-in rather than default.
Public API & Tests
tests/api_surface.rs, tests/builder_patterns.rs
Updated API surface snapshots and added tests validating Factory::deterministic_from_str and Seed::from_text public constructors and deterministic mode selection.
Facade & Feature Tests
crates/uselesskey/tests/facade.rs, crates/uselesskey/tests/feature_combinations.rs, crates/uselesskey/tests/feature_isolation.rs
Added deterministic facade order-independence test and X.509 reexport test. Renamed test modules and functions from default-feature nomenclature to explicit-rsa-feature naming to reflect feature changes.
Core API Tests
crates/uselesskey-core/tests/factory_text_seed.rs
Added two tests verifying deterministic_from_str text seed behavior and that hex-shaped strings are hashed verbatim rather than parsed.
Documentation
crates/uselesskey/README.md, crates/uselesskey/src/lib.rs
Updated examples to reflect empty default features, RSA as opt-in, and new deterministic_from_str constructor. Added Feature Selection section clarifying usage patterns.
Token-Only Fixture
tests/fixtures/token_only_facade/Cargo.toml, tests/fixtures/token_only_facade/src/lib.rs, tests/fixtures/token_only_facade/.gitignore
Added new fixture package demonstrating token-only usage with RSA disabled. Includes smoke test validating token generation without RSA dependencies.
Governance & Integration Tests
tests/governance.rs, tests/Cargo.toml, tests/tests/published_facade_smoke.rs
Added integration test infrastructure to validate feature combinations, empty default feature set, and token-only facade compilation. Added published facade smoke tests exercising deterministic factories, RSA, tokens, and X.509 chains across operation orders.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A seed from text, no hex to parse,
New constructors gleam, a feature alas—
RSA opts in, tokens dance free,
Deterministic paths flow endlessly! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(facade): make defaults lightweight and add consumer-shaped smoke coverage' clearly summarizes the main changes: making the uselesskey facade lightweight by default and adding comprehensive test coverage.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the public surface changes, rationale, guards, dogfooding tests, and testing strategy.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch slim-facade-defaults

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 and usage tips.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the uselesskey facade to be lightweight by default, removing the implicit dependency on RSA features. This change improves ergonomics for consumers who only need token-related functionalities, allowing them to opt into specific features explicitly. Additionally, new helper methods for deterministic seed and factory creation from plain text were introduced, simplifying testing and setup.

Highlights

  • Default Features: The uselesskey facade's default features were changed from ["rsa"] to [], making it lightweight by default and requiring explicit feature selection.
  • Deterministic Seed Generation: A new Seed::from_text(&str) method was added to derive seeds directly from plain text using BLAKE3 hashing.
  • Deterministic Factory Creation: A new Factory::deterministic_from_str(&str) method was introduced to create deterministic factories from plain text, simplifying test setup.
Changelog
  • crates/uselesskey-core-seed/src/lib.rs
    • Added Seed::from_text method and updated Seed::from_env_value to utilize it.
    • Added new tests for Seed::from_text to verify verbatim hashing and non-parsing of hex-shaped strings.
  • crates/uselesskey-core/src/factory.rs
    • Implemented Factory::deterministic_from_str for text-based deterministic factory creation.
  • crates/uselesskey-core/tests/factory_text_seed.rs
    • Added new tests to verify Factory::deterministic_from_str behavior, including its use of text seeds and avoidance of environment parsing conventions.
  • crates/uselesskey/Cargo.toml
    • Modified the default features to be empty, requiring explicit feature selection.
  • crates/uselesskey/README.md
    • Updated documentation to reflect the new default feature behavior, Seed::from_text, and Factory::deterministic_from_str.
    • Added a 'Feature Selection' section with examples for token-only consumers.
    • Adjusted 'Quick Start' and 'Deterministic Mode' examples to use Factory::deterministic_from_str and explicitly enable RSA features.
  • crates/uselesskey/src/lib.rs
    • Enhanced crate-level documentation with details on feature selection, quick start, and X.509 chains, aligning with the new default features.
    • Updated code examples to use Factory::deterministic_from_str and explicitly enable features.
  • crates/uselesskey/tests/facade.rs
    • Added a test for order-independent determinism across token and RSA factory calls.
    • Added a test for X.509 re-export functionality.
  • crates/uselesskey/tests/feature_combinations.rs
    • Renamed the test module from default_feature_rsa to explicit_rsa_feature and the test function from default_feature_provides_rsa to rsa_feature_provides_rsa to reflect the change in default features.
  • crates/uselesskey/tests/feature_isolation.rs
    • Renamed the test module from default_feature_includes_rsa to explicit_rsa_feature and test functions to reflect explicit RSA feature usage.
  • tests/Cargo.toml
    • Registered a new published_facade_smoke integration test.
  • tests/api_surface.rs
    • Added a test for Factory::deterministic_from_str to verify its mode.
    • Updated the API shape snapshot to include Factory::deterministic_from_str and Seed::from_text.
  • tests/builder_patterns.rs
    • Added a test for Factory::deterministic_from_str to verify its mode.
    • Added a test for Seed::from_text to verify its deterministic behavior.
  • tests/fixtures/token_only_facade/.gitignore
    • Added a .gitignore file for the new token-only fixture.
  • tests/fixtures/token_only_facade/Cargo.toml
    • Created a new Cargo.toml for the token-only facade fixture, explicitly disabling default features and enabling the token feature.
  • tests/fixtures/token_only_facade/src/lib.rs
    • Added a smoke test for the token-only facade fixture to ensure basic functionality.
  • tests/governance.rs
    • Added new functions for cargo metadata parsing and reachable package name analysis.
    • Introduced a governance test to assert that the facade's default feature set is empty.
    • Added governance tests to ensure the token-only fixture compiles and does not inadvertently resolve uselesskey-rsa or rsa dependencies.
  • tests/snapshots/api_surface__api_shape_snapshots__core_types_shape.snap
    • Updated the API snapshot to include the newly added Seed::from_text and Factory::deterministic_from_str methods.
  • tests/tests/published_facade_smoke.rs
    • Added a new integration test to verify the published facade's behavior and determinism across different fixture types and call orders.
Activity
  • A new token-only fixture was added to verify lightweight facade usage without default features.
  • Governance checks were implemented to confirm that the token-only facade compiles and does not inadvertently include uselesskey-rsa or rsa dependencies.
  • New smoke tests were introduced to validate facade-level order-independent determinism.
  • Facade-level X.509 smoke tests were added to ensure proper functionality.
  • A published_facade_smoke integration test was added to simulate downstream consumer usage.
  • A public X.509 doctest was added for comprehensive documentation and testing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the uselesskey facade to be lightweight by default, changing the default features from ["rsa"] to []. This is a significant, intentional breaking change. To improve ergonomics, new helpers Seed::from_text and Factory::deterministic_from_str are introduced. The changes are supported by extensive updates to documentation and a robust testing strategy, including new governance tests that verify the dependency graph of a token-only consumer. My feedback includes a suggestion to optimize a test helper function in tests/governance.rs to reduce string allocations.

Comment thread tests/governance.rs
Comment on lines +73 to +106
fn reachable_package_names(metadata: &Metadata, root_id: &str) -> BTreeSet<String> {
let node_map = metadata
.resolve
.nodes
.iter()
.map(|node| (node.id.as_str(), node.dependencies.as_slice()))
.collect::<std::collections::BTreeMap<_, _>>();
let package_names = metadata
.packages
.iter()
.map(|pkg| (pkg.id.as_str(), pkg.name.as_str()))
.collect::<std::collections::BTreeMap<_, _>>();

let mut seen = BTreeSet::new();
let mut stack = vec![root_id.to_string()];

while let Some(id) = stack.pop() {
if !seen.insert(id.clone()) {
continue;
}

if let Some(deps) = node_map.get(id.as_str()) {
stack.extend(deps.iter().map(|dep| dep.to_string()));
}
}

seen.into_iter()
.filter_map(|id| {
package_names
.get(id.as_str())
.map(|name| (*name).to_string())
})
.collect()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The implementation of reachable_package_names involves several string allocations within the graph traversal loop (e.g., id.clone(), dep.to_string()). While performance is not critical for this test helper, you can make it more efficient by working with string slices (&str) for the traversal, reducing unnecessary allocations.

fn reachable_package_names(metadata: &Metadata, root_id: &str) -> BTreeSet<String> {
    let node_map = metadata
        .resolve
        .nodes
        .iter()
        .map(|node| (node.id.as_str(), node.dependencies.as_slice()))
        .collect::<std::collections::BTreeMap<_, _>>();
    let package_names = metadata
        .packages
        .iter()
        .map(|pkg| (pkg.id.as_str(), pkg.name.as_str()))
        .collect::<std::collections::BTreeMap<_, _>>();

    let mut seen = BTreeSet::new();
    let mut stack = vec![root_id];

    while let Some(id) = stack.pop() {
        if !seen.insert(id) {
            continue;
        }

        if let Some(deps) = node_map.get(id) {
            stack.extend(deps.iter().map(String::as_str));
        }
    }

    seen.into_iter()
        .filter_map(|id| package_names.get(id).map(|&name| name.to_string()))
        .collect()
}

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/fixtures/token_only_facade/src/lib.rs`:
- Line 1: This crate root is missing the crate-level safety attribute; add the
directive #![forbid(unsafe_code)] at the top of src/lib.rs (before any items or
cfg attributes like #[cfg(test)]) so the crate enforces the repo-wide ban on
unsafe code; ensure the attribute is placed at the very top of the file so it
applies to tests and all modules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 01a8e3e4-4711-4f9e-a8b5-f197d19118bc

📥 Commits

Reviewing files that changed from the base of the PR and between 8174cc7 and 48ba95d.

⛔ Files ignored due to path filters (1)
  • tests/snapshots/api_surface__api_shape_snapshots__core_types_shape.snap is excluded by !**/*.snap
📒 Files selected for processing (17)
  • crates/uselesskey-core-seed/src/lib.rs
  • crates/uselesskey-core/src/factory.rs
  • crates/uselesskey-core/tests/factory_text_seed.rs
  • crates/uselesskey/Cargo.toml
  • crates/uselesskey/README.md
  • crates/uselesskey/src/lib.rs
  • crates/uselesskey/tests/facade.rs
  • crates/uselesskey/tests/feature_combinations.rs
  • crates/uselesskey/tests/feature_isolation.rs
  • tests/Cargo.toml
  • tests/api_surface.rs
  • tests/builder_patterns.rs
  • tests/fixtures/token_only_facade/.gitignore
  • tests/fixtures/token_only_facade/Cargo.toml
  • tests/fixtures/token_only_facade/src/lib.rs
  • tests/governance.rs
  • tests/tests/published_facade_smoke.rs

@@ -0,0 +1,11 @@
#[cfg(test)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add crate-level #![forbid(unsafe_code)].

This new fixture crate root skips the repo-wide unsafe ban, so it does not enforce the same safety baseline as the other crates.

Proposed fix
+#![forbid(unsafe_code)]
+
 #[cfg(test)]
 mod tests {

As per coding guidelines, "All crates must use #![forbid(unsafe_code)] at the crate root".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[cfg(test)]
#![forbid(unsafe_code)]
#[cfg(test)]
mod tests {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/fixtures/token_only_facade/src/lib.rs` at line 1, This crate root is
missing the crate-level safety attribute; add the directive
#![forbid(unsafe_code)] at the top of src/lib.rs (before any items or cfg
attributes like #[cfg(test)]) so the crate enforces the repo-wide ban on unsafe
code; ensure the attribute is placed at the very top of the file so it applies
to tests and all modules.

@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: 48ba95dc86

ℹ️ 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".

```toml
[dev-dependencies]
uselesskey = "0.2"
uselesskey = { features = ["rsa"] }

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 Add version to README dependency snippets

The new Cargo.toml examples omit version/path for uselesskey (e.g. uselesskey = { features = ["rsa"] }), which makes the snippets invalid for downstream users copying them into a normal project: Cargo rejects dependency specs that provide only feature flags. This regresses the quick-start path introduced in this commit, so the examples should include an explicit version (or another valid source such as path/workspace = true).

Useful? React with 👍 / 👎.

@EffortlessSteven EffortlessSteven merged commit b3dbfe7 into main Mar 12, 2026
4 checks passed
@EffortlessSteven EffortlessSteven deleted the slim-facade-defaults branch March 12, 2026 10:08
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