From eac50550d5dccfdfc9976497640a1791439b9293 Mon Sep 17 00:00:00 2001 From: PEEKPerformer <24813380+PEEKPerformer@users.noreply.github.com> Date: Thu, 17 Sep 2026 08:02:41 -0400 Subject: [PATCH] v2.4.1: turn off git auto-maintenance in the archive git runs `git maintenance run --auto --detach` after every commit. Once the loose-object count passes gc.auto, each commit starts its own detached full repack, and nothing stops a second one from starting while the first is still running. An archive's pack is mostly zstd or git-crypt blobs, so each repack holds gigabytes. One ingest tick makes one commit per changed session, which stacked repacks until a 16 GB Mac with a 7.3 GiB archive ran out of memory and had to be force-restarted. Set maintenance.auto=false and gc.auto=0 in the archive's local git config. init.py sets them after `git init`. ingest.py sets them under the ingest lock before the first commit, which migrates existing archives on their next tick. Loose objects now wait for a manual `git repack -d`. The selftest checks both the init path and the migration path. --- CHANGELOG.md | 25 +++++++++++++++++++++++++ holotype/__init__.py | 2 +- holotype/archive.py | 39 +++++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- scripts/ingest.py | 6 ++++++ scripts/init.py | 2 ++ scripts/selftest.py | 22 ++++++++++++++++++++++ 7 files changed, 96 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 226d614..0b1beb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ All notable changes to `holotype`. Format adapted from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.4.1] - 2026-09-17 + +Holotype now turns off git's automatic maintenance in the archive. On a large archive it could exhaust the machine's memory. + +### The failure + +git runs `git maintenance run --auto --detach` after every commit. When the loose-object count passes `gc.auto`, that starts a detached full repack (`git repack --cruft` and `git pack-objects --all`). Nothing stops a second repack from starting while the first is still running: each commit starts its own. One ingest tick makes one commit per changed session, so a busy tick starts several repacks at once. + +An archive's pack is mostly zstd or git-crypt blobs, which do not delta or compress. Every repack therefore reads the whole pack and holds gigabytes while it runs. On a real archive (7.3 GiB pack, 16 GB Mac) the repacks stacked up over one tick to 63 `git` processes and about 44 GB of memory. They never finished, the pack was never rewritten, the loose-object count stayed over the threshold, and every later commit started another repack. The machine ran out of memory and had to be force-restarted. + +Reproduced on git 2.54 with a scratch repository: four commits in a row left five concurrent `pack-objects --all` processes. + +### The fix + +- New `holotype.archive.disable_auto_maintenance()` sets `maintenance.auto=false` and `gc.auto=0` in the archive's local `.git/config`. It writes only when a value differs. +- `init.py` calls it right after `git init`. +- `ingest.py` calls it under the ingest lock, before the tick's first commit. Existing archives are migrated on their next tick with no action from you. +- No archive-format change. Nothing tracked in the archive changes. + +Loose objects now accumulate until you pack them. To pack only the loose objects, without rewriting the existing large pack, run `git -C repack -d`. + +### Tests + +The selftest checks that `init.py` sets both keys, and that `ingest.py` restores them on an archive where they are unset. + ## [2.4.0] — 2026-05-28 The archive's "hash chain" is now a real chain. Until this release, "hash chain" named an aspiration: each `manifest.json` carried the SHA-256 of its own transcript, and `verify.py` checked each file against its *own* manifest. That proves per-file content integrity but binds nothing across deposits — a coordinated edit of a transcript *and* its manifest is internally consistent and passed `verify.py` clean. The only thing recording the set and order of deposits was git's commit DAG, which a self-contained `paper_bundle` `.tar.gz` (shipped with no `.git`) doesn't carry. So a reviewer holding a bundle could confirm self-consistency but not that nothing had been inserted, deleted, or substituted. diff --git a/holotype/__init__.py b/holotype/__init__.py index d586123..61e18c2 100644 --- a/holotype/__init__.py +++ b/holotype/__init__.py @@ -1,3 +1,3 @@ """holotype: forensic-grade archival of agent-CLI sessions for scientific reproducibility.""" -__version__ = "2.4.0" +__version__ = "2.4.1" diff --git a/holotype/archive.py b/holotype/archive.py index 6631a5f..0286f75 100644 --- a/holotype/archive.py +++ b/holotype/archive.py @@ -12,6 +12,7 @@ from __future__ import annotations import json +import subprocess from pathlib import Path from typing import Iterator @@ -62,3 +63,41 @@ def resolve_session_by_prefix(archive: Path, prefix: str) -> Path | None: sys.stderr.write(f" {m.name}\n") return None return matches[0] + + +# git runs `git maintenance run --auto --detach` after every commit. Once +# the loose-object count crosses gc.auto, each commit starts its own +# detached full repack (`pack-objects --all`), and nothing stops a second +# one from starting while the first is still running. An archive's pack +# is mostly incompressible blobs (zstd or git-crypt), so each repack holds +# gigabytes and runs for a long time. One ingest tick makes one commit +# per changed session, which is enough to stack repacks until the machine +# runs out of memory. Holotype turns automatic maintenance off in the +# archive; repack by hand with `git repack -d` when loose objects pile up. +AUTO_MAINTENANCE_OFF = ( + ("maintenance.auto", "false"), + ("gc.auto", "0"), +) + + +def disable_auto_maintenance(archive: Path) -> None: + """Turn off git's automatic background maintenance for ``archive``. + + Writes to the archive's local ``.git/config`` only, and only when a + value differs, so calling this every ingest tick is cheap. Failures + are ignored: a missing setting costs memory, not correctness. + """ + for key, value in AUTO_MAINTENANCE_OFF: + try: + current = subprocess.run( + ["git", "-C", str(archive), "config", "--local", "--get", key], + capture_output=True, text=True, timeout=10, + ) + if current.stdout.strip() == value: + continue + subprocess.run( + ["git", "-C", str(archive), "config", "--local", key, value], + capture_output=True, text=True, timeout=10, + ) + except (subprocess.SubprocessError, OSError): + pass diff --git a/pyproject.toml b/pyproject.toml index 650e6ee..8771f9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "holotype" -version = "2.4.0" +version = "2.4.1" description = "Forensic-grade archival of LLM-driven agent CLI sessions for scientific reproducibility" readme = "README.md" license = { file = "LICENSE" } diff --git a/scripts/ingest.py b/scripts/ingest.py index e65da3c..437cdac 100644 --- a/scripts/ingest.py +++ b/scripts/ingest.py @@ -42,6 +42,7 @@ sys.path.insert(0, str(REPO_ROOT)) from holotype import __version__ +from holotype.archive import disable_auto_maintenance from holotype.chunking import bin_pack_paths, dir_size_bytes from holotype.compression import compress_bytes, find_transcript, transcript_filename from holotype.env import claude_code_version, git_state_for_path, platform_info @@ -902,6 +903,11 @@ def main(argv: list[str] | None = None) -> int: print("holotype: another ingest is running, exiting") return 0 + # Before the first commit of this tick, so no commit can start a + # detached repack. Also migrates archives created before this setting. + if not args.dry_run: + disable_auto_maintenance(archive) + try: counts: dict[str, int] = {"new": 0, "updated": 0, "skipped-live": 0, "skipped-unchanged": 0, "skipped-empty": 0} diff --git a/scripts/init.py b/scripts/init.py index 991e126..c08d6dd 100644 --- a/scripts/init.py +++ b/scripts/init.py @@ -35,6 +35,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from holotype import ledger # noqa: E402 +from holotype.archive import disable_auto_maintenance # noqa: E402 ARCHIVE_FORMAT_VERSION = 1 HOLOTYPE_SUBDIR = ".holotype" @@ -525,6 +526,7 @@ def init_archive(args: argparse.Namespace) -> int: is_new_repo = not (archive / ".git").exists() if is_new_repo: run(["git", "init", "-b", "main"], cwd=archive) + disable_auto_maintenance(archive) if args.sign_commits: # Probe for a signing key. Don't fail init outright — the user diff --git a/scripts/selftest.py b/scripts/selftest.py index c4f586d..9f7503e 100644 --- a/scripts/selftest.py +++ b/scripts/selftest.py @@ -171,6 +171,20 @@ def main(argv: list[str] | None = None) -> int: expect((archive / "README.md").exists(), "archive README.md missing") expect((archive / ".git").is_dir(), "archive is not a git repo") + step("init.py turns off git auto-maintenance in the archive") + for key, want in (("maintenance.auto", "false"), ("gc.auto", "0")): + got = subprocess.run( + ["git", "-C", str(archive), "config", "--local", "--get", key], + capture_output=True, text=True, + ).stdout.strip() + expect(got == want, f"archive {key}={got!r}, expected {want!r}") + # Unset again so the first ingest below has to migrate an + # archive created before this setting existed. + subprocess.run( + ["git", "-C", str(archive), "config", "--local", "--unset", key], + check=True, + ) + step("materialize synthetic source") source = materialize_source(tmp) @@ -186,6 +200,14 @@ def main(argv: list[str] | None = None) -> int: expect(result.returncode == 0, f"ingest.py returncode={result.returncode}: {result.stderr}") expect("new=3" in result.stdout, f"expected new=3 in output:\n{result.stdout}") + step("ingest turns off git auto-maintenance on an older archive") + for key, want in (("maintenance.auto", "false"), ("gc.auto", "0")): + got = subprocess.run( + ["git", "-C", str(archive), "config", "--local", "--get", key], + capture_output=True, text=True, + ).stdout.strip() + expect(got == want, f"archive {key}={got!r} after ingest, expected {want!r}") + sessions_dir = archive / "sessions" deposits = sorted(p for p in sessions_dir.rglob("transcript.jsonl")) expect(len(deposits) == 3, f"expected 3 deposits (2 top-level + 1 subagent), got {len(deposits)}")