Skip to content

feat: clean up architecture and add test suite - #1

Open
Anty0 wants to merge 1 commit into
mainfrom
refactor/architecture-cleanup
Open

feat: clean up architecture and add test suite#1
Anty0 wants to merge 1 commit into
mainfrom
refactor/architecture-cleanup

Conversation

@Anty0

@Anty0 Anty0 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bug fixes: code-fence normalizer now returns content between fences and passes through unterminated fences; collision-safe prompt/error substitution (rejects the broken {{weather_json}} token); throttle uses total_seconds(); timestamps are tz-aware and legacy/unparseable stored timestamps force one refresh instead of crashing startup.
  • New visualization/ package: Visualization value object with a single from_raw assembly point, VisualizationStatus enum, and the moved HtmlNormalizer — a dependency leaf shared by ai/, state/, websocket/, scheduler/.
  • Normalization at generation time: AIManager normalizes every progressive frame; ConnectionManager no longer normalizes and strips the tz offset only at the wire boundary.
  • Dependency injection: module-global state replaced with create_app(*, settings, provider_factory) wiring components onto app.state; module-level app = create_app() keeps aiweather:app working.
  • RefreshService extracted: owns fetch → archive → state → broadcast → generate, needs_refresh, and load_initial_state; WeatherScheduler now only owns APScheduler triggers. StateService is a pure passive holder.
  • Provider factory + readiness: one instance per provider name (skips unknown providers with a warning instead of crashing); bounded, non-fatal availability probe; new /ready endpoint while /health stays a cheap liveness check.
  • Housekeeping: CWD-independent asset paths (aiweather/paths.py); py3.14 builtin typing throughout; dead code removed; AGENTS.md and config.example.yaml updated.
  • Tests: new pytest suite (79 tests) covering normalizer, config, archive, state, refresh, AIManager, provider factory, weather client, websocket, scheduler, and wired-app integration; added a CI test job.

Accepted behavior changes

  • Displayed timestamp and archive dir keys now follow the configured scheduler.timezone (documented in config.example.yaml).
  • New /ready endpoint; /health payload unchanged.

Follow-up (not in this PR)

  • Fold current_visualizations + visualization_status into a single dict[str, ModelSlot] so visualization and status update atomically.

Bug fixes:
- Fix CodeBlockHtmlNormalizer to return content between fences (was
  returning only the opening fence) and pass through unterminated fences
- Replace fragile str.format prompt/error substitution with collision-safe
  str.replace / string.Template; reject the doubled {{weather_json}} token
- Use timedelta.total_seconds() for the progressive-update throttle
- Make timestamps tz-aware in the configured scheduler tz; force one
  refresh on legacy/unparseable stored timestamps instead of crashing

Architecture:
- New neutral visualization/ package: Visualization value object (single
  from_raw assembly point), VisualizationStatus enum, HtmlNormalizer
- Move normalization to generation time; ConnectionManager no longer
  normalizes and strips the tz offset only at the wire boundary
- Replace module-global state with create_app(settings, provider_factory)
  wiring components onto app.state; keep module-level app for aiweather:app
- Extract RefreshService (fetch/archive/state/broadcast/generate,
  needs_refresh, load_initial_state); WeatherScheduler now owns triggers
- StateService is a pure passive holder
- Minimal provider factory (one instance per name, skips unknown with a
  warning); bounded non-fatal availability probe; new /ready endpoint,
  /health stays a cheap liveness check
- CWD-independent asset paths via aiweather/paths.py
- Modernize typing to py3.14 builtins; remove dead code

Testing:
- Add a pytest suite (79 tests) covering normalizer, config, archive,
  state, refresh, AIManager, provider factory, weather client, websocket,
  scheduler, and wired-app integration; add a CI test job
@Anty0 Anty0 changed the title refactor: clean up architecture and add test suite feat: clean up architecture and add test suite Jul 1, 2026
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