]> git.hungrycats.org Git - bees/commitdiff
config: do not resolve a pinned version through newer schemas next
authorZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 18:59:20 +0000 (14:59 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 18:59:20 +0000 (14:59 -0400)
version_chain() consulted a version's ancestors and then its
descendants, so a key the selected version did not define resolved to
the value a newer schema introduced it with.  A configuration pinned to
an old version then changes behaviour whenever a newer schema adds an
option, which is what pinning is meant to prevent.

Resolve a version through itself and its ancestors only, and drop
next_version(), which only the descendant walk used.  Every key the code
reads must now be defined in the oldest schema; version 1 gained the
two it was missing in the previous commit, and test_builtin_versions()
already fails if any version cannot resolve a key another version
defines.

Update the version_chain(), config.version and --show-builtin-config
descriptions to match, and say in the version 1 file comment that new
options get a key there too, at the value that keeps v0.11 behaviour.

Assisted-by: Claude-Code:claude-opus-5-5
docs/config-file.md
docs/options.md
src/bees-config-v1.cc
src/bees-config.cc
src/bees-config.h

index afb9832e23ee0cf484c3254f9ba001399f3b26ab..88d3e082f55b7098cd15449a8d4675fd17b02590 100644 (file)
@@ -21,7 +21,7 @@ overrides global, command-line overrides all).
 * **`version`**
   Locks the version of default values so upgrades do not silently change behavior.
   If an option’s default value changes in a new bees release, `config.version` must be bumped to pick it up.
-  Selecting a version pins the defaults of the keys it defines; keys added after it take the value they were introduced with, so pinning an old version stays possible as bees gains options.
+  Selecting a version pins every default: a key resolves through the selected version and the versions before it, never a newer one.  Options added after a version are given a value in it that keeps that version's behavior.
   Accepted values:
 
   * Numeric version (e.g. `1`)
@@ -727,7 +727,7 @@ The `[thread]` section sets how many worker threads bees runs and how aggressive
 
   Do not set `no` unless you have confirmed your kernel is not affected.
 
-  Default: `auto`.
+  Default: `auto` (config version 1 and `v0.11`: `no`).
 
 ## [throttle] section
 
@@ -808,7 +808,7 @@ The `[loop]` section controls the crawl loop lifecycle.  By default bees runs as
 The `[resolve]` section controls how bees maps a physical btrfs address back to the files that reference it, using the `LOGICAL_INO_V2` ioctl.
 
 * **`commit-root`**
-  Resolve references against the filesystem's commit roots instead of the live tree.  Default: `yes`.
+  Resolve references against the filesystem's commit roots instead of the live tree.  Default: `yes` (config version 1 and `v0.11`: `no`).
 
   With `no`, the kernel walks the running transaction's trees, so the reference list reflects the filesystem as it is at the moment of the call.  To keep that view consistent, the kernel holds a tree mod log sequence for the whole duration of the walk.  While any sequence is live, every node-level change anywhere on the filesystem is journalled into unreclaimable slab, and the journal is only trimmed below the oldest live sequence.  Walks of heavily-shared extents take the longest and therefore hold a sequence the longest, which is also when other work — balance, snapshot deletion — is most likely to be generating tree changes to journal.
 
index 133b7c714285647d9b7485c33fc673c8d0421dfe..b800b3b13024e71d17bf3f57b72bed75dc7212d2 100644 (file)
@@ -116,16 +116,11 @@ space used--until the read-only snapshots are deleted.
 
   The output is what `VERSION` *resolves to*, not the contents of the schema
   file that carries its name.  A schema states only the keys it changes, and
-  everything else comes from the rest of the inheritance chain, so the dump
-  is the whole chain flattened: every key any version defines, each with the
-  value `VERSION` resolves for it.
-
-  That means asking for an older version still lists options added after it,
-  which is the point — a daemon pinned to that version resolves them too,
-  each to the value it was introduced with.  Where the selected version has
-  an opinion of its own, that opinion wins: on a build where version 2
-  changes `state.point.defer` to `yes`, `--show-builtin-config 1` lists the
-  key with version 1's `no`, alongside every option version 2 added.
+  everything else comes from the schemas before it, so the dump is that
+  chain flattened: every key, each with the value `VERSION` resolves for it.
+  Newer schemas are never consulted, so on a build where version 2 changes
+  `state.point.defer` to `yes`, `--show-builtin-config 1` lists the key with
+  version 1's `no`.
 
   This command does not load a filesystem, global config file, local config
   file, environment-derived paths, or `--config` / `--option` input.  It is
index 7f115c13059fd05e57d072b5cb317e23c67cea6b..92850fb982d85d80acd86e7feb934f33f6d180bb 100644 (file)
 // they get on their next upgrade, which is the one thing versioning the schema
 // exists to prevent.
 //
-// New options and changed defaults belong in the highest-numbered
-// bees-config-v*.cc either way.
+// A version never resolves a key through a newer schema, so every key the
+// code reads must be defined here.  A new option gets a key here too, set to
+// the value that keeps v0.11 behaviour; its new default goes in the
+// highest-numbered bees-config-v*.cc.  Existing keys here are only ever
+// added to, never changed.
 static const char bees_config_v1[] = R"--v1-config--(
 
 # The [config] section controls config file sources and versioning.
index 0faf6c6c6c33dd8b8428c675b999cc44dffcc128..f5406ff59af56d52720359fddbaba9be9b08b019 100644 (file)
@@ -106,26 +106,6 @@ BeesConfig::previous_version(const string &version)
        return resolved;
 }
 
-string
-BeesConfig::next_version(const string &version)
-{
-       THROW_CHECK0(runtime_error, s_previous);
-       string rv;
-       for (const auto &i : *s_previous) {
-               if (previous_version(i.first) != version) {
-                       continue;
-               }
-               // Two schemas inheriting from one would leave no single answer to
-               // what comes after it, and the descendant walk needs exactly one.
-               if (!rv.empty()) {
-                       THROW_ERROR(runtime_error, "config versions '" << rv << "' and '"
-                               << i.first << "' both inherit from '" << version << "'");
-               }
-               rv = i.first;
-       }
-       return rv;
-}
-
 vector<string>
 BeesConfig::version_chain(const string &version)
 {
@@ -145,9 +125,6 @@ BeesConfig::version_chain(const string &version)
        for (auto v = previous_version(version); !v.empty(); v = previous_version(v)) {
                push(v);
        }
-       for (auto v = next_version(version); !v.empty(); v = next_version(v)) {
-               push(v);
-       }
        return rv;
 }
 
index 933d30d07dbd80a81684c8b22538d193fd4a02ed..834b2cc2838f78fc04fb6655d33af01ec33f7774 100644 (file)
@@ -46,10 +46,7 @@ class BeesConfig {
        /// what CURRENT resolves to.
        static constexpr const char *s_current_version = "2";
        /// Most recently released config schema, and what STABLE resolves to.
-       /// Version 1 holds the defaults that reproduce v0.11 behaviour.  It may
-       /// come to define fewer keys than this build queries, and stays
-       /// selectable anyway because a version resolves through version_chain():
-       /// the keys added since come from the schemas that added them.  At a
+       /// Version 1 holds the defaults that reproduce v0.11 behaviour.  At a
        /// release the two constants meet again, and part company as development
        /// resumes.
        static constexpr const char *s_stable_version = "1";
@@ -90,20 +87,14 @@ class BeesConfig {
        /// The version @p version inherits from, resolved through the alias
        /// table and checked, or "" when @p version is the oldest schema.
        static string previous_version(const string &version);
-       /// The version that inherits from @p version, or "" when none does.
-       static string next_version(const string &version);
        /** \brief Versions consulted for @p version, in resolution order.
 
-           @p version first, then its ancestors nearest-first, then its
-           descendants nearest-first.  The two directions answer two different
-           questions and the sets are disjoint, so there is no ambiguity.
-
-           Ancestors are what let a schema state only the keys it changes.
-           Descendants are what let a selected version go on working as the
-           code grows past it: a key added after that version resolves to the
-           value it was introduced with, rather than throwing as missing.
-           Ancestors come first so that a later schema cannot reach back and
-           change a value the selected version already inherited.
+           @p version first, then its ancestors nearest-first.  Ancestors are
+           what let a schema state only the keys it changes.  A schema newer
+           than @p version is never consulted, so nothing added after it can
+           change what it resolves.  Every key the code reads must therefore be
+           defined by the oldest schema, with the value that reproduces its
+           behaviour.
        */
        static vector<string> version_chain(const string &version);