]> git.hungrycats.org Git - bees/commitdiff
config: resolve version aliases through one table, add v0.11
authorZygo Blaxell <bees@furryterror.org>
Sat, 29 Aug 2026 02:18:33 +0000 (22:18 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 5 Sep 2026 04:03:58 +0000 (00:03 -0400)
The names accepted by config.version were spelled out inline where the
defaults map is built, which works only as long as there is exactly one
place that has to know what a name means.  Collect them into
version_aliases() instead, and drive the alias entries in s_defaults from
it, so a name resolves the same way everywhere by construction.

Two kinds of name now live in that table.  STABLE and CURRENT track this
build and resolve through s_stable_version and s_current_version, so they
name a different schema as those constants move.  A release alias names a
frozen schema directly and goes on naming it however far development
moves ahead.

Add v0.11 as the first release alias.  That release shipped no
configuration file at all, so version 1 is not a schema v0.11 published:
it is the set of defaults that reproduce how v0.11 behaved.  The alias
selects version 1 and will keep selecting it after CURRENT has advanced
past it, which is what lets an installation pin the defaults of a release
it has already been running rather than a version number it has to look
up.

Assisted-by: Claude-Code:claude-opus-5
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
docs/config-file.md
src/bees-config.cc
src/bees-config.h

index 1fcaa859b2cc8cad551b4d9e046ba208cea348d4..da1f0a7a13e9c2fd8f69995cecfd8db3c3a7db73 100644 (file)
@@ -26,6 +26,7 @@ overrides global, command-line overrides all).
   * Numeric version (e.g. `1`)
   * `STABLE` – most recent released configuration version.  This _does_ change with new bees releases.  It is the default for tagged releases and release candidates.
   * `CURRENT` – most recent development version.  This changes between bees releases in order to enable experimental new features.  It is the default for untagged development versions between releases.
+  * A release alias such as `v0.11` – the configuration version that the named release shipped.  Unlike `STABLE` and `CURRENT`, a release alias names a frozen version, so it keeps its meaning across upgrades.
 
 * **`global-config-filename`**
   Path to the optional system-wide config file.
index fd8328c264aeb837fe2e634180229b702ce38660..80773a6bffe809ad15e5c18b445f7d19aff06d67 100644 (file)
@@ -38,6 +38,20 @@ insert_map_unique(map<string, Value> &mr, const string &key, const Value &val)
        THROW_CHECK1(runtime_error, key, rv.second);
 }
 
+const map<string, string> &
+BeesConfig::version_aliases()
+{
+       static const map<string, string> s_aliases {
+               { "STABLE",  s_stable_version  },
+               { "CURRENT", s_current_version },
+               // bees v0.11 shipped config schema version 1.  That schema is
+               // frozen, so the release name goes on selecting it however far
+               // CURRENT moves ahead.
+               { "v0.11",   "1"               },
+       };
+       return s_aliases;
+}
+
 BeesConfig::BeesConfig(const string &path, const Fd &fd) :
        m_root_fd(fd),
        m_root_path(path)
@@ -84,8 +98,9 @@ BeesConfig::BeesConfig(const string &path, const Fd &fd) :
        }
 
        // Set version aliases
-       insert_map_unique(*s_defaults, "STABLE", s_defaults->at(s_stable_version));
-       insert_map_unique(*s_defaults, "CURRENT", s_defaults->at(s_current_version));
+       for (const auto &i : version_aliases()) {
+               insert_map_unique(*s_defaults, i.first, s_defaults->at(i.second));
+       }
 }
 
 string
index 8b4aa7bc3edcbd87da199fe736ae98cbc80c72c0..2a1d6093d81e81d22d116b61958de1ca73fcf156 100644 (file)
@@ -45,6 +45,19 @@ class BeesConfig {
        /// Oldest config schema version that is fully compatible.
        static constexpr const char *s_stable_version = "1";
 
+       /** \brief Named aliases accepted wherever a config schema version is.
+
+           Two kinds of name live here.  STABLE and CURRENT track this build
+           and therefore resolve through the constants above, so they name a
+           different schema as the constants move.  A release alias such as
+           "v0.11" names a frozen schema directly and keeps naming it no
+           matter how far development has moved on.
+
+           Every consumer resolves through this one table so a name cannot
+           mean one thing in the defaults map and another somewhere else.
+       */
+       static const map<string, string> &version_aliases();
+
        /// Hierarchy of Innies (one per config layer)
        Innie m_argv;     ///< Values provided via command-line flags.
        Innie m_local;    ///< Values from the per-filesystem config file.