/* Current RLE catalog comparison, separate from recorded evaluation evidence. */
window.InstructionAudit = (() => {
const cache = new Map();
const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&', '<':'<', '>':'>', '"':'"', "'":'''}[c]));
const link = (url, label) => `${esc(label)} ↗ `;
const poolNames = {seen:'Seen templates', unseen:'Unseen templates', r1_distraction:'R1 · Distraction', r2_commonsense:'R2 · Commonsense', r3_reasoning:'R3 · Reasoning'};
async function render({panel, root, data, measuredInstructions, diff, isCurrent}) {
const main = document.querySelector('#main');
document.title = `Instructions audit · ${panel[0].toUpperCase() + panel.slice(1)} — Programmable VLA`;
main.innerHTML = '
Loading instruction comparison…
';
try {
if (!cache.has(panel)) cache.set(panel, fetch(root + `instruction-audit/${panel}.json`).then(response => {
if (!response.ok) throw Error(`Instruction snapshot unavailable (${response.status})`);
return response.json();
}).catch(error => {cache.delete(panel); throw error;}));
const audit = await cache.get(panel);
if (!isCurrent()) return;
mount({main, panel, root, data, measuredInstructions, diff, audit});
} catch (error) {
if (isCurrent()) main.innerHTML = ``;
}
}
function mount({main, panel, root, data, measuredInstructions, diff, audit}) {
const filters = {query:'', family:'', status:'', binding:''};
const sourceRoot = root + 'instruction-audit/';
const variants = new Map(data.variants.map(value => [value.id, value.label || value.agent]));
const episodes = new Map();
for (const episode of data.episodes) {
if (!episodes.has(episode.task_key)) episodes.set(episode.task_key, []);
episodes.get(episode.task_key).push(episode);
}
const rows = audit.tasks.map((task, index) => ({...task, index, difference:diff(task.native, task.measured)}));
const changed = rows.filter(task => task.status === 'changed').length;
const countBindings = rows.filter(task => Object.keys(task.bindings).length).length;
const scopeName = panel[0].toUpperCase() + panel.slice(1);
const sections = [['easy', 'Easy', root + 'index.html#instructions'], ['hard', 'Hard', root + 'hard/index.html#instructions'], ['plus', 'Plus', root + 'plus/index.html#instructions']];
main.innerHTML = `${esc(scopeName)} · Current RLE catalog
Instructions audit Current RLE instruction on the left. Pinned native task description on the right.
${sections.map(([key, name, href]) => `${name} `).join('')}
${esc(audit.comparison_basis)} Curly-braced RLE fields are filled from the initialized scene before the first model call.
Catalog comparison, separate from published results ${esc(audit.historical_note)} Native success predicates are unchanged; clearer language does not add missing checks to a verifier.
${panel === 'plus' ? 'Language-plus uses the same explicit RLE goal as the other configurations. This removes the original R1/R2/R3 language perturbation and must be reported as a separate RLE instruction protocol.
' : ''}
Snapshot ${esc(audit.created_at.slice(0, 10))} · ${esc(audit.version)} ${link(sourceRoot + 'sources.json', 'Source hashes')}${link(sourceRoot + panel + '.json', 'Audit JSON')}
`;
function card(task) {
const source = audit.native_sources[task.definition];
const bindingEntries = Object.entries(task.bindings);
const nativeCount = task.pool_keys.reduce((sum, key) => sum + source.pools[key].length, 0);
const recorded = episodes.get(task.published_task_key) || [];
return `
Current RLE instruction ${bindingEntries.length ? 'Scene-bound goal template' : 'Fixed goal'} · ${esc(audit.family)}
${task.difference.revised}
Native task description Upstream full_description · ${esc(source.revision.slice(0, 8))}
${task.difference.original}
${task.notes.length ? `${task.notes.map(note => `${esc(note)} `).join('')} ` : ''}
${bindingEntries.length ? `Scene bindings ${bindingEntries.map(([name, path]) => `{${esc(name)}} ← ${esc(path)} `).join('')}
` : ''}
Native runtime language · ${task.pool_keys.map(key => esc(poolNames[key])).join(' / ')} · ${nativeCount} ${task.configuration === 'demo_language_plus' ? 'sentences' : 'templates'}
Recorded episode instructions · ${recorded.length} episodes
`;
}
function renderRows() {
const query = filters.query.trim().toLowerCase();
const shown = rows.filter(task => (!filters.family || task.family === filters.family) && (!filters.status || task.status === filters.status) &&
(!filters.binding || Boolean(Object.keys(task.bindings).length) === (filters.binding === 'bound')) &&
(!query || [task.key, task.id, task.title, task.native_task, task.configuration, task.native, task.measured].some(value => value.toLowerCase().includes(query))));
main.querySelector('#audit-count').textContent = `${shown.length} / ${rows.length} tasks shown`;
main.querySelector('#audit-groups').innerHTML = shown.length ? audit.families.map(family => {
const matches = shown.filter(task => task.family === family.id);
return matches.length ? `
${esc(family.name)} ${matches.length} tasks ${matches.map(card).join('')} ` : '';
}).join('') : 'No matching tasks Try another search or reset the filters.
';
main.querySelectorAll('[data-native-pool]').forEach(details => details.addEventListener('toggle', () => {
if (details.open && !details.dataset.loaded) {nativePool(details, rows[Number(details.dataset.nativePool)]); details.dataset.loaded = 'true';}
}));
main.querySelectorAll('[data-recorded-language]').forEach(details => details.addEventListener('toggle', () => {
if (details.open && !details.dataset.loaded) {recordedLanguage(details, rows[Number(details.dataset.recordedLanguage)]); details.dataset.loaded = 'true';}
}));
}
function nativePool(details, task) {
const source = audit.native_sources[task.definition], container = details.querySelector('.audit-language-content');
const values = task.pool_keys.flatMap(key => source.pools[key].map((text, index) => ({text, key, index})));
container.innerHTML = `${task.configuration === 'demo_language_plus' ? 'Complete native sentences from the R1/R2/R3 pool; retained verbatim.' : 'Upstream runtime templates. Native placeholders use the upstream schema and are filled from the episode.'}
${source.schema ? `${esc(source.schema)}
` : ''}Native sample${values.map((value, index) => `${esc(poolNames[value.key])} · ${value.index + 1} `).join('')}
`;
const show = () => {container.querySelector('[data-native-sample]').textContent = values[Number(container.querySelector('select').value)].text;};
container.querySelector('select').addEventListener('change', show); show();
}
function recordedLanguage(details, task) {
const values = episodes.get(task.published_task_key) || [], container = details.querySelector('.audit-language-content');
if (!values.length) {container.textContent = 'No published episode for this task.'; return;}
container.innerHTML = `Exact recorded episode text. It is separate from the current catalog template above.
Published episode${values.map((episode, index) => `${esc(variants.get(episode.variant) || episode.variant)} · seed ${esc(episode.seed)} `).join('')}
`;
const show = () => {
const episode = values[Number(container.querySelector('select').value)];
container.querySelector('[data-recorded-instruction]').textContent = measuredInstructions.episodes[episode.id]?.text || episode.instruction || 'No recorded instruction text.';
container.querySelector('.audit-recorded-source').innerHTML = `Recorded policy: ${esc(episode.instruction_policy || 'unspecified')} Open episode evidence ↗ `;
};
container.querySelector('select').addEventListener('change', show); show();
}
main.querySelector('#audit-search').addEventListener('input', event => {filters.query = event.target.value; renderRows();});
for (const key of ['family', 'status', 'binding']) main.querySelector('#audit-' + key).addEventListener('change', event => {filters[key] = event.target.value; renderRows();});
main.querySelector('#audit-reset').addEventListener('click', () => {
for (const key of Object.keys(filters)) filters[key] = '';
main.querySelectorAll('.audit-controls input, .audit-controls select').forEach(element => {element.value = '';});
renderRows();
});
renderRows();
}
return {render};
})();