@sdsrs/code-graph 0.67.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "sdsrs"
6
6
  },
7
- "version": "0.67.0",
7
+ "version": "0.68.0",
8
8
  "keywords": [
9
9
  "code-graph",
10
10
  "ast",
@@ -531,6 +531,9 @@ function injectProjectMap() {
531
531
  timeout: 5000,
532
532
  encoding: 'utf8',
533
533
  stdio: ['pipe', 'pipe', 'pipe'],
534
+ // Hook-internal delivery, not a model conversion — keep record_cli_use from
535
+ // logging this `map` run as a phantom `use` (mirror injectRecentImpact's affected call).
536
+ env: { ...process.env, CODE_GRAPH_INTERNAL: '1' },
534
537
  });
535
538
 
536
539
  if (output && output.trim()) {
@@ -347,3 +347,15 @@ test('consistencyCheck returns version-mismatch when versions differ', (t) => {
347
347
  assert.ok(versionIssue.msg.includes('0.0.1'));
348
348
  });
349
349
 
350
+ test('injectProjectMap map call carries CODE_GRAPH_INTERNAL (delivery, not a model conversion)', () => {
351
+ // injectProjectMap runs `code-graph-mcp map --compact` to inject the project map.
352
+ // That run is a hook-internal delivery — it must carry the internal marker so
353
+ // record_cli_use (src/cli.rs) does not log it as a phantom model `use` event
354
+ // (the 2026-06-23 mem audit found this leak class; the sibling affected call was
355
+ // already guarded). Asserted at source level because injectProjectMap is not exported.
356
+ const src = fs.readFileSync(path.join(__dirname, 'session-init.js'), 'utf8');
357
+ const i = src.indexOf("['map', '--compact']");
358
+ assert.ok(i >= 0, 'map injection present');
359
+ assert.match(src.slice(i, i + 420), /CODE_GRAPH_INTERNAL:\s*'1'/);
360
+ });
361
+
@@ -374,6 +374,15 @@ function determineQueryType(intents, symbols, filePaths, isCoolingDownFn, messag
374
374
  return null;
375
375
  }
376
376
 
377
+ // Hook-internal CLI runs are PUSH deliveries, not model-initiated conversions.
378
+ // Tagging them CODE_GRAPH_INTERNAL=1 keeps record_cli_use (src/cli.rs) from
379
+ // logging them as `use` events — otherwise this hook's own injected callgraph/
380
+ // overview/search results read back as genuine consumer adoption (2026-06-23 mem
381
+ // audit: 100 phantom "model CLI calls" were this hook crediting its own deliveries).
382
+ function buildRunEnv(base = process.env) {
383
+ return { ...base, CODE_GRAPH_INTERNAL: '1' };
384
+ }
385
+
377
386
  // --- Main execution (only when run directly) ---
378
387
  // All exit-on-condition checks (manifest, computeQuietHooks, message length,
379
388
  // db presence) live INSIDE this guard so `require()` from tests doesn't
@@ -454,6 +463,7 @@ function runMain() {
454
463
  timeout: 3000,
455
464
  encoding: 'utf8',
456
465
  stdio: ['pipe', 'pipe', 'pipe'],
466
+ env: buildRunEnv(),
457
467
  });
458
468
  }
459
469
 
@@ -477,4 +487,4 @@ if (require.main === module) {
477
487
  runMain();
478
488
  }
479
489
 
480
- module.exports = { shouldSkip, extractFilePaths, extractSymbols, detectIntents, scoreIntent, INTENT_PATTERNS, INTENT_THRESHOLD, determineQueryType, computeQuietHooks, STOP_WORDS, PLAIN_WORD_EXCLUDE, hasSymptom, SYMPTOM_PATTERNS };
490
+ module.exports = { shouldSkip, extractFilePaths, extractSymbols, detectIntents, scoreIntent, INTENT_PATTERNS, INTENT_THRESHOLD, determineQueryType, computeQuietHooks, STOP_WORDS, PLAIN_WORD_EXCLUDE, hasSymptom, SYMPTOM_PATTERNS, buildRunEnv };
@@ -14,6 +14,7 @@ const {
14
14
  INTENT_THRESHOLD,
15
15
  determineQueryType,
16
16
  computeQuietHooks,
17
+ buildRunEnv,
17
18
  } = require('./user-prompt-context');
18
19
 
19
20
  // ── shouldSkip ──────────────────────────────────────────
@@ -713,3 +714,30 @@ test('integration: Why does this not work? → symptom-hint', () => {
713
714
  const r = analyze('Why does this not work?');
714
715
  assert.equal(r.query && r.query.type, 'symptom-hint');
715
716
  });
717
+
718
+ // ── buildRunEnv: hook-internal delivery marker (anti phantom-conversion) ──
719
+
720
+ test('buildRunEnv: tags CODE_GRAPH_INTERNAL=1 so deliveries are not logged as model `use`', () => {
721
+ const env = buildRunEnv({ PATH: '/usr/bin', HOME: '/home/x' });
722
+ assert.equal(env.CODE_GRAPH_INTERNAL, '1');
723
+ // preserves the base env (binary still resolves on PATH, cwd inherited, etc.)
724
+ assert.equal(env.PATH, '/usr/bin');
725
+ assert.equal(env.HOME, '/home/x');
726
+ });
727
+
728
+ test('buildRunEnv: defaults to process.env when no base given', () => {
729
+ const env = buildRunEnv();
730
+ assert.equal(env.CODE_GRAPH_INTERNAL, '1');
731
+ });
732
+
733
+ test('run() wires buildRunEnv() into execFileSync (no phantom use-event leak)', () => {
734
+ // run() lives inside runMain() (the file top-level-executes on require), so assert
735
+ // the wiring at the source level: every code-graph-mcp invocation this hook makes
736
+ // must carry the internal marker, else its PUSH injections read back as model
737
+ // adoption (the 2026-06-23 mem audit: 100 phantom "model CLI calls"). Mirrors the
738
+ // cg-answer.js / pre-edit-guide.js internal-env guard.
739
+ const src = fs.readFileSync(path.join(__dirname, 'user-prompt-context.js'), 'utf8');
740
+ const i = src.indexOf('function run(');
741
+ assert.ok(i >= 0, 'run() helper present');
742
+ assert.match(src.slice(i, i + 320), /env:\s*buildRunEnv\(\)/);
743
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdsrs/code-graph",
3
- "version": "0.67.0",
3
+ "version": "0.68.0",
4
4
  "description": "MCP server that indexes codebases into an AST knowledge graph with semantic search, call graph traversal, and HTTP route tracing",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,10 +35,10 @@
35
35
  "node": ">=16"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@sdsrs/code-graph-linux-x64": "0.67.0",
39
- "@sdsrs/code-graph-linux-arm64": "0.67.0",
40
- "@sdsrs/code-graph-darwin-x64": "0.67.0",
41
- "@sdsrs/code-graph-darwin-arm64": "0.67.0",
42
- "@sdsrs/code-graph-win32-x64": "0.67.0"
38
+ "@sdsrs/code-graph-linux-x64": "0.68.0",
39
+ "@sdsrs/code-graph-linux-arm64": "0.68.0",
40
+ "@sdsrs/code-graph-darwin-x64": "0.68.0",
41
+ "@sdsrs/code-graph-darwin-arm64": "0.68.0",
42
+ "@sdsrs/code-graph-win32-x64": "0.68.0"
43
43
  }
44
44
  }