thumbgate 1.39.1 → 1.40.2

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 (199) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.well-known/llms.txt +2 -2
  3. package/.well-known/mcp/server-card.json +1 -1
  4. package/README.md +5 -4
  5. package/adapters/claude/.mcp.json +6 -2
  6. package/adapters/codex/config.toml +5 -0
  7. package/adapters/forge/forge.yaml +4 -4
  8. package/adapters/future-agi/.mcp.json +1 -1
  9. package/adapters/future-agi/config.toml +1 -1
  10. package/adapters/future-agi/opencode.json +1 -1
  11. package/adapters/herdr/herdr-plugin.toml +2 -2
  12. package/adapters/mcp/server-stdio.js +82 -7
  13. package/adapters/opencode/opencode.json +1 -1
  14. package/bin/cli.js +128 -15
  15. package/config/brand-standards.json +131 -0
  16. package/config/gates/default.json +18 -1
  17. package/config/github-about.json +1 -1
  18. package/config/mcp-allowlists.json +16 -3
  19. package/config/merge-quality-checks.json +1 -0
  20. package/config/post-deploy-marketing-pages.json +3 -3
  21. package/config/schemas/task-outcome-receipt.schema.json +9 -0
  22. package/openapi/openapi.yaml +7 -3
  23. package/package.json +98 -31
  24. package/public/about.html +2 -2
  25. package/public/admin.html +771 -0
  26. package/public/agent-manager.html +3 -3
  27. package/public/agents-cost-savings.html +1 -1
  28. package/public/ai-malpractice-prevention.html +12 -12
  29. package/public/architecture.html +0 -1
  30. package/public/assets/diagrams/decision.svg +3 -3
  31. package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
  32. package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
  33. package/public/blog/git-at-agent-scale.html +2 -2
  34. package/public/blog/inside-your-boundary.html +1 -1
  35. package/public/blog/process-over-outcome-gates.html +1 -1
  36. package/public/case-studies.html +1 -2
  37. package/public/codex-enterprise.html +1 -1
  38. package/public/codex-plugin.html +1 -1
  39. package/public/dashboard.html +773 -481
  40. package/public/diagnostic.html +8 -3
  41. package/public/enterprise-governance.html +26 -174
  42. package/public/eval-scorecard.html +3 -4
  43. package/public/eval-scorecard.json +2 -2
  44. package/public/evaluations.html +0 -1
  45. package/public/founders.html +3 -3
  46. package/public/gaming-playbook.html +4 -4
  47. package/public/guide.html +3 -5
  48. package/public/index.html +181 -205
  49. package/public/install.html +12 -11
  50. package/public/js/buyer-intent.js +49 -8
  51. package/public/lessons.html +103 -46
  52. package/public/numbers.html +32 -33
  53. package/public/operator-framework.html +44 -72
  54. package/public/peter.html +3 -3
  55. package/public/platform-partners.html +1 -1
  56. package/public/pricing.html +61 -327
  57. package/public/pro.html +3 -1
  58. package/public/project-switcher.js +76 -0
  59. package/public/whitepaper.html +1 -2
  60. package/scripts/activation-quickstart.js +15 -3
  61. package/scripts/activation-tracker.js +280 -3
  62. package/scripts/agent-action-inventory.js +235 -143
  63. package/scripts/agent-operations-planner.js +1 -1
  64. package/scripts/agent-readiness.js +36 -6
  65. package/scripts/agentic-prompt-pipelines.js +901 -0
  66. package/scripts/analytics-report.js +363 -0
  67. package/scripts/analytics-window.js +7 -1
  68. package/scripts/async-job-runner.js +66 -11
  69. package/scripts/audit-trail.js +37 -24
  70. package/scripts/auto-context-packs.js +249 -0
  71. package/scripts/auto-promote-gates.js +37 -27
  72. package/scripts/backfill-lesson-scopes.js +122 -0
  73. package/scripts/billing-setup.js +137 -0
  74. package/scripts/billing.js +889 -132
  75. package/scripts/bot-detection.js +112 -0
  76. package/scripts/brand-standards-gate.js +571 -0
  77. package/scripts/chatgpt-ads-readiness-pack.js +1 -1
  78. package/scripts/check-update.js +236 -0
  79. package/scripts/cli-schema.js +1 -1
  80. package/scripts/commercial-offer.js +2 -2
  81. package/scripts/contextfs.js +9 -3
  82. package/scripts/conversion-rate-stats.js +442 -0
  83. package/scripts/cost-cli.js +147 -0
  84. package/scripts/creator-campaigns.js +239 -0
  85. package/scripts/cross-encoder-reranker.js +4 -0
  86. package/scripts/cuda-gate-batch.js +560 -0
  87. package/scripts/daemon-manager.js +108 -0
  88. package/scripts/dashboard-chat.js +11 -0
  89. package/scripts/dashboard.js +576 -169
  90. package/scripts/decision-journal.js +7 -4
  91. package/scripts/delegation-runtime.js +1036 -0
  92. package/scripts/dispatch-brief.js +159 -0
  93. package/scripts/distribution-surfaces.js +110 -0
  94. package/scripts/docker-sandbox-planner.js +3 -3
  95. package/scripts/egm-goldfish-packet.js +95 -0
  96. package/scripts/embeddinggemma-adapter.js +407 -0
  97. package/scripts/export-dpo-pairs.js +12 -7
  98. package/scripts/feedback-aggregate.js +4 -0
  99. package/scripts/feedback-attribution.js +6 -4
  100. package/scripts/feedback-history-distiller.js +18 -6
  101. package/scripts/feedback-loop.js +255 -89
  102. package/scripts/feedback-paths.js +8 -1
  103. package/scripts/feedback-sanitizer.js +5 -0
  104. package/scripts/feedback-scope.js +106 -0
  105. package/scripts/feedback-session.js +8 -2
  106. package/scripts/filesystem-search.js +13 -8
  107. package/scripts/financial-control-plane.js +707 -45
  108. package/scripts/funnel-analytics.js +35 -0
  109. package/scripts/gate-semantic-layer.js +292 -0
  110. package/scripts/gate-stats.js +8 -2
  111. package/scripts/gates-engine.js +694 -230
  112. package/scripts/generate-eval-scorecard.js +0 -1
  113. package/scripts/harness-tool-names.js +31 -5
  114. package/scripts/hybrid-feedback-context.js +5 -2
  115. package/scripts/implementation-notes.js +241 -0
  116. package/scripts/intent-router.js +518 -0
  117. package/scripts/intervention-policy.js +2 -1
  118. package/scripts/latency-budget.js +164 -0
  119. package/scripts/lesson-canonical.js +2 -2
  120. package/scripts/lesson-db.js +55 -14
  121. package/scripts/lesson-graph.js +2 -1
  122. package/scripts/lesson-retrieval.js +95 -9
  123. package/scripts/lesson-search.js +86 -22
  124. package/scripts/lesson-synthesis.js +21 -5
  125. package/scripts/mailer/index.js +17 -1
  126. package/scripts/mailer/resend-mailer.js +213 -179
  127. package/scripts/mcp-writeguard.js +158 -0
  128. package/scripts/migrate-project-scope.js +209 -0
  129. package/scripts/model-candidates.js +414 -0
  130. package/scripts/openrouter-armor-partnership-diode.js +2419 -0
  131. package/scripts/operational-dashboard.js +172 -0
  132. package/scripts/operational-integrity.js +436 -3
  133. package/scripts/operational-summary.js +190 -0
  134. package/scripts/operator-artifacts.js +622 -0
  135. package/scripts/optimize-context.js +17 -0
  136. package/scripts/override-audit.js +2 -0
  137. package/scripts/owner-admin.js +338 -0
  138. package/scripts/pr-manager.js +194 -1
  139. package/scripts/predictive-insights.js +449 -0
  140. package/scripts/profound-aeo-citation-engine.js +583 -0
  141. package/scripts/progressive-signoff.js +260 -0
  142. package/scripts/project-catalog.js +243 -0
  143. package/scripts/project-dashboard.js +61 -0
  144. package/scripts/project-evidence.js +172 -0
  145. package/scripts/project-identity.js +182 -0
  146. package/scripts/project-scope.js +381 -0
  147. package/scripts/prompt-guard.js +446 -52
  148. package/scripts/proof-report.js +232 -0
  149. package/scripts/provider-action-normalizer.js +14 -6
  150. package/scripts/pulse.js +80 -0
  151. package/scripts/rate-limiter.js +41 -0
  152. package/scripts/rrsi-doctor.js +2698 -0
  153. package/scripts/secret-redaction.js +171 -25
  154. package/scripts/secret-scanner.js +101 -42
  155. package/scripts/self-protection.js +2 -2
  156. package/scripts/seo-gsd.js +14 -14
  157. package/scripts/session-context-dedupe.js +66 -0
  158. package/scripts/session-report.js +120 -0
  159. package/scripts/settings-hierarchy.js +4 -2
  160. package/scripts/statusline-meta.js +34 -23
  161. package/scripts/subagent-profiles.js +79 -0
  162. package/scripts/task-outcomes.js +29 -2
  163. package/scripts/telemetry-analytics.js +238 -13
  164. package/scripts/third-author-cli.js +118 -0
  165. package/scripts/third-author-governance.js +437 -0
  166. package/scripts/thumbgate-dream.js +878 -0
  167. package/scripts/thumbgate-search.js +23 -9
  168. package/scripts/tool-kpi-tracker.js +5 -2
  169. package/scripts/tool-registry.js +42 -1
  170. package/scripts/triage-savings-calculator.js +1 -1
  171. package/scripts/vector-store.js +4 -1
  172. package/scripts/verified-lessons.js +270 -0
  173. package/scripts/verify-marketing-pages-deployed.js +2 -2
  174. package/scripts/workflow-sentinel.js +29 -10
  175. package/server.json +2 -2
  176. package/skills/thumbgate-daily-discoveries/SKILL.md +25 -41
  177. package/src/api/server.js +2371 -451
  178. package/src/feedback.js +21 -0
  179. package/src/hermes-sync-plane.js +2 -1
  180. package/src/index.js +2 -0
  181. package/src/lesson-search.js +9 -0
  182. package/src/mckinsey-top-company-ai-coding.js +493 -0
  183. package/src/mcp/server.js +3 -0
  184. package/src/mcp-writeguard.js +772 -11
  185. package/src/openshell-lovable-engine.js +1475 -0
  186. package/src/task-outcome.js +3 -0
  187. package/config/evals/agent-safety-eval.json +0 -447
  188. package/config/evals/retrieval-ranking-golden.json +0 -522
  189. package/config/progressive/01-wire-only.json +0 -11
  190. package/config/progressive/02-dashboard-empty-ok.json +0 -10
  191. package/config/progressive/03-one-lesson.json +0 -10
  192. package/config/progressive/04-warn-fires.json +0 -11
  193. package/config/progressive/05-strict-optional.json +0 -11
  194. package/config/progressive/README.md +0 -15
  195. package/public/assets/diagrams/agent-integration.png +0 -0
  196. package/public/assets/diagrams/thumbgate-architecture.png +0 -0
  197. package/scripts/install-thumbgate-daily-publish-launchd.sh +0 -83
  198. package/scripts/thumbgate-daily-discoveries-publish.js +0 -461
  199. package/scripts/thumbgate-daily-discoveries-publish.sh +0 -18
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ const { tenantDataScope, assertScopedDataPath } = require('./feedback-scope');
5
+
4
6
  const fs = require('fs');
5
7
  const os = require('os');
6
8
  const path = require('path');
@@ -9,7 +11,7 @@ const PROJECT_ROOT = path.join(__dirname, '..');
9
11
  const HOME = process.env.HOME || process.env.USERPROFILE || os.homedir() || '';
10
12
 
11
13
  function buildFeedbackPathsFromDir(dirPath) {
12
- return {
14
+ const paths = {
13
15
  FEEDBACK_DIR: dirPath,
14
16
  FEEDBACK_LOG_PATH: path.join(dirPath, 'feedback-log.jsonl'),
15
17
  DIAGNOSTIC_LOG_PATH: path.join(dirPath, 'diagnostic-log.jsonl'),
@@ -18,6 +20,8 @@ function buildFeedbackPathsFromDir(dirPath) {
18
20
  SUMMARY_PATH: path.join(dirPath, 'feedback-summary.json'),
19
21
  PREVENTION_RULES_PATH: path.join(dirPath, 'prevention-rules.md'),
20
22
  };
23
+ if (tenantDataScope()) for (const value of Object.values(paths)) assertScopedDataPath(value);
24
+ return paths;
21
25
  }
22
26
 
23
27
  function uniquePaths(paths = []) {
@@ -216,6 +220,8 @@ function getGlobalFeedbackDir(options = {}) {
216
220
  }
217
221
 
218
222
  function resolveFeedbackDir(options = {}) {
223
+ const scope = tenantDataScope();
224
+ if (scope) return options.feedbackDir ? assertScopedDataPath(options.feedbackDir) : assertScopedDataPath(scope.feedbackDir);
219
225
  const explicit = getExplicitFeedbackDir(options);
220
226
  if (explicit) return explicit;
221
227
 
@@ -248,6 +254,7 @@ function getFeedbackPaths(options = {}) {
248
254
  }
249
255
 
250
256
  function listFallbackFeedbackDirs(options = {}) {
257
+ if (tenantDataScope()) return [];
251
258
  const activeDir = path.resolve(resolveFeedbackDir(options));
252
259
  return uniquePaths([
253
260
  getFallbackFeedbackDir(options),
@@ -110,6 +110,11 @@ function looksLikeTransportBlob(text) {
110
110
  const trimmed = String(text || '').trim();
111
111
  if (!trimmed) return false;
112
112
 
113
+ // Transcript XML tags from runner envelopes must never be stored as lessons
114
+ if (/<\s*task-notification\b|<\s*tool-use-id\b|<\s*output-file\b|<\s*task-id\b/i.test(trimmed)) {
115
+ return true;
116
+ }
117
+
113
118
  if (hasTransportJsonKey(trimmed)) return true;
114
119
 
115
120
  // Multiple marker names identify non-JSON transport residue. A human
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ const { AsyncLocalStorage } = require('node:async_hooks');
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+
7
+ const storage = new AsyncLocalStorage();
8
+
9
+ function existingRealPath(candidate) {
10
+ let current = path.resolve(candidate);
11
+ const missing = [];
12
+ while (!fs.existsSync(current)) {
13
+ try {
14
+ if (fs.lstatSync(current).isSymbolicLink()) throw scopeError('Tenant scope cannot follow a dangling symbolic link');
15
+ } catch (error) { if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') throw error; }
16
+ const parent = path.dirname(current);
17
+ if (parent === current) break;
18
+ missing.unshift(path.basename(current));
19
+ current = parent;
20
+ }
21
+ return path.join(fs.realpathSync(current), ...missing);
22
+ }
23
+
24
+ function scopeError(message) {
25
+ const error = new Error(message);
26
+ error.statusCode = 400;
27
+ return error;
28
+ }
29
+
30
+ function withDataScope(scope, callback) {
31
+ if (!scope || !['tenant', 'legacy'].includes(scope.kind) || !path.isAbsolute(scope.feedbackDir || '')) {
32
+ throw scopeError('Invalid trusted data scope');
33
+ }
34
+ if (scope.kind === 'tenant' && !scope.tenantId) throw scopeError('Tenant scope requires an authenticated identity');
35
+ if (scope.kind === 'tenant' && fs.existsSync(scope.feedbackDir) && fs.lstatSync(scope.feedbackDir).isSymbolicLink()) {
36
+ throw scopeError('Tenant data root cannot be a symbolic link');
37
+ }
38
+ const frozen = Object.freeze({
39
+ kind: scope.kind,
40
+ tenantId: scope.tenantId || null,
41
+ principalId: scope.principalId || null,
42
+ feedbackDir: existingRealPath(scope.feedbackDir),
43
+ lexicalRoot: path.resolve(scope.feedbackDir),
44
+ });
45
+ return storage.run(frozen, callback);
46
+ }
47
+
48
+ function withoutDataScope(callback) {
49
+ return storage.exit(callback);
50
+ }
51
+
52
+ function currentDataScope() {
53
+ return storage.getStore() || null;
54
+ }
55
+
56
+ function tenantDataScope() {
57
+ const scope = currentDataScope();
58
+ return scope?.kind === 'tenant' ? scope : null;
59
+ }
60
+
61
+ function assertScopedDataPath(candidate) {
62
+ const resolved = path.resolve(String(candidate || ''));
63
+ const scope = tenantDataScope();
64
+ if (!scope) return resolved;
65
+ const inside = (value, root = scope.feedbackDir) => value === root || value.startsWith(root + path.sep);
66
+ if ((!inside(resolved) && !inside(resolved, scope.lexicalRoot)) || !inside(existingRealPath(resolved))) {
67
+ throw scopeError('Path must stay within the authenticated tenant scope');
68
+ }
69
+ return resolved;
70
+ }
71
+
72
+ function scopedStatePath(legacyPath) {
73
+ const scope = tenantDataScope();
74
+ return scope ? assertScopedDataPath(path.join(scope.feedbackDir, path.basename(legacyPath))) : legacyPath;
75
+ }
76
+
77
+ function dataScopeKey() {
78
+ const scope = currentDataScope();
79
+ return scope ? `${scope.kind}:${scope.feedbackDir}` : 'legacy';
80
+ }
81
+
82
+ function restrictedWorkerEnv(scope = tenantDataScope()) {
83
+ if (!scope) return process.env;
84
+ const env = {};
85
+ for (const key of ['PATH', 'LANG', 'LC_ALL', 'TZ', 'SYSTEMROOT']) {
86
+ if (process.env[key]) env[key] = process.env[key];
87
+ }
88
+ return {
89
+ ...env,
90
+ HOME: scope.feedbackDir,
91
+ THUMBGATE_FEEDBACK_DIR: scope.feedbackDir,
92
+ THUMBGATE_DISABLE_TELEMETRY: '1',
93
+ THUMBGATE_WORKER_SCOPE: JSON.stringify(scope),
94
+ };
95
+ }
96
+
97
+ module.exports = {
98
+ withDataScope,
99
+ withoutDataScope,
100
+ currentDataScope,
101
+ tenantDataScope,
102
+ assertScopedDataPath,
103
+ scopedStatePath,
104
+ dataScopeKey,
105
+ restrictedWorkerEnv,
106
+ };
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ const { dataScopeKey } = require('./feedback-scope');
5
+
4
6
  /**
5
7
  * Feedback Sessions
6
8
  *
@@ -54,6 +56,7 @@ function openSession(feedbackEventId, signal, initialContext) {
54
56
 
55
57
  const session = {
56
58
  sessionId,
59
+ scopeKey: dataScopeKey(),
57
60
  feedbackEventId,
58
61
  signal,
59
62
  initialContext: initialContext || '',
@@ -82,6 +85,7 @@ function openSession(feedbackEventId, signal, initialContext) {
82
85
  */
83
86
  function appendToSession(sessionId, message, role = 'user') {
84
87
  const session = activeSessions.get(sessionId);
88
+ if (session && session.scopeKey !== dataScopeKey()) return { status: 'not_found' };
85
89
  if (!session) {
86
90
  return { status: 'not_found', message: `No active session: ${sessionId}` };
87
91
  }
@@ -113,6 +117,7 @@ function appendToSession(sessionId, message, role = 'user') {
113
117
  */
114
118
  function finalizeSession(sessionId) {
115
119
  const session = activeSessions.get(sessionId);
120
+ if (session && session.scopeKey !== dataScopeKey()) return { status: 'not_found' };
116
121
  if (!session) {
117
122
  return { status: 'not_found' };
118
123
  }
@@ -253,7 +258,8 @@ function isGeneralFrustration(content) {
253
258
  * Get an active session by ID
254
259
  */
255
260
  function getSession(sessionId) {
256
- return activeSessions.get(sessionId) || null;
261
+ const session = activeSessions.get(sessionId);
262
+ return session?.scopeKey === dataScopeKey() ? session : null;
257
263
  }
258
264
 
259
265
  /**
@@ -261,7 +267,7 @@ function getSession(sessionId) {
261
267
  */
262
268
  function getActiveSession() {
263
269
  for (const [, session] of activeSessions) {
264
- if (session.status === 'open') return session;
270
+ if (session.scopeKey === dataScopeKey() && session.status === 'open') return session;
265
271
  }
266
272
  return null;
267
273
  }
@@ -16,6 +16,7 @@
16
16
  * - Data is always the JSONL source of truth (no sync drift)
17
17
  */
18
18
 
19
+ const { tenantDataScope, assertScopedDataPath } = require('./feedback-scope');
19
20
  const fs = require('node:fs');
20
21
  const path = require('node:path');
21
22
  const crypto = require('node:crypto');
@@ -35,15 +36,17 @@ function getFeedbackDir() {
35
36
  }
36
37
 
37
38
  function getContextFsDir() {
39
+ if (tenantDataScope()) return assertScopedDataPath(path.join(tenantDataScope().feedbackDir, 'contextfs'));
38
40
  return process.env.THUMBGATE_CONTEXTFS_DIR || path.join(getFeedbackDir(), 'contextfs');
39
41
  }
40
42
 
41
43
  function listJsonFiles(dirPath) {
44
+ assertScopedDataPath(dirPath);
42
45
  if (!fs.existsSync(dirPath)) return [];
43
46
  const results = [];
44
47
  const entries = fs.readdirSync(dirPath, { withFileTypes: true });
45
48
  for (const entry of entries) {
46
- const full = path.join(dirPath, entry.name);
49
+ const full = assertScopedDataPath(path.join(dirPath, entry.name));
47
50
  if (entry.isDirectory()) {
48
51
  results.push(...listJsonFiles(full));
49
52
  } else if (entry.isFile() && entry.name.endsWith('.json')) {
@@ -155,14 +158,16 @@ function scoreRecord(queryTokens, queryText, record) {
155
158
 
156
159
  function searchFeedbackLog(queryText, limit = 5, options = {}) {
157
160
  const feedbackDir = options.feedbackDir || getFeedbackDir();
158
- const logPath = path.join(feedbackDir, 'feedback-log.jsonl');
159
- let records = readJsonl(logPath);
161
+ const logPath = assertScopedDataPath(path.join(feedbackDir, 'feedback-log.jsonl'));
162
+ let records = require('./project-catalog').readProjectRows(feedbackDir, 'feedback-log.jsonl', options);
163
+ if (options.includeMemories) records.push(...require('./project-catalog').readProjectRows(feedbackDir, 'memory-log.jsonl', options).map((row) => ({ ...row, context: row.context || row.content || row.title, _kind: 'memory' })));
164
+ if (options.signal) records = records.filter((row) => require('./project-identity').matchesProject(row, options.projectKey) && (row.signal === options.signal || (options.signal === 'up' && row.signal === 'positive') || (options.signal === 'down' && row.signal === 'negative')));
160
165
 
161
166
  // SQLite fallback is allowed only inside the exact selected feedback root.
162
167
  // Falling back through lesson-db's ambient default can cross project/tenant
163
168
  // boundaries when a sparse project has zero or one JSONL row.
164
- const lessonDbPath = path.join(feedbackDir, 'lessons.sqlite');
165
- if (records.length <= 1 && fs.existsSync(lessonDbPath)) {
169
+ const lessonDbPath = assertScopedDataPath(path.join(feedbackDir, 'lessons.sqlite'));
170
+ if (options.projectKey == null && records.length <= 1 && fs.existsSync(lessonDbPath)) {
166
171
  let db = null;
167
172
  try {
168
173
  const { initDB } = require('./lesson-db');
@@ -221,13 +226,13 @@ function searchFeedbackLog(queryText, limit = 5, options = {}) {
221
226
  }
222
227
 
223
228
  function searchContextFs(queryText, limit = 5, options = {}) {
224
- const contextDir = options.contextDir || (options.feedbackDir ? path.join(options.feedbackDir, 'contextfs') : getContextFsDir());
229
+ const contextDir = assertScopedDataPath(options.contextDir || (options.feedbackDir ? path.join(options.feedbackDir, 'contextfs') : getContextFsDir()));
225
230
  const namespaces = options.namespaces || ['memory/error', 'memory/learning', 'rules', 'raw_history'];
226
231
  const queryTokens = getSearchTokens(queryText);
227
232
  const scored = [];
228
233
 
229
234
  for (const ns of namespaces) {
230
- const nsDir = path.join(contextDir, ns);
235
+ const nsDir = assertScopedDataPath(path.join(contextDir, ns));
231
236
  const files = listJsonFiles(nsDir);
232
237
 
233
238
  for (const filePath of files) {
@@ -257,7 +262,7 @@ function searchContextFs(queryText, limit = 5, options = {}) {
257
262
  }
258
263
 
259
264
  function searchPreventionRules(queryText, limit = 5, options = {}) {
260
- const rulesPath = path.join(options.feedbackDir || getFeedbackDir(), 'prevention-rules.md');
265
+ const rulesPath = assertScopedDataPath(path.join(options.feedbackDir || getFeedbackDir(), 'prevention-rules.md'));
261
266
  if (!fs.existsSync(rulesPath)) return [];
262
267
 
263
268
  const content = fs.readFileSync(rulesPath, 'utf-8');