Guides, local models and sandbox commands: follow-ups from the factory-dev walkthrough #29

Merged
dario merged 10 commits from dario/mlx-serve into main 2026-11-20 10:38:08 +01:00 AGit
Owner

Follow-ups from walking through the guides of #25 and from the first runs with a local model in the factory-dev sandbox.

Guides (review of #25 and the walkthrough)

  • The forge token is a sandbox secret; where the host stores it doesn't matter.
  • The model step covers Claude Code with a subscription and OpenCode with a local model (oc-mlx).
  • Placeholders (<n>, <pr>) instead of concrete issue and pull request numbers.
  • factory-dev allows any shell command ("allowed_shell": ["*"]): go test and just check already run agent-written code, so the list stopped little. The harness denials (git push, curl, wget, web tools) still apply.
  • Forge-specific credential details moved to a new "In a Docker Sandbox" section in docs/tokens.md.
  • What sbx actually prints, what an existing secret or sandbox means, what recreating the sandbox deletes and how to check for unpushed work first, what the setup checks print, where the config lives.

Local models and the sandbox

  • just mlx-serve: serves a profile's mlx-lm model on the host (model and port from factory.json), installs mlx-lm with uv and downloads the model on first use, offline, from an empty directory, on loopback.
  • just sandbox: enters a sandbox (creating it the first time) and serves the local models its roles use while you are inside.
  • just sandbox-update: installs a new factory binary and factory.json into the running sandbox and keeps its runs.
  • just sandbox-recreate: rebuilds, recreates the sandbox and enters it.

Fixes

  • factory-dev kit: OpenCode failed with exec format error, because --ignore-scripts left its placeholder bin/opencode.exe. The kit now copies the platform package's binary over it, as OpenCode's postinstall does, and the build fails unless the result is an ELF binary. The setup check runs opencode --version.
  • .gitignore: factory-linux from the manual build.

Test evidence

  • just check: passes.
  • Recipes checked with stand-ins for uv, mlx-lm and sbx: start, readiness wait, cleanup on exit, an existing server left alone, a dying server reported. On a Mac: just sandbox-update, which printed the new factory version. Not yet confirmed on a Mac: just mlx-serve and just sandbox with the uv install, sandbox-recreate, and the kit build with the OpenCode fix.

Open questions

  • sbx env is experimental upstream; the recipes depend on it.

🤖 Generated with Claude Code

Follow-ups from walking through the guides of #25 and from the first runs with a local model in the `factory-dev` sandbox. ## Guides (review of #25 and the walkthrough) - The forge token is a sandbox secret; where the host stores it doesn't matter. - The model step covers Claude Code with a subscription and OpenCode with a local model (`oc-mlx`). - Placeholders (`<n>`, `<pr>`) instead of concrete issue and pull request numbers. - `factory-dev` allows any shell command (`"allowed_shell": ["*"]`): `go test` and `just check` already run agent-written code, so the list stopped little. The harness denials (`git push`, `curl`, `wget`, web tools) still apply. - Forge-specific credential details moved to a new "In a Docker Sandbox" section in `docs/tokens.md`. - What `sbx` actually prints, what an existing secret or sandbox means, what recreating the sandbox deletes and how to check for unpushed work first, what the setup checks print, where the config lives. ## Local models and the sandbox - `just mlx-serve`: serves a profile's mlx-lm model on the host (model and port from `factory.json`), installs mlx-lm with uv and downloads the model on first use, offline, from an empty directory, on loopback. - `just sandbox`: enters a sandbox (creating it the first time) and serves the local models its roles use while you are inside. - `just sandbox-update`: installs a new factory binary and `factory.json` into the running sandbox and keeps its runs. - `just sandbox-recreate`: rebuilds, recreates the sandbox and enters it. ## Fixes - **factory-dev kit:** OpenCode failed with `exec format error`, because `--ignore-scripts` left its placeholder `bin/opencode.exe`. The kit now copies the platform package's binary over it, as OpenCode's postinstall does, and the build fails unless the result is an ELF binary. The setup check runs `opencode --version`. - **.gitignore:** `factory-linux` from the manual build. ## Test evidence - `just check`: passes. - Recipes checked with stand-ins for `uv`, mlx-lm and `sbx`: start, readiness wait, cleanup on exit, an existing server left alone, a dying server reported. On a Mac: `just sandbox-update`, which printed the new `factory version`. Not yet confirmed on a Mac: `just mlx-serve` and `just sandbox` with the uv install, `sandbox-recreate`, and the kit build with the OpenCode fix. ## Open questions - `sbx env` is experimental upstream; the recipes depend on it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Set the forge token as a sandbox secret; where the host keeps it doesn't matter.
- The model step covers both profiles: Claude Code with a subscription, or OpenCode with a local model (oc-mlx).
- Issue and pull request numbers in commands are placeholders (<n>, <pr>).
- factory-dev allows any shell command ("*"). In this sandbox the allow list stopped little, since go test and just check already run agent-written code. The harness denials (git push, curl, wget, web tools) still apply.
- Forge-specific credential details moved to tokens.md, in a new "In a Docker Sandbox" section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reads the model and port from the agent profile in factory.json,
installs mlx-lm with uv (uv tool install) and downloads the model on
first use, and serves offline from an empty directory on loopback, as
docs/deploy-microvm.md requires. The manual steps in the docs now use uv
too, so there is one way to install it.

Also ignore the factory-linux binary from the manual build and a stray
factory binary in the factory-dev kit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Starts just mlx-serve for each role profile whose base_url is on
host.docker.internal, waits until the model is loaded, runs sbx env run,
and stops the servers it started when you leave. A server already
running on the port is used and left alone. Builds the kit's factory
binary first if it has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With --ignore-scripts, @opencode/cli keeps bin/opencode.exe as a shell
stub that only prints that postinstall did not run, so starting opencode
failed with 'exec format error'. Copy the glibc binary for the target
CPU from the platform package, as postinstall would, and fail the build
unless the result is an ELF file. The setup check now runs
opencode --version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the sandbox and its runs; sandbox-recreate remains for kit changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dario merged commit 4b083be560 into main 2026-11-20 10:38:08 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dario/factory!29
No description provided.