File size: 34,212 Bytes
d82e576
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
---
pretty_name: JS/TS Code Review Decisions
language:
- en
- code
license: cc-by-4.0
tags:
- synthetic
- code
- code-review
- javascript
- typescript
- static-analysis
- code-quality
- small-decision-model
- decision-model
- typed-decisions
- structured-decisions
- system-one
- calibration
- benchmark
- classification
annotations_creators:
- machine-generated
multilinguality:
- monolingual
size_categories:
- 1K<n<10K
source_datasets:
- original
task_categories:
- text-classification
task_ids:
- multi-label-classification
configs:
- config_name: default
  default: true
  data_files:
  - split: train
    path: data/train.parquet
  - split: validation
    path: data/validation.parquet
  - split: test
    path: data/test.parquet
- config_name: decisions
  data_files:
  - split: train
    path: decisions/train.parquet
  - split: validation
    path: decisions/validation.parquet
  - split: test
    path: decisions/test.parquet
dataset_info:
- config_name: default
  features:
  - name: snippet_slug
    dtype: string
  - name: task_slug
    dtype: string
  - name: domain
    dtype: string
  - name: context
    dtype: string
  - name: description
    dtype: string
  - name: lang
    dtype: string
  - name: code
    dtype: string
  - name: line_count
    dtype: int64
  - name: unclear_naming
    dtype: bool
  - name: noise_comments
    dtype: bool
  - name: dead_code
    dtype: bool
  - name: inconsistent_style
    dtype: bool
  - name: over_abstracted
    dtype: bool
  - name: too_clever
    dtype: bool
  - name: duplicated_logic
    dtype: bool
  - name: error_handling_problem
    dtype: bool
  - name: type_safety_hole
    dtype: bool
  - name: unsafe_input
    dtype: bool
  - name: primary_flaw
    dtype: string
  - name: quality
    dtype: int64
  - name: difficulty
    dtype: string
  - name: uncertain_flags
    list: string
  - name: findings
    list:
    - name: finding_slug
      dtype: string
    - name: flag
      dtype: string
    - name: start_line
      dtype: int64
    - name: end_line
      dtype: int64
    - name: excerpt
      dtype: string
    - name: explanation
      dtype: string
    - name: audit_verdict
      dtype: string
  splits:
  - name: train
    num_bytes: 24714913
    num_examples: 9600
  - name: validation
    num_bytes: 3085557
    num_examples: 1200
  - name: test
    num_bytes: 3034445
    num_examples: 1200
  download_size: 12888541
  dataset_size: 30834915
- config_name: decisions
  features:
  - name: id
    dtype: string
  - name: task_slug
    dtype: string
  - name: split
    dtype: string
  - name: lang
    dtype: string
  - name: difficulty
    dtype: string
  - name: uncertain_flags
    list: string
  - name: state
    dtype: string
  - name: questions
    dtype: string
  - name: gold
    dtype: string
  - name: n_questions
    dtype: int64
  - name: unclear_naming__label
    dtype: string
  - name: unclear_naming__probability_true
    dtype: float64
  - name: noise_comments__label
    dtype: string
  - name: noise_comments__probability_true
    dtype: float64
  - name: dead_code__label
    dtype: string
  - name: dead_code__probability_true
    dtype: float64
  - name: inconsistent_style__label
    dtype: string
  - name: inconsistent_style__probability_true
    dtype: float64
  - name: over_abstracted__label
    dtype: string
  - name: over_abstracted__probability_true
    dtype: float64
  - name: too_clever__label
    dtype: string
  - name: too_clever__probability_true
    dtype: float64
  - name: duplicated_logic__label
    dtype: string
  - name: duplicated_logic__probability_true
    dtype: float64
  - name: error_handling_problem__label
    dtype: string
  - name: error_handling_problem__probability_true
    dtype: float64
  - name: type_safety_hole__label
    dtype: string
  - name: type_safety_hole__probability_true
    dtype: float64
  - name: unsafe_input__label
    dtype: string
  - name: unsafe_input__probability_true
    dtype: float64
  - name: has_flaw__label
    dtype: string
  - name: has_flaw__probability_true
    dtype: float64
  - name: primary_flaw__label
    dtype: string
  - name: primary_flaw__probabilities
    dtype: string
  - name: quality__label
    dtype: string
  - name: quality__probabilities
    dtype: string
  - name: quality__score
    dtype: float64
  splits:
  - name: train
    num_bytes: 101500450
    num_examples: 9600
  - name: validation
    num_bytes: 12706305
    num_examples: 1200
  - name: test
    num_bytes: 12640111
    num_examples: 1200
  download_size: 7819377
  dataset_size: 126846866
---

![JS/TS Code Review Decisions: 12,000 synthetic JavaScript and TypeScript snippets with 27,450 line-level findings across 10 code review flaws.](https://huggingface.co/datasets/yannelli/js-ts-code-review-decisions/resolve/main/assets/js-ts-code-review-decisions-banner.png)

# JS/TS Code Review Decisions

Training data and a benchmark for a small decision model that flags bad JavaScript and TypeScript code in real time.

The dataset contains 12,000 synthetic code snippets and 27,450 line-level findings. Each snippet has 10 Boolean flaw labels: unclear naming, noise comments, dead code, inconsistent style, over-abstraction, too-clever code, duplicated logic, error handling problems, type safety holes, and unsafe input. Each of the 3,000 tasks has 4 variants: one with no labeled flaws and three with flaws.

The `decisions` config poses the same data as typed decisions: a snippet is the state, and a model answers 13 typed questions about it at once, each with a probability. The schema follows the System One primitives (`noul`, `choice`, `score`), so a row replays against any API with that shape.

## Leaderboard

Results cover the `test` split of the `decisions` config: 300 tasks, 1,200 cases, and 15,600 decisions. `score_decisions.py` evaluates answers to each complete case: state plus all 13 questions. Specialist models are fitted on `train` and ranked separately from zero-shot general models. This release includes specialist and reference baselines.

| Metric | TF-IDF | Prior | Uniform |
|---|---:|---:|---:|
| Macro F1 @ 0.5 | 0.502 | 0.000 | 0.237 |
| Accuracy | 0.830 | 0.766 | 0.189 |
| Log loss | 0.449 | 0.636 | 0.895 |
| Brier | 0.172 | 0.230 | 0.343 |
| ECE | 0.030 | 0.005 | 0.319 |

- **TF-IDF:** TF-IDF + logistic regression, a specialist fitted on `train`. Implementation: `baseline_decisions.py`. Local p50 latency: **1.2 ms**; local execution rather than API pricing.
- **Prior:** reference baseline using `train` label frequencies, without the input.
- **Uniform:** reference baseline assigning equal probability to every option.

Higher is better for macro F1 and accuracy; lower is better for log loss, Brier, and ECE. 95% intervals for the TF-IDF row: macro F1 0.476 to 0.525, accuracy 0.824 to 0.836, log loss 0.434 to 0.462, Brier 0.167 to 0.176. Latency was measured locally, one case at a time, on 16 Neoverse V3 cores without a GPU. By question type its accuracy is 0.895 on the 11 nouls, 0.482 on `primary_flaw`, and 0.459 on `quality`, and it judges 31% of clean test cases clean.

The Prior baseline has the lowest ECE but a macro F1 of 0: it predicts no flaw at the 0.5 cutoff. Report calibration metrics alongside F1 and accuracy.

### Metrics

`score_decisions.py` reports all five metrics, scored and total case counts, and probability mass assigned to unknown options. Partial runs are scored on completed cases.

- **Macro F1 at 0.5**: F1 for each of the 10 flaw nouls with yes meaning P(yes) at or above 0.5, averaged. This follows the Jev evaluation paper's method for multi-label tasks posed as one yes/no question per label.
- **Accuracy**: share of the 15,600 decisions where the top answer is the gold one. Nouls use the 0.5 cutoff; choice and score use the most probable option.
- **Log loss**: minus the natural log of the probability given to the gold answer, floored at 0.000001. Because the gold is a single label, this equals the KL divergence from the gold distribution.
- **Brier**: (P(yes) minus truth) squared for nouls; the sum over options of (probability minus one-hot gold) squared for choice and score.
- **ECE**: expected calibration error with 15 equal-width bins, averaged over the 13 questions. Nouls bin P(yes) against the truth; choice and score bin the top probability against whether that option was right.

Intervals are 95% bootstrap intervals from 500 resamples of test tasks; a task's 4 variants move together.

Evaluation reference: *Evaluating and Benchmarking the System One Model Jev*, §3.4, arXiv 2609.37647. The paper describes Jev's evaluation methodology, not this dataset.

### Reading a score

Gold labels come from blind model review, with a separate finding-level audit that accepted 98.3% of findings. Each finding includes its `audit_verdict`.

The TF-IDF baseline's per-flag F1 ranges from 0.023 on `duplicated_logic` to 0.880 on `noise_comments`. Report per-question results and breakdowns by `difficulty` alongside aggregate scores.

### Adding a model

Answer every test case of the `decisions` config and write one line per case, `{"id": ..., "answers": ..., "latency_ms": ...}`, where `answers` is the map the API returned, with full distributions. Then:

```sh
uv run --no-project --with pyarrow==26.0.0 --with numpy==2.5.4 python3 score_decisions.py ANSWERS.jsonl
```

Open a discussion with the tables it prints, the model and version, the date, the mode (specialist or general), the request shape if it was not the whole case in one request, the hardware or endpoint behind the latency, and the price. Keep the answers file so the row can be rescored.

## Flaw definitions

These are the definitions used during annotation. A snippet can have several flags; counts are snippets with the flag set to true.

The short names below are used in the results tables.

### Naming

`unclear_naming` · 1,414 positive snippets.

Single letters outside short callbacks, names like data/temp/obj/handle, misleading names, abbreviations a new teammate could not expand.

### Comments

`noise_comments` · 1,743 positive snippets.

Any comment, including JSDoc blocks, comments that explain why, and banners; code should explain itself through names, types and structure. Tool directives such as `// @ts-check` or `// eslint-disable-next-line` do not count, and commented-out code is `dead_code`.

### Dead code

`dead_code` · 2,340 positive snippets.

Commented-out code, unused variables, imports, or parameters, unreachable branches, leftover console.log or debugger. Unused exports do not count, because callers are not visible.

### Style

`inconsistent_style` · 1,437 positive snippets.

camelCase next to snake_case, async/await mixed with .then chains, var next to const, mixed quotes or semicolon use, all inside one snippet.

### Abstraction

`over_abstracted` · 1,337 positive snippets.

An interface with one implementation, a factory or strategy for one case, generic parameters only ever used with one type, options that never vary, wrappers that only forward.

### Clever code

`too_clever` · 1,622 positive snippets.

Nested ternaries, one reduce doing three jobs, bitwise tricks, comma operators, side effects hidden in short-circuit expressions, a regex doing a parser's work.

### Duplication

`duplicated_logic` · 1,757 positive snippets.

The same logic appears two or more times with small variations.

### Errors

`error_handling_problem` · 1,472 positive snippets.

Empty catch, catch that logs and carries on as if the call succeeded, promise with no rejection handling, errors converted to null or false with the cause lost, thrown strings.

### Types

`type_safety_hole` · 1,447 positive snippets.

any, non-null `!`, `as` casts on unchecked values, @ts-ignore. In plain JS: loose equality where types can differ, property access on values that can be undefined.

### Input

`unsafe_input` · 1,622 positive snippets.

Request bodies, query params, env vars, file contents, or API responses used unchecked. String-built SQL, innerHTML, eval, file paths built from user input.

For error handling, an awaited or returned promise propagates errors; a local catch is not required.

## Example

This training row has two flags. Its `code` value:

```js
const { CartLineItem, ProductVariant } = require('../models');
const cartReaders = {
    active: async (cartId) => await CartLineItem.findAll({
        where: { cartId, active: true },
        attributes: ['id', 'variantId', 'quantity', 'unitPrice'],
        include: [{ model: ProductVariant, as: 'variant', required: true, attributes: ['id', 'sku', 'color', 'size'] }],
        order: [['id', 'ASC']]
    })
};
const selectCartReader = (mode) => cartReaders[mode];
async function fetchActiveCartItems(cartId = Number(process.env.CART_ID)) {
    return await selectCartReader('active')(cartId);
}
module.exports = { fetchActiveCartItems };
```

The rest of the row:

```json
{
  "snippet_slug": "query-the-relational-database-to-fetch-active-cart-line-items-and-join-product-variant-attributes-js-cfa9c2b0c6f9",
  "task_slug": "query-the-relational-database-to-fetch-active-cart-line-items-and-join-product-variant-attributes",
  "domain": "shopping-cart",
  "context": "database-access",
  "description": "Query the relational database to fetch active cart line items and join product variant attributes",
  "lang": "js",
  "line_count": 14,
  "unclear_naming": false,
  "noise_comments": false,
  "dead_code": false,
  "inconsistent_style": false,
  "over_abstracted": true,
  "too_clever": false,
  "duplicated_logic": false,
  "error_handling_problem": false,
  "type_safety_hole": false,
  "unsafe_input": true,
  "primary_flaw": "over_abstracted",
  "quality": 3,
  "difficulty": "subtle",
  "uncertain_flags": [],
  "findings": [
    {
      "finding_slug": "over-abstracted-cfa9c2b0c6f9-l2-l12-8521f090",
      "flag": "over_abstracted",
      "start_line": 2,
      "end_line": 12,
      "excerpt": "const cartReaders = {",
      "explanation": "The reader registry and mode selector implement only one strategy, and the sole call always selects 'active', so put the query directly in fetchActiveCartItems rather than routing through a single-case dispatch layer.",
      "audit_verdict": "valid"
    },
    {
      "finding_slug": "unsafe-input-cfa9c2b0c6f9-l11-l11-789284ad",
      "flag": "unsafe_input",
      "start_line": 11,
      "end_line": 11,
      "excerpt": "async function fetchActiveCartItems(cartId = Number(process.env.CART_ID)) {",
      "explanation": "The environment-derived cart ID reaches the database query after numeric conversion alone, which does not validate an identifier and can produce NaN or turn empty input into zero.",
      "audit_verdict": "valid"
    }
  ]
}
```

## Load the dataset

Two configs hold the same 12,000 snippets. `default` is the flat snippet table with line-level findings. `decisions` is the same data as typed decisions: one row per snippet with a `state`, 13 typed `questions`, and the `gold` answers.

```python
from datasets import load_dataset
import json

snippets = load_dataset("yannelli/js-ts-code-review-decisions", "default")
example = snippets["train"][0]
print(example["code"])
print(example["findings"])

decisions = load_dataset("yannelli/js-ts-code-review-decisions", "decisions", split="test")
row = decisions[0]
state, questions, gold = (json.loads(row[k]) for k in ("state", "questions", "gold"))
print(gold["dead_code"]["noul"], gold["primary_flaw"]["label"], gold["quality"]["score"])
```

Both configs have `train`, `validation`, and `test` splits stored as Parquet files. A local copy loads the same way when you pass its folder path to `load_dataset`.

## Decisions config

The schema follows the System One primitives (`noul`, `choice`, `score`) of the [TypeSafe API](https://docs.typesafe.ai/api), so a row replays against any API with that shape. `state` and `questions` together are the body of a `POST /v1/systemone` request, minus `model`. The dataset is independent of TypeSafe.

`state` is a JSON object with `task` (the one-sentence task description), `language`, and `code`. `questions` is a JSON map of 13 questions, identical for every row and listed in `manifest.json`:

- **The 10 flaw questions** (`noul`): Does this code have this flaw? Each question is named after its flag, and its criteria carry the flaw definition.
- **`has_flaw`** (`noul`): Does this code have at least one code review flaw?
- **`primary_flaw`** (`choice`): Which problem matters most? 11 options: `none` plus the 10 flaws.
- **`quality`** (`score`): How mergeable is this code? 5 levels, from "Should not merge." to "Exemplary. Merge as is."

`gold` stores one answer per question: `noul` for yes/no questions, `label` plus one-hot `probabilities` for choice and score, and `score` for the score question. Score levels are indexed from 0, so level `i` is `quality` `i + 1` in the `default` config. Flat `<question>__label`, `<question>__probability_true`, `<question>__probabilities`, and `quality__score` columns repeat the same answers for convenience.

Each gold answer is a hard label encoded as a one-hot distribution. One blind model reviewer set each label, and a second model audited every finding. `task_slug`, `lang`, `difficulty`, and `uncertain_flags` are metadata, not model input.

To replay a case against a System One API and keep its answers in the scorer's format:

```python
import json, time, requests

body = {"state": state, "questions": questions, "model": "jev-latest"}
started = time.perf_counter()
answers = requests.post("https://api.typesafe.ai/v1/systemone", json=body, headers=headers).json()["answers"]
line = {"id": row["id"], "answers": answers, "latency_ms": 1000 * (time.perf_counter() - started)}
print(json.dumps(line))
```

Write one such line per test case to a JSONL file and score it with `python3 score_decisions.py FILE.jsonl` from this folder, as described under [Leaderboard](#leaderboard).

## Train and evaluate

Use `code` as input and the 10 flaw labels as independent binary targets. Include `description` if the model needs to know the task's intended behavior. Several labels can be true for the same snippet.

A snippet is the training example. Its findings identify individual flaws, with line ranges and explanations. They support label inspection and training for flaw localization. Clean snippets have an empty findings list and all 10 labels set to false.

Keep the labels, `findings`, `primary_flaw`, `quality`, `difficulty`, and `uncertain_flags` out of the input. They reveal the answers: every snippet with `quality` 5 is a clean variant. Report macro F1 over the 10 flags at a 0.5 cutoff as the primary score, then per-flag F1, false positives on clean code, and inference latency on the test split. A threshold for each flag can be tuned on the validation split. To get a [leaderboard](#leaderboard) row, answer the `decisions` config instead and run `score_decisions.py`.

### Flag baseline

The flag baseline uses the same multi-label metrics: macro F1 with each flag's probability cut at 0.5 is the primary score, with macro F1 at thresholds tuned on validation, threshold-free AUROC and AUPRC, and calibration (Brier score and ECE over 15 equal-width bins). Intervals are 95% bootstrap intervals from 500 resamples of test tasks, with a task's 4 variants resampled together.

The baseline uses TF-IDF over code tokens and one logistic regression per flag, with `code` as the only input:

- Tokens: identifiers and single punctuation characters, as unigrams and bigrams (`min_df=2`, sublinear term frequency, case kept).
- Model: scikit-learn 1.9.1 `LogisticRegression` (`C=4`, balanced class weights, liblinear, `random_state=0`), trained on `train`.
- Tuned thresholds: for each flag, the validation threshold with the best F1, applied unchanged to test.

Test results:

| Score | Value | 95% interval |
|---|---:|---:|
| Macro F1 @ 0.5 | 0.574 | 0.554–0.595 |
| Macro F1, tuned | 0.583 | 0.562–0.602 |
| Micro F1 @ 0.5 | 0.563 | 0.542–0.586 |
| Macro AUROC | 0.848 | 0.837–0.860 |
| Macro AUPRC | 0.635 | 0.618–0.659 |

#### Per-flag F1

F1 @ 0.5 uses a fixed cutoff; tuned F1 uses per-flag validation thresholds. Short names map to the [flaw definitions](#flaw-definitions). Test-positive counts are listed under [Label statistics](#label-statistics).

| Flag | F1 @ 0.5 | Tuned F1 |
|---|---:|---:|
| Naming | 0.848 | 0.854 |
| Comments | 0.920 | 0.930 |
| Dead code | 0.419 | 0.422 |
| Style | 0.418 | 0.425 |
| Abstraction | 0.524 | 0.532 |
| Clever code | 0.590 | 0.606 |
| Duplication | 0.302 | 0.348 |
| Errors | 0.694 | 0.696 |
| Types | 0.521 | 0.519 |
| Input | 0.500 | 0.496 |

#### Ranking

| Flag | AUROC | AUPRC |
|---|---:|---:|
| Naming | 0.969 | 0.912 |
| Comments | 0.997 | 0.979 |
| Dead code | 0.702 | 0.469 |
| Style | 0.793 | 0.480 |
| Abstraction | 0.868 | 0.550 |
| Clever code | 0.880 | 0.655 |
| Duplication | 0.706 | 0.337 |
| Errors | 0.937 | 0.808 |
| Types | 0.811 | 0.588 |
| Input | 0.818 | 0.569 |

#### Calibration

| Flag | Brier | ECE |
|---|---:|---:|
| Naming | 0.036 | 0.089 |
| Comments | 0.027 | 0.097 |
| Dead code | 0.169 | 0.181 |
| Style | 0.140 | 0.217 |
| Abstraction | 0.107 | 0.157 |
| Clever code | 0.096 | 0.136 |
| Duplication | 0.130 | 0.118 |
| Errors | 0.072 | 0.148 |
| Types | 0.104 | 0.159 |
| Input | 0.117 | 0.141 |

Mean Brier score is 0.100 and mean ECE is 0.144. The balanced class weights push probabilities up for rare flags, which shows in the ECE. At the 0.5 cutoff the baseline flags at least one problem on 178 of the 300 clean test snippets, and on 197 at the tuned thresholds. Naming and comment flags score highest; duplicated logic, dead code, and inconsistent style score lowest.

The leaderboard's TF-IDF row uses the same tokens with one unweighted regression per question and C chosen by validation log loss. That trade is visible in the two sets of numbers: the balanced weights here score 0.574 macro F1 at 0.5 with an ECE of 0.144, while the unweighted row scores 0.502 with an ECE of 0.030, because an unweighted model rarely crosses 0.5 on flags that are true in 11% to 20% of snippets.

## Splits

`Val` denotes the `validation` split in the tables below.

| Count | Train | Val | Test |
|---|---:|---:|---:|
| Snippets | 9,600 | 1,200 | 1,200 |
| Tasks | 2,400 | 300 | 300 |
| Clean | 2,400 | 300 | 300 |
| Findings | 22,005 | 2,746 | 2,699 |

All 4 variants of a task share a `task_slug` and stay in the same split. The supplied splits assign 80% of tasks to training, 10% to validation, and 10% to testing. Keep these splits when training; splitting individual variants can put versions of the same task in both training and evaluation. Packaging refuses to build if a task appears in two splits, if any code value repeats, or if a task does not have 4 variants with exactly one clean.

The snippets cover 40 domains and 13 code contexts. Languages: 4,559 JavaScript, 516 JSX, 6,209 TypeScript, and 716 TSX snippets. `manifest.json` lists the SHA-256 and row count of every data file to identify the dataset version used in an evaluation.

### Label statistics

Positive snippets per flag and split:

| Flag | Train | Val | Test |
|---|---:|---:|---:|
| Naming | 1,140 | 135 | 139 |
| Comments | 1,382 | 183 | 178 |
| Dead code | 1,882 | 235 | 223 |
| Style | 1,146 | 144 | 147 |
| Abstraction | 1,061 | 131 | 145 |
| Clever code | 1,313 | 145 | 164 |
| Duplication | 1,422 | 164 | 171 |
| Errors | 1,182 | 150 | 140 |
| Types | 1,165 | 134 | 148 |
| Input | 1,290 | 167 | 165 |

Test has 139 to 223 positives per flag, so one snippet moves a flag's test recall by less than 1 percentage point.

Flags per flawed snippet:

| Flags | Snippets |
|---:|---:|
| 1 | 3,996 |
| 2 | 3,438 |
| 3 | 1,089 |
| 4 | 347 |
| 5 | 116 |
| 6 | 14 |

Quality scores:

| Quality | Snippets | Clean |
|---:|---:|---:|
| 1 | 1,250 | 0 |
| 2 | 3,118 | 0 |
| 3 | 3,612 | 0 |
| 4 | 1,100 | 80 |
| 5 | 2,920 | 2,920 |

Difficulty: 3,652 obvious, 7,422 subtle, and 926 borderline snippets.

Class declarations appear in 28.8% of `over_abstracted` snippets, 29.4% of other flawed snippets, and 27.2% of clean snippets.

## Fields

### `default` config

- `snippet_slug` (`string`): Unique snippet identifier: task slug, language, and a code hash suffix.
- `task_slug` (`string`): Descriptive task name shared by its 4 variants. Use for grouping, not as model input.
- `domain` (`string`): Business domain of the task.
- `context` (`string`): Code context of the task, such as `http-handler` or `react-hook`.
- `description` (`string`): One-sentence task description all 4 variants implement.
- `lang` (`string`): `js`, `jsx`, `ts`, or `tsx`.
- `code` (`string`): Source code. Lines are split on `\n`.
- `line_count` (`int64`): `len(code.split("\n"))`.
- `unclear_naming` (`bool`): True when the snippet has an `unclear_naming` finding.
- `noise_comments` (`bool`): True when the snippet has a `noise_comments` finding.
- `dead_code` (`bool`): True when the snippet has a `dead_code` finding.
- `inconsistent_style` (`bool`): True when the snippet has an `inconsistent_style` finding.
- `over_abstracted` (`bool`): True when the snippet has an `over_abstracted` finding.
- `too_clever` (`bool`): True when the snippet has a `too_clever` finding.
- `duplicated_logic` (`bool`): True when the snippet has a `duplicated_logic` finding.
- `error_handling_problem` (`bool`): True when the snippet has an `error_handling_problem` finding.
- `type_safety_hole` (`bool`): True when the snippet has a `type_safety_hole` finding.
- `unsafe_input` (`bool`): True when the snippet has an `unsafe_input` finding.
- `primary_flaw` (`string`): The most important flag, or `none` for the clean variant.
- `quality` (`int64`): Mergeability from 1 (should not merge) to 5 (exemplary).
- `difficulty` (`string`): `obvious`, `subtle`, or `borderline`, defined below.
- `uncertain_flags` (`list<string>`): Flags with a defensible competing interpretation. Can name a flag that is false. Empty for most snippets.
- `findings` (`list<struct>`): Line-level annotations, using the nested fields below. Empty for clean snippets.

Each item in `findings` has these fields:

- `finding_slug` (`string`): Unique finding identifier: flag name, snippet code hash, line range, and explanation hash.
- `flag` (`string`): One of the 10 flag names.
- `start_line` (`int64`): First line of the flaw, 1-indexed.
- `end_line` (`int64`): Last line of the flaw, 1-indexed and at least `start_line`.
- `excerpt` (`string`): Exact text of `start_line`, including indentation.
- `explanation` (`string`): One sentence explaining the flaw.
- `audit_verdict` (`string`): Audit result: `valid`, `invalid`, `wrong_flag`, or `wrong_lines`.

Line numbers start at 1 and include both endpoints. A flag is true exactly when at least one finding uses that flag.

Difficulty describes how hard the snippet is to judge. `obvious` means a quick scan is enough; `subtle` requires closer inspection; `borderline` means a reviewer could defend a different answer under a plausible reading of a flag definition. Borderline snippets have at least one entry in `uncertain_flags`.

### `decisions` config

- `id` (`string`): The snippet's `snippet_slug`.
- `task_slug` (`string`): Task shared by the 4 variants; the bootstrap unit. Not model input.
- `split` (`string`): `train`, `validation`, or `test`.
- `lang` (`string`): `js`, `jsx`, `ts`, or `tsx`.
- `difficulty` (`string`): As in `default`.
- `uncertain_flags` (`list<string>`): As in `default`.
- `state` (`string`): JSON object with `task`, `language`, and `code`.
- `questions` (`string`): JSON map of the 13 questions, identical for every row.
- `gold` (`string`): JSON map of the gold answers, one per question, in the API answer shape.
- `n_questions` (`int64`): 13.
- `<noul>__label` (`string`): `true` or `false`, for the 10 flaws and `has_flaw`.
- `<noul>__probability_true` (`float64`): 1.0 or 0.0.
- `primary_flaw__label` (`string`): `none` or a flaw name.
- `primary_flaw__probabilities` (`string`): JSON one-hot over the 11 options.
- `quality__label` (`string`): Level index `0` to `4`.
- `quality__probabilities` (`string`): JSON one-hot over the 5 levels.
- `quality__score` (`float64`): The level index as a number.

## Files

- `data/`: `train.parquet`, `validation.parquet`, and `test.parquet` contain the `default` config: snippets, labels, and findings.
- `decisions/`: the same three split filenames contain the `decisions` config: state, questions, and gold.
- `manifest.json`: SHA-256 and row count of every data file, and the 13 questions.
- `eval.yaml`: The leaderboard metrics, config, and split.
- `score_decisions.py`: Scores an answers file on a split; also prints the Prior and Uniform rows.
- `baseline_decisions.py`: Fits and writes the TF-IDF leaderboard row.
- `baselines/`: `tfidf-logreg.test.jsonl` contains that row's test answers, so the row can be rescored.
- `LICENSE`: CC BY 4.0.

## Creation and validation

Language models generated the snippets against a fixed set of tasks and flaw definitions, in three rounds of 1,000 tasks. Model reviewers read the code without seeing the planned labels, recorded findings, and sent failed examples back for repair and another review.

In the second and third rounds, the writer and reviewer were different models, and each flawed variant is a small edit of its task's clean variant, so the planted flaws are the main difference between them. Each of those tasks was also planned around either classes or plain functions, so that declaring a class is about as common with `over_abstracted` as without it. These rounds also plan `dead_code` and `duplicated_logic` more often. The third round used a writer model from a different developer than the first two.

Validation checked JavaScript/TypeScript syntax, unique code, task grouping, field types, label/finding agreement, and finding locations and excerpts. All 12,000 snippets passed those checks.

A separate model audited all 27,450 findings, and `audit_verdict` records its result.

The `noise_comments` rule changed after the first round: comments that explained why used to be exempt. First-round snippets were brought under the current rule. A model added 349 comment findings to 220 flawed snippets (120 of which had no `noise_comments` label before), and comments were removed from 84 clean snippets so they stay clean. The audit accepted all 349 added findings.

For the first-round tasks, a language model later edited task descriptions and finding explanations for clarity. That edit did not change code, labels, line ranges, or excerpts.

## Annotation audit

Labels follow the supplied flaw definitions. `uncertain_flags` records disputed cases.

The audit accepted 26,984 findings (98.30%) and challenged 466: 455 invalid, 6 wrong flag, and 5 wrong line range. Challenged findings remain in the labels; 185 invalid verdicts concern `unclear_naming`, and 166 positive flag labels rely entirely on challenged findings. Use `audit_verdict` to select an annotation subset.

The audit proposed 284 additional findings, which are excluded from the released labels. All but one concern snippets already labeled as flawed. The remaining proposal concerns a rejection handler that prints the error and sets exit code 1; its clean label was retained.

## Limitations

`noise_comments` follows a deterministic rule: any comment other than a tool directive or commented-out code sets the flag. A comment detector can classify this label.

Later rounds have fewer borderline snippets: 600 in the first round, 244 in the second, and 82 in the third.

Validation covers syntax and annotation consistency, not execution or type-checking.

Class balance is fixed at 25% clean snippets rather than sampled from production code. Evaluate false positives on code from the deployment environment.

Near-duplicate detection across tasks and public-benchmark overlap checks were not performed.

### Privacy

The snippets contain synthetic names and records. A regex scan of all code, descriptions and explanations found 234 email-like strings (35 distinct, on 11 domains, mostly `acme.test`, `example.com` and `client.test`) and 32 IPv4 addresses: the loopback address `127.0.0.1` and addresses in the `198.51.100.0/24` and `203.0.113.0/24` documentation ranges. It found no matches for the phone-number, API-key, access-token, or private-key patterns checked. Privacy screening used these regex checks only.

## License and attribution

This dataset is licensed under [Creative Commons Attribution 4.0 International (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/). You can copy, share, and adapt it, including commercially. When sharing it or an adaptation, credit Ryan Yannelli, link to the license, and indicate any changes. The full terms are in [LICENSE](LICENSE).

Suggested attribution: Ryan Yannelli (2026), *JS/TS Code Review Decisions*, CC BY 4.0.

## Citation

```bibtex
@misc{yannelli2026jstscodereviewdecisions,
  title        = {JS/TS Code Review Decisions},
  author       = {Ryan Yannelli},
  year         = {2026},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/datasets/yannelli/js-ts-code-review-decisions}}
}
```

## Maintainer

[Ryan Yannelli](https://ryanyannelli.com) | 10/11/2026 | [GitHub: @yannelli](https://github.com/yannelli) | [Hugging Face: yannelli](https://huggingface.co/yannelli)

## Appendix: slug format

`task_slug` comes from the task description: Unicode NFKD normalization, ASCII conversion, lowercase letters, and hyphens between runs of letters or digits. It has no leading or trailing hyphen.

`snippet_slug` appends the language and the first 12 hexadecimal characters of the code's SHA-256 hash to the task slug, separated by hyphens. `finding_slug` combines the hyphenated flag name, that code hash, `l<start_line>-l<end_line>`, and the first 8 hexadecimal characters of the explanation's SHA-256 hash. Hashes use UTF-8 text.

The hash suffixes distinguish variants and separate findings on the same lines. Slugs depend on their source text and change when that text changes. All slug fields are metadata; exclude them from model inputs.