Skip to content

fix(opencode): load compiled FFF from packaged sidecars - #150

Merged
brentyates-swx merged 17 commits into
swxtchfrom
fm/opencode-fff-extract-97
Oct 9, 2026
Merged

brentyates-swx merged 17 commits into
swxtchfrom
fm/opencode-fff-extract-97

Conversation

@brentyates-swx

@brentyates-swx brentyates-swx commented Oct 7, 2026 •

Copy link
Copy Markdown

Summary

Fix compiled native FFF loading for #97. The root package.json Bun packageManager pin selects Bun for Nix-built OpenCode and desktop binaries (nix/bun.nix, flake.nix). The compiled build (packages/opencode/script/build.ts, packages/script/src/fff-native.ts) creates target-specific FFF sidecars named from the library content digest; the @ff-labs/fff-bun patch loads the sidecar beside the executable and disables embedded addon extraction (patches/@ff-labs%2Ffff-bun@0.9.4.patch). The installer, npm postinstall, local-release, Docker, and generated release-package paths carry the sidecar with the binary (install, packages/opencode/script/postinstall.mjs, local-release.sh, packages/opencode/Dockerfile, packages/opencode/script/publish.ts).

Packaged Windows builds enable native FFF by default when the target sidecar is configured. If packaged FFF cannot load, search fails loudly with the expected sidecar path and the OPENCODE_DISABLE_FFF=1 ripgrep recovery option (packages/core/src/flag/flag.ts, packages/core/src/filesystem/search.ts).

Validation

  • packages/opencode/test/fff-compiled.test.ts checks sidecar loading and native search across normal and forced exits while measuring temporary addon allocations.
  • packages/opencode/test/fff-distribution.test.ts builds and runs the compiled executable, checks sidecar mapping and file search, and exercises missing-sidecar failure and recovery diagnostics.
  • packages/core/test/filesystem/search-fff.test.ts covers native file, directory, glob, and content search.
  • .github/workflows/fff-platform-validation.yml runs compiled distribution tests on native Windows x64 and ARM64 runners and checks Nix node_modules hashes plus OpenCode builds on native Linux and macOS runners; runner evidence is retained.

The validation workflow has read-only repository permissions and does not publish a release.

Raise the project build runtime to Bun 1.4.2, whose compiled FFI extraction uses a stable content-addressed file per user and addon. Keep the existing portable target and libc matrix.

Add a producer-driven compiled FFF regression that checks the real bundled addon across normal starts and forced exits, confirms the surviving bytes and live native operations, and proves the old runtime goes red. Exercise the core search and picker boundary, then run focused package checks.
Pin standalone builds to Bun 1.4.2, whose embedded FFI loader reuses a content-addressed native file. Add a compiled producer regression for normal and forced exits, plus native search coverage through the core FFF layer.
Provide Bun from packageManager to the Nix OpenCode and desktop binary derivations, and remove the version-check warning rewrites. Keep the fixed-output node_modules preparation on its existing Nixpkgs Bun.
Bun owns compiled type:file extraction and leaves named scratch files across the pre-rename crash window and foreign-owner rename fallback. The pinned fff-bun package only resolves that path and passes it to dlopen. Add an OpenCode-only compile mode that loads a content-addressed target library beside the packages/opencode binary, keeping the package default embedded mode for other builds.

Preserve the matching OS, architecture, and libc library through this distribution’s npm packages, release archives and installer, Nix, local release, Homebrew, AUR, Windows signing, and container image.

Keep the existing embedded extraction regression and its Bun 1.3.14 red result. Add a bounded compiled sidecar regression that observes all native files in an isolated temp directory across normal and forced exits and exercises live file search. Demonstrate the regression fails when sidecar mode is removed, then run focused native search coverage and packaging checks. Do not run the full suite or publish.
Add a pull-request-only, fork-scoped validation workflow. Build the compiled distribution on native Windows x64 and arm64 runners and run the existing producer-driven FFF test, recording the exact PR head, runner, command, and sidecar digest.

On native x86_64 and aarch64 Linux and macOS runners, derive Nix node_modules hashes with the existing updater, compare them with nix/hashes.json without editing it, retain per-system reports, and run a real OpenCode Nix build when hashes match. Keep permissions read-only and avoid publish/release workflows.
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