package main // The manager's settings (design 39 §8, design 39 bus-and-switch §33): today's five and the six of the switch, each // declared in the manifest's `config` with its default and bound, set through mesh-config and written into the // settings file. They are read again at every reading, so a change takes effect at the next one, and each change of a // value read is written in the audit under `settings`. import ( "context" "fmt" "reflect" . "claude-licence-manager/internal/licences" ) // settings are those in force. func (m *Manager) settings() Settings { m.settingsMu.RLock() defer m.settingsMu.RUnlock() return m.Settings } // ReadSettings reads the settings file again, at every reading (§33): each value that changed is written in the audit // under `settings`, its value before and now, and the settings read are those in force from then on. func (m *Manager) ReadSettings(ctx context.Context) error { if m.SettingsFile == "" { return nil } next := SettingsFrom(m.SettingsFile) m.settingsMu.Lock() before := m.Settings m.Settings = next m.settingsMu.Unlock() was, now := before.Values(), next.Values() changed := map[string]any{} for k, v := range now { if !reflect.DeepEqual(was[k], v) { changed[k] = map[string]any{"from": was[k], "to": v} } } if len(changed) == 0 { return nil } return m.record(ctx, "settings", fmt.Sprintf("%d setting(s) changed: %v", len(changed), changed), changed) }