Skip to content

Commit 9ea6240

Browse files
committed
test: keep acceptance sockets short and preserve failure evidence
1 parent d17c5ae commit 9ea6240

3 files changed

Lines changed: 34 additions & 9 deletions

File tree

‎docs/cloud-acceptance.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ Do not copy that system-wide policy change onto a shared workstation or producti
6161
host. Use a disposable Linux VM with suitable namespace policy instead.
6262

6363
Fixtures allowlist process environments, generate their own SSH keys, use only
64-
synthetic credentials and keep separate runtime/home directories. They are not
64+
synthetic credentials and keep separate runtime/home directories. Ephemeral Unix
65+
sockets use short private directories under `/tmp` to avoid Linux socket path
66+
limits even when artifact directories are deeply nested. Those socket directories
67+
are removed after their fixture processes stop. Fixtures are not
6568
intended to access your real accounts, shared daemon or managed VM. Never add
6669
production tokens, account files or SSH keys to the fixtures or workflow.
6770

@@ -74,7 +77,7 @@ python3 tests/test_cloud_acceptance_harness.py
7477
```
7578

7679
These fast contracts check failure propagation, timeouts, report generation,
77-
provider gates, and fixture-only process cleanup. They are not a substitute for
80+
provider gates, short socket paths, and fixture-only process cleanup. They are not a substitute for
7881
running the actual acceptance matrix below.
7982

8083
Use an already-built executable, with an absolute path recommended:

‎scripts/cloud_acceptance_tui.py‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import socket
88
import subprocess
99
import sys
10+
import tempfile
1011
import time
1112

1213
SCRIPTS = Path(__file__).resolve().parent
@@ -40,6 +41,11 @@ def __init__(self, binary, root):
4041
self.binary = str(Path(binary).resolve())
4142
self.root = Path(root).resolve()
4243
self.root.mkdir(parents=True)
44+
# Unix sockets have a 108-byte path limit. Keep ephemeral sockets out of
45+
# arbitrarily deep artifact paths, while retaining all logs in root.
46+
self.runtime = tempfile.TemporaryDirectory(prefix="jca-", dir="/tmp")
47+
for side in ("local", "cloud"):
48+
(Path(self.runtime.name) / side).mkdir()
4349
self.children = []
4450
self.files = []
4551
self.env = {"PATH": "/usr/bin:/bin", "LANG": "C.UTF-8", "TERM": "xterm-256color",
@@ -49,10 +55,10 @@ def __init__(self, binary, root):
4955
self.repo = self.root / "local-repo"
5056
self.cloud_repo = self.root / "cloud-repo"
5157
self.control = self.root / "control"
52-
self.sock = str(self.root / "tmux.sock")
58+
self.sock = str(Path(self.runtime.name) / "tmux.sock")
5359
self.sid = None
54-
for name in ("local-repo", "cloud-repo", "local-home", "cloud-home", "local-run",
55-
"cloud-run", "control", "ssh", "bin"):
60+
for name in ("local-repo", "cloud-repo", "local-home", "cloud-home",
61+
"control", "ssh", "bin"):
5662
(self.root / name).mkdir()
5763

5864
def checkpoint(self, message):
@@ -159,7 +165,7 @@ def start(self):
159165
(self.root / "ssh/known_hosts").write_text(f"[127.0.0.1]:{ssh_port} {host_key}\n")
160166
cloud_env = dict(self.env, **model_env, HOME=str(self.root / "cloud-home"),
161167
JCODE_HOME=str(self.root / "cloud-home"),
162-
JCODE_RUNTIME_DIR=str(self.root / "cloud-run"),
168+
JCODE_RUNTIME_DIR=str(Path(self.runtime.name) / "cloud"),
163169
JCODE_CLOUD_HOST_LABEL="cloud-acceptance")
164170
# Same absolute workspace path on separate disks. This is a real SSH
165171
# command, not the JCODE_CLOUD_TRANSPORT override used by CLI tests.
@@ -214,7 +220,7 @@ def start(self):
214220
self.local_env = dict(self.env, **model_env, HOME=str(self.root / "local-home"),
215221
PATH=f"{self.root}/bin:/usr/bin:/bin",
216222
JCODE_HOME=str(self.root / "local-home"),
217-
JCODE_RUNTIME_DIR=str(self.root / "local-run"),
223+
JCODE_RUNTIME_DIR=str(Path(self.runtime.name) / "local"),
218224
JCODE_CLOUD_HOST="cloud-acceptance", JCODE_CLOUD_HOST_LABEL="laptop-acceptance",
219225
JCODE_CLOUD_REMOTE_BINARY=str(remote_binary),
220226
JCODE_DEBUG_CMD_PATH=str(self.control / "debug.cmd"),
@@ -230,7 +236,12 @@ def probe():
230236
command += '; result=$?; printf "\\nJCODE_ACCEPTANCE_EXIT=%s\\n" "$result"; sleep 600'
231237
self.tmux("-f", "/dev/null", "new-session", "-d", "-s", "acceptance", "-x", "160", "-y", "48",
232238
shlex.join(["/bin/bash", "-c", command]))
233-
wait_for(lambda: "Welcome to jcode" in self.frame() or "Ready to use" in self.frame(), "TUI startup")
239+
def ready():
240+
frame = self.frame()
241+
if "JCODE_ACCEPTANCE_EXIT=" in frame:
242+
raise AssertionError("TUI exited during startup; see frame.txt")
243+
return "Welcome to jcode" in frame or "Ready to use" in frame
244+
wait_for(ready, "TUI startup")
234245
if "Welcome to jcode" in self.frame():
235246
self.tmux("send-keys", "-t", "acceptance", "Right", "Enter")
236247
self.wait_text("Ready to use")
@@ -323,7 +334,7 @@ def close(self):
323334
for side in ("local", "cloud"):
324335
env = dict(self.env, HOME=str(self.root / f"{side}-home"),
325336
JCODE_HOME=str(self.root / f"{side}-home"),
326-
JCODE_RUNTIME_DIR=str(self.root / f"{side}-run"))
337+
JCODE_RUNTIME_DIR=str(Path(self.runtime.name) / side))
327338
try:
328339
subprocess.run([self.binary, "--no-update", "server", "stop"], env=env,
329340
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=10)
@@ -367,6 +378,7 @@ def owned():
367378
raise AssertionError(f"Fixture processes survived cleanup: {remaining}")
368379
for handle in self.files:
369380
handle.close()
381+
self.runtime.cleanup()
370382

371383

372384
def idle_round_trip(t):

‎tests/test_cloud_acceptance_harness.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
from pathlib import Path
6+
import socket
67
import subprocess
78
import sys
89
import tempfile
@@ -119,6 +120,14 @@ def test_later_user_prompt_does_not_retrigger_historical_gate(self):
119120

120121

121122
class Isolation(unittest.TestCase):
123+
def test_long_artifact_paths_do_not_lengthen_runtime_sockets(self):
124+
with tempfile.TemporaryDirectory() as temp:
125+
fixture = acceptance.CloudTUI("/bin/true", Path(temp) / ("long-artifacts-" * 12))
126+
self.addCleanup(fixture.close)
127+
self.assertLess(len(os.fsencode(fixture.sock)), 100)
128+
with socket.socket(socket.AF_UNIX) as sock:
129+
sock.bind(fixture.sock)
130+
122131
def test_cleanup_reaps_only_exact_workspace_marker(self):
123132
with tempfile.TemporaryDirectory() as temp:
124133
fixture = acceptance.CloudTUI("/bin/true", Path(temp) / "fixture")
@@ -137,6 +146,7 @@ def test_cleanup_reaps_only_exact_workspace_marker(self):
137146
def test_only_agent_requests_count_as_continuation_evidence(self):
138147
with tempfile.TemporaryDirectory() as temp:
139148
fixture = acceptance.CloudTUI("/bin/true", Path(temp) / "fixture")
149+
self.addCleanup(fixture.close)
140150
(fixture.root / "model.jsonl").write_text(
141151
json.dumps({"agent": False, "messages": [{"content": "old cloud notice"}]}) + "\n" +
142152
json.dumps({"agent": True, "messages": [{"content": "fresh agent turn"}]}) + "\n" +

0 commit comments

Comments
 (0)