|
| 1 | +"""Parity guard: the six supported adapters agree at every layer. |
| 2 | +
|
| 3 | +Andy's 2026-09-10 ruling fixes the supported set at exactly kiro, claude, |
| 4 | +codex, opencode, pi and grok (Grok Build) -- see |
| 5 | +``docs/architecture/session-memory/receipts/adapter-scope-2026-09-10.md``. |
| 6 | +
|
| 7 | +Before this guard, the set lived in six places that could each drift alone: |
| 8 | +the harness contract, the doctor table, the installer links, the exporter |
| 9 | +registry, the export CLI's ``--sources`` choices, and the extractor's source |
| 10 | +filter. ``80d24e48`` dropped grok from the launch layers while the exporter |
| 11 | +kept it, and nothing failed. This file holds the ONE literal; every layer |
| 12 | +must equal it, so the next drift fails here with the layer named. |
| 13 | +""" |
| 14 | + |
| 15 | +from __future__ import annotations |
| 16 | + |
| 17 | +import re |
| 18 | +from pathlib import Path |
| 19 | + |
| 20 | +from agent_session_tools.export_sessions import SOURCE_CHOICES |
| 21 | +from agent_session_tools.exporters import EXPORTERS |
| 22 | +from studyloop import installers |
| 23 | +from studyloop.doctor.agents import TOOL_AGENTS |
| 24 | +from studyloop.extractors.pipeline import STUDY_SOURCES |
| 25 | +from studyloop.harnesses import HARNESSES, RELEASE_HARNESSES, SESSION_SOURCE_BY_HARNESS |
| 26 | +from studyloop.web.services.session_start import ACP_CAPABLE_AGENTS |
| 27 | + |
| 28 | +#: The ruling. Harness ids as used by ``harnesses.py`` and the exporter registry. |
| 29 | +EXPECTED_HARNESSES = frozenset({"kiro", "claude", "codex", "opencode", "pi", "grok"}) |
| 30 | + |
| 31 | +#: The ``sessions.source`` labels those six harnesses write. Two differ from |
| 32 | +#: the harness id (``kiro_cli``, ``claude_code``); the rest coincide. |
| 33 | +EXPECTED_SOURCES = frozenset({"kiro_cli", "claude_code", "codex", "opencode", "pi", "grok"}) |
| 34 | + |
| 35 | +REPO_ROOT = Path(__file__).resolve().parents[3] |
| 36 | + |
| 37 | + |
| 38 | +def _layer_diff(name: str, actual: set[str]) -> str: |
| 39 | + return ( |
| 40 | + f"{name} disagrees with the six-adapter ruling: " |
| 41 | + f"missing {sorted(EXPECTED_HARNESSES - actual)}, " |
| 42 | + f"unexpected {sorted(actual - EXPECTED_HARNESSES)}" |
| 43 | + ) |
| 44 | + |
| 45 | + |
| 46 | +def test_release_contract_is_exactly_the_six() -> None: |
| 47 | + assert len(RELEASE_HARNESSES) == len(set(RELEASE_HARNESSES)), "duplicate harness id" |
| 48 | + assert set(RELEASE_HARNESSES) == EXPECTED_HARNESSES, _layer_diff( |
| 49 | + "RELEASE_HARNESSES", set(RELEASE_HARNESSES) |
| 50 | + ) |
| 51 | + |
| 52 | + |
| 53 | +def test_launch_layers_enumerate_the_same_six() -> None: |
| 54 | + layers = { |
| 55 | + "harnesses.HARNESSES": set(HARNESSES), |
| 56 | + "harnesses.SESSION_SOURCE_BY_HARNESS": set(SESSION_SOURCE_BY_HARNESS), |
| 57 | + "doctor.agents.TOOL_AGENTS": set(TOOL_AGENTS), |
| 58 | + "installers._TOOL_LINKS": set(installers._TOOL_LINKS), |
| 59 | + } |
| 60 | + for name, actual in layers.items(): |
| 61 | + assert actual == EXPECTED_HARNESSES, _layer_diff(name, actual) |
| 62 | + |
| 63 | + |
| 64 | +def test_session_export_layers_enumerate_the_same_six() -> None: |
| 65 | + assert set(EXPORTERS) == EXPECTED_HARNESSES, _layer_diff("exporters.EXPORTERS", set(EXPORTERS)) |
| 66 | + assert set(SOURCE_CHOICES) == EXPECTED_HARNESSES, _layer_diff( |
| 67 | + "export_sessions.SOURCE_CHOICES", set(SOURCE_CHOICES) |
| 68 | + ) |
| 69 | + |
| 70 | + |
| 71 | +def test_source_labels_agree_between_contract_and_extractor() -> None: |
| 72 | + assert set(SESSION_SOURCE_BY_HARNESS.values()) == EXPECTED_SOURCES |
| 73 | + assert STUDY_SOURCES == EXPECTED_SOURCES, ( |
| 74 | + "extractors.pipeline.STUDY_SOURCES must be derived from the harness contract: " |
| 75 | + f"missing {sorted(EXPECTED_SOURCES - STUDY_SOURCES)}, " |
| 76 | + f"unexpected {sorted(STUDY_SOURCES - EXPECTED_SOURCES)}" |
| 77 | + ) |
| 78 | + |
| 79 | + |
| 80 | +def test_acp_capable_set_is_a_subset_of_the_six() -> None: |
| 81 | + assert ACP_CAPABLE_AGENTS <= EXPECTED_HARNESSES, sorted(ACP_CAPABLE_AGENTS - EXPECTED_HARNESSES) |
| 82 | + |
| 83 | + |
| 84 | +def test_readme_names_every_supported_harness_by_its_label() -> None: |
| 85 | + """The README is the first thing a new user reads; it must name all six.""" |
| 86 | + text = (REPO_ROOT / "README.md").read_text(encoding="utf-8") |
| 87 | + missing = [ |
| 88 | + harness.label |
| 89 | + for harness in HARNESSES.values() |
| 90 | + if not re.search(rf"\b{re.escape(harness.label)}\b", text) |
| 91 | + ] |
| 92 | + assert not missing, f"README.md does not name these supported harnesses: {missing}" |
0 commit comments