Skip to content

Commit f41ba65

Browse files
committed
fix(parity): filter sentinel, register temp dirs before await, clarify binary path check
1 parent 1709a2c commit f41ba65

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

.claude/skills/parity/SKILL.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,27 @@ All steps run from the repo root.
4949
```bash
5050
codesign --sign - --force crates/codegraph-core/*.node
5151
```
52-
4. Verify the loader picks it up:
52+
4. Verify the loader picks up the **locally built** binary, not the published
53+
package. First check which path is actually resolved:
54+
```bash
55+
node -e "
56+
const { createRequire } = require('node:module');
57+
const r = createRequire(require.resolve('./dist/index.js'));
58+
try { console.log(r.resolve('codegraph-core')); } catch { console.log('not found via require'); }
59+
"
60+
```
61+
If the resolved path points to
62+
`node_modules/@optave/codegraph-<platform>-<arch>/codegraph-core.node`
63+
(the installed package), copy your freshly built binary over it:
64+
```bash
65+
cp crates/codegraph-core/*.node node_modules/@optave/codegraph-<platform>-<arch>/codegraph-core.node
66+
```
67+
Then confirm the loader picks it up:
5368
```bash
5469
node -e "import('./dist/infrastructure/native.js').then(m => console.log(m.isNativeAvailable()))"
5570
```
5671
If `false`, stop and report — auditing parity without the native engine is
57-
meaningless. Note: if the repo (or a parent) has
58-
`node_modules/@optave/codegraph-<platform>-<arch>/` installed, Node resolves
59-
that package **before** the crate-local build — copy the freshly built
60-
binary over `codegraph-core.node` in that package dir, or the audit will
61-
silently test the published binary instead of your changes.
72+
meaningless.
6273

6374
## Phase 1 — Audit
6475

scripts/parity-compare.mjs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ const BUILD_OPTS = {
134134
skipRegistry: true,
135135
};
136136

137-
async function buildEngine(fixtureDir, engine, label) {
137+
async function buildEngine(fixtureDir, engine, label, tempDirs) {
138138
const dir = mkdtempSync(join(tmpdir(), `parity-${label}-`));
139+
tempDirs.push(dir); // register before await so cleanup runs even if buildGraph throws
139140
cpSync(fixtureDir, dir, { recursive: true });
140141
await buildGraph(dir, { ...BUILD_OPTS, engine });
141142
return dir;
@@ -145,8 +146,9 @@ async function buildEngine(fixtureDir, engine, label) {
145146
// build on the same dir triggers "Engine changed (wasm -> native), promoting
146147
// to full rebuild", which sets forceFullRebuild and skips the orchestrator —
147148
// the JS pipeline then drives the napi buildCallEdges resolver.
148-
async function buildHybrid(fixtureDir, label) {
149+
async function buildHybrid(fixtureDir, label, tempDirs) {
149150
const dir = mkdtempSync(join(tmpdir(), `parity-${label}-`));
151+
tempDirs.push(dir); // register before await so cleanup runs even if buildGraph throws
150152
cpSync(fixtureDir, dir, { recursive: true });
151153
await buildGraph(dir, { ...BUILD_OPTS, incremental: true, engine: 'wasm' });
152154
await buildGraph(dir, { ...BUILD_OPTS, incremental: true, engine: 'native' });
@@ -193,6 +195,7 @@ function readMultisets(dir) {
193195
function diffMultisets(base, other) {
194196
const diffs = [];
195197
const keys = new Set([...base.keys(), ...other.keys()]);
198+
keys.delete('__TOTAL_ROWS__');
196199
for (const key of keys) {
197200
const a = base.get(key) ?? 0;
198201
const b = other.get(key) ?? 0;
@@ -213,15 +216,13 @@ for (const fixture of fixtures) {
213216
const tempDirs = [];
214217

215218
try {
216-
const wasmDir = await buildEngine(fixtureDir, 'wasm', `${fixture}-wasm`);
217-
tempDirs.push(wasmDir);
219+
const wasmDir = await buildEngine(fixtureDir, 'wasm', `${fixture}-wasm`, tempDirs);
218220
const base = readMultisets(wasmDir);
219221

220-
const variants = [['native', await buildEngine(fixtureDir, 'native', `${fixture}-native`)]];
221-
tempDirs.push(variants[0][1]);
222+
const nativeDir = await buildEngine(fixtureDir, 'native', `${fixture}-native`, tempDirs);
223+
const variants = [['native', nativeDir]];
222224
if (hybrid) {
223-
const hybridDir = await buildHybrid(fixtureDir, `${fixture}-hybrid`);
224-
tempDirs.push(hybridDir);
225+
const hybridDir = await buildHybrid(fixtureDir, `${fixture}-hybrid`, tempDirs);
225226
variants.push(['hybrid', hybridDir]);
226227
}
227228

0 commit comments

Comments
 (0)