Skip to content

fix(terraform): run the OpenComputer snapshot builder from the repo root#842

Merged
ColeMurray merged 1 commit into
mainfrom
fix/opencomputer-build-base-snapshot-repo-root
Jun 27, 2026
Merged

fix(terraform): run the OpenComputer snapshot builder from the repo root#842
ColeMurray merged 1 commit into
mainfrom
fix/opencomputer-build-base-snapshot-repo-root

Conversation

@ColeMurray

@ColeMurray ColeMurray commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the Terraform-managed OpenComputer snapshot build (added in #840). A real terraform apply with SANDBOX_PROVIDER=opencomputer fails immediately with:

Missing sandbox runtime directory: ../../../packages/sandbox-runtime/src/sandbox_runtime

Root cause

The script ran the builder through npm run build:opencomputer-template, which uses npm -w @open-inspect/opencomputer-infra and moves cwd into the workspace (packages/opencomputer-infra). build-template.ts resolves the sandbox-runtime source relative to that cwd, so it looked for the runtime dir under the workspace instead of the repo root.

Fix

Mirror the sibling Vercel builder (terraform/modules/vercel-sandbox-infra/scripts/build-base-snapshot.sh), which splits build from run and invokes the builder directly from the repo root:

cd "${PROJECT_ROOT}"
npm run build -w @open-inspect/opencomputer-infra        # build the bundle (cwd irrelevant)
node packages/opencomputer-infra/dist/build-template.js  # run from repo root -> cwd = repo root

The script already cds into the repo, so running node from there keeps cwd at the repo root and the runtime dir resolves — with no OPENINSPECT_REPO_ROOT env override and no git dependency. This keeps repo-root resolution consistent with how the other providers' Terraform builders work.

Validation

Ran the new invocation with --print-manifest (which builds the image and returns before the snapshot API call) from the repo root:

  • exit 0, no "Missing sandbox runtime directory"
  • 26 sandbox_runtime/* files resolved, including the 4 skills/*/SKILL.md prompts
  • cacheKey computed

The original $(pwd) approach was also proven end-to-end against a real OpenComputer build (image built all 36 steps); this revision keeps that working while removing the env contract per review.

Pure shell change — bash -n clean, file mode (100755) preserved.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed snapshot build path resolution issues caused by changing directories during the build process, improving reliability across runs.
    • Improved build logic to ensure the correct runtime and template resources are located consistently, even when invoked from the repository root.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e8a2a08-1913-4332-9832-ca2581e83b36

📥 Commits

Reviewing files that changed from the base of the PR and between 891f5f4 and 27c1e0d.

📒 Files selected for processing (1)
  • terraform/modules/opencomputer-infra/scripts/build-base-snapshot.sh

📝 Walkthrough

Walkthrough

The snapshot build script now changes into PROJECT_ROOT, builds @open-inspect/opencomputer-infra, and then runs the generated template builder from packages/opencomputer-infra/dist/build-template.js.

Changes

Absolute repo root for snapshot build

Layer / File(s) Summary
Repo root resolution
terraform/modules/opencomputer-infra/scripts/build-base-snapshot.sh
The script adds comments about cwd-based runtime resolution, builds the workspace package, and runs the generated template builder directly.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

🐇 I hopped to the repo root so neat,
Then built the template on its feet.
One quick node run, bright and clear,
Makes the snapshot spring up here.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: updating the OpenComputer snapshot builder to run from the repo root.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/opencomputer-build-base-snapshot-repo-root

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

Comment thread terraform/modules/opencomputer-infra/scripts/build-base-snapshot.sh Outdated

@open-inspect open-inspect Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

PR #842, fix(terraform): resolve OpenComputer build repo root to absolute path, by @ColeMurray changes one file (+8/-4) to pass an absolute repository root into the OpenComputer snapshot builder. The change is minimal and correctly addresses the relative-path mismatch caused by running the builder through an npm workspace.

Critical Issues

None found.

Suggestions

None.

Nitpicks

None.

Positive Feedback

  • The fix is scoped to the actual integration boundary: the shell script now exports the path in the form expected by build-template.ts.
  • Resolving after cd "${PROJECT_ROOT}" avoids duplicating path resolution logic and works whether PROJECT_ROOT is relative or absolute.
  • The expanded comment documents the non-obvious npm workspace cwd behavior that caused the bug.

Questions

None.

Verdict

Approve: ready to merge.

The Terraform-managed OpenComputer snapshot build ran the builder via
`npm run build:opencomputer-template`, which uses `npm -w` and moves cwd
into packages/opencomputer-infra. build-template.ts resolves the
sandbox-runtime source relative to cwd, so `terraform apply` failed:

  Missing sandbox runtime directory:
  ../../../packages/sandbox-runtime/src/sandbox_runtime

Mirror the sibling Vercel builder (terraform/modules/vercel-sandbox-infra):
build the bundle, then run `node packages/opencomputer-infra/dist/build-template.js`
directly from the repo root. The script already `cd`s into the repo, so cwd
is the repo root and the runtime dir resolves with no env override and no git
dependency.

Validated with `--print-manifest` from the repo root: 26 runtime files
resolved (incl. the 4 skills/*/SKILL.md prompts) and the cacheKey computed,
before the snapshot API call.
@ColeMurray ColeMurray force-pushed the fix/opencomputer-build-base-snapshot-repo-root branch from 891f5f4 to 27c1e0d Compare June 27, 2026 07:30
@ColeMurray ColeMurray changed the title fix(terraform): resolve OpenComputer build repo root to absolute path fix(terraform): run the OpenComputer snapshot builder from the repo root Jun 27, 2026
@github-actions

Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

@ColeMurray ColeMurray merged commit 8b215cf into main Jun 27, 2026
17 of 18 checks passed
@ColeMurray ColeMurray deleted the fix/opencomputer-build-base-snapshot-repo-root branch June 27, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant