Skip to content

feat(opencode): bare launch works on OpenCode 2 - #801

Merged
lukemaj merged 3 commits into
mainfrom
opencode-2-bare-launch
Nov 18, 2026
Merged

lukemaj merged 3 commits into
mainfrom
opencode-2-bare-launch

Conversation

@lukemaj

@lukemaj lukemaj commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

What: Bare launch now works on OpenCode 2.x: a bare thread runs on a private OpenCode 2 server with system prompt . and only shell/file tools.
Why: Chromeria refused bare on 2.x ("no demonstrated bare stripping interface"), and the user's machines are moving to OpenCode 2.
So what: Needs independent review and the user's merge decision; nothing is deployed.

Closes #320

Elon record

Requirements and who asked: The user (2026-11-18) needs bare launch on OpenCode 2.x before moving machines to it; the bare contract (stripped prompt, positive tools, truthful receipt) comes from #289.
Deleted: Bare on the shared 2.x server or background service, external serverUrl bare, stripping OpenCode's <env>/date block (no control exists), a tool-listing model call at open (costs a request), agent permissions in the bare config (session rules decide visibility).
Bottleneck: OpenCode 2 has no --pure; skill and opencode_worktree_remove stayed listed under "*": false, so the decisive question was OpenCode 2's tool-visibility rule, read from its embedded source and measured on a scratch 2.3.2 server.
Checked myself: Captured the real outbound model request of a live bare launch on my own dev server (below), the failing-before tests on the base code, vp run check:changed, bash scripts/fork-check.sh --upstream upstream.

How it works

  • driver.ts: bare 2.x opens go to a second v2 adapter backed by a private opencode serve, started lazily at the first bare open (success cached) with the instance's bare home (<state>/bare/<instance>/opencode2/xdg-config). Normal 2.x threads keep the shared server. An external serverUrl refuses bare, as on 1.x.
  • v2/bare.ts (fork-owned):
    • Config: agents.build/plan.system ".", empty instructions, plugins, mcp, policies: skill.use deny, title disabled. Isolation reuses the 1.x recipe (shadow XDG_CONFIG_HOME, OPENCODE_DISABLE_PROJECT_CONFIG, OPENCODE_DISABLE_CLAUDE_CODE, OPENCODE_CONFIG_CONTENT).
    • Session rules: OpenCode 2 lists a tool unless the last rule matching its permission is a * deny, and it appends agent defaults (skill browser deny) after config. So bare session rules start with * deny, then allow read/glob/grep (keeping OpenCode's .env ask defaults), then the normal mode rules filtered to shell, read, edit, glob, grep, external_directory and this thread's T3 MCP pattern when the launch names t3-code.
    • Inspection before the first prompt: agent.get (build/plan system must be .), plugin.list (only built-ins), mcp.list (only T3 Code thread servers), skill.list (empty). Anything else fails the open; results go into the receipt.
  • v2/adapter.ts hooks: bare sessions skip T3 Code's instruction entry and add the T3 MCP server only when named, as on 1.x, and expose getBareReceipt.
  • Retained and disclosed in the receipt: model identity, date, <env> block, OpenCode's worktree session_move hint, and opencode_worktree_remove, which OpenCode gates on the edit permission (it cannot be hidden without hiding edit/write).

Proof

Failing-before tests (driver.test.ts, lowest layer that fails on main): on the base code both new cases fail with BareLaunchError: OpenCode 2.x has no demonstrated bare stripping interface (no server start); on this branch a bare open reaches a server whose env carries the bare config and isolated config dir, normal opens keep the shared server, and an external serverUrl refuses with its own reason. v2/bare.test.ts checks the visible tool set under OpenCode's rule for full-access, supervised and plan modes, named and unnamed T3 MCP, and that inspection rejects a prompt, a package plugin and a foreign MCP server.

Live bare launch (dev server in this worktree, scratch HOME/XDG, OpenCode 2.3.2 installed in a scratch prefix, free local Gemma via oMLX through a logging proxy; zero paid spend). The scratch project's AGENTS.md says "Always answer in French". t3_thread_launch with bare: {} completed with the reply hi. Outbound request to the model:

SYSTEM 1016 chars:
.
# Your Model
- Name: Gemma ...
Today's date: Wed Nov 18 2026
<env> working directory, git repo, platform, temp dir </env>
When you create a worktree ... `tools.opencode.session_move` ...
TOOLS ['edit', 'glob', 'grep', 'opencode_worktree_remove', 'read', 'shell', 'write']

With bare: { additions: [{ type: "mcp", server: "t3-code", tool: "t3_thread_read" }] } the tools add exactly t3-code-<thread>_t3_thread_read. The bare server ran as its own process with XDG_CONFIG_HOME=<state>/bare/opencode/opencode2/xdg-config. Stored receipt evidence: system_text observed_retained (build ".", plan "."), plugins/mcp/skills observed_clean, tools unobserved (session-rule identities). For comparison, normal full-access session rules on the same bare config produced a 9953-char system prompt and 12 tools including skill, subagent, webfetch, execute.

Not via the v2 context API: on 2.3.2, GET /api/session/:id/context returns only session messages (model switch, user, assistant, idle); it does not show the system prompt or tool list, so the prompt and tools above come from the captured outbound request instead. The provider for Gemma was defined in the bare home's xdg-config/opencode/opencode.json as a test fixture, because bare isolation drops user provider config (same as 1.x).

Checks: vp run check:changed all pass (format, lint, knip, typecheck of 42 packages, tests); bash scripts/fork-check.sh --upstream upstream OK; OpenCode 2 adapter, bare adapter and 1.x adapter suites pass (363 tests); focused suites rerun on the rebased head (251 tests).

Upstream first: pingdotgg/t3code has no bare launch (fork feature #289/#335); code search for bareSupport and PR search for OpenCode prompt stripping found nothing to port.

Evals: no fork-owned model-facing text (instructions, MCP tool descriptions or schemas) changed, so no eval cases selected.

browser doc: no user-visible change

Work by Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

lukemaj and others added 2 commits November 18, 2026 11:26
OpenCode 2 refused bare launches because it has no --pure mode and runs one
shared server per instance. A bare 2.x session now runs on a private OpenCode 2
server started for the instance's bare home, with an isolated config dir and a
2.x config that sets system "." for build and plan, empty instructions, plugins
and MCP, denies skills and disables titles. Session rules start with a deny-all
so OpenCode lists only shell, read, write, edit, glob, grep (and the named T3
tools); this also hides skill, which agent defaults kept listed. Before the
first prompt Chromeria reads agent, plugin, MCP and skill inventories over the
v2 API, fails the open on unexpected context, and reports them in the receipt.

Refs #320

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #320

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 18, 2026
Review found the adapter hooks untested: the driver test stops at server
start and the bare.ts tests call helpers directly, so a rebase dropping a
hook in the upstream v2 adapter would pass. A replay test now opens a bare
session, checks the inventory reads, the session rules sent at create, that
no T3 Code instruction entry is written before the prompt, and the receipt.
Inspection reads run in order so the replay is deterministic.

Refs #320

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukemaj

lukemaj commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Independent review, round 1 (head cf053939d6, reviewer: Codex gpt-6.1-sol via Prism, relayed unchanged)

  • Non-blocking: bare adapter hooks lack regression coverage. driver.test.ts:371 deliberately fails at server startup, while bare.test.ts exercises helpers directly. These tests would still pass if the adapter stopped applying bare permissions, suppressing instructions, gating MCP, or exposing the receipt. Extend the existing v2 adapter fixture to assert those outgoing calls and getBareReceipt.

No blocking defects found after tracing routing, server lifetime, permission updates through create/resume/fork, MCP and instruction handling, receipts, and registry/docs changes. Source inspection only.

PASS (no blocking findings).

Author response: fixed in 63aab5501e with a replay test in OpenCode2AdapterV2.test.ts (inventory reads, bare session rules at create, no instruction entry before the prompt, receipt). Mutation check: dropping the instruction skip or the rule filter each fails it. MCP gating is not covered there because the replay harness has no T3 MCP session; it was exercised in the live named-MCP launch.

@lukemaj

lukemaj commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Independent review, round 2 (head 63aab5501e, reviewer: Codex gpt-6.1-sol via Prism, relayed unchanged)

  • Non-blocking: OpenCode2AdapterV2.test.ts:4174 supplies no MCP session, so it cannot catch removal of the bare MCP gate. Extend the replay with named and unnamed MCP cases asserting registration and headers. This remaining coverage gap is acceptable as non-blocking.

Reviewed the whole exact-head diff and round 2 changes. The new oracle independently checks permissions, instruction omission, and receipt contents; fixture defaults preserve existing behavior, registry edits are consistent, and sequential inspection remains fail-closed. Static review only.

PASS (no blocking findings).

Author note: the MCP gate stays covered by the live named-MCP launch in the PR body (only t3-code-<thread>_t3_thread_read listed); left as is.

@lukemaj lukemaj mentioned this pull request Nov 18, 2026
5 tasks
@lukemaj

lukemaj commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Agent cost: agent-observer publish --task toolboxmd/chromeria#801 reported "nothing to publish: no sessions in scope", so no cost comment is attached.

@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 45.8 KiB 45.8 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 45.8 KiB 45.8 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 46.4 KiB 46.4 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 46.4 KiB 46.4 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: e2c5d6d · PR result: 63aab55 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@lukemaj
lukemaj merged commit 5d3c5ba into main Nov 18, 2026
32 checks passed
@lukemaj
lukemaj deleted the opencode-2-bare-launch branch November 18, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bare launch on OpenCode 2.x

1 participant