28 eval-informed mental models and critical-thinking skills for Claude Code, GitHub Copilot, Codex, Cursor, and other Agent Skills-compatible tools
JavaScript agent-skillsai-toolsanthropicclaudeclaude-codecritical-thinkingdecision-makingfirst-principlesmental-modelsproblem-solvingsystems-thinking
fix(m3-datasets): fix fault-localization scorer parsing + truncation bugs, recalibrate debugging family
Travis Boudreaux0c97d3b659f8
diff --git a/evals/datasets/calibrated/debugging-fault-localization.manifest.json b/evals/datasets/calibrated/debugging-fault-localization.manifest.jsonindex 690f00f..23b4fde 100644--- a/evals/datasets/calibrated/debugging-fault-localization.manifest.json+++ b/evals/datasets/calibrated/debugging-fault-localization.manifest.json@@ -24,29 +24,32 @@"ground_truth_field": "gold_files"},"calibration": {- "baseline": 1,+ "baseline": 0.792,"baseline_estimated": false,"band": [0.4,0.7],- "status": "measured_sample",+ "status": "ceiling_needs_harder_data","baseline_source": "measured_sample","in_band": false,- "exemption": "Calibration partially completed (10 items, K_TRIALS=5, 2 scored with 100% accuracy, 8 unattempted due to JSON/SWE-bench format parsing issues). The SWE-bench items require file-path prediction with ANSWER: format which conflicts with JSON-output instructions; most model responses could not be parsed. The 2 successfully-scored items are ceiling. Full calibration requires improved format handling but preliminary evidence suggests ceiling-level performance on truncated code-context prompts.",- "calibrated_items": 10,- "in_band_items": 0,+ "verdict": "CEILING-NEEDS-HARDER-DATA",+ "verdict_note": "Honest measured baseline is 79.2% (25 items, K_TRIALS=5, solver claude-sonnet-4-6). 19/25 items are ceiling (100% placebo), 4 floor (0%), 1 in-band (60%), 1 other out-of-band (20%). The claude-sonnet-4-6 solver is already very strong at SWE-bench fault localization without any thinking skill — placebo ceiling is genuine, not an artifact of parsing bugs or truncation. Per Invariant #4, ceiling is NOT a kill verdict; this family needs genuinely harder fault-localization items (more obscure repos, subtler bugs, multi-file localization) before a fair headroom-gated evaluation is possible. The one in-band item (swebench-3: astropy NDDataRef mask propagation, 60%) suggests that items requiring deeper domain knowledge can reach the calibration band. The scoring bug (ANSWER:-vs-JSON parsing + MAX_PROMPT_LEN truncation) was fixed before this measurement — all 125 trials scored successfully.",+ "exemption": "Genuine ceiling: placebo baseline 79.2% on 25-item SWE-bench sample (K_TRIALS=5). 19/25 items at 100% accuracy — the solver localizes fault files trivially well without any skill. This is NOT a measurement artifact; the ANSWER:-vs-JSON parsing and MAX_PROMPT_LEN truncation bugs were fixed before this run (all 125 trials scored). CEILING-NEEDS-HARDER-DATA per Invariant #4 — not a kill. The family needs harder items (subtler bugs, more obscure repos, multi-file patches) to reach the 40-70% calibration band.",+ "calibrated_items": 25,+ "in_band_items": 1,"decisive_split_items": 224,"calibration_only_items": 0,"exempt_items": 0,- "calibration_run_id": "calib-m3",+ "calibration_run_id": "calib-m3-fixed",+ "calibration_result_file": "evals/results/calib-m3-fixed/calibration-debugging-fault-localization-candidate-pool-calib-m3-fixed.json","calibration_solver": "claude-sonnet-4-6","calibration_k_trials": 5,- "sample_size": 10,- "ceiling_items": 2,- "floor_items": 0,- "other_out_of_band": 0,- "exemption_reason": "measured_baseline_outside_band"+ "sample_size": 25,+ "ceiling_items": 19,+ "floor_items": 4,+ "other_out_of_band": 1,+ "exemption_reason": "ceiling_needs_harder_data"},"item_counts": {"total": 224,@@ -57,7 +60,7 @@"decisive": 224,"calibration_only": 0,"exempt": 0,- "calibrated": 10+ "calibrated": 25},"item_class_definitions": {"target": "Items that directly measure the family value surface — in-domain, skill-relevant items where the skill is expected to help.",@@ -76,6 +79,6 @@},"created": "2026-06-06","frozen": true,- "frozen_at": "2026-06-06T15:16:01.832Z",- "frozen_by": "fix-m3-real-calibration-all-pools"+ "frozen_at": "2026-06-06T20:00:00.000Z",+ "frozen_by": "fix-m3-debugging-localization-scorer"}diff --git a/evals/run-calibration.js b/evals/run-calibration.jsindex 35d82d3..fe50df8 100644--- a/evals/run-calibration.js+++ b/evals/run-calibration.js@@ -126,6 +126,14 @@ function parsePrediction(json, rawText) {const m = str.match(ANSWER_LINE_RE);if (m) return { value: m[1].trim(), type: 'string', ok: true };+ // Fallback: try ANSWER: pattern in the raw text (model may have returned JSON+ // wrapper around a text answer, or the raw text may contain the answer line+ // that wasn't captured by JSON field iteration).+ if (rawText) {+ const rm = rawText.match(ANSWER_LINE_RE);+ if (rm) return { value: rm[1].trim(), type: 'string', ok: true };+ }+return { value: null, ok: false };}@@ -215,40 +223,57 @@ function truncatePrompt(prompt, maxLen = MAX_PROMPT_LEN) {}function buildCalibrationPrompt(problemText, decisionInstruction) {- // Replace "ANSWER: <path>" format requests with JSON format for reliable parsing.- // The ANSWER_LINE_RE in parsePrediction handles the text format as fallback,- // but we prefer JSON when we can control the prompt.- let di = decisionInstruction;- const answerMatch = di.match(/End\s+with\s+exactly\s*:\s*ANSWER\s*:\s*(.+)/i);+ // Strip the ANSWER: format instruction from the problem text since we add our+ // own format instruction. Conflicting format signals (ANSWER: vs JSON) cause+ // the model to follow the embedded text instruction and return non-JSON text+ // that droidJsonAsync cannot parse.+ let cleanProblem = problemText;+ // Remove trailing "End with exactly: ANSWER: ..." from the problem text+ // (SWE-bench items embed the decision instruction inside the prompt field).+ cleanProblem = cleanProblem.replace(/\n*\s*End\s+with\s+exactly\s*:\s*ANSWER\s*:.+\s*$/im, '');++ // Construct a single, unambiguous instruction.+ // Use a descriptive key name, not a literal placeholder like "<path/to/file.ext>"+ // which the model may return verbatim.+ let instruction = decisionInstruction;+ // If the original instruction references ANSWER:, generalize it for JSON.+ const answerMatch = instruction.match(/End\s+with\s+exactly\s*:\s*ANSWER\s*:\s*(.+)/i);if (answerMatch) {- const answerDesc = answerMatch[1].trim();- di = di.replace(/End\s+with\s+exactly\s*:\s*ANSWER\s*:.+/i,- `Return ONLY valid JSON: {"answer": "${answerDesc}"}`);+ // Replace only the "End with exactly: ANSWER: <placeholder>" part with a clean+ // JSON instruction. Keep the substantive question text.+ instruction = instruction.replace(/\s*End\s+with\s+exactly\s*:\s*ANSWER\s*:.+\s*$/i, '');+ instruction += '\n\nReturn ONLY valid JSON. Use the key "answer" for your file path. Example: {"answer": "path/to/file.ext"}';}- // Don't duplicate JSON format if the instruction already contains one.- const hasJsonInstruction = /return\s+only\s+valid\s+json/i.test(di) ||- /\{"\w+":/i.test(di);++ // Check if the instruction already has JSON guidance (avoid duplication).+ const hasJsonInstruction = /return\s+only\s+valid\s+json/i.test(instruction) ||+ /\{"\w+":/i.test(instruction);+if (hasJsonInstruction) {- return `${di}\n\nProblem:\n${problemText}`;+ return `${instruction}\n\nProblem:\n${cleanProblem}`;}- return `${di}\n\nProblem:\n${problemText}\n\nReturn ONLY valid JSON with your answer.`;+ return `${instruction}\n\nProblem:\n${cleanProblem}\n\nReturn ONLY valid JSON with your answer.`;}// ---- Shared trial processing ----async function processItemTrial(item, itemIndex) {+ const normLabel = normalizeLabel(item);const rawPrompt = buildCalibrationPrompt(item.prompt, item.decision_instruction);- const prompt = truncatePrompt(rawPrompt);++ // For filepath items (SWE-bench fault localization), skip truncation:+ // MAX_PROMPT_LEN=1600 strips the code context needed to localize bugs.+ const isFilepathItem = normLabel && normLabel.type === 'filepath';+ const prompt = isFilepathItem ? rawPrompt : truncatePrompt(rawPrompt);+const r = await droidJsonAsync({ model: SOLVER_MODEL, prompt, effort: SOLVER_EFFORT });let correct = null;let prediction = null;let predType = null;- let rawText = '';-- const normLabel = normalizeLabel(item);+ // droidJsonAsync returns {raw: text} not {text: text} — use r.raw+ const rawText = r.raw || '';if (r.ok) {- rawText = r.text || (r.json ? JSON.stringify(r.json) : '');const parsed = parsePrediction(r.json, rawText);predType = parsed.type;prediction = parsed.value;@@ -257,6 +282,19 @@ async function processItemTrial(item, itemIndex) {const result = judgePrediction(parsed, normLabel);correct = result;}+ } else {+ // JSON parsing failed — the model likely returned text with ANSWER: format.+ // Try to extract the answer from the raw text using the ANSWER_LINE_RE pattern.+ if (rawText) {+ const parsed = parsePrediction(null, rawText);+ predType = parsed.type;+ prediction = parsed.value;++ if (parsed.ok && normLabel) {+ const result = judgePrediction(parsed, normLabel);+ correct = result;+ }+ }}return {@@ -271,7 +309,7 @@ async function processItemTrial(item, itemIndex) {predType,correct,raw: rawText,- ok: r.ok,+ ok: r.ok || (prediction !== null), // mark as ok if we managed to extract a predictionerror: r.error,usage: r.usage,durationMs: r.durationMs,diff --git a/evals/run-swe.js b/evals/run-swe.jsindex 6d39557..c32e624 100644--- a/evals/run-swe.js+++ b/evals/run-swe.js@@ -32,11 +32,20 @@ function loadItems() {function skillContent(s) { return fs.readFileSync(path.join(SKILLS_DIR, 'thinking-' + s.replace(/^thinking-/, ''), 'SKILL.md'), 'utf8'); }function locatedCorrectly(item, text) {- // correct if a gold file path or its (distinctive) basename appears in the response+ // Correct if a gold file path or its (distinctive) basename appears in the response.+ // Normalize paths (handle backslashes, leading slashes) for consistency with+ // run-calibration.js judgePrediction filepath handling.+ const normText = text.replace(/\\/g, '/');for (const g of item.gold_files) {- if (text.includes(g)) return true;- const base = g.split('/').pop();- if (base && !/^(__init__|utils|index|main|app|setup)\.\w+$/.test(base) && new RegExp('\\b' + base.replace('.', '\\.') + '\\b').test(text)) return true;+ const normGold = String(g).replace(/\\/g, '/');+ // Exact path match (normalized)+ if (normText.includes(normGold)) return true;+ // Also try without leading slash+ const stripped = normGold.replace(/^\/+/, '');+ if (stripped !== normGold && normText.includes(stripped)) return true;+ // Basename fallback (for responses that only mention the file name)+ const base = normGold.split('/').pop();+ if (base && !/^(__init__|utils|index|main|app|setup)\.\w+$/.test(base) && new RegExp('\\b' + base.replace('.', '\\.') + '\\b').test(normText)) return true;}return false;}