diff --git a/STATE.md b/STATE.md index c002206..de46689 100644 --- a/STATE.md +++ b/STATE.md @@ -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) diff --git a/pyproject.toml b/pyproject.toml index b23db3e..915a353 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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" diff --git a/tests/test_packaging.py b/tests/test_packaging.py index 56c57be..5eab828 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -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 @@ -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 diff --git a/uv.lock b/uv.lock index 5e9a634..2408de0 100644 --- a/uv.lock +++ b/uv.lock @@ -69,6 +69,7 @@ default-groups = ["dev", "experiment"] [package.dev-dependencies] dev = [ + { name = "hatchling" }, { name = "pyright" }, { name = "pytest" }, { name = "ruff" }, @@ -83,6 +84,7 @@ experiment = [ [package.metadata.requires-dev] dev = [ + { name = "hatchling" }, { name = "pyright" }, { name = "pytest" }, { name = "ruff" }, @@ -395,6 +397,22 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, ] +[[package]] +name = "hatchling" +version = "1.33.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, + { name = "pathspec" }, + { name = "pluggy" }, + { name = "tomlkit" }, + { name = "trove-classifiers" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7a/f1/e47b937226ae3b093bbd0132eb0b7ee5bfad12c2b5324afd10ae49946b05/hatchling-1.33.0.tar.gz", hash = "sha256:4c422bd4d554fcff5de5b73e9596f85e41e9f97f7e553d8f7595ecb31a627bef", size = 58079, upload-time = "2026-10-28T02:27:30.694Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/64/4afe5dd77b2939a93e8c9513f8082dbd049ecba9c1484a379a0f6ae29d6b/hatchling-1.33.0-py3-none-any.whl", hash = "sha256:415290b84f464d2884303fca8974d38e7b85579069fab02a15db0828fbb1446d", size = 78750, upload-time = "2026-10-28T02:27:29.033Z" }, +] + [[package]] name = "httpcore" version = "1.0.9" @@ -845,6 +863,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ba/7b/5504f91c9c2733f693d7759e50ede5d27119d4da7e5836c46d3b5ff81d56/packaging-26.4-py3-none-any.whl", hash = "sha256:81383611a09c1bc0b08b76e0fd5829d7c6824c65b27a6aee339da133f4233ea2", size = 140049, upload-time = "2026-11-23T21:44:09.531Z" }, ] +[[package]] +name = "pathspec" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/82/42f767fc1c1143d6fd36efb827202a2d997a375e160a71eb2888a925aac1/pathspec-1.1.1.tar.gz", hash = "sha256:17db5ecd524104a120e173814c90367a96a98d07c45b2e10c2f3919fff91bf5a", size = 135180, upload-time = "2026-04-27T01:46:08.907Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f1/d9/7fb5aa316bc299258e68c73ba3bddbc499654a07f151cba08f6153988714/pathspec-1.1.1-py3-none-any.whl", hash = "sha256:a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189", size = 57328, upload-time = "2026-04-27T01:46:07.06Z" }, +] + [[package]] name = "pillow" version = "13.0.0" @@ -1413,6 +1440,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/35/5e/9b01afd037bfa22a0033963fa091e0f75b6fb15cd85bffb42ff86e697323/tiktoken-0.14.0-cp315-cp315t-win_amd64.whl", hash = "sha256:561e7580f84a79859af1ef6f676968e9030fcc3fe195700b15235bca64f009c9", size = 987929, upload-time = "2026-08-17T19:49:38.947Z" }, ] +[[package]] +name = "tomlkit" +version = "0.15.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c9/85/4a7c68111c057a6498f5bc721ef93b388b420bb31d7020759f18a5f0c2ec/tomlkit-0.15.3.tar.gz", hash = "sha256:b3c3020ec1a4bd469d12e31fb4da938e7f6ba758cdbec3fd9047db63120eaf81", size = 204435, upload-time = "2026-11-24T07:21:10.422Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c3/49/6b0a22e69c844c0b18cb66c206bdd791693d0cf845badc5f84e6448f2192/tomlkit-0.15.3-py3-none-any.whl", hash = "sha256:a83ce6de3b648e68dd9b50aabadad749ba823eb58b1d026f3c0a283c4767a9c1", size = 55467, upload-time = "2026-11-24T07:21:11.239Z" }, +] + +[[package]] +name = "trove-classifiers" +version = "2026.9.21.13" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/93/af436dfaa845cab5d96f0adbc1e4f3730532d37fa249e4eb796fb1d7fc82/trove_classifiers-2026.9.21.13.tar.gz", hash = "sha256:0a9ebc8d4e2f3e8a22848c5258033035bec17a3012ac3fea16dbaa764489eb71", size = 17085, upload-time = "2026-09-21T13:29:07.301Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/30/81/0da8afb52a71d0a4f2bd3152357b1a441e393b286374802b9d3addab4ab5/trove_classifiers-2026.9.21.13-py3-none-any.whl", hash = "sha256:8b1ff4f9c191b1040b71c37f1e445ab99732911e3cd91de52838453a854d7a17", size = 14232, upload-time = "2026-09-21T13:29:06.123Z" }, +] + [[package]] name = "truststore" version = "0.10.5"