docs(curator): trim drops the oldest lines regardless of shape
_trim_oldest never parses lines: it drops the OLDEST ones whatever they are, so 'malformed lines always survive' was false. Reword docstring, curator.md and the kept test's docstring to the true guarantee: lines in the retained tail are never rewritten or parsed, so a malformed line there survives verbatim. No behaviour change. PROOF: probes/s5_trim_probe.py (cap 4096, malformed first line, 4 fat appends) -> old malformed survived: False, contradicting the old wording; the kept test asserts a LAST-line malformed row, which is what the new wording promises.
This commit is contained in:
@@ -651,9 +651,11 @@ def test_auto_compact_triggers_at_threshold(ledger_env, monkeypatch):
|
||||
|
||||
def test_trim_oldest_when_still_over_cap(ledger_env, monkeypatch):
|
||||
"""When compaction alone cannot reach the cap (every entry genuinely
|
||||
differs), the oldest entries are dropped until it fits under the LOW-WATER
|
||||
mark (80% of the cap, so the next append does not immediately re-trigger the
|
||||
sweep) — newest entries survive, malformed lines are kept verbatim."""
|
||||
differs), the oldest lines are dropped — whatever their shape — until the
|
||||
file fits under the LOW-WATER mark (80% of the cap, so the next append does
|
||||
not immediately re-trigger the sweep). The newest entry survives, and lines
|
||||
in the retained tail are never parsed or rewritten: a malformed last line
|
||||
survives verbatim."""
|
||||
from tools import skill_ledger
|
||||
|
||||
import hermes_cli.config as _cfg
|
||||
|
||||
@@ -357,9 +357,10 @@ _TRIM_LOW_WATER = 0.8 # trim target as a fraction of ``skills.ledger_max_bytes`
|
||||
|
||||
|
||||
def _trim_oldest(max_bytes: int) -> int:
|
||||
"""Rewrite the ledger without its oldest parsed entries until it is at most
|
||||
*max_bytes*; the newest entry always survives, malformed lines are kept verbatim.
|
||||
Returns the number of lines dropped (0 = file untouched)."""
|
||||
"""Rewrite the ledger without its oldest lines until it is at most *max_bytes*;
|
||||
the newest entry always survives. Lines in the retained tail are never rewritten
|
||||
or parsed — malformed lines there survive verbatim; trimming drops the oldest
|
||||
lines regardless of shape. Returns the number of lines dropped (0 = untouched)."""
|
||||
path = ledger_path()
|
||||
raw = _read_ledger("trim skipped")
|
||||
if raw is None:
|
||||
|
||||
@@ -175,7 +175,7 @@ skills:
|
||||
ledger: false
|
||||
```
|
||||
|
||||
The file is also size-bounded: once it grows past `skills.ledger_max_bytes` (default 5 MB), the next mutation first rewrites it through the unchanged-file dedup (exactly what `hermes curator ledger --compact` does) and, if genuinely-divergent entries still exceed the cap, drops the oldest ones — the newest entry and any malformed lines always survive, and the sweep frees blobs nothing references anymore. Set it to `0` to keep the ledger append-only forever.
|
||||
The file is also size-bounded: once it grows past `skills.ledger_max_bytes` (default 5 MB), the next mutation first rewrites it through the unchanged-file dedup (exactly what `hermes curator ledger --compact` does) and, if genuinely-divergent entries still exceed the cap, drops the oldest ones regardless of shape — the newest entry always survives, lines in the retained tail are never rewritten or parsed (a malformed line there survives verbatim), and the sweep frees blobs nothing references anymore. Set it to `0` to keep the ledger append-only forever.
|
||||
|
||||
```yaml
|
||||
skills:
|
||||
|
||||
Reference in New Issue
Block a user