Skip to content

Commit c8315cc

Browse files
test(e2e): classify hermetic test worlds as unclassified context scope
The context system never infers a scope from a harness: without memory.default_scope or SESSION_CONTEXT_SCOPE a session/start raises ScopeError (HTTP 409 context_scope_unavailable). The in-process conftest autouse fixture already classifies tests as 'unclassified', but three spawn paths built environments that never carried it, so ~170 integration/e2e tests failed at session start after the context-memory merge: - _playwright_helpers._isolated_child_env: the hermetic base env for every spawned studyloop web server - e2e/_env.build_test_world: the TestWorld verbatim environment - test_harness_matrix._build_env: a class-scoped fixture that snapshots os.environ BEFORE the function-scoped autouse monkeypatch runs Each now sets SESSION_CONTEXT_SCOPE=unclassified explicitly — the same choice the in-process fixture makes, made at the same trust boundary.
1 parent 51a5fca commit c8315cc

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎packages/studyloop/tests/_playwright_helpers.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ def _isolated_child_env(extra_env: Mapping[str, str] | None = None) -> dict[str,
8787
"NO_COLOR": "1",
8888
"TERM": "dumb",
8989
"PYTHONHASHSEED": "0",
90+
# The context system never infers a scope from a harness: without a
91+
# configured memory.default_scope a session/start raises ScopeError
92+
# (HTTP 409 context_scope_unavailable). The hermetic child gets no
93+
# real config, so classify it explicitly as unclassified — mirroring
94+
# conftest.py's in-process _isolate_memory_policy autouse fixture.
95+
"SESSION_CONTEXT_SCOPE": "unclassified",
9096
}
9197
# conftest.py sets these once, process-wide, to a tmp path (never the
9298
# developer's real sessions.db/state dir) via os.environ.setdefault --

‎packages/studyloop/tests/e2e/_env.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ def build_test_world(
260260
"STUDYLOOP_CONFIG": str(config),
261261
"STUDYLOOP_SESSION_DIR": str(session_dir),
262262
"STUDYLOOP_PLANS_DIR": str(plans),
263+
# The context system refuses to infer a scope from a harness
264+
# (ScopeError -> HTTP 409 on session/start). Test worlds carry no
265+
# memory.default_scope config, so classify them explicitly — the
266+
# same choice the in-process conftest autouse fixture makes.
267+
"SESSION_CONTEXT_SCOPE": "unclassified",
263268
}
264269
if fake_agent:
265270
child_env["STUDYLOOP_TEST_AGENT_CMD"] = shlex.join(

‎packages/studyloop/tests/test_harness_matrix.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ def _build_env(
141141
**os.environ,
142142
"STUDYLOOP_TEST_AGENT_CMD": agent_cmd,
143143
"STUDYLOOP_CONFIG": str(config_path),
144+
# This class-scoped fixture builds env before the function-scoped
145+
# autouse _isolate_memory_policy fixture runs, so os.environ does
146+
# not yet carry SESSION_CONTEXT_SCOPE. The child `studyloop study`
147+
# would hit ScopeError (scope is never inferred from a harness)
148+
# before writing session-state.json. Classify the world explicitly.
149+
"SESSION_CONTEXT_SCOPE": "unclassified",
144150
**_agent_extra_env(agent_name, tmp_path),
145151
}
146152
env.pop("TMUX", None)

0 commit comments

Comments
 (0)