Repository navigation
Closed
Labels
Milestone
Description
👤 User Story
As a
uf maintainer
I want to
GO/NO-GO evidence that opencode run works inside fullsend-sandbox with Vertex WIF, env sourcing, output stream location, and ndjson metrics
So that
we do not build Increment 1 on an unproven runtime path
🎯 Acceptance Criteria
- [~]
opencode runinsidefullsend-sandboxwith Vertex WIF viaOPENCODE_CONFIG_CONTENT+GOOGLE_APPLICATION_CREDENTIALSreturns council JSON — PARTIAL: proven headless via gcloud user ADC (authorized_user); real WIF (external_account) untestable locally (needs GitHub OIDC) and council JSON not run end-to-end. Residual rolls forward to [Story] Onboard unbound-force/unbound-force into FullSend (per-repo enrollment) #519 (real Vertex WIF via GitHub OIDC) + [Story] Contribute OpenCodeRuntime to FullSend #510/[Story] Run the Divisor council review in FullSend #512 (first real council run). Sandbox egress for the Vertex path is fixed in OpenShell feat: add uf sandbox command for containerized OpenCode sessions #91/fix: add workflow phase boundary guardrails to prevent spec-phase code changes #92. -
.env.d/*.envsourcing is confirmed, or the command builder sources it explicitly — opencode does NOT auto-source; harness must. .env+ loop.env.d/*.envexplicitly -
OutputPathstream file location is known and usable by a host-side validation script — stdout →output.jsonl;io.TeeReaderpattern confirmed - OpenCode ndjson token/cost fields are documented — all 6
step_finishfields map 1:1 toparseOpenCodeStream(fullsend PR #6147) - Written GO/NO-GO for Approach A with any blockers named — posted, with 3 bugs + 2 enhancements + Containerfile/docs items
🚫 Out of Scope
- Implementing
OpenCodeRuntimein FullSend - Shipping a custom image
- Write-capable agents
Phase 0 from Jay's comment. Comparable to a bounded research + config spike with a known execution model (council-review-action).
🏁 Definition of Done — 🛠️ Quality & Testing
- Code has been peer-reviewed for bugs and vulnerabilities.
- [~] Proper testing has been completed and passes (Unit, Integration, E2E via GitHub Actions).(spike verification done; real-WIF-in-CI + end-to-end council JSON roll forward to [Story] Onboard unbound-force/unbound-force into FullSend (per-repo enrollment) #519/[Story] Contribute OpenCodeRuntime to FullSend #510)
- The feature has been demonstrated/validated successfully in the target environment.
🏁 Definition of Done — 📝 Architecture & Docs
- Usage documentation or changelog updated (if user-facing changes introduced).
- Local ADR written and verified by Tech Lead if technical architecture deviated.
- Any newly introduced technical debt has been logged as a GitHub issue.
Context
- Source RFC: https://github.com/orgs/unbound-force/discussions/437
- Execution plan (Jay / @jflowers): https://github.com/orgs/unbound-force/discussions/437#discussioncomment-14559914
- Locked approach: A — OpenCode + uf as the agent runtime; FullSend is infrastructure (sandbox, WIF, dispatch)
- Size: M (comparative T-shirt; same scale as ComplyTime / Agentic-SSDLC / Unbound Force planning)
Implementation Notes (added by @jflowers, Aug 2026)
Spike tasks (7 discrete checks):
- Headless
opencode runin fullsend-sandbox: pullghcr.io/fullsend-ai/fullsend-sandbox:latest, execopencode run --model google-vertex-anthropic/claude-sonnet-4-6 --format json --pure --file review_prompt.txt -- "Review this PR…". Validate ndjson output and non-zero exit on error. Reference:council-review-action/scripts/run-review.sh:94-100. - Vertex WIF credential flow: set
GOOGLE_APPLICATION_CREDENTIALS(WIF file) +OPENCODE_CONFIG_CONTENT(jq-assembled Vertex provider config + permission denials perrun-review.sh:47-79). Confirmopencode runauthenticates to Vertex without additional setup. .env.d/*.envsourcing: confirm whether opencode auto-sources.env.d/files or whether the command builder must. /sandbox/workspace/.envexplicitly (as claude.go does at line 297).- OutputPath stream file: verify ndjson can be tee'd to a known path (e.g.,
output.jsonlin the iteration dir) usable by host-side validation scripts. Confirmio.TeeReaderpattern fromclaude.go:103-112works with opencode's stdout. - ndjson token/cost field fidelity: document the
step_finishenvelope fields (cost,tokens.input,tokens.output,tokens.reasoning,tokens.cache.read,tokens.cache.write). Verify they populateRunMetricscorrectly viaparseOpenCodeStream(already merged, fullsend PR #6147). Partial metrics acceptable for Inc1. - uf binary install method: verify the uf release tarball (linux amd64/arm64) installs cleanly on the fullsend-sandbox base image (Ubuntu/apt per
images/sandbox/Containerfile). uf ships no.deb— install viacurl+sha256sum -c(same pattern as gitleaks/tirith in the base image). Confirmuf doctorpasses. - Built-in
questiontool headless behavior: Runopencode run --format jsonwith a prompt that triggers aquestiontool call. Document actual behavior (error, hang, no-op, or auto-answer). Then place a customquestion.tsin~/.config/opencode/tools/and confirm the custom tool overrides the built-in in headless mode. This validates the Inc2 question-tool override design (#513).
Additional checks to fold in:
- Cosign runner trust policy: ADR 0036 mandates cosign image signing + runner verification, but no runtime admission check is implemented today (ADR 0038 defers). Proactively confirm a per-org image from
ghcr.io/unbound-force/is not rejected by the runner. - Base image OS: confirmed Ubuntu/Debian (apt-based) per
images/sandbox/Containerfile. Not Fedora — do NOT usednf/rpmto install uf.
GO/NO-GO deliverable format: written summary with: (a) each spike task pass/fail, (b) blockers named with issue refs, (c) recommendation proceed/halt for Inc1.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✔️
Activity
yvonnedevlinrh commentedon Aug 19, 2026
SPIKE 1 Steps and results
Running opencode headless inside a fullsend/OpenShell sandbox
Goal: Prove that
opencode run --format json --pureworks inside a fullsendsandbox, using Vertex AI (Google Claude) for inference.
Platform: macOS with Podman Desktop (Apple Silicon)
OpenShell version: 0.0.83
opencode version: 1.18.16
Sandbox OS: Ubuntu 24.04 (Noble)
Prerequisites
podman machine list)~/.config/gcloud/application_default_credentials.jsonitpc-gcp-prodsec-eng-claudeStep 1 — Install OpenShell
Step 2 — Configure and start the OpenShell gateway
2a. Tell OpenShell where Podman is
The gateway looks for the Podman socket at a fixed XDG path. Podman Desktop puts
it in a temp directory instead. Fix it with a symlink:
2b. Configure the gateway environment
2c. Start the gateway
Step 3 — Build fullsend from source
Step 4 — Build the sandbox images
4a. Build the fullsend base sandbox image
cd /tmp/fullsend-src podman build -t fullsend-sandbox:local \ -f images/sandbox/Containerfile images/sandbox/This takes a while on first build.
4b. Build the opencode spike image on top
Create a dedicated build directory (using
/tmp/directly as build contextcauses permission errors — Podman tries to send all of
/tmp/):Step 5 — Create a Vertex AI provider on the gateway
This gives the gateway your GCP credentials so it can inject auth tokens for
sandboxes.
openshell provider create \ --name vertex-spike \ --type google-vertex-ai \ --from-gcloud-adc \ --config project=itpc-gcp-prodsec-eng-claude \ --config region=global # Expected: ✓ Created provider vertex-spikeStep 6 — Create the sandbox
Step 7 — Add the required network policy rules
The default policy does not include rules for the opencode binary (
opencode.exeis a Bun ELF, not the paths listed in the default policy). Add rules for each
required endpoint:
Step 8 — Copy ADC credentials into the sandbox
The gateway's TLS MITM injects auth on
*-aiplatform.googleapis.comrequests,but
google-auth-library(used by opencode) must first resolve credentialslocally before making any API call. It does this by calling
getApplicationDefaultAsync(), which needs a real ADC file inside the sandbox.The gateway does not intercept
oauth2.googleapis.comtoken refresh — soyou must provide real credentials inside the sandbox.
Step 9 — Create the opencode config inside the sandbox
Step 10 — Run opencode headless
Expected output: a JSONL stream ending with something like:
{"type":"text","part":{"text":"SPIKE_PASS"}}Troubleshooting reference
no compute driver configuredopenshell gateway start: unrecognized subcommandbrew services restart openshellpermission denied: open /usr/local/bin/fullsend~/.local/bin/insteadpermission denied: open /private/tmp/ticket-*/tmp/policy_denied: CONNECT api.anthropic.com:443Could not load the default credentialsProviderModelNotFoundError: Model not foundclaude-sonnet-4-6@defaultnotclaude-sonnet-4-20250514invalid_clientfrom oauth2.googleapis.commodels.opencode.aiblocked, fallback to built-inmodels.opencode.aipolicy rule (Step 7)What the gateway does and does not do
The OpenShell gateway is a TLS MITM proxy. When the sandbox makes an HTTPS
request to
*-aiplatform.googleapis.com, the gateway:Authorization: Bearer <token>using thevertex-spikeprovidercredentials
What it does not do:
oauth2.googleapis.comtoken refresh — those go to Google directlylocally before making any API call)
This means: even though the gateway handles auth on the Vertex endpoint, the
google-auth-libraryinside opencode must still resolve credentials locallyfirst. A real ADC file inside the sandbox is required.
Known gaps to document/fix
GOOGLE_VERTEX_LOCATIONnot injected: The sandbox receivesGOOGLE_CLOUD_PROJECTfrom the provider but notGOOGLE_VERTEX_LOCATION.Must be set manually at runtime.
models.opencode.ainot in default policy: opencode silently falls backto a built-in default model when the model registry is unreachable. No error
is emitted. Should be in the default
opencodepolicy rule.Credential injection gap: The gateway's credential injection only works
after the SDK resolves credentials locally. SDKs that use
google-auth-library(like opencode's Vertex provider) fail at local ADC resolution before the
gateway gets a chance to inject. A real ADC file must be present inside the
sandbox. This is a feature gap in fullsend/OpenShell for Vertex AI workloads.
Podman socket symlink is not stable: The socket lives in
/var/folders/(macOS temp) and may change if the Podman machine is recreated. The symlink
must be re-created after machine recreation.
Screenshot showing opencode running headless in Fullsend sandbox
yvonnedevlinrh commentedon Aug 19, 2026
SPIKE 2 Steps and results
Tested
OPENCODE_CONFIG_CONTENTenv var using the exact jq assembly pattern fromrun-review.sh:47-79:Result:
SPIKE_PASSreturned successfully.OPENCODE_CONFIG_CONTENTworks as an env var with permission denials + provider config merged via jq.WIF credential type: Tested with gcloud user ADC (
type: authorized_user), not WIF (type: external_account). WIF is untestable locally — it requires an external identity provider (GitHub OIDC / GKE metadata). Both credential types use the samegoogle-auth-librarycode path viaGOOGLE_APPLICATION_CREDENTIALS.WIF policy note: WIF additionally needs
sts.googleapis.com:443in the network policy (currently onlyoauth2.googleapis.com:443is allowed). The token exchange endpoint differs between credential types:typefieldauthorized_useroauth2.googleapis.comservice_accountoauth2.googleapis.comexternal_accountsts.googleapis.comyvonnedevlinrh commentedon Aug 19, 2026
Test
/sandbox/workspace/.envwithSPIKE_ENV_VAR=hello_from_dotenv/sandbox/workspace/.env.d/custom.envwithSPIKE_ENVD_VAR=hello_from_envdopencode run— vars are not visible to the modelopencode run— vars are visibleResult
opencode does not auto-source
.envor.env.d/files. The mechanism works only if the calling harness explicitly sources them before invokingopencode run:GO/NO-GO
NO-GO as-is. The harness must handle
.env.d/sourcing. This is a known gap — file as an opencode enhancement request for native.env/.env.d/support inopencode run. Until that ships, the entrypoint script in the sandbox image must include explicit sourcing.To file
.env/.env.d/auto-sourcing toopencode run(standard developer tool expectation; Docker Compose, Next.js, Vite all support this natively)yvonnedevlinrh commentedon Aug 19, 2026
Spike 4 tests and results
Shell redirection captures NDJSON cleanly:
openshell sandbox exec -- cat > /tmp/spike-output.jsonlrun-review.sh:100pattern exactly (> review_raw.txt 2>review_err.txt)io.TeeReaderin the Go harness will work identicallyyvonnedevlinrh commentedon Aug 19, 2026
Spike 5 tests and results
Steps
Existing sandbox
opencode-spikewith working Vertex AI configuration.Created
/sandbox/workspace/test-data.txt:Commands Run
Output: 7 JSONL events (2 LLM turns)
typestep_startsessionID,messageIDtool_usetool: "read",state.status: "completed", read spike-prompt.txttool_usetool: "read",state.status: "completed", read test-data.txtstep_finishreason: "tool-calls", tokens + cost (see below)step_starttextstep_finishreason: "stop", tokens + cost (see below)step_finishtoken envelopesStep 1 (tool-calls turn):
{ "type": "step_finish", "part": { "reason": "tool-calls", "cost": 0.032319, "tokens": { "total": 8301, "input": 3, "output": 106, "reasoning": 0, "cache": { "read": 0, "write": 8192 } } } }Step 2 (stop turn):
{ "type": "step_finish", "part": { "reason": "stop", "cost": 0.03186675, "tokens": { "total": 8474, "input": 1, "output": 8, "reasoning": 0, "cache": { "read": 0, "write": 8465 } } } }Field mapping to fullsend parser
Verified against
fullsend/internal/runtime/opencode_progress.go:103-257:part.costocStepFinishPart.CostTotalCostUSDpart.tokens.inputocStepTokens.InputInputTokenspart.tokens.outputocStepTokens.OutputOutputTokenspart.tokens.reasoningocStepTokens.ReasoningReasoningTokenspart.tokens.cache.readocCacheTokens.ReadCacheReadInputTokenspart.tokens.cache.writeocCacheTokens.WriteCacheCreationInputTokenspart.tokens.totalKey observations
step_finisheventtokens.totalis emitted by opencode but correctly ignored byparseOpenCodeStream(not in Go struct)tokens.reasoningis 0 because claude-sonnet-4-6 doesn't use extended thinking by default; would populate with--thinkingflagTokensEventis emitted for eachstep_finish, and values are summed intoResultEventat EOFcache.write→ fullsend's `CacheCreationInputTokensyvonnedevlinrh commentedon Aug 19, 2026
Prerequisites
Policy rules for
curlbinary (added viaopenshell policy update):github.com:443— release pageapi.github.com:443— APIobjects.githubusercontent.com:443— asset CDNrelease-assets.githubusercontent.com:443— redirect target for release downloadsCommands Run
Doctor results
All failures are expected — sandbox workspace is not a UF project checkout.
Containerfile note
The binary in the tarball is named
unbound-force, notuf. The Containerfile should install it as:SHA256 checksum verification should also be added per Constitution Principle V (Security by Default).
yvonnedevlinrh commentedon Aug 19, 2026
Spike 7 steps and results
Summary
Custom tools DO work in
opencode runheadless mode — but with constraints that affect the Inc2 question tool design (#513).Test Matrix
ping.ts{}"pong"ask.ts{}question.ts{}questionpermissionquestion.ts@opencode-ai/pluginCannot find module '@opencode-ai/plugin'question.tszodCannot find package 'zod'question.tsFinding 1: Zero-import custom tools work in headless mode
A
.opencode/tools/ping.tswith no imports andargs: {}loads and executes correctly:Output from
opencode run --format json --pure:{"type":"tool_use","part":{"tool":"ping","state":{"status":"completed","input":{},"output":"pong"}}}Finding 2: Tool named
questionis blocked by built-in permissionIn headless mode, opencode injects default permissions:
[ {"permission": "question", "pattern": "*", "action": "deny"}, {"permission": "plan_enter", "pattern": "*", "action": "deny"}, {"permission": "plan_exit", "pattern": "*", "action": "deny"} ]A custom tool named
question.tsis caught by thequestionpermission deny — it never appears in the tool list. Setting"question": "allow"inOPENCODE_CONFIG_CONTENTdoes not fix this (the permission controls the built-in interactive question flow, not custom tool names, but the name collision prevents registration).Workaround: Name the tool anything other than
question(e.g.,ask,prompt,user_input).Finding 3: npm install through OpenShell gateway fails
opencode runs a background
npm installvia its Bun runtime to resolve@opencode-ai/plugin. This fails through the gateway proxy:Tested mitigations (all failed):
registry.npmjs.org:443to policy for bothopencode.exeandnodebinariesnpm config set cafileto gateway CAnode_modules/viaopenshell sandbox uploadpackage.json+package-lock.json(skips npm install but Bun still can't resolve the pre-installed modules)Root cause: Gateway TLS MITM drops npm/Bun fetch connections (ECONNRESET). Separate from policy — the socket itself is terminated.
Finding 4: Args schema requires Zod or plugin import
The docs show two patterns for typed args:
import { tool } from "@opencode-ai/plugin"withtool.schema.string()import { z } from "zod"withz.string()Both require npm packages. Plain JSON Schema objects (
{ type: "string" }) silently fail to register.Zero-arg tools (
args: {}) work but can't validate input.Implications for #513
The Inc2 custom question tool must either:
args: {}question@opencode-ai/pluginAPI, typed argsnpm install @opencode-ai/pluginat image build timeRecommendation: Approach B — add
npm install @opencode-ai/pluginto the Containerfile and name the toolask(notquestion).Env/Versions
@opencode-ai/plugin1.18.18 (tested via host install + upload)yvonnedevlinrh commentedon Aug 19, 2026
Check: Cosign runner trust policy
Result: NOT ENFORCED — no admission control exists
Objective
Determine whether OpenShell/fullsend enforces cosign image signature verification as an admission control before running sandbox containers.
Commands Run (on macOS host)
Findings
fullsend-opencode-spike:localghcr.io/fullsend-ai/fullsend-sandbox:latestghcr.io/unbound-force/unbound-force:latestgcr.io/projectsigstore/cosign:v2.2.0Assessment
yvonnedevlinrh commentedon Aug 19, 2026
Check: Base image OS confirmation
Result: Ubuntu 24.04.3 LTS (Noble Numbat) — confirmed
Commands Run
Output
Notes
FROM ubuntu:24.04fullsend-opencode-spike:local(unsigned)yvonnedevlinrh commentedon Aug 19, 2026
Spike #509 — GO/NO-GO Summary
Results at a glance
opencode run--format json --pureOPENCODE_CONFIG_CONTENTenv var works.env.d/*.envsourcing.envfiles; harness must do it explicitly.jsonlworks; stderr separateparseOpenCodeStreamunbound-forcenotuf(see below)questionname blocked by built-in permission; must name itaskWhat potentially needs happen to run opencode + uf in fullsend
Bugs to file
questionpermission blocks custom tool registration by name collisionquestionis silently denied by headless mode's{permission: "question", action: "deny"}rule. Tool must be named something else (ask).args: { type: "string" }(plain JSON Schema) don't register. Must use Zod schema. No error, just silently ignored.Enhancements to request
.env/.env.d/auto-sourcing inopencode runnode_modulespackage-lock.jsonpresent, opencode tries to npm install and fails in network-restricted environments.Documentation / Containerfile items
aiplatform.googleapis.com:443,oauth2.googleapis.com:443,models.opencode.ai:443. Addsts.googleapis.com:443for WIF./usr/lib/node_modules/opencode-ai/bin/opencode.exe(actual Bun ELF), not symlink path.google-vertex-anthropic/claude-sonnet-4-6@defaultprovider/model. Setsmall_modelexplicitly or it defaults to Gemini.GOOGLE_VERTEX_LOCATION,GOOGLE_VERTEX_PROJECT,GOOGLE_APPLICATION_CREDENTIALS,HOME=/sandboxunbound-force; Containerfile mustmvtounbound-forceandln -s ... uf. Add SHA256 verification.@opencode-ai/plugin). Bundle deps in image or don't import. Name toolasknotquestion..envsourcing. .envand loop.env.d/*.envbeforeopencode run.Summary
The core path works: opencode runs headless, produces correct JSONL, token/cost fields map 1:1 to the fullsend parser, uf installs and runs. The main friction is around the sandbox environment (npm blocked, credential injection gap, missing env vars) and custom tool registration quirks. Three bugs, two enhancements, and the Containerfile/docs items above cover the full gap.
yvonnedevlinrh commentedon Aug 20, 2026
Reviewed PR fullsend-ai/fullsend#6355
This is the right architecture and a prerequisite for OpenCode support.
The PR:
Five things our spike #509 testing surfaced that matter for the follow-up:
So after this PR merges, we'd still need:
The skeleton OpenCodeRuntime{} type already exists in the codebase (the test file references it), but it's a stub — Bootstrap is a no-op and it's not in the runtime registry.
jflowers commentedon Aug 24, 2026
#509 closeout readiness — ready for @yvonnedevlinrh to close
Verdict: GO — spike delivered its purpose
All 7 spike tasks and both extra checks were executed (Aug 19) with a written GO/NO-GO summary posted. The spike is not OBE — its output (proof the OpenCode runtime path works headless) is the exact foundation #510/#519 build on. It is substantively done.
AC status
opencode runin sandbox w/ Vertex WIFauthorized_user). Real WIF (external_account) untestable locally — needs GitHub OIDC. Actualcouncil-review-actionJSON not run end-to-end..env.d/*.envsourcing confirmed. .env+ loop.env.d/*.envexplicitlyoutput.jsonlredirect;io.TeeReaderpattern confirmedparseOpenCodeStream(fullsend PR #6147)Residual (AC1): real-WIF-in-CI + council JSON end-to-end rolls forward into #519 (per-repo onboarding provisions real Vertex WIF via GitHub OIDC) and #510/#512 (first real council run). Pi already proved the WIF-reuse path on fullsend main — this is not a blocker for closing #509.
Correction: OpenCode plugin hooks DO exist (affects #515, #513)
The Aug 20 PR review comment states
tool.execute.before/after"doesn't exist in opencode." This is incorrect — verified against opencode.ai/docs/plugins (Aug 24):tool.execute.beforeandtool.execute.afterare real Tool Events in the plugin system.env-protection example usingtool.execute.beforeshell.env(relevant to the.env.dsourcing gap from Spike 3)The confusion is plugins vs custom tools — two separate extension mechanisms:
.opencode/plugins/*.ts).opencode/plugins/tool.execute.before,tool.execute.after,shell.env, etc..opencode/tools/*.ts).opencode/tools/This matters for two downstream stories:
tool.execute.before/afterIS the correct interception point for wiringsecurity.HookPlanscripts, mirroring pi'spi_extension/fullsend-hooks.js. The fullsend-hooks adapter should be an OpenCode plugin, not a custom tool..opencode/tools/question.tswas blocked by the built-inquestionpermission deny rule. But a plugin-registered tool with the same name takes precedence over built-ins per the docs: "If a plugin tool uses the same name as a built-in tool, the plugin tool takes precedence." This may dissolve the Spike 7 blocker entirely — the question override should be a plugin tool, not a bare custom tool.DoD checklist — remaining items
Leaving this for @yvonnedevlinrh to close when ready.
yvonnedevlinrh commentedon Aug 27, 2026
Closing — all DoD items satisfied
DoD item 1 (log newly introduced technical debt as tracked issues) is now complete. Final tracking for the 3 bugs + 2 enhancements from the GO/NO-GO summary:
questionpermission blocks same-named custom tool (headless).env/.env.dauto-sourcingnode_modulespresentAC outcome
external_accountWIF needs GitHub OIDC in CI ([Story] Onboard unbound-force/unbound-force into FullSend (per-repo enrollment) #519) and the first real council run ([Story] Contribute OpenCodeRuntime to FullSend #510/[Story] Run the Divisor council review in FullSend #512). Pi already proved the WIF-reuse path on fullsend main, so this is not a blocker. The sandbox egress gap that would have blocked it is fixed in OpenShell feat: add uf sandbox command for containerized OpenCode sessions #91/fix: add workflow phase boundary guardrails to prevent spec-phase code changes #92.Verdict: GO for Increment 1. The headless OpenCode runtime path is proven; residual AC1 work is tracked downstream. Closing as completed.