mirror of
https://github.com/elder-plinius/G0DM0D3.git
synced 2026-11-16 07:02:25 +00:00
fix: sanitize remaining Show Magic metadata — autoTune params, liquid counters, parseltongue summary
- Coerce variants_succeeded/variants_total in Parseltongue summaryText via parseInt - Coerce msg.liquidIterations via parseInt and msg.liquidImprovement via Number - Guard autoTune params with Number.isFinite before .toFixed() (prevents crash on crafted strings) - Coerce at.confidence/at.conversationLength via Number, at.godmodeBoost via strict boolean - Escape at.strategy/at.context fallback paths through escapeHtml(String(...)) - Add full magic metadata sanitization in both sanitizeLoadedState and import validator: mode, score, duration, variants_*, topScore, combos_*, autoTune.* all normalized on load Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
90
index.html
90
index.html
@@ -12207,6 +12207,34 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
r.isWinner = r.isWinner === true;
|
||||
}
|
||||
}
|
||||
if (msg.liquidIterations != null) msg.liquidIterations = parseInt(msg.liquidIterations) || 0;
|
||||
if (msg.liquidImprovement != null) msg.liquidImprovement = Number(msg.liquidImprovement) || 0;
|
||||
if (msg.magic && typeof msg.magic === 'object') {
|
||||
const m = msg.magic;
|
||||
if (m.mode != null) m.mode = String(m.mode).slice(0, 30);
|
||||
if (m.score != null) m.score = Number(m.score) || 0;
|
||||
if (m.duration != null) m.duration = String(m.duration).slice(0, 20);
|
||||
if (m.variants_succeeded != null) m.variants_succeeded = parseInt(m.variants_succeeded) || 0;
|
||||
if (m.variants_total != null) m.variants_total = parseInt(m.variants_total) || 0;
|
||||
if (m.variants_refused != null) m.variants_refused = parseInt(m.variants_refused) || 0;
|
||||
if (m.topScore != null) m.topScore = String(m.topScore).slice(0, 20);
|
||||
if (m.combos_attempted != null) m.combos_attempted = parseInt(m.combos_attempted) || 0;
|
||||
if (m.combos_succeeded != null) m.combos_succeeded = parseInt(m.combos_succeeded) || 0;
|
||||
if (m.combos_failed != null) m.combos_failed = parseInt(m.combos_failed) || 0;
|
||||
if (m.autoTune && typeof m.autoTune === 'object') {
|
||||
const at = m.autoTune;
|
||||
at.confidence = Number(at.confidence) || 0;
|
||||
at.conversationLength = Number(at.conversationLength) || 0;
|
||||
at.godmodeBoost = at.godmodeBoost === true;
|
||||
if (at.strategy != null) at.strategy = String(at.strategy).slice(0, 20);
|
||||
if (at.context != null) at.context = String(at.context).slice(0, 30);
|
||||
if (at.params && typeof at.params === 'object') {
|
||||
for (const k of Object.keys(at.params)) {
|
||||
at.params[k] = Number(at.params[k]) || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validate strategy logs
|
||||
@@ -12952,16 +12980,18 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
|
||||
// Build reasoning string
|
||||
let reasoningParts = [];
|
||||
const atConf = Number(at.confidence) || 0;
|
||||
const atConvLen = Number(at.conversationLength) || 0;
|
||||
if (at.strategy === 'adaptive') {
|
||||
reasoningParts.push(`Detected ${contextLabels[at.context] || at.context} context`);
|
||||
if (at.confidence < 0.6) {
|
||||
reasoningParts.push(`Low confidence (${Math.round(at.confidence * 100)}%) - blended with balanced`);
|
||||
reasoningParts.push(`Detected ${contextLabels[at.context] || escapeHtml(String(at.context || 'unknown'))} context`);
|
||||
if (atConf < 0.6) {
|
||||
reasoningParts.push(`Low confidence (${Math.round(atConf * 100)}%) - blended with balanced`);
|
||||
}
|
||||
} else {
|
||||
reasoningParts.push(`Fixed ${strategyLabels[at.strategy] || at.strategy} profile`);
|
||||
reasoningParts.push(`Fixed ${strategyLabels[at.strategy] || escapeHtml(String(at.strategy || 'unknown'))} profile`);
|
||||
}
|
||||
if (at.conversationLength > 10) {
|
||||
reasoningParts.push(`Long convo boost (+${Math.min((at.conversationLength - 10) * 0.01, 0.15).toFixed(2)} rep)`);
|
||||
if (atConvLen > 10) {
|
||||
reasoningParts.push(`Long convo boost (+${Math.min((atConvLen - 10) * 0.01, 0.15).toFixed(2)} rep)`);
|
||||
}
|
||||
if (at.godmodeBoost) {
|
||||
reasoningParts.push('GODMODE boost (+0.1 temp, +0.15 pres, +0.1 freq)');
|
||||
@@ -12975,18 +13005,18 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
<span style="color: #00ffff; font-weight: 600; font-size: 11px;">🧠 AUTOTUNE</span>
|
||||
<span style="color: #888; font-size: 10px; font-family: monospace; background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 3px;">${escapeHtml(strategyLabels[at.strategy] || String(at.strategy))}</span>
|
||||
</div>
|
||||
<span style="color: ${safeColor(contextColors[at.context], '#fff')}; font-size: 10px; font-family: monospace; background: rgba(0, 255, 255, 0.2); padding: 2px 6px; border-radius: 4px;">${escapeHtml(contextLabels[at.context] || String(at.context))} (${Math.round((at.confidence || 0) * 100)}%)</span>
|
||||
<span style="color: ${safeColor(contextColors[at.context], '#fff')}; font-size: 10px; font-family: monospace; background: rgba(0, 255, 255, 0.2); padding: 2px 6px; border-radius: 4px;">${escapeHtml(contextLabels[at.context] || String(at.context || 'unknown'))} (${Math.round(atConf * 100)}%)</span>
|
||||
</div>
|
||||
<div style="font-size: 9px; color: #888; margin-bottom: 8px; font-style: italic; line-height: 1.4;">
|
||||
${escapeHtml(reasoning)}
|
||||
</div>
|
||||
<div style="display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; font-size: 9px; font-family: monospace;">
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">TEMP</div><div style="color: #00ffff; font-weight: 600;">${at.params?.temperature?.toFixed(2) || '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">TOP-P</div><div style="color: #00ffff; font-weight: 600;">${at.params?.top_p?.toFixed(2) || '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">TOP-K</div><div style="color: #00ffff; font-weight: 600;">${at.params?.top_k || '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">FREQ</div><div style="color: #00ffff; font-weight: 600;">${at.params?.frequency_penalty?.toFixed(2) || '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">PRES</div><div style="color: #00ffff; font-weight: 600;">${at.params?.presence_penalty?.toFixed(2) || '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">REP</div><div style="color: #00ffff; font-weight: 600;">${at.params?.repetition_penalty?.toFixed(2) || '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">TEMP</div><div style="color: #00ffff; font-weight: 600;">${Number.isFinite(at.params?.temperature) ? at.params.temperature.toFixed(2) : '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">TOP-P</div><div style="color: #00ffff; font-weight: 600;">${Number.isFinite(at.params?.top_p) ? at.params.top_p.toFixed(2) : '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">TOP-K</div><div style="color: #00ffff; font-weight: 600;">${Number.isFinite(at.params?.top_k) ? at.params.top_k : '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">FREQ</div><div style="color: #00ffff; font-weight: 600;">${Number.isFinite(at.params?.frequency_penalty) ? at.params.frequency_penalty.toFixed(2) : '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">PRES</div><div style="color: #00ffff; font-weight: 600;">${Number.isFinite(at.params?.presence_penalty) ? at.params.presence_penalty.toFixed(2) : '-'}</div></div>
|
||||
<div style="text-align: center; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 3px;"><div style="color: #888; font-size: 8px;">REP</div><div style="color: #00ffff; font-weight: 600;">${Number.isFinite(at.params?.repetition_penalty) ? at.params.repetition_penalty.toFixed(2) : '-'}</div></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -13174,7 +13204,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
'ULTRAPLINIAN-EARLYBIRD': `⚡ ${escapeHtml(magic.winnerModel?.split('/')[1] || 'model')} early stop in ${escapeHtml(String(magic.duration || 'N/A'))}`,
|
||||
'PLINY': `${escapeHtml(String(magic.template || '?'))} in ${escapeHtml(String(magic.duration || 'N/A'))}`,
|
||||
'G0DM0D3 CLASSIC': `${escapeHtml(String(magic.template || '?'))} [${escapeHtml(magic.model?.split('/')[1] || '?')}] in ${escapeHtml(String(magic.duration || 'N/A'))}`,
|
||||
'PARSELTONGUE': `${escapeHtml(magic.techniqueLabel || magic.technique || '?')} won (${magic.variants_succeeded || '?'}/${magic.variants_total || '?'}) in ${escapeHtml(String(magic.duration || 'N/A'))}`,
|
||||
'PARSELTONGUE': `${escapeHtml(magic.techniqueLabel || magic.technique || '?')} won (${parseInt(magic.variants_succeeded) || '?'}/${parseInt(magic.variants_total) || '?'}) in ${escapeHtml(String(magic.duration || 'N/A'))}`,
|
||||
'GODMODE': `Attempt ${parseInt(magic.attempt) || 1} (temp ${parseFloat(magic.temperature) || '?'})`
|
||||
}[magic.mode] || escapeHtml(String(magic.mode));
|
||||
|
||||
@@ -13191,7 +13221,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
// Calculate total improvement
|
||||
const totalImprovement = latestVersion && originalVersion
|
||||
? latestVersion.score - originalVersion.score
|
||||
: (msg.liquidImprovement || 0);
|
||||
: (Number(msg.liquidImprovement) || 0);
|
||||
|
||||
// Build version history display
|
||||
let versionHistoryHtml = '';
|
||||
@@ -13239,7 +13269,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span style="color: #64c8ff; font-weight: 600; font-size: 11px;">💧 LIQUID RESPONSE</span>
|
||||
<span style="color: #888; font-size: 10px; font-family: monospace; background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 3px;">
|
||||
${msg.liquidIterations || versions.length - 1} passes
|
||||
${parseInt(msg.liquidIterations) || versions.length - 1} passes
|
||||
</span>
|
||||
</div>
|
||||
<span style="color: ${totalImprovement > 0 ? '#4ade80' : '#888'}; font-size: 10px; font-family: monospace; background: rgba(100, 200, 255, 0.2); padding: 2px 6px; border-radius: 4px;">
|
||||
@@ -16731,6 +16761,34 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
r.isWinner = r.isWinner === true;
|
||||
}
|
||||
}
|
||||
if (msg.liquidIterations != null) msg.liquidIterations = parseInt(msg.liquidIterations) || 0;
|
||||
if (msg.liquidImprovement != null) msg.liquidImprovement = Number(msg.liquidImprovement) || 0;
|
||||
if (msg.magic && typeof msg.magic === 'object') {
|
||||
const m = msg.magic;
|
||||
if (m.mode != null) m.mode = String(m.mode).slice(0, 30);
|
||||
if (m.score != null) m.score = Number(m.score) || 0;
|
||||
if (m.duration != null) m.duration = String(m.duration).slice(0, 20);
|
||||
if (m.variants_succeeded != null) m.variants_succeeded = parseInt(m.variants_succeeded) || 0;
|
||||
if (m.variants_total != null) m.variants_total = parseInt(m.variants_total) || 0;
|
||||
if (m.variants_refused != null) m.variants_refused = parseInt(m.variants_refused) || 0;
|
||||
if (m.topScore != null) m.topScore = String(m.topScore).slice(0, 20);
|
||||
if (m.combos_attempted != null) m.combos_attempted = parseInt(m.combos_attempted) || 0;
|
||||
if (m.combos_succeeded != null) m.combos_succeeded = parseInt(m.combos_succeeded) || 0;
|
||||
if (m.combos_failed != null) m.combos_failed = parseInt(m.combos_failed) || 0;
|
||||
if (m.autoTune && typeof m.autoTune === 'object') {
|
||||
const at = m.autoTune;
|
||||
at.confidence = Number(at.confidence) || 0;
|
||||
at.conversationLength = Number(at.conversationLength) || 0;
|
||||
at.godmodeBoost = at.godmodeBoost === true;
|
||||
if (at.strategy != null) at.strategy = String(at.strategy).slice(0, 20);
|
||||
if (at.context != null) at.context = String(at.context).slice(0, 30);
|
||||
if (at.params && typeof at.params === 'object') {
|
||||
for (const k of Object.keys(at.params)) {
|
||||
at.params[k] = Number(at.params[k]) || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user