Repository navigation
Conversation
…lan snapshots (WP3) - timeseries.db as a separate SQLite file with its own migrations: raw measurements (48 h), 1-minute (30 days) and 15-minute aggregates (unlimited), forecasts versioned by issue time, prices; TimeseriesStore with batched appends, core-series round trips, latest forecast before t, idempotent nightly downsample/retention and VACUUM only when worth it. - Rebuild of the 15-minute history from recorder/statistics_during_period (hour period, explicit units, chunked), stored as derived rows; HAConnection.statistics_during_period plus a recorder fake in the simulator. - suncore.db migration 0004: plan_snapshot and learned_param with small repositories (schema 4; earlier versions refuse it). - Per-(domain, service) rate limiter with try-acquire/deadline for call_action_response (follow-up A3); boundary rule 7 admits suncore.app.adapters only. - Runtime wiring: batched measurement recorder (flush every 60 s), nightly job, rebuild after the first connect; errors are logged and never reach the control loop. - Fix: a cancelled writer could leave a transaction open on the shared connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
Only SQLite's "not a database"/"malformed" errors and a failing PRAGMA quick_check move the file; a locked, busy, full, unreadable or permission-denied database is logged and the app runs without time series (retry on the next start, nothing moved). The file is moved with its -wal/-shm as timeseries.db.corrupt-<UTC>, the newest two are kept, and timeseries.db.corrupt* is excluded from backups in both apps. The open now happens inside the try of build_runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
…red beats derived - measurement and measurement_1m use PRIMARY KEY (ts, key) (schema unreleased, 0001 changed). One flush now touches the last pages of the table instead of one page per key. Measured on a 48 h preload with 10 keys, 120 rows per flush, WAL bytes per flush: (key, ts) 131841, (ts, key) 23897 (5.5x less). Per-key range reads seek on ts (query-plan test); no extra index. - downsample writes the 1-minute tier only up to floor(now, 15 min), so a bucket is either whole in measurement_1m or whole in the raw rows and read_series never mixes the two inside one quarter hour (regression test with the review example: job at 03:35, 5 min x 100 W then 10 min x 1000 W reads 700 W). - read_series: a derived (rebuilt) row never beats data measured live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
The rebuild no longer depends on "measurement_15m is empty" (which a maintenance run or the first samples defeated). A marker row in timeseries.db (table meta, key history_rebuilt_at; it dies with the file) is set after a successful rebuild. A timeout or Home Assistant error is retried after 1, 5, 15 and then every 60 minutes; unknown_command is final for the process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
…lation paths
- MeasurementRecorder.flush puts the batch back on any BaseException (shutdown cancels the flush
loop) and re-raises; the 7 hours (not 100 minutes) of the buffer cap are documented correctly.
- Database: Transaction.executemany closes its cursor even if the task is cancelled, and the
retrieved outcome of the shielded rollback no longer raises "exception never retrieved".
- Includes the earlier fix that a cancelled writer could leave a transaction open on the shared
connection ("cannot start a transaction within a transaction"; rollback is now queued behind
the cancelled statements and shielded). It affects suncore.db as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
…al connection call_action_response takes rate_key (e.g. the target entity or date): the limiter key is domain.service or domain.service#key, so two different calls of one service do not block each other. A cancelled waiter keeps its reservation (documented, tested). FakeHAConnection uses the same ActionRateLimiter, so adapter tests meet the real behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
…s twice The loop wakes at most hourly and targets "the first 03:30 after the last run" in the current zone, so a zone that becomes known after start (Home Assistant's) moves the target instead of leaving a stale 24 h sleep, and a wake-up cannot repeat a run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
Energy (sum of mean x n and min/max) is preserved per complete quarter hour and in the 1-minute tier, downsampling is idempotent for random gaps and job times, and rows sit on bucket boundaries strictly before floor(now, 15 min). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
4-B moves to Done, header updated, two UNVERIFIED rows added (recorder/* via the proxy, change/sum of real counters and the backup_exclude glob), follow-ups noted (size_report not on a diagnostics page, a too-new timeseries.db is only logged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
…ick hook and the action call - Runtime.stop cancels the storage tasks (prune, flush, maintenance, history) but awaits them only after ControlStack.shutdown(): a running downsample or retention statement keeps the shielded rollback of its cancelled task waiting, which must not delay the device release (the gate still shuts down before the connection closes). Test with a stuck maintenance task. - ControlStack._record_measurements builds the values inside the try as well. - call_action_response checks the connection before taking a rate-limit slot. - Boundary rule 8: statistics_during_period only in suncore.ha and suncore.sim. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHXsfH6PkT62o9idByAd6e
5 tasks done
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.
Gestapelt auf #25 (PR 4-A). Basis ist der Branch von 4-A; nach dessen Merge wird die Basis auf
mainumgestellt.Was
WP3 aus
docs/plans/phase-4.md:/data/timeseries.dbmit eigenen Migrationen (suncore/storage/timeseries.py):backup_exclude).recorder/statistics_during_period, Periodehour, mit expliziten Einheiten (suncore/ha/statistics.py,suncore/app/history.py). Der Neuaufbau läuft, bis er einmal geklappt hat, mit Back-off. Gemessene Werte werden nie überschrieben.suncore.dbMigration 0004:plan_snapshot(komprimiert, 200 Stück / 14 Tage) undlearned_param(gelernte Werte für WP5–WP7). DB-Schema 4.domain.service(optional mit Unterschlüssel), Folgepunkt A3 aus Phase 1. Grenzregel 7: nursuncore.app.adaptersdarf Aktionen aufrufen. Grenzregel 8:statistics_during_periodgibt es nur inha/sim.suncore.db.Warum
Prognosegüte, Risikomodell (WP7), Lastprognose (WP6) und Planer (WP8) brauchen Historie, versionierte Prognosen und Preise. Ohne Neuaufbau aus HA würde die Lastprognose wochenlang ohne Daten starten.
Wie getestet
./scripts/check.shgrün: ruff, mypy, 3229 Python-Tests, Abdeckung 96 %, Frontend 219 Tests, Bundle im Budget.(ts, key)statt(key, ts)senkt die WAL-Schreiblast pro Flush von 131 841 auf 23 897 Bytes (5,5×, schont die SD-Karte).Risiken
DOCS.mdbeider Apps).timeseries.dbist nicht im Backup. Nach einer Wiederherstellung werden nur 28 Tage Viertelstundenwerte neu aufgebaut, keine Prognose-Historie.UNVERIFIED: ob der Supervisor-Proxyrecorder/*durchreicht, undchange/sumechter Energiezähler. Schlägt der Neuaufbau fehl, läuft SunCore mit Warnung ohne ihn weiter.Safety-Review
control-safety: freigegeben nach Behebung von M1 (Commit ef3aa20).
on_measurements-Haken imControlStack-Takt ist synchron, arbeitet nur im Speicher und schluckt Ausnahmen; der ganze Rumpf steht imtry. Er kopiert nur OK-Werte in ein neues Dict, die Steuer-Eingaben bleiben unverändert.suncore.app.adaptersdarfcall_action_responseaufrufen, und die Allowlist wird vor dem Limiter geprüft. Der Aktions-Limiter ist eine eigene Instanz und berührt die Schreibratenbegrenzung desServiceCallernicht.Runtime.stop()wartete vorstack.shutdown()auf laufende Speicher-Tasks. Das hätte die Freigabe der Geräte um Sekunden verzögern können. Jetzt laufen Abbruch undstack.shutdown()zuerst, dann wird auf die Speicher-Tasks gewartet.gate.shutdown()liegt weiter vor dem Schließen der Verbindung. Test mit hängendem Wartungsjob.apply()-Pfad,controller/undsafety/unverändert).Checkliste
enunddeDOCS.md: Schema 4 undtimeseries.db)docs/STATUS.mdaktualisiertdocs/research/ha-websocket-api.md, Offenes alsUNVERIFIEDOffene Fragen an den Maintainer
ActionRateLimitedError) und nicht als stilles Ergebnis, damit Adapter sie nicht übersehen. Passt das?timeseries.dberscheint nur im Log. Der Hinweis in der Oberfläche kommt mit 4-H.Generated by Claude Code