fix(plugins): use shared handoff resources and native patch versions

This commit is contained in:
kartik-mem0
2026-09-10 19:20:14 +05:30
parent 19a71bbacf
commit 2ac8f2f9a9
83 changed files with 2515 additions and 2916 deletions
@@ -19,7 +19,7 @@ launcher = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(launcher)
REVISION = "1" * 40
FILES = {
"claude_to_codex.py": b"def main(argv=None, default_source=None):\n return 0\n",
"handoff_engine.py": b"def main(argv=None, default_source=None):\n return 0\n",
"handoff_sources.py": b"# reader\n",
}
@@ -87,7 +87,7 @@ def test_failed_second_download_publishes_no_partial_runtime(tmp_path, monkeypat
def download(url, timeout):
if url.endswith("handoff_sources.py"):
raise URLError("offline")
return io.BytesIO(FILES["claude_to_codex.py"])
return io.BytesIO(FILES["handoff_engine.py"])
monkeypatch.setattr(launcher, "urlopen", download)
with pytest.raises(OSError, match="could not download pinned handoff runtime handoff_sources.py"):
@@ -103,7 +103,7 @@ def test_hash_mismatch_never_replaces_existing_cache(tmp_path, monkeypatch):
monkeypatch.setattr(launcher, "urlopen", lambda *args, **kwargs: io.BytesIO(b"wrong response"))
with pytest.raises(ValueError, match="SHA256 mismatch"):
launcher.runtime_root(plugin)
assert (cache / "claude_to_codex.py").read_bytes() == FILES["claude_to_codex.py"]
assert (cache / "handoff_engine.py").read_bytes() == FILES["handoff_engine.py"]
assert (cache / "handoff_sources.py").read_bytes() == b"tampered"
assert list(cache.parent.iterdir()) == [cache]
@@ -111,7 +111,7 @@ def test_hash_mismatch_never_replaces_existing_cache(tmp_path, monkeypatch):
def test_tampered_cache_cannot_run_offline(tmp_path, monkeypatch, capsys):
plugin, cache, _ = installation(tmp_path, monkeypatch)
launcher.runtime_root(plugin)
(cache / "claude_to_codex.py").write_bytes(b"untrusted code")
(cache / "handoff_engine.py").write_bytes(b"untrusted code")
def offline(*args, **kwargs):
raise URLError("offline")
@@ -150,7 +150,7 @@ def test_missing_manifest_returns_actionable_error(tmp_path, monkeypatch, capsys
def test_launcher_executes_adjacent_engine_with_generic_cli_contract(tmp_path):
shutil.copy2(CORE / "python" / "session_handoff.py", tmp_path / "session_handoff.py")
(tmp_path / "handoff_sources.py").write_text("# reader\n")
(tmp_path / "claude_to_codex.py").write_text(
(tmp_path / "handoff_engine.py").write_text(
"import sys\ndef main(argv=None, default_source='unexpected'):\n"
" assert default_source is None\n assert sys.argv[1:] == ['--bundle', '-']\n return 7\n"
)
@@ -163,7 +163,7 @@ def test_launcher_executes_adjacent_engine_with_generic_cli_contract(tmp_path):
def test_manifest_declares_only_launcher_and_hashes_pinned_engines():
manifest = json.loads((CORE / "build" / "handoff-runtime.json").read_text())
assert manifest["artifacts"] == ["session_handoff.py", "handoff-runtime.json"]
assert manifest["revision"] == "0fb924051fa876b5d6311fe3378794cc92fb6ff8"
assert len(manifest["revision"]) == 40 and all(char in "0123456789abcdef" for char in manifest["revision"])
assert set(manifest["files"]) == launcher.ENGINE_FILES
for name, digest in manifest["files"].items():
assert digest == hashlib.sha256((CORE / "python" / name).read_bytes()).hexdigest()