Preserve timezone and extra integration channels across setup re-runs#2
Draft
tedboudros wants to merge 1 commit intomainfrom
Draft
Preserve timezone and extra integration channels across setup re-runs#2tedboudros wants to merge 1 commit intomainfrom
tedboudros wants to merge 1 commit intomainfrom
Conversation
- cli/config_gen.py: merge wizard-generated config onto existing config instead of overwriting it. Only sections the wizard fully owns (ai.providers, ai.default_provider, ai.agents, market_data.providers, integrations, risk.rules, scheduler.handlers) are replaced. Everything else -- scheduler.timezone, scheduler.check_interval, scheduler.default_tasks, learning.*, position_tracking.*, logging.*, market_data.poll_interval, ai.task_routing, and any manual edits -- is preserved. - cli/setup.py: prompt for scheduler.timezone with the current value as the default, validate against IANA timezone db when zoneinfo is available, and round-trip the full integrations[*].channels list so additional output-only channels added by hand do not disappear on re-run. - cli/config_gen.py: when building an integration's channels list, merge the wizard's flat chat_id/direction fields into the first existing channel (preserving its id and any extra keys) and keep the remaining channels intact. - docs/CONFIGURATION.md: document re-run semantics, the new timezone prompt, and how to add additional integration channels manually. Co-authored-by: Ted Boudros <tedboudros@users.noreply.github.com>
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.
What's broken
Running
clawquant setupa second time on an already-configured instance silently erased parts ofconfig.yaml:scheduler.timezonereset toAmerica/New_York. The wizard never prompted for a timezone, andgenerate_configwrote a fresh config from scratch, so any custom timezone (plus everything else outside the wizard's known sections) was dropped. On the next load,SchedulerConfig.timezonefell back to its Pydantic default._read_plugin_values_from_configonly readchannels[0].chat_id/channels[0].direction, flattened them onto the values dict, and thenvalues.pop("channels", None)discarded the full list.generate_configthen rebuiltchannels:as a single entry from those flattened fields, nuking any additional channels.What this PR does
cli/config_gen.pygenerate_confignow loads the existingconfig.yaml(if present) and merges the wizard's output onto it instead of overwriting.ai.providers,ai.default_provider,ai.agentsmarket_data.providersintegrationsrisk.rulesscheduler.handlersscheduler.timezone,scheduler.check_interval,scheduler.default_tasks,learning.*,position_tracking.*,logging.*,market_data.poll_interval,market_data.history_depth,ai.task_routing, and any manual user-added keys) survives.chat_id/directionfields are merged into the first existing channel (preserving itsidand any extra keys) rather than replacing the whole list. Additional channels stay intact.scheduler_timezoneparam is written underscheduler.timezone.cli/setup.pyScheduler timezoneprompt right after the auto-update prompt. It defaults to the current value fromconfig.yaml(orAmerica/New_Yorkon first install) and validates againstzoneinfo.ZoneInfowhen available; invalid input falls back to the default with a clear message._read_plugin_values_from_confignow preserves the fullchannelslist for integrations, so extra channels round-trip through_configure_pluginand land back ingenerate_config._configure_pluginalso carries over any non-field keys from the existing values (e.g.channels) so the "Configure now" path doesn't accidentally drop them either.docs/CONFIGURATION.mdclawquant setup" section documents what the wizard owns vs. preserves, mentions the timezone prompt, and shows how to hand-edit additional integration channels (e.g. a Telegramdirection: outputchannel) with the confidence they'll survive re-runs.Testing
Verified with a scripted end-to-end simulation against a populated
~/.clawquantthat includes:scheduler.timezone: Europe/Berlin,scheduler.check_interval: 60slearning,logging,position_tracking, andmarket_data.poll_intervalpersonal=both,signals_only=output)After re-running the generator in both "skip" and "configure" code paths:
scheduler.timezonestays atEurope/Berlin; all other non-wizard sections are preserved.ids; edits to the primary channel apply without losing the second.AppConfig.model_validate.