Skip to content

Commit 51a5fca

Browse files
fix(packaging): declare agent-session-tools as a required dependency
The context-memory integration made agent_session_tools a module-level import of core studyloop code (history/*, parking, notes, mcp.tools, web.context_response), so a wheel installed without it cannot even start — the installed-wheel web smoke caught exactly this. The pre-integration shape (no advertised dependency; DECISIONS.md B1's 'source-install only') is no longer honest, so: - packages/studyloop/pyproject.toml declares agent-session-tools>=0.1.0 as a required dependency, resolved from the uv workspace during development ([tool.uv.sources] workspace = true). - agent-session-tools is still not on PyPI, so a release ships BOTH wheels: scripts/build-release.sh builds the companion, and every wheel smoke (web, extras, template packaging) builds and installs the pair — which is exactly what a user installs. - test_extras_contract.py's guard is inverted accordingly: it now pins the dependency + workspace source instead of forbidding them. There is still no 'sessions' extra: the dependency is unconditional. Verification: smoke-web, smoke-extras, template packaging, mcp stdio smoke, and web session lifecycle integration tests all pass; the default suite (5563 tests) is green.
1 parent 213feef commit 51a5fca

7 files changed

Lines changed: 164 additions & 91 deletions

File tree

‎packages/studyloop/pyproject.toml‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ dependencies = [
2222
"pyyaml>=6.0",
2323
"pexpect>=4.9",
2424
"python-dotenv>=1.2.2",
25+
# The context-memory integration made agent-session-tools a module-level
26+
# import of core studyloop code (history/*, parking, notes, mcp.tools,
27+
# web.context_response), so the wheel is simply broken without it and the
28+
# dependency must be declared. This supersedes the R-29/F-02-era shape
29+
# (no advertised dependency) and DECISIONS.md B1's "source-install only"
30+
# framing: agent-session-tools is still unpublished on PyPI, so releases
31+
# ship BOTH wheels (scripts/build-release.sh) and the wheel smokes install
32+
# them together. The source-install path is unchanged
33+
# (install_workspace_tools() still passes --with-editable).
34+
"agent-session-tools>=0.1.0",
2535
]
2636

2737
[project.optional-dependencies]
@@ -31,19 +41,15 @@ notebooklm = ["notebooklm-py>=0.3.4"]
3141
tui = ["textual>=0.80"]
3242
web = ["fastapi>=0.115", "uvicorn[standard]>=0.34", "httpx>=0.27", "websockets>=12.0", "cryptography>=42.0"]
3343
mcp = ["mcp[cli]>=1.0.0,<2"]
34-
# There is deliberately no `sessions` extra. `agent-session-tools` (the
35-
# session DB / cross-harness knowledge base) is not published anywhere, so
36-
# `[tool.uv.sources] workspace = true` -- the only thing that ever made
37-
# `studyloop[sessions]` resolve -- worked inside this repo's own uv workspace
38-
# and nowhere else: a wheel built with `--no-sources`, or any install of a
39-
# hypothetical future PyPI release, advertised a dependency that could never
40-
# install (REPORT.md R-29 / F-02).
41-
#
42-
# Instead, `agent-session-tools` is a HARD dependency of the source-install
43-
# path (DECISIONS.md B1): `install_workspace_tools()` in `installers.py`
44-
# passes `--with-editable <agent-session-tools path>` unconditionally when
45-
# installing the `studyloop` tool, independent of any extra. A source
46-
# checkout always gets it; a bare wheel install never advertises it.
44+
# `agent-session-tools` is a REQUIRED dependency (see `dependencies` above)
45+
# but is not published on PyPI: it resolves from this uv workspace during
46+
# development, and releases ship its wheel next to studyloop's
47+
# (scripts/build-release.sh builds both; the wheel smokes install both).
48+
# History: there was deliberately no `sessions` extra (REPORT.md R-29 / F-02
49+
# — an extra that could never resolve outside the workspace), and B1 made it
50+
# a hard dependency of the source-install path only. The context-memory
51+
# integration then made it a hard import of core modules, which is what
52+
# moved it into `dependencies`.
4753
all = ["studyloop[content,bedrock,web,notebooklm,tui,mcp]"]
4854

4955
[project.scripts]
@@ -60,6 +66,13 @@ Documentation = "https://github.com/NetDevAutomate/StudyLoop/tree/main/docs"
6066
requires = ["hatchling"]
6167
build-backend = "hatchling.build"
6268

69+
[tool.uv.sources]
70+
# Backs the REQUIRED agent-session-tools dependency during development:
71+
# inside this workspace it resolves to the sibling package. Release builds
72+
# use --no-sources, so the built wheel carries the bare requirement and a
73+
# release ships both wheels together (scripts/build-release.sh).
74+
agent-session-tools = { workspace = true }
75+
6376
[tool.hatch.build.targets.wheel]
6477
packages = ["src/studyloop"]
6578
# Dev-only vendored assets are tracked in git -- a developer needs them on every

‎packages/studyloop/tests/test_extras_contract.py‎

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
"""R-29 guard: `studyloop[sessions]` / `studyloop[all]` must not advertise a
1+
"""Extras contract: every advertised extra must resolve outside the workspace.
22
3-
dependency that cannot resolve outside the uv workspace.
3+
History (R-29 / F-02, DECISIONS.md B1): `agent-session-tools` was once an
4+
unresolvable `sessions` extra, then a hard dependency of the source-install
5+
path only (`install_workspace_tools()`'s unconditional `--with-editable`).
6+
The context-memory integration made it a module-level import of core
7+
studyloop code, so it is now a REQUIRED dependency, resolved from the
8+
workspace during development and shipped as a companion wheel in releases
9+
(scripts/build-release.sh builds both; the wheel smokes install both).
410
5-
`agent-session-tools` is not published anywhere -- `[tool.uv.sources]
6-
agent-session-tools = { workspace = true }` only ever worked inside this
7-
repo's own uv workspace, so a wheel built with `--no-sources` (or any install
8-
from a hypothetical future PyPI release) advertised an unresolvable
9-
dependency (REPORT.md F-02 / R-29; DECISIONS.md B1).
10-
11-
`agent-session-tools` reaches the studyloop tool venv today via
12-
`install_workspace_tools()`'s unconditional `--with-editable` flag
13-
(`installers.py`), completely independent of any extra -- that is the "hard
14-
dependency on the source-install path" DECISIONS.md B1 describes. The extra
15-
was always redundant with that mechanism and never actually needed by it, so
16-
dropping it changes nothing about the real, tested install flow.
11+
There is still no `sessions` extra: the dependency is unconditional, not
12+
optional, and an extra would again advertise something PyPI cannot supply.
1713
1814
`[all]` stays, because `install_workspace_tools()` still requests it
19-
unconditionally for both workspace packages -- but it is redefined to the six
15+
unconditionally for both workspace packages -- it expands to the six
2016
extras that genuinely resolve from a bare wheel (proved per-extra in
21-
test_wheel_extras_smoke.py), with `sessions` removed from its expansion.
17+
test_wheel_extras_smoke.py).
2218
"""
2319

2420
from __future__ import annotations
@@ -68,16 +64,24 @@ def test_all_extra_expands_to_exactly_the_resolvable_extras() -> None:
6864
assert named <= extras.keys(), "studyloop[all] names an extra that does not exist"
6965

7066

71-
def test_no_uv_source_maps_the_dropped_agent_session_tools_extra() -> None:
72-
"""The `[tool.uv.sources]` entry existed only to resolve the now-removed
73-
74-
`sessions` extra; leaving it behind would be dead configuration pointing
75-
at a name this file no longer references anywhere.
67+
def test_agent_session_tools_is_a_required_dependency_with_workspace_source() -> None:
68+
"""The context-memory integration made `agent_session_tools` a
69+
module-level import of core studyloop code, so the dependency must be
70+
declared (the pre-integration shape — no advertised dependency, B1's
71+
"source-install only" — would ship a wheel that cannot even import).
72+
The `[tool.uv.sources]` workspace mapping is what resolves it during
73+
development; releases build with --no-sources and ship both wheels.
7674
"""
7775
with PACKAGE_PYPROJECT.open("rb") as pyproject_file:
7876
pyproject = tomllib.load(pyproject_file)
77+
deps = pyproject.get("project", {}).get("dependencies", [])
78+
assert any(spec.startswith("agent-session-tools") for spec in deps), (
79+
f"agent-session-tools must be a required dependency; got {deps}"
80+
)
7981
sources = pyproject.get("tool", {}).get("uv", {}).get("sources", {})
80-
assert "agent-session-tools" not in sources
82+
assert sources.get("agent-session-tools") == {"workspace": True}, (
83+
f"agent-session-tools must resolve from the workspace during development; got {sources!r}"
84+
)
8185

8286

8387
# ---------------------------------------------------------------------------

‎packages/studyloop/tests/test_second_brain_template_packaging.py‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ def built_wheel(tmp_path_factory) -> Path:
3535
if shutil.which("uv") is None:
3636
pytest.skip("uv is not on PATH, so the wheel cannot be built here")
3737
out = tmp_path_factory.mktemp("template-packaging")
38-
proc = subprocess.run(
39-
["uv", "build", "--package", "studyloop", "--wheel", "-o", str(out)],
40-
cwd=REPO_ROOT,
41-
capture_output=True,
42-
text=True,
43-
timeout=300,
44-
)
45-
if proc.returncode != 0:
46-
pytest.fail(f"wheel build failed:\n{proc.stdout}\n{proc.stderr}")
38+
# agent-session-tools is a required dependency of the studyloop wheel but
39+
# is not on PyPI, so build the companion too — a release ships both.
40+
for package in ("studyloop", "agent-session-tools"):
41+
proc = subprocess.run(
42+
["uv", "build", "--package", package, "--wheel", "-o", str(out)],
43+
cwd=REPO_ROOT,
44+
capture_output=True,
45+
text=True,
46+
timeout=300,
47+
)
48+
if proc.returncode != 0:
49+
pytest.fail(f"wheel build failed for {package}:\n{proc.stdout}\n{proc.stderr}")
4750
wheels = list(out.glob("studyloop-*.whl"))
4851
assert len(wheels) == 1, f"expected one wheel, got {wheels}"
4952
return wheels[0]
@@ -74,8 +77,17 @@ def test_templates_load_from_the_installed_wheel(built_wheel: Path, tmp_path) ->
7477
venv = tmp_path / "venv"
7578
subprocess.run(["uv", "venv", str(venv)], check=True, capture_output=True)
7679
python = venv / "bin" / "python"
80+
companion = next(built_wheel.parent.glob("agent_session_tools-*.whl"))
7781
subprocess.run(
78-
["uv", "pip", "install", "--python", str(python), str(built_wheel)],
82+
[
83+
"uv",
84+
"pip",
85+
"install",
86+
"--python",
87+
str(python),
88+
str(companion),
89+
str(built_wheel),
90+
],
7991
check=True,
8092
capture_output=True,
8193
timeout=300,

‎packages/studyloop/tests/test_wheel_extras_smoke.py‎

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
"""R-29: every extra `studyloop`'s wheel still advertises must actually
22
3-
install and import from a **bare** wheel -- no uv workspace, no sibling
4-
package, no `--with-editable`.
3+
install and import from the **release wheels** -- no uv workspace, no
4+
`--with-editable`. `agent-session-tools` became a required dependency of the
5+
studyloop wheel with the context-memory integration (core modules import it
6+
at module level), but it is not published on PyPI, so "what a user installs"
7+
is the release pair: both wheels installed together. Each install below
8+
therefore provides the companion wheel explicitly, exactly like
9+
scripts/build-release.sh's output instructs.
510
611
This is the other half of the R-29 fix (see test_extras_contract.py for the
712
"[sessions]/[all] must not lie" half). Dropping `sessions` proved the
@@ -65,21 +70,28 @@ def built_wheel(tmp_path_factory: pytest.TempPathFactory) -> Path:
6570
# --no-sources: build exactly what a real distribution would ship, not
6671
# what the local workspace's [tool.uv.sources] would substitute. This is
6772
# the same flag scripts/build-release.sh uses, and the one that exposed
68-
# R-29 in the first place (a plain `uv build` masks the defect).
69-
proc = subprocess.run(
70-
["uv", "build", "--package", "studyloop", "--no-sources", "--wheel", "-o", str(out)],
71-
cwd=REPO_ROOT,
72-
capture_output=True,
73-
text=True,
74-
timeout=300,
75-
)
76-
if proc.returncode != 0:
77-
pytest.fail(f"wheel build failed:\n{proc.stdout}\n{proc.stderr}")
73+
# R-29 in the first place (a plain `uv build` masks the defect). A release
74+
# ships BOTH wheels, so both are built here.
75+
for package in ("studyloop", "agent-session-tools"):
76+
proc = subprocess.run(
77+
["uv", "build", "--package", package, "--no-sources", "--wheel", "-o", str(out)],
78+
cwd=REPO_ROOT,
79+
capture_output=True,
80+
text=True,
81+
timeout=300,
82+
)
83+
if proc.returncode != 0:
84+
pytest.fail(f"wheel build failed for {package}:\n{proc.stdout}\n{proc.stderr}")
7885
wheels = list(out.glob("studyloop-*.whl"))
79-
assert len(wheels) == 1, f"expected one wheel, got {wheels}"
86+
assert len(wheels) == 1, f"expected one studyloop wheel, got {wheels}"
8087
return wheels[0]
8188

8289

90+
def _companion_wheel(built_wheel: Path) -> Path:
91+
"""The agent-session-tools wheel built next to the studyloop wheel."""
92+
return next(built_wheel.parent.glob("agent_session_tools-*.whl"))
93+
94+
8395
def test_sessions_is_not_advertised_on_the_built_wheel(built_wheel: Path) -> None:
8496
with zipfile.ZipFile(built_wheel) as wheel:
8597
metadata_name = next(n for n in wheel.namelist() if n.endswith(".dist-info/METADATA"))
@@ -107,13 +119,21 @@ def test_extra_installs_and_imports_from_a_bare_wheel(
107119
python = venv_dir / "bin" / "python"
108120

109121
install = subprocess.run(
110-
["uv", "pip", "install", "--python", str(python), f"{built_wheel}[{extra}]"],
122+
[
123+
"uv",
124+
"pip",
125+
"install",
126+
"--python",
127+
str(python),
128+
str(_companion_wheel(built_wheel)),
129+
f"{built_wheel}[{extra}]",
130+
],
111131
capture_output=True,
112132
text=True,
113133
timeout=180,
114134
)
115135
assert install.returncode == 0, (
116-
f"installing studyloop[{extra}] from the bare wheel failed:\n"
136+
f"installing studyloop[{extra}] from the release wheels failed:\n"
117137
f"{install.stdout}\n{install.stderr}"
118138
)
119139

@@ -127,18 +147,16 @@ def test_extra_installs_and_imports_from_a_bare_wheel(
127147
)
128148

129149

130-
def test_bare_wheel_with_no_extras_and_no_agent_session_tools_still_works(
131-
built_wheel: Path, tmp_path: Path
132-
) -> None:
133-
"""D2 (council)/D3: a plain `pip install studyloop` (no extras, no
134-
135-
sibling `agent-session-tools`) must still give a working CLI. Every
136-
other test in this file installs an extra; nothing until now proved the
137-
*unextended* base case -- the one a real `pip install studyloop` user
138-
with no extras and no workspace actually gets. `studyloop --version` and
139-
`studyloop doctor --help` are both eager Click options that must not
140-
require `agent_session_tools` to be importable, and `import studyloop.cli`
141-
must not eagerly import anything that isn't a hard dependency.
150+
def test_bare_wheel_with_no_extras_still_works(built_wheel: Path, tmp_path: Path) -> None:
151+
"""D2 (council)/D3, updated for the context-memory integration: a plain
152+
153+
no-extras install (the release wheel pair, since agent-session-tools is
154+
now a required dependency that PyPI cannot supply) must still give a
155+
working CLI. Every other test in this file installs an extra; nothing
156+
until now proved the *unextended* base case. `studyloop --version` and
157+
`studyloop doctor --help` are both eager Click options, and
158+
`import studyloop.cli` must not eagerly import anything that isn't a
159+
hard dependency.
142160
"""
143161
venv_dir = tmp_path / "venv-bare"
144162
venv_proc = subprocess.run(
@@ -149,19 +167,23 @@ def test_bare_wheel_with_no_extras_and_no_agent_session_tools_still_works(
149167
studyloop_bin = venv_dir / "bin" / "studyloop"
150168

151169
install = subprocess.run(
152-
["uv", "pip", "install", "--python", str(python), str(built_wheel)],
170+
[
171+
"uv",
172+
"pip",
173+
"install",
174+
"--python",
175+
str(python),
176+
str(_companion_wheel(built_wheel)),
177+
str(built_wheel),
178+
],
153179
capture_output=True,
154180
text=True,
155181
timeout=180,
156182
)
157183
assert install.returncode == 0, (
158-
f"installing bare studyloop (no extras) from the wheel failed:\n"
184+
f"installing bare studyloop (no extras) from the release wheels failed:\n"
159185
f"{install.stdout}\n{install.stderr}"
160186
)
161-
assert "agent-session-tools" not in install.stdout.lower(), (
162-
"a bare install must not pull in agent-session-tools -- it is not a "
163-
f"dependency of any extra-less install:\n{install.stdout}"
164-
)
165187

166188
# Isolated away from the real machine's config/session DB, matching
167189
# scripts/smoke-installed-cli.sh's isolation -- defensive here since

‎packages/studyloop/tests/test_wheel_web_smoke.py‎

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,23 @@ def built_wheel(tmp_path_factory: pytest.TempPathFactory) -> Path:
5555
pytest.skip("uv is not on PATH, so the wheel cannot be built here")
5656
out = tmp_path_factory.mktemp("web-smoke-wheel")
5757
# --no-sources: build exactly what a real distribution would ship, same as
58-
# scripts/build-release.sh and test_wheel_extras_smoke.py.
59-
proc = subprocess.run(
60-
["uv", "build", "--package", "studyloop", "--no-sources", "--wheel", "-o", str(out)],
61-
cwd=REPO_ROOT,
62-
capture_output=True,
63-
text=True,
64-
timeout=300,
65-
)
66-
if proc.returncode != 0:
67-
pytest.fail(f"wheel build failed:\n{proc.stdout}\n{proc.stderr}")
58+
# scripts/build-release.sh and test_wheel_extras_smoke.py. A release ships
59+
# BOTH wheels (studyloop requires the unpublished agent-session-tools), so
60+
# both are built here and installed together below.
61+
for package in ("studyloop", "agent-session-tools"):
62+
proc = subprocess.run(
63+
["uv", "build", "--package", package, "--no-sources", "--wheel", "-o", str(out)],
64+
cwd=REPO_ROOT,
65+
capture_output=True,
66+
text=True,
67+
timeout=300,
68+
)
69+
if proc.returncode != 0:
70+
pytest.fail(f"wheel build failed for {package}:\n{proc.stdout}\n{proc.stderr}")
6871
wheels = list(out.glob("studyloop-*.whl"))
69-
assert len(wheels) == 1, f"expected one wheel, got {wheels}"
72+
assert len(wheels) == 1, f"expected one studyloop wheel, got {wheels}"
73+
companions = list(out.glob("agent_session_tools-*.whl"))
74+
assert len(companions) == 1, f"expected one agent-session-tools wheel, got {companions}"
7075
return wheels[0]
7176

7277

@@ -82,14 +87,24 @@ def web_venv(built_wheel: Path, tmp_path_factory: pytest.TempPathFactory) -> Pat
8287
)
8388
assert venv_proc.returncode == 0, f"uv venv failed:\n{venv_proc.stdout}\n{venv_proc.stderr}"
8489
python = venv_dir / "bin" / "python"
90+
companion = next(built_wheel.parent.glob("agent_session_tools-*.whl"))
8591
install = subprocess.run(
86-
["uv", "pip", "install", "--python", str(python), f"{built_wheel}[web]"],
92+
[
93+
"uv",
94+
"pip",
95+
"install",
96+
"--python",
97+
str(python),
98+
str(companion),
99+
f"{built_wheel}[web]",
100+
],
87101
capture_output=True,
88102
text=True,
89103
timeout=300,
90104
)
91105
assert install.returncode == 0, (
92-
f"installing studyloop[web] from the bare wheel failed:\n{install.stdout}\n{install.stderr}"
106+
f"installing studyloop[web] from the release wheels failed:\n"
107+
f"{install.stdout}\n{install.stderr}"
93108
)
94109
return venv_dir
95110

‎scripts/build-release.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ cd "$ROOT_DIR"
88
rm -rf dist
99
mkdir -p dist
1010

11+
# The studyloop wheel declares agent-session-tools as a required dependency,
12+
# but agent-session-tools is not published on PyPI — a release therefore
13+
# ships BOTH wheels, installed together:
14+
# uv pip install dist/agent_session_tools-*.whl "dist/studyloop-*.whl[web]"
1115
uv build --package studyloop --no-sources "$@"
16+
uv build --package agent-session-tools --no-sources "$@"

0 commit comments

Comments
 (0)