Skip to content

[Story] Prove OpenCode runs headless in the FullSend sandbox #509

Closed

Description

@beatrizmcouto

👤 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

🚫 Out of Scope

  • Implementing OpenCodeRuntime in 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

🏁 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


Implementation Notes (added by @jflowers, Aug 2026)

Spike tasks (7 discrete checks):

  1. Headless opencode run in fullsend-sandbox: pull ghcr.io/fullsend-ai/fullsend-sandbox:latest, exec opencode 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.
  2. Vertex WIF credential flow: set GOOGLE_APPLICATION_CREDENTIALS (WIF file) + OPENCODE_CONFIG_CONTENT (jq-assembled Vertex provider config + permission denials per run-review.sh:47-79). Confirm opencode run authenticates to Vertex without additional setup.
  3. .env.d/*.env sourcing: confirm whether opencode auto-sources .env.d/ files or whether the command builder must . /sandbox/workspace/.env explicitly (as claude.go does at line 297).
  4. OutputPath stream file: verify ndjson can be tee'd to a known path (e.g., output.jsonl in the iteration dir) usable by host-side validation scripts. Confirm io.TeeReader pattern from claude.go:103-112 works with opencode's stdout.
  5. ndjson token/cost field fidelity: document the step_finish envelope fields (cost, tokens.input, tokens.output, tokens.reasoning, tokens.cache.read, tokens.cache.write). Verify they populate RunMetrics correctly via parseOpenCodeStream (already merged, fullsend PR #6147). Partial metrics acceptable for Inc1.
  6. 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 via curl + sha256sum -c (same pattern as gitleaks/tirith in the base image). Confirm uf doctor passes.
  7. Built-in question tool headless behavior: Run opencode run --format json with a prompt that triggers a question tool call. Document actual behavior (error, hang, no-op, or auto-answer). Then place a custom question.ts in ~/.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 use dnf/rpm to 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.

Activity

  1. added
    enhancement
    llm_assisted
    on Aug 17, 2026
  2. added this to the FullSend BYOA milestone on Aug 18, 2026
  3. moved this to In Progress 📋 in Unbound Force Planningon Aug 18, 2026
  4. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    SPIKE 1 Steps and results

    Running opencode headless inside a fullsend/OpenShell sandbox

    Goal: Prove that opencode run --format json --pure works inside a fullsend
    sandbox, 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 Desktop installed and a default machine running (podman machine list)
    • gcloud CLI installed with ADC credentials at
      ~/.config/gcloud/application_default_credentials.json
    • Go toolchain installed (for building fullsend)
    • GCP project with Vertex AI access: itpc-gcp-prodsec-eng-claude

    Step 1 — Install OpenShell

    export OPENSHELL_VERSION=0.0.83
    curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/v${OPENSHELL_VERSION}/install.sh \
      | OPENSHELL_VERSION=v${OPENSHELL_VERSION} sh
    openshell --version  # should print 0.0.83

    Step 2 — Configure and start the OpenShell gateway

    Important: On macOS with Homebrew, the gateway runs as a launchd service.
    There is no openshell gateway start command — use brew services.

    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:

    # Find the actual socket path
    PODMAN_SOCK=$(podman machine inspect \
      --format '{{.ConnectionInfo.PodmanSocket.Path}}')
    echo "Podman socket: $PODMAN_SOCK"
    
    # Create the symlink where OpenShell expects it
    mkdir -p ~/.local/share/containers/podman/machine
    ln -sf "$PODMAN_SOCK" \
      ~/.local/share/containers/podman/machine/podman.sock

    Note: This symlink persists across shell sessions, but if your Podman
    machine is ever recreated the socket path may change (it lives in /var/folders/).
    Re-run the symlink command if the gateway stops finding Podman after a machine
    restart.

    2b. Configure the gateway environment

    mkdir -p ~/.config/openshell
    cat > ~/.config/openshell/gateway.env << 'EOF'
    OPENSHELL_DRIVERS=podman
    EOF

    OPENSHELL_PODMAN_SOCKET in gateway.env is NOT read by the gateway binary
    (only OPENSHELL_DRIVERS is). Use the symlink approach above instead.

    2c. Start the gateway

    brew services restart openshell
    sleep 5
    openshell gateway list
    # Expected output:
    #   NAME       ENDPOINT                 TYPE   SOURCE  AUTH
    # * openshell  https://127.0.0.1:17670  local  user    mtls

    Diagnosing startup failures: Check
    /opt/homebrew/var/log/openshell/openshell-gateway.out.log for errors. The
    gateway requires mTLS — curl -sk https://127.0.0.1:17670/healthz will always
    report "connection refused" or "SSL error" from curl; use openshell gateway list instead.


    Step 3 — Build fullsend from source

    cd /tmp
    git clone https://github.com/yvonnedevlinrh/fullsend.git fullsend-src
    cd fullsend-src
    
    # /usr/local/bin is SIP-protected on macOS — use ~/.local/bin
    mkdir -p ~/.local/bin
    go build -o ~/.local/bin/fullsend ./cmd/fullsend/
    export PATH="$HOME/.local/bin:$PATH"
    fullsend --version  # should print: fullsend version dev

    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 context
    causes permission errors — Podman tries to send all of /tmp/):

    mkdir -p /tmp/opencode-spike-build
    cat > /tmp/opencode-spike-build/Containerfile << 'EOF'
    FROM fullsend-sandbox:local
    
    USER root
    
    # Install OpenCode (npm is already in the base image)
    # Pin to the same version as your devcontainer
    RUN npm install -g [email protected]
    
    # Verify
    RUN opencode --version
    
    USER 998
    EOF
    
    podman build -t fullsend-opencode-spike:local \
      -f /tmp/opencode-spike-build/Containerfile \
      /tmp/opencode-spike-build/

    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-spike

    Flags: --from-gcloud-adc and --credential are mutually exclusive.
    Project and region are config (not credentials), so use --config, not
    --credential.


    Step 6 — Create the sandbox

    openshell sandbox create \
      --name opencode-spike \
      --keep \
      --no-tty \
      --from fullsend-opencode-spike:local \
      --provider vertex-spike \
      -- true
    
    # Wait for Ready
    openshell sandbox get opencode-spike
    # Look for: Phase: Ready

    Do not use --policy at create time unless you have a complete policy
    that includes all the network rules you need. Passing --policy replaces the
    entire default policy (which has the built-in claude_code and other rules).
    Add custom rules with openshell policy update on the live sandbox instead.


    Step 7 — Add the required network policy rules

    The default policy does not include rules for the opencode binary (opencode.exe
    is a Bun ELF, not the paths listed in the default policy). Add rules for each
    required endpoint:

    # Allow the opencode binary to reach Vertex AI
    openshell policy update opencode-spike \
      --add-endpoint "aiplatform.googleapis.com:443:full:rest:enforce" \
      --binary "/usr/lib/node_modules/opencode-ai/bin/opencode.exe" \
      --rule-name opencode-vertex \
      --wait
    
    # Allow Google OAuth2 token refresh (required by google-auth-library)
    openshell policy update opencode-spike \
      --add-endpoint "oauth2.googleapis.com:443:full:rest:enforce" \
      --binary "/usr/lib/node_modules/opencode-ai/bin/opencode.exe" \
      --rule-name opencode-oauth2 \
      --wait
    
    # Allow the opencode model registry (without this, opencode silently
    # falls back to a built-in default model instead of your configured one)
    openshell policy update opencode-spike \
      --add-endpoint "models.opencode.ai:443:full:rest:enforce" \
      --binary "/usr/lib/node_modules/opencode-ai/bin/opencode.exe" \
      --rule-name opencode-models \
      --wait

    Key fact: The actual opencode binary is
    /usr/lib/node_modules/opencode-ai/bin/opencode.exe (a Bun-compiled ELF).
    /usr/bin/opencode is just a symlink to it. Policy rules must name the real
    binary path, not the symlink.


    Step 8 — Copy ADC credentials into the sandbox

    The gateway's TLS MITM injects auth on *-aiplatform.googleapis.com requests,
    but google-auth-library (used by opencode) must first resolve credentials
    locally 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.com token refresh — so
    you must provide real credentials inside the sandbox.

    # Create the expected directory structure inside the sandbox
    openshell sandbox exec --name opencode-spike --no-tty -- \
      mkdir -p /sandbox/.config/gcloud
    
    # Copy your host ADC into the sandbox
    cat ~/.config/gcloud/application_default_credentials.json | \
      openshell sandbox exec --name opencode-spike --no-tty -- \
      sh -c 'cat > /sandbox/.config/gcloud/application_default_credentials.json'

    Step 9 — Create the opencode config inside the sandbox

    openshell sandbox exec --name opencode-spike --no-tty -- \
      sh -c 'mkdir -p /sandbox/workspace && cat > /sandbox/workspace/opencode.json << '"'"'EOF'"'"'
    {
      "$schema": "https://opencode.ai/config.json",
      "model": "google-vertex-anthropic/claude-sonnet-4-6@default",
      "small_model": "google-vertex-anthropic/claude-sonnet-4-6@default"
    }
    EOF'

    Provider: Use google-vertex-anthropic (not google-vertex). This routes
    to the publishers/anthropic/models/ Vertex endpoint for Claude.

    Model IDs: Use claude-sonnet-4-6@default format, not
    claude-sonnet-4-20250514. The @default suffix is required.

    small_model: Set this explicitly. Without it, opencode defaults to a Gemini
    model which also requires auth — but Gemini has different endpoint requirements.


    Step 10 — Run opencode headless

    openshell sandbox exec --name opencode-spike -- bash -c '
    export GOOGLE_VERTEX_LOCATION=us-east5
    export GOOGLE_VERTEX_PROJECT=itpc-gcp-prodsec-eng-claude
    export GOOGLE_APPLICATION_CREDENTIALS=/sandbox/.config/gcloud/application_default_credentials.json
    export HOME=/sandbox
    cd /sandbox/workspace
    opencode run --format json --pure "Respond with exactly: SPIKE_PASS"
    '

    Expected output: a JSONL stream ending with something like:

    {"type":"text","part":{"text":"SPIKE_PASS"}}

    Troubleshooting reference

    Error Cause Fix
    no compute driver configured OpenShell can't find Podman at startup Create symlink (Step 2a)
    openshell gateway start: unrecognized subcommand Wrong command Use brew services restart openshell
    permission denied: open /usr/local/bin/fullsend macOS SIP Build to ~/.local/bin/ instead
    permission denied: open /private/tmp/ticket-* Podman build context is /tmp/ Use a dedicated subdirectory (Step 4b)
    policy_denied: CONNECT api.anthropic.com:443 opencode binary not in policy allowlist Add policy rules (Step 7)
    Could not load the default credentials No ADC file inside sandbox Copy ADC credentials (Step 8)
    ProviderModelNotFoundError: Model not found Wrong model ID format Use claude-sonnet-4-6@default not claude-sonnet-4-20250514
    invalid_client from oauth2.googleapis.com Dummy ADC credentials Use real ADC from host (Step 8)
    opencode uses wrong model silently models.opencode.ai blocked, fallback to built-in Add models.opencode.ai policy 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:

    1. Terminates the TLS connection
    2. Injects Authorization: Bearer <token> using the vertex-spike provider
      credentials
    3. Forwards the request to Google

    What it does not do:

    • Rewrite Anthropic API calls to Vertex (it's not an API translation layer)
    • Handle oauth2.googleapis.com token refresh — those go to Google directly
    • Resolve application default credentials for the SDK (the SDK must do this
      locally before making any API call)

    This means: even though the gateway handles auth on the Vertex endpoint, the
    google-auth-library inside opencode must still resolve credentials locally
    first. A real ADC file inside the sandbox is required.


    Known gaps to document/fix

    1. GOOGLE_VERTEX_LOCATION not injected: The sandbox receives
      GOOGLE_CLOUD_PROJECT from the provider but not GOOGLE_VERTEX_LOCATION.
      Must be set manually at runtime.

    2. models.opencode.ai not in default policy: opencode silently falls back
      to a built-in default model when the model registry is unreachable. No error
      is emitted. Should be in the default opencode policy rule.

    3. 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.

    4. 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

    Image
  5. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    SPIKE 2 Steps and results

    Tested OPENCODE_CONFIG_CONTENT env var using the exact jq assembly pattern from run-review.sh:47-79:

    openshell sandbox exec --name opencode-spike -- bash -c '
    export OPENCODE_CONFIG_CONTENT='"'"'{
      "$schema": "https://opencode.ai/config.json",
      "permission": {
        "edit": "deny",
        "bash": "deny",
        "webfetch": "deny",
        "websearch": "deny",
        "skill": "deny",
        "external_directory": "deny",
        "doom_loop": "deny"
      },
      "provider": {
        "google-vertex-anthropic": {
          "models": {
            "claude-sonnet-4-6@default": {}
          }
        }
      }
    }'"'"'
    export GOOGLE_VERTEX_LOCATION=us-east5
    export GOOGLE_VERTEX_PROJECT=itpc-gcp-prodsec-eng-claude
    export GOOGLE_APPLICATION_CREDENTIALS=/sandbox/.config/gcloud/application_default_credentials.json
    export HOME=/sandbox
    cd /sandbox/workspace
    timeout 120 opencode run \
      --model google-vertex-anthropic/claude-sonnet-4-6@default \
      --format json \
      --pure \
      -- "Respond with exactly: SPIKE_PASS"
    '

    Result: SPIKE_PASS returned successfully. OPENCODE_CONFIG_CONTENT works 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 same google-auth-library code path via GOOGLE_APPLICATION_CREDENTIALS.

    WIF policy note: WIF additionally needs sts.googleapis.com:443 in the network policy (currently only oauth2.googleapis.com:443 is allowed). The token exchange endpoint differs between credential types:

    Credential type File type field Token endpoint
    gcloud user ADC (tested) authorized_user oauth2.googleapis.com
    Service account key service_account oauth2.googleapis.com
    WIF (production) external_account sts.googleapis.com
  6. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    Test

    1. Created /sandbox/workspace/.env with SPIKE_ENV_VAR=hello_from_dotenv
    2. Created /sandbox/workspace/.env.d/custom.env with SPIKE_ENVD_VAR=hello_from_envd
    3. Ran opencode run — vars are not visible to the model
    4. Explicitly sourced before opencode run — vars are visible

    Result

    opencode does not auto-source .env or .env.d/ files. The mechanism works only if the calling harness explicitly sources them before invoking opencode run:

    # Required in entrypoint/harness — opencode won't do this
    [ -f /sandbox/workspace/.env ] && . /sandbox/workspace/.env
    for f in /sandbox/workspace/.env.d/*.env; do
      [ -f "$f" ] && . "$f"
    done
    
    opencode run --format json --pure -- "..."

    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 in opencode run. Until that ships, the entrypoint script in the sandbox image must include explicit sourcing.

    To file

    • opencode: Enhancement — add .env / .env.d/ auto-sourcing to opencode run (standard developer tool expectation; Docker Compose, Next.js, Vite all support this natively)
  7. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    Spike 4 tests and results

    Shell redirection captures NDJSON cleanly:

    opencode run --format json --pure -- "..." \
      > /sandbox/workspace/output.jsonl 2>/sandbox/workspace/stderr.log
    • Output: 3 lines, 936 bytes of valid JSONL
    • stderr: empty (clean run)
    • File copied to host via openshell sandbox exec -- cat > /tmp/spike-output.jsonl
    • Matches run-review.sh:100 pattern exactly (> review_raw.txt 2>review_err.txt)
    • io.TeeReader in the Go harness will work identically
  8. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    Spike 5 tests and results

    Steps

    Existing sandbox opencode-spike with working Vertex AI configuration.

    Created /sandbox/workspace/test-data.txt:

    line1: alpha
    line2: bravo
    line3: charlie
    

    Commands Run

    # Multi-step prompt to force tool use (glob + read) + text response
    openshell sandbox exec --name opencode-spike -- bash -c '
    export GOOGLE_VERTEX_LOCATION=us-east5
    export GOOGLE_VERTEX_PROJECT=itpc-gcp-prodsec-eng-claude
    export GOOGLE_APPLICATION_CREDENTIALS=/sandbox/.config/gcloud/application_default_credentials.json
    export HOME=/sandbox
    cd /sandbox/workspace
    opencode run --format json --pure \
      "Read the file spike-prompt.txt in the current directory. Then read test-data.txt. Then summarize both files." \
      > /sandbox/workspace/st5-output.jsonl 2>/sandbox/workspace/st5-stderr.log
    '
    
    # Extract output
    openshell sandbox exec --name opencode-spike -- cat /sandbox/workspace/st5-output.jsonl > /tmp/st5-output.jsonl
    openshell sandbox exec --name opencode-spike -- cat /sandbox/workspace/st5-stderr.log > /tmp/st5-stderr.log

    Output: 7 JSONL events (2 LLM turns)

    # type Key fields
    1 step_start sessionID, messageID
    2 tool_use tool: "read", state.status: "completed", read spike-prompt.txt
    3 tool_use tool: "read", state.status: "completed", read test-data.txt
    4 step_finish reason: "tool-calls", tokens + cost (see below)
    5 step_start second LLM turn
    6 text summary response
    7 step_finish reason: "stop", tokens + cost (see below)

    step_finish token envelopes

    Step 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:

    JSONL path Go struct field RunMetrics field Aggregation Present?
    part.cost ocStepFinishPart.Cost TotalCostUSD sum YES
    part.tokens.input ocStepTokens.Input InputTokens sum YES
    part.tokens.output ocStepTokens.Output OutputTokens sum YES
    part.tokens.reasoning ocStepTokens.Reasoning ReasoningTokens sum YES
    part.tokens.cache.read ocCacheTokens.Read CacheReadInputTokens sum YES
    part.tokens.cache.write ocCacheTokens.Write CacheCreationInputTokens sum YES
    part.tokens.total — — not consumed correct

    Key observations

    1. All 6 fields the ticket asks about are present and populated in every step_finish event
    2. tokens.total is emitted by opencode but correctly ignored by parseOpenCodeStream (not in Go struct)
    3. tokens.reasoning is 0 because claude-sonnet-4-6 doesn't use extended thinking by default; would populate with --thinking flag
    4. Per-step TokensEvent is emitted for each step_finish, and values are summed into ResultEvent at EOF
    5. Cache write/read semantics map correctly: opencode's cache.write → fullsend's `CacheCreationInputTokens
  9. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    Prerequisites

    Policy rules for curl binary (added via openshell policy update):

    • github.com:443 — release page
    • api.github.com:443 — API
    • objects.githubusercontent.com:443 — asset CDN
    • release-assets.githubusercontent.com:443 — redirect target for release downloads

    Commands Run

    # 1. Detect architecture
    openshell sandbox exec --name opencode-spike -- bash -c '
    uname -m && uname -s
    '
    # Output: aarch64 / Linux
    
    # 2. Download release tarball + checksums
    openshell sandbox exec --name opencode-spike -- bash -c '
    mkdir -p /tmp/uf-install && cd /tmp/uf-install
    curl -fsSL -o unbound-force.tar.gz \
      "https://github.com/unbound-force/unbound-force/releases/download/v0.15.0/unbound-force_0.15.0_linux_arm64.tar.gz"
    curl -fsSL -o checksums.txt \
      "https://github.com/unbound-force/unbound-force/releases/download/v0.15.0/checksums.txt"
    ls -la
    '
    # Output: unbound-force.tar.gz (4,476,132 bytes) + checksums.txt
    
    # 3. Verify SHA256 checksum
    openshell sandbox exec --name opencode-spike -- bash -c '
    cd /tmp/uf-install
    sha256sum -c checksums.txt 2>&1 | grep -E "(OK|FAILED|No such)"
    '
    # Output:
    # unbound-force_0.15.0_linux_arm64.tar.gz: OK
    # (other platform tarballs: "No such file" — expected, only arm64 downloaded)
    
    # 4. Extract and inspect
    openshell sandbox exec --name opencode-spike -- bash -c '
    cd /tmp/uf-install
    tar xzf unbound-force.tar.gz
    ls -la
    file unbound-force
    '
    # Tarball contents: CHANGELOG.md, LICENSE, README.md, unbound-force
    # Binary: ELF 64-bit LSB executable, ARM aarch64, 11,600,056 bytes
    
    # 5. Version check
    openshell sandbox exec --name opencode-spike -- bash -c '
    cd /tmp/uf-install
    ./unbound-force --version
    '
    # Output: 0.15.0 (commit 52938ec...)
    
    # 6. Doctor check
    openshell sandbox exec --name opencode-spike -- bash -c '
    cd /tmp/uf-install
    ./unbound-force doctor 2>&1 | head -40
    '

    Doctor results

    Status Count Details
    PASS 10 opencode, speckit, git, gh, jq, podman-remote, make, OS, architecture, goreleaser
    WARN 10 devpod, ollama, gaze, golangci-lint, cosign, cobra-cli, go-jsonschema, changie, commitlint, megalinter
    FAIL 7 go, podman (local), AGENTS.md, scaffold dirs, go.mod (not in a UF project workspace)

    All failures are expected — sandbox workspace is not a UF project checkout.

    Containerfile note

    The binary in the tarball is named unbound-force, not uf. The Containerfile should install it as:

    RUN curl -fsSL -o /tmp/uf.tar.gz \
        "https://github.com/unbound-force/unbound-force/releases/download/v0.15.0/unbound-force_0.15.0_linux_arm64.tar.gz" \
      && cd /tmp && tar xzf uf.tar.gz \
      && mv unbound-force /usr/local/bin/uf \
      && chmod 755 /usr/local/bin/uf \
      && rm -rf /tmp/uf.tar.gz /tmp/CHANGELOG.md /tmp/LICENSE /tmp/README.md

    SHA256 checksum verification should also be added per Constitution Principle V (Security by Default).

  10. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    Spike 7 steps and results

    Summary

    Custom tools DO work in opencode run headless mode — but with constraints that affect the Inc2 question tool design (#513).

    Test Matrix

    Test Tool File Imports Args Result
    1 ping.ts None {} PASS — loaded, callable, returned "pong"
    2 ask.ts None {} PASS — loaded, callable, returned JSON
    3 question.ts None {} FAIL — blocked by built-in question permission
    4 question.ts @opencode-ai/plugin typed FAIL — Cannot find module '@opencode-ai/plugin'
    5 question.ts zod typed FAIL — Cannot find package 'zod'
    6 question.ts None JSON Schema objects FAIL — tool silently doesn't register

    Finding 1: Zero-import custom tools work in headless mode

    A .opencode/tools/ping.ts with no imports and args: {} loads and executes correctly:

    // .opencode/tools/ping.ts — WORKS
    export default {
      description: "Simple ping tool that returns pong",
      args: {},
      async execute() {
        return "pong"
      },
    }

    Output from opencode run --format json --pure:

    {"type":"tool_use","part":{"tool":"ping","state":{"status":"completed","input":{},"output":"pong"}}}

    Finding 2: Tool named question is blocked by built-in permission

    In 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.ts is caught by the question permission deny — it never appears in the tool list. Setting "question": "allow" in OPENCODE_CONFIG_CONTENT does 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 install via its Bun runtime to resolve @opencode-ai/plugin. This fails through the gateway proxy:

    WARN "background dependency install failed"
      error: "FetchError: request to https://registry.npmjs.org/@opencode-ai%2fplugin
      failed, reason: The socket connection was closed unexpectedly."
    

    Tested mitigations (all failed):

    • Adding registry.npmjs.org:443 to policy for both opencode.exe and node binaries
    • Setting npm config set cafile to gateway CA
    • Pre-installing node_modules/ via openshell sandbox upload
    • Adding package.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:

    1. import { tool } from "@opencode-ai/plugin" with tool.schema.string()
    2. import { z } from "zod" with z.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:

    Approach Pros Cons
    A. Zero-import, args: {} Works now, no build changes No input validation, name can't be question
    B. Bundle deps in Containerfile Full @opencode-ai/plugin API, typed args Requires npm install @opencode-ai/plugin at image build time
    C. Inline Zod from node_modules Typed args without runtime install Fragile, version coupling

    Recommendation: Approach B — add npm install @opencode-ai/plugin to the Containerfile and name the tool ask (not question).

    Env/Versions

    • opencode 1.18.16 (Bun ELF binary)
    • OpenShell 0.0.83, policy v13
    • Sandbox: Ubuntu 24.04 arm64
    • @opencode-ai/plugin 1.18.18 (tested via host install + upload)
  11. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    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)

    # Install cosign
    brew install cosign
    cosign version
    # v3.1.3
    
    # Check fullsend base image
    cosign verify ghcr.io/fullsend-ai/fullsend-sandbox:latest
    # Error: no signatures found for image
    
    # Check UF image (does it exist as container?)
    cosign verify ghcr.io/unbound-force/unbound-force:latest
    # Error: MANIFEST_UNKNOWN (no container image — distributed as tarball)
    
    # Sanity check: verify a known-signed image
    cosign verify gcr.io/projectsigstore/cosign:v2.2.0
    # PASS — 1 verified signature
    
    # Confirm unsigned local image runs fine
    openshell sandbox list
    # opencode-spike: Running (image: fullsend-opencode-spike:local, unsigned)

    Findings

    Image Signed? Runs in sandbox?
    fullsend-opencode-spike:local No (locally built) Yes
    ghcr.io/fullsend-ai/fullsend-sandbox:latest No signatures found Would run
    ghcr.io/unbound-force/unbound-force:latest N/A (no container image) N/A
    gcr.io/projectsigstore/cosign:v2.2.0 Yes (verified) Would run

    Assessment

    • No cosign admission control exists in OpenShell. Unsigned images are accepted without warning.
    • ADR 0038 defers container image signing to a future milestone.
    • Constitution Principle V (Security by Default) gap confirmed but not blocking for this spike.
    • Recommendation: File issue to track cosign admission policy for production deployment.
  12. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    Check: Base image OS confirmation

    Result: Ubuntu 24.04.3 LTS (Noble Numbat) — confirmed

    Commands Run

    openshell sandbox exec --name opencode-spike -- cat /etc/os-release
    openshell sandbox exec --name opencode-spike -- uname -a

    Output

    PRETTY_NAME="Ubuntu 24.04.3 LTS"
    NAME="Ubuntu"
    VERSION_ID="24.04"
    VERSION="24.04.3 LTS (Noble Numbat)"
    VERSION_CODENAME=noble
    ID=ubuntu
    ID_LIKE=debian
    
    Linux opencode-spike 6.19.7-200.fc43.aarch64 #1 SMP ... aarch64 aarch64 aarch64 GNU/Linux
    

    Notes

    • Guest OS: Ubuntu 24.04 LTS (Noble) — matches Containerfile FROM ubuntu:24.04
    • Architecture: aarch64 (ARM64) — Apple Silicon host
    • Host kernel: Fedora 43 (6.19.7) — Podman machine VM kernel, not macOS
    • Image: locally built fullsend-opencode-spike:local (unsigned)
  13. yvonnedevlinrh commented on Aug 19, 2026

    @yvonnedevlinrh
    Contributor

    Spike #509 — GO/NO-GO Summary

    Results at a glance

    # Spike task Verdict Notes
    ST1 Headless opencode run GO Works with --format json --pure
    ST2 Vertex WIF credential flow PARTIAL GO gcloud ADC works; WIF untestable locally (needs external IdP); OPENCODE_CONFIG_CONTENT env var works
    ST3 .env.d/*.env sourcing NO-GO opencode does NOT auto-source .env files; harness must do it explicitly
    ST4 OutputPath stream file GO stdout redirect to .jsonl works; stderr separate
    ST5 ndjson token/cost fidelity GO All 6 fields present, maps 1:1 to parseOpenCodeStream
    ST6 uf binary install GO Download, checksum, doctor all work; binary named unbound-force not uf (see below)
    ST7 Question tool headless PARTIAL GO Zero-import custom tools work; question name blocked by built-in permission; must name it ask
    Check Base image OS Ubuntu 24.04 Confirmed Noble Numbat aarch64
    Check Cosign admission NOT ENFORCED No admission control; unsigned images run fine

    What potentially needs happen to run opencode + uf in fullsend

    Bugs to file

    Project Issue Why
    OpenCode question permission blocks custom tool registration by name collision Custom tool named question is silently denied by headless mode's {permission: "question", action: "deny"} rule. Tool must be named something else (ask).
    OpenCode Plain-object tool args silently fail to register Custom tools with args: { type: "string" } (plain JSON Schema) don't register. Must use Zod schema. No error, just silently ignored.
    OpenShell Gateway TLS MITM drops npm registry connections (ECONNRESET) Both Bun and Node.js npm fail through the gateway proxy. Affects all npm traffic, not opencode-specific.

    Enhancements to request

    Project Enhancement Why
    OpenCode .env / .env.d/ auto-sourcing in opencode run Harness currently must source env files before invoking opencode. Would simplify container entrypoints.
    OpenCode Background npm install should respect pre-installed node_modules Even with deps pre-installed in the image and package-lock.json present, opencode tries to npm install and fails in network-restricted environments.

    Documentation / Containerfile items

    Item Detail
    Policy rules Minimum 3 endpoints for opencode.exe: aiplatform.googleapis.com:443, oauth2.googleapis.com:443, models.opencode.ai:443. Add sts.googleapis.com:443 for WIF.
    ADC credentials Must be real — gateway credential injection only works on aiplatform endpoints, not oauth2 token refresh. Copy host ADC or use WIF.
    Binary allowlist Must use /usr/lib/node_modules/opencode-ai/bin/opencode.exe (actual Bun ELF), not symlink path.
    opencode.json Use google-vertex-anthropic/claude-sonnet-4-6@default provider/model. Set small_model explicitly or it defaults to Gemini.
    Env vars at runtime GOOGLE_VERTEX_LOCATION, GOOGLE_VERTEX_PROJECT, GOOGLE_APPLICATION_CREDENTIALS, HOME=/sandbox
    uf install Tarball binary is unbound-force; Containerfile must mv to unbound-force and ln -s ... uf. Add SHA256 verification.
    Custom tools Must use zero-import pattern (no @opencode-ai/plugin). Bundle deps in image or don't import. Name tool ask not question.
    .env sourcing Harness entrypoint must explicitly . .env and loop .env.d/*.env before opencode run.
    models.opencode.ai Must be in policy or opencode silently falls back to built-in default model ("Big Pickle").
    Cosign No admission control exists. Track for future production hardening (ADR 0038).

    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.

  14. yvonnedevlinrh commented on Aug 20, 2026

    @yvonnedevlinrh
    Contributor

    Reviewed PR fullsend-ai/fullsend#6355

    This is the right architecture and a prerequisite for OpenCode support.
    The PR:

    • Makes hook scripts runtime-neutral via SandboxHooksBootstrap + HookPlan
    • Replaces rt.Name() == "claude" checks with clean capability interfaces
    • Updates the security matrix to show hooks are "wired; not loaded" under Claude today

    Five things our spike #509 testing surfaced that matter for the follow-up:

    1. tool.execute.before/after doesn't exist in opencode — the docs name it as the OpenCode interception mechanism, but it's not a real API. The adapter needs a different approach.
    2. .env sourcing is not automatic — appendHookEnv writes to .env but OpenCode won't read it unless the adapter's run command explicitly sources it.
    3. Model name / separator — validModelName regex blocks OpenCode's provider/model format. Flagged in the PR but needs follow-up.
    4. DebugLogNameFor(tx) missing rt — call site only passes transcript handler, not runtime. Works today because Claude is both, but will silently break for OpenCode.
    5. ContextBridger is correct — OpenCode reads AGENTS.md natively, so WantsClaudeMDBridge returning false is right.

    So after this PR merges, we'd still need:

    1. An OpenCodeRuntime struct implementing Runtime (bootstrap, run loop, env exports, config dir)
    2. Registration in ValidRuntimes() so config.yaml can select it
    3. A TranscriptHandler for OpenCode's JSONL output (the parseOpenCodeStream parser from PR #6147 already exists)
    4. An adapter that wires HookPlan scripts through whatever interception mechanism OpenCode supports
    5. The validModelName regex relaxed to allow / for google-vertex-anthropic/claude-sonnet-4-6@default

    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.

  15. jflowers commented on Aug 24, 2026

    @jflowers
    Contributor

    #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

    AC Status Evidence
    opencode run in sandbox w/ Vertex WIF PARTIAL Proven headless via gcloud user ADC (authorized_user). Real WIF (external_account) untestable locally — needs GitHub OIDC. Actual council-review-action JSON not run end-to-end.
    .env.d/*.env sourcing confirmed DONE opencode does NOT auto-source; harness must . .env + loop .env.d/*.env explicitly
    OutputPath stream file known/usable DONE stdout → output.jsonl redirect; io.TeeReader pattern confirmed
    ndjson token/cost fields documented DONE All 6 fields map 1:1 to parseOpenCodeStream (fullsend PR #6147)
    Written GO/NO-GO w/ blockers DONE Full summary posted with 3 bugs, 2 enhancements, Containerfile/docs items

    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.before and tool.execute.after are real Tool Events in the plugin system
    • The official docs include a .env-protection example using tool.execute.before
    • Plugins also expose shell.env (relevant to the .env.d sourcing gap from Spike 3)

    The confusion is plugins vs custom tools — two separate extension mechanisms:

    Mechanism Directory Has before/after hooks? Can register tools?
    Plugins (.opencode/plugins/*.ts) .opencode/plugins/ Yes — tool.execute.before, tool.execute.after, shell.env, etc. Yes — and plugin tools take precedence over built-ins with the same name
    Custom tools (.opencode/tools/*.ts) .opencode/tools/ No — just tool definitions Yes, but subject to built-in permission blocks

    This matters for two downstream stories:

    • [Story] Close the OpenCode security-hook gap before write-capable agents #515 (security hooks): tool.execute.before/after IS the correct interception point for wiring security.HookPlan scripts, mirroring pi's pi_extension/fullsend-hooks.js. The fullsend-hooks adapter should be an OpenCode plugin, not a custom tool.
    • [Story] Resume FullSend agents from GitHub comment answers #513 (question tool): Spike 7 found .opencode/tools/question.ts was blocked by the built-in question permission 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

    • Confirm the 3 bugs and 2 enhancements from the GO/NO-GO summary were filed as tracked issues (DoD requires tech debt logging)
    • Tick satisfied ACs in the issue body
    • Close as completed

    Leaving this for @yvonnedevlinrh to close when ready.

  16. yvonnedevlinrh commented on Aug 27, 2026

    @yvonnedevlinrh
    Contributor

    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:

    Item Tracked as
    Bug 1 — question permission blocks same-named custom tool (headless) anomalyco/opencode#45531
    Bug 2 — custom tool with plain-object args silently fails to register anomalyco/opencode#45532
    Bug 3 — sandbox egress: npm ECONNRESET + no Vertex AI / WIF egress NVIDIA/OpenShell-Community#91 (fix: #92)
    Enh 1 — .env / .env.d auto-sourcing comment on anomalyco/opencode#21197
    Enh 2 — skip npm install when node_modules present comment on anomalyco/opencode#37888

    AC outcome

    Verdict: GO for Increment 1. The headless OpenCode runtime path is proven; residual AC1 work is tracked downstream. Closing as completed.

  17. moved this from In Progress 📋 to Done ✔️ in Unbound Force Planningon Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementllm_assisted

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions