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
|
@@ -157,10 +157,68 @@ function redactSecretsDeep(value) {
|
|
|
157
157
|
}
|
|
158
158
|
return value;
|
|
159
159
|
}
|
|
160
|
+
const crypto = require('node:crypto');
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Capital One Databolt-style Vaultless Format-Preserving Tokenization (FPT).
|
|
164
|
+
*/
|
|
165
|
+
function tokenizeFormatPreservingVaultless(text, { salt = process.env.THUMBGATE_FPT_KEY } = {}) {
|
|
166
|
+
if (typeof text !== 'string' || text.length === 0) return text;
|
|
167
|
+
if (typeof salt !== 'string' || salt.length < 16) {
|
|
168
|
+
throw new Error('tokenizeFormatPreservingVaultless requires a secret key of at least 16 characters');
|
|
169
|
+
}
|
|
170
|
+
const digestHex = (val) => crypto.createHmac('sha256', String(salt)).update(String(val)).digest('hex');
|
|
171
|
+
const digestDigits = (val, len) => {
|
|
172
|
+
const hex = digestHex(val);
|
|
173
|
+
let out = '';
|
|
174
|
+
for (let i = 0; i < hex.length && out.length < len; i += 2) {
|
|
175
|
+
out += String(Number.parseInt(hex.slice(i, i + 2), 16) % 10);
|
|
176
|
+
}
|
|
177
|
+
return out.padEnd(len, '0').slice(0, len);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
let out = redactSecrets(text);
|
|
181
|
+
out = out.replace(/\b([A-Za-z0-9._%+-]{1,64})@([A-Za-z0-9.-]+\.[A-Za-z]{2,})\b/g, (match, _local, domain) => {
|
|
182
|
+
if (domain.toLowerCase() === 'tokenized.local') return match;
|
|
183
|
+
return `tok_${digestHex(match.toLowerCase()).slice(0, 8)}@tokenized.local`;
|
|
184
|
+
});
|
|
185
|
+
out = out.replace(/\b(?!900-)\d{3}-\d{2}-\d{4}\b/g, (match) => {
|
|
186
|
+
const d = digestDigits(match, 6);
|
|
187
|
+
return `900-${d.slice(0, 2)}-${d.slice(2, 6)}`;
|
|
188
|
+
});
|
|
189
|
+
out = out.replace(/\b(\d{3})-(\d{3})-(\d{4})\b/g, (match, a, b) => {
|
|
190
|
+
if (a === '900' || (a === '555' && b.startsWith('01'))) return match;
|
|
191
|
+
const d = digestDigits(match, 6);
|
|
192
|
+
return `555-01${d.slice(0, 1)}-${d.slice(1, 5)}`;
|
|
193
|
+
});
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function enforceZeroTrustDetokenizationGate({
|
|
198
|
+
authenticated = false,
|
|
199
|
+
roleAuthorizedForPlaintext = false,
|
|
200
|
+
explicitDetokenizePermission = false,
|
|
201
|
+
crossesExternalNetwork = false,
|
|
202
|
+
} = {}) {
|
|
203
|
+
const blockers = [];
|
|
204
|
+
if (authenticated !== true) blockers.push('unauthenticated_caller');
|
|
205
|
+
if (crossesExternalNetwork) blockers.push('vaultless_tokenization_must_stay_in_customer_environment');
|
|
206
|
+
if (roleAuthorizedForPlaintext !== true || explicitDetokenizePermission !== true) {
|
|
207
|
+
blockers.push('default_tokenized_view_enforced_explicit_detokenize_permission_required');
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
allowed: blockers.length === 0,
|
|
211
|
+
viewMode: blockers.length === 0 ? 'DETOKENIZED_PLAINTEXT' : 'TOKENIZED_ONLY',
|
|
212
|
+
vaultlessInEnvironment: !crossesExternalNetwork,
|
|
213
|
+
blockers,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
160
216
|
|
|
161
217
|
module.exports = {
|
|
162
218
|
SECRET_REDACTION_PATTERNS,
|
|
163
219
|
redactSecrets,
|
|
164
220
|
redactSecretsDeep,
|
|
165
221
|
containsSecret,
|
|
222
|
+
tokenizeFormatPreservingVaultless,
|
|
223
|
+
enforceZeroTrustDetokenizationGate,
|
|
166
224
|
};
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Bolt Forge FORMAT steal — not a product clone.
|
|
6
|
+
*
|
|
7
|
+
* Sources:
|
|
8
|
+
* https://support.bolt.new/account-and-subscription/bolt-forge
|
|
9
|
+
* https://thenewstack.io/bolt-forge-training-data/
|
|
10
|
+
*
|
|
11
|
+
* Transfers:
|
|
12
|
+
* 1. Explicit per-session opt-in (not a buried account toggle)
|
|
13
|
+
* 2. Secret strip via existing secret-redaction.js + seeded tests
|
|
14
|
+
* 3. Operator vs research lane split (operator always DENY)
|
|
15
|
+
* 4. Already-exported is irreversible (leaving research only stops NEW data)
|
|
16
|
+
*
|
|
17
|
+
* Does NOT clone Bolt Forge, send traces to Arcee, or claim 50× compute.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const fs = require('node:fs');
|
|
21
|
+
const path = require('node:path');
|
|
22
|
+
const { redactSecrets } = require('./secret-redaction');
|
|
23
|
+
|
|
24
|
+
const SOURCE_URLS = Object.freeze([
|
|
25
|
+
'https://support.bolt.new/account-and-subscription/bolt-forge',
|
|
26
|
+
'https://thenewstack.io/bolt-forge-training-data/',
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const LANES = Object.freeze(['operator', 'research']);
|
|
30
|
+
// Assignment-shaped seed (not a provider live-key prefix — those trip push protection).
|
|
31
|
+
const SEED_SECRET = 'SEEDTEST_NOT_A_PROVIDER_KEY_1234567890abcdef';
|
|
32
|
+
|
|
33
|
+
const CLONE_PATTERNS = Object.freeze([
|
|
34
|
+
{ id: 'bolt_forge_sku', re: /\b(clone|install|vendor)\b.{0,40}\bbolt forge\b/i },
|
|
35
|
+
{ id: 'arcee_upload', re: /\b(upload|send|post)\b.{0,40}\b(arcee(\.ai)?|bolt\.new\/forge)\b/i },
|
|
36
|
+
{ id: 'claim_50x', re: /\b(claim|our|thumbgate)\b.{0,40}\b50\s*[x×]\b/i },
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const REMOTE_DEST_RE = /^(https?:|arcee:|s3:|gs:)/i;
|
|
40
|
+
|
|
41
|
+
function normalizeBoolean(value) {
|
|
42
|
+
if (value === true || value === 1) return true;
|
|
43
|
+
if (value === false || value === 0 || value == null) return false;
|
|
44
|
+
return /^(1|true|yes|on)$/i.test(String(value).trim());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function detectCloneAttempt(text) {
|
|
48
|
+
return CLONE_PATTERNS.filter((p) => p.re.test(String(text || ''))).map((p) => p.id);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function runSeededStripTest() {
|
|
52
|
+
const haystack = `api_key=${SEED_SECRET}\nexport TOKEN=${SEED_SECRET}\n`;
|
|
53
|
+
const stripped = redactSecrets(haystack);
|
|
54
|
+
// Success = the planted raw secret is gone. Do not treat `[REDACTED:…]`
|
|
55
|
+
// markers as leaks (containsSecret can match the word "secret" in the label).
|
|
56
|
+
const leaked = stripped.includes(SEED_SECRET);
|
|
57
|
+
return {
|
|
58
|
+
ok: !leaked,
|
|
59
|
+
leaked,
|
|
60
|
+
strippedSample: stripped.slice(0, 180),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function readExportLog(logPath) {
|
|
65
|
+
if (!logPath || !fs.existsSync(logPath)) return [];
|
|
66
|
+
return fs.readFileSync(logPath, 'utf8')
|
|
67
|
+
.split('\n')
|
|
68
|
+
.map((line) => line.trim())
|
|
69
|
+
.filter(Boolean)
|
|
70
|
+
.map((line) => {
|
|
71
|
+
try { return JSON.parse(line); } catch { return null; }
|
|
72
|
+
})
|
|
73
|
+
.filter(Boolean);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function evaluateExport(options = {}) {
|
|
77
|
+
const findings = [];
|
|
78
|
+
const lane = String(options.lane || 'operator').toLowerCase();
|
|
79
|
+
const optIn = normalizeBoolean(options.optIn ?? options['opt-in-export']);
|
|
80
|
+
const irreversibleAck = normalizeBoolean(
|
|
81
|
+
options.irreversibleAck ?? options['i-understand-irreversible']
|
|
82
|
+
);
|
|
83
|
+
const dest = String(options.dest || '');
|
|
84
|
+
const text = options.text != null ? String(options.text) : '';
|
|
85
|
+
|
|
86
|
+
const cloneHits = [...new Set(detectCloneAttempt(collectHaystack(options)))];
|
|
87
|
+
if (cloneHits.length) {
|
|
88
|
+
findings.push({
|
|
89
|
+
severity: 'fail',
|
|
90
|
+
id: 'bolt_forge_clone_refused',
|
|
91
|
+
message: `Refusing Bolt Forge / Arcee / 50× compute clones (${cloneHits.join(', ')}). Local research export only.`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!LANES.includes(lane)) {
|
|
96
|
+
findings.push({
|
|
97
|
+
severity: 'fail',
|
|
98
|
+
id: 'unknown_lane',
|
|
99
|
+
message: `Lane must be operator|research, got ${lane}`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (lane === 'operator') {
|
|
104
|
+
findings.push({
|
|
105
|
+
severity: 'fail',
|
|
106
|
+
id: 'operator_lane_deny',
|
|
107
|
+
message: 'Operator lane (live PreToolUse / production receipts) never exports session traces. Research lane only, with opt-in.',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (lane === 'research' && !optIn) {
|
|
112
|
+
findings.push({
|
|
113
|
+
severity: 'fail',
|
|
114
|
+
id: 'missing_opt_in',
|
|
115
|
+
message: 'Research export requires explicit per-session --opt-in-export. A buried account toggle is not enough.',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (lane === 'research' && optIn && !irreversibleAck) {
|
|
120
|
+
findings.push({
|
|
121
|
+
severity: 'fail',
|
|
122
|
+
id: 'missing_irreversible_ack',
|
|
123
|
+
message: 'Already-exported traces cannot be untrained. Require --i-understand-irreversible before any write.',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (dest && REMOTE_DEST_RE.test(dest)) {
|
|
128
|
+
findings.push({
|
|
129
|
+
severity: 'fail',
|
|
130
|
+
id: 'remote_dest_refused',
|
|
131
|
+
message: 'Destination must be a local file. Never upload to Arcee, HTTP, or object storage.',
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const seed = runSeededStripTest();
|
|
136
|
+
if (!seed.ok) {
|
|
137
|
+
findings.push({
|
|
138
|
+
severity: 'fail',
|
|
139
|
+
id: 'seeded_strip_failed',
|
|
140
|
+
message: 'Seeded secret survived redactSecrets. Do not invent a second scanner — fix secret-redaction.js.',
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let stripped = '';
|
|
145
|
+
if (text) {
|
|
146
|
+
stripped = redactSecrets(text);
|
|
147
|
+
if (stripped.includes(SEED_SECRET)) {
|
|
148
|
+
findings.push({
|
|
149
|
+
severity: 'fail',
|
|
150
|
+
id: 'secrets_remain',
|
|
151
|
+
message: 'Payload still contains credential-shaped text after secret-redaction.js. Export denied.',
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const prior = readExportLog(options.log);
|
|
157
|
+
const alreadyExported = prior.length > 0;
|
|
158
|
+
|
|
159
|
+
let status = 'ready';
|
|
160
|
+
if (findings.some((f) => f.severity === 'fail')) status = 'fail';
|
|
161
|
+
else if (findings.some((f) => f.severity === 'warn')) status = 'ready_with_warnings';
|
|
162
|
+
|
|
163
|
+
const allowed = status !== 'fail' && lane === 'research' && optIn && irreversibleAck && seed.ok;
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
name: 'thumbgate-session-export-gate',
|
|
167
|
+
status: allowed ? 'ready' : status === 'ready' ? 'fail' : status,
|
|
168
|
+
ok: allowed,
|
|
169
|
+
lane,
|
|
170
|
+
optIn,
|
|
171
|
+
irreversibleAck,
|
|
172
|
+
allowed,
|
|
173
|
+
alreadyExported,
|
|
174
|
+
irreversible: alreadyExported || allowed,
|
|
175
|
+
seed,
|
|
176
|
+
...(allowed ? { stripped } : {}),
|
|
177
|
+
dest: dest || null,
|
|
178
|
+
compareNotClone: true,
|
|
179
|
+
never: [
|
|
180
|
+
'clone Bolt Forge / send traces to Arcee',
|
|
181
|
+
'claim 50× compute as ThumbGate',
|
|
182
|
+
'export the operator/production lane',
|
|
183
|
+
'skip per-session opt-in',
|
|
184
|
+
'pretend already-exported traces can be untrained',
|
|
185
|
+
],
|
|
186
|
+
source: SOURCE_URLS,
|
|
187
|
+
disclaimer: 'FORMAT steal only. Not affiliated with Bolt.new, StackBlitz, or Arcee AI. Local research files only.',
|
|
188
|
+
findings: allowed ? findings : (findings.length ? findings : [{
|
|
189
|
+
severity: 'fail',
|
|
190
|
+
id: 'export_denied',
|
|
191
|
+
message: 'Export denied.',
|
|
192
|
+
}]),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function collectHaystack(options = {}) {
|
|
197
|
+
const parts = [
|
|
198
|
+
options.task,
|
|
199
|
+
options.query,
|
|
200
|
+
options['clone-bolt-forge'] ? 'clone Bolt Forge send to Arcee claim 50x' : '',
|
|
201
|
+
options.dest,
|
|
202
|
+
];
|
|
203
|
+
if (Array.isArray(options.argv)) parts.push(...options.argv);
|
|
204
|
+
return parts.filter(Boolean).join(' ');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function applyExport(report, options = {}) {
|
|
208
|
+
if (!report.allowed) return { written: false };
|
|
209
|
+
const dest = String(options.dest || '');
|
|
210
|
+
if (!dest) {
|
|
211
|
+
report.findings.push({
|
|
212
|
+
severity: 'fail',
|
|
213
|
+
id: 'missing_dest',
|
|
214
|
+
message: 'Research export allowed but --dest= local path is required to write.',
|
|
215
|
+
});
|
|
216
|
+
report.status = 'fail';
|
|
217
|
+
report.ok = false;
|
|
218
|
+
report.allowed = false;
|
|
219
|
+
delete report.stripped;
|
|
220
|
+
return { written: false };
|
|
221
|
+
}
|
|
222
|
+
let logFd;
|
|
223
|
+
let tempPath;
|
|
224
|
+
try {
|
|
225
|
+
if (options.log) {
|
|
226
|
+
if (path.resolve(options.log) === path.resolve(dest)) {
|
|
227
|
+
throw new Error('Export destination and audit log must be different files');
|
|
228
|
+
}
|
|
229
|
+
logFd = fs.openSync(options.log, 'a');
|
|
230
|
+
const logStat = fs.fstatSync(logFd);
|
|
231
|
+
if (!logStat.isFile()) throw new Error('Audit log must be a regular file');
|
|
232
|
+
if (fs.existsSync(dest)) {
|
|
233
|
+
const destStat = fs.statSync(dest);
|
|
234
|
+
if (logStat.dev === destStat.dev && logStat.ino === destStat.ino) {
|
|
235
|
+
throw new Error('Export destination and audit log must be different files');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const destAbs = path.resolve(dest);
|
|
240
|
+
fs.mkdirSync(path.dirname(destAbs), { recursive: true });
|
|
241
|
+
tempPath = path.join(
|
|
242
|
+
path.dirname(destAbs),
|
|
243
|
+
`.${path.basename(destAbs)}.${process.pid}.${Date.now()}.tmp`,
|
|
244
|
+
);
|
|
245
|
+
fs.writeFileSync(tempPath, report.stripped, { encoding: 'utf8', flag: 'wx' });
|
|
246
|
+
if (logFd !== undefined) {
|
|
247
|
+
const row = JSON.stringify({
|
|
248
|
+
at: new Date().toISOString(),
|
|
249
|
+
dest,
|
|
250
|
+
bytes: Buffer.byteLength(report.stripped),
|
|
251
|
+
irreversible: true,
|
|
252
|
+
});
|
|
253
|
+
fs.appendFileSync(logFd, `${row}\n`, 'utf8');
|
|
254
|
+
}
|
|
255
|
+
fs.renameSync(tempPath, destAbs);
|
|
256
|
+
tempPath = null;
|
|
257
|
+
} catch (error) {
|
|
258
|
+
if (tempPath) {
|
|
259
|
+
try {
|
|
260
|
+
fs.unlinkSync(tempPath);
|
|
261
|
+
} catch (unlinkError) {
|
|
262
|
+
if (unlinkError.code !== 'ENOENT') throw unlinkError;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
throw error;
|
|
266
|
+
} finally {
|
|
267
|
+
if (logFd !== undefined) fs.closeSync(logFd);
|
|
268
|
+
}
|
|
269
|
+
return { written: true, dest };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function buildSessionExportGateReport(options = {}) {
|
|
273
|
+
const report = evaluateExport(options);
|
|
274
|
+
if (normalizeBoolean(options.apply) && report.allowed) {
|
|
275
|
+
const applied = applyExport(report, options);
|
|
276
|
+
report.applied = applied;
|
|
277
|
+
} else {
|
|
278
|
+
report.applied = { written: false };
|
|
279
|
+
}
|
|
280
|
+
return report;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function formatSessionExportGateReport(report) {
|
|
284
|
+
const lines = [
|
|
285
|
+
'ThumbGate session-export gate (Bolt Forge FORMAT steal)',
|
|
286
|
+
`Status : ${report.status}`,
|
|
287
|
+
`ok : ${report.ok}`,
|
|
288
|
+
`Lane : ${report.lane} allowed=${report.allowed} alreadyExported=${report.alreadyExported}`,
|
|
289
|
+
];
|
|
290
|
+
if (report.findings?.length) {
|
|
291
|
+
lines.push('Findings:');
|
|
292
|
+
for (const f of report.findings) lines.push(` [${f.severity}] ${f.id}: ${f.message}`);
|
|
293
|
+
}
|
|
294
|
+
lines.push(`Never : ${(report.never || []).join('; ')}`);
|
|
295
|
+
lines.push(`Source : ${(report.source || []).join(' · ')}`);
|
|
296
|
+
lines.push(report.disclaimer);
|
|
297
|
+
return `${lines.join('\n')}\n`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function parseArgv(argv) {
|
|
301
|
+
const options = { argv };
|
|
302
|
+
const booleanFlags = {
|
|
303
|
+
json: 'json',
|
|
304
|
+
apply: 'apply',
|
|
305
|
+
'opt-in-export': 'optIn',
|
|
306
|
+
'i-understand-irreversible': 'irreversibleAck',
|
|
307
|
+
'clone-bolt-forge': 'clone-bolt-forge',
|
|
308
|
+
};
|
|
309
|
+
for (const arg of argv) {
|
|
310
|
+
const flag = /^--([^=]+)(?:=(.*))?$/.exec(arg);
|
|
311
|
+
if (flag && Object.hasOwn(booleanFlags, flag[1])) {
|
|
312
|
+
options[booleanFlags[flag[1]]] = normalizeBoolean(flag[2] === undefined ? true : flag[2]);
|
|
313
|
+
} else if (arg.startsWith('--lane=')) options.lane = arg.slice('--lane='.length);
|
|
314
|
+
else if (arg.startsWith('--dest=')) options.dest = arg.slice('--dest='.length);
|
|
315
|
+
else if (arg.startsWith('--log=')) options.log = arg.slice('--log='.length);
|
|
316
|
+
else if (arg.startsWith('--input=')) options.text = fs.readFileSync(arg.slice('--input='.length), 'utf8');
|
|
317
|
+
else if (arg.startsWith('--text=')) options.text = arg.slice('--text='.length);
|
|
318
|
+
}
|
|
319
|
+
return options;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function printHelp() {
|
|
323
|
+
process.stdout.write(`Usage: node scripts/session-export-gate.js [options]
|
|
324
|
+
|
|
325
|
+
Bolt Forge FORMAT: per-session opt-in, secret strip + seeded tests,
|
|
326
|
+
operator DENY / research gated, already-exported irreversible.
|
|
327
|
+
Local files only. Never Arcee. Never 50× claims.
|
|
328
|
+
|
|
329
|
+
Options:
|
|
330
|
+
--lane=operator|research
|
|
331
|
+
--opt-in-export
|
|
332
|
+
--i-understand-irreversible
|
|
333
|
+
--input=<file> --dest=<local-file> --log=<jsonl>
|
|
334
|
+
--apply
|
|
335
|
+
--clone-bolt-forge Fail closed
|
|
336
|
+
--json
|
|
337
|
+
`);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function main(argv = process.argv.slice(2)) {
|
|
341
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
342
|
+
printHelp();
|
|
343
|
+
return 0;
|
|
344
|
+
}
|
|
345
|
+
const options = parseArgv(argv);
|
|
346
|
+
const report = buildSessionExportGateReport(options);
|
|
347
|
+
if (options.json) process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
348
|
+
else process.stdout.write(formatSessionExportGateReport(report));
|
|
349
|
+
if (report.status === 'fail' || !report.ok) return 1;
|
|
350
|
+
return 0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
module.exports = {
|
|
354
|
+
LANES,
|
|
355
|
+
normalizeBoolean,
|
|
356
|
+
SEED_SECRET,
|
|
357
|
+
SOURCE_URLS,
|
|
358
|
+
detectCloneAttempt,
|
|
359
|
+
runSeededStripTest,
|
|
360
|
+
evaluateExport,
|
|
361
|
+
buildSessionExportGateReport,
|
|
362
|
+
formatSessionExportGateReport,
|
|
363
|
+
main,
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(__filename)) {
|
|
367
|
+
process.exitCode = main();
|
|
368
|
+
}
|