Login
OCX protocol v1: examples
Login

Whole messages of protocol v1, each with what a node writes back. Each block is what a forum post or ticket change holds, fenced as `json; the text around it is free. A spec reads each one as a node does (spec/ocx/examples_spec.cr), so they stay valid.

An unconfined echo

{"ocx": 1, "kind": "run", "node": "lab-1", "objective": "Say hello.",
 "process": {"user": "builder", "command": ["echo", "hello"], "env": {"PATH": "/usr/bin:/bin"},
             "keep": {"stdout_when": "always"}}}

On a node that runs processes unconfined (section 11, row 7), the node writes started, runs echo hello in /, posts a reply holding hello, then ended, exited, exit 0. Any other node answers ended, refused.

A check of a branch, and its stop

{"ocx": 1, "kind": "run", "node": "lab-1", "objective": "make test passes on dev.",
 "workspace": [
   {"step": "directory", "at": "$$root$$/$$user$$/projects/$$project$$/$$run$$"},
   {"step": "password"},
   {"step": "clone", "into": "$$workspace$$/clone"},
   {"step": "checkout", "of": "dev", "into": "$$workspace$$/tree"}],
 "sandbox": {"uid": 1000, "gid": 1000, "capabilities": [], "network": false, "own_session": true,
             "ends_with_node": true,
             "read_only": ["/usr", "/bin", "/lib", "/lib64"],
             "read_write": ["$$workspace$$"], "homes": [], "files": [],
             "proc": "/proc", "dev": "/dev", "tmp": "/tmp"},
 "limits": {"wall": "20m"},
 "process": {"user": "builder", "command": ["make", "test"], "cwd": "$$tree$$",
             "env": {"PATH": "/usr/bin:/bin", "HOME": "$$workspace$$"},
             "keep": {"stdout_when": "always"}}}

The node writes started, its values naming the check-in dev resolved to, runs make test in the checkout with no network, posts the ends of what it printed, then ended, exited with its code; past 20 minutes, ended, budget. With the network closed, nothing the process writes in its clone reaches the server. To end it early, a user holding admin or setup replies in its thread with:

{"ocx": 1, "kind": "stop", "node": "lab-1", "run": "HASH"}

HASH being, in full, the hash of the post holding the run. The node ends the process, posts its kept logs, and writes ended, stopped.

A session that answers each post

{"ocx": 1, "kind": "run", "node": "lab-1", "objective": "Answer what is said here.",
 "workspace": [
   {"step": "directory", "at": "$$root$$/$$user$$/projects/$$project$$/$$run$$"},
   {"step": "password"},
   {"step": "clone", "into": "$$workspace$$/clone"},
   {"step": "checkout", "of": "trunk", "into": "$$workspace$$/tree"}],
 "sandbox": {"uid": 1000, "gid": 1000, "capabilities": [], "network": true, "own_session": true,
             "ends_with_node": true,
             "read_only": ["/usr", "/bin", "/lib", "/lib64", "/etc/resolv.conf", "/etc/ssl/certs", "$$release$$"],
             "read_write": ["$$workspace$$"],
             "homes": ["/root/.claude", "/root/.claude.json"],
             "files": [{"at": "/etc/passwd", "text": "$$user$$:x:1000:1000::$$workspace$$:/bin/sh\n"}],
             "proc": "/proc", "dev": "/dev", "tmp": "/tmp"},
 "limits": {"wall": "8h"},
 "process": {"user": "claude-1", "command": ["claude", "-p", "Answer the post on your standard input with ocx2 post."],
             "cwd": "$$tree$$", "session": true, "hears": ["*"], "deliveries": "start",
             "env": {"HOME": "$$workspace$$", "USER": "$$user$$", "PATH": "$$release$$:/usr/local/bin:/usr/bin:/bin",
                     "IS_SANDBOX": "1"}}}

The node writes started and starts a process for the run, reading {"run": HASH, "objective": "Answer what is said here."}. Each post then made in its thread by anyone but claude-1 or a node's user starts a process of its own, once the one before has exited, reading that line and then {"post": POST, "from": USER, "text": TEXT}, its input then closed. Each process's kept logs are posted. It ends stopped at a stop, or budget after 8 hours.

A pattern, by convention the wiki page run/NAME, holds such fields once; OCX's create writes them into each run in full.