fix(publish): build native addon from source in preflight#954
Conversation
The preflight job ran `npm install && npm test` against the last-published native binary, while WASM ran from current source. When a PR updated both extractors in lockstep, the parity test would pass on CI (which rebuilds native from source) but fail on every subsequent publish run until the next release caught up. Mirror the ci.yml `parity` job pattern: compile the native addon from the current Rust source, copy it over the installed platform binary via ci-install-native.mjs, then run tests. WASM and native now come from the same commit.
|
Claude finished @carlos-alm's task —— View job PR Review: Native Addon Build FixReview Checklist:
Root Cause AnalysisProblem Being Solved: The publish workflow's preflight job was using stale published native binaries (from the last npm release) while the WASM engine used current TypeScript source. When PRs updated both TS and Rust extractors in lockstep (like #947), this created a version mismatch that caused Why This Approach: The solution correctly mirrors the proven pattern from Risk Assessment: ✅ LOW RISK. This is a defensive fix that eliminates a source of false failures. The added build step is isolated to preflight and mirrors existing proven CI patterns. Backlog Compliance
Technical AnalysisWorkflow Changes (lines 35-58):
Script Integration: The Comparison with CI Pattern:
Code Quality AssessmentSecurity: ✅ No security concerns. Uses standard GitHub Actions and existing trusted scripts. Correctness: ✅ The build sequence matches proven CI patterns. The
Performance: ✅ Adds ~2-3 minutes to preflight but eliminates false release failures that cost much more time to debug. Maintainability: ✅ Follows established patterns and uses existing utilities. Concerns & ValidationMinor Observations:
Test Plan Validation: ✅ The test plan is sound:
Critical ConcernsNone identified. This is a well-designed fix addressing a real infrastructure issue. Final Assessment |
Greptile SummaryThis PR fixes a publish workflow regression where the Confidence Score: 5/5Safe to merge — the fix is a direct port of the proven ci.yml pattern with no new failure modes. Single workflow file change with no P0/P1 findings. Step ordering (npm install → napi build → install-native → test) is correct, Rust cache is wired up to avoid cold-build overhead, and the napi-rs CLI version pin matches the rest of the codebase. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant GH as GitHub Actions
participant Rust as Rust Toolchain
participant npm as npm registry
participant napi as napi-rs CLI
participant script as ci-install-native.mjs
participant tests as npm test
GH->>npm: npm install (pulls stale published binary)
npm-->>GH: node_modules/@optave/codegraph-linux-x64-gnu/ (v3.9.3 binary)
GH->>Rust: Setup + cache (dtolnay/rust-toolchain, Swatinem/rust-cache)
GH->>napi: npm install -g @napi-rs/cli@3
GH->>napi: napi build --release (crates/codegraph-core/)
napi-->>GH: crates/codegraph-core/*.node (built from HEAD)
GH->>script: node scripts/ci-install-native.mjs
script-->>GH: copies HEAD .node to node_modules/@optave/codegraph-linux-x64-gnu/codegraph-core.node
GH->>tests: npm test (WASM + native both from same commit)
Reviews (1): Last reviewed commit: "fix(publish): build native addon from so..." | Re-trigger Greptile |
Summary
The publish workflow's preflight job ran
npm install && npm testagainst the last-published native binary, while the WASM engine used the current TypeScript source. When a PR updated both the TS and Rust extractors in lockstep (e.g. #947), thebuild-paritytest passed on CI — which rebuilds native from source via theparityjob — but failed on every subsequentpublish.ymlrun until the next release caught up.This is what blocked the v3.9.4 release (run 24588894845): the preflight loaded the v3.9.3 native binary (21 nodes, 37 edges) while WASM produced 26 nodes, 41 edges from PR #947's extractor additions.
Fix
Mirror the
ci.ymlparityjob pattern inline in preflight:npm install(pulls the stale published binary intonode_modules/@optave/codegraph-linux-x64-gnu)napi build --releasefromcrates/codegraph-corenode scripts/ci-install-native.mjscopies the freshly-built.nodeover the published binarynpm test— both engines now run from the same commitTest plan
preflightjob runs onworkflow_dispatchandreleaseevents; CI's own parity job already validates the native build step works)