Repository navigation
fix(setup): seal wizard secrets into the vault the bot opens (#156) - #157
Merged
Merged
Conversation
The wizard sealed credentials into <config_dir>/secrets/vault while the bot opens <resolved home>/secrets/vault, so a fresh --setup run outside ~/.rustfox left the bot unable to find openrouter.api_key. - Wizard save, CLI save and add-bot now resolve the home with the same precedence as Config::resolve (RUSTFOX_HOME, [general].home, ~/.rustfox). - On boot, secrets in an old vault beside config.toml are copied into the home vault (home wins, old vault kept), so existing users need no re-setup. - Done page says 'rustfox' instead of 'cargo run --bin rustfox'.
chinkan
commented
Oct 6, 2026
chinkan
left a comment
Owner
Author
There was a problem hiding this comment.
TL ACCEPT at 6267a19.
Matches #156 AC:
- Wizard seal (web/CLI/add-bot) uses
home_for_config_textwith the same precedence as the bot — vault no longer follows cwd. - Fresh setup from a non-home folder lands secrets where boot opens them.
- Boot-time
import_config_dir_vaultcopies missing names from a legacy beside-config vault; home wins; old vault kept; idempotent. Regression tests cover the main paths.
Done-page hint rustfox is fine.
Non-blocking polish (Researcher edge): when both vaults have the same name but different values, log a warn naming which value is kept (home) and which is skipped (config-dir). No behaviour change. Nice if it lands in this tip before merge; otherwise a tiny follow-up is OK — do not HOLD #157 for it.
Merge after CI green + Product GO + QA three-AC smoke (incl. real TG reply). Do not tag until #156 is fixed (this PR).
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.
Fixes #156 (P0).
Problem
The setup wizard sealed credentials into
<config_dir>/secrets/vault, but the bot opens<resolved home>/secrets/vault(RUSTFOX_HOME, then[general].home, then~/.rustfox). Runningrustfox --setupfrom any folder other than~/.rustfoxtherefore produced a bot that exits withsecret 'openrouter.api_key' not found in SecretStore.Fix
home::home_for_config_textresolves the home from the config text with the same precedence asConfig::resolve. The web wizard save, the CLI wizard save and/api/add-botall seal into that home, so the vault no longer depends on the working directory.secret_store::import_config_dir_vaultruns on boot before the store opens. If an older wizard left a vault besideconfig.toml(and that folder is not the home), its secrets are copied into the home vault. Names already in the home vault win, values are read back after write, and the old vault is left in place. It copies file to file so a stale keyutils entry cannot shadow the newer wizard value. Existing users do not need to run setup again.rustfoxinstead ofcargo run --bin rustfox.macOS and Windows use the OS keyring, which does not depend on a path, so this only changes behaviour when the encrypted file vault is used (always on Linux).
Acceptance criteria
config.tomllives.--setupfrom any folder boots with no SecretStore error.config.tomlis read without re-running setup, with no silent secret loss.Tests
wizard_seal_writes_the_vault_the_bot_opens: the seal lands in<home>/secrets/vaultand the written config resolves to the same home.config_dir_vault_secrets_are_copied_without_overwriting: old secrets are copied, the home value wins, the old vault is kept, and a second run copies nothing.config_dir_vault_import_is_a_no_op_for_home_or_missing_vault: no copy when the config folder is the home, and no stray key file when there is no old vault.config_text_home_reads_general_home.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo test --lockedpass (921 tests).Manual check on Linux with an empty
HOME, running from~/Downloads/rustfox:rustfox --setup --cliwrites~/.rustfox/secrets/vault, and nothing is written besideconfig.toml.rustfoxgets past secret resolution and starts the Telegram dispatcher. It then stops only because the test token is fake.config.tomlto simulate an old install, boot logsCopied 2 secret(s) from the vault beside config.tomland starts. The next boot copies nothing.