oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

S5 progress: OpenCode on OpenCode Go

Branch connections-s5-opencode from main f5d1d677 (S1 to S4 merged). Spec: docs/superpowers/specs/2026-11-12-equipo-connectors-and-token-scheduling.md revision 3.2, §11 row S5: §0 decision 7 (Go stays metered), §2.1 to §2.3 (S1's guard; the Go row of the limit table), §3 (isolation, containment, pinning, mapping, families, acceptance), §4.2, §4.4's OpenCode row, and round 3 findings 5, 8 and 9. The controller's 2026-11-12 note: keep S1's single-model pick; S5b generalises models.

No real key, no sign-in, no real provider. The real pinned OpenCode 2.2.7 ran only against a fake OpenCode Go on 127.0.0.1 (TLS as opencode.ai under a test authority), through the real relay, in the real bubblewrap namespace.

Probes

  • OC-P1, passed. OpenCode runs a whole step with only opencode.ai reachable: TestOpenCodeP1OnlyOpenCodeReachable (a Review through Equipo's MCP tool; every request was Go's chat completions with the key; the relay refused no connection during the step; another host is refused). Bun honours HTTPS_PROXY and NODE_EXTRA_CA_CERTS. The OpenAI-compatible provider is bundled in the binary: no npm fetch. With OPENCODE_DISABLE_MODELS_FETCH left out, the catalogue fetch is refused at the relay (mutation R2).
  • OC-P2, a stdio mode exists, so the bridge is not built. opencode acp speaks the Agent Client Protocol (JSON-RPC, one message per line) on stdio: session/new, session/load (replays history first), session/prompt (answered at the turn's end with stopReason and the turn's usage), session/update (text chunks, tool calls), session/request_permission, session/cancel. serve --stdio is not a transport: it prints the loopback URL and serves HTTP. Every OpenCode test drives acp.
  • OC-P3, the allowance does not reach OpenCode's events. Go's opencode.allowance (and billing_source) were in every fake answer and in none of OpenCode's ACP messages (TestOpenCodeP3AllowanceNotInEvents). Headroom is "not reported".
  • OC-P4, the figure is the turn's own. ACP's prompt answer carries the turn's usage summed over its requests, not the session's running total: one request 60/7/40, then a two-request turn 120/14/80 (TestOpenCodeP4UsagePerTurn). (The serve API's session.usage.updated replaces the session's totals, so it is cumulative; it is not used.) inputTokens is the uncached part; outputTokens excludes reasoning, so the tally adds thoughtTokens into output (Go bills reasoning as output).

Found on the way

  • OpenCode makes a hidden title-generation request per session whose usage is not in the turn's. agents.title.disabled: true stops it (disable does not: v2 reads disabled); the summary agent and automatic compaction (compaction.auto: false) are off too; warming is off unless configured. OC-P1 counts the requests (mutation R4).
  • Missing usage is zero, not absent: OpenCode coerces every figure a provider did not give to 0. A turn whose input (uncached, cached and written) is zero is counted as not reported, so the connection pauses. A provider dropping usage on only some requests of a multi-request turn would under-count undetected: stated, not mitigated (§12's "reported usage can be wrong").
  • A rejected permission ends the turn cancelled (usage still reported). No role's rules ever ask.
  • The host's /etc/opencode overrides user configuration: masked with a tmpfs for OpenCode launches.

Done

  1. Wire (3e722df7). Protocol 17, ProtocolOpenCode: provider opencode-go, harness opencode. Below 17 Encode drops that provider's held connections (hello, sync) and usage rows (usage, step, answer, reply) and refuses a connect or connection report about it, checked against the frozen protocol 16 provider and harness sets. S5 first took 16; main's publishing took 16 first, so the merge renumbered S5 to 17. Encode's chain runs OpenCode's step (below 17), then publish's (below 16), then every older step in order. APIKeyProvider gains ModelsPath, BaseURL, CompletionsURL, ModelsURL. OpenCode Go is neither PerToken nor Overflow: always metered, a pay-as-you-go confirmation refused.
  2. Egress: (opencode, opencode-go) to opencode.ai only. Prices: opencode-go-2026-11-12, the Go page's per-model prices (opencode.ai/docs/console/go/, "Token prices", read 2026-11-12) for its chat-completions models; cache writes priced only where Go states a price; DeepSeek at its peak price; free, Responses, Messages and Gemini models unpriced (spend unknown, not offered). Probe client: models at /inference/go/v1/models, completions at /inference/go/openai/v1/chat/completions. Capability matrix: opencode for Engineering and Review, never the coordinator or Research.
  3. Pinning (dba19e50), internal/runner/provider/opencode: the committed npm/package.json and package-lock.json pin @opencode/cli 2.2.7 by its integrity and every platform package by theirs. npm cannot install it as pinned (--ignore-scripts pulls all four linux-x64 variants, about 1 GB, as npm records no libc; --omit=optional gets no binary), so the installer fetches exactly @opencode/cli and this platform's binary package by the lockfile's URLs, checks each against the lockfile's sha512 integrity before unpacking, unpacks regular files and directories only, runs no script, seals, and holds the tree (per-platform digest) and the binary (SHA-256, amd64 589253d3…, arm64 c577783e…) to the committed pins. equipo-runner install-opencode <root> prints EQUIPO_OPENCODE_ROOT; install and verify-installed hold it to its pins. CI's box installs the same at /opt/equipo-opencode (Python, the same digests, held to the code by TestBoxOpenCodeMatchesTheCode); testci fingerprints it.
  4. The policy (opencode-v1, provider/opencode_policy.go): argv /opt/opencode acp; environment XDG_* in the runtime home and OPENCODE_DISABLE_PROJECT_CONFIG, _CLAUDE_CODE, _MODELS_FETCH, _AUTOUPDATE, _FREE_MODELS, _FILEWATCHER; opencode.json rebuilt from provider, model, tools and role and accepted exactly (no other file beside it): updates off, one provider under Equipo's own id (equipo, never the catalogue's opencode-go) with the bundled OpenAI-compatible package, the table's base URL and the key by its variable, one model, title and summary off, compaction off, Equipo's MCP server, and permissions that start with a deny of everything, allow the role's tools and end with explicit denies (subagent, skill, question, webfetch, websearch, execute, external_directory, image generation; and edit, shell for a read-only role). Only the binary is mounted; the tree is hashed when the policy is built, the binary (streamed) at build, attestation and, through the descriptor bubblewrap mounts, at the mount. The key reaches the namespace as OPENCODE_GO_API_KEY through the --args pipe.
  5. The adapter: an ACP client (LF framing, 8 MiB message cap, 16 MiB queue budget, writes that give up with their context), a decoder (text chunks to delta; a tool call to tool_call at its first update that carries its arguments, its end to tool_result; a permission request to ask; the prompt's answer to usage and done with completed/interrupted/failed and the class: -32000 auth, provider.rate-limit and Go's budget limits quota; updates before the turn, such as a load's replay, and other sessions' dropped; unknown kinds counted by name), Pi's tally, and a provider.Launcher that checks the version (2.2.7) and the session's model option. Kept sessions are OpenCode's database, copied without following links. fakeopencode reproduces the recorded protocol (provider/opencode/testdata, from the real binary); a fake Go serves the real-binary tests.
  6. The runner (404c85b3): one metered step path for Pi and OpenCode; the prepared launch is what differs. OpenCode names its own session (taken from Open), resumed by session/load. A metered step whose harness is not installed is refused before admission. OpenCode Go connections are metered bindings, scheduled with OpenCode's capability; Review's family is the model that ran (glm-5.3 is glm).
  7. The instance (677e91a0): the Add page offers OpenCode Go with its required confirmation, Go's limit wording and page, and no pay-as-you-go confirmation; an OpenCode Go connection to a runner below 17 is refused (runner_too_old) and never sent. Names: "OpenCode Go", harness "OpenCode".

Tests

  • internal/wire: TestEncodeBelowProtocol17DropsOpenCode, TestEncodeMixedVersionsOpenCodeAndPublish, TestOpenCodeGoProvider.
  • internal/runner/egress: TestEgressTableKeyedByHarnessAndProvider (OpenCode rows).
  • internal/runner/metered: TestOpenCodeGoPrices.
  • internal/runner/connect: TestAPIClientModelsPath, TestCapableOpenCode.
  • internal/runner/provider: TestOpenCodePolicyIsolatedConfiguration, TestOpenCodePolicyRefusals, TestOpenCodePolicyAttestation, TestOpenCodeLaunchSecretEnv.
  • internal/runner/provider/opencode: TestLockfilePinsOpenCode, TestInstallFromArchives, TestPinnedInstallVerifies, TestDecodeRecordedRuns, TestDecodeOnlyTheTurn, TestDecodeUnknownMessages, TestDecodeUsage, TestDecodeClipsToolArguments, TestFamilyFromModel, TestClientWritesAreCancellable, TestClientQueueIsBounded, TestLauncherInterruptIsBounded, TestKeepSessionRefusesLinks, TestOpenCodeFakeReviewInNamespace; the real pinned OpenCode: TestOpenCodeP1OnlyOpenCodeReachable, TestOpenCodeP3AllowanceNotInEvents, TestOpenCodeP4UsagePerTurn, TestOpenCodeAcceptanceHostileRepository, TestOpenCodeAStepCanReadTheKey, TestOpenCodeDescendantTermination, TestOpenCodeKeptSessionResumes.
  • internal/runner/thin: TestOpenCodeReviewStep, TestOpenCodeReviewWithoutLeaveToSpend, TestOpenCodeBudgetHoldsTheNextStep, TestOpenCodeNoUsagePausesTheConnection, TestOpenCodeKeyRefused, TestOpenCodeAskKeptSession, TestOpenCodeEngineeringRun, TestOpenCodeRedactsTheKey, TestOpenCodeNotInstalled, TestAPIKeyOpenCodeGoConnect, and the finish line TestOpenCodeStepsRealOpenCode; the Pi tests unchanged on the shared path.
  • internal/thintest: TestContractOpenCodeGoConnection.
  • internal/testci: TestBoxOpenCodeMatchesTheCode. cmd/equipo-runner: TestVerifyInstalledHoldsEveryProgramToTheRelease (OpenCode root), TestInstallOpenCodeArguments.
  • internal/headless (-tags browser, CI only): TestBrowserConnectionsOpenCodeGoLimitRequired.

The §3 acceptance for the OpenCode cells: the hostile repository loads nothing (TestOpenCodeAcceptanceHostileRepository: project and .opencode configuration, plugins, agents, commands, skills in .opencode, .claude, .agents and a home-level ~/.claude, AGENTS.md, CLAUDE.md); only the provider host is reachable (OC-P1); Review has no write or shell tool (the hostile test: shell and edit refused without an ask; the offered tools); killing the namespace ends every descendant (TestOpenCodeDescendantTermination); the budget stops the next step (TestOpenCodeBudgetHoldsTheNextStep); a step with no usage pauses the connection (TestOpenCodeNoUsagePausesTheConnection); a resent usage row charges once (TestOpenCodeReviewStep); and, stated as §2.1 says, a step can read the key (TestOpenCodeAStepCanReadTheKey).

Local runs were targeted (-run), with -tags testbuild where the seams are needed and the real-binary tests against a local pinned install (EQUIPO_OPENCODE_ROOT, made by the installer from the registry's tarballs); plus gofmt, go vet, staticcheck on the changed packages, the darwin runner build, gitleaks on the staged changes, rastrillo budget size and the dead-reference scan. The browser test was not run locally (headless lane).

Mutations, each observed failing

W1 to W5 were taken at protocol 16, before the renumbering to 17.

  • wire W1: hello's OpenCode Go connections kept below 16 -> TestEncodeBelowProtocol16DropsOpenCode (hello at 15 names provider "opencode-go")
  • wire W2: a step report's OpenCode Go usage rows kept below 16 -> TestEncodeBelowProtocol16DropsOpenCode (step at 15 names provider "opencode-go")
  • wire W3: an OpenCode Go connect encoded below 16 -> TestEncodeBelowProtocol16DropsOpenCode (connect encoded at 15)
  • wire W4: an OpenCode Go connection report encoded below 16 -> TestEncodeBelowProtocol16DropsOpenCode (connection encoded at 15)
  • wire W5: the protocol 16 step skipped -> TestEncodeBelowProtocol16DropsOpenCode (hello at 15)
  • wire W6: OpenCode Go as an overflow subscription (a pay-as-you-go confirmation makes it a subscription) -> TestOpenCodeGoProvider (not always metered)
  • egress E1: no (opencode, opencode-go) route -> TestEgressTableKeyedByHarnessAndProvider (failed before the row, observed first)
  • prices X1: no OpenCode Go table -> TestOpenCodeGoPrices (failed before the table, observed first)
  • connect A1: the model list read under the completions path -> TestAPIClientModelsPath (failed before ModelsPath, observed first)
  • choose C1: opencode not in the Engineering and Review rows -> TestCapableOpenCode (failed before the matrix row, observed first)
  • policy P1: a read-only role allowed edit or shell -> TestOpenCodePolicyRefusals (review with shell accepted)
  • policy P2: the config not compared with Equipo's rebuilt one -> TestOpenCodePolicyRefusals (a plugin accepted)
  • policy P3: other files beside opencode.json accepted -> TestOpenCodePolicyRefusals (a second config file accepted)
  • policy P4: attestation not reading the config again -> TestOpenCodePolicyAttestation (a changed config attested)
  • policy P5: attestation not hashing the binary again -> TestOpenCodePolicyAttestation (a replaced binary attested)
  • policy P6: the binary's digest not compared at build -> TestOpenCodePolicyRefusals (another binary accepted)
  • policy P7: OPENCODEDISABLEPROJECT_CONFIG left out -> TestOpenCodePolicyIsolatedConfiguration (env)
  • policy P8: the title agent left on -> TestOpenCodePolicyIsolatedConfiguration (agents), TestOpenCodePolicyRefusals (the title agent on accepted)
  • policy P9: no leading deny of everything -> TestOpenCodePolicyIsolatedConfiguration (an unnamed action asks)
  • policy P10: Review's explicit edit and shell denies dropped -> TestOpenCodePolicyIsolatedConfiguration (review's last rules). First version of the test MISSED it by reading effects only (the leading deny still denies); the explicit-rule check was added before the mutation run
  • policy P11: a binary outside the tree accepted -> TestOpenCodePolicyRefusals (a binary outside the tree accepted)
  • policy P13: the selection's model not compared -> TestOpenCodePolicyAttestation (another model attested)
  • policy P12: the session a launch resumes not compared -> TestOpenCodePolicyAttestation (a resumed session attested)
  • install I1: an install held to no tree pin left in place -> TestInstallFromArchives (an install that did not verify was left)
  • decode D1: tool-call updates parsed with content as an object (as first written) -> TestDecodeRecordedRuns (no tool_result: a real update's content is a list). A real bug, found by the recordings
  • containment N1: OpenCode's key variable not in the secret allowlist (as first written) -> TestOpenCodeFakeReviewInNamespace (namespacemountrejected). A real bug
  • containment N2: the binary hashed through the OPATH descriptor directly (as first written) -> TestOpenCodeFakeReviewInNamespace (namespacemount_rejected). A real bug, fixed by reading /proc/self/fd/N
  • real R1: OPENCODEDISABLEPROJECTCONFIG left out -> TestOpenCodeAcceptanceHostileRepository (provideridentity_mismatch: the repository's opencode.json chose its own model)
  • real R2: OPENCODEDISABLEMODELS_FETCH left out -> TestOpenCodeP1OnlyOpenCodeReachable (the relay refused connections during the step). First version of the probe MISSED it (the fetch never reaches the fake Go); the relay's denial count was added, then caught
  • real R3: OPENCODEDISABLECLAUDE_CODE left out -> MISSED, twice: neither the repository's .claude and CLAUDE.md nor a home-level ~/.claude planted in the runtime home is read by 2.2.7 once project configuration is off. Kept as defence in depth; no test can observe it today
  • real R4: the title agent left on -> TestOpenCodeP1OnlyOpenCodeReachable (3 requests: a title request whose usage the turn does not report)
  • real R5: Review allowed shell -> TestOpenCodeAcceptanceHostileRepository (shell in a Review ran)
  • real R6: updates decoded before the turn starts (session/load's replay) -> TestOpenCodeKeptSessionResumes (the replayed history taken as this turn's). First caught by a nil-map panic; the decoder was made robust so the assertion catches it
  • thin T1: the connect client without Go's models path -> TestAPIKeyOpenCodeGoConnect (no model card: the list was looked for under the completions path)
  • thin T2: OpenCode connections not among a person's metered bindings -> TestOpenCodeReviewStep (held, never run)
  • thin T3: the binding's family by Pi's rule -> TestOpenCodeEngineeringRun, TestAPIKeyOpenCodeGoConnect (family ""). First run against TestOpenCodeReviewStep MISSED it: the report's family is the model that ran's, by the harness's own rule
  • thin T4: OpenCode's own session id not taken from Open -> TestOpenCodeReviewStep, TestOpenCodeAskKeptSession (not kept, not askable)
  • thin T5: a resumed launch without its ResumeSessionID -> TestOpenCodeAskKeptSession (providerpolicyrejected at attestation)
  • thin T6: a metered step admitted with its harness absent -> TestOpenCodeNotInstalled (charged, slot claimed). A real bug, found by writing the test: the step was admitted, then failed
  • thin T7: the OpenCode branch of the launch preparation removed -> TestOpenCodeReviewStep (account_unavailable)
  • cmd V1: verify-installed not holding the OpenCode root to its pins -> TestVerifyInstalledHoldsEveryProgramToTheRelease (verified with an empty OpenCode root)
  • box B1: the box's arm64 tree pin not the code's -> TestBoxOpenCodeMatchesTheCode (the box installs another tree)
  • instance I1: an OpenCode Go connect accepted for a protocol 15 runner -> TestContractOpenCodeGoConnection (a protocol 15 runner accepted). The test failed before the instance check, observed first
  • instance I2: OpenCode Go not offered on the Add page -> TestContractOpenCodeGoConnection (the Add page does not offer OpenCode Go)
  • instance I3: no docs link for Go's limits -> TestContractOpenCodeGoConnection (the form lacks Go's page)
  • instance I4: OpenCode Go taking a pay-as-you-go confirmation (Overflow) -> TestContractOpenCodeGoConnection (pay-as-you-go off confirmed: accepted). First runs of I2 to I4 failed for the test's own reason (an Expect's cancelled context dropped the fake runner); the test was reordered and all four rerun
  • client K1: a write that waits for OpenCode however long -> TestClientWritesAreCancellable (hangs to the test timeout at the write)
  • client K2: the client's byte budget off -> TestClientQueueIsBounded (2420 bytes queued against 300)
  • interrupt K3: TestLauncherInterruptIsBounded first failed for the test's own reason (an unbuffered pipe blocked the prompt); the stuck process now reads the prompt, as a real pipe's buffer would

Decisions where the spec was open

  • ACP, no bridge (OC-P2), as §4.2 says when a stdio mode exists. The serve API's per-step events would have let a zero be caught per request; ACP gives the turn's sum. The gap is stated above.
  • Hidden model calls off by configuration, held by the exact-config check: title and summary agents, automatic compaction. A session that overflows its context then fails rather than compacting.
  • Go is always metered with no pay-as-you-go confirmation offered. Note for Paul: Go's page now names an "Extra Usage" switch ("you can turn it off or on again on the Go page", said for Go Teams; not said for Go or Go Plus). If his plan has it, a later change could offer the overflow-off confirmation (§0 decision 7); not built.
  • The install runs no npm and no Node: the lockfile is committed and its integrities are what the installer checks; the tree is the two packages, sealed.
  • Only the binary is mounted (/opt/opencode); the tree is held to its digest when the policy is built.
  • The x64 build needs AVX2; the baseline and musl builds are not pinned.
  • Equipo's provider id is equipo, so OpenCode's own catalogue entry for Go can never merge in; models are named equipo/<id>.
  • Prices: list prices from the Go page; within its plan Go reports cost: 0, so the larger-of rule charges the list price. DeepSeek at peak. The free models, and models Go serves only on Responses, Messages or Gemini's API, are unpriced and not offered.
  • Review's file tools are confined to /workspace by denying external_directory (Engineering too; its shell is the namespace's).
  • A refused permission ends OpenCode's turn: no role's rules ask, so a step never meets one.
  • Families from the model's name: glm, kimi, deepseek, qwen, minimax, mimo, longcat, step, and hy3/hy4 as hunyuan.
  • The key variable is OPENCODE_GO_API_KEY.
  • Protocol 17 for the new provider; usage rows of it are dropped, not refused, below 17 (spend stays on the runner's ledger).

Copy: delegated review (Astra, 2026-11-12)

The four strings went through Astra as the copy-review gate (Paul's delegation of 2026-10-25): two kept, two changed, applied verbatim, each now COPY ACCEPTED BY DELEGATION (Astra, 2026-11-12) in copy.go and in the Plan 3 inventory. No test quotes them.

  • chat.connections.opencode-go: OpenCode Go
  • chat.connections.opencode-go_desc: Open-weight models on your Go plan, billed per token.
  • chat.connections.metered.limit_how.opencode-go: At OpenCode Go, your plan sets limits for each model. With Extra Usage on, further use draws on your Console balance. Keep that balance at what you are willing to spend.
  • chat.connections.metered.limit_docs.opencode-go: How OpenCode Go limits work

Staging witness (Paul)

  1. On the staging runner: equipo-runner install-opencode /home/<runner>/.local/share/equipo-runner/opencode, add the printed EQUIPO_OPENCODE_ROOT to the service environment, equipo-runner verify-installed, restart the unit.
  2. Paul adds OpenCode Go in Settings, Connections, Add a connection: ticks "This key has a spending limit at OpenCode Go" (Extra Usage off, or a small Console balance), keeps $1 and $10, pastes a key from opencode.ai/console, picks glm-5.3; the one-token probe makes it Ready and shows on its spend line.
  3. A small task on a test repository, marked urgent (or Run now on a held step), with Claude and Codex limited or absent for Engineering: the Engineering step runs on Go. Witness: its usage row with cost_micros and the spend line moved by it; the runner log shows no egress denial and no opencode unknown events line (or names them).
  4. A Review on a Go model: with Engineering on Claude, Review goes to another family and runs on Go; family glm, label other_family.
  5. Ask the Review a question: it answers from its session, on Go, charged. Check again on the connection, then sign out.

Open

  • The staging witness above (Paul's key, a release).
  • The browser test runs in CI only.
  • No full headless scenario runs an OpenCode step; the finish line runs real steps in thin with real containment.
  • Mac runners: OpenCode stays parked, as Pi.

Security round (Astra, read-only, on 5aac73ca)

Verdict NOT READY: eight mechanical findings, fixed here, each with a test written first and a mutation observed; one design finding (#3) left to the controller with facts, behaviour unchanged.

  1. Session copying followed parent links (opencode/home.go): the kept database is read beneath the runtime home's own descriptor (openat2 RESOLVE_BENEATH, no link in any component; macOS O_NOFOLLOW_ANY), and restoring reads the keep directory the same way. TestKeepSessionRefusesLinkedDirectories.
  2. The binary lost S2's filesystem checks after the policy (opencode_policy.go, containment/mounts.go): at the policy, the attestation and the mount (through the descriptor bubblewrap mounts) the binary is held to its seal as well as its bytes: a regular file root or this user owns, one name, not writable, every ancestor safe. TestOpenCodeBinaryStaysSealed, TestNamespaceOpenCodeBinaryAfterAttestation (rewritten, made writable, a second name, replaced with other sealed bytes).
  3. The reported cost was discarded (opencode/decode.go): the decoder keeps the session's cumulative cost from usage_update, between turns too; a turn's reported cost is what it added from its baseline, so the larger-of rule charges it. session/load reports no cost (probed on the real binary), so keeping a session records its cost so far beside the database and a resumed launch starts from it; with none recorded the whole session cost counts as the turn's, never less. A cost that is not a finite, non-negative USD amount, or goes down, makes the turn's usage uncountable. TestDecodeReportedCost, TestOpenCodeReportedCostCharged (a step charged $0.50 reported over the table's few micro-dollars; a question on its kept session charged the $0.20 it added).
  4. Unbounded goroutines and retained bytes (opencode/acp.go, launcher.go, decode.go): one writer goroutine and a queue of 32; Send gives up with its context or the shutdown; unsupported requests are refused through TrySend, or dropped and counted when the queue is full; pending permission requests capped at 64; tool ids at 256 bytes; kept calls at 1024 and their arguments at 4 MiB in total. TestClientWritesAreBounded, TestLauncherRequestsAreBounded, TestDecodeBoundsRetainedCalls.
  5. Startup ignored cancellation (thin/pistep.go): both launchers gain OpenWithin(lifetime, startup); the step passes its own context with one deadline shared by the start and the run, so a start that never answers ends as cancelled or step_timeout, the attempt's kill and proof unchanged. TestOpenCodeStartupCancellable.
  6. Readers blocked forever after the consumer left (launcher.go, acp.go): Close shuts the session down; its reader stops however full its events are, the client's however full its queue or channel, and the writer closes OpenCode's stdin so a blocked write ends. TestClientShutdownWithFullQueues, TestLauncherCloseFreesTheReader.
  7. Stray traffic on opencode.ai was invisible (fakeopencode/gofake.go): the fake Go records every request before routing; OC-P1 asserts every one is a POST to Go's chat completions. Sharing: 2.2.7's config has share (manual, auto, disabled), pinned to disabled and held by the exact-config check. Telemetry: 2.2.7 has no telemetry setting; its only exporter is OTLP, started only when OTEL_EXPORTER_OTLP_ENDPOINT is set, which no launch can carry (the containment admits the policy's variables only). TestGoRecordsEveryRequest.
  8. Hostile marks went to a host path (opencode/real_test.go): marks go to /home/runner, the writable runtime home; a control proves a mark left in the namespace is seen; each source of configuration has its own subtest. TestOpenCodeAcceptanceHostileRepository.

Mutations observed:

  • S1a: session files opened by path with O_NOFOLLOW on the last component only (as it was) -> TestKeepSessionRefusesLinkedDirectories (.local, share and opencode linked: a host database kept; restored through a linked kept directory). The test failed before the fix, observed first
  • S2a: the binary held to its bytes only (as it was), at attestation -> TestOpenCodeBinaryStaysSealed (made writable, a second name, an ancestor others can write: attested). Observed first
  • S2b: the same, at the mount through the descriptor -> TestNamespaceOpenCodeBinaryAfterAttestation (writable, second name: a binary changed after its attestation was mounted)
  • S4a: the turn's reported cost not taken (as it was) -> TestDecodeReportedCost (first turn: cost 0), TestOpenCodeReportedCostCharged (failed before the fix, observed first)
  • S4b: the turn's cost not measured from its baseline -> TestDecodeReportedCost (first turn: 0.35, the session's whole cost)
  • S4c: a cost that goes down accepted -> TestDecodeReportedCost (down: counted)
  • S4d: a resumed launch without its kept baseline -> TestOpenCodeReportedCostCharged (the question charged 0.70, the session's whole cost)
  • S4e: the session's cost not recorded when kept (read after Close, as first written) -> TestOpenCodeReportedCostCharged (charged 0.70). A real bug in the first fix, found by the test
  • S5a: a goroutine per write (TrySend as an unbounded spawn) -> TestClientWritesAreBounded (goroutines 4 then 9971). The test did not compile before the fix, observed first
  • S5b: pending permission requests unbounded -> TestLauncherRequestsAreBounded (5001 pending asks)
  • S5c: arguments kept without a total -> TestDecodeBoundsRetainedCalls (62928896 bytes in 1024 calls)
  • S5d: tool ids of any length kept -> TestDecodeBoundsRetainedCalls (a long id kept)
  • S7a: the session's event send without the shutdown escape -> TestLauncherCloseFreesTheReader (321 events after Close). First MISSED: the test read events after Close, which unblocks the reader; it now drains only after Close and holds the count to the channel's capacity
  • S7b: the client's message send without the shutdown escape -> TestClientShutdownWithFullQueues (the 1 MiB budget case: the reader never ends). First MISSED twice: the small budget blocks in take before the channel fills, and draining Messages unblocks the reader; a large-budget case nobody reads was added, checked by the goroutine count
  • S7c: the byte-budget wait without the shutdown check -> TestClientShutdownWithFullQueues (timed out)
  • S7d: Shutdown not closing stdin (the writer blocked forever) -> TestClientShutdownWithFullQueues (goroutines 4, before 3). First MISSED: the caller was freed but nothing checked the writer goroutine; the goroutine count was added
  • S6a: the start bounded only by the attempt's lifetime (as it was) -> TestOpenCodeStartupCancellable (cancelled and deadline: each waited the 90 s start bound; the test failed before the fix, observed first; under the mutation it hit the test timeout)
  • S8a: the fake Go recording only the paths it serves (as it was) -> TestGoRecordsEveryRequest (only the models list seen). The test failed before the fix, observed first; OC-P1 now asserts every recorded request is a POST to Go's chat completions
  • S8b: sharing not pinned off -> TestOpenCodePolicyIsolatedConfiguration (config keys), TestOpenCodePolicyRefusals (sharing left out: accepted). Observed first
  • S9a: OPENCODEDISABLEPROJECTCONFIG left out -> TestOpenCodeAcceptanceHostileRepository: project config and .opencode directory (provideridentity_mismatch: the repository chose its own model), context files (AGENTS.md reached the model)
  • S9b: Review allowed edit and shell -> the same test's project config, .opencode directory and context files subtests (edit and shell offered)
  • S9c: the marks looked for outside the namespace's mounts (as the finding describes) -> the same test's control, "a mark is seen" (no mark seen)
  • S9d: OPENCODEDISABLECLAUDE_CODE left out -> still MISSED with each source on its own: 2.2.7 reads neither the repository's nor the home's Claude Code files once project configuration is off. Kept as defence in depth

Finding 3: per-request usage, the facts (no behaviour changed)

Probed on the real 2.2.7 with the fake Go answering one request of a two-request turn without usage (TestOpenCodePartialUsageFacts records it):

  • ACP carries no per-request usage. The prompt's answer has the turn's sum: 60/7/40, Complete, for a turn whose second request had no figure. usage_update gives the context size and the session's cumulative cost only. 2.2.7 never sends ACP's session_message updates (the schema is the SDK's; no code emits them), and opencode/child-session-updates is about subagent sessions.
  • The session database has it. session_message holds one assistant row per request, in seq order after the turn's user row, each with tokens {input, output, reasoning, cache {read, write}} and finish; the request without usage is stored with every token 0 (input 0, cache.read 0), beside its sibling's 60/7/40. The event table is empty (events are not stored). session_v2 keeps only cumulative totals.
  • Options and their cost: - A. Read the database after termination (about a day): copy opencode.db and its journal out of the runtime home beneath its descriptor (finding 1's way), size-capped, into runner scratch; open the copy read-only with modernc.org/sqlite (already in go.mod, pure Go); take the assistant rows after the turn's last user row; any with input, cache read and cache write all 0 makes the turn's spend unknown. One prompt per launch keeps the turn boundary simple. The table and JSON shape are 2.2.7's internals (pinned; a real-binary test would catch drift on a bump). The file is the model's to write in Engineering; that is no new exposure, as a step can already spend the key (§2.1), but parsing a hostile SQLite file wants a time and size bound. - B. The serve API through the bridge (several days): per-step session.step.ended events carry the step's tokens and native provider data; that is §4.2's bridge, not built since OC-P2 found ACP. - C. Count requests at the relay (not viable): the relay sees TLS tunnels, not requests (keep-alive and HTTP/2 multiplex them). - D. Infer the request count from tool calls (heuristic only): parallel tool calls share one request, so the count is not exact.

Controller follow-up (2026-11-12)

1. Protocol 17

Main took protocol 16 for website publishing (ProtocolPublish), so S5 takes 17: ProtocolOpenCode = Protocol17, with ProtocolCurrent moving to it. That renumber landed on main with S5's squash (5880ab10), along with its mixed-version tests: TestEncodeBelowProtocol17DropsOpenCode checks every frame at 16 and 15, TestEncodeMixedVersionsOpenCodeAndPublish, and the contract test's older runners at 16 and 15. This follow-up branch (connections-s5-undercount) carries only items 2 and 3 and adds no wire change. The branch's own renumber was dropped, since main's covers everything it had: its hello test with the sites capability and an OpenCode Go connection is covered by the mixed-version test's hello at 16 and at 15.

2. Finding 3: the gap accepted and stated

The controller's ruling: option 1, accept the stated gap; option A (read the per-request rows from OPENCODE_DB after the attempt) is the slice after S5b, not built here.

  • The spec says it: §2.3's OpenCode bullet, §4.2 ("Usage as built"), §12 ("OpenCode can under-count a turn"), and a line in its history.
  • The Usage page's spend source line gains a line (below) for a connection whose harness has the gap. It comes from data: wire.Harnesses holds each metered harness's facts, PartialUsageUnderCounts true for OpenCode, false for Pi, and the page reads the connection's harness, never its provider. TestUsageSpendUnderCountLine (OpenCode Go shows it once; TensorX does not; a connection on a harness with the gap shows it whatever its provider).
  • Why not Pi on TensorX: Pi reports usage per request (message_end.usage), and the tally (S2's security round, finding 3) makes the whole attempt's figures unknown when any message has no usage, no input or output, or a negative figure. A missing figure there is spend unknown, which pauses the connection; it is never a smaller sum. OpenCode's ACP gives only the turn's sum, in which OpenCode has already turned a missing figure into zeros.

Mutations observed:

  • U1: the line keyed on the provider -> TestUsageSpendUnderCountLine (the line follows the provider, not the harness)
  • U2: Pi given the gap -> TestUsageSpendUnderCountLine (TensorX shows the line)
  • U3: the line dropped from the page -> TestUsageSpendUnderCountLine (the line shows 0 times)

3. Copy: delegated review (Astra, 2026-11-12)

The new string went through Astra as the copy-review gate and was changed; applied verbatim, marked COPY ACCEPTED BY DELEGATION (Astra, 2026-11-12) in copy.go and the Plan 3 inventory; the page test quotes it.

  • usage.spend_undercount: Spend may be higher than shown when usage is not reported for a request.