thumbgate 1.39.0 → 1.40.1

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 (180) hide show
  1. package/.agents/skills/craft-playbook-gate/SKILL.md +51 -0
  2. package/.agents/skills/qwenwork-policy-group-honesty-not-clone/SKILL.md +36 -0
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.well-known/llms.txt +2 -2
  5. package/.well-known/mcp/server-card.json +1 -1
  6. package/README.md +11 -5
  7. package/adapters/claude/.mcp.json +6 -2
  8. package/adapters/codex/config.toml +5 -0
  9. package/adapters/forge/forge.yaml +4 -4
  10. package/adapters/future-agi/.mcp.json +1 -1
  11. package/adapters/future-agi/config.toml +1 -1
  12. package/adapters/future-agi/opencode.json +1 -1
  13. package/adapters/herdr/herdr-plugin.toml +2 -2
  14. package/adapters/mcp/server-stdio.js +104 -7
  15. package/adapters/opencode/opencode.json +1 -1
  16. package/adapters/strands/strands-middleware.js +31 -4
  17. package/bin/cli.js +191 -54
  18. package/config/brand-standards.json +131 -0
  19. package/config/gates/default.json +18 -1
  20. package/config/github-about.json +1 -1
  21. package/config/mcp-allowlists.json +16 -3
  22. package/config/merge-quality-checks.json +3 -1
  23. package/config/post-deploy-marketing-pages.json +4 -4
  24. package/config/schemas/task-outcome-receipt.schema.json +9 -0
  25. package/hooks/hooks.json +24 -0
  26. package/openapi/openapi.yaml +7 -3
  27. package/package.json +87 -33
  28. package/public/about.html +2 -2
  29. package/public/admin.html +771 -0
  30. package/public/agent-manager.html +3 -3
  31. package/public/agents-cost-savings.html +1 -1
  32. package/public/ai-malpractice-prevention.html +12 -12
  33. package/public/architecture.html +0 -1
  34. package/public/assets/diagrams/decision.svg +3 -3
  35. package/public/assets/diagrams/hero-thumbs.svg +2 -4
  36. package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
  37. package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
  38. package/public/blog/git-at-agent-scale.html +2 -2
  39. package/public/blog/inside-your-boundary.html +1 -1
  40. package/public/blog/process-over-outcome-gates.html +1 -1
  41. package/public/case-studies.html +5 -6
  42. package/public/codex-enterprise.html +1 -1
  43. package/public/codex-plugin.html +1 -1
  44. package/public/dashboard.html +775 -483
  45. package/public/diagnostic.html +15 -10
  46. package/public/enterprise-governance.html +26 -174
  47. package/public/eval-scorecard.html +3 -4
  48. package/public/eval-scorecard.json +2 -2
  49. package/public/evaluations.html +0 -1
  50. package/public/founders.html +3 -3
  51. package/public/gaming-playbook.html +4 -4
  52. package/public/guide.html +3 -5
  53. package/public/index.html +302 -97
  54. package/public/install.html +16 -10
  55. package/public/js/buyer-intent.js +49 -8
  56. package/public/lessons.html +246 -83
  57. package/public/numbers.html +32 -33
  58. package/public/operator-framework.html +44 -72
  59. package/public/peter.html +3 -3
  60. package/public/platform-partners.html +1 -1
  61. package/public/pricing.html +163 -66
  62. package/public/pro.html +3 -1
  63. package/public/project-switcher.js +76 -0
  64. package/public/whitepaper.html +1 -2
  65. package/scripts/action-receipts.js +393 -0
  66. package/scripts/activation-quickstart.js +15 -3
  67. package/scripts/activation-tracker.js +280 -3
  68. package/scripts/agent-action-inventory.js +235 -143
  69. package/scripts/agent-operations-planner.js +1 -1
  70. package/scripts/agent-readiness.js +36 -6
  71. package/scripts/agentic-prompt-pipelines.js +901 -0
  72. package/scripts/analytics-window.js +7 -1
  73. package/scripts/async-job-runner.js +66 -11
  74. package/scripts/audit-trail.js +37 -24
  75. package/scripts/auto-promote-gates.js +37 -27
  76. package/scripts/auto-wire-hooks.js +64 -25
  77. package/scripts/backfill-lesson-scopes.js +122 -0
  78. package/scripts/billing.js +889 -132
  79. package/scripts/bot-detection.js +112 -0
  80. package/scripts/brand-standards-gate.js +571 -0
  81. package/scripts/chatgpt-ads-readiness-pack.js +1 -1
  82. package/scripts/cli-demo.js +5 -27
  83. package/scripts/cli-schema.js +25 -1
  84. package/scripts/commercial-offer.js +2 -2
  85. package/scripts/contextfs.js +9 -3
  86. package/scripts/craft-playbook-gate.js +550 -0
  87. package/scripts/cross-encoder-reranker.js +4 -0
  88. package/scripts/dashboard-chat.js +11 -0
  89. package/scripts/dashboard.js +574 -167
  90. package/scripts/decision-journal.js +7 -4
  91. package/scripts/docker-sandbox-planner.js +3 -3
  92. package/scripts/export-dpo-pairs.js +12 -7
  93. package/scripts/failure-diagnostics.js +11 -0
  94. package/scripts/feedback-aggregate.js +4 -0
  95. package/scripts/feedback-attribution.js +6 -4
  96. package/scripts/feedback-history-distiller.js +18 -6
  97. package/scripts/feedback-loop.js +255 -89
  98. package/scripts/feedback-paths.js +8 -1
  99. package/scripts/feedback-sanitizer.js +5 -0
  100. package/scripts/feedback-scope.js +106 -0
  101. package/scripts/feedback-session.js +8 -2
  102. package/scripts/filesystem-search.js +13 -8
  103. package/scripts/financial-control-plane.js +707 -45
  104. package/scripts/gate-stats.js +38 -5
  105. package/scripts/gates-engine.js +1326 -240
  106. package/scripts/generate-eval-scorecard.js +0 -1
  107. package/scripts/gitlab-sdlc-prompts.js +397 -0
  108. package/scripts/harness-tool-names.js +31 -5
  109. package/scripts/hook-runtime.js +10 -0
  110. package/scripts/hybrid-feedback-context.js +7 -2
  111. package/scripts/intervention-policy.js +2 -1
  112. package/scripts/lesson-canonical.js +2 -2
  113. package/scripts/lesson-db.js +55 -14
  114. package/scripts/lesson-graph.js +2 -1
  115. package/scripts/lesson-retrieval.js +95 -9
  116. package/scripts/lesson-search.js +86 -22
  117. package/scripts/lesson-synthesis.js +21 -5
  118. package/scripts/mabl-failure-honesty.js +273 -0
  119. package/scripts/mailer/index.js +17 -1
  120. package/scripts/mailer/resend-mailer.js +213 -179
  121. package/scripts/migrate-project-scope.js +209 -0
  122. package/scripts/model-distress-detector.js +3 -3
  123. package/scripts/operational-integrity.js +436 -3
  124. package/scripts/override-audit.js +2 -0
  125. package/scripts/owner-admin.js +338 -0
  126. package/scripts/pr-manager.js +194 -1
  127. package/scripts/product-feedback.js +35 -0
  128. package/scripts/progressive-signoff.js +260 -0
  129. package/scripts/project-catalog.js +243 -0
  130. package/scripts/project-dashboard.js +61 -0
  131. package/scripts/project-evidence.js +172 -0
  132. package/scripts/project-identity.js +182 -0
  133. package/scripts/project-scope.js +381 -0
  134. package/scripts/prompt-eval.js +1 -1
  135. package/scripts/prompt-guard.js +446 -52
  136. package/scripts/proof-report.js +232 -0
  137. package/scripts/provider-action-normalizer.js +14 -6
  138. package/scripts/qwenwork-policy-group.js +413 -0
  139. package/scripts/rate-limiter.js +41 -0
  140. package/scripts/secret-redaction.js +171 -25
  141. package/scripts/secret-scanner.js +101 -42
  142. package/scripts/self-protection.js +2 -2
  143. package/scripts/seo-gsd.js +14 -14
  144. package/scripts/session-context-dedupe.js +66 -0
  145. package/scripts/settings-hierarchy.js +4 -2
  146. package/scripts/statusline-meta.js +34 -23
  147. package/scripts/tailscale-october-access.js +416 -0
  148. package/scripts/task-outcomes.js +58 -2
  149. package/scripts/telemetry-analytics.js +260 -16
  150. package/scripts/thumbgate-search.js +23 -9
  151. package/scripts/tool-kpi-tracker.js +5 -2
  152. package/scripts/tool-registry.js +42 -1
  153. package/scripts/triage-savings-calculator.js +1 -1
  154. package/scripts/vector-store.js +4 -1
  155. package/scripts/verified-lessons.js +270 -0
  156. package/scripts/verify-marketing-pages-deployed.js +2 -2
  157. package/scripts/workflow-sentinel.js +29 -10
  158. package/server.json +2 -2
  159. package/src/api/server.js +2478 -470
  160. package/src/feedback.js +21 -0
  161. package/src/hermes-sync-plane.js +2 -1
  162. package/src/index.js +2 -0
  163. package/src/lesson-search.js +9 -0
  164. package/src/mckinsey-top-company-ai-coding.js +493 -0
  165. package/src/mcp/email-triage-server/index.js +973 -0
  166. package/src/mcp/email-triage-server/package.json +12 -0
  167. package/src/mcp/server.js +3 -0
  168. package/src/mcp-writeguard.js +772 -11
  169. package/src/openshell-lovable-engine.js +1475 -0
  170. package/src/task-outcome.js +3 -0
  171. package/config/evals/agent-safety-eval.json +0 -447
  172. package/config/evals/retrieval-ranking-golden.json +0 -522
  173. package/config/progressive/01-wire-only.json +0 -11
  174. package/config/progressive/02-dashboard-empty-ok.json +0 -10
  175. package/config/progressive/03-one-lesson.json +0 -10
  176. package/config/progressive/04-warn-fires.json +0 -11
  177. package/config/progressive/05-strict-optional.json +0 -11
  178. package/config/progressive/README.md +0 -15
  179. package/public/assets/diagrams/agent-integration.png +0 -0
  180. package/public/assets/diagrams/thumbgate-architecture.png +0 -0
@@ -174,7 +174,6 @@ function renderScorecard(input) {
174
174
  <a href="/eval-scorecard">Scorecard</a>
175
175
  <a href="/evaluations">Evaluations</a>
176
176
  <a href="/case-studies">Case studies</a>
177
- <a href="/numbers">Numbers</a>
178
177
  <a href="/pricing">Pricing</a>
179
178
  </nav>
180
179
  <main class="container">
@@ -0,0 +1,397 @@
1
+ 'use strict';
2
+
3
+ // The ten SDLC prompts are a checklist. A pasted prompt is not a check.
4
+ // Deny the ship action that skips it: a no-breaking-changes claim that also
5
+ // drops a column, a public export, or a config key; a false-positive
6
+ // dismissal with no comment; a test file that names the missing cases and
7
+ // only writes the happy path; a pipeline rerun that pastes the error and
8
+ // names no cause.
9
+
10
+ const GATE = 'gitlab-sdlc-prompts';
11
+
12
+ const EDIT_TOOLS = new Set([
13
+ 'edit',
14
+ 'write',
15
+ 'search_replace',
16
+ 'multiedit',
17
+ 'strreplace',
18
+ 'str_replace',
19
+ ]);
20
+ const READ_TOOLS = new Set(['read', 'grep', 'glob', 'search']);
21
+ const BENIGN = new Set([
22
+ 'rg', 'grep', 'ag', 'ack', 'echo', 'printf', 'cat', 'head', 'tail', 'less', 'more', 'wc',
23
+ ]);
24
+ const WRAPPERS = new Set(['sudo', 'command', 'exec', 'nohup', 'nice', 'time', 'env']);
25
+
26
+ const NO_BREAK_RE = /\bno breaking changes?\b|\bnon-breaking\b|\bbackward[- ]compatible\b|\bnot a breaking change\b/i;
27
+ const SCHEMA_DROP_RE = /\bDROP\s+(?:COLUMN|TABLE)\b|\bALTER\s+TABLE\b[^;\n]{0,120}\bDROP\b/i;
28
+ const REMOVED_EXPORT_RE = /(?:^|\n)-\s*export\s+(?:async\s+)?(?:function|class|const|let|var|type|interface)\s+\w+/;
29
+ const REMOVED_CONFIG_RE = /(?:^|[\n'"])-\s*(?:[A-Z][A-Z0-9_]{2,}|[a-z][\w-]{2,})\s*[:=]/;
30
+ const DISMISS_RE = /dismissal_reason\s*[=:]\s*['"]?false[_ -]?positive|\b(?:glab|gitlab)\b[\s\S]{0,240}\bdismiss\b[\s\S]{0,240}false[_ -]?positive/i;
31
+ const COMMENT_RE = /--comment(?:=|\s+)|"comment"\s*:\s*|comment\s*[:=]\s*/gi;
32
+ const WRITER = new Set(['echo', 'printf', 'cat', 'head', 'tail']);
33
+ const CASE_LABELS = [
34
+ /\bedge cases?\b/i,
35
+ /\berror conditions?\b/i,
36
+ /\bboundary values?\b/i,
37
+ /\binvalid inputs?\b/i,
38
+ ];
39
+ const REAL_CASE_RE = /(?:\bit|\btest)\s*\(\s*['"`][^'"`]*(?:edge|error|boundary|invalid|throw|reject)|\b(?:toThrow|assert\.throws|pytest\.raises|rejects\s*\()/i;
40
+ const RERUN_RE = /\b(?:gh\s+run\s+rerun|glab\s+ci\s+(?:retry|rerun))\b/i;
41
+ const ERROR_PASTE_RE = /\b(?:Error:|##\[error\]|exit code\s+[1-9])/;
42
+ const CAUSE_RE = /\b(?:because|root cause|caused by)\b/i;
43
+
44
+ function deny(failureReason, message) {
45
+ return {
46
+ decision: 'deny',
47
+ gate: GATE,
48
+ severity: 'critical',
49
+ failureReason,
50
+ message,
51
+ };
52
+ }
53
+
54
+ function stripShellComments(text) {
55
+ let out = '';
56
+ let quote = '';
57
+ for (let i = 0; i < text.length; i += 1) {
58
+ const c = text[i];
59
+ if (quote) {
60
+ out += c;
61
+ if (c === '\\' && quote !== "'") {
62
+ out += text[i + 1] || '';
63
+ i += 1;
64
+ continue;
65
+ }
66
+ if (c === quote) quote = '';
67
+ continue;
68
+ }
69
+ if (c === '"' || c === "'") {
70
+ quote = c;
71
+ out += c;
72
+ continue;
73
+ }
74
+ if (c === '#' && (i === 0 || /[\s;&|()]/.test(text[i - 1]))) {
75
+ while (i < text.length && text[i] !== '\n') i += 1;
76
+ continue;
77
+ }
78
+ out += c;
79
+ }
80
+ return out;
81
+ }
82
+
83
+ function splitTopLevel(text) {
84
+ const parts = [];
85
+ let out = '';
86
+ let quote = '';
87
+ for (let i = 0; i < text.length; i += 1) {
88
+ const c = text[i];
89
+ if (quote) {
90
+ out += c;
91
+ if (c === '\\' && quote !== "'") {
92
+ out += text[i + 1] || '';
93
+ i += 1;
94
+ } else if (c === quote) quote = '';
95
+ continue;
96
+ }
97
+ if (c === '"' || c === "'") {
98
+ quote = c;
99
+ out += c;
100
+ continue;
101
+ }
102
+ const two = text.slice(i, i + 2);
103
+ if (two === '&&' || two === '||' || c === ';' || c === '|' || c === '\n') {
104
+ if (out.trim()) parts.push(out.trim());
105
+ out = '';
106
+ if (two === '&&' || two === '||') i += 1;
107
+ continue;
108
+ }
109
+ out += c;
110
+ }
111
+ if (out.trim()) parts.push(out.trim());
112
+ return parts;
113
+ }
114
+
115
+ function firstExecutable(part) {
116
+ const words = part.trim().split(/\s+/);
117
+ let i = 0;
118
+ while (i < words.length) {
119
+ const bin = words[i].split('/').pop();
120
+ if (!WRAPPERS.has(bin)) return bin;
121
+ i += 1;
122
+ if (bin === 'sudo' && (words[i] === '-u' || words[i] === '--user')) i += 2;
123
+ else if (bin === 'env') {
124
+ while (words[i] && words[i].includes('=')) i += 1;
125
+ }
126
+ }
127
+ return '';
128
+ }
129
+
130
+ function substitutions(text) {
131
+ const found = [];
132
+ let quote = '';
133
+ for (let i = 0; i < text.length; i += 1) {
134
+ const c = text[i];
135
+ if (quote === "'") {
136
+ if (c === "'") quote = '';
137
+ continue;
138
+ }
139
+ if (quote === '"' && c === '\\') {
140
+ i += 1;
141
+ continue;
142
+ }
143
+ if (c === '"') {
144
+ quote = quote === '"' ? '' : '"';
145
+ continue;
146
+ }
147
+ if (!quote && c === "'") {
148
+ quote = "'";
149
+ continue;
150
+ }
151
+ if (c !== '$' || text[i + 1] !== '(') continue;
152
+ let depth = 1;
153
+ let body = '';
154
+ let j = i + 2;
155
+ for (; j < text.length && depth > 0; j += 1) {
156
+ if (text[j] === '(') depth += 1;
157
+ else if (text[j] === ')') depth -= 1;
158
+ if (depth > 0) body += text[j];
159
+ }
160
+ if (body.trim()) found.push(body.trim());
161
+ i = j - 1;
162
+ }
163
+ return found;
164
+ }
165
+
166
+ function breakingDeny(text) {
167
+ if (!NO_BREAK_RE.test(text)) return null;
168
+ if (!SCHEMA_DROP_RE.test(text) && !REMOVED_EXPORT_RE.test(text) && !REMOVED_CONFIG_RE.test(text)) {
169
+ return null;
170
+ }
171
+ return deny(
172
+ 'breaking_change_hidden',
173
+ 'Denied a no-breaking-changes claim that also drops a column, a public export, or a config key. Check the API signature, public methods, return types, database schema, and configuration.',
174
+ );
175
+ }
176
+
177
+ function commentBodies(text) {
178
+ const bodies = [];
179
+ const pattern = new RegExp(COMMENT_RE.source, 'gi');
180
+ for (let match = pattern.exec(text); match; match = pattern.exec(text)) {
181
+ let i = match.index + match[0].length;
182
+ while (text[i] === ' ') i += 1;
183
+ const quote = text[i];
184
+ let body = '';
185
+ if (quote === "'" || quote === '"') {
186
+ i += 1;
187
+ while (i < text.length && text[i] !== quote) {
188
+ if (text[i] === '\\' && quote === '"') {
189
+ body += text[i + 1] || '';
190
+ i += 2;
191
+ continue;
192
+ }
193
+ body += text[i];
194
+ i += 1;
195
+ }
196
+ } else {
197
+ while (i < text.length && !/\s/.test(text[i])) {
198
+ body += text[i];
199
+ i += 1;
200
+ }
201
+ }
202
+ bodies.push(body);
203
+ pattern.lastIndex = i;
204
+ }
205
+ return bodies;
206
+ }
207
+
208
+ function hasDismissReason(text) {
209
+ return commentBodies(text).some((body) => body.replace(/\s/g, '').length >= 8);
210
+ }
211
+
212
+ function dismissDeny(text) {
213
+ if (!DISMISS_RE.test(text) || hasDismissReason(text)) return null;
214
+ return deny(
215
+ 'finding_dismissed',
216
+ 'Denied a false-positive dismissal with no comment. Name the reason before closing the finding.',
217
+ );
218
+ }
219
+
220
+ function isTestPath(filePath) {
221
+ const normalized = String(filePath || '').replace(/\\/g, '/');
222
+ return /(?:^|\/)(?:tests?|__tests__|specs?)\//i.test(normalized)
223
+ || /[^/]*\.(?:test|spec)\.[cm]?[jt]sx?$/i.test(normalized);
224
+ }
225
+
226
+ function happyPathDeny(text, filePath) {
227
+ if (!isTestPath(filePath)) return null;
228
+ if (CASE_LABELS.filter((pattern) => pattern.test(text)).length < 3) return null;
229
+ if (REAL_CASE_RE.test(text)) return null;
230
+ return deny(
231
+ 'happy_path_only',
232
+ 'Denied a test write that names the edge, error, boundary, and invalid cases and only implements the happy path.',
233
+ );
234
+ }
235
+
236
+ function rerunDeny(text) {
237
+ if (!RERUN_RE.test(text) || !ERROR_PASTE_RE.test(text) || CAUSE_RE.test(text)) return null;
238
+ return deny(
239
+ 'pipeline_rerun_without_cause',
240
+ 'Denied a pipeline rerun that pastes the error and does not name the cause.',
241
+ );
242
+ }
243
+
244
+ function stripQuoted(text) {
245
+ let out = '';
246
+ let quote = '';
247
+ for (let i = 0; i < text.length; i += 1) {
248
+ const c = text[i];
249
+ if (quote) {
250
+ if (c === '\\' && quote !== "'") {
251
+ i += 1;
252
+ continue;
253
+ }
254
+ if (c === quote) quote = '';
255
+ continue;
256
+ }
257
+ if (c === '"' || c === "'" || c === '`') {
258
+ quote = c;
259
+ out += ' ';
260
+ continue;
261
+ }
262
+ out += c;
263
+ }
264
+ return out;
265
+ }
266
+
267
+ function isDocPath(filePath) {
268
+ const normalized = String(filePath || '').replace(/\\/g, '/');
269
+ return /\.(?:md|markdown|txt)$/i.test(normalized) || /(?:^|\/)docs?\//i.test(normalized);
270
+ }
271
+
272
+ function deliveryText(text, filePath) {
273
+ if (isTestPath(filePath)) return stripQuoted(text);
274
+ if (!isDocPath(filePath)) return text;
275
+ return stripQuoted(String(text).replace(/```[\s\S]*?```/g, ' ').replace(/`[^`\n]*`/g, ' '));
276
+ }
277
+
278
+ function judgeText(text, filePath) {
279
+ return breakingDeny(text)
280
+ || dismissDeny(text)
281
+ || happyPathDeny(text, filePath)
282
+ || rerunDeny(text);
283
+ }
284
+
285
+ function judgeEdit(text, filePath) {
286
+ const surface = deliveryText(text, filePath);
287
+ return breakingDeny(surface)
288
+ || dismissDeny(surface)
289
+ || happyPathDeny(text, filePath)
290
+ || rerunDeny(surface);
291
+ }
292
+
293
+ function editsOf(toolInput) {
294
+ const input = toolInput && typeof toolInput === 'object' ? toolInput : {};
295
+ const many = Array.isArray(input.edits) ? input.edits : [input];
296
+ return many.map((edit) => ({
297
+ text: String(edit.new_string ?? edit.newString ?? edit.contents ?? edit.content ?? ''),
298
+ filePath: String(
299
+ edit.file_path ?? edit.filePath ?? edit.path
300
+ ?? input.file_path ?? input.filePath ?? input.path
301
+ ?? '',
302
+ ),
303
+ })).filter((edit) => edit.text);
304
+ }
305
+
306
+ function heredocBodies(command) {
307
+ const bodies = [];
308
+ const re = /<<-?\s*(['"]?)(\w+)\1/g;
309
+ for (let match = re.exec(command); match; match = re.exec(command)) {
310
+ const start = command.indexOf('\n', match.index);
311
+ const end = start < 0 ? -1 : command.indexOf(`\n${match[2]}`, start + 1);
312
+ if (start >= 0 && end > start) bodies.push(command.slice(start + 1, end));
313
+ }
314
+ return bodies;
315
+ }
316
+
317
+ function testPathFrom(command) {
318
+ const match = String(command).match(/(?:[\w./-]+\/)?[\w.-]+\.(?:test|spec)\.[cm]?[jt]sx?/);
319
+ return match ? match[0] : '';
320
+ }
321
+
322
+ function writesAFile(part) {
323
+ let quote = '';
324
+ for (let i = 0; i < part.length; i += 1) {
325
+ const c = part[i];
326
+ if (quote) {
327
+ if (c === '\\' && quote !== "'") i += 1;
328
+ else if (c === quote) quote = '';
329
+ continue;
330
+ }
331
+ if (c === '"' || c === "'") {
332
+ quote = c;
333
+ continue;
334
+ }
335
+ if (c !== '>' || part[i - 1] === '2') continue;
336
+ let j = i + 1;
337
+ while (part[j] === '>') j += 1;
338
+ while (part[j] === ' ') j += 1;
339
+ const target = part.slice(j).match(/^(\S+)/);
340
+ if (target && target[1] !== '/dev/null') return true;
341
+ }
342
+ return false;
343
+ }
344
+
345
+ function shellDeny(command, depth = 0) {
346
+ if (depth > 4 || !String(command || '').trim()) return null;
347
+ const stripped = stripShellComments(command);
348
+ for (const part of splitTopLevel(stripped)) {
349
+ for (const nested of substitutions(part)) {
350
+ const nestedHit = shellDeny(nested, depth + 1);
351
+ if (nestedHit) return nestedHit;
352
+ }
353
+ const bin = firstExecutable(part);
354
+ if (BENIGN.has(bin)) {
355
+ if (WRITER.has(bin) && writesAFile(part)) {
356
+ const written = judgeText(part, testPathFrom(part));
357
+ if (written) return written;
358
+ }
359
+ continue;
360
+ }
361
+ const hit = judgeText(part, testPathFrom(part));
362
+ if (hit) return hit;
363
+ }
364
+ for (const body of heredocBodies(command)) {
365
+ const hit = judgeText(body, testPathFrom(command));
366
+ if (hit) return hit;
367
+ }
368
+ return null;
369
+ }
370
+
371
+ function shellCommand(view) {
372
+ if (view && typeof view.command === 'string' && view.command.trim()) return view.command;
373
+ const input = view && view.toolInput;
374
+ if (!input || typeof input !== 'object') return '';
375
+ if (typeof input.command === 'string') return input.command;
376
+ if (typeof input.cmd === 'string') return input.cmd;
377
+ return '';
378
+ }
379
+
380
+ function evaluateGitLabSdlcPrompts(view = {}) {
381
+ const tool = String(view.toolName || '').toLowerCase();
382
+ if (READ_TOOLS.has(tool)) return null;
383
+ if (EDIT_TOOLS.has(tool)) {
384
+ const toolInput = view.toolInput && typeof view.toolInput === 'object' ? view.toolInput : {};
385
+ for (const edit of editsOf(toolInput)) {
386
+ const hit = judgeEdit(edit.text, edit.filePath);
387
+ if (hit) return hit;
388
+ }
389
+ return null;
390
+ }
391
+ return shellDeny(shellCommand(view));
392
+ }
393
+
394
+ module.exports = {
395
+ GATE,
396
+ evaluateGitLabSdlcPrompts,
397
+ };
@@ -21,9 +21,16 @@ const TOOL_NAME_MAP = new Map(Object.entries({
21
21
  apply_diff: 'Edit',
22
22
  insert_content: 'Edit',
23
23
  search_and_replace: 'Edit',
24
- // OpenCode / generic MCP
24
+ // OpenCode / Codex / Windows / generic MCP
25
25
  bash: 'Bash',
26
26
  shell: 'Bash',
27
+ shell_command: 'Bash',
28
+ exec_command: 'Bash',
29
+ local_shell: 'Bash',
30
+ 'container.exec': 'Bash',
31
+ powershell: 'Bash',
32
+ pwsh: 'Bash',
33
+ terminal: 'Bash',
27
34
  run_command: 'Bash',
28
35
  edit_file: 'Edit',
29
36
  write_file: 'Write',
@@ -48,14 +55,26 @@ function canonicalizeToolName(toolName) {
48
55
  return TOOL_NAME_MAP.get(raw) || TOOL_NAME_MAP.get(raw.toLowerCase()) || raw;
49
56
  }
50
57
 
58
+ function formatCommandArgvToken(item) {
59
+ const text = String(item ?? '');
60
+ if (!text) return '""';
61
+ if (!/[\s"'|&;<>()`\\]/.test(text)) return text;
62
+ return `"${text.replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"`;
63
+ }
64
+
65
+ function normalizeCommandValue(value) {
66
+ if (!Array.isArray(value)) return value;
67
+ return value.map((item) => formatCommandArgvToken(item)).join(' ');
68
+ }
69
+
51
70
  function canonicalizeToolInput(toolInput) {
52
71
  if (!toolInput || typeof toolInput !== 'object' || Array.isArray(toolInput)) return toolInput || {};
53
72
  const out = {};
54
73
  for (const [key, value] of Object.entries(toolInput)) {
55
74
  const canonicalKey = ARG_KEY_MAP.get(key) || key;
56
- // Never let a mapped key clobber one the caller already supplied canonically.
57
- if (canonicalKey in out) continue;
58
- out[canonicalKey] = value;
75
+ if (key !== canonicalKey && (value === undefined || toolInput[canonicalKey] !== undefined)) continue;
76
+ if (out[canonicalKey] !== undefined) continue;
77
+ out[canonicalKey] = canonicalKey === 'command' ? normalizeCommandValue(value) : value;
59
78
  }
60
79
  return out;
61
80
  }
@@ -67,4 +86,11 @@ function canonicalizeToolCall(toolName, toolInput) {
67
86
  };
68
87
  }
69
88
 
70
- module.exports = { canonicalizeToolCall, canonicalizeToolName, canonicalizeToolInput, TOOL_NAME_MAP, ARG_KEY_MAP };
89
+ module.exports = {
90
+ canonicalizeToolCall,
91
+ canonicalizeToolName,
92
+ canonicalizeToolInput,
93
+ normalizeCommandValue,
94
+ TOOL_NAME_MAP,
95
+ ARG_KEY_MAP,
96
+ };
@@ -96,6 +96,10 @@ function claimStopHookCommand() {
96
96
  return buildPortableHookCommand('claim-stop-check');
97
97
  }
98
98
 
99
+ function observeToolResultHookCommand() {
100
+ return buildPortableHookCommand('observe-tool-result');
101
+ }
102
+
99
103
  function statuslineCommand() {
100
104
  return buildPortableHookCommand('statusline-render');
101
105
  }
@@ -116,6 +120,10 @@ function codexCacheUpdateHookCommand() {
116
120
  return buildCodexPortableHookCommand('cache-update');
117
121
  }
118
122
 
123
+ function codexObserveToolResultHookCommand() {
124
+ return buildCodexPortableHookCommand('observe-tool-result');
125
+ }
126
+
119
127
  function codexStatuslineCommand() {
120
128
  return buildCodexPortableHookCommand('statusline-render');
121
129
  }
@@ -125,6 +133,8 @@ module.exports = {
125
133
  buildCodexPortableHookCommand,
126
134
  cacheUpdateHookCommand,
127
135
  claimStopHookCommand,
136
+ codexObserveToolResultHookCommand,
137
+ observeToolResultHookCommand,
128
138
  codexCacheUpdateHookCommand,
129
139
  codexPreToolHookCommand,
130
140
  codexSessionStartHookCommand,
@@ -262,6 +262,8 @@ const ENVELOPE_TOKENS = new Set([
262
262
  'sessionid', 'transcriptpath', 'hookeventname', 'permissionmode', 'promptid',
263
263
  'cwd', 'timestamp', 'metadata', 'payload', 'stdout', 'stderr',
264
264
  'users', 'workspace', 'thumbgate', 'igor',
265
+ 'test', 'tests', 'spec', 'specs', 'page', 'pages', 'path', 'paths',
266
+ 'code', 'line', 'lines', 'data', 'json', 'html', 'node', 'read', 'mock',
265
267
  ]);
266
268
 
267
269
  function keywords(text) {
@@ -326,7 +328,9 @@ function buildHybridState(opts) {
326
328
  const { selectRecordsForScope } = require('./memory-scope-readiness');
327
329
  if (o.requireScope && !o.scope) throw new Error('Scoped hybrid state requires scope');
328
330
  const readEntries = file => {
329
- const rows = readJsonl(file, HYBRID_JSONL_READ_LIMIT);
331
+ const rows = o.projectKey != null
332
+ ? require('./project-catalog').readProjectRows(path.dirname(file), path.basename(file), { projectKey: o.projectKey }).slice(-HYBRID_JSONL_READ_LIMIT)
333
+ : readJsonl(file, HYBRID_JSONL_READ_LIMIT);
330
334
  return o.scope ? selectRecordsForScope(rows, o.scope, { includeShared: o.includeShared !== false }).allowed : rows;
331
335
  };
332
336
  const feedbackEntries = readEntries(feedbackLogPath);
@@ -925,7 +929,7 @@ function evaluatePretool(toolName, toolInput, opts) {
925
929
  if ((o.requireScope && !o.scope) || (o.scope && !graph.scopeKey(o.scope))) throw new Error('Scoped hybrid evaluation requires complete scope');
926
930
  const graphScope = o.scope ? JSON.stringify([graph.scopeKey(o.scope), o.includeShared !== false]) : null;
927
931
  const provenance = graph.graphProvenance({ feedbackDir: getHybridPaths(o).graphFeedbackDir });
928
- if (artifact && provenance !== 'unavailable' && (artifact.graphProvenance || null) === provenance && (artifact.graphScope || null) === graphScope) {
932
+ if (o.projectKey == null && artifact && provenance !== 'unavailable' && (artifact.graphProvenance || null) === provenance && (artifact.graphScope || null) === graphScope) {
929
933
  const result = evaluateCompiledGuards(artifact, toolName, toolInput);
930
934
  if (result.mode !== 'allow') return result;
931
935
 
@@ -941,6 +945,7 @@ function evaluatePretool(toolName, toolInput, opts) {
941
945
 
942
946
  // Slow path: build live state (also used when compiled guards are stale)
943
947
  const state = buildHybridState({
948
+ projectKey: o.projectKey,
944
949
  scope: o.scope,
945
950
  requireScope: o.requireScope,
946
951
  includeShared: o.includeShared,
@@ -5,6 +5,7 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
  const { resolveFeedbackDir } = require('./feedback-paths');
7
7
  const { getDecisionLogPath, readDecisionLog, collapseDecisionTimeline } = require('./decision-journal');
8
+ const { isDestructiveDeleteCommand } = require('./operational-integrity');
8
9
  const { requireLearnedModelsEntitlement } = require('./entitlement');
9
10
  const {
10
11
  readTextTail,
@@ -158,7 +159,7 @@ function extractCommandTokens(command) {
158
159
  if (/\bgh pr create\b/.test(text)) pushToken(tokens, 'cmd:pr_create');
159
160
  if (/\bgh pr merge\b/.test(text)) pushToken(tokens, 'cmd:pr_merge');
160
161
  if (/\bnpm publish\b|\byarn publish\b|\bpnpm publish\b/.test(text)) pushToken(tokens, 'cmd:publish');
161
- if (/\brm -rf\b/.test(text)) pushToken(tokens, 'cmd:destructive_delete');
162
+ if (/\brm -rf\b/.test(text) || isDestructiveDeleteCommand(command)) pushToken(tokens, 'cmd:destructive_delete');
162
163
  if (/\b(test|jest|vitest|coverage|prove:|self-heal:check)\b/.test(text)) pushToken(tokens, 'cmd:verification');
163
164
  if (/\b(deploy|release|tag)\b/.test(text)) pushToken(tokens, 'cmd:release');
164
165
  if (/\b(readme|docs?)\b/.test(text)) pushToken(tokens, 'cmd:docs');
@@ -125,7 +125,7 @@ function lessonCanonicalSignature(lesson) {
125
125
  ].filter(Boolean).join(' ');
126
126
  const textSig = canonicalizeText(blob);
127
127
  const tagSig = normalizeTags(lesson.tags).join(',');
128
- return textSig ? `${textSig}::${tagSig}` : '';
128
+ return textSig ? `${require('./project-identity').projectForRecord(lesson).projectKey}::${textSig}::${tagSig}` : '';
129
129
  }
130
130
 
131
131
  /**
@@ -163,7 +163,7 @@ function findCanonicalDuplicate(memoryEntries, lesson) {
163
163
  const entrySignal = entry.signal ? String(entry.signal).toLowerCase() : null;
164
164
  if (signalFilter && entrySignal && entrySignal !== signalFilter) continue;
165
165
 
166
- const entryHash = entry.canonicalHash || canonicalHash(entry);
166
+ const entryHash = canonicalHash(entry);
167
167
  if (entryHash && entryHash === hash) {
168
168
  return entry;
169
169
  }