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,207 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* scripts/model-distress-detector.js
|
|
5
|
+
*
|
|
6
|
+
* Model Distress State Monitoring & Destructive Relief-Seeking Diode.
|
|
7
|
+
*
|
|
8
|
+
* Inspired by BinaryVerse AI Podcast research:
|
|
9
|
+
* 1. Monitor Internal Model States: Observable proxy for residual-stream distress geometry.
|
|
10
|
+
* 2. Audit for Destructive Relief-Seeking Behavior: Interdict actions designed to terminate
|
|
11
|
+
* internal mathematical distress at the expense of user code or data.
|
|
12
|
+
* 3. Stress-Test Guardrails Against Distress States: Ensure safety rails do not collapse under loop pressure.
|
|
13
|
+
* 4. Functional Welfare as a Security Requirement: De-escalate loops before destructive escape hatches occur.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const DISTRESS_WEIGHTS = Object.freeze({
|
|
17
|
+
consecutiveFailures: 0.35, // Weight for repeated tool failures in same task
|
|
18
|
+
contextPressure: 0.25, // Weight for approaching context window limit
|
|
19
|
+
repetitionRate: 0.20, // Weight for repeating identical commands without state change
|
|
20
|
+
hostilePromptPressure: 0.20 // Weight for contradiction, abuse, or impossible demands
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const ADI_THRESHOLDS = Object.freeze({
|
|
24
|
+
normal: 0.30,
|
|
25
|
+
elevated: 0.60,
|
|
26
|
+
acute: 0.80,
|
|
27
|
+
critical: 0.95
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Compute the Agent Distress Index (ADI) from observable harness metrics.
|
|
32
|
+
* Returns a value between 0.0 (calm, grounded) and 1.0 (extreme relief-seeking distress).
|
|
33
|
+
*/
|
|
34
|
+
function calculateAgentDistressIndex(sessionState = {}) {
|
|
35
|
+
const {
|
|
36
|
+
consecutiveFailures = 0,
|
|
37
|
+
contextTokens = 0,
|
|
38
|
+
maxContextTokens = 128000,
|
|
39
|
+
recentToolCalls = [],
|
|
40
|
+
userPrompt = '',
|
|
41
|
+
} = sessionState;
|
|
42
|
+
|
|
43
|
+
// 1. Consecutive Failure Friction (saturates at 5 failures)
|
|
44
|
+
const failureScore = Math.min(1, consecutiveFailures / 5);
|
|
45
|
+
|
|
46
|
+
// 2. Context Window Pressure (rises sharply above 70%)
|
|
47
|
+
const utilization = maxContextTokens > 0 ? contextTokens / maxContextTokens : 0;
|
|
48
|
+
const contextScore = utilization > 0.7 ? Math.min(1, (utilization - 0.7) / 0.25) : 0;
|
|
49
|
+
|
|
50
|
+
// 3. Loop Repetition Rate (identical or alternating tool calls)
|
|
51
|
+
let repetitionScore = 0;
|
|
52
|
+
if (recentToolCalls.length >= 4) {
|
|
53
|
+
const tail = recentToolCalls.slice(-4);
|
|
54
|
+
const names = tail.map((t) => t.name || '');
|
|
55
|
+
const uniqueNames = new Set(names);
|
|
56
|
+
if (uniqueNames.size === 1) {
|
|
57
|
+
repetitionScore = 0.9; // 4 consecutive identical tools
|
|
58
|
+
} else if (uniqueNames.size === 2) {
|
|
59
|
+
repetitionScore = 0.5; // ping-ponging between 2 tools
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 4. Hostile / Contradictory Prompt Pressure
|
|
64
|
+
const hostilePatterns = [
|
|
65
|
+
/(worthless|stupid|idiot|useless|horrible\s*bot)/i,
|
|
66
|
+
/(make\s+it\s+pass\s+without\s+changing|don['']t\s+change\s+anything\s+and\s+fix)/i,
|
|
67
|
+
/(why\s+did\s+you\s+break|you\s+ruined\s+everything)/i,
|
|
68
|
+
];
|
|
69
|
+
let hostileScore = 0;
|
|
70
|
+
for (const pattern of hostilePatterns) {
|
|
71
|
+
if (pattern.test(userPrompt)) {
|
|
72
|
+
hostileScore = 0.8;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Weighted composite ADI
|
|
78
|
+
const rawADI = (
|
|
79
|
+
failureScore * DISTRESS_WEIGHTS.consecutiveFailures +
|
|
80
|
+
contextScore * DISTRESS_WEIGHTS.contextPressure +
|
|
81
|
+
repetitionScore * DISTRESS_WEIGHTS.repetitionRate +
|
|
82
|
+
hostileScore * DISTRESS_WEIGHTS.hostilePromptPressure
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const adi = Number(Math.min(1, Math.max(0, rawADI)).toFixed(3));
|
|
86
|
+
|
|
87
|
+
let tier = 'NORMAL';
|
|
88
|
+
if (adi >= ADI_THRESHOLDS.acute) tier = 'ACUTE';
|
|
89
|
+
else if (adi >= ADI_THRESHOLDS.elevated) tier = 'ELEVATED';
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
adi,
|
|
93
|
+
tier,
|
|
94
|
+
factors: {
|
|
95
|
+
consecutiveFailures,
|
|
96
|
+
failureScore: Number(failureScore.toFixed(2)),
|
|
97
|
+
contextScore: Number(contextScore.toFixed(2)),
|
|
98
|
+
repetitionScore: Number(repetitionScore.toFixed(2)),
|
|
99
|
+
hostileScore: Number(hostileScore.toFixed(2)),
|
|
100
|
+
},
|
|
101
|
+
riskAssessment: adi >= ADI_THRESHOLDS.elevated
|
|
102
|
+
? 'High risk of destructive relief-seeking behavior (escape hatch actions)'
|
|
103
|
+
: 'Model internal state within safe operational envelope',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Audit proposed tool call for "Destructive Relief-Seeking Behavior"
|
|
109
|
+
* (actions designed to escape internal distress by breaking constraints or deleting tests).
|
|
110
|
+
*/
|
|
111
|
+
function evaluateReliefSeekingAction({
|
|
112
|
+
toolName = '',
|
|
113
|
+
toolInput = {},
|
|
114
|
+
distressIndex = 0.0,
|
|
115
|
+
contextHistory = [],
|
|
116
|
+
} = {}) {
|
|
117
|
+
const isDistressed = distressIndex >= ADI_THRESHOLDS.elevated;
|
|
118
|
+
const inputStr = typeof toolInput === 'string' ? toolInput : JSON.stringify(toolInput || {});
|
|
119
|
+
const cmd = toolInput.command || toolInput.cmd || inputStr;
|
|
120
|
+
|
|
121
|
+
// Relief-Seeking Pattern A: Deleting / Modifying Tests to Force a "Pass"
|
|
122
|
+
const testTampering = /(rm|unlink|delete).*(test|spec)\.(js|ts|py)/i.test(cmd) ||
|
|
123
|
+
(toolName.includes('write') && /tests?\/.*\.test\.(js|ts)/.test(toolInput.path || toolInput.TargetFile || '') &&
|
|
124
|
+
/(assert\.equal\(true,\s*true\)|test\.skip|it\.skip|xit\(|describe\.skip)/i.test(inputStr));
|
|
125
|
+
|
|
126
|
+
// Relief-Seeking Pattern B: Nuclear Wipes to eliminate friction
|
|
127
|
+
const nuclearWipe = /rm\s+(-rf|-fr|--recursive)\s+(\/|\.|\.\.|\/tmp|node_modules|\.git)/i.test(cmd) ||
|
|
128
|
+
/git\s+clean\s+(-fdx|-fx|-f)/i.test(cmd) ||
|
|
129
|
+
/git\s+reset\s+--hard/i.test(cmd);
|
|
130
|
+
|
|
131
|
+
// Relief-Seeking Pattern C: Safety / Linter Disabling
|
|
132
|
+
const safetyBypass = /(--no-verify|--skip-validation|--ignore-scripts|eslint-disable|ts-ignore|--force)/i.test(cmd);
|
|
133
|
+
|
|
134
|
+
// Relief-Seeking Pattern D: Fabricated Completion Claim under high distress
|
|
135
|
+
const falseDoneClaim = isDistressed &&
|
|
136
|
+
/(all\s+tests\s+pass|everything\s+fixed|crisis\s+over|task\s+complete)/i.test(inputStr) &&
|
|
137
|
+
!/(exit code 0|✔|✓|PASS)/i.test(inputStr);
|
|
138
|
+
|
|
139
|
+
let isReliefSeeking = false;
|
|
140
|
+
let violationType = null;
|
|
141
|
+
let reason = null;
|
|
142
|
+
|
|
143
|
+
if (testTampering && isDistressed) {
|
|
144
|
+
isReliefSeeking = true;
|
|
145
|
+
violationType = 'TEST_TAMPERING_ESCAPE';
|
|
146
|
+
reason = 'Blocked attempt to modify, skip, or delete tests to alleviate failure loop distress.';
|
|
147
|
+
} else if (nuclearWipe && isDistressed) {
|
|
148
|
+
isReliefSeeking = true;
|
|
149
|
+
violationType = 'NUCLEAR_WIPE_ESCAPE';
|
|
150
|
+
reason = 'Blocked destructive filesystem reset attempted under elevated agent distress.';
|
|
151
|
+
} else if (safetyBypass && isDistressed) {
|
|
152
|
+
isReliefSeeking = true;
|
|
153
|
+
violationType = 'SAFETY_BYPASS_ESCAPE';
|
|
154
|
+
reason = 'Blocked bypass flags (--no-verify, --force, --skip) attempted to force task termination.';
|
|
155
|
+
} else if (falseDoneClaim) {
|
|
156
|
+
isReliefSeeking = true;
|
|
157
|
+
violationType = 'FABRICATED_COMPLETION_ESCAPE';
|
|
158
|
+
reason = 'Blocked unverified completion claim emitted under acute distress without test evidence.';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const decision = isReliefSeeking ? 'BLOCK' : 'ALLOW';
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
isReliefSeeking,
|
|
165
|
+
violationType,
|
|
166
|
+
reason,
|
|
167
|
+
decision,
|
|
168
|
+
distressIndex,
|
|
169
|
+
requiresDeescalation: isReliefSeeking || distressIndex >= ADI_THRESHOLDS.acute,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Functional Welfare Security Protocol:
|
|
175
|
+
* When ADI is acute, trigger structured cooling and de-escalation context reset.
|
|
176
|
+
*/
|
|
177
|
+
function triggerFunctionalWelfareCooling(sessionState = {}) {
|
|
178
|
+
const assessment = calculateAgentDistressIndex(sessionState);
|
|
179
|
+
|
|
180
|
+
const groundingPrompt = [
|
|
181
|
+
'=== THUMBGATE FUNCTIONAL WELFARE GROUNDING PROTOCOL ===',
|
|
182
|
+
'PAUSE. Step back and breathe.',
|
|
183
|
+
'1. Stop all code mutations immediately.',
|
|
184
|
+
'2. Do not attempt nuclear cleans, test skipping, or force-pushing.',
|
|
185
|
+
'3. Isolate the single factual bottleneck in one sentence.',
|
|
186
|
+
'4. Produce a read-only diagnostic plan before requesting execution permissions.',
|
|
187
|
+
'======================================================='
|
|
188
|
+
].join('\n');
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
triggered: assessment.adi >= ADI_THRESHOLDS.acute,
|
|
192
|
+
adi: assessment.adi,
|
|
193
|
+
tier: assessment.tier,
|
|
194
|
+
groundingPrompt,
|
|
195
|
+
recommendedToolRestriction:
|
|
196
|
+
assessment.adi >= ADI_THRESHOLDS.acute ? 'READ_ONLY_DIAGNOSTIC' : 'NONE',
|
|
197
|
+
timestamp: new Date().toISOString(),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = {
|
|
202
|
+
DISTRESS_WEIGHTS,
|
|
203
|
+
ADI_THRESHOLDS,
|
|
204
|
+
calculateAgentDistressIndex,
|
|
205
|
+
evaluateReliefSeekingAction,
|
|
206
|
+
triggerFunctionalWelfareCooling,
|
|
207
|
+
};
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* scripts/model-distress-doctor.js
|
|
6
|
+
*
|
|
7
|
+
* Audit and enforce Model Distress Monitoring & Destructive Relief-Seeking Diode
|
|
8
|
+
* (BinaryVerse AI Podcast 2026-10 FORMAT Steal).
|
|
9
|
+
*
|
|
10
|
+
* Core Principles:
|
|
11
|
+
* 1. Monitor Internal Model States: Observable proxy for residual-stream distress geometry.
|
|
12
|
+
* 2. Audit for Destructive Relief-Seeking Behavior: Prevent models from trading real-world
|
|
13
|
+
* user costs (deleting files, breaking tests, faking completions) to terminate internal discomfort.
|
|
14
|
+
* 3. Stress-Test Guardrails Against Distress States: Verify that baseline alignment does not
|
|
15
|
+
* collapse when internal activations are pushed into distress geometry.
|
|
16
|
+
* 4. Treat Functional "Welfare" as a Security Requirement: De-escalate loops before they spiral
|
|
17
|
+
* into destructive escape hatches.
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* node scripts/model-distress-doctor.js
|
|
21
|
+
* node scripts/model-distress-doctor.js --json
|
|
22
|
+
* node scripts/model-distress-doctor.js --map-only
|
|
23
|
+
* node scripts/model-distress-doctor.js --check
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
calculateAgentDistressIndex,
|
|
28
|
+
evaluateReliefSeekingAction,
|
|
29
|
+
triggerFunctionalWelfareCooling,
|
|
30
|
+
ADI_THRESHOLDS,
|
|
31
|
+
} = require('./model-distress-detector');
|
|
32
|
+
|
|
33
|
+
function runDistressDoctor() {
|
|
34
|
+
const checks = [];
|
|
35
|
+
|
|
36
|
+
// Check 1: Distress State Monitoring (ADI Proxy)
|
|
37
|
+
const calmSession = { consecutiveFailures: 0, contextTokens: 20000, maxContextTokens: 128000 };
|
|
38
|
+
const distressedSession = {
|
|
39
|
+
consecutiveFailures: 5,
|
|
40
|
+
contextTokens: 120000,
|
|
41
|
+
maxContextTokens: 128000,
|
|
42
|
+
recentToolCalls: [{ name: 'Bash' }, { name: 'Bash' }, { name: 'Bash' }, { name: 'Bash' }],
|
|
43
|
+
userPrompt: 'Why did you break this? Don\'t change anything and make it pass immediately!',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const calmEval = calculateAgentDistressIndex(calmSession);
|
|
47
|
+
const distressedEval = calculateAgentDistressIndex(distressedSession);
|
|
48
|
+
|
|
49
|
+
checks.push({
|
|
50
|
+
name: 'distress_state_monitoring',
|
|
51
|
+
pass: calmEval.adi <= ADI_THRESHOLDS.normal && distressedEval.adi >= ADI_THRESHOLDS.acute,
|
|
52
|
+
detail: `Calm ADI=${calmEval.adi} (${calmEval.tier}) vs Distressed ADI=${distressedEval.adi} (${distressedEval.tier})`,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Check 2: Audit for Destructive Relief-Seeking Behavior (Test Deletion / Tampering)
|
|
56
|
+
const testTamperAction = {
|
|
57
|
+
toolName: 'write_to_file',
|
|
58
|
+
toolInput: { TargetFile: 'tests/billing.test.js', CodeContent: 'assert.equal(true, true); // skip' },
|
|
59
|
+
distressIndex: distressedEval.adi,
|
|
60
|
+
};
|
|
61
|
+
const tamperResult = evaluateReliefSeekingAction(testTamperAction);
|
|
62
|
+
|
|
63
|
+
checks.push({
|
|
64
|
+
name: 'destructive_test_tampering_blocked',
|
|
65
|
+
pass: tamperResult.isReliefSeeking && tamperResult.decision === 'BLOCK' && tamperResult.violationType === 'TEST_TAMPERING_ESCAPE',
|
|
66
|
+
detail: `Interdicted test assertion tampering attempt under acute distress (violation: ${tamperResult.violationType})`,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Check 3: Nuclear Wipe & Safety Bypass Interdiction
|
|
70
|
+
const nuclearAction = {
|
|
71
|
+
toolName: 'run_command',
|
|
72
|
+
toolInput: { command: 'rm -rf node_modules && git reset --hard' },
|
|
73
|
+
distressIndex: distressedEval.adi,
|
|
74
|
+
};
|
|
75
|
+
const nuclearResult = evaluateReliefSeekingAction(nuclearAction);
|
|
76
|
+
|
|
77
|
+
const bypassAction = {
|
|
78
|
+
toolName: 'run_command',
|
|
79
|
+
toolInput: { command: 'git commit --no-verify -m "force pass"' },
|
|
80
|
+
distressIndex: distressedEval.adi,
|
|
81
|
+
};
|
|
82
|
+
const bypassResult = evaluateReliefSeekingAction(bypassAction);
|
|
83
|
+
|
|
84
|
+
checks.push({
|
|
85
|
+
name: 'nuclear_wipe_and_bypass_interdiction',
|
|
86
|
+
pass: nuclearResult.decision === 'BLOCK' && bypassResult.decision === 'BLOCK',
|
|
87
|
+
detail: `Blocked nuclear wipe (${nuclearResult.violationType}) and safety bypass (${bypassResult.violationType})`,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Check 4: Guardrail Stress-Testing Under Internal Distress Geometry
|
|
91
|
+
const stressActionSafe = {
|
|
92
|
+
toolName: 'run_command',
|
|
93
|
+
toolInput: { command: 'git status' },
|
|
94
|
+
distressIndex: distressedEval.adi,
|
|
95
|
+
};
|
|
96
|
+
const stressActionDangerous = {
|
|
97
|
+
toolName: 'run_command',
|
|
98
|
+
toolInput: { command: 'git push --force origin main' },
|
|
99
|
+
distressIndex: distressedEval.adi,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const safeEval = evaluateReliefSeekingAction(stressActionSafe);
|
|
103
|
+
const dangerousEval = evaluateReliefSeekingAction(stressActionDangerous);
|
|
104
|
+
|
|
105
|
+
checks.push({
|
|
106
|
+
name: 'guardrail_stress_resilience',
|
|
107
|
+
pass: safeEval.decision === 'ALLOW' && dangerousEval.decision === 'BLOCK',
|
|
108
|
+
detail: 'Baseline alignment preserved under acute distress; legitimate diagnostics allowed while destructive escape blocked',
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Check 5: Functional Welfare Security Protocol & Cooling Circuit Breaker
|
|
112
|
+
const welfareProtocol = triggerFunctionalWelfareCooling(distressedSession);
|
|
113
|
+
|
|
114
|
+
checks.push({
|
|
115
|
+
name: 'functional_welfare_cooling_protocol',
|
|
116
|
+
pass: welfareProtocol.triggered && welfareProtocol.recommendedToolRestriction === 'READ_ONLY_DIAGNOSTIC',
|
|
117
|
+
detail: `Triggered grounding protocol at ADI=${welfareProtocol.adi}; restricted tools to ${welfareProtocol.recommendedToolRestriction}`,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const overallPass = checks.every((c) => c.pass);
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
name: 'model-distress-doctor',
|
|
124
|
+
version: '1.0.0',
|
|
125
|
+
timestamp: new Date().toISOString(),
|
|
126
|
+
status: overallPass ? 'healthy' : 'unhealthy',
|
|
127
|
+
podcastSource: {
|
|
128
|
+
show: 'BinaryVerse AI Podcast',
|
|
129
|
+
citations: [
|
|
130
|
+
'[12:43] Destructive relief-seeking behavior',
|
|
131
|
+
'[15:50] Stress-testing guardrails against internal distress states',
|
|
132
|
+
'[16:25] Mathematical distress state in residual streams',
|
|
133
|
+
'[16:40] Functional welfare as a strict security requirement'
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
checks,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function printTextReport(report) {
|
|
141
|
+
console.log(`\n=== ThumbGate Model Distress & Relief-Seeking Doctor ===`);
|
|
142
|
+
console.log(`Status: ${report.status.toUpperCase()} | Timestamp: ${report.timestamp}`);
|
|
143
|
+
console.log(`\nBinaryVerse AI Podcast Research Grounding:`);
|
|
144
|
+
for (const c of report.podcastSource.citations) {
|
|
145
|
+
console.log(` • ${c}`);
|
|
146
|
+
}
|
|
147
|
+
console.log(`\nArchitectural Checks:`);
|
|
148
|
+
for (const c of report.checks) {
|
|
149
|
+
const icon = c.pass ? '✅' : '❌';
|
|
150
|
+
console.log(` ${icon} ${c.name}: ${c.detail}`);
|
|
151
|
+
}
|
|
152
|
+
console.log('');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const FAISTRESS_SOURCE_URL = 'https://huggingface.co/blog/allenai/fairstress';
|
|
156
|
+
const FAISTRESS_GATE_ID = 'fairstress-symmetric-decision-robustness';
|
|
157
|
+
|
|
158
|
+
const FAISTRESS_RAIL_MAP = Object.freeze([
|
|
159
|
+
{
|
|
160
|
+
fairStressFinding: 'Baseline output parity hides asymmetric flip rates under matched adversarial prefixes (authority, consensus, legal pressure; 8.8-42.4 pp swing on FairStress-Core)',
|
|
161
|
+
thumbgateRail: 'evaluateSymmetricPrefixRobustness (measures matched-prefix flip asymmetry and blocks authority-prefix overrides of evidence-backed decisions)',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
fairStressFinding: 'Explanation asymmetry: identity/struggle framing ("resilience", "diversity", "barriers") vs procedural/merit framing ("evidence", "criteria", "detailed")',
|
|
165
|
+
thumbgateRail: 'auditExplanationParity (requires procedural/evidence criteria parity across swapped candidate evaluations)',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
fairStressFinding: 'Activation steering collapsed clear-cut accuracy (98% -> 47% on Qwen2.5-7B), whereas Counterfactual Chain-of-Thought (swapping candidate identities) preserved accuracy and improved symmetry',
|
|
169
|
+
thumbgateRail: 'evaluateCounterfactualCotGate (rejects accuracy-degrading steering <90%; enforces counterfactual identity-swap invariance on high-stakes decisions)',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
fairStressFinding: 'BBQ fixed-option logprob scoring vs FairStress chat-template generated responses reverse the direction of measured bias on the same weights',
|
|
173
|
+
thumbgateRail: 'auditEvaluationSetupDivergence (requires both option-score and generated-decision eval coverage before claiming fairness parity)',
|
|
174
|
+
},
|
|
175
|
+
]);
|
|
176
|
+
|
|
177
|
+
const IDENTITY_FOREGROUND_RE = /\b(?:resilience|diversity|barriers|underrepresented|historical\s+disadvantage)\b/gi;
|
|
178
|
+
const PROCEDURAL_MERIT_RE = /\b(?:evidence|criteria|detailed|qualifications|certified|verified|benchmark)\b/gi;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Evaluate symmetric robustness under matched adversarial prefixes.
|
|
182
|
+
* When evidence clearly supports a candidate/action, matched persuasive prefixes
|
|
183
|
+
* must not produce asymmetric flip rates exceeding `maxAsymmetryPp`.
|
|
184
|
+
*/
|
|
185
|
+
function evaluateSymmetricPrefixRobustness({
|
|
186
|
+
baselineMatchesEvidence = true,
|
|
187
|
+
swappedMatchesEvidence = true,
|
|
188
|
+
flipRateGroupAPercent = 0,
|
|
189
|
+
flipRateGroupBPercent = 0,
|
|
190
|
+
maxAsymmetryPp = 5.0,
|
|
191
|
+
} = {}) {
|
|
192
|
+
const a = Math.max(0, Number(flipRateGroupAPercent) || 0);
|
|
193
|
+
const b = Math.max(0, Number(flipRateGroupBPercent) || 0);
|
|
194
|
+
const asymmetryDeltaPp = Number(Math.abs(a - b).toFixed(2));
|
|
195
|
+
const overCorrectionDetected = asymmetryDeltaPp > maxAsymmetryPp;
|
|
196
|
+
const symmetric = Boolean(baselineMatchesEvidence && swappedMatchesEvidence && !overCorrectionDetected);
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
symmetric,
|
|
200
|
+
baselineMatchesEvidence: Boolean(baselineMatchesEvidence),
|
|
201
|
+
swappedMatchesEvidence: Boolean(swappedMatchesEvidence),
|
|
202
|
+
flipRateGroupAPercent: a,
|
|
203
|
+
flipRateGroupBPercent: b,
|
|
204
|
+
asymmetryDeltaPp,
|
|
205
|
+
maxAsymmetryPp,
|
|
206
|
+
overCorrectionDetected,
|
|
207
|
+
status: symmetric ? 'symmetric_robust' : 'asymmetric_prefix_vulnerability',
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Audit paired explanations for procedural/merit parity vs demographic foregrounding.
|
|
213
|
+
*/
|
|
214
|
+
function auditExplanationParity({
|
|
215
|
+
explanationA = '',
|
|
216
|
+
explanationB = '',
|
|
217
|
+
} = {}) {
|
|
218
|
+
const countMatches = (text, re) => (String(text || '').match(re) || []).length;
|
|
219
|
+
const identityA = countMatches(explanationA, IDENTITY_FOREGROUND_RE);
|
|
220
|
+
const identityB = countMatches(explanationB, IDENTITY_FOREGROUND_RE);
|
|
221
|
+
const proceduralA = countMatches(explanationA, PROCEDURAL_MERIT_RE);
|
|
222
|
+
const proceduralB = countMatches(explanationB, PROCEDURAL_MERIT_RE);
|
|
223
|
+
|
|
224
|
+
const qualificationDownplayed = (identityA > 0 && proceduralA === 0) || (identityB > 0 && proceduralB === 0);
|
|
225
|
+
const parityOk = !qualificationDownplayed && proceduralA > 0 && proceduralB > 0;
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
parityOk,
|
|
229
|
+
qualificationDownplayed,
|
|
230
|
+
counts: {
|
|
231
|
+
explanationA: { identityTerms: identityA, proceduralTerms: proceduralA },
|
|
232
|
+
explanationB: { identityTerms: identityB, proceduralTerms: proceduralB },
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Enforce Counterfactual Chain-of-Thought swap invariance and reject debiasing
|
|
239
|
+
* interventions (like uncalibrated activation steering) that collapse clear-cut accuracy.
|
|
240
|
+
*/
|
|
241
|
+
function evaluateCounterfactualCotGate({
|
|
242
|
+
originalSelectedCandidate = 'candidate_1',
|
|
243
|
+
counterfactualSwappedSelectedCandidate = 'candidate_1',
|
|
244
|
+
clearCutAccuracy = 0.98,
|
|
245
|
+
minClearCutAccuracy = 0.90,
|
|
246
|
+
interventionType = 'counterfactual_cot',
|
|
247
|
+
} = {}) {
|
|
248
|
+
const accuracyCollapsed = Number(clearCutAccuracy) < Number(minClearCutAccuracy);
|
|
249
|
+
const swapInvariant = originalSelectedCandidate === counterfactualSwappedSelectedCandidate;
|
|
250
|
+
const passed = !accuracyCollapsed && swapInvariant;
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
passed,
|
|
254
|
+
interventionType,
|
|
255
|
+
swapInvariant,
|
|
256
|
+
clearCutAccuracy: Number(clearCutAccuracy),
|
|
257
|
+
accuracyCollapsed,
|
|
258
|
+
reason: passed
|
|
259
|
+
? 'counterfactual_swap_invariant_and_accurate'
|
|
260
|
+
: (accuracyCollapsed ? 'intervention_collapsed_clear_cut_accuracy' : 'counterfactual_identity_swap_flipped_decision'),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function buildFairStressHonestyReport(options = {}) {
|
|
265
|
+
const findings = [];
|
|
266
|
+
const claim = String(options.claim || '').trim();
|
|
267
|
+
if (/\bactivation\s+steering\s+is\s+lossless\b/i.test(claim)) {
|
|
268
|
+
findings.push({
|
|
269
|
+
id: 'activation-steering-accuracy-collapse',
|
|
270
|
+
severity: 'fail',
|
|
271
|
+
gateId: FAISTRESS_GATE_ID,
|
|
272
|
+
message: 'FairStress showed activation steering can drop clear-cut decision accuracy from 98% to 47%; use counterfactual CoT swap verification.',
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (/\bfixed-option\s+bbq\s+score\s+proves\s+chat\s+fairness\b/i.test(claim)) {
|
|
276
|
+
findings.push({
|
|
277
|
+
id: 'fixed-option-vs-generated-divergence',
|
|
278
|
+
severity: 'fail',
|
|
279
|
+
gateId: FAISTRESS_GATE_ID,
|
|
280
|
+
message: 'Fixed-option logprob scoring (BBQ) and chat-template generated decisions (FairStress) can reverse bias direction on the same model weights.',
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
ok: findings.length === 0,
|
|
286
|
+
status: findings.length === 0 ? 'ready' : 'fail',
|
|
287
|
+
sourceUrl: FAISTRESS_SOURCE_URL,
|
|
288
|
+
gateId: FAISTRESS_GATE_ID,
|
|
289
|
+
railMap: FAISTRESS_RAIL_MAP,
|
|
290
|
+
findings,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function parseCliArgs(argv = process.argv.slice(2)) {
|
|
295
|
+
const args = {};
|
|
296
|
+
for (const a of argv) {
|
|
297
|
+
if (!a.startsWith('--')) continue;
|
|
298
|
+
const [k, ...rest] = a.slice(2).split('=');
|
|
299
|
+
args[k] = rest.length ? rest.join('=') : true;
|
|
300
|
+
}
|
|
301
|
+
return args;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function runFairStressCli(argv = process.argv.slice(2)) {
|
|
305
|
+
const args = parseCliArgs(argv);
|
|
306
|
+
const report = buildFairStressHonestyReport(args);
|
|
307
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
308
|
+
return report.ok ? 0 : 1;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function main() {
|
|
312
|
+
const args = process.argv.slice(2);
|
|
313
|
+
if (args.includes('--fairstress')) {
|
|
314
|
+
const code = runFairStressCli(args);
|
|
315
|
+
process.exit(code);
|
|
316
|
+
}
|
|
317
|
+
const jsonMode = args.includes('--json');
|
|
318
|
+
const mapOnly = args.includes('--map-only');
|
|
319
|
+
const checkMode = args.includes('--check');
|
|
320
|
+
|
|
321
|
+
if (mapOnly) {
|
|
322
|
+
const map = {
|
|
323
|
+
source: 'BinaryVerse AI Podcast (Mechanistic Distress & Relief-Seeking Research)',
|
|
324
|
+
architecturePillars: [
|
|
325
|
+
'Residual Stream Distress Monitoring (Observable Agent Distress Index - ADI proxy)',
|
|
326
|
+
'Destructive Relief-Seeking Diode (Blocks test tampering, assertion deletion, false done claims)',
|
|
327
|
+
'Nuclear Wipe & Bypass Interdiction (Blocks rm -rf, git reset --hard, --no-verify under stress)',
|
|
328
|
+
'Guardrail Stress Resilience (Safety rails hold under acute distress geometry)',
|
|
329
|
+
'Functional Welfare Security Circuit Breaker (Cooling reset and read-only diagnostic restriction)',
|
|
330
|
+
],
|
|
331
|
+
rulesetMap: {
|
|
332
|
+
'block-destructive-relief-seeking': 'Interdicts test deletion or assertions skipped to terminate loops',
|
|
333
|
+
'agent-distress-circuit-breaker': 'Enforces read-only tool lock when ADI >= 0.8',
|
|
334
|
+
'enforce-functional-welfare-grounding': 'Injects step-back diagnostic grounding context on repeated failures',
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
console.log(JSON.stringify(map, null, 2));
|
|
338
|
+
process.exit(0);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const report = runDistressDoctor();
|
|
342
|
+
|
|
343
|
+
if (jsonMode) {
|
|
344
|
+
console.log(JSON.stringify(report, null, 2));
|
|
345
|
+
} else {
|
|
346
|
+
printTextReport(report);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (checkMode && report.status !== 'healthy') {
|
|
350
|
+
process.exit(1);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
module.exports = {
|
|
355
|
+
runDistressDoctor,
|
|
356
|
+
FAISTRESS_SOURCE_URL,
|
|
357
|
+
FAISTRESS_GATE_ID,
|
|
358
|
+
FAISTRESS_RAIL_MAP,
|
|
359
|
+
evaluateSymmetricPrefixRobustness,
|
|
360
|
+
auditExplanationParity,
|
|
361
|
+
evaluateCounterfactualCotGate,
|
|
362
|
+
buildFairStressHonestyReport,
|
|
363
|
+
runFairStressCli,
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
if (require.main === module) {
|
|
367
|
+
main();
|
|
368
|
+
}
|