Skip to content

fix(melpa): serialize forge's sqlite3 module build across the oracle's two editors - #429

Merged
eval-exec merged 1 commit into
mainfrom
fix/forge-sqlite3-build-race
Sep 22, 2026
Merged

eval-exec merged 1 commit into
mainfrom
fix/forge-sqlite3-build-race

Conversation

@eval-exec

Copy link
Copy Markdown
Owner

Root cause of the intermittent forge red (seen as RestartProbe (exit Some(255))):

  • run_elisp_oracle_batch evaluates GNU Emacs and Neovm concurrently (thread::scope) against one shared prepared package tree.
  • forge's dependency sqlite3 lazily compiles its native module there on first load; each make deletes the intermediate sqlite3-api.o after linking.
  • On a cold cache the two builds race: one editor's cleanup removes the .o between the other's compile and link → ld.bfd: cannot find sqlite3-api.o.

Fix: point SQLITE3_API_BUILD_COMMAND at flock -w 600 <workspace>/tmp/forge-sqlite3-build.lock make all. The first editor builds the module; the second's make sees it up to date. Both inevitably load the same artifact.

Verified cold (artifacts deleted): forge_practical_workflows_batch passes; the module is present afterwards. Melpa sweep locally 939/942.

…s two editors

The batch oracle evaluates GNU Emacs and Neovm concurrently
(thread::scope in run_elisp_oracle_batch) against one shared prepared
package tree.  forge's dependency sqlite3 lazily compiles its native
module (sqlite3-api.so) in that tree on first load, and each make run
deletes the intermediate sqlite3-api.o after linking.  With both builds
running on a cold cache, one editor's cleanup removes the .o between
the other's compile and link, so the slower link fails:

    Building sqlite3-api module with "make all"
    Failed to compile module using: make all: ...
    ld.bfd: cannot find sqlite3-api.o: No such file or directory

The race is nondeterministic and can hit either editor, which is why
forge surfaced as an intermittent RestartProbe exit 255.

Point SQLITE3_API_BUILD_COMMAND at
  flock -w 600 <workspace>/tmp/forge-sqlite3-build.lock make all
so the first build completes before the second make runs; the second
then observes an up-to-date module and both editors load the same .so.

Melpa sweep locally: 939/942.
Copilot AI balanced review requested due to automatic review settings September 22, 2026 13:28
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3ed2153b-477d-419a-893d-aff4295c857a

📥 Commits

Reviewing files that changed from the base of the PR and between 2870d91 and 2c66959.

📒 Files selected for processing (1)
  • crates/neomacs-melpa-tests/src/parity_tests/forge.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The Forge parity test sets SQLITE3_API_BUILD_COMMAND to run make all through a workspace-scoped flock lock. This serializes concurrent SQLite native module builds.

Changes

Forge SQLite build serialization

Layer / File(s) Summary
Configure locked SQLite build
crates/neomacs-melpa-tests/src/parity_tests/forge.rs
The Forge test sets SQLITE3_API_BUILD_COMMAND to acquire tmp/forge-sqlite3-build.lock for up to 600 seconds before running make all.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2c669

The change makes Forge’s SQLite native-module build wait on a workspace lock, intended to prevent concurrent cold-cache build failures. No concrete merge-blocking risk is currently established.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: serializing Forge's SQLite3 module build across the two oracle editors.
Description check ✅ Passed The description directly explains the concurrent build race, the flock-based fix, and verification results. It is related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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
  • Commit to this branch
  • Create a new PR

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The lock is forge-specific and set only in forge's PRELUDE, so it cannot serialize against closql/org_roam, which build the identical shared sqlite3-api.so with no lock, leaving the documented cross-suite race unaddressed.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

This PR addresses an intermittent MELPA CI failure (ld.bfd: cannot find sqlite3-api.o) in the forge parity suite. forge's sqlite3 dependency lazily compiles its native module on first (require 'sqlite3), and the batch oracle evaluates GNU Emacs and Neomacs concurrently against a shared package tree; because make deletes the intermediate sqlite3-api.o after linking, the two concurrent builds race. The fix sets SQLITE3_API_BUILD_COMMAND in forge's PRELUDE to wrap make all in flock against a workspace-scoped lock file so the two editors serialize their module build.

Changes:

  • Prepend a (setenv "SQLITE3_API_BUILD_COMMAND" ...) form to forge's PRELUDE that runs the module build under flock -w 600 <workspace>/tmp/forge-sqlite3-build.lock make all.
  • Add an explanatory comment documenting the module-build race and the serialization intent.
File Description
crates/​neomacs-melpa-tests/​src/​parity_tests/​forge.rs Wraps forge's lazy sqlite3 native-module build in a flock-guarded command to serialize the two concurrent oracle editors.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +15 to +18
(setenv "SQLITE3_API_BUILD_COMMAND"
(format "flock -w 600 %s make all"
(expand-file-name "tmp/forge-sqlite3-build.lock"
(getenv "NEOMACS_TEST_WORKSPACE_ROOT"))))
@eval-exec
eval-exec merged commit 3ddce0e into main Sep 22, 2026
34 checks passed
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.

2 participants