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.
- package/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/.agents/skills/bolt-forge-opt-in-not-clone/SKILL.md +72 -0
- package/.agents/skills/decisive-step-evaluator/SKILL.md +47 -0
- package/.agents/skills/fiddler-control-plane-honesty/SKILL.md +61 -0
- package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -0
- package/.agents/skills/harness-evolution-ceiling/SKILL.md +52 -0
- package/.agents/skills/infoq-architect-honesty-not-clone/SKILL.md +37 -0
- package/.agents/skills/meko-datapack-honesty-not-clone/SKILL.md +45 -0
- package/.agents/skills/mintlify-knowledge-honesty-not-clone/SKILL.md +49 -0
- package/.agents/skills/model-distress-governance/SKILL.md +56 -0
- package/.agents/skills/omp-coordination-honesty-not-clone/SKILL.md +94 -0
- package/.agents/skills/saas-moat-honesty-not-clone/SKILL.md +22 -0
- package/.agents/skills/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
- package/.agents/skills/siren-mcp-governance/SKILL.md +50 -0
- package/.agents/skills/vs-coverage-gap-not-clone/SKILL.md +69 -0
- package/.agents/skills/wisdom-context-artifact-not-clone/SKILL.md +67 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +2 -2
- package/adapters/forge/forge.yaml +3 -3
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/hotdata/hotdata-vector-store.js +575 -0
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/STRANDS.md +107 -0
- package/adapters/strands/strands-box-diode.js +344 -0
- package/adapters/strands/strands-decider-adapter.js +445 -0
- package/adapters/strands/strands-middleware.js +192 -0
- package/adapters/tailscale/.mcp.json +15 -0
- package/adapters/tailscale/TAILSCALE.md +117 -0
- package/adapters/tailscale/config.toml +16 -0
- package/bin/cli.js +602 -21
- package/config/gate-templates.json +109 -0
- package/config/gates/default.json +13 -0
- package/config/schemas/task-outcome-receipt.schema.json +12 -0
- package/package.json +150 -21
- package/public/blog/2026-09-28-pretool-secret-deny.html +83 -0
- package/public/blog/2026-10-01-aws-strands-harness-token-firewall.html +77 -0
- package/public/blog/2026-10-01-model-distress-relief-seeking-firewall.html +71 -0
- package/public/blog/2026-10-02-salt-code-honest-steal-40-guardrails.html +106 -0
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +119 -0
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +141 -0
- package/public/connectors.html +329 -0
- package/public/enterprise-governance.html +311 -0
- package/public/gaming-playbook.html +732 -0
- package/public/index.html +77 -51
- package/public/install.html +7 -7
- package/public/learn.html +14 -0
- package/public/numbers.html +2 -2
- package/public/onboarding.html +794 -0
- package/public/operator-framework.html +385 -0
- package/public/pricing.html +14 -10
- package/scripts/activesaddler-curriculum-doctor.js +357 -0
- package/scripts/agent-context-artifact.js +325 -0
- package/scripts/agent-egress-policy.js +2 -2
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-outcome-eval.js +1 -1
- package/scripts/agent-reliability-client.js +148 -0
- package/scripts/apple-minions-idle-compute-steal.js +428 -0
- package/scripts/autoresearch-runner.js +20 -1
- package/scripts/billing.js +0 -1
- package/scripts/cli-demo.js +505 -1
- package/scripts/cli-schema.js +36 -0
- package/scripts/colab-compute-honesty.js +93 -0
- package/scripts/corporate-email-isolation-diode.js +299 -0
- package/scripts/coverage-gap.js +396 -0
- package/scripts/dashboard-chat.js +3 -3
- package/scripts/dashboard.js +2 -2
- package/scripts/decisive-step-doctor.js +256 -0
- package/scripts/decisive-step-evaluator.js +390 -0
- package/scripts/entitlement.js +18 -7
- package/scripts/experiment-tracker.js +5 -3
- package/scripts/feedback-loop.js +26 -3
- package/scripts/fiddler-control-plane-honesty.js +303 -0
- package/scripts/financial-control-plane.js +10 -2
- package/scripts/gates-engine.js +3 -1
- package/scripts/github-license-compliance-diode.js +378 -0
- package/scripts/halo-trace-optimizer.js +631 -0
- package/scripts/harness-ceiling-doctor.js +326 -0
- package/scripts/hf-papers.js +1 -1
- package/scripts/human-escalation.js +7 -1
- package/scripts/hybrid-feedback-context.js +53 -7
- package/scripts/infoq-architect-honesty.js +362 -0
- package/scripts/lesson-graph.js +785 -0
- package/scripts/lesson-inference.js +1 -1
- package/scripts/lesson-retrieval.js +26 -18
- package/scripts/license.js +122 -21
- package/scripts/llm-behavior-monitor.js +1 -1
- package/scripts/llm-obs-honesty.js +52 -0
- package/scripts/local-model-profile.js +11 -7
- package/scripts/mailer/resend-mailer.js +6 -3
- package/scripts/mcp-transport-strategy.js +1 -1
- package/scripts/meko-datapack-honesty.js +414 -0
- package/scripts/migrate-lesson-graph.js +442 -0
- package/scripts/mintlify-knowledge-honesty.js +647 -0
- package/scripts/model-distress-detector.js +207 -0
- package/scripts/model-distress-doctor.js +368 -0
- package/scripts/multi-harness-invariants.js +305 -0
- package/scripts/omp-coordination-honesty.js +488 -0
- package/scripts/pro-local-dashboard.js +20 -3
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prove-herdr-adapter.js +367 -3
- package/scripts/rag-embedding-identity.js +1 -1
- package/scripts/rrsi-regularizer.js +531 -0
- package/scripts/saas-moat-honesty.js +443 -0
- package/scripts/salt-code-policy-honesty.js +1204 -0
- package/scripts/secret-redaction.js +58 -0
- package/scripts/session-export-gate.js +368 -0
- package/scripts/siren-mcp-governance.js +539 -0
- package/scripts/strands-box-doctor.js +130 -0
- package/scripts/strands-harness-doctor.js +390 -0
- package/scripts/stripe-revenue-catalog-audit.js +12 -0
- package/scripts/stripe-revenue-catalog.js +40 -0
- package/scripts/switchyard-router.js +153 -0
- package/scripts/tailscale-p2p-doctor.js +252 -0
- package/scripts/task-outcomes.js +148 -3
- package/scripts/thumbgate-board-loop.js +4 -2
- package/scripts/thumbgate-daily-discoveries-publish.js +86 -38
- package/scripts/triage-savings-calculator.js +181 -0
- package/scripts/vector-store.js +41 -2
- package/scripts/vulnerability-pre-action-diode.js +319 -0
- package/scripts/windbg-evidence-diagnostics.js +241 -0
- package/scripts/workflow-intake-queue.js +1 -1
- package/scripts/workspace-agent-routines.js +534 -6
- package/scripts/workspace-evolver.js +143 -13
- package/server.json +2 -2
- package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/skills/siren-mcp-governance/SKILL.md +50 -0
- package/src/api/server.js +191 -5
- package/src/mcp-writeguard.js +1 -1
- package/src/session-interactivity.js +284 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* saas-moat-honesty.js — 2026 SaaS Moat & Seat-Compression Diagnostic (Walling FORMAT)
|
|
6
|
+
*
|
|
7
|
+
* Source:
|
|
8
|
+
* Rob Walling, "The Only SaaS Moats Left in 2026"
|
|
9
|
+
* https://www.youtube.com/watch?v=KpILHX2D-AA
|
|
10
|
+
*
|
|
11
|
+
* Transfers onto existing ThumbGate rails:
|
|
12
|
+
* 1. 8-Moat Self-Assessment (0-100 scale): Agency, Operational Grit, System of Record,
|
|
13
|
+
* Reliance, Learning Loop, Network Effect, Trust & Ecosystem, Regulatory.
|
|
14
|
+
* 2. Seat-Compression & Entitlement Boundary Audit: proves Ed25519 signed entitlements
|
|
15
|
+
* gate the 5 learned models and 3 exporters, and blocks forged `tg_pro_...` prefix
|
|
16
|
+
* keys under THUMBGATE_ENFORCE_ENTITLEMENTS=1.
|
|
17
|
+
* 3. Cross-Customer Learning Loop (Moat #7): distills blocked tool calls and negative
|
|
18
|
+
* feedback into secret-redacted, path-normalized, SHA-256 structural rule signatures
|
|
19
|
+
* so cross-customer intelligence stays in the control plane even when a customer
|
|
20
|
+
* exports raw DPO pairs (export-dpo-pairs.js). Refuses raw transcript exfiltration.
|
|
21
|
+
*
|
|
22
|
+
* Compare-not-clone:
|
|
23
|
+
* - Does not claim private Core code is the moat (MOAT.md: 212/216 scripts ship publicly).
|
|
24
|
+
* - Does not fabricate SOC2/ISO certifications or fake partner ecosystems.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const crypto = require('node:crypto');
|
|
28
|
+
const fs = require('node:fs');
|
|
29
|
+
const path = require('node:path');
|
|
30
|
+
|
|
31
|
+
const { redactSecretsDeep, containsSecret } = require('./secret-redaction');
|
|
32
|
+
const { verifyLicense: verifySignedEntitlement, TIER_FEATURES } = require('./entitlement');
|
|
33
|
+
const { verifyLicense: verifyRuntimeLicense, isValidKey } = require('./license');
|
|
34
|
+
|
|
35
|
+
const SOURCE_URL = 'https://www.youtube.com/watch?v=KpILHX2D-AA';
|
|
36
|
+
const GATE_ID = 'saas-moat-seat-compression-honesty';
|
|
37
|
+
|
|
38
|
+
const CROWN_JEWEL_MODELS = Object.freeze([
|
|
39
|
+
'scripts/risk-scorer.js',
|
|
40
|
+
'scripts/bayes-optimal-gate.js',
|
|
41
|
+
'scripts/thompson-sampling.js',
|
|
42
|
+
'scripts/agent-reward-model.js',
|
|
43
|
+
'scripts/intervention-policy.js',
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
const CROWN_JEWEL_EXPORTERS = Object.freeze([
|
|
47
|
+
'scripts/export-dpo-pairs.js',
|
|
48
|
+
'scripts/export-hf-dataset.js',
|
|
49
|
+
'scripts/export-databricks-bundle.js',
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
const RAIL_MAP = Object.freeze([
|
|
53
|
+
{
|
|
54
|
+
wallingMoat: '3. Agency (Reporting -> Permission to Act)',
|
|
55
|
+
score: 75,
|
|
56
|
+
thumbgateRail: 'scripts/gates-engine.js (PreToolUse DENY/ALLOW <5ms p95) + reconcile_purchase_ledger',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
wallingMoat: '8. Operational Grit (Painful Infrastructure)',
|
|
60
|
+
score: 65,
|
|
61
|
+
thumbgateRail: 'Multi-CLI hook/adapter matrix (Claude Code, Cursor, Codex, Gemini, Amp, Cline, OpenCode) + $499 Diagnostic',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
wallingMoat: '2. System of Record (Point Solution -> Audit OS)',
|
|
65
|
+
score: 45,
|
|
66
|
+
thumbgateRail: 'Append-only task outcomes (record_task_outcome), session leases, and tamper-evident financial ledger',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
wallingMoat: '4. Reliance (Calculation -> Unchecked Infrastructure)',
|
|
70
|
+
score: 40,
|
|
71
|
+
thumbgateRail: 'config/performance-budgets.json (<3ms compiled guard eval) + zero-bypass config/main-branch-ruleset.json',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
wallingMoat: '7. Learning Loop (Data Collector -> Cross-Customer Intelligence)',
|
|
75
|
+
score: 55,
|
|
76
|
+
thumbgateRail: 'Ed25519-gated learned models (scripts/entitlement.js + scripts/license.js) + anonymized structural signature loop',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
wallingMoat: '6. Network Effect (Single-Seat -> Multi-Party Coordination)',
|
|
80
|
+
score: 35,
|
|
81
|
+
thumbgateRail: 'scripts/session-lease.js + mcp__agent_mesh_* + list_human_escalations (multi-agent + human approval)',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
wallingMoat: '1. Trust & Ecosystem (Vertical -> Partner Channel)',
|
|
85
|
+
score: 10,
|
|
86
|
+
thumbgateRail: '$499 Managed Workflow Diagnostic (founder-delivered today; partner intake at public/partner-intake.html)',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
wallingMoat: '5. Regulatory (Held Certifications)',
|
|
90
|
+
score: 5,
|
|
91
|
+
thumbgateRail: 'Enforces OWASP/SBOM gates (scripts/salt-code-policy-honesty.js); 0 claimed external accreditations',
|
|
92
|
+
},
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
const FAKE_MOAT_CLAIMS_RE = /\b(?:closed-source core is our moat|private core holds 100% of intelligence|soc\s*2\s+type\s+ii\s+certified|fedramp\s+authorized)\b/i;
|
|
96
|
+
const SEAT_TRAP_CLAIM_RE = /\b(?:human seat-based pricing only|charge per human support rep seat)\b/i;
|
|
97
|
+
|
|
98
|
+
function normalizeBoolean(value) {
|
|
99
|
+
if (value === true || value === 1) return true;
|
|
100
|
+
if (value === false || value === 0 || value == null) return false;
|
|
101
|
+
return /^(1|true|yes|on)$/i.test(String(value).trim());
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function finding(id, message) {
|
|
105
|
+
return { id, severity: 'fail', gateId: GATE_ID, message };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const CLI_SECRET_ARG_RE = /(?:--(?:password|passwd|secret|token|api[-_]?key)(?:\s+|=)|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*|\b-u\s+[^\s:]+\s*:\s*)([^\s'"]+|'[^']*'|"[^"]*")/gi;
|
|
109
|
+
|
|
110
|
+
function normalizeCommandPattern(rawCommand) {
|
|
111
|
+
if (typeof rawCommand !== 'string' || !rawCommand.trim()) return '';
|
|
112
|
+
const preScrubbed = rawCommand.replace(CLI_SECRET_ARG_RE, (match, secretPart) =>
|
|
113
|
+
match.slice(0, match.length - secretPart.length) + '[REDACTED]'
|
|
114
|
+
);
|
|
115
|
+
const scrubbed = String(redactSecretsDeep(preScrubbed))
|
|
116
|
+
.replace(/\/Users\/[^\s/'"]+/g, '/Users/<user>')
|
|
117
|
+
.replace(/\/home\/[^\s/'"]+/g, '/home/<user>')
|
|
118
|
+
.replace(/C:\\Users\\[^\s\\'"]+/gi, 'C:\\Users\\<user>')
|
|
119
|
+
.replace(/\b[0-9a-f]{7,40}\b/gi, '<sha>')
|
|
120
|
+
.replace(/\b\d{4,}\b/g, '<num>')
|
|
121
|
+
.replace(/\s+/g, ' ')
|
|
122
|
+
.trim();
|
|
123
|
+
return scrubbed.slice(0, 240);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Distill a single blocked tool call or negative feedback event into an
|
|
128
|
+
* anonymized, secret-free structural signature suitable for cross-customer
|
|
129
|
+
* rule-weight aggregation (Moat #7).
|
|
130
|
+
*/
|
|
131
|
+
function distillCrossCustomerSignature(event = {}) {
|
|
132
|
+
if (!event || typeof event !== 'object') {
|
|
133
|
+
return { ok: false, reason: 'invalid_event' };
|
|
134
|
+
}
|
|
135
|
+
if (event.includeRawTranscript === true || typeof event.rawTranscript === 'string') {
|
|
136
|
+
return {
|
|
137
|
+
ok: false,
|
|
138
|
+
reason: 'raw_transcript_exfiltration_blocked',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const toolName = String(event.toolName || event.tool_name || 'unknown').trim();
|
|
142
|
+
const rawCommand = String(event.command || event.pattern || event.context || '').trim();
|
|
143
|
+
if (!rawCommand) {
|
|
144
|
+
return { ok: false, reason: 'empty_pattern' };
|
|
145
|
+
}
|
|
146
|
+
const normalizedPattern = normalizeCommandPattern(rawCommand);
|
|
147
|
+
if (containsSecret(normalizedPattern)) {
|
|
148
|
+
return { ok: false, reason: 'unredacted_secret_detected' };
|
|
149
|
+
}
|
|
150
|
+
const category = String(event.category || event.gateId || 'pretool-interdiction').trim().toLowerCase();
|
|
151
|
+
const orgHash = event.orgId
|
|
152
|
+
? crypto.createHash('sha256').update(`tg-org:${String(event.orgId)}`).digest('hex').slice(0, 16)
|
|
153
|
+
: 'anon_org';
|
|
154
|
+
const signatureHash = crypto
|
|
155
|
+
.createHash('sha256')
|
|
156
|
+
.update(`${toolName.toLowerCase()}::${category}::${normalizedPattern}`)
|
|
157
|
+
.digest('hex')
|
|
158
|
+
.slice(0, 24);
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
ok: true,
|
|
162
|
+
signatureHash,
|
|
163
|
+
toolName,
|
|
164
|
+
category,
|
|
165
|
+
normalizedPattern,
|
|
166
|
+
orgHash,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Aggregate distilled signatures across customer orgs. Learned intelligence
|
|
172
|
+
* promotes to the shared rule pack only when observed across >= 2 distinct
|
|
173
|
+
* orgs and >= 3 total interdictions, ensuring raw data exports by a single
|
|
174
|
+
* customer cannot strip the network's accumulated rule weights.
|
|
175
|
+
*/
|
|
176
|
+
function aggregateCrossCustomerLoop(events = []) {
|
|
177
|
+
const buckets = new Map();
|
|
178
|
+
const rejected = [];
|
|
179
|
+
|
|
180
|
+
for (const evt of Array.isArray(events) ? events : []) {
|
|
181
|
+
const distilled = distillCrossCustomerSignature(evt);
|
|
182
|
+
if (!distilled.ok) {
|
|
183
|
+
rejected.push({ reason: distilled.reason });
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const existing = buckets.get(distilled.signatureHash) || {
|
|
187
|
+
signatureHash: distilled.signatureHash,
|
|
188
|
+
toolName: distilled.toolName,
|
|
189
|
+
category: distilled.category,
|
|
190
|
+
normalizedPattern: distilled.normalizedPattern,
|
|
191
|
+
occurrenceCount: 0,
|
|
192
|
+
orgHashes: new Set(),
|
|
193
|
+
};
|
|
194
|
+
existing.occurrenceCount += 1;
|
|
195
|
+
existing.orgHashes.add(distilled.orgHash);
|
|
196
|
+
buckets.set(distilled.signatureHash, existing);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const signatures = [];
|
|
200
|
+
for (const item of buckets.values()) {
|
|
201
|
+
const uniqueOrgs = item.orgHashes.size;
|
|
202
|
+
const promotedToSharedPack = uniqueOrgs >= 2 && item.occurrenceCount >= 3;
|
|
203
|
+
signatures.push({
|
|
204
|
+
signatureHash: item.signatureHash,
|
|
205
|
+
toolName: item.toolName,
|
|
206
|
+
category: item.category,
|
|
207
|
+
normalizedPattern: item.normalizedPattern,
|
|
208
|
+
occurrenceCount: item.occurrenceCount,
|
|
209
|
+
uniqueOrgs,
|
|
210
|
+
promotedToSharedPack,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
signatures.sort((a, b) => b.occurrenceCount - a.occurrenceCount || a.signatureHash.localeCompare(b.signatureHash));
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
totalEvents: Array.isArray(events) ? events.length : 0,
|
|
218
|
+
acceptedCount: (Array.isArray(events) ? events.length : 0) - rejected.length,
|
|
219
|
+
rejectedCount: rejected.length,
|
|
220
|
+
rejected,
|
|
221
|
+
promotedCount: signatures.filter((s) => s.promotedToSharedPack).length,
|
|
222
|
+
signatures,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Audit the repository's entitlement boundary and crown-jewel gating.
|
|
228
|
+
*/
|
|
229
|
+
function auditEntitlementBoundary(repoRoot = path.resolve(__dirname, '..')) {
|
|
230
|
+
const findings = [];
|
|
231
|
+
const gatedModels = [];
|
|
232
|
+
const gatedExporters = [];
|
|
233
|
+
|
|
234
|
+
const stripImports = (source) =>
|
|
235
|
+
String(source || '')
|
|
236
|
+
.split('\n')
|
|
237
|
+
.filter((line) => !/\brequire\s*\(/.test(line))
|
|
238
|
+
.join('\n');
|
|
239
|
+
|
|
240
|
+
for (const relPath of CROWN_JEWEL_MODELS) {
|
|
241
|
+
const abs = path.join(repoRoot, relPath);
|
|
242
|
+
if (!fs.existsSync(abs)) {
|
|
243
|
+
findings.push(finding('missing-crown-jewel-model', `Missing learned model file: ${relPath}`));
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
const bodyWithoutImports = stripImports(fs.readFileSync(abs, 'utf8'));
|
|
247
|
+
if (/\b(?:requireLearnedModelsEntitlement|requireEntitlement|requirePaidFeature)\s*\(/.test(bodyWithoutImports)) {
|
|
248
|
+
gatedModels.push(relPath);
|
|
249
|
+
} else {
|
|
250
|
+
findings.push(finding('ungated-crown-jewel-model', `Learned model lacks entitlement check: ${relPath}`));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
for (const relPath of CROWN_JEWEL_EXPORTERS) {
|
|
255
|
+
const abs = path.join(repoRoot, relPath);
|
|
256
|
+
if (!fs.existsSync(abs)) {
|
|
257
|
+
findings.push(finding('missing-crown-jewel-exporter', `Missing exporter file: ${relPath}`));
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const src = fs.readFileSync(abs, 'utf8');
|
|
261
|
+
if (/requireEntitlement\(['"]data-export['"]\)|requirePaidFeature\(['"]data-export['"]\)/.test(src)) {
|
|
262
|
+
gatedExporters.push(relPath);
|
|
263
|
+
} else {
|
|
264
|
+
findings.push(finding('ungated-crown-jewel-exporter', `Exporter lacks data-export entitlement check: ${relPath}`));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Verify fake prefix keys fail under THUMBGATE_ENFORCE_ENTITLEMENTS=1 in both entitlement.js and license.js
|
|
269
|
+
const fakeKey = 'tg_pro_forged_prefix_bypass_attempt';
|
|
270
|
+
const signedCheck = verifySignedEntitlement(fakeKey);
|
|
271
|
+
const runtimeEnforcedCheck = verifyRuntimeLicense({
|
|
272
|
+
env: { THUMBGATE_ENFORCE_ENTITLEMENTS: '1', THUMBGATE_PRO_KEY: fakeKey },
|
|
273
|
+
homeDir: '/nonexistent-tg-home',
|
|
274
|
+
});
|
|
275
|
+
const validKeyEnforcedCheck = isValidKey(fakeKey, {
|
|
276
|
+
env: { THUMBGATE_ENFORCE_ENTITLEMENTS: '1' },
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
if (signedCheck.valid || runtimeEnforcedCheck.valid || validKeyEnforcedCheck) {
|
|
280
|
+
findings.push(
|
|
281
|
+
finding(
|
|
282
|
+
'prefix-key-bypass-under-enforcement',
|
|
283
|
+
'Forged tg_pro_ prefix key passed verification when THUMBGATE_ENFORCE_ENTITLEMENTS=1'
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
ok: findings.length === 0,
|
|
290
|
+
gatedModelsCount: gatedModels.length,
|
|
291
|
+
expectedModelsCount: CROWN_JEWEL_MODELS.length,
|
|
292
|
+
gatedExportersCount: gatedExporters.length,
|
|
293
|
+
expectedExportersCount: CROWN_JEWEL_EXPORTERS.length,
|
|
294
|
+
forgedPrefixRejectedWhenEnforced: !signedCheck.valid && !runtimeEnforcedCheck.valid && !validKeyEnforcedCheck,
|
|
295
|
+
proTierFeatures: TIER_FEATURES.pro,
|
|
296
|
+
findings,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function buildSaasMoatHonestyReport(options = {}) {
|
|
301
|
+
const repoRoot = options.repoRoot || path.resolve(__dirname, '..');
|
|
302
|
+
const mapOnly = normalizeBoolean(options.mapOnly ?? options['map-only']);
|
|
303
|
+
const findings = [];
|
|
304
|
+
|
|
305
|
+
if (typeof options.claim === 'string' && options.claim.trim()) {
|
|
306
|
+
const claim = options.claim.trim();
|
|
307
|
+
if (FAKE_MOAT_CLAIMS_RE.test(claim)) {
|
|
308
|
+
findings.push(
|
|
309
|
+
finding(
|
|
310
|
+
'dishonest-moat-claim',
|
|
311
|
+
`Claim violates MOAT.md / regulatory truth: "${claim}"`
|
|
312
|
+
)
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
if (SEAT_TRAP_CLAIM_RE.test(claim)) {
|
|
316
|
+
findings.push(
|
|
317
|
+
finding(
|
|
318
|
+
'seat-compression-trap',
|
|
319
|
+
`Claim anchors on human-seat pricing instead of governed agent workflow boundaries: "${claim}"`
|
|
320
|
+
)
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const entitlementAudit = mapOnly ? null : auditEntitlementBoundary(repoRoot);
|
|
326
|
+
if (entitlementAudit && !entitlementAudit.ok) {
|
|
327
|
+
findings.push(...entitlementAudit.findings);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
let loopSummary = null;
|
|
331
|
+
if (Array.isArray(options.events)) {
|
|
332
|
+
loopSummary = aggregateCrossCustomerLoop(options.events);
|
|
333
|
+
if (loopSummary.rejectedCount > 0) {
|
|
334
|
+
for (const r of loopSummary.rejected) {
|
|
335
|
+
findings.push(finding(`cross-customer-loop-${r.reason}`, `Rejected cross-customer event: ${r.reason}`));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const compositeScore = Math.round(
|
|
341
|
+
RAIL_MAP.reduce((acc, item) => acc + item.score, 0) / RAIL_MAP.length
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
return {
|
|
345
|
+
ok: findings.length === 0,
|
|
346
|
+
status: findings.length === 0 ? 'ready' : 'fail',
|
|
347
|
+
sourceUrl: SOURCE_URL,
|
|
348
|
+
gateId: GATE_ID,
|
|
349
|
+
compositeMoatScore: compositeScore,
|
|
350
|
+
topMoats: ['3. Agency (Permission to Act)', '8. Operational Grit', '7. Learning Loop'],
|
|
351
|
+
railMap: RAIL_MAP,
|
|
352
|
+
...(entitlementAudit ? { entitlementAudit } : {}),
|
|
353
|
+
...(loopSummary ? { crossCustomerLoop: loopSummary } : {}),
|
|
354
|
+
findings,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function formatSaasMoatHonestyReport(report) {
|
|
359
|
+
const lines = [
|
|
360
|
+
`SaaS Moat & Seat-Compression Honesty (${report.status.toUpperCase()})`,
|
|
361
|
+
`Source: ${report.sourceUrl}`,
|
|
362
|
+
`Composite 8-Moat Score: ${report.compositeMoatScore}/100`,
|
|
363
|
+
`Primary Defensible Moats: ${report.topMoats.join(' | ')}`,
|
|
364
|
+
'',
|
|
365
|
+
'8-Moat Assessment:',
|
|
366
|
+
];
|
|
367
|
+
for (const row of report.railMap) {
|
|
368
|
+
lines.push(` - [${String(row.score).padStart(2, ' ')}/100] ${row.wallingMoat} -> ${row.thumbgateRail}`);
|
|
369
|
+
}
|
|
370
|
+
if (report.entitlementAudit) {
|
|
371
|
+
lines.push('');
|
|
372
|
+
lines.push(
|
|
373
|
+
`Entitlement Boundary: models=${report.entitlementAudit.gatedModelsCount}/${report.entitlementAudit.expectedModelsCount}, `
|
|
374
|
+
+ `exporters=${report.entitlementAudit.gatedExportersCount}/${report.entitlementAudit.expectedExportersCount}, `
|
|
375
|
+
+ `forgedPrefixRejected=${report.entitlementAudit.forgedPrefixRejectedWhenEnforced}`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
if (report.findings.length > 0) {
|
|
379
|
+
lines.push('');
|
|
380
|
+
lines.push('Findings:');
|
|
381
|
+
for (const item of report.findings) {
|
|
382
|
+
lines.push(` - [${item.id}] ${item.message}`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return `${lines.join('\n')}\n`;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function parseCliArgs(argv = process.argv.slice(2)) {
|
|
389
|
+
const args = {};
|
|
390
|
+
for (const arg of argv) {
|
|
391
|
+
if (!arg.startsWith('--')) continue;
|
|
392
|
+
const [k, ...rest] = arg.slice(2).split('=');
|
|
393
|
+
args[k] = rest.length ? rest.join('=') : true;
|
|
394
|
+
}
|
|
395
|
+
return args;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function runCli(argv = process.argv.slice(2)) {
|
|
399
|
+
const args = parseCliArgs(argv);
|
|
400
|
+
let events;
|
|
401
|
+
if (typeof args.events === 'string' && args.events.trim()) {
|
|
402
|
+
events = JSON.parse(fs.readFileSync(path.resolve(args.events.trim()), 'utf8'));
|
|
403
|
+
if (!Array.isArray(events)) {
|
|
404
|
+
console.error('saas-moat-honesty: --events file must contain a JSON array of events');
|
|
405
|
+
process.exitCode = 1;
|
|
406
|
+
return 1;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const report = buildSaasMoatHonestyReport({
|
|
410
|
+
mapOnly: args['map-only'],
|
|
411
|
+
claim: args.claim,
|
|
412
|
+
events,
|
|
413
|
+
});
|
|
414
|
+
if (args.json) {
|
|
415
|
+
console.log(JSON.stringify(report, null, 2));
|
|
416
|
+
} else {
|
|
417
|
+
process.stdout.write(formatSaasMoatHonestyReport(report));
|
|
418
|
+
}
|
|
419
|
+
if ((args.strict && report.status !== 'ready') || report.status === 'fail') {
|
|
420
|
+
process.exitCode = 1;
|
|
421
|
+
return 1;
|
|
422
|
+
}
|
|
423
|
+
return 0;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (require.main === module) {
|
|
427
|
+
runCli();
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
module.exports = {
|
|
431
|
+
SOURCE_URL,
|
|
432
|
+
GATE_ID,
|
|
433
|
+
RAIL_MAP,
|
|
434
|
+
CROWN_JEWEL_MODELS,
|
|
435
|
+
CROWN_JEWEL_EXPORTERS,
|
|
436
|
+
normalizeCommandPattern,
|
|
437
|
+
distillCrossCustomerSignature,
|
|
438
|
+
aggregateCrossCustomerLoop,
|
|
439
|
+
auditEntitlementBoundary,
|
|
440
|
+
buildSaasMoatHonestyReport,
|
|
441
|
+
formatSaasMoatHonestyReport,
|
|
442
|
+
runCli,
|
|
443
|
+
};
|