TS-PRGuard / README.md
Lukitaduarte's picture
TS-PRGuard: labeled code changes for pull request review
75d67e0 verified
|
Raw History Blame Contribute Delete
52.6 kB
metadata
license: cc-by-4.0
language:
  - en
pretty_name: TS-PRGuard
size_categories:
  - 10K<n<100K
task_categories:
  - text-classification
tags:
  - typestrict
  - code
  - code-review
  - pull-requests
  - security
  - cwe
  - breaking-changes
  - git
configs:
  - config_name: description_match
    data_files:
      - split: train
        path: description_match/train.jsonl.gz
      - split: test
        path: description_match/test.jsonl.gz
  - config_name: complexity
    data_files:
      - split: train
        path: complexity/train.jsonl.gz
      - split: test
        path: complexity/test.jsonl.gz
  - config_name: change_type
    data_files:
      - split: train
        path: change_type/train.jsonl.gz
      - split: test
        path: change_type/test.jsonl.gz
  - config_name: breaking
    data_files:
      - split: train
        path: breaking/train.jsonl.gz
      - split: test
        path: breaking/test.jsonl.gz
  - config_name: breaking_api
    data_files:
      - split: train
        path: breaking_api/train.jsonl.gz
      - split: test
        path: breaking_api/test.jsonl.gz
  - config_name: tests
    data_files:
      - split: train
        path: tests/train.jsonl.gz
      - split: test
        path: tests/test.jsonl.gz
  - config_name: security_fix
    data_files:
      - split: train
        path: security_fix/train.jsonl.gz
      - split: test
        path: security_fix/test.jsonl.gz
  - config_name: security_fix_mobile
    data_files:
      - split: test
        path: security_fix_mobile/test.jsonl.gz
  - config_name: security_synthetic
    data_files:
      - split: train
        path: security_synthetic/train.jsonl.gz
      - split: test
        path: security_synthetic/test.jsonl.gz

TS-PRGuard by typestrict.ai

Train your own on typestrict.ai | Docs | CLI | All TS models
License: CC BY 4.0 for the labels, each row's code under its repository's license | Authors: typestrict.ai

TS-PRGuard

37,048 labeled code changes for pull request review, in 11 programming languages and 9 configs. Each row is a real diff from a permissively licensed repository with one answer: does the message describe the change, how big is it, what kind of change is it, does it break compatibility, do the tests cover it, does it fix a vulnerability (and which CWE).

We built it to train the PR Guard decision models on typestrict.ai, and we publish it because the open data for these questions was either non-commercial, noisy, or missing the languages of mobile apps.

  • Commercial use: every source and every repository allows it. Non-commercial and research-only sources were left out, without exception.
  • Measured labels: an independent review of 300 fresh rows found 297 correct (upper 95% bound on the error of about 2.4%). Every config has its own check, listed below.
  • No easy shortcuts: the hints that give the answer away were removed from the text (details in Leakage).
  • Mobile included: Kotlin, Swift and Dart in every question, with a public API rule for breaking changes and a checked synthetic set for vulnerabilities.

Examples per task and language

🧭 Configs

ConfigQuestionLabelsTrainTest
description_matchDoes the commit message describe this diff?matches, does_not_match5,723682
complexityHow large and spread out is the change?bands 0 to 46,056673
change_typeWhat kind of change is it?feat, fix, refactor, perf, test, build, chore, style, docs, ci2,961330
breakingDoes the pull request break compatibility?breaking, not_breaking5,337594
breaking_apiDoes the commit break the public API of a Kotlin, Swift or Dart library?breaking, not_breaking2,950335
testsDo the tests in the change cover it?covered, not_covered, not_applicable5,927709
security_fixWhich vulnerability does this commit fix?first CWE id, or unspecified3,267363
security_fix_mobileSame, real fixes in Kotlin, Swift and Dart (test only)CWE id067
security_syntheticDoes this change introduce a vulnerability?introduces, safe (537 pairs)960114

In the security configs label is the first CWE and cwe holds all of them; 175 rows of security_fix are confirmed fixes whose advisory names no specific CWE (unspecified). In security_synthetic, cwe is the flaw of the pair, in both halves.

from datasets import load_dataset

ds = load_dataset("typestrict/TS-PRGuard", "tests")
row = ds["train"][0]
print(row["label"], row["language"], row["repo"])
print(row["diff"][:500])

Splits

The test split holds about 10% of the rows of each config, chosen by whole repository: no repository has rows in both splits of a config, so a model cannot pass the test by remembering a codebase. The two halves of a synthetic pair are always on the same side. security_fix_mobile is test only, and so are the 73 Kotlin, Swift and Dart rows of security_fix: real vulnerability fixes in these languages are rare, so they measure the models trained on security_synthetic instead of feeding them.

🗂️ Fields

FieldTypeMeaning
idstringStable row id
configstringOne of the configs above
labelstringThe answer (see the table above)
languagestringMain language of the change
repostringowner/name on GitHub
licensestringSPDX id of the repository's license
sourcestringWhere the row comes from (see Sources)
refstringCommit SHA, pull request number, or SWE-rebench instance id
messagestringCommit message or pull request text, with the leaks removed
fileslist of stringsChanged files
n_filesintNumber of changed files
diffstringUnified diff, code files first, cut at 5,000 characters
cwelist of stringsCWE ids (security configs only)
cvestringCVE id when there is one (security_fix)
advisorystringAdvisory title, kept out of message (security_fix)
pair_id, versionstringThe two halves of a synthetic pair: vulnerable and safe (security_synthetic)

🏗️ How it was built

  1. Mining. Commits from the git histories of permissively licensed repositories (including 27 security focused Kotlin, Swift and Dart projects), CommitPack, pull requests labeled as breaking, the GitHub Advisory Database, MoreFixes, and SWE-rebench-V2.
  2. Rules. Each question has deterministic rules: only repositories with a known permissive license, no generated or vendored files, the complexity band computed on the full diff before the cut, a public API comparison over the whole diff for breaking_api (default parameters and moved code do not count; apps, examples, generated code and internal packages are excluded).
  3. Independent checks. Every row was checked by a decision model. change_type, security_fix, security_fix_mobile, the breaking side of breaking_api and security_synthetic also went through a second, independent LLM classifier. A row stays only when every check agrees with the label.
  4. Review. Fresh samples of every config were reviewed independently after the filters, and the rules were changed until the error was low (the results are below).

tests

covered and not_covered come from execution: SWE-rebench-V2 runs the tests of each change, and a change is covered when its FAIL_TO_PASS tests are part of it. not_applicable rows are changes that do not ask for a test (docs, configuration, formatting), selected by rules and checked.

security_synthetic

Real vulnerability fixes in Kotlin, Swift and Dart are too few to train on. Each pair takes a real commit with no security relevance and adds, in the same code, one flaw from a catalog of CWEs (vulnerable) and the safe version of the same lines (safe). The rows were written by an LLM and kept only when:

  • a blind check, which did not know which half it was reading, found the flaw with the right CWE in the vulnerable half and nothing in the safe half;
  • a decision model confirmed that something is really at stake (a test file or unused data does not count).

CWE-208 (timing) and CWE-601 (open redirect) were removed after the final review: on the client side the generator got them wrong most of the time. The 10 CWEs left are 532, 798, 295, 22, 330, 319, 89, 922, 327 and 749. The real fixes of security_fix_mobile are the test that tells whether a model learned the flaw or the style of the generator.

📏 Label quality

Every check below was made on rows the filters had already accepted, by a reviewer that did not take part in the labeling.

ConfigCheckResult
The six main questions300 fresh rows, 50 per question297 correct, 2 wrong, 1 unsure
breaking_api50 fresh rows49 correct
security_fix_mobile50 rows48 correct
security_synthetic52 pairs50 correct, 1 wrong, 1 unsure

The known wrong rows: a feature commit linked to a CVE, a test in a testdata/ folder outside the usual pattern, and a breaking change in an internal package of the Dart SDK.

🧹 Leakage we removed

  • change_type: the conventional commit prefix (feat:, fix(api):) is removed from the message.
  • breaking: every form of "break" ("breaking change", "[breaking]", "BC break", "non-breaking") and "major version" is masked as [...] in the pull request text, on both labels, so the mask itself gives nothing away.
  • security_fix: the advisory text and the CVE are in their own fields, never in message.
  • description_match: the negative message is a specific message from another commit of the same repository with no file in common, so the repository's vocabulary does not give the answer.
  • security_synthetic: both halves come from the same commit and differ only in the changed lines; the blind check found no style that gives the half away.
  • diff: code files come first and the cut is at 5,000 characters; the complexity band is computed before the cut.

📚 Sources

SourceLicenseConfigs
Git histories of permissive repositoriesEach repository's licensedescription_match, complexity, breaking_api, tests, security_fix_mobile, security_synthetic
bigcode/commitpackMIT (code under each repository's license)description_match, complexity, change_type, breaking_api
Pull requests labeled as breaking on GitHubEach repository's licensebreaking
Flutter pull requests labeled c: API breakBSD-3-Clausebreaking_api
nebius/SWE-rebench-V2CC BY 4.0tests
GitHub Advisory DatabaseCC BY 4.0security_fix
MoreFixesCC BY 4.0security_fix

Repository licenses in the rows: MIT (17,854), Apache-2.0 (10,712), BSD-3-Clause (7,988), BSD-2-Clause (207), ISC (169), Unlicense (56), CC0-1.0 (31), MIT-0 (22), Zlib (4), UPL-1.0 (3), PostgreSQL (1), 0BSD (1). Every row keeps repo, ref and license, so you can trace any diff to its origin and keep its notice.

⚠️ Limitations

  • Diffs are cut at 5,000 characters, so a very large change is seen only in part.
  • breaking follows the maintainers' own label, which is not always applied the same way across projects.
  • security_fix has fixes only: read in reverse, the same diff introduces the flaw, which is how we use it for the "introduces" side.
  • description_match has no PHP and change_type has no Java or PHP: the sources had too few clean rows.
  • The natural language text is in English.

🚀 Train your own on typestrict.ai

Train a decision model on your data with typestrict.ai

Every config here is one decision. On typestrict.ai you can train a small model on any of them, or on your own pull requests, and get it measured on examples held out from training. The trained model is a small ONNX package that runs on a CPU, in your CI or on your own servers.

curl -fsSL https://typestrict.ai/install.sh | sh && typestrict login
typestrict train --hf typestrict/TS-PRGuard:tests/train.jsonl.gz,tests/test.jsonl.gz \
  --goal "Do the tests in the change cover it?" --watch

Links

Citation

@misc{typestrict2026prguard,
  author = {{typestrict.ai}},
  title  = {TS-PRGuard: labeled code changes for pull request review},
  year   = {2026},
  url    = {https://huggingface.co/datasets/typestrict/TS-PRGuard}
}