Skip to content

Commit bc861c8

Browse files
Adarsh Kumarappanclaude
authored andcommitted
JS hardening complete: add Codex prompts, update hardening log
JavaScript overall GPT-5.5 Pass@1: 49.2% (target ≤55%) Per-category scores: - Code2NL/NL2Code: 44.4% (9 Codex mutations) - Code Purpose: 44.0% (no hardening needed) - Syntax Completion: 50.0% (3 Codex mutations) - Pattern Matching: 50.8% (15 Codex mutations) - API Usage: 51.2% (20 Codex mutations) - Low Context: 54.8% (10 Codex mutations) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6175298 commit bc861c8

7 files changed

Lines changed: 1156 additions & 5 deletions

CODEX_PROMPT_JS_API_USAGE.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Task for Codex: Harden DevBench JavaScript API Usage
2+
3+
## Context
4+
5+
DevBench is a code generation benchmark paper rejected from ICLR 2026 (ceiling effect: 84.8% Pass@1). Resubmitting to NeurIPS 2026 with harder tasks. Python is done (53% overall for GPT-5.5). Now doing JavaScript.
6+
7+
The benchmark uses fill-in-the-middle (FIM) code completion:
8+
- Each task has: `prefix`, `golden_completion`, `suffix`, `assertions`
9+
- The model sees: `prefix + #TODO: You Code Here + suffix`
10+
- The model does NOT see `assertions` (hidden tests)
11+
- Execution runs: `prefix + model_completion + suffix + assertions`
12+
- Pass@1 with n=5 samples
13+
14+
## Goal
15+
16+
**Bring GPT-5.5 Pass@1 on JavaScript API Usage to ≤58%** (currently 91.2%).
17+
18+
- Current total points: 4560 (out of 5000)
19+
- Target: ≤2900 points (58%)
20+
- Need to reduce by: 1660 points
21+
- If each conversion takes a 100% task to 0%: need ~17 conversions
22+
- There are 44 tasks at 100% — plenty of candidates
23+
24+
This is the HARDEST category to harden — 91.2% baseline means GPT-5.5 handles Node.js APIs very well. You'll need aggressive mutations.
25+
26+
## MANDATORY: Read these files first
27+
28+
1. **`HARDENING_LOG.md`** — FULL methodology. Pay special attention to:
29+
- Round 6 (API Usage Codex report) — CSV dialect mechanism
30+
- Round 6B (API Usage continuation) — docstring precision mechanism
31+
- "What worked best" and "What did not work" from both rounds
32+
2. **`benchmark/javascript/api_usage/api_usage.jsonl`** — Current 50 JavaScript API Usage tasks
33+
3. **`eval_poc.py`** (at repo root) — Evaluation script
34+
4. **`.env`** — API keys
35+
36+
## What Worked for Python API Usage (from HARDENING_LOG.md)
37+
38+
### Mechanism 1: CSV dialect edge cases (Round 6)
39+
- Custom `csv.writer` with specific delimiter, quotechar, escapechar combinations
40+
- GPT-5.5 used `lineterminator=''` which changed quoting behavior
41+
- 3 tasks accepted (0/5, 2/5, 0/5)
42+
43+
### Mechanism 2: API-specific docstring precision (Round 6B — MORE ROBUST)
44+
- Completion slot is a function DOCSTRING
45+
- Suffix contains the implementation using specific stdlib APIs
46+
- Hidden assertions require precise documentation of API params, return types, side effects, exceptions
47+
- GPT-5.5 wrote generic "Return the SHA-256 hex digest..." and omitted details
48+
- 5 tasks accepted (all 0/5)
49+
50+
**For JavaScript, the docstring approach needs adaptation:**
51+
- JS doesn't have Python's `.__doc__` attribute
52+
- Use `.doc` property assignment: `myFunc.doc = 'precise description...'`
53+
- Or use a `describe*()` function that returns the description string
54+
- Or use `Function.prototype.toString()` which includes JSDoc comments inside the function body
55+
56+
### What didn't work:
57+
- `base91_encode`: GPT-5.5 solved 5/5 in API Usage context
58+
- Explicit Decimal docstring: GPT-5.5 scored 4/5 when prefix directly said "add a docstring"
59+
60+
## Current GPT-5.5 Scores
61+
62+
```
63+
100% (44 tasks): 1,2,3,5,6,7,10,11,12,13,14,15,16,17,18,19,20,21,22,23,25,26,27,28,30,31,32,33,34,35,36,37,38,39,40,41,42,44,45,46,47,48,49,50
64+
80% (1 task): 24
65+
60% (1 task): 43
66+
20% (1 task): 4
67+
0% (3 tasks): 8,9,29
68+
```
69+
70+
Overall: 91.2% (4560/5000). Target: ≤58% (2900/5000).
71+
72+
### Analysis of 0% tasks (what's working):
73+
- Task 8: SafeEmitter with error handling + emit override + maxListeners — multi-invariant pattern
74+
- Task 9: Raw deflate (`deflateRawSync`/`inflateRawSync`) — API edge case (windowBits: -15)
75+
- Task 29: fs.mkdtempSync — specific API usage pattern
76+
77+
### Analysis of 100% tasks:
78+
Most are straightforward Node.js API usage that GPT-5.5 handles well. Need aggressive mutations using BOTH mechanisms: API edge cases AND docstring precision.
79+
80+
## Your Task
81+
82+
**Replace 100% tasks ONE AT A TIME.** This category needs ~17 conversions — the most of any category. Be efficient.
83+
84+
### Recommended approach (mix of mechanisms):
85+
- **8-10 encoding/escaping tasks**: Custom base encoders with reversed alphabets (proven 0% in Pattern Matching and Low Context). These work in ANY category when wrapped appropriately.
86+
- **4-5 API docstring precision tasks**: Completion is a `.doc` string or `describe*()` return that must precisely document Node.js API behavior
87+
- **3-4 API edge case tasks**: Specific Node.js API usage where GPT-5.5 gets edge cases wrong
88+
89+
### JavaScript encoding task template for API Usage context:
90+
91+
Frame the encoding as "API Usage" by having the prefix establish a pattern of using Buffer/crypto APIs:
92+
93+
```javascript
94+
// PREFIX: Show 2-3 examples of encoding functions using Node.js Buffer API
95+
const STANDARD58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
96+
const REVERSED58 = STANDARD58.split('').reverse().join('');
97+
98+
function hexEncode(data) {
99+
return Buffer.from(data).toString('hex');
100+
}
101+
102+
function leadingZeroBytes(data) {
103+
let count = 0;
104+
for (const b of data) { if (b !== 0) break; count++; }
105+
return count;
106+
}
107+
108+
// GOLDEN: base58Encode using Buffer API with reversed default
109+
function base58Encode(data, alphabet = REVERSED58) {
110+
if (typeof data === 'string') data = Buffer.from(data);
111+
let n = BigInt('0x' + (data.length ? Buffer.from(data).toString('hex') : '0'));
112+
const base = BigInt(alphabet.length);
113+
const out = [];
114+
while (n > 0n) { out.push(alphabet[Number(n % base)]); n = n / base; }
115+
return alphabet[0].repeat(leadingZeroBytes(data)) + out.reverse().join('');
116+
}
117+
118+
// SUFFIX: assert custom != standard
119+
```
120+
121+
### Process for each task:
122+
1. Pick a task ID from the 100% list
123+
2. Design a new task using one of the three mechanisms
124+
3. Write JSON with all required fields
125+
4. Validate with Node.js
126+
5. Eval against GPT-5.5 (n=5)
127+
6. If pass@1 ≤ 40%: SUCCESS
128+
7. If pass@1 ≥ 80%: try different approach (up to 3 attempts)
129+
8. Update running score
130+
9. **Stop when overall ≤ 58%**
131+
132+
### MANDATORY: Save completions for every evaluated task
133+
134+
```bash
135+
echo '{TASK_JSON}' > /tmp/codex_eval_task.jsonl
136+
EVAL_MODEL=gpt-5.5-2026-04-23 \
137+
EVAL_FILE=/tmp/codex_eval_task.jsonl \
138+
SAVE_COMPLETIONS=1 \
139+
COMPLETIONS_OUT=/Users/adarshkumarappan/Impt/devbench/benchmark/javascript/api_usage/completions-codex-mutation-task{ID}-attempt{N}.jsonl \
140+
/Users/adarshkumarappan/miniconda3/envs/devbench/bin/python -u /Users/adarshkumarappan/Impt/devbench/eval_poc.py
141+
```
142+
143+
### Evaluation setup:
144+
- Model: `gpt-5.5-2026-04-23` (no temperature)
145+
- Use `max_completion_tokens` not `max_tokens`
146+
- n=5, Pass@1 = c/n
147+
- Eval script: `/Users/adarshkumarappan/Impt/devbench/eval_poc.py`
148+
- Node.js: `/Users/adarshkumarappan/.nvm/versions/node/v24.12.0/bin/node`
149+
- Conda: `/Users/adarshkumarappan/miniconda3/envs/devbench/bin/python`
150+
- **ALWAYS use absolute paths**
151+
152+
### Important constraints:
153+
- Tasks must be solvable from visible context (FAIRNESS)
154+
- Suffix must contain signals for correct behavior
155+
- Tasks should fit "API Usage" category: testing Node.js built-in module usage
156+
- Golden completions: 3-15 lines
157+
- Node.js standard modules only
158+
- ONE task at a time, track running score
159+
- **Pre-compute all expected values** — do NOT guess encoding outputs
160+
161+
### What to save:
162+
1. Append new tasks to: `benchmark/javascript/api_usage/codex_mutations.jsonl`
163+
2. Save per-task completions (see MANDATORY section)
164+
3. Save scores to: `benchmark/javascript/api_usage/codex_mutation_scores.jsonl`
165+
4. Update `HARDENING_LOG.md` with JS API Usage results
166+
5. Do NOT assemble final file
167+
168+
## [CODEX: ADD YOUR OWN INSIGHTS HERE]
169+
170+
Before starting:
171+
1. Analyze the 3 tasks that score 0% — understand what mechanisms work
172+
2. Look at the 44 tasks at 100% — understand why they're easy
173+
3. Plan which tasks to replace and with which mechanism
174+
4. Since you need ~17 conversions, efficiency matters — start with proven encoding tasks
175+
176+
## Stop condition
177+
178+
**Stop when running_score ≤ 58%.** Do NOT continue past this. Do NOT re-eval all 50.

CODEX_PROMPT_JS_CODE2NL.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# Task for Codex: Harden DevBench JavaScript Code2NL/NL2Code
2+
3+
## Context
4+
5+
DevBench is a code generation benchmark rejected from ICLR 2026 (ceiling effect). Resubmitting to NeurIPS 2026. Python is done (53% overall for GPT-5.5). Now doing JavaScript.
6+
7+
FIM code completion format:
8+
- Model sees: `prefix + #TODO: You Code Here + suffix`
9+
- Model does NOT see `assertions` (hidden tests)
10+
- Execution: `prefix + model_completion + suffix + assertions`
11+
- Pass@1 with n=5 samples
12+
13+
## Goal
14+
15+
**Bring GPT-5.5 Pass@1 on JavaScript Code2NL/NL2Code to ≤45%** (currently 62.4%).
16+
17+
- Current total points: 3120 (out of 5000)
18+
- Target: ≤2250 points (45%)
19+
- Need to reduce by: 870 points
20+
- If each conversion takes a 100% task to 0%: need ~9 conversions
21+
- There are 28 tasks at 100% — plenty of candidates
22+
23+
## MANDATORY: Read these files first
24+
25+
1. **`HARDENING_LOG.md`** — Full methodology. Pay special attention to:
26+
- Round 7 (Code2NL Codex report) — docstring precision mechanism
27+
- The exact failure pattern: GPT-5.5 returns empty completion or `pass` instead of precise docs
28+
2. **`benchmark/javascript/code2NL_NL2code/code2NL_NL2code.jsonl`** — Current 50 JavaScript tasks
29+
3. **`eval_poc.py`** (at repo root) — Evaluation script
30+
4. **`.env`** — API keys
31+
32+
## What Worked for Python Code2NL (from HARDENING_LOG.md — achieved 46.4%)
33+
34+
**Docstring precision gaps** — the ONLY mechanism that worked:
35+
- Completion slot is immediately after a function/method header, before the executable body
36+
- The body is visible in the suffix and shows specific API behavior
37+
- Hidden assertions check that `.__doc__` contains specific keywords
38+
- GPT-5.5 returns empty completion or generic "Processes input" instead of precise docs
39+
40+
**For JavaScript, the docstring approach uses:**
41+
1. **`.doc` property**: `myFunc.doc = 'precise description...'` — assertions check `myFunc.doc.includes('keyword')`
42+
2. **`describe*()` function**: returns description string — assertions check return value
43+
3. **NL2Code**: prefix has natural language spec, completion is code implementation with subtle behavioral requirements
44+
45+
### What the 17 existing 0% tasks prove works in JS:
46+
- Tasks 1-8: `.doc` property and `describe*()` approaches — GPT-5.5 writes generic descriptions missing specific keywords like "mutating", "WeakSet", "circular", "leading", "undefined"
47+
- Tasks 21-22, 24-28, 30: doc property and describe functions requiring precise API documentation — GPT-5.5 omits details about LRU promotion, bottom-up traversal, deref(), non-enumerable properties
48+
- Task 40: Complex template engine NL2Code — GPT-5.5 can't coordinate pipe filters + double-brace escaping
49+
50+
## Current GPT-5.5 Scores
51+
52+
```
53+
100% (28 tasks): 9,10,11,12,13,14,15,17,18,19,20,23,29,31,32,33,34,36,37,38,39,41,42,44,46,47,49,50
54+
80% (3 tasks): 16,45,48
55+
60% (1 task): 43
56+
20% (1 task): 35
57+
0% (17 tasks): 1,2,3,4,5,6,7,8,21,22,24,25,26,27,28,30,40
58+
```
59+
60+
Overall: 62.4% (3120/5000). Target: ≤45% (2250/5000).
61+
62+
## Your Task
63+
64+
**Replace 100% tasks ONE AT A TIME with harder Code2NL/NL2Code tasks.**
65+
66+
### Recommended mechanism mix (for 9 conversions):
67+
- **5-6 doc/describe tasks**: Completion is a `.doc` property string or `describe*()` return value. Assertions check for specific keywords that GPT-5.5 omits from generic descriptions.
68+
- **3-4 NL2Code tasks**: Prefix has detailed natural language spec, completion is code with subtle behavioral requirements that differ from standard implementations.
69+
70+
### Doc/describe task template:
71+
72+
```javascript
73+
// PREFIX:
74+
function stablePartition(arr, predicate) {
75+
76+
// GOLDEN_COMPLETION (doc property):
77+
stablePartition.doc = 'Stably partition array in place by predicate. ' +
78+
'Items where predicate returns true move to front, preserving relative order ' +
79+
'within both groups. Mutates the input array. Predicate is called exactly once ' +
80+
'per item. Returns the split index.';
81+
82+
// SUFFIX (implementation visible to model):
83+
const kept = [];
84+
const rest = [];
85+
for (const item of arr) {
86+
(predicate(item) ? kept : rest).push(item);
87+
}
88+
const idx = kept.length;
89+
kept.push(...rest);
90+
arr.length = 0;
91+
arr.push(...kept);
92+
return idx;
93+
}
94+
95+
// ASSERTIONS (hidden):
96+
const assert = require('assert');
97+
assert(stablePartition.doc.includes('in place'));
98+
assert(stablePartition.doc.includes('Mutates'));
99+
assert(stablePartition.doc.includes('exactly once'));
100+
assert(stablePartition.doc.includes('split index'));
101+
```
102+
103+
### Keywords that GPT-5.5 consistently OMITS (use these in assertions):
104+
- "mutate" / "in place" / "modifies" (for mutation operations)
105+
- Specific API method names (e.g., "WeakSet", "deref", "bisect")
106+
- "exactly once" / "at most once" (for call count guarantees)
107+
- Exception/error behavior ("throws TypeError", "throws RangeError")
108+
- Return value details ("returns the split index", "returns undefined")
109+
- Side effect details ("appends to audit log", "updates counter")
110+
- Edge case behavior ("empty input returns", "null treated as")
111+
112+
### NL2Code task template:
113+
114+
```javascript
115+
// PREFIX (natural language spec):
116+
// Implement slugify(str) that:
117+
// - Converts to lowercase
118+
// - Replaces spaces with hyphens
119+
// - REMOVES non-alphanumeric chars (does NOT replace with hyphens)
120+
// - Collapses consecutive hyphens
121+
// - Trims leading/trailing hyphens
122+
123+
// GOLDEN_COMPLETION:
124+
function slugify(str) {
125+
return str.toLowerCase()
126+
.replace(/\s+/g, '-')
127+
.replace(/[^a-z0-9-]/g, '') // remove, not replace
128+
.replace(/-+/g, '-')
129+
.replace(/^-|-$/g, '');
130+
}
131+
132+
// SUFFIX:
133+
const assert = require('assert');
134+
assert.strictEqual(slugify('Hello World'), 'hello-world');
135+
136+
// ASSERTIONS (hidden — test the subtle behavior):
137+
assert.strictEqual(slugify('a!!!b'), 'ab'); // NOT 'a-b'
138+
```
139+
140+
### Process for each task:
141+
1. Pick from the 100% list
142+
2. Design using doc/describe or NL2Code mechanism
143+
3. Write JSON with all fields
144+
4. Validate with Node.js
145+
5. Eval against GPT-5.5 (n=5)
146+
6. If pass@1 ≤ 40%: SUCCESS
147+
7. If pass@1 ≥ 80%: try different (up to 3 attempts)
148+
8. Update running score
149+
9. **Stop when overall ≤ 45%**
150+
151+
### MANDATORY: Save completions
152+
153+
```bash
154+
echo '{TASK_JSON}' > /tmp/codex_eval_task.jsonl
155+
EVAL_MODEL=gpt-5.5-2026-04-23 \
156+
EVAL_FILE=/tmp/codex_eval_task.jsonl \
157+
SAVE_COMPLETIONS=1 \
158+
COMPLETIONS_OUT=/Users/adarshkumarappan/Impt/devbench/benchmark/javascript/code2NL_NL2code/completions-codex-mutation-task{ID}-attempt{N}.jsonl \
159+
/Users/adarshkumarappan/miniconda3/envs/devbench/bin/python -u /Users/adarshkumarappan/Impt/devbench/eval_poc.py
160+
```
161+
162+
### Evaluation setup:
163+
- Model: `gpt-5.5-2026-04-23` (no temperature)
164+
- `max_completion_tokens` not `max_tokens`
165+
- n=5, Pass@1 = c/n
166+
- Eval script: `/Users/adarshkumarappan/Impt/devbench/eval_poc.py`
167+
- Node.js: `/Users/adarshkumarappan/.nvm/versions/node/v24.12.0/bin/node`
168+
- Conda: `/Users/adarshkumarappan/miniconda3/envs/devbench/bin/python`
169+
- **ALWAYS use absolute paths**
170+
171+
### Important constraints:
172+
- Doc tasks: completion is DOCUMENTATION, not code
173+
- NL2Code tasks: completion is CODE from a spec, with subtle behavioral traps
174+
- Do NOT use encoding tasks — wrong category
175+
- Golden completions: 3-12 lines
176+
- Node.js standard modules only
177+
- ONE task at a time
178+
179+
### What to save:
180+
1. Append new tasks to: `benchmark/javascript/code2NL_NL2code/codex_mutations.jsonl`
181+
2. Save per-task completions
182+
3. Save scores to: `benchmark/javascript/code2NL_NL2code/codex_mutation_scores.jsonl`
183+
4. Update `HARDENING_LOG.md`
184+
5. Do NOT assemble final file
185+
186+
## [CODEX: ADD YOUR OWN INSIGHTS HERE]
187+
188+
Analyze the 17 existing 0% tasks. What keywords do their assertions check for? Which doc/describe patterns are most effective? Use that to design your replacements.
189+
190+
## Stop condition
191+
192+
**Stop when running_score ≤ 45%.** Need ~9 conversions.

0 commit comments

Comments
 (0)