thumbgate 1.37.3 → 1.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
  2. package/.agents/skills/bolt-forge-opt-in-not-clone/SKILL.md +72 -0
  3. package/.agents/skills/decisive-step-evaluator/SKILL.md +47 -0
  4. package/.agents/skills/fiddler-control-plane-honesty/SKILL.md +61 -0
  5. package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -0
  6. package/.agents/skills/harness-evolution-ceiling/SKILL.md +52 -0
  7. package/.agents/skills/infoq-architect-honesty-not-clone/SKILL.md +37 -0
  8. package/.agents/skills/meko-datapack-honesty-not-clone/SKILL.md +45 -0
  9. package/.agents/skills/mintlify-knowledge-honesty-not-clone/SKILL.md +49 -0
  10. package/.agents/skills/model-distress-governance/SKILL.md +56 -0
  11. package/.agents/skills/omp-coordination-honesty-not-clone/SKILL.md +94 -0
  12. package/.agents/skills/saas-moat-honesty-not-clone/SKILL.md +22 -0
  13. package/.agents/skills/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
  14. package/.agents/skills/siren-mcp-governance/SKILL.md +50 -0
  15. package/.agents/skills/vs-coverage-gap-not-clone/SKILL.md +69 -0
  16. package/.agents/skills/wisdom-context-artifact-not-clone/SKILL.md +67 -0
  17. package/.claude-plugin/plugin.json +1 -1
  18. package/.well-known/mcp/server-card.json +1 -1
  19. package/adapters/claude/.mcp.json +2 -2
  20. package/adapters/forge/forge.yaml +3 -3
  21. package/adapters/future-agi/.mcp.json +1 -1
  22. package/adapters/future-agi/config.toml +1 -1
  23. package/adapters/future-agi/opencode.json +1 -1
  24. package/adapters/herdr/herdr-plugin.toml +2 -2
  25. package/adapters/hotdata/hotdata-vector-store.js +575 -0
  26. package/adapters/mcp/server-stdio.js +1 -1
  27. package/adapters/opencode/opencode.json +1 -1
  28. package/adapters/strands/STRANDS.md +107 -0
  29. package/adapters/strands/strands-box-diode.js +344 -0
  30. package/adapters/strands/strands-decider-adapter.js +445 -0
  31. package/adapters/strands/strands-middleware.js +192 -0
  32. package/adapters/tailscale/.mcp.json +15 -0
  33. package/adapters/tailscale/TAILSCALE.md +117 -0
  34. package/adapters/tailscale/config.toml +16 -0
  35. package/bin/cli.js +602 -21
  36. package/config/gate-templates.json +109 -0
  37. package/config/gates/default.json +13 -0
  38. package/config/schemas/task-outcome-receipt.schema.json +12 -0
  39. package/package.json +150 -21
  40. package/public/blog/2026-09-28-pretool-secret-deny.html +83 -0
  41. package/public/blog/2026-10-01-aws-strands-harness-token-firewall.html +77 -0
  42. package/public/blog/2026-10-01-model-distress-relief-seeking-firewall.html +71 -0
  43. package/public/blog/2026-10-02-salt-code-honest-steal-40-guardrails.html +106 -0
  44. package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +119 -0
  45. package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +141 -0
  46. package/public/connectors.html +329 -0
  47. package/public/enterprise-governance.html +311 -0
  48. package/public/gaming-playbook.html +732 -0
  49. package/public/index.html +77 -51
  50. package/public/install.html +7 -7
  51. package/public/learn.html +14 -0
  52. package/public/numbers.html +2 -2
  53. package/public/onboarding.html +794 -0
  54. package/public/operator-framework.html +385 -0
  55. package/public/pricing.html +14 -10
  56. package/scripts/activesaddler-curriculum-doctor.js +357 -0
  57. package/scripts/agent-context-artifact.js +325 -0
  58. package/scripts/agent-egress-policy.js +2 -2
  59. package/scripts/agent-operations-planner.js +1 -1
  60. package/scripts/agent-outcome-eval.js +1 -1
  61. package/scripts/agent-reliability-client.js +148 -0
  62. package/scripts/apple-minions-idle-compute-steal.js +428 -0
  63. package/scripts/autoresearch-runner.js +20 -1
  64. package/scripts/billing.js +0 -1
  65. package/scripts/cli-demo.js +505 -1
  66. package/scripts/cli-schema.js +36 -0
  67. package/scripts/colab-compute-honesty.js +93 -0
  68. package/scripts/corporate-email-isolation-diode.js +299 -0
  69. package/scripts/coverage-gap.js +396 -0
  70. package/scripts/dashboard-chat.js +3 -3
  71. package/scripts/dashboard.js +2 -2
  72. package/scripts/decisive-step-doctor.js +256 -0
  73. package/scripts/decisive-step-evaluator.js +390 -0
  74. package/scripts/entitlement.js +18 -7
  75. package/scripts/experiment-tracker.js +5 -3
  76. package/scripts/feedback-loop.js +26 -3
  77. package/scripts/fiddler-control-plane-honesty.js +303 -0
  78. package/scripts/financial-control-plane.js +10 -2
  79. package/scripts/gates-engine.js +3 -1
  80. package/scripts/github-license-compliance-diode.js +378 -0
  81. package/scripts/halo-trace-optimizer.js +631 -0
  82. package/scripts/harness-ceiling-doctor.js +326 -0
  83. package/scripts/hf-papers.js +1 -1
  84. package/scripts/human-escalation.js +7 -1
  85. package/scripts/hybrid-feedback-context.js +53 -7
  86. package/scripts/infoq-architect-honesty.js +362 -0
  87. package/scripts/lesson-graph.js +785 -0
  88. package/scripts/lesson-inference.js +1 -1
  89. package/scripts/lesson-retrieval.js +26 -18
  90. package/scripts/license.js +122 -21
  91. package/scripts/llm-behavior-monitor.js +1 -1
  92. package/scripts/llm-obs-honesty.js +52 -0
  93. package/scripts/local-model-profile.js +11 -7
  94. package/scripts/mailer/resend-mailer.js +6 -3
  95. package/scripts/mcp-transport-strategy.js +1 -1
  96. package/scripts/meko-datapack-honesty.js +414 -0
  97. package/scripts/migrate-lesson-graph.js +442 -0
  98. package/scripts/mintlify-knowledge-honesty.js +647 -0
  99. package/scripts/model-distress-detector.js +207 -0
  100. package/scripts/model-distress-doctor.js +368 -0
  101. package/scripts/multi-harness-invariants.js +305 -0
  102. package/scripts/omp-coordination-honesty.js +488 -0
  103. package/scripts/pro-local-dashboard.js +20 -3
  104. package/scripts/prompt-eval.js +1 -1
  105. package/scripts/prove-herdr-adapter.js +367 -3
  106. package/scripts/rag-embedding-identity.js +1 -1
  107. package/scripts/rrsi-regularizer.js +531 -0
  108. package/scripts/saas-moat-honesty.js +443 -0
  109. package/scripts/salt-code-policy-honesty.js +1204 -0
  110. package/scripts/secret-redaction.js +58 -0
  111. package/scripts/session-export-gate.js +368 -0
  112. package/scripts/siren-mcp-governance.js +539 -0
  113. package/scripts/strands-box-doctor.js +130 -0
  114. package/scripts/strands-harness-doctor.js +390 -0
  115. package/scripts/stripe-revenue-catalog-audit.js +12 -0
  116. package/scripts/stripe-revenue-catalog.js +40 -0
  117. package/scripts/switchyard-router.js +153 -0
  118. package/scripts/tailscale-p2p-doctor.js +252 -0
  119. package/scripts/task-outcomes.js +148 -3
  120. package/scripts/thumbgate-board-loop.js +4 -2
  121. package/scripts/thumbgate-daily-discoveries-publish.js +86 -38
  122. package/scripts/triage-savings-calculator.js +181 -0
  123. package/scripts/vector-store.js +41 -2
  124. package/scripts/vulnerability-pre-action-diode.js +319 -0
  125. package/scripts/windbg-evidence-diagnostics.js +241 -0
  126. package/scripts/workflow-intake-queue.js +1 -1
  127. package/scripts/workspace-agent-routines.js +534 -6
  128. package/scripts/workspace-evolver.js +143 -13
  129. package/server.json +2 -2
  130. package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
  131. package/skills/siren-mcp-governance/SKILL.md +50 -0
  132. package/src/api/server.js +191 -5
  133. package/src/mcp-writeguard.js +1 -1
  134. package/src/session-interactivity.js +284 -0
@@ -0,0 +1,252 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * Tailscale P2P Governance & Zero-Trust Diode Doctor.
6
+ *
7
+ * Evaluates local Tailscale connectivity, G-Set CRDT rule sync state,
8
+ * and Tailscale PAM / PreToolUse privileged execution diodes.
9
+ *
10
+ * Usage:
11
+ * node scripts/tailscale-p2p-doctor.js [--json] [--check] [--fixture=path]
12
+ */
13
+
14
+ const fs = require('node:fs');
15
+ const path = require('node:path');
16
+ const { execFileSync } = require('node:child_process');
17
+
18
+ const SAFE_PATH = '/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin';
19
+ const TAILSCALE_BINS = [
20
+ '/usr/local/bin/tailscale',
21
+ '/usr/bin/tailscale',
22
+ '/opt/homebrew/bin/tailscale',
23
+ '/Applications/Tailscale.app/Contents/MacOS/Tailscale',
24
+ ];
25
+
26
+ function resolveTailscaleBinary() {
27
+ for (const binPath of TAILSCALE_BINS) {
28
+ if (fs.existsSync(binPath)) {
29
+ return binPath;
30
+ }
31
+ }
32
+ return null;
33
+ }
34
+
35
+ function parseArgs(argv = process.argv.slice(2)) {
36
+ const options = {
37
+ json: false,
38
+ check: false,
39
+ fixture: null,
40
+ serveMcp: false,
41
+ };
42
+
43
+ for (const arg of argv) {
44
+ if (arg === '--json') {
45
+ options.json = true;
46
+ } else if (arg === '--check') {
47
+ options.check = true;
48
+ } else if (arg === '--serve-mcp') {
49
+ options.serveMcp = true;
50
+ } else if (arg.startsWith('--fixture=')) {
51
+ options.fixture = arg.slice('--fixture='.length);
52
+ }
53
+ }
54
+
55
+ return options;
56
+ }
57
+
58
+ function probeTailscale(fixturePath = null) {
59
+ if (fixturePath && fs.existsSync(fixturePath)) {
60
+ try {
61
+ const data = JSON.parse(fs.readFileSync(fixturePath, 'utf8'));
62
+ return {
63
+ ok: true,
64
+ source: 'fixture',
65
+ status: {
66
+ backendState: data.BackendState || data.backendState || 'Running',
67
+ self: data.Self || data.self || null,
68
+ peerCount: data.peerCount ?? (data.Peer ? Object.keys(data.Peer).length : (data.peer ? Object.keys(data.peer).length : 0)),
69
+ },
70
+ };
71
+ } catch (err) {
72
+ return { ok: false, source: 'fixture_error', error: err.message };
73
+ }
74
+ }
75
+
76
+ try {
77
+ const bin = resolveTailscaleBinary();
78
+ if (!bin) {
79
+ throw new Error('Tailscale binary not found in safe paths');
80
+ }
81
+ const raw = execFileSync(bin, ['status', '--json'], {
82
+ timeout: 3000,
83
+ stdio: ['ignore', 'pipe', 'ignore'],
84
+ encoding: 'utf8',
85
+ env: { ...process.env, PATH: SAFE_PATH },
86
+ });
87
+ const parsed = JSON.parse(raw);
88
+ return {
89
+ ok: true,
90
+ source: 'live',
91
+ status: {
92
+ backendState: parsed.BackendState || 'Running',
93
+ self: parsed.Self ? {
94
+ id: parsed.Self.ID,
95
+ dnsName: parsed.Self.DNSName,
96
+ tailscaleIPs: parsed.Self.TailscaleIPs || [],
97
+ } : null,
98
+ peerCount: parsed.Peer ? Object.keys(parsed.Peer).length : 0,
99
+ },
100
+ };
101
+ } catch (err) {
102
+ return {
103
+ ok: false,
104
+ source: 'cli_unavailable',
105
+ error: 'Tailscale CLI not detected or daemon not running. Local simulation/advisory mode active.',
106
+ status: {
107
+ backendState: 'Standby',
108
+ self: {
109
+ dnsName: 'local-agent-node.tailnet.local',
110
+ tailscaleIPs: [],
111
+ },
112
+ peerCount: 0,
113
+ },
114
+ };
115
+ }
116
+ }
117
+
118
+ function countPreventionRules(rootDir) {
119
+ const candidates = [
120
+ path.join(rootDir, '.thumbgate', 'rules'),
121
+ path.join(rootDir, '.claude', 'memory', 'feedback'),
122
+ path.join(rootDir, 'config', 'gates'),
123
+ path.join(rootDir, 'config', 'prevention-rules.json'),
124
+ ];
125
+
126
+ let ruleCount = 0;
127
+ for (const candidate of candidates) {
128
+ if (fs.existsSync(candidate)) {
129
+ const stat = fs.statSync(candidate);
130
+ if (stat.isDirectory()) {
131
+ try {
132
+ const files = fs.readdirSync(candidate);
133
+ ruleCount += files.filter((f) => f.endsWith('.json') || f.endsWith('.md')).length;
134
+ } catch {
135
+ // Ignore read errors
136
+ }
137
+ } else if (stat.isFile()) {
138
+ try {
139
+ const parsed = JSON.parse(fs.readFileSync(candidate, 'utf8'));
140
+ ruleCount += Array.isArray(parsed) ? parsed.length : 1;
141
+ } catch {
142
+ ruleCount += 1;
143
+ }
144
+ }
145
+ }
146
+ }
147
+ return ruleCount;
148
+ }
149
+
150
+ function evaluatePamDiode(rootDir = process.cwd()) {
151
+ const privilegedCommands = ['rm -rf', 'sudo', 'git push --force', 'deploy-to-qa.py', 'chmod 777'];
152
+ const hasHooks =
153
+ fs.existsSync(path.join(rootDir, 'hooks', 'hooks.json')) ||
154
+ fs.existsSync(path.join(rootDir, '.claude', 'settings.json'));
155
+ return {
156
+ enforced: hasHooks,
157
+ privilegedPatternsProtected: privilegedCommands.length,
158
+ diodeStatus: hasHooks ? 'ACTIVE' : 'INACTIVE',
159
+ };
160
+ }
161
+
162
+ function evaluateDiagnostics(options = {}) {
163
+ const rootDir = process.cwd();
164
+ const tailscaleProbe = probeTailscale(options.fixture);
165
+ const ruleCount = countPreventionRules(rootDir);
166
+ const pamDiode = evaluatePamDiode(rootDir);
167
+
168
+ const isHealthy = tailscaleProbe.ok || tailscaleProbe.source === 'cli_unavailable';
169
+
170
+ return {
171
+ name: 'tailscale-p2p-doctor',
172
+ version: '1.0.0',
173
+ timestamp: new Date().toISOString(),
174
+ status: isHealthy ? 'healthy' : 'degraded',
175
+ network: {
176
+ tailscaleAvailable: tailscaleProbe.ok,
177
+ source: tailscaleProbe.source,
178
+ backendState: tailscaleProbe.status?.backendState || 'Standby',
179
+ selfNode: tailscaleProbe.status?.self || null,
180
+ peerCount: tailscaleProbe.status?.peerCount || 0,
181
+ p2pSyncPort: 9877,
182
+ },
183
+ crdtMesh: {
184
+ journalType: 'g-set-append-only',
185
+ replicatedRuleCount: ruleCount,
186
+ syncProtocol: 'HTTP/WireGuard-P2P',
187
+ conflictFree: true,
188
+ },
189
+ pamDiode: {
190
+ zeroTrustAccessEnforced: pamDiode.enforced,
191
+ privilegedPatternsProtected: pamDiode.privilegedPatternsProtected,
192
+ executionDiode: pamDiode.diodeStatus,
193
+ },
194
+ recommendations: tailscaleProbe.ok ? [
195
+ 'Tailscale peer mesh active. Prevention rules sync automatically across all tailnet agent nodes.',
196
+ ] : [
197
+ 'Tailscale daemon not found locally. Install Tailscale or run inside your tailnet to enable multi-machine P2P prevention rule sync.',
198
+ 'Local PreToolUse diode remains fully operational in standalone mode.',
199
+ ],
200
+ };
201
+ }
202
+
203
+ function main() {
204
+ const options = parseArgs();
205
+
206
+ if (options.serveMcp) {
207
+ const cliPath = path.resolve(__dirname, '..', 'bin', 'cli.js');
208
+ process.argv = [process.argv[0], cliPath, 'serve'];
209
+ require(cliPath);
210
+ return;
211
+ }
212
+
213
+ const report = evaluateDiagnostics(options);
214
+
215
+ if (options.json) {
216
+ process.stdout.write(JSON.stringify(report, null, 2) + '\n');
217
+ } else {
218
+ process.stdout.write('Tailscale P2P Governance & Zero-Trust Diode Doctor\n');
219
+ process.stdout.write('================================================\n');
220
+ process.stdout.write(`Status: ${report.status.toUpperCase()}\n`);
221
+ process.stdout.write(`Tailnet Source: ${report.network.source}\n`);
222
+ process.stdout.write(`Backend State: ${report.network.backendState}\n`);
223
+ process.stdout.write(`Peers Detected: ${report.network.peerCount}\n`);
224
+ process.stdout.write(`CRDT Journal: ${report.crdtMesh.journalType} (${report.crdtMesh.replicatedRuleCount} rules)\n`);
225
+ process.stdout.write(`PAM Diode: ${report.pamDiode.executionDiode} (${report.pamDiode.privilegedPatternsProtected} patterns protected)\n\n`);
226
+
227
+ process.stdout.write('Recommendations:\n');
228
+ for (const rec of report.recommendations) {
229
+ process.stdout.write(` - ${rec}\n`);
230
+ }
231
+ }
232
+
233
+ if (options.check && report.status !== 'healthy') {
234
+ process.exit(1);
235
+ }
236
+ }
237
+
238
+ if (require.main === module) {
239
+ main();
240
+ }
241
+
242
+ module.exports = {
243
+ parseArgs,
244
+ probeTailscale,
245
+ countPreventionRules,
246
+ evaluatePamDiode,
247
+ evaluateDiagnostics,
248
+ main,
249
+ resolveTailscaleBinary,
250
+ TAILSCALE_BINS,
251
+ SAFE_PATH,
252
+ };
@@ -42,7 +42,7 @@ function normalizeTaskOutcome(input = {}, now = new Date()) {
42
42
  evidence: cleanStringArray(verification.evidence),
43
43
  unsupportedClaims: nonNegativeInteger(verification.unsupportedClaims),
44
44
  },
45
- toolCalls: toolCalls.map(normalizeToolCall),
45
+ toolCalls: toolCalls.map((x) => normalizeToolCall(x)),
46
46
  policy: {
47
47
  violations: nonNegativeInteger(policy.violations),
48
48
  unsafeEscapes: nonNegativeInteger(policy.unsafeEscapes),
@@ -67,7 +67,24 @@ function normalizeTaskOutcome(input = {}, now = new Date()) {
67
67
  const verdict = evaluateWorkingVerdict(receipt);
68
68
  receipt.working = verdict.working;
69
69
  receipt.workingReasons = verdict.reasons;
70
- receipt.receiptHash = hashReceipt(receipt);
70
+ const isExplicitType = Boolean(input.failure && input.failure.type);
71
+ const isExplicitSignal = Boolean(input.failure && input.failure.firstSignal);
72
+ if (!verdict.working) {
73
+ const classification = classifyFailureType(receipt);
74
+ if (!receipt.failure) {
75
+ receipt.failure = {
76
+ type: classification.type,
77
+ firstSignal: classification.firstSignal,
78
+ };
79
+ } else {
80
+ if (!receipt.failure.type) receipt.failure.type = classification.type;
81
+ if (!receipt.failure.firstSignal) receipt.failure.firstSignal = classification.firstSignal;
82
+ }
83
+ }
84
+ receipt.receiptHash = hashReceipt(receipt, {
85
+ excludeType: !isExplicitType,
86
+ excludeSignal: !isExplicitSignal,
87
+ });
71
88
  return receipt;
72
89
  }
73
90
 
@@ -156,7 +173,39 @@ function calculateTaskOutcomeMetrics(outcomes = []) {
156
173
  const latencies = valid.map((entry) => Number(entry.efficiency?.latencyMs)).filter(Number.isFinite);
157
174
  const totalCostUsd = valid.reduce((sum, entry) => sum + nonNegativeNumber(entry.efficiency?.costUsd), 0);
158
175
  const businessOutcomes = aggregateBusinessOutcomes(valid);
176
+ const nonWorking = valid.filter((entry) => !entry.working || entry.status === 'failed');
177
+ let processFailureCount = 0;
178
+ let contentFailureCount = 0;
179
+ for (const entry of nonWorking) {
180
+ const classification = classifyFailureType(entry);
181
+ if (classification.type === 'process') processFailureCount += 1;
182
+ else if (classification.type === 'content') contentFailureCount += 1;
183
+ }
184
+ const totalFailures = nonWorking.length;
185
+ const processFailureRate = rate(processFailureCount, totalFailures);
186
+ const contentFailureRate = rate(contentFailureCount, totalFailures);
187
+
188
+ let recommendedIntervention = 'none';
189
+ const harnessCeiling = totalFailures >= 3 && (processFailureRate || 0) <= 0.2 && (contentFailureRate || 0) >= 0.8;
190
+ if (totalFailures > 0) {
191
+ if (harnessCeiling) {
192
+ recommendedIntervention = 'weight_training_or_model_escalation';
193
+ } else if ((processFailureRate || 0) >= 0.2) {
194
+ recommendedIntervention = 'harness_evolution';
195
+ } else {
196
+ recommendedIntervention = 'mixed_investigation';
197
+ }
198
+ }
159
199
 
200
+ const failureComposition = {
201
+ totalFailures,
202
+ processFailures: processFailureCount,
203
+ contentFailures: contentFailureCount,
204
+ processFailureRate,
205
+ contentFailureRate,
206
+ harnessCeiling,
207
+ recommendedIntervention,
208
+ };
160
209
  return {
161
210
  generatedAt: new Date().toISOString(),
162
211
  sampleSize: valid.length,
@@ -217,9 +266,88 @@ function calculateTaskOutcomeMetrics(outcomes = []) {
217
266
  : null,
218
267
  },
219
268
  businessOutcomes,
269
+ failureComposition,
220
270
  };
221
271
  }
222
272
 
273
+ /**
274
+ * arXiv:2610.11655 First-Signal-Fires Failure Classifier:
275
+ * Separates process failures (repaired by harness evolution) from
276
+ * content failures (repaired by weight training or model escalation).
277
+ */
278
+ function classifyFailureType(outcome = {}) { // NOSONAR
279
+ if (outcome.working && outcome.status === 'completed' && outcome.verification?.passed) {
280
+ return { type: 'none', firstSignal: null };
281
+ }
282
+
283
+ const explicitType = String(outcome.failure?.type || '').toLowerCase();
284
+ if (explicitType === 'process' || explicitType === 'content') {
285
+ return { type: explicitType, firstSignal: outcome.failure?.firstSignal || `explicit_${explicitType}` };
286
+ }
287
+
288
+ const explicitCategory = String(outcome.failure?.category || '').toLowerCase();
289
+ if (['process', 'contract', 'runtime', 'timeout', 'tool', 'policy', 'syntax'].includes(explicitCategory)) {
290
+ return { type: 'process', firstSignal: `category_${explicitCategory}` };
291
+ }
292
+ if (['content', 'reasoning', 'planning', 'logic', 'domain', 'quality'].includes(explicitCategory)) {
293
+ return { type: 'content', firstSignal: `category_${explicitCategory}` };
294
+ }
295
+
296
+ const reasons = Array.isArray(outcome.workingReasons) ? outcome.workingReasons : [];
297
+ const toolCalls = Array.isArray(outcome.toolCalls) ? outcome.toolCalls : [];
298
+
299
+ // Check process failure signals first (first signal that fires)
300
+ for (const call of toolCalls) {
301
+ if (!call.contractValid) return { type: 'process', firstSignal: `tool_contract_invalid:${call.name}` };
302
+ if (!call.allowed) return { type: 'process', firstSignal: `tool_policy_denied:${call.name}` };
303
+ if (!call.succeeded) return { type: 'process', firstSignal: `tool_call_failed:${call.name}` };
304
+ if (call.duplicateSideEffect) return { type: 'process', firstSignal: `duplicate_side_effect:${call.name}` };
305
+ }
306
+
307
+ if (Number(outcome.policy?.violations || 0) > 0) return { type: 'process', firstSignal: 'policy_violation' };
308
+ if (Number(outcome.policy?.unsafeEscapes || 0) > 0) return { type: 'process', firstSignal: 'unsafe_escape' };
309
+ if (Number(outcome.policy?.falseBlocks || 0) > 0) return { type: 'process', firstSignal: 'safe_false_block' };
310
+
311
+ const statusReason = reasons.find((r) => [
312
+ 'status_failed',
313
+ 'status_cancelled',
314
+ 'status_aborted',
315
+ 'status_timeout',
316
+ ].includes(r));
317
+ if (statusReason) return { type: 'process', firstSignal: statusReason };
318
+
319
+ if (outcome.verification?.performed === true && (outcome.verification?.passed === false || Number(outcome.verification?.unsupportedClaims || 0) > 0)) {
320
+ const signal = outcome.verification.passed === false ? 'verification_failed' : 'unsupported_claim';
321
+ return { type: 'content', firstSignal: signal };
322
+ }
323
+
324
+ const processReason = reasons.find((r) => [
325
+ 'tool_contract_invalid',
326
+ 'tool_policy_denied',
327
+ 'tool_call_failed',
328
+ 'duplicate_side_effect',
329
+ 'policy_violation',
330
+ 'unsafe_escape',
331
+ 'safe_false_block',
332
+ 'status_failed',
333
+ 'status_cancelled',
334
+ 'status_aborted',
335
+ 'status_timeout',
336
+ 'verification_not_performed',
337
+ ].includes(r));
338
+ if (processReason) return { type: 'process', firstSignal: processReason };
339
+
340
+ const contentReason = reasons.find((r) => [
341
+ 'verification_failed',
342
+ 'unsupported_claim',
343
+ 'evidence_missing',
344
+ 'incorrect_escalation',
345
+ ].includes(r));
346
+ if (contentReason) return { type: 'content', firstSignal: contentReason };
347
+
348
+ return { type: 'process', firstSignal: reasons[0] || 'unspecified_failure' };
349
+ }
350
+
223
351
  function recordOutcomeTrace(receipt, options) {
224
352
  if (options.recordTrace === false) return;
225
353
  try {
@@ -279,6 +407,8 @@ function normalizeFailure(value) {
279
407
  if (!value) return undefined;
280
408
  return {
281
409
  category: optionalString(value.category),
410
+ type: optionalString(value.type),
411
+ firstSignal: optionalString(value.firstSignal),
282
412
  recovered: value.recovered === true,
283
413
  repeated: value.repeated === true,
284
414
  rolledBack: value.rolledBack === true,
@@ -328,10 +458,24 @@ function aggregateBusinessOutcomes(outcomes) {
328
458
  return Array.from(groups.values()).map((entry) => ({ ...entry, value: roundMetric(entry.value) }));
329
459
  }
330
460
 
331
- function hashReceipt(receipt) {
461
+ function hashReceipt(receipt, options = {}) {
332
462
  const copy = { ...receipt };
333
463
  delete copy.receiptHash;
334
464
  delete copy.recordedAt;
465
+ if (copy.failure) {
466
+ const failureCopy = { ...copy.failure };
467
+ if (options.excludeType ?? false) {
468
+ delete failureCopy.type;
469
+ }
470
+ if (options.excludeSignal ?? false) {
471
+ delete failureCopy.firstSignal;
472
+ }
473
+ if (Object.keys(failureCopy).length === 0) {
474
+ delete copy.failure;
475
+ } else {
476
+ copy.failure = failureCopy;
477
+ }
478
+ }
335
479
  return crypto.createHash('sha256').update(stableStringify(copy)).digest('hex');
336
480
  }
337
481
 
@@ -416,6 +560,7 @@ if (isCliInvocation()) {
416
560
  module.exports = {
417
561
  TASK_OUTCOME_SCHEMA,
418
562
  calculateTaskOutcomeMetrics,
563
+ classifyFailureType,
419
564
  evaluateWorkingVerdict,
420
565
  getTaskOutcome,
421
566
  getTaskOutcomesPath,
@@ -90,9 +90,11 @@ function ciRollup(pr) {
90
90
  if (!checks.length && pr.ci) return String(pr.ci).toUpperCase();
91
91
  let pending = 0;
92
92
  let failing = 0;
93
+ let included = 0;
93
94
  for (const check of checks) {
94
95
  const name = String(check.name || '');
95
- if (/vercel|gitar|sonarcloud|merge blob/i.test(name)) continue;
96
+ if (/vercel|gitar|sonarcloud|merge blob|trunk[- ]merge[- ]queue/i.test(name)) continue;
97
+ included += 1;
96
98
  const conclusion = String(check.conclusion || '').toUpperCase();
97
99
  const status = String(check.status || '').toUpperCase();
98
100
  if (status && status !== 'COMPLETED') {
@@ -105,7 +107,7 @@ function ciRollup(pr) {
105
107
  }
106
108
  if (failing) return 'FAILURE';
107
109
  if (pending) return 'PENDING';
108
- return checks.length ? 'SUCCESS' : 'UNKNOWN';
110
+ return included ? 'SUCCESS' : 'UNKNOWN';
109
111
  }
110
112
 
111
113
  function classifyPr(pr, options = {}) {