deb,config: keep the newest and the newest successful staged trees

The retention kept the newest five staged trees per target, so the
staged trees of a kernel-scale target alone could hold three-digit
GiB. The policy is now the pair that earns its disk: the newest
staged tree (what a failed run is re-forked from explicitly) and the
newest successful one (what the next --incremental run forks
automatically) — one record when they coincide; every other staged
tree degrades to metadata-only at the next build's retention. The
retention decision moved into a pure planner over (success, size) so
the policy is table-testable.

The size cap no longer drops a tree outright: an --incremental run's
own tree is always kept by its own run — the user asked for a carried
tree, and at least one always exists — and the cap only thins the kept
pair while another member covers the resume, the newest successful
tree being the last one standing. Oversized trees left by older pkh
versions or interrupted builds come down at the next build's
retention, once their lock is free.

The cap moves to the first user settings file, config.yml in
~/.config/pkh (YAML, like the data files; missing file or keys mean
defaults, a corrupt file is backed up, PKH_STAGED_MAXSIZE overrides),
replacing the JSON sketch from the previous commit. Default 20G, 0
disables the size rule. Every retained tree's size is measured once at
retention and recorded in the manifest, so sweeps never re-walk the
trees.
This commit is contained in:
2026-10-03 21:29:07 +02:00
parent 93943dcce0
commit a9a6d2001c
7 changed files with 363 additions and 173 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
//! User settings: the optional `config.json` in the pkh configuration
//! User settings: the optional `config.yml` in the pkh configuration
//! directory (the same `~/.config/pkh/` that holds `contexts.json`),
//! its defaults, and the environment overrides.
//!
@@ -21,10 +21,10 @@ pub fn config_dir() -> Option<PathBuf> {
/// The settings file in [`config_dir`].
fn config_path() -> Option<PathBuf> {
config_dir().map(|dir| dir.join("config.json"))
config_dir().map(|dir| dir.join("config.yml"))
}
/// The user-adjustable settings, as stored in `config.json`. New fields
/// The user-adjustable settings, as stored in `config.yml`. New fields
/// must default — the file always may carry a subset.
#[derive(Debug, Clone, Deserialize, Default)]
#[serde(default)]
@@ -61,7 +61,7 @@ fn file_staged_maxsize() -> u64 {
let Ok(text) = std::fs::read_to_string(&path) else {
return DEFAULT;
};
let settings: Settings = match serde_json::from_str(&text) {
let settings: Settings = match serde_yaml::from_str(&text) {
Ok(settings) => settings,
Err(e) => {
log::error!(