Skip to content

Preserve timezone and extra integration channels across setup re-runs#2

Draft
tedboudros wants to merge 1 commit intomainfrom
cursor/setup-preserve-timezone-and-channels-4886
Draft

Preserve timezone and extra integration channels across setup re-runs#2
tedboudros wants to merge 1 commit intomainfrom
cursor/setup-preserve-timezone-and-channels-4886

Conversation

@tedboudros
Copy link
Copy Markdown
Owner

What's broken

Running clawquant setup a second time on an already-configured instance silently erased parts of config.yaml:

  1. scheduler.timezone reset to America/New_York. The wizard never prompted for a timezone, and generate_config wrote 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.timezone fell back to its Pydantic default.
  2. Second Telegram channel disappeared even when selecting "Skip (keep current values)". _read_plugin_values_from_config only read channels[0].chat_id / channels[0].direction, flattened them onto the values dict, and then values.pop("channels", None) discarded the full list. generate_config then rebuilt channels: as a single entry from those flattened fields, nuking any additional channels.

What this PR does

cli/config_gen.py

  • generate_config now loads the existing config.yaml (if present) and merges the wizard's output onto it instead of overwriting.
  • Only sections the wizard fully owns are replaced wholesale:
    • ai.providers, ai.default_provider, ai.agents
    • market_data.providers
    • integrations
    • risk.rules
    • scheduler.handlers
  • Everything else (scheduler.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.
  • Integration channels: the wizard's flat chat_id/direction fields are merged into the first existing channel (preserving its id and any extra keys) rather than replacing the whole list. Additional channels stay intact.
  • New optional scheduler_timezone param is written under scheduler.timezone.

cli/setup.py

  • Adds a Scheduler timezone prompt right after the auto-update prompt. It defaults to the current value from config.yaml (or America/New_York on first install) and validates against zoneinfo.ZoneInfo when available; invalid input falls back to the default with a clear message.
  • _read_plugin_values_from_config now preserves the full channels list for integrations, so extra channels round-trip through _configure_plugin and land back in generate_config.
  • _configure_plugin also 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.md

  • New "Re-running clawquant 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 Telegram direction: output channel) with the confidence they'll survive re-runs.

Testing

Verified with a scripted end-to-end simulation against a populated ~/.clawquant that includes:

  • scheduler.timezone: Europe/Berlin, scheduler.check_interval: 60s
  • Custom learning, logging, position_tracking, and market_data.poll_interval
  • A Telegram integration with two channels (personal = both, signals_only = output)

After re-running the generator in both "skip" and "configure" code paths:

  • scheduler.timezone stays at Europe/Berlin; all other non-wizard sections are preserved.
  • Both Telegram channels are present with their original ids; edits to the primary channel apply without losing the second.
  • A fresh install (no existing config) still produces a valid single-channel config.
  • Both configs pass AppConfig.model_validate.
Open in Web Open in Cursor 

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

2 participants