@evomap/evolver 1.85.2 → 1.85.3

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.
Files changed (49) hide show
  1. package/package.json +1 -1
  2. package/src/adapters/scripts/evolver-session-end.js +0 -1
  3. package/src/evolve/guards.js +1 -1
  4. package/src/evolve/pipeline/collect.js +1 -1
  5. package/src/evolve/pipeline/dispatch.js +1 -1
  6. package/src/evolve/pipeline/enrich.js +1 -1
  7. package/src/evolve/pipeline/hub.js +1 -1
  8. package/src/evolve/pipeline/select.js +1 -1
  9. package/src/evolve/pipeline/signals.js +1 -1
  10. package/src/evolve/utils.js +1 -1
  11. package/src/evolve.js +1 -1
  12. package/src/gep/a2aProtocol.js +1 -1
  13. package/src/gep/candidateEval.js +1 -1
  14. package/src/gep/candidates.js +1 -1
  15. package/src/gep/claimNudge.js +10 -10
  16. package/src/gep/contentHash.js +1 -1
  17. package/src/gep/crypto.js +1 -1
  18. package/src/gep/curriculum.js +1 -1
  19. package/src/gep/deviceId.js +1 -1
  20. package/src/gep/envFingerprint.js +1 -1
  21. package/src/gep/epigenetics.js +1 -1
  22. package/src/gep/explore.js +1 -1
  23. package/src/gep/featureFlags.js +11 -8
  24. package/src/gep/hash.js +1 -1
  25. package/src/gep/hubFetch.js +1 -1
  26. package/src/gep/hubReview.js +1 -1
  27. package/src/gep/hubSearch.js +1 -1
  28. package/src/gep/hubVerify.js +1 -1
  29. package/src/gep/learningSignals.js +1 -1
  30. package/src/gep/localStateAwareness.js +8 -9
  31. package/src/gep/memoryGraph.js +1 -1
  32. package/src/gep/memoryGraphAdapter.js +1 -1
  33. package/src/gep/mutation.js +1 -1
  34. package/src/gep/narrativeMemory.js +1 -1
  35. package/src/gep/openPRRegistry.js +1 -1
  36. package/src/gep/paths.js +81 -18
  37. package/src/gep/personality.js +1 -1
  38. package/src/gep/policyCheck.js +1 -1
  39. package/src/gep/prompt.js +1 -1
  40. package/src/gep/recallVerifier.js +1 -1
  41. package/src/gep/reflection.js +1 -1
  42. package/src/gep/selector.js +1 -1
  43. package/src/gep/skillDistiller.js +1 -1
  44. package/src/gep/solidify.js +1 -1
  45. package/src/gep/strategy.js +1 -1
  46. package/src/gep/validator/stakeBootstrap.js +12 -11
  47. package/src/proxy/index.js +4 -4
  48. package/src/proxy/lifecycle/manager.js +44 -1
  49. package/src/webui/observer/interactions.js +4 -3
package/src/gep/paths.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
+ const os = require('os');
3
4
 
4
5
  let _cachedRepoRoot = null;
5
6
 
@@ -42,34 +43,73 @@ function getRepoRoot() {
42
43
  const legacyFlag = process.env.EVOLVER_USE_PARENT_GIT;
43
44
  const legacyOptOut = typeof legacyFlag === 'string' && legacyFlag.toLowerCase() === 'false';
44
45
 
45
- // Walk upward from process.cwd() the project the user is standing in.
46
- if (!noParent && !legacyOptOut) {
47
- let cwd = process.cwd();
48
- while (cwd !== path.dirname(cwd)) {
49
- if (fs.existsSync(path.join(cwd, '.git'))) {
50
- if (!process.env.EVOLVER_QUIET_PARENT_GIT) {
51
- console.log('[evolver] Using host git repository at:', cwd);
52
- }
53
- _cachedRepoRoot = cwd;
54
- return _cachedRepoRoot;
55
- }
56
- cwd = path.dirname(cwd);
57
- }
46
+ // Both upward walks below must stop at the parent of the nearest
47
+ // `node_modules` ancestor never escape into whatever `.git` happens
48
+ // to live above it (issue #541). On macOS with Homebrew, the global
49
+ // install lives at `/opt/homebrew/lib/node_modules/@evomap/evolver`
50
+ // and `/opt/homebrew` is itself a git repo; an unbounded walk
51
+ // therefore resolves repoRoot to `/opt/homebrew`, sending
52
+ // workspaceRoot / memoryDir / evolutionDir to a directory that
53
+ // doesn't belong to the user and silently producing evolution
54
+ // proposals for the wrong codebase.
55
+ //
56
+ // Boundary semantics: returns the parent of the nearest `node_modules`
57
+ // ancestor (inclusive — a `.git` at that parent IS still picked up),
58
+ // or null if `dir` is not inside any `node_modules` (dev clone /
59
+ // user project root). Callers stop AFTER checking the boundary path
60
+ // itself.
61
+ //
62
+ // For a local install (`<project>/node_modules/@evomap/evolver`), the
63
+ // parent of node_modules IS the user's project, so the boundary
64
+ // includes `<project>` and `<project>/.git` is still picked up
65
+ // correctly. For a dev clone, the boundary is null and the walk is
66
+ // unbounded as before.
67
+ function _nodeModulesBoundary(dir) {
68
+ const segments = dir.split(path.sep);
69
+ const nmIdx = segments.lastIndexOf('node_modules');
70
+ if (nmIdx <= 0) return null;
71
+ return segments.slice(0, nmIdx).join(path.sep) || path.sep;
58
72
  }
59
73
 
60
- // Walk upward from ownDir's parent (local install inside node_modules).
61
- if (!noParent && !legacyOptOut) {
62
- let dir = path.dirname(ownDir);
74
+ function _walkForGit(start) {
75
+ const stopAt = _nodeModulesBoundary(start);
76
+ let dir = start;
63
77
  while (dir !== path.dirname(dir)) {
64
78
  if (fs.existsSync(path.join(dir, '.git'))) {
65
79
  if (!process.env.EVOLVER_QUIET_PARENT_GIT) {
66
80
  console.log('[evolver] Using host git repository at:', dir);
67
81
  }
68
- _cachedRepoRoot = dir;
69
- return _cachedRepoRoot;
82
+ return dir;
70
83
  }
84
+ if (stopAt !== null && dir === stopAt) break;
71
85
  dir = path.dirname(dir);
72
86
  }
87
+ return null;
88
+ }
89
+
90
+ // Walk upward from process.cwd() — the project the user is standing in.
91
+ // Bounded the same way as the ownDir walk: a user who `cd`s into the
92
+ // global install (e.g. `cd /opt/homebrew/lib/node_modules/@evomap/evolver`
93
+ // to debug) would otherwise hit `/opt/homebrew/.git` here BEFORE the
94
+ // ownDir walk runs, defeating its boundary. The boundary still
95
+ // includes the parent of node_modules, so a user `cd`'d into
96
+ // `<their-project>/node_modules/lodash` still has `<their-project>/.git`
97
+ // picked correctly.
98
+ if (!noParent && !legacyOptOut) {
99
+ const hit = _walkForGit(process.cwd());
100
+ if (hit) {
101
+ _cachedRepoRoot = hit;
102
+ return _cachedRepoRoot;
103
+ }
104
+ }
105
+
106
+ // Walk upward from ownDir's parent (local install inside node_modules).
107
+ if (!noParent && !legacyOptOut) {
108
+ const hit = _walkForGit(path.dirname(ownDir));
109
+ if (hit) {
110
+ _cachedRepoRoot = hit;
111
+ return _cachedRepoRoot;
112
+ }
73
113
  }
74
114
 
75
115
  // Fallback: evolver's own directory (dev mode or isolated install).
@@ -224,6 +264,27 @@ function getEvolverInstallRoot() {
224
264
  return path.resolve(__dirname, '..', '..');
225
265
  }
226
266
 
267
+ // Resolve the per-user `~/.evomap` directory, with `EVOLVER_HOME` env var
268
+ // override. Lazy (function call, not a module-level `const`) so tests can
269
+ // flip `EVOLVER_HOME` per case without monkey-patching `os.homedir`.
270
+ //
271
+ // Existing call sites used to duplicate `path.join(os.homedir(), '.evomap')`
272
+ // across ~9 modules; about two thirds silently ignored `EVOLVER_HOME` (it
273
+ // worked for stake bootstrap and claim nudge but not for node-id, device-id,
274
+ // feature flags, etc.). #114 consolidates onto this helper so the override
275
+ // is uniform and tests don't need to monkey-patch the global homedir
276
+ // function (which doesn't compose with `node --test` parallel execution).
277
+ function getEvomapDir() {
278
+ return process.env.EVOLVER_HOME || path.join(os.homedir(), '.evomap');
279
+ }
280
+
281
+ // Join sub-segments under `~/.evomap`. Just a convenience wrapper so call
282
+ // sites don't have to `path.join(getEvomapDir(), 'mailbox', 'state.json')`
283
+ // in two pieces.
284
+ function getEvomapPath(...segments) {
285
+ return path.join(getEvomapDir(), ...segments);
286
+ }
287
+
227
288
  // Per-workspace random secret used to attest that a memory_graph.jsonl
228
289
  // entry was written by the same workspace that's now reading it. Stored
229
290
  // at <workspace>/.evolver/workspace-id with mode 0600 and lazily created
@@ -319,4 +380,6 @@ module.exports = {
319
380
  getNarrativePath,
320
381
  getEvolutionPrinciplesPath,
321
382
  getReflectionLogPath,
383
+ getEvomapDir,
384
+ getEvomapPath,
322
385
  };