Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <archive> 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.
Expand Down
2 changes: 1 addition & 1 deletion holotype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""holotype: forensic-grade archival of agent-CLI sessions for scientific reproducibility."""

__version__ = "2.4.0"
__version__ = "2.4.1"
39 changes: 39 additions & 0 deletions holotype/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from __future__ import annotations

import json
import subprocess
from pathlib import Path
from typing import Iterator

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
6 changes: 6 additions & 0 deletions scripts/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions scripts/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions scripts/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)}")
Expand Down
Loading