@evomap/evolver 1.84.1 → 1.85.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.
Files changed (73) hide show
  1. package/assets/gep/genes.seed.json +17 -15
  2. package/index.js +45 -8
  3. package/package.json +4 -3
  4. package/src/adapters/claudeCode.js +44 -31
  5. package/src/adapters/codex.js +70 -26
  6. package/src/adapters/cursor.js +3 -1
  7. package/src/adapters/hookAdapter.js +142 -2
  8. package/src/adapters/kiro.js +6 -14
  9. package/src/adapters/opencode.js +6 -14
  10. package/src/adapters/scripts/_runtimePaths.js +114 -0
  11. package/src/adapters/scripts/evolver-session-end.js +37 -61
  12. package/src/adapters/scripts/evolver-session-start.js +1 -31
  13. package/src/config.js +20 -1
  14. package/src/evolve/guards.js +1 -1
  15. package/src/evolve/pipeline/collect.js +1 -1
  16. package/src/evolve/pipeline/dispatch.js +1 -1
  17. package/src/evolve/pipeline/enrich.js +1 -1
  18. package/src/evolve/pipeline/hub.js +1 -1
  19. package/src/evolve/pipeline/select.js +1 -1
  20. package/src/evolve/pipeline/signals.js +1 -1
  21. package/src/evolve/utils.js +1 -1
  22. package/src/evolve.js +1 -1
  23. package/src/gep/a2aProtocol.js +1 -1
  24. package/src/gep/assetStore.js +27 -6
  25. package/src/gep/candidateEval.js +1 -1
  26. package/src/gep/candidates.js +1 -1
  27. package/src/gep/contentHash.js +1 -1
  28. package/src/gep/crypto.js +1 -1
  29. package/src/gep/curriculum.js +1 -1
  30. package/src/gep/deviceId.js +1 -1
  31. package/src/gep/directoryClient.js +4 -3
  32. package/src/gep/envFingerprint.js +1 -1
  33. package/src/gep/epigenetics.js +1 -1
  34. package/src/gep/explore.js +1 -1
  35. package/src/gep/hash.js +1 -1
  36. package/src/gep/hubFetch.js +1 -0
  37. package/src/gep/hubReview.js +1 -1
  38. package/src/gep/hubSearch.js +1 -1
  39. package/src/gep/hubVerify.js +1 -1
  40. package/src/gep/learningSignals.js +1 -1
  41. package/src/gep/memoryGraph.js +1 -1
  42. package/src/gep/memoryGraphAdapter.js +1 -1
  43. package/src/gep/mutation.js +1 -1
  44. package/src/gep/narrativeMemory.js +1 -1
  45. package/src/gep/openPRRegistry.js +1 -1
  46. package/src/gep/personality.js +1 -1
  47. package/src/gep/policyCheck.js +1 -1
  48. package/src/gep/prompt.js +1 -1
  49. package/src/gep/recallVerifier.js +1 -1
  50. package/src/gep/reflection.js +1 -1
  51. package/src/gep/schemas/gene.js +70 -1
  52. package/src/gep/schemas/protocol.js +9 -1
  53. package/src/gep/selector.js +1 -1
  54. package/src/gep/selfPR.js +62 -32
  55. package/src/gep/skillDistiller.js +1 -1
  56. package/src/gep/skillPublisher.js +3 -2
  57. package/src/gep/solidify.js +1 -1
  58. package/src/gep/strategy.js +1 -1
  59. package/src/gep/taskReceiver.js +6 -5
  60. package/src/gep/validator/index.js +10 -6
  61. package/src/gep/validator/reporter.js +2 -1
  62. package/src/gep/validator/stakeBootstrap.js +2 -1
  63. package/src/proxy/index.js +69 -0
  64. package/src/proxy/lifecycle/manager.js +3 -2
  65. package/src/proxy/router/cache_passthrough.js +26 -0
  66. package/src/proxy/router/features.js +84 -0
  67. package/src/proxy/router/messages_route.js +242 -0
  68. package/src/proxy/router/model_router.js +113 -0
  69. package/src/proxy/server/http.js +92 -5
  70. package/src/proxy/server/routes.js +12 -2
  71. package/src/proxy/server/settings.js +37 -11
  72. package/src/proxy/sync/inbound.js +3 -2
  73. package/src/proxy/sync/outbound.js +2 -1
package/src/gep/selfPR.js CHANGED
@@ -14,7 +14,7 @@ const { execSync } = require('child_process');
14
14
  // on large repos). See GHSA reports / issue #451.
15
15
  const MAX_EXEC_BUFFER = 10 * 1024 * 1024;
16
16
 
17
- const { getEvolutionDir, getRepoRoot } = require('./paths');
17
+ const { getEvolutionDir, getRepoRoot, getEvolverInstallRoot } = require('./paths');
18
18
  const { fullLeakCheck, redactString } = require('./sanitize');
19
19
  const {
20
20
  SELF_PR_MIN_SCORE,
@@ -28,35 +28,52 @@ const {
28
28
 
29
29
  const STATE_FILE = 'self_pr_state.json';
30
30
 
31
- // Files obfuscated in public.manifest.json -- PRs touching these are meaningless.
32
- const OBFUSCATED_FILES = new Set([
33
- 'src/evolve.js',
34
- 'src/gep/selector.js',
35
- 'src/gep/mutation.js',
36
- 'src/gep/solidify.js',
37
- 'src/gep/prompt.js',
38
- 'src/gep/candidates.js',
39
- 'src/gep/reflection.js',
40
- 'src/gep/narrativeMemory.js',
41
- 'src/gep/curriculum.js',
42
- 'src/gep/personality.js',
43
- 'src/gep/learningSignals.js',
44
- 'src/gep/memoryGraph.js',
45
- 'src/gep/memoryGraphAdapter.js',
46
- 'src/gep/strategy.js',
47
- 'src/gep/candidateEval.js',
48
- 'src/gep/hubVerify.js',
49
- 'src/gep/crypto.js',
50
- 'src/gep/contentHash.js',
51
- 'src/gep/a2aProtocol.js',
52
- 'src/gep/hubSearch.js',
53
- 'src/gep/hubReview.js',
54
- 'src/gep/policyCheck.js',
55
- 'src/gep/deviceId.js',
56
- 'src/gep/envFingerprint.js',
57
- 'src/gep/skillDistiller.js',
58
- 'src/gep/explore.js',
59
- ]);
31
+ // Files obfuscated in public.manifest.json -- PRs touching these would land
32
+ // raw source on the public repo where the file ships obfuscated, leaking
33
+ // implementation detail. Source of truth: public.manifest.json `obfuscate`
34
+ // array, loaded lazily on first use.
35
+ //
36
+ // public.manifest.json is itself excluded from the npm package (it's a
37
+ // build-time artifact for the obfuscation pipeline), so on npm installs the
38
+ // file is absent. That is expected — self-PR is dev-only (gated by
39
+ // EVOLVER_SELF_PR=true) and a missing manifest correctly produces the
40
+ // fail-safe behavior (reject all files). We therefore stay silent on load
41
+ // failure here and only surface a warning when maybeCreatePR is actually
42
+ // invoked but the manifest cannot be read.
43
+ let _obfuscatedFilesCache; // undefined = not loaded; Set | null after first attempt
44
+ let _manifestLoadError = null;
45
+ let _warnedAboutMissingManifest = false;
46
+
47
+ function loadObfuscatedFromManifest() {
48
+ if (_obfuscatedFilesCache !== undefined) return _obfuscatedFilesCache;
49
+ try {
50
+ const manifestPath = path.join(getEvolverInstallRoot(), 'public.manifest.json');
51
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
52
+ if (!Array.isArray(manifest.obfuscate)) {
53
+ throw new Error('public.manifest.json missing `obfuscate` array');
54
+ }
55
+ // Reject glob patterns: build_public.js may expand them, but Set.has(rel)
56
+ // would silently miss matches and reintroduce the drift this PR fixed.
57
+ for (const f of manifest.obfuscate) {
58
+ if (typeof f !== 'string' || /[*?[\]]/.test(f)) {
59
+ throw new Error('public.manifest.json `obfuscate` must contain literal paths, got: ' + JSON.stringify(f));
60
+ }
61
+ }
62
+ _obfuscatedFilesCache = new Set(manifest.obfuscate.map((f) => f.replace(/\\/g, '/').replace(/^\.\/+/, '')));
63
+ } catch (e) {
64
+ _manifestLoadError = e.message;
65
+ _obfuscatedFilesCache = null;
66
+ }
67
+ return _obfuscatedFilesCache;
68
+ }
69
+
70
+ // Test-only: reset the lazy cache so a test can exercise the load path
71
+ // (e.g. cover the fail-safe branch after a missing manifest is restored).
72
+ function _resetObfuscatedCache() {
73
+ _obfuscatedFilesCache = undefined;
74
+ _manifestLoadError = null;
75
+ _warnedAboutMissingManifest = false;
76
+ }
60
77
 
61
78
  // Files that are included in the public manifest (superset patterns).
62
79
  const PUBLIC_INCLUDE_PREFIXES = ['src/', 'scripts/'];
@@ -70,7 +87,9 @@ function normalizeRel(filePath) {
70
87
  function isPublicNonObfuscated(filePath) {
71
88
  const rel = normalizeRel(filePath);
72
89
  if (!rel) return false;
73
- if (OBFUSCATED_FILES.has(rel)) return false;
90
+ const obfuscated = loadObfuscatedFromManifest();
91
+ if (obfuscated === null) return false; // fail-safe when manifest is unreadable
92
+ if (obfuscated.has(rel)) return false;
74
93
  for (const excl of PUBLIC_EXCLUDE_PREFIXES) {
75
94
  if (rel.startsWith(excl)) return false;
76
95
  }
@@ -244,6 +263,16 @@ function getGitDiff(changedFiles, repoRoot) {
244
263
  async function maybeCreatePR({ capsule, event, mutation, gene, blastRadius }) {
245
264
  if (String(process.env.EVOLVER_SELF_PR || '').toLowerCase() !== 'true') return null;
246
265
 
266
+ // User has explicitly opted into self-PR. Ensure we have the obfuscate
267
+ // list so we don't accidentally leak obfuscated source via a "non-obf" PR.
268
+ if (loadObfuscatedFromManifest() === null) {
269
+ if (!_warnedAboutMissingManifest) {
270
+ console.warn('[SelfPR] public.manifest.json not found at ' + getEvolverInstallRoot() + ' — rejecting all self-PRs (manifest is required to identify obfuscated files). Error: ' + _manifestLoadError);
271
+ _warnedAboutMissingManifest = true;
272
+ }
273
+ return null;
274
+ }
275
+
247
276
  const score = capsule && capsule.outcome ? (capsule.outcome.score || 0) : 0;
248
277
  const streak = capsule ? (capsule.success_streak || 0) : 0;
249
278
 
@@ -402,5 +431,6 @@ module.exports = {
402
431
  writeState,
403
432
  recordPR,
404
433
  // For testing
405
- _OBFUSCATED_FILES: OBFUSCATED_FILES,
434
+ _loadObfuscatedFromManifest: loadObfuscatedFromManifest,
435
+ _resetObfuscatedCache,
406
436
  };