Skip to content

test: flare-vault: cheap Argon2 KDF params under test (8-25s per vault test today) - #814

Merged
getappz merged 2 commits into
masterfrom
task/652-flare-vault-cheap-argon2-kdf-params-unde
Sep 25, 2026
Merged

getappz merged 2 commits into
masterfrom
task/652-flare-vault-cheap-argon2-kdf-params-unde

Conversation

@getappz

@getappz getappz commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Hakari verified clean. Final status:

Done. Committed as 68a4acf on task/652-flare-vault-cheap-argon2-kdf-params-unde.

What changed:

  • flare-vault: KdfParams::default() now uses cheap Argon2 params (1/16KiB/1) under cfg(test) or the new insecure-fast-kdf feature; production stays 3/65536/4, pinned by a test. lib.rs has a compile_error! if the feature is on without debug_assertions, so it can't reach a release build. Root crate's Cargo.toml enables the feature only in [dev-dependencies].
  • Found and fixed a second, undocumented hot path: src/auth_crypt.rs (used by gateway_secrets.rs, and transitively by vault.rs migration tests) runs its own PBKDF2-HMAC-SHA256 KDF at 600,000 iterations, entirely separate from flare-vault's Argon2. This — not flare-vault — was why gateway_secrets::tests::* (12-14.6s) and vault::tests::migrates_legacy_gateway_secret_on_first_unlock/migration_does_not_overwrite_an_existing_vault_secret stayed slow even after the flare-vault fix. Now drops to 1 iteration under cfg(test) (same-crate, so no feature-flag plumbing needed), production count pinned by a test.
  • Fixed a dead_code/assertions_on_constants clippy break the prior round's FAST_KDF const introduced (removed it, simplified the test that used it).

Verified (foreground):

  • cargo fmt --check — clean
  • cargo clippy -p flare-vault --all-targets --all-features -D warnings -A unsafe_code -A clippy::pedantic — clean
  • cargo clippy -p agentflare --all-targets --all-features same flags — clean except one pre-existing, unrelated dead-code error in src/agent_launch_tests.rs (from master commit 7731882, not touched by this diff — full-workspace clippy will still fail until that's fixed separately)
  • cargo hakari generate --diff / verify — no diff needed
  • cargo nextest run -p flare-vault: 25/25 pass, all <0.4s (was ~8.3-8.6s)
  • cargo nextest run --bin agentflare vault:: gateway_secrets:: auth_crypt::: 14/14 pass, all <1s, worst case 0.974s (concurrency test, not KDF-bound) — was up to 25.5s

Concerns:

  • Host C: drive hit 0 bytes free mid-task from accumulated worktree target/ dirs (other worktrees at 5.3/4.9/3.2 GB). I freed space by cargo clean-ing only this worktree's own target and clearing the regenerable ~/.cargo/registry/src cache — didn't touch other worktrees/agents' data. Worth a broader disk-hygiene pass across .worktrees/* separately.
  • Full cargo clippy --workspace --all-targets --all-features still fails on the pre-existing fast_stall dead-code issue in src/agent_launch_tests.rs; out of this task's scope but blocks the literal gate command as written.

Opened by claude-code on flared:c997d745ae66 for item #652 via agentflare.

Summary by CodeRabbit

  • Security
    • Production vault encryption retains its established Argon2id settings, and production authentication continues to use 600,000 PBKDF2 iterations.
    • Faster key-derivation settings are available for test builds only; enabling them in release builds now causes a compile-time error.
  • Tests
    • Added checks to keep production key-derivation settings consistent and verify the faster test configuration.

… Argon2 cost

flare-vault's KdfParams::default() ran full Argon2id (3/64MiB/4 lanes) in
every test that touched a vault, costing 8-25s per test on CI. Test builds
(cfg(test), or the new insecure-fast-kdf feature enabled from the root
crate's dev-dependencies) now derive keys with the cheapest Argon2 accepts.
The feature can't reach a release build: lib.rs raises a compile_error! if
it's enabled without debug_assertions. Production defaults are pinned by a
test so a future change is deliberate.

gateway_secrets.rs's separate PBKDF2-HMAC-SHA256 KDF in auth_crypt.rs
(600k iterations) was the other hidden cost behind the slow
gateway_secrets/migration tests; it now also drops to 1 iteration under
cfg(test), with the production iteration count pinned the same way.

Agentflare-Agent: claude-code
Agentflare-Branch: task/652-flare-vault-cheap-argon2-kdf-params-unde
Agentflare-Item: 652
Agentflare-Session: 3cb04fb0-5821-4d74-a3fe-f33d6e2a718c
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 3 included reviews currently available. Your 46 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 807a239e-675d-473c-95ff-4ce0e7f005ec

📥 Commits

Reviewing files that changed from the base of the PR and between 58dd97a and 97c1e28.

📒 Files selected for processing (5)
  • Cargo.toml
  • crates/flare-vault/Cargo.toml
  • crates/flare-vault/src/crypto/kdf.rs
  • crates/flare-vault/src/lib.rs
  • src/auth_crypt.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 49d26c93-5c92-4112-92f9-f51932ebd176

📥 Commits

Reviewing files that changed from the base of the PR and between 3dc882e and 58dd97a.

📒 Files selected for processing (5)
  • Cargo.toml
  • crates/flare-vault/Cargo.toml
  • crates/flare-vault/src/crypto/kdf.rs
  • crates/flare-vault/src/lib.rs
  • src/auth_crypt.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

Test builds can use lower KDF costs for vault and gateway-secret tests. Production KDF settings remain explicit, and the vault fast-KDF feature is rejected in release builds.

Changes

Test KDF parameters

Layer / File(s) Summary
Vault test KDF configuration
crates/flare-vault/Cargo.toml, crates/flare-vault/src/crypto/kdf.rs, crates/flare-vault/src/lib.rs, Cargo.toml
The vault crate adds configurable production and fast KDF parameters. Test builds use fast defaults. The insecure-fast-kdf feature is added as a root-package dev dependency and triggers a compile error without debug_assertions. Tests check the production settings and fast parameters.
Gateway-secret test iterations
src/auth_crypt.rs
Test builds use one PBKDF2 iteration. Other builds use the production setting of 600,000 iterations. A test checks the production setting.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: 🔵 Low · up to 58dd9

Production release builds keep full Argon2 costs. However, some developer builds of the CLI can silently create a vault with weak key-derivation costs. Because vault files do not record their costs, a later production build cannot open such a vault. This is a bounded developer-workflow hazard and is reasonable to address before or soon after merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: cheaper Argon2 KDF parameters for flare-vault tests. The timing note is extra but does not obscure the change.
Description check ✅ Passed The description provides a detailed summary, test results, risk notes, production-safety details, and the known pre-existing Clippy failure. It does not use every template heading or explicitly state …
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 3 files. (2 skipped: 2 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@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: 58dd97a9be

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

Comment on lines +6 to +9
#[cfg(all(feature = "insecure-fast-kdf", not(debug_assertions)))]
compile_error!(
"flare-vault feature `insecure-fast-kdf` is test-only and must not be enabled in a release build"
);

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 Allow release-mode tests to use the test KDF

Running cargo test --release -p agentflare now fails before executing any tests: the root package's dev-dependency enables insecure-fast-kdf, while Cargo's --release option “Build[s] artifacts in release mode,” disabling debug_assertions and triggering this compile_error!. This prevents optimized test runs that can expose release-only behavior; the guard or test-feature plumbing should distinguish a release test artifact from a distributable release binary.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

#[cfg(all(feature = "insecure-fast-kdf", not(debug_assertions)))]
compile_error!(
"flare-vault feature `insecure-fast-kdf` is test-only and must not be enabled in a release build"
);

P2 Badge Allow release-mode tests to use the test KDF

Running cargo test --release -p agentflare now fails before executing any tests: the root package's dev-dependency enables insecure-fast-kdf, while Cargo's --release option “Build[s] artifacts in release mode,” disabling debug_assertions and triggering this compile_error!. This prevents optimized test runs that can expose release-only behavior; the guard or test-feature plumbing should distinguish a release test artifact from a distributable release binary.

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

@getappz
getappz merged commit d5bbeb4 into master Sep 25, 2026
16 checks passed
@getappz
getappz deleted the task/652-flare-vault-cheap-argon2-kdf-params-unde branch September 25, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant