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
1 change: 1 addition & 0 deletions STATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The harness is built and runs end to end offline (`make offline`) against fake m

## Recently Done

- The source distribution holds only the tool's source, the tests and the readme and licence files, about 160 KB instead of 33 MB with `results/` and `data/`; a test builds it and checks its files and size (#113)
- [README](README.md): the finding and the main chart first, then the six arms, the four hypotheses with their numbers, one gallery trace, how to rerun the analysis for free and the models under a cap, what it cost, and the tool with its install, a real session and its limits (#34)
- The trial session rerun with the hook's final line: in two of three sessions the agent searched once after the compaction and answered correctly; in the third it offered to search but asked first, because the user had told the compaction to drop those details ([trial session](docs/trial-session.md)) (#104)
- Claude Code plugin in `plugin/`, installable from the repo's marketplace: the bundled `backread` command, a skill on when to search, and a hook that adds one line after each compaction naming this session's transcript; its wording is the `search` arm's neutral tool sentence, adapted for Claude Code ([plugin](docs/plugin.md)) (#32)
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies = []
backread = "backread.cli:main"

[dependency-groups]
dev = ["ruff", "pyright", "pytest"]
dev = ["ruff", "pyright", "pytest", "hatchling"]
experiment = [
"anthropic>=2.14.0",
"compactbench==0.3.0",
Expand All @@ -30,6 +30,12 @@ build-backend = "hatchling.build"
# The published wheel is the tool only. backread_exp runs from a checkout.
packages = ["src/backread"]

[tool.hatch.build.targets.sdist]
# The source distribution builds that wheel: the tool's source and the tests. Hatchling adds
# pyproject.toml, the readme and LICENSE/NOTICE itself; LICENSES/ only comes in when listed.
# results/, data/ and the experiment stay in the repo.
only-include = ["src/backread", "tests", "LICENSES"]

[tool.ruff]
line-length = 100
target-version = "py313"
Expand Down
45 changes: 44 additions & 1 deletion tests/test_packaging.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""The tool stays dependency-free and the experiment package stays importable."""
"""The tool stays dependency-free, the experiment importable, and the sdist small."""

import importlib
import pkgutil
import subprocess
import sys
import tarfile
import tomllib
from pathlib import Path

from hatchling.builders.sdist import SdistBuilder

import backread
import backread_exp

Expand Down Expand Up @@ -57,3 +60,43 @@ def test_experiment_modules_import() -> None:
def test_tool_modules_exist() -> None:
names = {info.name for info in pkgutil.walk_packages(backread.__path__, "backread.")}
assert {"backread.search", "backread.cli", "backread.transcript", "backread.store"} <= names


# What the source distribution may hold: the files hatchling always adds, the licence files, the
# tool's source and the tests. Anything else, results/ and data/ above all, is a packaging bug.
SDIST_TOP_LEVEL_FILES = {
".gitignore",
"LICENSE",
"NOTICE",
"PKG-INFO",
"README.md",
"pyproject.toml",
}
SDIST_DIRECTORIES = ("LICENSES/", "src/backread/", "tests/")
# It was about 160 KB when this test was written, against 33 MB before the include list.
SDIST_MAX_BYTES = 1_000_000


def test_sdist_holds_only_the_tool_its_tests_and_licences(tmp_path: Path) -> None:
root = PYPROJECT.parent
[built] = SdistBuilder(str(root)).build(directory=str(tmp_path), versions=["standard"])
sdist = Path(built)
assert sdist.stat().st_size < SDIST_MAX_BYTES, f"sdist is {sdist.stat().st_size:,} bytes"

with tarfile.open(sdist) as archive:
prefix = f"{sdist.name.removesuffix('.tar.gz')}/"
names = {
member.name.removeprefix(prefix) for member in archive.getmembers() if member.isfile()
}
unexpected = {
name
for name in names
if name not in SDIST_TOP_LEVEL_FILES and not name.startswith(SDIST_DIRECTORIES)
}
assert not unexpected, f"unexpected files in the sdist: {sorted(unexpected)}"

tool_source = {
path.relative_to(root).as_posix() for path in (root / "src" / "backread").rglob("*.py")
}
assert tool_source <= names, f"missing from the sdist: {sorted(tool_source - names)}"
assert {"pyproject.toml", "README.md", "LICENSE"} <= names
45 changes: 45 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading