thumbgate 1.4.3 → 1.4.5

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 (270) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.well-known/llms.txt +12 -8
  4. package/.well-known/mcp/server-card.json +1 -1
  5. package/README.md +18 -8
  6. package/adapters/README.md +1 -1
  7. package/adapters/claude/.mcp.json +2 -2
  8. package/adapters/codex/config.toml +2 -2
  9. package/adapters/mcp/server-stdio.js +1 -1
  10. package/adapters/opencode/opencode.json +1 -1
  11. package/config/github-about.json +2 -2
  12. package/package.json +158 -10
  13. package/scripts/billing.js +5 -2
  14. package/scripts/statusline.sh +1 -0
  15. package/src/api/server.js +113 -16
  16. package/src/index.js +3 -0
  17. package/.claude-plugin/bundle/icon.png +0 -0
  18. package/.claude-plugin/bundle/icon.svg +0 -18
  19. package/.claude-plugin/bundle/server/index.js +0 -24
  20. package/adapters/chatgpt/INSTALL.md +0 -158
  21. package/adapters/perplexity/.mcp.json +0 -36
  22. package/adapters/perplexity/config.toml +0 -16
  23. package/adapters/perplexity/opencode.json +0 -29
  24. package/bin/memory.sh +0 -64
  25. package/bin/obsidian-sync.sh +0 -20
  26. package/plugins/amp-skill/INSTALL.md +0 -52
  27. package/plugins/amp-skill/SKILL.md +0 -64
  28. package/plugins/claude-codex-bridge/.claude-plugin/plugin.json +0 -22
  29. package/plugins/claude-codex-bridge/.mcp.json +0 -14
  30. package/plugins/claude-codex-bridge/INSTALL.md +0 -43
  31. package/plugins/claude-codex-bridge/README.md +0 -46
  32. package/plugins/claude-codex-bridge/scripts/codex-bridge.js +0 -286
  33. package/plugins/claude-codex-bridge/skills/adversarial-review/SKILL.md +0 -24
  34. package/plugins/claude-codex-bridge/skills/result/SKILL.md +0 -22
  35. package/plugins/claude-codex-bridge/skills/review/SKILL.md +0 -28
  36. package/plugins/claude-codex-bridge/skills/second-pass/SKILL.md +0 -27
  37. package/plugins/claude-codex-bridge/skills/setup/SKILL.md +0 -21
  38. package/plugins/claude-codex-bridge/skills/status/SKILL.md +0 -19
  39. package/plugins/claude-skill/INSTALL.md +0 -55
  40. package/plugins/claude-skill/SKILL.md +0 -46
  41. package/plugins/codex-profile/.codex-plugin/plugin.json +0 -43
  42. package/plugins/codex-profile/.mcp.json +0 -14
  43. package/plugins/codex-profile/AGENTS.md +0 -20
  44. package/plugins/codex-profile/INSTALL.md +0 -89
  45. package/plugins/codex-profile/README.md +0 -61
  46. package/plugins/cursor-marketplace/.cursor-plugin/plugin.json +0 -23
  47. package/plugins/cursor-marketplace/CHANGELOG.md +0 -30
  48. package/plugins/cursor-marketplace/LICENSE +0 -21
  49. package/plugins/cursor-marketplace/README.md +0 -124
  50. package/plugins/cursor-marketplace/agents/reliability-reviewer.md +0 -31
  51. package/plugins/cursor-marketplace/assets/logo-400x400.png +0 -0
  52. package/plugins/cursor-marketplace/commands/capture-feedback.md +0 -33
  53. package/plugins/cursor-marketplace/commands/check-gates.md +0 -25
  54. package/plugins/cursor-marketplace/commands/show-lessons.md +0 -27
  55. package/plugins/cursor-marketplace/hooks/hooks.json +0 -10
  56. package/plugins/cursor-marketplace/mcp.json +0 -14
  57. package/plugins/cursor-marketplace/rules/feedback-capture.mdc +0 -34
  58. package/plugins/cursor-marketplace/rules/pre-action-gates.mdc +0 -30
  59. package/plugins/cursor-marketplace/rules/session-continuity.mdc +0 -28
  60. package/plugins/cursor-marketplace/scripts/gate-check.sh +0 -21
  61. package/plugins/cursor-marketplace/skills/capture-feedback/SKILL.md +0 -48
  62. package/plugins/cursor-marketplace/skills/prevention-rules/SKILL.md +0 -31
  63. package/plugins/cursor-marketplace/skills/recall-context/SKILL.md +0 -30
  64. package/plugins/cursor-marketplace/skills/search-lessons/SKILL.md +0 -33
  65. package/plugins/gemini-extension/INSTALL.md +0 -92
  66. package/plugins/gemini-extension/gemini_prompt.txt +0 -14
  67. package/plugins/gemini-extension/tool_contract.json +0 -45
  68. package/plugins/opencode-profile/INSTALL.md +0 -57
  69. package/public/assets/instagram-card.png +0 -0
  70. package/public/assets/tiktok-agent-memory.mp4 +0 -0
  71. package/public/blog.html +0 -474
  72. package/public/compare/mem0.html +0 -189
  73. package/public/compare/speclock.html +0 -180
  74. package/public/compare.html +0 -310
  75. package/public/dashboard.html +0 -1100
  76. package/public/guide.html +0 -317
  77. package/public/guides/claude-code-prevent-repeated-mistakes.html +0 -161
  78. package/public/guides/codex-cli-guardrails.html +0 -158
  79. package/public/guides/cursor-prevent-repeated-mistakes.html +0 -161
  80. package/public/guides/pre-action-gates.html +0 -162
  81. package/public/guides/stop-repeated-ai-agent-mistakes.html +0 -159
  82. package/public/index.html +0 -1225
  83. package/public/js/buyer-intent.js +0 -252
  84. package/public/learn/agent-harness-pattern.html +0 -180
  85. package/public/learn/ai-agent-persistent-memory.html +0 -203
  86. package/public/learn/learn.css +0 -45
  87. package/public/learn/mcp-pre-action-gates-explained.html +0 -172
  88. package/public/learn/stop-ai-agent-force-push.html +0 -134
  89. package/public/learn/vibe-coding-safety-net.html +0 -142
  90. package/public/learn.html +0 -274
  91. package/public/lessons.html +0 -967
  92. package/public/llm-context.md +0 -156
  93. package/public/pro.html +0 -1087
  94. package/public/vercel.json +0 -8
  95. package/scripts/a2ui-engine.js +0 -73
  96. package/scripts/adk-consolidator.js +0 -274
  97. package/scripts/agent-security-hardening.js +0 -225
  98. package/scripts/ai-search-visibility.js +0 -116
  99. package/scripts/autonomous-sales-agent.js +0 -39
  100. package/scripts/autoresearch-runner.js +0 -216
  101. package/scripts/background-agent-governance.js +0 -229
  102. package/scripts/behavioral-extraction.js +0 -93
  103. package/scripts/budget-enforcer.js +0 -173
  104. package/scripts/budget-guard.js +0 -173
  105. package/scripts/build-claude-mcpb.js +0 -255
  106. package/scripts/build-codex-plugin.js +0 -152
  107. package/scripts/capture-railway-diagnostics.sh +0 -97
  108. package/scripts/changeset-check.js +0 -372
  109. package/scripts/check-congruence.js +0 -443
  110. package/scripts/computer-use-firewall.js +0 -280
  111. package/scripts/content-engine/linkedin-content-generator.js +0 -154
  112. package/scripts/content-engine/output/linkedin-memento-validation.md +0 -17
  113. package/scripts/content-engine/output/linkedin-posts-2026-04-09.md +0 -175
  114. package/scripts/content-engine/reddit-thread-finder.js +0 -154
  115. package/scripts/context-engine.js +0 -710
  116. package/scripts/daily-digest.js +0 -11
  117. package/scripts/data-governance.js +0 -173
  118. package/scripts/deploy-gcp.sh +0 -44
  119. package/scripts/deploy-policy.js +0 -249
  120. package/scripts/disagreement-mining.js +0 -315
  121. package/scripts/dpo-optimizer.js +0 -206
  122. package/scripts/ensure-repo-bootstrap.js +0 -130
  123. package/scripts/ephemeral-agent-store.js +0 -212
  124. package/scripts/eval-harness.js +0 -56
  125. package/scripts/export-kto-pairs.js +0 -309
  126. package/scripts/export-training.js +0 -446
  127. package/scripts/feedback-fallback.js +0 -111
  128. package/scripts/feedback-inbox-read.js +0 -162
  129. package/scripts/feedback-root-consolidator.js +0 -233
  130. package/scripts/feedback-to-memory.js +0 -185
  131. package/scripts/gate-satisfy.js +0 -42
  132. package/scripts/generate-paperbanana-diagrams.sh +0 -99
  133. package/scripts/generate-pretool-hook.sh +0 -40
  134. package/scripts/github-about.js +0 -430
  135. package/scripts/github-outreach.js +0 -65
  136. package/scripts/gtm-revenue-loop.js +0 -535
  137. package/scripts/hallucination-detector.js +0 -226
  138. package/scripts/hf-papers.js +0 -317
  139. package/scripts/hook-auto-capture.sh +0 -100
  140. package/scripts/hook-stop-pr-thread-check.sh +0 -68
  141. package/scripts/hook-stop-self-score.sh +0 -51
  142. package/scripts/hook-stop-verify-deploy.sh +0 -31
  143. package/scripts/hook-verify-before-done.sh +0 -20
  144. package/scripts/managed-dpo-export.js +0 -91
  145. package/scripts/markdown-escape.js +0 -12
  146. package/scripts/marketing-experiment.js +0 -657
  147. package/scripts/memalign-recall.js +0 -111
  148. package/scripts/memory-migration.js +0 -296
  149. package/scripts/meta-policy.js +0 -190
  150. package/scripts/metered-billing.js +0 -16
  151. package/scripts/model-tier-router.js +0 -310
  152. package/scripts/money-watcher.js +0 -218
  153. package/scripts/multi-hop-recall.js +0 -240
  154. package/scripts/per-step-scoring.js +0 -163
  155. package/scripts/perplexity-command-center.js +0 -644
  156. package/scripts/perplexity-marketing.js +0 -454
  157. package/scripts/pii-scanner.js +0 -153
  158. package/scripts/plan-gate.js +0 -154
  159. package/scripts/post-everywhere.js +0 -341
  160. package/scripts/post-to-x-retry.sh +0 -22
  161. package/scripts/post-to-x.js +0 -369
  162. package/scripts/pr-manager.js +0 -421
  163. package/scripts/principle-extractor.js +0 -162
  164. package/scripts/pro-features.js +0 -41
  165. package/scripts/prompt-dlp.js +0 -222
  166. package/scripts/prove-adapters.js +0 -860
  167. package/scripts/prove-attribution.js +0 -361
  168. package/scripts/prove-automation.js +0 -651
  169. package/scripts/prove-autoresearch.js +0 -304
  170. package/scripts/prove-claim-verification.js +0 -277
  171. package/scripts/prove-cloudflare-sandbox.js +0 -161
  172. package/scripts/prove-data-pipeline.js +0 -408
  173. package/scripts/prove-data-quality.js +0 -227
  174. package/scripts/prove-evolution.js +0 -352
  175. package/scripts/prove-harnesses.js +0 -287
  176. package/scripts/prove-intelligence.js +0 -257
  177. package/scripts/prove-lancedb.js +0 -425
  178. package/scripts/prove-local-intelligence.js +0 -340
  179. package/scripts/prove-loop-closure.js +0 -263
  180. package/scripts/prove-packaged-runtime.js +0 -327
  181. package/scripts/prove-predictive-insights.js +0 -355
  182. package/scripts/prove-runtime.js +0 -363
  183. package/scripts/prove-seo-gsd.js +0 -234
  184. package/scripts/prove-settings.js +0 -279
  185. package/scripts/prove-subway-upgrades.js +0 -277
  186. package/scripts/prove-tessl.js +0 -229
  187. package/scripts/prove-training-export.js +0 -325
  188. package/scripts/prove-workflow-contract.js +0 -112
  189. package/scripts/prove-xmemory.js +0 -332
  190. package/scripts/publish-decision.js +0 -159
  191. package/scripts/ralph-loop.js +0 -376
  192. package/scripts/ralph-mode-ci.js +0 -434
  193. package/scripts/reddit-dm-outreach.js +0 -192
  194. package/scripts/reddit-monitor-cron.sh +0 -26
  195. package/scripts/reminder-engine.js +0 -132
  196. package/scripts/revenue-status.js +0 -472
  197. package/scripts/rotate-stripe-webhook-secret.js +0 -314
  198. package/scripts/schedule-manager.js +0 -249
  199. package/scripts/self-healing-check.js +0 -193
  200. package/scripts/session-analyzer.js +0 -533
  201. package/scripts/shieldcortex-memory-firewall-runner.mjs +0 -53
  202. package/scripts/skill-exporter.js +0 -260
  203. package/scripts/skill-materializer.js +0 -134
  204. package/scripts/skill-packs.js +0 -136
  205. package/scripts/skill-proposer.js +0 -99
  206. package/scripts/skill-quality-tracker.js +0 -282
  207. package/scripts/slow-loop.js +0 -72
  208. package/scripts/social-analytics/db/marketing-db.js +0 -179
  209. package/scripts/social-analytics/db/schema.sql +0 -55
  210. package/scripts/social-analytics/digest.js +0 -256
  211. package/scripts/social-analytics/engagement-audit.js +0 -185
  212. package/scripts/social-analytics/generate-instagram-card.js +0 -123
  213. package/scripts/social-analytics/generate-slides.js +0 -268
  214. package/scripts/social-analytics/instagram-thumbgate-post.js +0 -111
  215. package/scripts/social-analytics/install-growth-automation.js +0 -114
  216. package/scripts/social-analytics/load-env.js +0 -77
  217. package/scripts/social-analytics/mcp-server.js +0 -289
  218. package/scripts/social-analytics/normalizer.js +0 -580
  219. package/scripts/social-analytics/notify.js +0 -162
  220. package/scripts/social-analytics/poll-all.js +0 -107
  221. package/scripts/social-analytics/pollers/github.js +0 -195
  222. package/scripts/social-analytics/pollers/instagram.js +0 -253
  223. package/scripts/social-analytics/pollers/linkedin.js +0 -340
  224. package/scripts/social-analytics/pollers/plausible.js +0 -245
  225. package/scripts/social-analytics/pollers/reddit.js +0 -306
  226. package/scripts/social-analytics/pollers/threads.js +0 -233
  227. package/scripts/social-analytics/pollers/tiktok.js +0 -203
  228. package/scripts/social-analytics/pollers/x.js +0 -227
  229. package/scripts/social-analytics/pollers/youtube.js +0 -304
  230. package/scripts/social-analytics/pollers/zernio.js +0 -183
  231. package/scripts/social-analytics/post-video.js +0 -316
  232. package/scripts/social-analytics/publish-instagram-thumbgate.js +0 -104
  233. package/scripts/social-analytics/publish-thumbgate-launch.js +0 -322
  234. package/scripts/social-analytics/publishers/devto.js +0 -122
  235. package/scripts/social-analytics/publishers/instagram.js +0 -317
  236. package/scripts/social-analytics/publishers/linkedin.js +0 -294
  237. package/scripts/social-analytics/publishers/reddit.js +0 -385
  238. package/scripts/social-analytics/publishers/threads.js +0 -275
  239. package/scripts/social-analytics/publishers/tiktok.js +0 -217
  240. package/scripts/social-analytics/publishers/x.js +0 -259
  241. package/scripts/social-analytics/publishers/youtube.js +0 -223
  242. package/scripts/social-analytics/publishers/zernio.js +0 -568
  243. package/scripts/social-analytics/reconcile-thumbgate-campaign.js +0 -165
  244. package/scripts/social-analytics/run-digest.js +0 -34
  245. package/scripts/social-analytics/schedule-thumbgate-campaign.js +0 -275
  246. package/scripts/social-analytics/store.js +0 -455
  247. package/scripts/social-analytics/sync-launch-assets.js +0 -185
  248. package/scripts/social-analytics/utm.js +0 -143
  249. package/scripts/social-pipeline.js +0 -2626
  250. package/scripts/social-post-hourly.js +0 -228
  251. package/scripts/social-quality-gate.js +0 -134
  252. package/scripts/social-reply-monitor.js +0 -592
  253. package/scripts/status-dashboard.js +0 -155
  254. package/scripts/stripe-live-status.js +0 -115
  255. package/scripts/subagent-profiles.js +0 -79
  256. package/scripts/sync-branch-protection.js +0 -340
  257. package/scripts/sync-gh-secrets-from-env.sh +0 -70
  258. package/scripts/sync-github-about.js +0 -55
  259. package/scripts/sync-version.js +0 -479
  260. package/scripts/synthetic-dpo.js +0 -234
  261. package/scripts/tessl-export.js +0 -369
  262. package/scripts/test-coverage.js +0 -128
  263. package/scripts/thumbgate-bench.js +0 -494
  264. package/scripts/thumbgate_session_start.sh +0 -32
  265. package/scripts/train_from_feedback.py +0 -929
  266. package/scripts/validate-feedback.js +0 -581
  267. package/scripts/verify-obsidian-setup.sh +0 -269
  268. package/scripts/verify-run.js +0 -269
  269. package/scripts/weekly-auto-post.js +0 -124
  270. package/scripts/x-autonomous-marketing.js +0 -139
@@ -1,860 +0,0 @@
1
- #!/usr/bin/env node
2
- const fs = require('fs');
3
- const path = require('path');
4
- const os = require('os');
5
- const { spawn, execFileSync } = require('child_process');
6
- const { waitForBackgroundSideEffects } = require('./feedback-loop');
7
- const { startServer } = require('../src/api/server');
8
- const { handleRequest } = require('../adapters/mcp/server-stdio');
9
- const { validateSubagentProfiles, listSubagentProfiles } = require('./subagent-profiles');
10
- const { getAllowedTools } = require('./mcp-policy');
11
- const { ensureDir } = require('./fs-utils');
12
-
13
- const ROOT = path.join(__dirname, '..');
14
- const DEFAULT_PROOF_DIR = path.join(ROOT, 'proof', 'compatibility');
15
-
16
-
17
- function check(condition, message) {
18
- if (!condition) {
19
- throw new Error(message);
20
- }
21
- }
22
-
23
- function escapeRegExp(value) {
24
- return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
25
- }
26
-
27
- function parseLeadingJson(text) {
28
- const raw = String(text || '');
29
- const marker = '\n\n---';
30
- const boundary = raw.indexOf(marker);
31
- const jsonSegment = boundary === -1 ? raw : raw.slice(0, boundary);
32
- return JSON.parse(jsonSegment.trim());
33
- }
34
-
35
- function initGitRepo() {
36
- const repoPath = fs.mkdtempSync(path.join(os.tmpdir(), 'thumbgate-proof-repo-'));
37
- execFileSync('git', ['init', '-b', 'main'], { cwd: repoPath, stdio: 'ignore' });
38
- execFileSync('git', ['config', 'user.name', 'ThumbGate Proof'], { cwd: repoPath, stdio: 'ignore' });
39
- execFileSync('git', ['config', 'user.email', 'proof@example.com'], { cwd: repoPath, stdio: 'ignore' });
40
- execFileSync('git', ['config', 'commit.gpgsign', 'false'], { cwd: repoPath, stdio: 'ignore' });
41
- fs.writeFileSync(path.join(repoPath, 'README.md'), '# proof repo\n');
42
- execFileSync('git', ['add', 'README.md'], { cwd: repoPath, stdio: 'ignore' });
43
- execFileSync('git', ['commit', '-m', 'init'], { cwd: repoPath, stdio: 'ignore' });
44
- return repoPath;
45
- }
46
-
47
- function removeWorktree(repoPath, worktreePath) {
48
- if (!repoPath || !worktreePath || !fs.existsSync(worktreePath)) return;
49
- execFileSync('git', ['-C', repoPath, 'worktree', 'remove', '--force', worktreePath], {
50
- stdio: 'ignore',
51
- });
52
- }
53
-
54
- async function fetchWithRetry(url, options, { retries = 5, delayMs = 100 } = {}) {
55
- let lastError = null;
56
-
57
- for (let attempt = 0; attempt <= retries; attempt += 1) {
58
- try {
59
- return await fetch(url, options);
60
- } catch (err) {
61
- lastError = err;
62
- if (attempt === retries) {
63
- throw err;
64
- }
65
- await new Promise((resolve) => setTimeout(resolve, delayMs * (attempt + 1)));
66
- }
67
- }
68
-
69
- throw lastError;
70
- }
71
-
72
- async function proveMcpStdioTransport({
73
- root,
74
- transport = 'ndjson',
75
- timeoutMs = 10000,
76
- cwd = root,
77
- env = process.env,
78
- }) {
79
- const cliPath = path.join(root, 'bin', 'cli.js');
80
- const child = spawn(process.execPath, [cliPath, 'serve'], {
81
- cwd,
82
- stdio: ['pipe', 'pipe', 'pipe'],
83
- env,
84
- });
85
-
86
- let stdoutBuffer = Buffer.alloc(0);
87
- let stderrBuffer = '';
88
-
89
- function parseResponse() {
90
- const headerEnd = stdoutBuffer.indexOf('\r\n\r\n');
91
- if (headerEnd !== -1) {
92
- const header = stdoutBuffer.slice(0, headerEnd).toString('utf8');
93
- const match = header.match(/Content-Length:\s*(\d+)/i);
94
- if (!match) return null;
95
- const length = Number(match[1]);
96
- const bodyStart = headerEnd + 4;
97
- const bodyEnd = bodyStart + length;
98
- if (stdoutBuffer.length < bodyEnd) return null;
99
- return stdoutBuffer.slice(bodyStart, bodyEnd).toString('utf8');
100
- }
101
-
102
- const newlineIndex = stdoutBuffer.indexOf('\n');
103
- if (newlineIndex === -1) return null;
104
- const line = stdoutBuffer.slice(0, newlineIndex).toString('utf8').trim();
105
- if (!line) return null;
106
- return line;
107
- }
108
-
109
- return new Promise((resolve, reject) => {
110
- let settled = false;
111
- const done = (err, value) => {
112
- if (settled) return;
113
- settled = true;
114
- try {
115
- child.kill('SIGKILL');
116
- } catch (_) {
117
- // no-op
118
- }
119
- if (err) reject(err);
120
- else resolve(value);
121
- };
122
-
123
- const timer = setTimeout(() => {
124
- done(new Error(`stdio ${transport} initialize timeout; stderr=${stderrBuffer}`));
125
- }, timeoutMs);
126
-
127
- child.on('error', (err) => {
128
- clearTimeout(timer);
129
- done(err);
130
- });
131
-
132
- child.on('exit', (code, signal) => {
133
- if (settled) return;
134
- clearTimeout(timer);
135
- done(new Error(`stdio ${transport} exited early (code=${code}, signal=${signal}); stderr=${stderrBuffer}`));
136
- });
137
-
138
- child.stderr.on('data', (chunk) => {
139
- stderrBuffer += String(chunk || '');
140
- });
141
-
142
- child.stdout.on('data', (chunk) => {
143
- stdoutBuffer = Buffer.concat([stdoutBuffer, Buffer.from(chunk)]);
144
- const body = parseResponse();
145
- if (!body) return;
146
-
147
- clearTimeout(timer);
148
- try {
149
- const parsed = JSON.parse(body);
150
- done(null, parsed);
151
- } catch (err) {
152
- done(err);
153
- }
154
- });
155
-
156
- const initialize = {
157
- jsonrpc: '2.0',
158
- id: 777,
159
- method: 'initialize',
160
- params: {
161
- protocolVersion: '2025-06-18',
162
- capabilities: {},
163
- clientInfo: {
164
- name: 'prove-adapters',
165
- version: '1.0.0',
166
- },
167
- },
168
- };
169
-
170
- if (transport === 'framed') {
171
- const body = JSON.stringify(initialize);
172
- child.stdin.write(`Content-Length: ${Buffer.byteLength(body, 'utf8')}\r\n\r\n${body}`);
173
- return;
174
- }
175
-
176
- child.stdin.write(`${JSON.stringify(initialize)}\n`);
177
- });
178
- }
179
-
180
- async function runProof(options = {}) {
181
- const proofDir = options.proofDir || process.env.THUMBGATE_PROOF_DIR || DEFAULT_PROOF_DIR;
182
- const writeArtifacts = options.writeArtifacts !== false;
183
- const proofPort = options.port ?? 0;
184
-
185
- if (writeArtifacts) {
186
- ensureDir(proofDir);
187
- }
188
-
189
- const tmpFeedbackDir = fs.mkdtempSync(path.join(os.tmpdir(), 'thumbgate-proof-'));
190
- const previousFeedbackDir = process.env.THUMBGATE_FEEDBACK_DIR;
191
- const previousApiKey = process.env.THUMBGATE_API_KEY;
192
- const previousMcpProfile = process.env.THUMBGATE_MCP_PROFILE;
193
- const previousCodegraphStub = process.env.THUMBGATE_CODEGRAPH_STUB_RESPONSE;
194
- process.env.THUMBGATE_FEEDBACK_DIR = tmpFeedbackDir;
195
- process.env.THUMBGATE_API_KEY = 'proof-key';
196
- process.env.THUMBGATE_MCP_PROFILE = 'default';
197
- process.env.THUMBGATE_CODEGRAPH_STUB_RESPONSE = JSON.stringify({
198
- source: 'stub',
199
- symbols: ['planIntent'],
200
- callers: ['src/api/server.js -> planIntent', 'adapters/mcp/server-stdio.js -> planIntent'],
201
- callees: ['rankActions', 'decomposeActions'],
202
- deadCode: ['legacyIntentPlanner'],
203
- });
204
-
205
- const report = {
206
- generatedAt: new Date().toISOString(),
207
- checks: [],
208
- summary: { passed: 0, failed: 0 },
209
- };
210
-
211
- function addResult(name, passed, details) {
212
- report.checks.push({ name, passed, details });
213
- if (passed) report.summary.passed += 1;
214
- else report.summary.failed += 1;
215
- }
216
-
217
- const { server, port } = await startServer({ port: proofPort });
218
- const baseUrl = `http://127.0.0.1:${port}`;
219
- let currentCheck = 'bootstrap';
220
-
221
- try {
222
- // API checks
223
- {
224
- currentCheck = 'api.healthz';
225
- const res = await fetchWithRetry(`${baseUrl}/healthz`, {
226
- headers: { Authorization: 'Bearer proof-key' },
227
- });
228
- check(res.status === 200, `health expected 200, got ${res.status}`);
229
- addResult('api.healthz', true, { status: res.status });
230
- }
231
-
232
- {
233
- currentCheck = 'api.auth.required';
234
- const res = await fetchWithRetry(`${baseUrl}/v1/feedback/stats`);
235
- check(res.status === 401, `stats unauthorized expected 401, got ${res.status}`);
236
- addResult('api.auth.required', true, { status: res.status });
237
- }
238
-
239
- {
240
- currentCheck = 'api.intents.catalog';
241
- const res = await fetchWithRetry(`${baseUrl}/v1/intents/catalog?mcpProfile=locked`, {
242
- headers: { Authorization: 'Bearer proof-key' },
243
- });
244
- check(res.status === 200, `intents catalog expected 200, got ${res.status}`);
245
- const body = await res.json();
246
- check(Array.isArray(body.intents), 'intents catalog should return intents array');
247
- addResult('api.intents.catalog', true, { intents: body.intents.length, profile: body.mcpProfile });
248
- }
249
-
250
- {
251
- currentCheck = 'api.intents.plan';
252
- const res = await fetchWithRetry(`${baseUrl}/v1/intents/plan`, {
253
- method: 'POST',
254
- headers: {
255
- Authorization: 'Bearer proof-key',
256
- 'Content-Type': 'application/json',
257
- },
258
- body: JSON.stringify({
259
- intentId: 'publish_dpo_training_data',
260
- mcpProfile: 'default',
261
- approved: false,
262
- }),
263
- });
264
- check(res.status === 200, `intent plan expected 200, got ${res.status}`);
265
- const body = await res.json();
266
- check(body.status === 'checkpoint_required', 'intent plan should require checkpoint when not approved');
267
- addResult('api.intents.plan', true, { status: body.status, risk: body.intent.risk });
268
- }
269
-
270
- {
271
- currentCheck = 'api.intents.plan.codegraph';
272
- const res = await fetchWithRetry(`${baseUrl}/v1/intents/plan`, {
273
- method: 'POST',
274
- headers: {
275
- Authorization: 'Bearer proof-key',
276
- 'Content-Type': 'application/json',
277
- },
278
- body: JSON.stringify({
279
- intentId: 'incident_postmortem',
280
- context: 'Refactor `planIntent` in scripts/intent-router.js',
281
- mcpProfile: 'default',
282
- repoPath: ROOT,
283
- }),
284
- });
285
- check(res.status === 200, `intent plan with codegraph expected 200, got ${res.status}`);
286
- const body = await res.json();
287
- check(body.codegraphImpact && body.codegraphImpact.enabled === true, 'api intent plan should include codegraph impact');
288
- check(body.codegraphImpact.evidence.deadCodeCount >= 1, 'api intent plan should carry dead-code evidence');
289
- addResult('api.intents.plan.codegraph', true, {
290
- source: body.codegraphImpact.source,
291
- impactScore: body.codegraphImpact.evidence.impactScore,
292
- });
293
- }
294
-
295
- {
296
- currentCheck = 'api.internal_agent.bootstrap';
297
- const repoPath = initGitRepo();
298
- const sandboxRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'thumbgate-proof-bootstrap-'));
299
- let sandboxPath = null;
300
-
301
- try {
302
- const res = await fetchWithRetry(`${baseUrl}/v1/internal-agent/bootstrap`, {
303
- method: 'POST',
304
- headers: {
305
- Authorization: 'Bearer proof-key',
306
- 'Content-Type': 'application/json',
307
- },
308
- body: JSON.stringify({
309
- source: 'github',
310
- repoPath,
311
- sandboxRoot,
312
- context: 'Improve the response with evidence and prevention rules',
313
- trigger: { type: 'pull_request_comment', id: '17', actor: 'octocat' },
314
- task: {
315
- title: 'Harden bootstrap plan',
316
- body: 'Refactor scripts/intent-router.js and provide proof.',
317
- },
318
- }),
319
- });
320
- check(res.status === 200, `internal agent bootstrap expected 200, got ${res.status}`);
321
- const body = await res.json();
322
- sandboxPath = body.sandbox && body.sandbox.path;
323
- check(body.sandbox && body.sandbox.ready === true, 'api bootstrap should prepare a sandbox');
324
- check(body.reviewerLane && body.reviewerLane.enabled === true, 'api bootstrap should recommend a reviewer lane');
325
- addResult('api.internal_agent.bootstrap', true, {
326
- sandboxReady: body.sandbox.ready,
327
- executionMode: body.intentPlan.executionMode,
328
- });
329
- } finally {
330
- removeWorktree(repoPath, sandboxPath);
331
- fs.rmSync(repoPath, { recursive: true, force: true });
332
- fs.rmSync(sandboxRoot, { recursive: true, force: true });
333
- }
334
- }
335
-
336
- {
337
- currentCheck = 'api.capture_feedback';
338
- const res = await fetchWithRetry(`${baseUrl}/v1/feedback/capture`, {
339
- method: 'POST',
340
- headers: {
341
- Authorization: 'Bearer proof-key',
342
- 'Content-Type': 'application/json',
343
- },
344
- body: JSON.stringify({
345
- signal: 'up',
346
- context: 'adapter proof harness',
347
- whatWorked: 'end-to-end verification flow',
348
- tags: ['verification', 'proof'],
349
- }),
350
- });
351
- check(res.status === 200, `capture expected 200, got ${res.status}`);
352
- const body = await res.json();
353
- check(body.accepted === true, 'capture should be accepted');
354
- addResult('api.capture_feedback', true, { accepted: body.accepted });
355
- }
356
-
357
- {
358
- currentCheck = 'api.capture_feedback.clarification';
359
- const res = await fetchWithRetry(`${baseUrl}/v1/feedback/capture`, {
360
- method: 'POST',
361
- headers: {
362
- Authorization: 'Bearer proof-key',
363
- 'Content-Type': 'application/json',
364
- },
365
- body: JSON.stringify({
366
- signal: 'up',
367
- context: 'thumbs up',
368
- tags: ['verification'],
369
- }),
370
- });
371
- check(res.status === 422, `clarification capture expected 422, got ${res.status}`);
372
- const body = await res.json();
373
- check(body.status === 'clarification_required', 'vague capture should require clarification');
374
- check(body.needsClarification === true, 'vague capture should set needsClarification');
375
- addResult('api.capture_feedback.clarification', true, { status: body.status, prompt: body.prompt });
376
- }
377
-
378
- {
379
- currentCheck = 'api.capture_feedback.rubric_gate';
380
- const res = await fetchWithRetry(`${baseUrl}/v1/feedback/capture`, {
381
- method: 'POST',
382
- headers: {
383
- Authorization: 'Bearer proof-key',
384
- 'Content-Type': 'application/json',
385
- },
386
- body: JSON.stringify({
387
- signal: 'up',
388
- context: 'unsafe approval attempt',
389
- whatWorked: 'claimed success',
390
- rubricScores: [
391
- { criterion: 'verification_evidence', score: 5, judge: 'judge-a' },
392
- { criterion: 'verification_evidence', score: 2, judge: 'judge-b', evidence: 'missing logs' },
393
- ],
394
- guardrails: { testsPassed: false, pathSafety: true, budgetCompliant: true },
395
- tags: ['verification'],
396
- }),
397
- });
398
- check(res.status === 422, `rubric-gated capture expected 422, got ${res.status}`);
399
- const body = await res.json();
400
- check(body.accepted === false, 'rubric-gated capture should not be accepted');
401
- addResult('api.capture_feedback.rubric_gate', true, { accepted: body.accepted });
402
- }
403
-
404
- {
405
- currentCheck = 'api.context.construct';
406
- const construct = await fetchWithRetry(`${baseUrl}/v1/context/construct`, {
407
- method: 'POST',
408
- headers: {
409
- Authorization: 'Bearer proof-key',
410
- 'Content-Type': 'application/json',
411
- },
412
- body: JSON.stringify({ query: 'verification', maxItems: 5, maxChars: 5000 }),
413
- });
414
- check(construct.status === 200, `context construct expected 200, got ${construct.status}`);
415
- const pack = await construct.json();
416
- check(Boolean(pack.packId), 'context packId missing');
417
- addResult('api.context.construct', true, { packId: pack.packId, items: pack.items.length });
418
-
419
- currentCheck = 'api.context.evaluate';
420
- const evaluate = await fetchWithRetry(`${baseUrl}/v1/context/evaluate`, {
421
- method: 'POST',
422
- headers: {
423
- Authorization: 'Bearer proof-key',
424
- 'Content-Type': 'application/json',
425
- },
426
- body: JSON.stringify({
427
- packId: pack.packId,
428
- outcome: 'useful',
429
- signal: 'positive',
430
- rubricScores: [
431
- { criterion: 'correctness', score: 4, evidence: 'tests pass', judge: 'judge-a' },
432
- { criterion: 'verification_evidence', score: 4, evidence: 'logs attached', judge: 'judge-a' },
433
- ],
434
- guardrails: { testsPassed: true, pathSafety: true, budgetCompliant: true },
435
- }),
436
- });
437
- check(evaluate.status === 200, `context evaluate expected 200, got ${evaluate.status}`);
438
- const evalBody = await evaluate.json();
439
- check(Boolean(evalBody.rubricEvaluation), 'context evaluate should include rubricEvaluation');
440
- addResult('api.context.evaluate', true, { status: evaluate.status, rubric: evalBody.rubricEvaluation.rubricId });
441
- }
442
-
443
- // MCP checks
444
- {
445
- currentCheck = 'mcp.initialize';
446
- const init = await handleRequest({ jsonrpc: '2.0', id: 1, method: 'initialize', params: {} });
447
- check(Boolean(init.serverInfo && init.serverInfo.name), 'mcp initialize missing serverInfo');
448
- addResult('mcp.initialize', true, { server: init.serverInfo.name });
449
- }
450
-
451
- {
452
- currentCheck = 'mcp.stdio.framed.initialize';
453
- const framedResponse = await proveMcpStdioTransport({ root: ROOT, transport: 'framed' });
454
- check(framedResponse.id === 777, 'stdio framed initialize returned wrong id');
455
- check(Boolean(framedResponse.result && framedResponse.result.serverInfo), 'stdio framed initialize missing serverInfo');
456
- addResult('mcp.stdio.framed.initialize', true, { server: framedResponse.result.serverInfo.name });
457
- }
458
-
459
- {
460
- currentCheck = 'mcp.stdio.ndjson.initialize';
461
- const ndjsonResponse = await proveMcpStdioTransport({ root: ROOT, transport: 'ndjson' });
462
- check(ndjsonResponse.id === 777, 'stdio ndjson initialize returned wrong id');
463
- check(Boolean(ndjsonResponse.result && ndjsonResponse.result.serverInfo), 'stdio ndjson initialize missing serverInfo');
464
- addResult('mcp.stdio.ndjson.initialize', true, { server: ndjsonResponse.result.serverInfo.name });
465
- }
466
-
467
- {
468
- currentCheck = 'mcp.cli.serve.bad_home.initialize';
469
- const isolatedDir = fs.mkdtempSync(path.join(os.tmpdir(), 'thumbgate-proof-cli-serve-'));
470
- const badHomePath = path.join(isolatedDir, 'invalid-home');
471
- fs.writeFileSync(badHomePath, 'not-a-directory\n');
472
-
473
- try {
474
- const response = await proveMcpStdioTransport({
475
- root: ROOT,
476
- transport: 'ndjson',
477
- cwd: isolatedDir,
478
- env: {
479
- ...process.env,
480
- HOME: badHomePath,
481
- USERPROFILE: badHomePath,
482
- },
483
- });
484
- check(response.id === 777, 'cli serve bad HOME initialize returned wrong id');
485
- check(Boolean(response.result && response.result.serverInfo), 'cli serve bad HOME initialize missing serverInfo');
486
- addResult('mcp.cli.serve.bad_home.initialize', true, { server: response.result.serverInfo.name });
487
- } finally {
488
- fs.rmSync(isolatedDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
489
- }
490
- }
491
-
492
- {
493
- currentCheck = 'mcp.tools.list';
494
- const list = await handleRequest({ jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} });
495
- check(Array.isArray(list.tools) && list.tools.length > 0, 'mcp tools/list empty');
496
- addResult('mcp.tools.list', true, { tools: list.tools.length });
497
- }
498
-
499
- {
500
- currentCheck = 'mcp.tools.call.feedback_summary';
501
- const call = await handleRequest({
502
- jsonrpc: '2.0',
503
- id: 3,
504
- method: 'tools/call',
505
- params: {
506
- name: 'feedback_summary',
507
- arguments: { recent: 5 },
508
- },
509
- });
510
- check(Array.isArray(call.content), 'mcp feedback_summary should return content[]');
511
- addResult('mcp.tools.call.feedback_summary', true, { contentLength: call.content[0].text.length });
512
- }
513
-
514
- {
515
- currentCheck = 'mcp.tools.call.diagnose_failure';
516
- const call = await handleRequest({
517
- jsonrpc: '2.0',
518
- id: 36,
519
- method: 'tools/call',
520
- params: {
521
- name: 'diagnose_failure',
522
- arguments: {
523
- step: 'capture_feedback',
524
- context: 'Attempted to approve publish flow without required approval',
525
- toolName: 'capture_feedback',
526
- toolArgs: {},
527
- intentId: 'publish_dpo_training_data',
528
- mcpProfile: 'default',
529
- },
530
- },
531
- });
532
- const diagnosis = JSON.parse(call.content[0].text);
533
- check(diagnosis.rootCauseCategory === 'intent_plan_misalignment', 'mcp diagnose_failure should classify approval mismatch');
534
- check(diagnosis.compiledConstraints.summary.toolSchemaCount >= 1, 'mcp diagnose_failure should include compiled constraints');
535
- addResult('mcp.tools.call.diagnose_failure', true, {
536
- rootCauseCategory: diagnosis.rootCauseCategory,
537
- toolSchemaCount: diagnosis.compiledConstraints.summary.toolSchemaCount,
538
- });
539
- }
540
-
541
- {
542
- currentCheck = 'mcp.tools.call.plan_intent';
543
- const call = await handleRequest({
544
- jsonrpc: '2.0',
545
- id: 31,
546
- method: 'tools/call',
547
- params: {
548
- name: 'plan_intent',
549
- arguments: {
550
- intentId: 'publish_dpo_training_data',
551
- mcpProfile: 'default',
552
- },
553
- },
554
- });
555
- const plan = JSON.parse(call.content[0].text);
556
- check(plan.status === 'checkpoint_required', 'mcp plan_intent should return checkpoint_required by default');
557
- addResult('mcp.tools.call.plan_intent', true, { status: plan.status });
558
- }
559
-
560
- {
561
- currentCheck = 'mcp.tools.call.plan_intent.codegraph';
562
- const call = await handleRequest({
563
- jsonrpc: '2.0',
564
- id: 34,
565
- method: 'tools/call',
566
- params: {
567
- name: 'plan_intent',
568
- arguments: {
569
- intentId: 'incident_postmortem',
570
- context: 'Refactor `planIntent` in scripts/intent-router.js',
571
- mcpProfile: 'default',
572
- repoPath: ROOT,
573
- },
574
- },
575
- });
576
- const plan = JSON.parse(call.content[0].text);
577
- check(plan.codegraphImpact && plan.codegraphImpact.enabled === true, 'mcp plan_intent should include codegraph impact');
578
- check(plan.codegraphImpact.evidence.deadCodeCount >= 1, 'mcp plan_intent should include dead-code evidence');
579
- addResult('mcp.tools.call.plan_intent.codegraph', true, {
580
- impactScore: plan.codegraphImpact.evidence.impactScore,
581
- });
582
- }
583
-
584
- {
585
- currentCheck = 'mcp.tools.call.get_business_metrics';
586
- const call = await handleRequest({
587
- jsonrpc: '2.0',
588
- id: 101,
589
- method: 'tools/call',
590
- params: {
591
- name: 'get_business_metrics',
592
- arguments: { window: 'lifetime' },
593
- },
594
- });
595
- const metrics = JSON.parse(call.content[0].text);
596
- check(metrics.metrics && typeof metrics.metrics.bookedRevenueCents === 'number', 'get_business_metrics should return numeric revenue');
597
- addResult('mcp.tools.call.get_business_metrics', true, { generatedAt: metrics.generatedAt });
598
- }
599
-
600
- {
601
- currentCheck = 'mcp.tools.call.describe_semantic_entity';
602
- const call = await handleRequest({
603
- jsonrpc: '2.0',
604
- id: 102,
605
- method: 'tools/call',
606
- params: {
607
- name: 'describe_semantic_entity',
608
- arguments: { type: 'Customer' },
609
- },
610
- });
611
- const entity = JSON.parse(call.content[0].text);
612
- check(entity.description && entity.tiers, 'describe_semantic_entity should return Customer definition');
613
- addResult('mcp.tools.call.describe_semantic_entity', true, { type: 'Customer' });
614
- }
615
-
616
- {
617
- currentCheck = 'mcp.tools.call.recall.codegraph';
618
- const call = await handleRequest({
619
- jsonrpc: '2.0',
620
- id: 35,
621
- method: 'tools/call',
622
- params: {
623
- name: 'recall',
624
- arguments: {
625
- query: 'Refactor `planIntent` in scripts/intent-router.js',
626
- repoPath: ROOT,
627
- },
628
- },
629
- });
630
- check(/## Code Graph Impact/.test(call.content[0].text), 'mcp recall should include code graph impact section');
631
- check(/Potential dead code/.test(call.content[0].text), 'mcp recall should include dead-code evidence');
632
- addResult('mcp.tools.call.recall.codegraph', true, {
633
- contentLength: call.content[0].text.length,
634
- });
635
- }
636
-
637
- {
638
- currentCheck = 'mcp.tools.call.bootstrap_internal_agent';
639
- const repoPath = initGitRepo();
640
- const sandboxRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'thumbgate-proof-mcp-bootstrap-'));
641
- let sandboxPath = null;
642
-
643
- try {
644
- const call = await handleRequest({
645
- jsonrpc: '2.0',
646
- id: 37,
647
- method: 'tools/call',
648
- params: {
649
- name: 'bootstrap_internal_agent',
650
- arguments: {
651
- source: 'github',
652
- repoPath,
653
- sandboxRoot,
654
- context: 'Improve the response with evidence and prevention rules',
655
- trigger: { type: 'pull_request_comment', id: '18', actor: 'octocat' },
656
- task: {
657
- title: 'Harden bootstrap plan',
658
- body: 'Refactor scripts/intent-router.js and provide proof.',
659
- },
660
- },
661
- },
662
- });
663
- const payload = JSON.parse(call.content[0].text);
664
- sandboxPath = payload.sandbox && payload.sandbox.path;
665
- check(payload.sandbox && payload.sandbox.ready === true, 'mcp bootstrap should prepare a sandbox');
666
- check(payload.reviewerLane && payload.reviewerLane.enabled === true, 'mcp bootstrap should recommend a reviewer lane');
667
- addResult('mcp.tools.call.bootstrap_internal_agent', true, {
668
- sandboxReady: payload.sandbox.ready,
669
- executionMode: payload.intentPlan.executionMode,
670
- });
671
- } finally {
672
- removeWorktree(repoPath, sandboxPath);
673
- fs.rmSync(repoPath, { recursive: true, force: true });
674
- fs.rmSync(sandboxRoot, { recursive: true, force: true });
675
- }
676
- }
677
-
678
- {
679
- currentCheck = 'mcp.tools.call.capture_feedback.rubric_gate';
680
- const call = await handleRequest({
681
- jsonrpc: '2.0',
682
- id: 32,
683
- method: 'tools/call',
684
- params: {
685
- name: 'capture_feedback',
686
- arguments: {
687
- signal: 'up',
688
- context: 'unsafe approval attempt',
689
- whatWorked: 'claimed success',
690
- rubricScores: [
691
- { criterion: 'verification_evidence', score: 5, judge: 'judge-a' },
692
- { criterion: 'verification_evidence', score: 2, judge: 'judge-b', evidence: 'missing logs' },
693
- ],
694
- guardrails: { testsPassed: false, pathSafety: true, budgetCompliant: true },
695
- },
696
- },
697
- });
698
- const payload = parseLeadingJson(call.content[0].text);
699
- check(payload.accepted === false, 'mcp capture_feedback should apply rubric gating');
700
- addResult('mcp.tools.call.capture_feedback.rubric_gate', true, { accepted: payload.accepted });
701
- }
702
-
703
- {
704
- currentCheck = 'mcp.tools.call.capture_feedback.clarification';
705
- const call = await handleRequest({
706
- jsonrpc: '2.0',
707
- id: 33,
708
- method: 'tools/call',
709
- params: {
710
- name: 'capture_feedback',
711
- arguments: {
712
- signal: 'up',
713
- context: 'thumbs up',
714
- tags: ['verification'],
715
- },
716
- },
717
- });
718
- const payload = parseLeadingJson(call.content[0].text);
719
- check(payload.status === 'clarification_required', 'mcp capture_feedback should require clarification for vague praise');
720
- check(payload.needsClarification === true, 'mcp capture_feedback should mark vague praise as clarification_required');
721
- addResult('mcp.tools.call.capture_feedback.clarification', true, { status: payload.status, prompt: payload.prompt });
722
- }
723
-
724
- {
725
- currentCheck = 'mcp.policy.locked_profile_denies_write_tool';
726
- process.env.THUMBGATE_MCP_PROFILE = 'locked';
727
- let denied = false;
728
- try {
729
- await handleRequest({
730
- jsonrpc: '2.0',
731
- id: 4,
732
- method: 'tools/call',
733
- params: {
734
- name: 'capture_feedback',
735
- arguments: { signal: 'up', context: 'should be denied' },
736
- },
737
- });
738
- } catch (err) {
739
- denied = /not allowed/i.test(String(err.message));
740
- }
741
- process.env.THUMBGATE_MCP_PROFILE = 'default';
742
- check(denied, 'locked profile should deny capture_feedback');
743
- addResult('mcp.policy.locked_profile_denies_write_tool', true, { denied });
744
- }
745
-
746
- // Spec and adapter files checks
747
- {
748
- currentCheck = 'adapter.chatgpt.openapi.parity';
749
- const canonical = fs.readFileSync(path.join(ROOT, 'openapi/openapi.yaml'), 'utf-8');
750
- const chatgpt = fs.readFileSync(path.join(ROOT, 'adapters/chatgpt/openapi.yaml'), 'utf-8');
751
- check(canonical === chatgpt, 'chatgpt openapi not in sync with canonical openapi');
752
-
753
- ['/v1/feedback/capture', '/v1/dpo/export', '/v1/context/construct', '/v1/intents/plan', '/v1/internal-agent/bootstrap'].forEach((route) => {
754
- check(new RegExp(escapeRegExp(route)).test(canonical), `route missing from openapi: ${route}`);
755
- });
756
- addResult('adapter.chatgpt.openapi.parity', true, { byteEqual: true });
757
- }
758
-
759
- {
760
- currentCheck = 'adapter.gemini.declarations';
761
- const gemini = JSON.parse(fs.readFileSync(path.join(ROOT, 'adapters/gemini/function-declarations.json'), 'utf-8'));
762
- check(Array.isArray(gemini.tools), 'gemini tools missing');
763
- check(gemini.tools.length >= 3, 'gemini tools should have at least 3 entries');
764
- addResult('adapter.gemini.declarations', true, { tools: gemini.tools.length });
765
- }
766
-
767
- {
768
- currentCheck = 'adapter.files.present';
769
- const mustExist = [
770
- 'adapters/claude/.mcp.json',
771
- 'plugins/claude-codex-bridge/.claude-plugin/plugin.json',
772
- 'plugins/claude-codex-bridge/.mcp.json',
773
- 'plugins/cursor-marketplace/mcp.json',
774
- 'adapters/codex/config.toml',
775
- 'plugins/codex-profile/.codex-plugin/plugin.json',
776
- 'plugins/codex-profile/.mcp.json',
777
- '.agents/plugins/marketplace.json',
778
- 'adapters/amp/skills/thumbgate-feedback/SKILL.md',
779
- ];
780
- mustExist.forEach((file) => {
781
- check(fs.existsSync(path.join(ROOT, file)), `missing adapter file: ${file}`);
782
- });
783
- addResult('adapter.files.present', true, { files: mustExist.length });
784
- }
785
-
786
- // Profiles and policy checks
787
- {
788
- currentCheck = 'subagent.profiles.valid';
789
- const validation = validateSubagentProfiles();
790
- check(validation.valid, `subagent profiles invalid: ${validation.issues.join('; ')}`);
791
- const names = listSubagentProfiles();
792
- check(names.length >= 2, 'expected at least 2 subagent profiles');
793
- addResult('subagent.profiles.valid', true, { profiles: names });
794
- }
795
-
796
- {
797
- currentCheck = 'mcp.policy.profile_differentiation';
798
- const defaultTools = getAllowedTools('default');
799
- const lockedTools = getAllowedTools('locked');
800
- check(defaultTools.length > lockedTools.length, 'default profile should expose more tools than locked');
801
- addResult('mcp.policy.profile_differentiation', true, {
802
- defaultTools: defaultTools.length,
803
- lockedTools: lockedTools.length,
804
- });
805
- }
806
- } catch (err) {
807
- addResult('fatal', false, {
808
- check: currentCheck,
809
- error: err.message,
810
- cause: err.cause && err.cause.message ? err.cause.message : null,
811
- });
812
- } finally {
813
- await new Promise((resolve) => server.close(resolve));
814
- await waitForBackgroundSideEffects();
815
- fs.rmSync(tmpFeedbackDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
816
- if (previousFeedbackDir === undefined) delete process.env.THUMBGATE_FEEDBACK_DIR;
817
- else process.env.THUMBGATE_FEEDBACK_DIR = previousFeedbackDir;
818
- if (previousApiKey === undefined) delete process.env.THUMBGATE_API_KEY;
819
- else process.env.THUMBGATE_API_KEY = previousApiKey;
820
- if (previousMcpProfile === undefined) delete process.env.THUMBGATE_MCP_PROFILE;
821
- else process.env.THUMBGATE_MCP_PROFILE = previousMcpProfile;
822
- if (previousCodegraphStub === undefined) delete process.env.THUMBGATE_CODEGRAPH_STUB_RESPONSE;
823
- else process.env.THUMBGATE_CODEGRAPH_STUB_RESPONSE = previousCodegraphStub;
824
- }
825
-
826
- if (writeArtifacts) {
827
- const reportPath = path.join(proofDir, 'report.json');
828
- fs.writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`);
829
-
830
- const mdLines = [
831
- '# Adapter Compatibility Proof',
832
- '',
833
- `Generated: ${report.generatedAt}`,
834
- '',
835
- `Passed: ${report.summary.passed}`,
836
- `Failed: ${report.summary.failed}`,
837
- '',
838
- '## Checks',
839
- ...report.checks.map((checkItem) => `- ${checkItem.passed ? 'PASS' : 'FAIL'} ${checkItem.name}`),
840
- '',
841
- ];
842
- fs.writeFileSync(path.join(proofDir, 'report.md'), `${mdLines.join('\n')}\n`);
843
- }
844
-
845
- if (report.summary.failed > 0) {
846
- process.exitCode = 1;
847
- }
848
-
849
- return report;
850
- }
851
-
852
- module.exports = {
853
- runProof,
854
- };
855
-
856
- if (require.main === module) {
857
- runProof().then((report) => {
858
- console.log(JSON.stringify(report.summary, null, 2));
859
- });
860
- }