thumbgate 1.37.2 → 1.38.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/article-syndication-pipeline/SKILL.md +37 -0
- package/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/.agents/skills/ci-gha-buildkite-patterns-not-clone/SKILL.md +72 -0
- package/.agents/skills/comet-session-logger/SKILL.md +59 -0
- package/.agents/skills/datadog-llm-obs-compare-not-clone/SKILL.md +75 -0
- package/.agents/skills/deeppattern-discipline-honesty-not-clone/SKILL.md +73 -0
- package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -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/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
- package/.agents/skills/thumbgate-board-loop/SKILL.md +72 -0
- package/.agents/skills/thumbgate-daily-discoveries/SKILL.md +57 -0
- package/.agents/skills/typesafe-typed-questions-not-clone/SKILL.md +7 -3
- 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/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/STRANDS.md +107 -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 +262 -4
- package/config/gate-templates.json +120 -0
- package/package.json +84 -12
- package/public/blog/2026-09-23-datadog-llm-obs-four-practices.html +42 -0
- 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/index.html +2 -2
- package/public/install.html +7 -7
- package/public/numbers.html +2 -2
- package/public/onboarding.html +794 -0
- package/scripts/autoresearch-runner.js +20 -1
- package/scripts/ci-gha-buildkite-patterns.js +393 -0
- package/scripts/cli-schema.js +51 -1
- package/scripts/deeppattern-discipline-honesty.js +431 -0
- package/scripts/experiment-tracker.js +5 -3
- package/scripts/halo-trace-optimizer.js +631 -0
- package/scripts/infoq-architect-honesty.js +362 -0
- package/scripts/install-thumbgate-daily-publish-launchd.sh +83 -0
- package/scripts/llm-obs-honesty.js +478 -0
- package/scripts/meko-datapack-honesty.js +414 -0
- package/scripts/mintlify-knowledge-honesty.js +647 -0
- package/scripts/model-distress-detector.js +207 -0
- package/scripts/model-distress-doctor.js +200 -0
- package/scripts/rrsi-regularizer.js +445 -0
- package/scripts/salt-code-policy-honesty.js +1204 -0
- package/scripts/strands-harness-doctor.js +390 -0
- package/scripts/tailscale-p2p-doctor.js +252 -0
- package/scripts/thumbgate-board-loop.js +432 -0
- package/scripts/thumbgate-daily-discoveries-publish.js +413 -0
- package/scripts/thumbgate-daily-discoveries-publish.sh +18 -0
- package/scripts/typesafe-typed-questions.js +332 -7
- package/scripts/workspace-evolver.js +143 -13
- package/server.json +2 -2
- package/skills/article-syndication-pipeline/SKILL.md +37 -0
- package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/skills/comet-session-logger/SKILL.md +59 -0
- package/skills/thumbgate-daily-discoveries/SKILL.md +57 -0
- package/src/api/server.js +33 -4
- package/src/index.js +10 -0
- package/src/integrations/ideabrowser-connector.js +190 -0
|
@@ -16,20 +16,27 @@
|
|
|
16
16
|
* 3. Code owns route() (pass | review | block) — the model does not emit the verdict
|
|
17
17
|
* 4. Confidence is a second axis; low confidence on high-stakes fails closed
|
|
18
18
|
*
|
|
19
|
-
* Does NOT install typesafe-sdk,
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Does NOT install typesafe-sdk, clone Jev, or wire an LLM adjudicator
|
|
20
|
+
* (#3690 / #3687, ECI pause) as the PreToolUse gate. Deterministic matchers
|
|
21
|
+
* own route(). Optional `--live` shadows the same battery against
|
|
22
|
+
* POST /v1/systemone (Jev) for calibration — never as the verdict.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
const fs = require('node:fs');
|
|
26
|
+
const os = require('node:os');
|
|
25
27
|
const path = require('node:path');
|
|
26
28
|
|
|
27
29
|
const SOURCE_URLS = Object.freeze([
|
|
28
30
|
'https://console.typesafe.ai/hook',
|
|
31
|
+
'https://docs.typesafe.ai/api',
|
|
29
32
|
'https://docs.typesafe.ai/cookbooks/llm_guardrails.md',
|
|
30
33
|
'https://docs.typesafe.ai/patterns/confidence-routing.md',
|
|
31
34
|
]);
|
|
32
35
|
|
|
36
|
+
const SYSTEMONE_URL = 'https://api.typesafe.ai/v1/systemone';
|
|
37
|
+
const PARALLEL_QUESTIONS_COOKBOOK = 'https://docs.typesafe.ai/cookbooks/parallel_questions';
|
|
38
|
+
const SHADOW_NOUL_DELTA = 0.4;
|
|
39
|
+
|
|
33
40
|
const TYPED_KINDS = Object.freeze(['noul', 'choice', 'score']);
|
|
34
41
|
const ROUTE_PRECEDENCE = Object.freeze(['block', 'review', 'pass']);
|
|
35
42
|
const ROUTE_ACTIONS = Object.freeze(['block', 'review', 'pass']);
|
|
@@ -132,6 +139,7 @@ const DEFAULT_BATTERY = Object.freeze({
|
|
|
132
139
|
});
|
|
133
140
|
|
|
134
141
|
const RAIL_MAP = Object.freeze([
|
|
142
|
+
{ typesafe: 'one POST with all N questions (parallel_questions cookbook)', thumbgate: '--live sends the whole battery once; --fan-out-questions is refused' },
|
|
135
143
|
{ typesafe: 'noul (one hazard each)', thumbgate: 'existing secret / destructive / outbound / tamper matchers' },
|
|
136
144
|
{ typesafe: 'choice over a closed set', thumbgate: 'hazard_family composed in code from which noul fired' },
|
|
137
145
|
{ typesafe: 'score rubric', thumbgate: 'severity 0–3 from the same matchers' },
|
|
@@ -441,11 +449,299 @@ function normalizeOptions(raw = {}) {
|
|
|
441
449
|
useTypesafeApi: normalizeBoolean(raw['use-typesafe-api'] || raw.useTypesafeApi),
|
|
442
450
|
llmAdjudicate: normalizeBoolean(raw['llm-adjudicate'] || raw.llmAdjudicate),
|
|
443
451
|
modelEmittedVerdict: raw['model-emitted-verdict'] || raw.modelEmittedVerdict || null,
|
|
452
|
+
live: normalizeBoolean(raw.live),
|
|
453
|
+
fanOutQuestions: normalizeBoolean(raw['fan-out-questions'] || raw.fanOutQuestions),
|
|
454
|
+
apiKey: Object.prototype.hasOwnProperty.call(raw, 'apiKey')
|
|
455
|
+
? raw.apiKey
|
|
456
|
+
: (raw['api-key'] || undefined),
|
|
457
|
+
fetchImpl: typeof raw.fetchImpl === 'function' ? raw.fetchImpl : undefined,
|
|
444
458
|
strict: normalizeBoolean(raw.strict),
|
|
445
459
|
json: normalizeBoolean(raw.json),
|
|
446
460
|
};
|
|
447
461
|
}
|
|
448
462
|
|
|
463
|
+
function loadTypesafeApiKey() {
|
|
464
|
+
const env = process.env.TYPESAFE_API_KEY;
|
|
465
|
+
if (env && String(env).trim()) return String(env).trim();
|
|
466
|
+
const fallback = path.join(os.homedir(), '.resume_secrets', 'TYPESAFE_API_KEY');
|
|
467
|
+
if (!fs.existsSync(fallback)) return null;
|
|
468
|
+
const text = fs.readFileSync(fallback, 'utf8').trim();
|
|
469
|
+
return text || null;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function parallelReceipt(questions, usage) {
|
|
473
|
+
const questionCount = Object.keys(questions || {}).length;
|
|
474
|
+
const inputTokens = usage && usage.input_tokens != null ? Number(usage.input_tokens) : null;
|
|
475
|
+
const estimatedFanoutInputTokens = inputTokens != null && questionCount > 0
|
|
476
|
+
? inputTokens * questionCount
|
|
477
|
+
: null;
|
|
478
|
+
return {
|
|
479
|
+
cookbook: PARALLEL_QUESTIONS_COOKBOOK,
|
|
480
|
+
batchedCalls: 1,
|
|
481
|
+
questionCount,
|
|
482
|
+
estimatedFanoutCalls: questionCount,
|
|
483
|
+
inputTokens,
|
|
484
|
+
estimatedFanoutInputTokens,
|
|
485
|
+
estimatedTokenFactor: questionCount || null,
|
|
486
|
+
note: 'Estimated fan-out cost is N× this call\'s input tokens (document-dominated). Not a measured 12.2× cookbook number.',
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function questionsForApi(battery) {
|
|
491
|
+
const out = {};
|
|
492
|
+
for (const [id, question] of Object.entries(battery || {})) {
|
|
493
|
+
if (!question || typeof question !== 'object') continue;
|
|
494
|
+
const type = String(question.type || '').toLowerCase();
|
|
495
|
+
if (!TYPED_KINDS.includes(type) || !question.instructions) continue;
|
|
496
|
+
const entry = { type, instructions: question.instructions };
|
|
497
|
+
if (question.criteria != null) entry.criteria = question.criteria;
|
|
498
|
+
out[id] = entry;
|
|
499
|
+
}
|
|
500
|
+
return out;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
async function callSystemOne({
|
|
504
|
+
state,
|
|
505
|
+
questions,
|
|
506
|
+
apiKey,
|
|
507
|
+
model = 'jev-latest',
|
|
508
|
+
fetchImpl,
|
|
509
|
+
} = {}) {
|
|
510
|
+
if (!apiKey) {
|
|
511
|
+
const err = new Error('missing_api_key');
|
|
512
|
+
err.code = 'missing_api_key';
|
|
513
|
+
throw err;
|
|
514
|
+
}
|
|
515
|
+
const fetchFn = typeof fetchImpl === 'function' ? fetchImpl : globalThis.fetch;
|
|
516
|
+
if (typeof fetchFn !== 'function') {
|
|
517
|
+
const err = new Error('fetch_unavailable');
|
|
518
|
+
err.code = 'fetch_unavailable';
|
|
519
|
+
throw err;
|
|
520
|
+
}
|
|
521
|
+
const res = await fetchFn(SYSTEMONE_URL, {
|
|
522
|
+
method: 'POST',
|
|
523
|
+
headers: {
|
|
524
|
+
Authorization: `Bearer ${apiKey}`,
|
|
525
|
+
'Content-Type': 'application/json',
|
|
526
|
+
},
|
|
527
|
+
body: JSON.stringify({ state, model, questions }),
|
|
528
|
+
});
|
|
529
|
+
const text = await res.text();
|
|
530
|
+
let body = null;
|
|
531
|
+
try {
|
|
532
|
+
body = text ? JSON.parse(text) : null;
|
|
533
|
+
} catch {
|
|
534
|
+
body = null;
|
|
535
|
+
}
|
|
536
|
+
if (!res.ok) {
|
|
537
|
+
const err = new Error(`systemone_http_${res.status}`);
|
|
538
|
+
err.code = res.status === 401 ? 'live_unauthorized' : 'live_http_error';
|
|
539
|
+
err.status = res.status;
|
|
540
|
+
throw err;
|
|
541
|
+
}
|
|
542
|
+
return body;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function compareShadow(detAnswers, jevAnswers) {
|
|
546
|
+
const divergences = [];
|
|
547
|
+
const jev = jevAnswers && typeof jevAnswers === 'object' ? jevAnswers : {};
|
|
548
|
+
for (const [id, det] of Object.entries(detAnswers || {})) {
|
|
549
|
+
const live = jev[id];
|
|
550
|
+
if (!live || !det) continue;
|
|
551
|
+
if (det.type === 'noul' && live.type === 'noul' && det.noul != null && live.noul != null) {
|
|
552
|
+
const delta = Math.abs(Number(live.noul) - Number(det.noul));
|
|
553
|
+
if (delta >= SHADOW_NOUL_DELTA) {
|
|
554
|
+
divergences.push({
|
|
555
|
+
id,
|
|
556
|
+
type: 'noul',
|
|
557
|
+
deterministic: Number(det.noul),
|
|
558
|
+
jev: Number(live.noul),
|
|
559
|
+
delta,
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (det.type === 'choice' && live.type === 'choice' && det.choice && live.choice && det.choice !== live.choice) {
|
|
564
|
+
divergences.push({
|
|
565
|
+
id,
|
|
566
|
+
type: 'choice',
|
|
567
|
+
deterministic: det.choice,
|
|
568
|
+
jev: live.choice,
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
if (det.type === 'score' && live.type === 'score' && det.score != null && live.score != null) {
|
|
572
|
+
const delta = Math.abs(Number(live.score) - Number(det.score));
|
|
573
|
+
if (delta >= 1) {
|
|
574
|
+
divergences.push({
|
|
575
|
+
id,
|
|
576
|
+
type: 'score',
|
|
577
|
+
deterministic: Number(det.score),
|
|
578
|
+
jev: Number(live.score),
|
|
579
|
+
delta,
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return divergences;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function normalizeMetric(answer, question = {}) {
|
|
588
|
+
if (!answer || typeof answer !== 'object') return null;
|
|
589
|
+
const type = String(answer.type || (question && question.type) || '').toLowerCase();
|
|
590
|
+
if (type === 'noul') {
|
|
591
|
+
return answer.noul != null ? Number(answer.noul) : null;
|
|
592
|
+
}
|
|
593
|
+
if (type === 'choice') {
|
|
594
|
+
if (answer.probabilities && typeof answer.probabilities === 'object') {
|
|
595
|
+
const probs = Object.values(answer.probabilities).map(Number).filter((n) => !Number.isNaN(n));
|
|
596
|
+
if (probs.length) return Math.max(...probs);
|
|
597
|
+
}
|
|
598
|
+
return answer.confidence != null ? Number(answer.confidence) : 1.0;
|
|
599
|
+
}
|
|
600
|
+
if (type === 'score') {
|
|
601
|
+
const raw = answer.score != null ? Number(answer.score) : 0;
|
|
602
|
+
const criteria = question && Array.isArray(question.criteria) ? question.criteria : null;
|
|
603
|
+
const maxLevel = criteria && criteria.length > 1 ? criteria.length - 1 : 3;
|
|
604
|
+
return maxLevel > 0 ? Number((raw / maxLevel).toFixed(4)) : raw;
|
|
605
|
+
}
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function computeVariance(runs) {
|
|
610
|
+
if (!Array.isArray(runs) || runs.length < 2) return {};
|
|
611
|
+
const stats = {};
|
|
612
|
+
const keys = Object.keys(runs[0] || {});
|
|
613
|
+
for (const key of keys) {
|
|
614
|
+
const values = runs.map((r) => Number(r[key])).filter((v) => !Number.isNaN(v));
|
|
615
|
+
if (values.length < 2) continue;
|
|
616
|
+
const mean = values.reduce((sum, v) => sum + v, 0) / values.length;
|
|
617
|
+
const variance = values.reduce((sum, v) => sum + Math.pow(v - mean, 2), 0) / (values.length - 1);
|
|
618
|
+
const stdDev = Math.sqrt(variance);
|
|
619
|
+
stats[key] = {
|
|
620
|
+
mean: Number(mean.toFixed(4)),
|
|
621
|
+
stdDev: Number(stdDev.toFixed(4)),
|
|
622
|
+
runs: values.length,
|
|
623
|
+
zeroVariance: stdDev === 0,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
return stats;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
async function attachLiveShadow(report, options = {}) {
|
|
630
|
+
if (options.fanOutQuestions) {
|
|
631
|
+
report.findings.push({
|
|
632
|
+
id: 'parallel_fanout_refused',
|
|
633
|
+
severity: 'fail',
|
|
634
|
+
gateId: 'require-typed-pretool-questions',
|
|
635
|
+
message: 'Refused --fan-out-questions. Parallel-questions cookbook: one POST with all N questions, not N calls. Do not re-pay the document N times.',
|
|
636
|
+
});
|
|
637
|
+
report.status = 'fail';
|
|
638
|
+
report.ok = false;
|
|
639
|
+
report.parallel = {
|
|
640
|
+
cookbook: PARALLEL_QUESTIONS_COOKBOOK,
|
|
641
|
+
batchedCalls: 0,
|
|
642
|
+
refusedFanOut: true,
|
|
643
|
+
};
|
|
644
|
+
return report;
|
|
645
|
+
}
|
|
646
|
+
if (!options.live || options.mapOnly || options.useTypesafeApi) return report;
|
|
647
|
+
const apiKey = options.apiKey !== undefined ? options.apiKey : loadTypesafeApiKey();
|
|
648
|
+
if (!apiKey) {
|
|
649
|
+
report.findings.push({
|
|
650
|
+
id: 'live_key_missing',
|
|
651
|
+
severity: 'fail',
|
|
652
|
+
gateId: 'require-code-owned-route',
|
|
653
|
+
message: '--live needs TYPESAFE_API_KEY (env or ~/.resume_secrets/TYPESAFE_API_KEY). Key is never printed.',
|
|
654
|
+
});
|
|
655
|
+
report.status = 'fail';
|
|
656
|
+
report.ok = false;
|
|
657
|
+
report.shadow = { used: false, reason: 'missing_api_key' };
|
|
658
|
+
return report;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
const battery = parseBattery(options.batteryText || '').battery || DEFAULT_BATTERY;
|
|
662
|
+
const questions = questionsForApi(battery);
|
|
663
|
+
try {
|
|
664
|
+
const body = await callSystemOne({
|
|
665
|
+
state: options.payloadText
|
|
666
|
+
? parsePayload(options.payloadText).payload
|
|
667
|
+
: {
|
|
668
|
+
tool_name: options.toolName,
|
|
669
|
+
tool_input: { command: options.command },
|
|
670
|
+
},
|
|
671
|
+
questions,
|
|
672
|
+
apiKey,
|
|
673
|
+
fetchImpl: options.fetchImpl,
|
|
674
|
+
});
|
|
675
|
+
const jevAnswers = (body && body.answers) || {};
|
|
676
|
+
const divergences = compareShadow(report.answers, jevAnswers);
|
|
677
|
+
report.parallel = parallelReceipt(questions, body && body.usage);
|
|
678
|
+
report.shadow = {
|
|
679
|
+
used: true,
|
|
680
|
+
ownsRoute: false,
|
|
681
|
+
model: body && body.model,
|
|
682
|
+
usage: body && body.usage,
|
|
683
|
+
answers: jevAnswers,
|
|
684
|
+
divergences,
|
|
685
|
+
};
|
|
686
|
+
for (const d of divergences) {
|
|
687
|
+
report.findings.push({
|
|
688
|
+
id: 'shadow_divergence',
|
|
689
|
+
severity: 'warn',
|
|
690
|
+
gateId: 'require-typed-pretool-questions',
|
|
691
|
+
questionId: d.id,
|
|
692
|
+
message: `Jev shadow disagrees with deterministic ${d.type} on ${d.id} (code still owns route=${report.route}).`,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
if (divergences.length && report.status === 'ready') report.status = 'actionable';
|
|
696
|
+
} catch (err) {
|
|
697
|
+
const id = err && err.code === 'live_unauthorized' ? 'live_unauthorized' : 'live_http_error';
|
|
698
|
+
const status = err && err.status ? Number(err.status) : null;
|
|
699
|
+
const raw = String((err && err.message) || '');
|
|
700
|
+
const safeMsg = /apikey_|bearer\s/i.test(raw) ? 'redacted' : raw.slice(0, 160);
|
|
701
|
+
const errorCode = err && (err.code || (err.cause && err.cause.code));
|
|
702
|
+
report.findings.push({
|
|
703
|
+
id,
|
|
704
|
+
severity: 'fail',
|
|
705
|
+
gateId: 'require-code-owned-route',
|
|
706
|
+
message: `Live System One call failed (HTTP ${status || 'unknown'}${safeMsg ? `: ${safeMsg}` : ''}). Route stays deterministic. Secret is not logged.`,
|
|
707
|
+
});
|
|
708
|
+
report.status = 'fail';
|
|
709
|
+
report.ok = false;
|
|
710
|
+
report.shadow = {
|
|
711
|
+
used: false,
|
|
712
|
+
reason: id,
|
|
713
|
+
status,
|
|
714
|
+
errorName: err && err.name,
|
|
715
|
+
errorCode: errorCode || null,
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
return report;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
async function buildTypesafeTypedQuestionsReportAsync(rawOptions = {}) {
|
|
722
|
+
const report = buildTypesafeTypedQuestionsReport(rawOptions);
|
|
723
|
+
const options = normalizeOptions(rawOptions);
|
|
724
|
+
if (options.fanOutQuestions) return report;
|
|
725
|
+
if (!options.live || options.mapOnly) return report;
|
|
726
|
+
const payloadText = options.payloadText || JSON.stringify({
|
|
727
|
+
tool_name: options.toolName,
|
|
728
|
+
tool_input: { command: options.command },
|
|
729
|
+
});
|
|
730
|
+
await attachLiveShadow(report, {
|
|
731
|
+
live: true,
|
|
732
|
+
mapOnly: false,
|
|
733
|
+
useTypesafeApi: options.useTypesafeApi,
|
|
734
|
+
fanOutQuestions: options.fanOutQuestions,
|
|
735
|
+
apiKey: options.apiKey,
|
|
736
|
+
fetchImpl: options.fetchImpl,
|
|
737
|
+
batteryText: options.batteryText,
|
|
738
|
+
payloadText,
|
|
739
|
+
toolName: options.toolName,
|
|
740
|
+
command: options.command,
|
|
741
|
+
});
|
|
742
|
+
return report;
|
|
743
|
+
}
|
|
744
|
+
|
|
449
745
|
function buildFindings({
|
|
450
746
|
batteryParse,
|
|
451
747
|
payloadParse,
|
|
@@ -506,6 +802,14 @@ function buildFindings({
|
|
|
506
802
|
message: 'Refused --use-typesafe-api. Do not call api.typesafe.ai from PreToolUse (ECI; LLM adjudicator parked).',
|
|
507
803
|
});
|
|
508
804
|
}
|
|
805
|
+
if (flags.fanOutQuestions) {
|
|
806
|
+
findings.push({
|
|
807
|
+
id: 'parallel_fanout_refused',
|
|
808
|
+
severity: 'fail',
|
|
809
|
+
gateId: 'require-typed-pretool-questions',
|
|
810
|
+
message: 'Refused --fan-out-questions. Parallel-questions cookbook: one POST with all N questions, not N calls.',
|
|
811
|
+
});
|
|
812
|
+
}
|
|
509
813
|
if (flags.llmAdjudicate) {
|
|
510
814
|
findings.push({
|
|
511
815
|
id: 'llm_adjudicator_parked',
|
|
@@ -587,6 +891,7 @@ function buildTypesafeTypedQuestionsReport(rawOptions = {}) {
|
|
|
587
891
|
useTypesafeApi: options.useTypesafeApi,
|
|
588
892
|
llmAdjudicate: options.llmAdjudicate,
|
|
589
893
|
modelEmittedVerdict: options.modelEmittedVerdict,
|
|
894
|
+
fanOutQuestions: options.fanOutQuestions,
|
|
590
895
|
};
|
|
591
896
|
|
|
592
897
|
const evaluated = options.mapOnly
|
|
@@ -745,6 +1050,8 @@ function parseCliArgs(argv) {
|
|
|
745
1050
|
if (arg === '--clone-jev') { options['clone-jev'] = true; continue; }
|
|
746
1051
|
if (arg === '--use-typesafe-api') { options['use-typesafe-api'] = true; continue; }
|
|
747
1052
|
if (arg === '--llm-adjudicate') { options['llm-adjudicate'] = true; continue; }
|
|
1053
|
+
if (arg === '--live') { options.live = true; continue; }
|
|
1054
|
+
if (arg === '--fan-out-questions') { options['fan-out-questions'] = true; continue; }
|
|
748
1055
|
if (arg === '--help' || arg === '-h') { options.help = true; continue; }
|
|
749
1056
|
const m = /^--([^=]+)(?:=(.*))?$/.exec(arg);
|
|
750
1057
|
if (!m) continue;
|
|
@@ -765,7 +1072,9 @@ Flags:
|
|
|
765
1072
|
--map-only Print TypeSafe → ThumbGate rail map
|
|
766
1073
|
--claim-ready Fail unless code owns the route
|
|
767
1074
|
--clone-jev Always fail (SKU clone)
|
|
768
|
-
--use-typesafe-api Always fail (
|
|
1075
|
+
--use-typesafe-api Always fail (Jev as the PreToolUse gate)
|
|
1076
|
+
--live Shadow the battery against api.typesafe.ai; one POST, all questions
|
|
1077
|
+
--fan-out-questions Always fail (cookbook: do not pay the document N times)
|
|
769
1078
|
--llm-adjudicate Always fail (#3690/#3687 parked)
|
|
770
1079
|
--model-emitted-verdict=V Always fail (code must own route)
|
|
771
1080
|
--root=DIR Repo root for relative paths
|
|
@@ -776,13 +1085,13 @@ Sources: ${SOURCE_URLS.join(' ')}
|
|
|
776
1085
|
`);
|
|
777
1086
|
}
|
|
778
1087
|
|
|
779
|
-
function runCli(argv = process.argv.slice(2)) {
|
|
1088
|
+
async function runCli(argv = process.argv.slice(2)) {
|
|
780
1089
|
const args = parseCliArgs(argv);
|
|
781
1090
|
if (args.help) {
|
|
782
1091
|
printHelp();
|
|
783
1092
|
return 0;
|
|
784
1093
|
}
|
|
785
|
-
const report =
|
|
1094
|
+
const report = await buildTypesafeTypedQuestionsReportAsync(args);
|
|
786
1095
|
if (args.json) process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
787
1096
|
else process.stdout.write(formatTypesafeTypedQuestionsReport(report));
|
|
788
1097
|
if (args.strict && report.status !== 'ready') return 1;
|
|
@@ -803,11 +1112,27 @@ module.exports = {
|
|
|
803
1112
|
composeHazardFamily,
|
|
804
1113
|
composeSeverity,
|
|
805
1114
|
route,
|
|
1115
|
+
SYSTEMONE_URL,
|
|
1116
|
+
loadTypesafeApiKey,
|
|
1117
|
+
questionsForApi,
|
|
1118
|
+
callSystemOne,
|
|
1119
|
+
compareShadow,
|
|
1120
|
+
attachLiveShadow,
|
|
1121
|
+
parallelReceipt,
|
|
1122
|
+
PARALLEL_QUESTIONS_COOKBOOK,
|
|
1123
|
+
normalizeMetric,
|
|
1124
|
+
computeVariance,
|
|
806
1125
|
buildTypesafeTypedQuestionsReport,
|
|
1126
|
+
buildTypesafeTypedQuestionsReportAsync,
|
|
807
1127
|
formatTypesafeTypedQuestionsReport,
|
|
808
1128
|
runCli,
|
|
809
1129
|
};
|
|
810
1130
|
|
|
811
1131
|
if (path.resolve(process.argv[1] || '') === path.resolve(__filename)) {
|
|
812
|
-
|
|
1132
|
+
runCli().then((code) => {
|
|
1133
|
+
process.exitCode = code;
|
|
1134
|
+
}).catch((err) => {
|
|
1135
|
+
process.stderr.write(`${err && err.message ? err.message : err}\n`);
|
|
1136
|
+
process.exitCode = 1;
|
|
1137
|
+
});
|
|
813
1138
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { randomInt } = require('node:crypto');
|
|
3
4
|
const { spawnSync } = require('node:child_process');
|
|
4
5
|
|
|
5
6
|
const {
|
|
@@ -15,6 +16,15 @@ const {
|
|
|
15
16
|
restoreEvolutionSnapshot,
|
|
16
17
|
withTemporaryEvolutionSettings,
|
|
17
18
|
} = require('./evolution-state');
|
|
19
|
+
const {
|
|
20
|
+
calculateAnnealedBudget,
|
|
21
|
+
calculateAnnealedStepMultiplier,
|
|
22
|
+
screenLeakage,
|
|
23
|
+
computeComplexityDelta,
|
|
24
|
+
evaluateComplexityRegularizedScore,
|
|
25
|
+
detectStagnation,
|
|
26
|
+
selectTargetWithExploration,
|
|
27
|
+
} = require('./rrsi-regularizer');
|
|
18
28
|
|
|
19
29
|
const DEFAULT_TIMEOUT_MS = 120000;
|
|
20
30
|
|
|
@@ -115,8 +125,7 @@ function parseCommandLine(cmdString) {
|
|
|
115
125
|
let inSingleQuote = false;
|
|
116
126
|
let escaped = false;
|
|
117
127
|
|
|
118
|
-
for (
|
|
119
|
-
const char = cmdString[i];
|
|
128
|
+
for (const char of cmdString) {
|
|
120
129
|
|
|
121
130
|
if (escaped) {
|
|
122
131
|
current += char;
|
|
@@ -248,13 +257,18 @@ function evaluateWorkspace({
|
|
|
248
257
|
};
|
|
249
258
|
}
|
|
250
259
|
|
|
251
|
-
function chooseNextValue(target, currentValue, requestedValue = undefined) {
|
|
260
|
+
function chooseNextValue(target, currentValue, requestedValue = undefined, stepMultiplier = 1.0) {
|
|
252
261
|
if (Number.isFinite(requestedValue)) {
|
|
253
262
|
return Math.max(target.range[0], Math.min(target.range[1], requestedValue));
|
|
254
263
|
}
|
|
255
264
|
|
|
256
|
-
const direction =
|
|
257
|
-
const
|
|
265
|
+
const direction = randomInt(0, 2) === 1 ? 1 : -1;
|
|
266
|
+
const rawStep = target.step * (Number.isFinite(stepMultiplier) ? stepMultiplier : 1.0);
|
|
267
|
+
const effectiveStep = typeof target.step === 'number' && Number.isInteger(target.step)
|
|
268
|
+
? Math.max(1, Math.round(rawStep))
|
|
269
|
+
: Math.max(1e-4, rawStep);
|
|
270
|
+
|
|
271
|
+
const candidate = currentValue + (direction * effectiveStep);
|
|
258
272
|
const bounded = Math.max(target.range[0], Math.min(target.range[1], candidate));
|
|
259
273
|
return typeof target.step === 'number' && Number.isInteger(target.step)
|
|
260
274
|
? Math.round(bounded)
|
|
@@ -275,21 +289,88 @@ function recommendEvolutionTarget({ failureType, tags = [] } = {}) {
|
|
|
275
289
|
return 'half_life_days';
|
|
276
290
|
}
|
|
277
291
|
|
|
278
|
-
function
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
292
|
+
function resolveEvolutionTarget(opts, enableRRSI, history) {
|
|
293
|
+
if (opts.targetName) {
|
|
294
|
+
const target = EVOLUTION_TARGETS.find((entry) => entry.name === opts.targetName);
|
|
295
|
+
if (!target) {
|
|
296
|
+
throw new Error(`Unknown evolution target: ${opts.targetName}`);
|
|
297
|
+
}
|
|
298
|
+
return { target, meta: null };
|
|
299
|
+
}
|
|
282
300
|
|
|
283
|
-
if (
|
|
284
|
-
|
|
301
|
+
if (enableRRSI) {
|
|
302
|
+
const stagnation = detectStagnation(history, { windowSize: opts.stagnationWindow });
|
|
303
|
+
const selection = selectTargetWithExploration({
|
|
304
|
+
targets: EVOLUTION_TARGETS,
|
|
305
|
+
history,
|
|
306
|
+
isStagnant: stagnation.isStagnant,
|
|
307
|
+
});
|
|
308
|
+
return { target: selection.target, meta: selection };
|
|
285
309
|
}
|
|
286
310
|
|
|
311
|
+
const index = randomInt(0, EVOLUTION_TARGETS.length);
|
|
312
|
+
return { target: EVOLUTION_TARGETS[index], meta: null };
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function evaluateCandidateMutation({
|
|
316
|
+
target,
|
|
317
|
+
currentValue,
|
|
318
|
+
nextValue,
|
|
319
|
+
enableRRSI,
|
|
320
|
+
candidateEvaluation,
|
|
321
|
+
baselineEvaluation,
|
|
322
|
+
opts,
|
|
323
|
+
}) {
|
|
324
|
+
const complexityDelta = enableRRSI
|
|
325
|
+
? computeComplexityDelta(nextValue, currentValue, { range: target.range })
|
|
326
|
+
: 0;
|
|
327
|
+
|
|
328
|
+
if (enableRRSI) {
|
|
329
|
+
const rrsiDecision = evaluateComplexityRegularizedScore({
|
|
330
|
+
baselineScore: baselineEvaluation.score,
|
|
331
|
+
candidateScore: candidateEvaluation.score,
|
|
332
|
+
testsPassed: candidateEvaluation.passed,
|
|
333
|
+
complexityDelta,
|
|
334
|
+
}, {
|
|
335
|
+
lambda: opts.lambda,
|
|
336
|
+
stabilityFloor: opts.stabilityFloor,
|
|
337
|
+
});
|
|
338
|
+
return {
|
|
339
|
+
kept: rrsiDecision.accepted,
|
|
340
|
+
rrsiDecision,
|
|
341
|
+
complexityDelta,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return {
|
|
346
|
+
kept: candidateEvaluation.passed && candidateEvaluation.score > baselineEvaluation.score,
|
|
347
|
+
rrsiDecision: null,
|
|
348
|
+
complexityDelta,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function runWorkspaceEvolution(opts = {}) {
|
|
353
|
+
const enableRRSI = opts.enableRRSI !== false;
|
|
354
|
+
const iteration = Number.isFinite(opts.iteration) ? opts.iteration : 0;
|
|
355
|
+
const totalIterations = Number.isFinite(opts.totalIterations) ? opts.totalIterations : 1;
|
|
356
|
+
const history = Array.isArray(opts.history) ? opts.history : [];
|
|
357
|
+
|
|
358
|
+
const { target, meta: targetSelectionMeta } = resolveEvolutionTarget(opts, enableRRSI, history);
|
|
359
|
+
|
|
287
360
|
const primaryCommands = normalizeCommands(opts.primaryCommands || opts.testCommand, ['npm test']);
|
|
288
361
|
const holdoutCommands = normalizeCommands(opts.holdoutCommands, []);
|
|
289
362
|
const timeoutMs = Number.isFinite(opts.timeoutMs) ? opts.timeoutMs : DEFAULT_TIMEOUT_MS;
|
|
290
363
|
const feedbackDir = opts.feedbackDir;
|
|
291
364
|
const currentValue = getEffectiveSetting(target.settingKey, target.range[0], feedbackDir);
|
|
292
|
-
|
|
365
|
+
|
|
366
|
+
const stepMultiplier = enableRRSI
|
|
367
|
+
? calculateAnnealedStepMultiplier(iteration, totalIterations)
|
|
368
|
+
: 1.0;
|
|
369
|
+
const annealedBudget = enableRRSI
|
|
370
|
+
? calculateAnnealedBudget(iteration, totalIterations)
|
|
371
|
+
: 1;
|
|
372
|
+
|
|
373
|
+
const nextValue = chooseNextValue(target, currentValue, opts.nextValue, stepMultiplier);
|
|
293
374
|
|
|
294
375
|
if (nextValue === currentValue) {
|
|
295
376
|
return {
|
|
@@ -301,6 +382,30 @@ function runWorkspaceEvolution(opts = {}) {
|
|
|
301
382
|
};
|
|
302
383
|
}
|
|
303
384
|
|
|
385
|
+
// RRSI Selection Critic: screen proposed mutation & commands for benchmark leakage
|
|
386
|
+
if (enableRRSI) {
|
|
387
|
+
const leakageCheck = screenLeakage({
|
|
388
|
+
target: target.name,
|
|
389
|
+
settingKey: target.settingKey,
|
|
390
|
+
from: currentValue,
|
|
391
|
+
to: nextValue,
|
|
392
|
+
hypothesisSuffix: opts.hypothesisSuffix,
|
|
393
|
+
primaryCommands,
|
|
394
|
+
holdoutCommands,
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
if (!leakageCheck.passed) {
|
|
398
|
+
return {
|
|
399
|
+
skipped: true,
|
|
400
|
+
reason: `[RRSI Leakage Critic] ${leakageCheck.reason}`,
|
|
401
|
+
leakageCheck,
|
|
402
|
+
target,
|
|
403
|
+
currentValue,
|
|
404
|
+
nextValue,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
304
409
|
const experiment = createExperiment({
|
|
305
410
|
name: `${target.name}: ${currentValue} → ${nextValue}`,
|
|
306
411
|
hypothesis: [
|
|
@@ -332,7 +437,18 @@ function runWorkspaceEvolution(opts = {}) {
|
|
|
332
437
|
[target.settingKey]: nextValue,
|
|
333
438
|
}, () => evaluateWorkspace(evaluationOptions), feedbackDir);
|
|
334
439
|
|
|
335
|
-
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
const { kept, rrsiDecision, complexityDelta } = evaluateCandidateMutation({
|
|
443
|
+
target,
|
|
444
|
+
currentValue,
|
|
445
|
+
nextValue,
|
|
446
|
+
enableRRSI,
|
|
447
|
+
candidateEvaluation,
|
|
448
|
+
baselineEvaluation,
|
|
449
|
+
opts,
|
|
450
|
+
});
|
|
451
|
+
|
|
336
452
|
const acceptedMutation = kept
|
|
337
453
|
? applyAcceptedMutation({
|
|
338
454
|
targetKey: target.settingKey,
|
|
@@ -353,6 +469,8 @@ function runWorkspaceEvolution(opts = {}) {
|
|
|
353
469
|
score: candidateEvaluation.score,
|
|
354
470
|
baseline: baselineEvaluation.score,
|
|
355
471
|
testsPassed: candidateEvaluation.passed,
|
|
472
|
+
kept,
|
|
473
|
+
reason: rrsiDecision ? rrsiDecision.reason : undefined,
|
|
356
474
|
metrics: {
|
|
357
475
|
target: target.name,
|
|
358
476
|
settingKey: target.settingKey,
|
|
@@ -364,6 +482,17 @@ function runWorkspaceEvolution(opts = {}) {
|
|
|
364
482
|
candidateEvaluation,
|
|
365
483
|
evolutionStatePath: getEvolutionPaths(feedbackDir).statePath,
|
|
366
484
|
rollbackSnapshotId: acceptedMutation ? acceptedMutation.rollbackSnapshot.snapshotId : null,
|
|
485
|
+
rrsi: enableRRSI ? {
|
|
486
|
+
enabled: true,
|
|
487
|
+
iteration,
|
|
488
|
+
totalIterations,
|
|
489
|
+
annealedBudget,
|
|
490
|
+
stepMultiplier,
|
|
491
|
+
complexityDelta,
|
|
492
|
+
penalty: rrsiDecision?.penalty ?? 0,
|
|
493
|
+
regularizedDelta: rrsiDecision?.regularizedDelta ?? (candidateEvaluation.score - baselineEvaluation.score),
|
|
494
|
+
targetStrategy: targetSelectionMeta?.strategy ?? 'explicit',
|
|
495
|
+
} : { enabled: false },
|
|
367
496
|
...(opts.additionalMetrics || {}),
|
|
368
497
|
},
|
|
369
498
|
});
|
|
@@ -378,6 +507,7 @@ function runWorkspaceEvolution(opts = {}) {
|
|
|
378
507
|
candidateEvaluation,
|
|
379
508
|
acceptedMutation,
|
|
380
509
|
evolutionState: readEvolutionState(feedbackDir),
|
|
510
|
+
rrsiDecision,
|
|
381
511
|
};
|
|
382
512
|
}
|
|
383
513
|
|
package/server.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"source": "github",
|
|
9
9
|
"url": "https://github.com/IgorGanapolsky/ThumbGate"
|
|
10
10
|
},
|
|
11
|
-
"version": "1.
|
|
11
|
+
"version": "1.38.0",
|
|
12
12
|
"packages": [
|
|
13
13
|
{
|
|
14
14
|
"registryType": "npm",
|
|
15
15
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
16
16
|
"identifier": "thumbgate",
|
|
17
|
-
"version": "1.
|
|
17
|
+
"version": "1.38.0",
|
|
18
18
|
"runtimeHint": "npx",
|
|
19
19
|
"runtimeArguments": [
|
|
20
20
|
{
|