Files
Gabriel VidalandClaude Opus 5.5 1574ccd388 sidecar: strict plugin-only cutover (Wave 3C)
Delete the built-in bridges and the legacy harness / usage modules now owned
by ai-agent-plugins (harness_builtin, claude_cli, claude_accounts,
claude_usage, pi_runs, opencode_{cli,mirror,tools,usage},
agy_{cli,mirror,tools,usage}). routes_runs / fork keep only the routes; the
harness-* plugins' drivers launch.

- harness_loader: no builtins; the first read boots the registry; a live dir
  never materialized falls back to .lkg, then (host only) the seed plugins
  (SIDECAR_SEED_PLUGINS_DIR, default ~/projects/ai-agent-plugins/plugins);
  codeless provider entries keep their manifest + config.json; module() and
  forget_status() accessors; hub-written absolute dirs resolved by name.
- usage_loader: provider_configs() covers every provider plugin, evox2()
  reads servers + Wake-on-LAN from provider-evox2 (local_ready, gen_progress
  use it — no duplicated EVOX2 constants).
- core helpers kept self-contained: claude_env.py (run env, account env,
  machine login), run_errors.py (typed errors); launch._stop_run calls the
  driver's stop_extra; /accounts?fresh=1 and guest listing go through drivers;
  gen_progress reads the opencode db via harness_loader.module; tools_check
  via driver status; tools_install has its own gh device-login pump.
- /sync accepts a provider bundle without a usage reader.
- backend workers/labsync: always send harnesses + providers maps ({} clears
  a worker); guests only get harnesses whose own plugin.json says
  guestAllowed.
- tests + A/B scripts run the real plugins (conftest live index + legacy-name
  import hook; launch-dump / _mirror_worker load the plugins for a tree with
  no bridges). install.sh points the host unit at the hub's live dirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:53:17 +01:00

68 lines
2.7 KiB
Python

"""The claude fork's transcript surgery (harness-claude plugin's
``runs.fork_transcript``): the cut point canary and its bookkeeping trim for a
follow-up delivered through the inbox socket."""
import json
import pytest
from fastapi import HTTPException
from conftest import plugin_module
def _fork_transcript(*a, **k):
return plugin_module("harness", "harness-claude", "runs").fork_transcript(*a, **k)
PREFIX = ("[Follow-up from your user, sent from the ai-agent composer — this IS "
"your user's own message, not a peer agent's.]\n\n")
ASIDE = PREFIX + "there is blender on evox2 if you need"
def _src(tmp_path, recs):
p = tmp_path / "src.jsonl"
p.write_text("".join(json.dumps(r) + "\n" for r in recs))
return p
# What 2.1.296 records when a busy run absorbs a follow-up mid-turn.
MID_TURN = [
{"type": "user", "sessionId": "s", "message": {"role": "user", "content": "go"}},
{"type": "assistant", "sessionId": "s", "message": {"role": "assistant", "content": [
{"type": "tool_use", "id": "tu1", "name": "Write", "input": {}}]}},
{"type": "queue-operation", "operation": "enqueue", "sessionId": "s",
"content": ASIDE},
{"type": "user", "sessionId": "s", "message": {"role": "user", "content": [
{"type": "tool_result", "tool_use_id": "tu1", "content": "ok"}]}},
{"type": "attachment", "sessionId": "s", "attachment": {
"type": "queued_command", "prompt": ASIDE, "origin": {"kind": "peer"}}},
{"type": "queue-operation", "operation": "remove", "sessionId": "s",
"reason": "absorbed_mid_turn", "content": ASIDE},
]
def test_forks_at_a_mid_turn_followup_without_its_bookkeeping(tmp_path):
dst = tmp_path / "dst.jsonl"
_fork_transcript(_src(tmp_path, MID_TURN), dst, "new", 4,
"there is blender on evox2 if you need")
out = [json.loads(ln) for ln in dst.read_text().splitlines()]
assert [o["type"] for o in out] == ["user", "assistant", "user"]
assert all(o["sessionId"] == "new" for o in out)
assert "blender" not in dst.read_text()
def test_canary_matches_an_idle_inbox_followup(tmp_path):
recs = [MID_TURN[0],
{"type": "user", "sessionId": "s", "message": {"role": "user", "content":
"Another Claude session sent a message:\n" + ASIDE}}]
dst = tmp_path / "dst.jsonl"
_fork_transcript(_src(tmp_path, recs), dst, "new", 1,
"there is blender on evox2")
assert len(dst.read_text().splitlines()) == 1
def test_canary_still_refuses_another_message(tmp_path):
with pytest.raises(HTTPException) as e:
_fork_transcript(_src(tmp_path, MID_TURN), tmp_path / "d.jsonl", "new", 4,
"something else entirely")
assert e.value.status_code == 409