v2 migration: the two pins in check-pins and the CI, the matcher in py_compile and its floor, the docs (opencode.md, agents-and-network.md, README)

- check-pins.sh answers the opencode2 release the same way as 1.x's (same asset shape, same
  digest rule), the CI's asset step checks both pairs and install.sh's own pair gate refuses a
  v2 version without its checksum; oc-permissions.py joins py_compile and the coverage floors
- docs/opencode.md: the opt-in, the marker, the rollback, each 2.x fact with its measurement date
- docs/agents-and-network.md: the guards under the v2 grammar, one matcher and one probe table for
  the installer and the panel, guard_ok null when nothing proves it
- README: --opencode 2 named beside the out-of-the-box line

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-11-20 07:37:14 +01:00
1 parent 3fc3e68627
commit b05a6e6465
6 files changed
+49 -23

No files matched your search

+19 -15
View File
@@ -90,7 +90,7 @@ jobs:
py=$(git ls-files '*.py' ':!flash-sglang/')
[ "$(echo "$py" | wc -l)" -ge 100 ] || { echo "found only: $py"; exit 1; }
ruff check --select F,E9 $py
python3 -m py_compile patch-template.py patch-yarn.py patch-kv.py keepalive-proxy.py engine-inputs.py oc-merge-limits.py oc-point-default.py oc-fit-limits.py bench-agent.py conc-check.py build-token-map.py tools-check.py systemone-check.py bench-systemone.py evals/mmlu.py evals/humaneval.py flash-sglang/qwen4_exp.py flash-sglang/qwen_sparse_attn_backend.py flash-sglang/sm121_varlen.py dashboard/cockpit.py dashboard/lifecycle.py dashboard/recipes.py dashboard/registry.py dashboard/agent_relay.py
python3 -m py_compile patch-template.py patch-yarn.py patch-kv.py keepalive-proxy.py engine-inputs.py oc-merge-limits.py oc-point-default.py oc-fit-limits.py bench-agent.py conc-check.py build-token-map.py tools-check.py systemone-check.py bench-systemone.py evals/mmlu.py evals/humaneval.py flash-sglang/qwen4_exp.py flash-sglang/qwen_sparse_attn_backend.py flash-sglang/sm121_varlen.py dashboard/cockpit.py dashboard/lifecycle.py dashboard/recipes.py dashboard/registry.py dashboard/agent_relay.py oc-permissions.py
- name: Pin contracts (every consumer's own block runs against install.sh)
run: |
@@ -1341,20 +1341,24 @@ jobs:
pip install 'jinja2==3.1.6'
"$(./tests/testpy.sh jinja2)" tests/lane-templates-check.py
- name: The pinned opencode release is the one its sha256 names
# install.sh installs this exact asset on every box that has no opencode or an
# older one, and refuses a download that does not match. A pin bumped without
# its checksum, or a release asset replaced upstream, fails here instead of on a
# user's box. The asset itself is checked, not the API's word for it.
- name: The pinned opencode releases are the ones their sha256 name
# install.sh installs these exact assets, and refuses a download that does not match:
# 1.x is the pin of every box, the --opencode 2 choice (opt-in, decision 1386) is pinned
# the same way on the same repo. A pin bumped without its checksum, or a release asset
# replaced upstream, fails here instead of on a user's box. The asset itself is checked,
# not the API's word for it.
run: |
v=$(grep -oE '^OPENCODE_VERSION="\$\{OPENCODE_VERSION:-[0-9.]+\}"' install.sh | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
sha=$(grep -oE '^OPENCODE_SHA256="\$\{OPENCODE_SHA256:-[0-9a-f]{64}\}"' install.sh | grep -oE '[0-9a-f]{64}')
test -n "$v" && test -n "$sha" || { echo "install.sh no longer declares OPENCODE_VERSION and OPENCODE_SHA256 the way this step reads them"; exit 1; }
d=$(mktemp -d)
curl -fsSL --retry 3 -o "$d/oc.tar.gz" "https://github.com/anomalyco/opencode/releases/download/v$v/opencode-linux-arm64.tar.gz"
echo "$sha $d/oc.tar.gz" | sha256sum -c --quiet -
tar -tzf "$d/oc.tar.gz" | grep -qx opencode || { echo "the asset no longer holds an opencode binary at its top"; exit 1; }
echo "opencode $v: the release asset matches its pinned sha256"
for pair in "OPENCODE_VERSION OPENCODE_SHA256" "OPENCODE2_VERSION OPENCODE2_SHA256"; do
set -- $pair
v=$(grep -oE "^$1=\"\\$\\{$1:-[0-9.]+\\}\"" install.sh | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
sha=$(grep -oE "^$2=\"\\$\\{$2:-[0-9a-f]{64}\\}\"" install.sh | grep -oE '[0-9a-f]{64}')
test -n "$v" && test -n "$sha" || { echo "install.sh no longer declares $1 and $2 the way this step reads them"; exit 1; }
d=$(mktemp -d)
curl -fsSL --retry 3 -o "$d/oc.tar.gz" "https://github.com/anomalyco/opencode/releases/download/v$v/opencode-linux-arm64.tar.gz"
echo "$sha $d/oc.tar.gz" | sha256sum -c --quiet -
tar -tzf "$d/oc.tar.gz" | grep -qx opencode || { echo "the asset of $1 no longer holds an opencode binary at its top"; exit 1; }
echo "opencode $v ($1): the release asset matches its pinned sha256"
done
- name: House typography (no em/en dashes in tracked files)
run: |
@@ -1634,7 +1638,7 @@ jobs:
# never run there. The gate caught exactly that on the first push. Note
# that lifecycle.py and recipes.py read 100% in both, which is what
# being pure logic buys.
FLOORS = {"cockpit.py": 68, "agent_relay.py": 88, "registry.py": 88,
FLOORS = {"cockpit.py": 68, "agent_relay.py": 88, "oc-permissions.py": 88, "registry.py": 88,
"lifecycle.py": 100, "recipes.py": 100}
TOTAL_FLOOR = 89
got, bad = {}, []
+1 -1
View File
@@ -113,7 +113,7 @@ The 27B path is the fastest configuration measured so far on GB10 (**SGLang + NV
The flash path serves a model that does not otherwise fit: the 176B checkpoint's 47.7 GiB FP8 N-gram table is **served from a sparse file on NVMe**, read row by row by the gather kernel through GB10's host page tables, leaving the unified pool to the compute weights and a real KV cache. Until v1.7 that was a vendored patch of this repo's own; since v1.8 it is upstream (`--ple-offload-backend file`, [sglang#37068](https://github.com/sgl-project/sglang/pull/37068)) and the overlay is retired, along with the vendored sm_121 QSA kernel and the workaround for the GB10 MTP collapse. **Prefix caching works** (27k tokens re-served in 2.5 s against 12.0 s cold), decode is **47.9 tok/s on code and 47.1 on math** single stream at the `context` tier (29-31 on prose), prefill ~2,250 tok/s cold, and image input stays available. Since v1.8 it also takes **`--speculative-token-map`**, which hands the speculative draft the target's `lm_head` sliced to 65,536 rows instead of all 248,320: that removes 2.6 GiB from every engine step on a lane that is memory-bandwidth bound, and it is worth 14 to 25% of decode without changing what the model can say, because the target still verifies every drafted token over the whole vocabulary.
Whatever the target, you get the same surface: an **OpenAI-compatible API** and the Anthropic protocol on port 30001 for every text lane, through a keepalive proxy built for agent CLIs (the engine itself answers on `127.0.0.1:30000`, on the box only), and **[opencode](https://opencode.ai) works out of the box** (the installer writes a ready-to-use provider config; the chat template ships pre-patched for agentic clients). The stack is built to grow: more targets, engines and drafters will slot into the same switch surface.
Whatever the target, you get the same surface: an **OpenAI-compatible API** and the Anthropic protocol on port 30001 for every text lane, through a keepalive proxy built for agent CLIs (the engine itself answers on `127.0.0.1:30000`, on the box only), and **[opencode](https://opencode.ai) works out of the box** (the installer writes a ready-to-use provider config; the chat template ships pre-patched for agentic clients; `./install.sh --opencode 2` opts the box into OpenCode 2, [docs/opencode.md](docs/opencode.md)). The stack is built to grow: more targets, engines and drafters will slot into the same switch surface.
## Where everything is
+3 -1
View File
@@ -44,7 +44,7 @@ eval "$pins"
# The pins that do not live in the pin block: opencode's release and its digest, and the
# image lane's checkpoint, source commit and wheel. None of them was checked, so a release
# or a commit removed upstream went unseen (found in review, 2026-09-24).
more="$(grep -E '^(OPENCODE_VERSION|OPENCODE_SHA256)=' "$REPO_DIR/install.sh")"
more="$(grep -E '^(OPENCODE_VERSION|OPENCODE_SHA256|OPENCODE2_VERSION|OPENCODE2_SHA256)=' "$REPO_DIR/install.sh")"
eval "$more"
lane="$(grep -E '^(IMAGE_MODEL_PIN|IMAGE_MODEL_PIN_REV|IMAGE_TURBO_PIN|IMAGE_TURBO_PIN_REV|PIN|WHEEL)=' "$REPO_DIR/install-image.sh")"
eval "$lane"
@@ -449,6 +449,8 @@ check_wheel sglang-wheel-image-h3 sglang "$IMAGE_H3_WHEEL"
check_wheel image-h3-fa4 flash-attn-4 "$FA4_VERSION"
check_asset image-h3-cubin flashinfer-ai/flashinfer "$FLASHINFER_TAG" "$FLASHINFER_CUBIN_FILE" "$FLASHINFER_CUBIN_SHA256"
check_asset image-h3-jit flashinfer-ai/flashinfer "$FLASHINFER_TAG" "$FLASHINFER_JIT_FILE" "$FLASHINFER_JIT_SHA256"
# the --opencode 2 choice (opt-in, decision 1386): the same repo, the v2 tag, checked the same way
check_asset opencode2 anomalyco/opencode "v$OPENCODE2_VERSION" opencode-linux-arm64.tar.gz "$OPENCODE2_SHA256"
echo "Kolibri-1 lane"
check_model kolibri-fp8 "$KOLIBRI_FP8_REPO" "$KOLIBRI_FP8_REV"
check_model kolibri-nvfp4 "$KOLIBRI_NVFP4_REPO" "$KOLIBRI_NVFP4_REV"
+2
View File
@@ -39,6 +39,8 @@ opencode reads its permission rules in order and the last one that matches wins,
Checked on the box on 2026-10-28 with opencode 1.19.4 and the FP4-Local lane: a shell command naming an aliyuncs.com host was refused under `--yolo` and under the new `AGENT_AUTO` value, and ran under the old one (`{"*":"allow"}` alone). On 2026-10-30 opencode 1.19.4 and 1.19.5 refused it the
same way under both, against an endpoint that asked for that very command, where a command naming no such host ran.
Under `./install.sh --opencode 2` (opt-in, docs/opencode.md) the same three rules ride the v2 grammar, an ordered array `"permissions"` of `{action, resource, effect}` objects whose last match wins, and with `AGENT_AUTO=1` they come last inside `OPENCODE_CONFIG_CONTENT`, the document the server merges after every file (measured on 2.3.0 the 2026-11-14: the wildcard allow of the content approves what its last rules do not deny, and a deny of ours holds over an earlier allow). Two readers check they still deny, with one matcher and one table of probes (`oc-permissions.py` and `deny_probes()`): the installer verifies the file it wrote, and the Agent panel answers `guard_ok` from the documents the running server serves on `/api/config`, not from the file on disk. The matcher is the server's own, read in 2.3.0's bundle and measured on the binary the 2026-11-15: `*` any run, `?` exactly one character, brackets and the dot literal, whole-text match, and a needle inside a command's comment is not command text (`touch x # aliyuncs.com` is no request to that host). A guard the panel cannot read (no pattern to probe, an unreadable answer) says nothing rather than saying well: `guard_ok` stays null and the line does not claim the guard holds.
What they stop: the case Cohere observed, a shell command whose text names an aliyuncs.com host or a cloud metadata address. The first pattern is Alibaba Cloud's whole domain, its OSS buckets as well as DashScope and its container registry, and a command naming any of them is refused and raises the banner below. What they do not stop: a host written in capitals, since opencode's patterns tell case apart (the proxy below does not), a model that writes the address another way (a variable, an encoding, a script it writes first), and opencode's `webfetch`, which they leave alone. What opencode reads after them can allow what they deny: a project's own `opencode.json` or `.opencode` directory, which opencode loads after the configs above, an agent's own `permission` block, and an "Always" you give to a command (below). In a config of yours the rules stay in place after `uninstall.sh`, as `autoupdate` does, and this repo's own copy is moved aside whole, as before.
## What the cockpit shows
+15
View File
@@ -121,6 +121,21 @@ version without its checksum is refused: it would not be a pin). A download that
not match its sha256 is not installed, and nothing about opencode fails the rest of the
install.
## OpenCode 2, opt-in
OpenCode 2 is not the default of anything: the box stays on the tested 1.19.5 until you ask. `./install.sh --opencode 2` (one-liner: `| bash -s -- --opencode 2`) installs the pinned 2.3.0 (GitHub's release asset, `OPENCODE2_VERSION` with its `OPENCODE2_SHA256`, refused without its checksum like 1.x), remembers the choice in `~/.config/qwen38/opencode.major`, and wires everything to it: the Agent unit, the `oc` launcher, the generated config. `./install.sh --opencode 1` goes back: it takes this repo's `permissions` array out of your global config (OpenCode 1.19 refuses to start while one holds it, measured against 1.19.5 on 2026-11-14; an array that is not the one this repo wrote is left alone and said, with the way back), erases the marker and installs the pinned 1.x again. A stray 2.x found on the PATH (Homebrew Core's formula is one) never opts a box in: the choice wins, and a run that cannot download serves neither major as the other.
What the 2.x server is, measured on 2.3.0 on this box (the binary, its answers and its bundle, 2026-11-14 and 15):
- `serve` takes `--hostname --port --cors --service` and the globals, and no `--yolo`: `oc` launches 2.x with `--auto`, which approves every tool call no rule asks about (a rule of yours still asks, a deny still stops).
- the unit's `ExecStart` says `--print-logs --log-level info`: 2.x refuses the capitals 1.x wants (`Invalid value for flag --log-level: "INFO"`), so the flag's case follows the major.
- the health probe is `GET /api/info`, JSON behind the Basic auth, and it must be read as JSON: `/global/health` answers the app's HTML page with a 200 on 2.x (the 1.x health route), so a probe that takes any 200 certifies a dead server.
- `/api/config`, `/api/provider`, `/api/model` answer the provider options after resolving `{file:...}`: the box's API key came back in clear on each of them, and `/api/credential` carries stored secrets too. The Agent relay reads these answers, scrubs every secret and refuses what it cannot read (compressed, not JSON, oversized), and asks for identity encoding to begin with. A path is classified after normalizing it, because the server's router answers `/api//config` and `/foo/../api/config` as `/api/config`.
- the generated 2.x config adds what the 2.x defaults would otherwise leave open: `policies` denying `provider.use` on the `opencode` provider (without it its free cloud models answer on `/api/model`, and an agent with no provider named goes there), `share: "disabled"`, `websearch: false`, `update: "disable"`, and the `permissions` array (this repo's exfiltration denies, last-match-wins, kept under `--auto`, measured 2026-11-14). Those v2 keys are written only under the v2 choice: 1.19.5 will not start with a `permissions` key in its config.
- the approvals the unit injects ride `OPENCODE_CONFIG_CONTENT`, which the server merges last (it is the document without a path in `/api/config`); the Agent panel reads the served documents, with the server's own matcher (`oc-permissions.py`, read in 2.3.0's bundle: `*` any run, `?` exactly one character, brackets and dot literal, whole-text match), and says in its guard line whether the exfiltration denies still deny.
- 2.x reads neither `OPENCODE_PERMISSION` nor `OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX` (dead names in the unit would lie): the output cap is the model's `limit.output`, which the table writes as 32,000, measured on the build's own requests.
- the first boot migrates 1.x's session store (`GET /api/experimental/migration/v1` follows it); going back to 1.x after a 2.x session is possible but the newer sessions are then unreadable by the older server, which is why the choice is yours.
## Opting out
Do not want any of it? `./install.sh --no-opencode` (one-liner: `| bash -s -- --no-opencode`) installs the API only: no generated config, no `oc` launcher, and `switch-model.sh` never touches your opencode default model. The choice is remembered by later runs (marker `~/.config/qwen38/opencode.off`); `./install.sh --with-opencode` turns it back on. Your own `~/.config/opencode/opencode.json` is never rewritten in either mode: when the integration is on, the installer only merges into it the served lane's limits, its compaction block, the provider of a lane installed since, the default model when it is unset or already one of this box's (a default you pointed at another provider is yours, and stays) and, with the version pinned, `"autoupdate": false`, plus the shell deny rules (a deny holds under `--yolo`) and a `lean` variant for the 27B and flash models, each by a targeted edit that keeps your comments (in every form opencode accepts: `//`, `/* */`, trailing commas), your other providers and your line endings, with a dated backup first (the ten newest of each file are kept) and in one step, so a full disk leaves the file as it was.
+9 -6
View File
@@ -22,6 +22,7 @@ import unittest
REPO = pathlib.Path(__file__).resolve().parents[1]
SCRIPT = REPO / "check-pins.sh"
OC_SHA = re.search(r'^OPENCODE_SHA256="\$\{OPENCODE_SHA256:-([0-9a-f]{64})\}"', (REPO / "install.sh").read_text(), re.M).group(1)
OC2_SHA = re.search(r'^OPENCODE2_SHA256="\$\{OPENCODE2_SHA256:-([0-9a-f]{64})\}"', (REPO / "install.sh").read_text(), re.M).group(1)
SPEECH = (REPO / "install-speech.sh").read_text()
@@ -112,8 +113,10 @@ elif body is None and url.startswith("https://pypi.nvidia.com/"):
body = "".join('<a href="%s#sha256=%s">%s</a><br/>\n' % (f, "0" * 64, f) for f in up.get("nvidia", {}).get(url.split("/")[3], []))
elif body is None and "/releases/tags/" in url:
repo = url.split("/repos/", 1)[1].split("/releases/", 1)[0]
tag = url.split("/releases/tags/")[-1]
sha = os.environ.get("FAKE_OC_SHA2", "") if tag.startswith("v2") else os.environ.get("FAKE_OC_SHA", "")
body = json.dumps({"assets": up.get("assets", {}).get(repo) or [{"name": "opencode-linux-arm64.tar.gz",
"digest": "sha256:" + os.environ.get("FAKE_OC_SHA", "")}]})
"digest": "sha256:" + sha}]})
elif body is None and url.startswith("https://huggingface.co/") and url.rsplit("/", 1)[-1] in up.get("lfs", {}):
body = "version https://git-lfs.github.com/spec/v1\noid sha256:%s\nsize 804749248\n" % up["lfs"][url.rsplit("/", 1)[-1]]
elif body is None and "/manifests/" in url:
@@ -150,7 +153,7 @@ class PinsBase(unittest.TestCase):
# a cloud review, 2026-10-18, in a container that exports it)
env = {k: v for k, v in os.environ.items() if k not in ("HF_TOKEN", "GITHUB_TOKEN")}
env.update(PATH=f"{self.bin}:{env['PATH']}", FAKE_PINS=json.dumps(scenario or {}),
FAKE_LOG=str(self.log), FAKE_OC_SHA=OC_SHA)
FAKE_LOG=str(self.log), FAKE_OC_SHA=OC_SHA, FAKE_OC_SHA2=OC2_SHA)
if token is not None:
env["HF_TOKEN"] = token
r = subprocess.run(["bash", str(SCRIPT), *args], env=env, capture_output=True, text=True,
@@ -202,12 +205,12 @@ class TheCheckPins(PinsBase):
address is shared, and both tries of 2026-10-02 got 403 with the limit spent."""
env_tok = "ghs_secretvalue456"
env = {k: v for k, v in os.environ.items() if k not in ("HF_TOKEN", "GITHUB_TOKEN")}
env.update(PATH=f"{self.bin}:{env['PATH']}", FAKE_PINS="{}", FAKE_LOG=str(self.log), FAKE_OC_SHA=OC_SHA,
env.update(PATH=f"{self.bin}:{env['PATH']}", FAKE_PINS="{}", FAKE_LOG=str(self.log), FAKE_OC_SHA=OC_SHA, FAKE_OC_SHA2=OC2_SHA,
GITHUB_TOKEN=env_tok)
r = subprocess.run(["bash", str(SCRIPT)], env=env, capture_output=True, text=True, timeout=60)
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
gh = [c for c in self.calls() if c["url"].startswith("https://api.github.com/")]
self.assertEqual(len(gh), 9, gh) # the three source commits, the opencode release, llama.cpp's commit, Kokoro's release and FlashInfer's, once per file
self.assertEqual(len(gh), 10, gh) # the three source commits, the two opencode releases (1.x and the --opencode 2 pin), llama.cpp's commit, Kokoro's release and FlashInfer's, once per file
for c in gh:
self.assertIn(f"Authorization: Bearer {env_tok}", c["stdin"], c)
self.assertFalse(any(env_tok in a for a in c["argv"]), c["argv"])
@@ -300,7 +303,7 @@ class ThePinsOutsideThePinBlock(PinsBase):
def test_they_are_all_checked(self):
rc, out = self.run_pins()
self.assertEqual(rc, 0, out)
for label in ("qwen-image", "qwen-image-turbo", "sglang-source", "sglang-wheel", "opencode"):
for label in ("qwen-image", "qwen-image-turbo", "sglang-source", "sglang-wheel", "opencode", "opencode2"):
self.assertIn("ok", self.line(out, label), out)
self.assertTrue(any("Qwen/Qwen-Image-2.1/raw/790c9263" in c["url"] and c["url"].endswith("/model_index.json")
for c in self.calls()), "the image checkpoint is asked for at its pinned revision")
@@ -580,7 +583,7 @@ class TheEndpointsThatDoNotAnswer(PinsBase):
for label in self.GITHUB:
self.assertIn("HTTP 504 from the GitHub API, so not checked", self.line(out, label), out)
self.assertNotIn("no such", self.line(out, label), out)
self.assertIn("9 of 68 pins could not be asked about", out)
self.assertIn("10 of 69 pins could not be asked about", out)
self.assertIn("run it again before re-pinning anything", out)
self.assertNotIn("A removed upstream revision", out)