feat: фича-флаги конфигурации — клиент не сохраняет то, чего не понимает

Конфигурация хранит feature_flags (JSON-массив, NULL = нет) — какие данные
она использует. Флаги выводятся из содержимого при каждом сохранении
(internal/configfeatures). Если у конфигурации есть флаг, неизвестный этой
версии, клиент отказывается её изменять: все write-пути отдают 409
unsupported_config_features со списком флагов, конфигуратор показывает
баннер «обновите приложение» и блокирует сохранение. Push на сервер тоже
отказывается, если серверная версия несёт неизвестный флаг; такое изменение
остаётся в очереди до обновления.

Первый флаг: sale_row_markups. Серверная миграция 034 добавляет колонку;
до её применения запись идёт без колонки (с warning). Формат имён и реестр
флагов — bible-local/02-architecture.md, ADL 2026-09-24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail ChusavitinandClaude Opus 5.5 committed 2026-09-24 12:10:58 +03:00
1 parent 6b9652e3ac
commit 4e3b43dbd0
18 files changed
+579 -20

No files matched your search

+14 -1
View File
@@ -10,6 +10,7 @@ import (
"sync"
"time"
"git.mchus.pro/mchus/quoteforge/internal/configfeatures"
"git.mchus.pro/mchus/quoteforge/internal/appmeta"
"git.mchus.pro/mchus/quoteforge/internal/db"
"git.mchus.pro/mchus/quoteforge/internal/localdb"
@@ -985,7 +986,10 @@ func (s *Service) PushPendingChanges() (int, error) {
firstErr = err.Error()
}
failed++
if newAttempts >= maxPendingChangeAttempts {
// Refused over unknown feature flags: not a transient failure, and dropping it would
// lose the local edit — keep it queued until the app is updated.
_, unsupported := configfeatures.AsUnsupported(err)
if newAttempts >= maxPendingChangeAttempts && !unsupported {
slog.Error("abandoning pending change after max attempts",
"id", change.ID, "type", change.EntityType, "op", change.Operation,
"attempts", newAttempts, "last_error", err.Error())
@@ -1301,6 +1305,15 @@ func (s *Service) pushConfigurationUpdate(change *localdb.PendingChange) error {
}
}
// A newer client may have written this config since our last pull, adding data this
// build can't see (marked by a feature flag we don't know). Pushing our snapshot over
// it would erase that data, so refuse; the change stays queued until the app is updated.
if serverCfg, getErr := configRepo.GetByUUID(cfg.UUID); getErr == nil {
if err := configfeatures.Check(serverCfg.FeatureFlags); err != nil {
return fmt.Errorf("push of configuration %s refused: %w", cfg.UUID, err)
}
}
// Update on server
if err := configRepo.Update(&cfg); err != nil {
return fmt.Errorf("updating configuration on server: %w", err)