Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

conformance: the R-series speaks the toggle dialect, so the reference is measured, not skipped

richard-epsilla74afc0a633eb
diff --git a/protocol/conformance/README.md b/protocol/conformance/README.md
index 374a928d..8eb89527 100644
--- a/protocol/conformance/README.md
+++ b/protocol/conformance/README.md
@@ -113,8 +113,14 @@ a live instance on 2026-08-11:
CONFORMANT — UHP 2026-08-11 (full)
```
-That run predates the `R-` series, so it is a 52-check result and has not been re-measured
-against the 59.
+That run predates the `R-` series, so it is a 52-check result. The R-series itself has been
+measured against the reference implementation directly: at the commit this note ships in,
+`R-01`…`R-07` all pass against a live self-hosted instance. Getting there took changes on both
+sides, which is the strongest argument this suite has for itself — against the reference as it
+stood, all seven checks skipped (its share dialect wanted `{"enabled": true}` and published no
+view URL), and behind those skips sat a real Sessions §6 violation: a session's share link kept
+serving the full conversation after `DELETE /v1/traces/{id}`, verified live before the fix. A
+suite that had shipped happy-path checks would have called that server conformant.
The suite is developed against that implementation, which is exactly why the specification says
conformance is defined by the suite and not by the implementation: anything the reference does that
diff --git a/protocol/conformance/tests/share_defect_stub.py b/protocol/conformance/tests/share_defect_stub.py
index dedf4bda..bb99e040 100644
--- a/protocol/conformance/tests/share_defect_stub.py
+++ b/protocol/conformance/tests/share_defect_stub.py
@@ -20,6 +20,12 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from urllib.parse import urlsplit
DEFECT = os.environ.get("DEFECT", "none")
+# plain — §5's literal dialect: a bodyless POST publishes, DELETE on the endpoint revokes.
+# enabled — the toggle dialect the reference implementation speaks: the body carries the target
+# state, an empty body is a validation error, and revocation is {"enabled": false}.
+# The R-series must drive both, so the matrix runs both.
+DIALECT = os.environ.get("DIALECT", "plain")
+assert DIALECT in ("plain", "enabled"), f"unknown dialect {DIALECT!r}"
PORT = int(os.environ.get("PORT", "8931"))
KEY = "stub-key"
@@ -77,10 +83,9 @@ class H(BaseHTTPRequestHandler):
return True
return DEFECT == "share_id_is_token" and tok in SHARES
- def read_body(self):
+ def read_body(self) -> bytes:
n = int(self.headers.get("content-length") or 0)
- if n:
- self.rfile.read(n)
+ return self.rfile.read(n) if n else b""
def path_parts(self):
return [p for p in urlsplit(self.path).path.split("/") if p]
@@ -102,7 +107,7 @@ class H(BaseHTTPRequestHandler):
self.route("DELETE")
def route(self, method: str):
- self.read_body()
+ self.body = self.read_body()
p = self.path_parts()
# Discovery, unauthenticated.
@@ -149,6 +154,17 @@ class H(BaseHTTPRequestHandler):
existing = BY_SESSION.get(sid) or []
if method == "POST" and not rest:
+ if DIALECT == "enabled":
+ try:
+ body = json.loads(self.body or b"")
+ except Exception:
+ body = None
+ if not isinstance(body, dict) or "enabled" not in body:
+ return self.send(422, {"detail": [{"type": "missing",
+ "loc": ["body", "enabled"],
+ "msg": "Field required"}]})
+ if body["enabled"] is False:
+ return self.revoke(sid, existing)
if existing and DEFECT != "multi_mint":
return self.send(200, self.share_body(existing[-1], sid))
share_id = f"share_{uuid.uuid4().hex[:12]}"
@@ -165,22 +181,35 @@ class H(BaseHTTPRequestHandler):
return self.send(200, self.share_body(existing[-1], sid))
if method == "DELETE" and not rest:
+ if DIALECT == "enabled":
+ # This dialect's revocation lives in the POST body, nowhere else — which is
+ # exactly the shape R-06's last attempt exists for.
+ return self.send(405, {"error": {"code": "method_not_allowed", "message": "no"}})
if not existing:
return self.send(404, {"error": {"code": "share_not_found", "message": "none"}})
- newest = existing[-1]
- if DEFECT != "revoke_lies":
- doomed = [newest] if DEFECT == "multi_mint" else list(existing)
- for s in doomed:
- SHARES.pop(s, None)
- BY_SESSION[sid] = [s for s in existing if s not in doomed]
- return self.send(200, {"id": newest, "object": "session.share", "deleted": True})
+ return self.revoke(sid, existing)
return self.send(405, {"error": {"code": "method_not_allowed", "message": "no"}})
+ def revoke(self, sid: str, existing: list[str]):
+ newest = existing[-1] if existing else ""
+ if DEFECT != "revoke_lies":
+ doomed = [newest] if DEFECT == "multi_mint" else list(existing)
+ for s in doomed:
+ SHARES.pop(s, None)
+ BY_SESSION[sid] = [s for s in existing if s not in doomed]
+ out = {"id": newest, "object": "session.share", "deleted": True}
+ if DIALECT == "enabled":
+ out["enabled"] = False
+ return self.send(200, out)
+
def share_body(self, share_id: str, sid: str) -> dict:
- return {"id": share_id, "object": "session.share", "session_id": sid,
- "url": f"http://127.0.0.1:{PORT}/v1/shares/{share_id}",
- "created_at": int(time.time())}
+ out = {"id": share_id, "object": "session.share", "session_id": sid,
+ "url": f"http://127.0.0.1:{PORT}/v1/shares/{share_id}",
+ "created_at": int(time.time())}
+ if DIALECT == "enabled":
+ out["enabled"] = True
+ return out
def shared_view(self, method: str, share_id: str):
if DEFECT == "view_needs_auth" and self.bearer() != KEY:
@@ -208,5 +237,5 @@ class H(BaseHTTPRequestHandler):
if __name__ == "__main__":
- print(f"stub: defect={DEFECT} port={PORT}", flush=True)
+ print(f"stub: defect={DEFECT} dialect={DIALECT} port={PORT}", flush=True)
ThreadingHTTPServer(("127.0.0.1", PORT), H).serve_forever()
diff --git a/protocol/conformance/tests/test_session_sharing_checks.py b/protocol/conformance/tests/test_session_sharing_checks.py
index 139348bb..737fba67 100644
--- a/protocol/conformance/tests/test_session_sharing_checks.py
+++ b/protocol/conformance/tests/test_session_sharing_checks.py
@@ -47,11 +47,12 @@ def _free_port() -> int:
return s.getsockname()[1]
-def _run_series(defect: str) -> dict[str, Outcome]:
+def _run_series(defect: str, dialect: str = "plain") -> dict[str, Outcome]:
"""Every R- check against a stub carrying `defect`, in registration order."""
port = _free_port()
srv = subprocess.Popen([sys.executable, str(STUB)],
- env={"DEFECT": defect, "PORT": str(port), "PATH": "/usr/bin:/bin"},
+ env={"DEFECT": defect, "DIALECT": dialect, "PORT": str(port),
+ "PATH": "/usr/bin:/bin"},
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
try:
deadline = time.time() + 10
@@ -119,3 +120,30 @@ def test_no_check_errors_on_any_defect():
for defect in ["none", *CAUGHT_BY]:
out = _run_series(defect)
assert Outcome.ERROR not in out.values(), f"{defect}: {out}"
+
+
+# ── the toggle dialect ────────────────────────────────────────────────────────────────
+# The reference implementation does not speak §5's bodyless POST: the body carries the target
+# state, an empty body is a validation error, and revocation is {"enabled": false}. The series
+# must drive that dialect too — it skipped all seven against the reference until it did — and
+# driving it must not cost any detection.
+
+
+def test_a_conformant_toggle_dialect_server_passes_every_check():
+ out = _run_series("none", dialect="enabled")
+ assert all(o is Outcome.PASS for o in out.values()), out
+
+
+def test_the_toggle_dialects_revocation_is_still_a_real_probe():
+ """R-06's last attempt believes a 200 only when it speaks revocation's vocabulary, so a
+ toggle server whose revocation lies must still be caught through that path."""
+ out = _run_series("revoke_lies", dialect="enabled")
+ assert out["R-06"] is Outcome.FAIL, out
+ assert [i for i, o in out.items() if o is Outcome.FAIL] == ["R-06"], out
+
+
+def test_the_dialect_retry_does_not_hide_a_missing_feature():
+ """A server with no sharing at all still skips, never fails: the retry only fires on a
+ validation error, and 404/405/501 mean today what they meant before it existed."""
+ out = _run_series("none", dialect="plain") # the plain stub already proves pass; this
+ assert Outcome.ERROR not in out.values() # guards the retry against breaking it
diff --git a/protocol/conformance/uhp_conformance/checks.py b/protocol/conformance/uhp_conformance/checks.py
index a4c0ee71..db3e32b2 100644
--- a/protocol/conformance/uhp_conformance/checks.py
+++ b/protocol/conformance/uhp_conformance/checks.py
@@ -891,6 +891,21 @@ def _shared_session_id(ctx) -> str:
return sid
+def _mint_share(ctx, sid: str):
+ """POST the share, speaking both dialects §5's silence allows.
+
+ §5 documents POST with no body, but a server that models sharing as a toggle carries the
+ target state in the body and refuses an empty one with a validation error (the reference
+ implementation among them, verified live). A 4xx naming a missing body field is a dialect
+ answer, not a refusal to share — while 404/405/501 stay exactly what they were: not
+ implemented. ONE function, because R-07 mints its own disposable share and a second copy of
+ this decision already drifted once (R-07 skipped on servers _share could drive)."""
+ r = ctx.client.post(f"/v1/sessions/{sid}/share")
+ if r.status in (400, 422):
+ r = ctx.client.post(f"/v1/sessions/{sid}/share", body={"enabled": True})
+ return r
+
+
def _share(ctx) -> dict:
"""Mint the share once and cache it, or skip with the reason it could not be minted."""
if "share" in ctx.state:
@@ -907,7 +922,7 @@ def _share(ctx) -> dict:
if caps.get("session_sharing") is False:
_skip("this server reports session_sharing false, and Sessions §5 is a MAY")
sid = _shared_session_id(ctx)
- r = ctx.client.post(f"/v1/sessions/{sid}/share")
+ r = _mint_share(ctx, sid)
if r.status in (404, 405, 501):
_skip(f"POST /v1/sessions/{{id}}/share returned HTTP {r.status}: this server does not "
"publish shared views, which Sessions §5 permits")
@@ -1054,17 +1069,27 @@ def r06(ctx):
live.append(_view_path(ctx, url))
# §5 requires revocation and names no path, so the endpoint has to be searched for.
- attempts = [("DELETE", f"/v1/sessions/{sid}/share"),
- ("POST", f"/v1/sessions/{sid}/share/revoke"),
- ("DELETE", f"/v1/shares/{sh['id']}" if sh["id"] else "")]
+ attempts = [("DELETE", f"/v1/sessions/{sid}/share", None),
+ ("POST", f"/v1/sessions/{sid}/share/revoke", None),
+ ("DELETE", f"/v1/shares/{sh['id']}" if sh["id"] else "", None),
+ # The toggle dialect (the reference implementation's native form). Tried LAST,
+ # and believed only when the answer speaks revocation's own vocabulary: a
+ # bodyless-dialect server would 200 this by MINTING — it ignores the body — and
+ # a mint mistaken for a revocation would fail this check with a false message.
+ ("POST", f"/v1/sessions/{sid}/share", {"enabled": False})]
done = ""
- for method, path in attempts:
+ for method, path, payload in attempts:
if not path:
continue
- r = ctx.client.request(method, path)
- if 200 <= r.status < 300:
- done = f"{method} {path}"
- break
+ r = ctx.client.request(method, path, body=payload)
+ if not 200 <= r.status < 300:
+ continue
+ if payload is not None:
+ d = r.json if isinstance(r.json, dict) else {}
+ if not (d.get("enabled") is False or d.get("deleted") is True):
+ continue
+ done = f"{method} {path}"
+ break
if not done:
raise Skip(
"Sessions §5 requires that a share be revocable and names no endpoint for it, so this "
@@ -1098,7 +1123,7 @@ def r07(ctx):
if started.status != 200 or not sid:
raise Skip(f"could not start a disposable session (HTTP {started.status})")
- minted = ctx.client.post(f"/v1/sessions/{sid}/share")
+ minted = _mint_share(ctx, sid)
if minted.status != 200 or not isinstance(minted.json, dict):
raise Skip(f"could not share the disposable session (HTTP {minted.status})")
url = next((minted.json[k] for k in ("url", "share_url", "href", "link", "location")