Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Languages:
English
Size:
10K - 100K
ArXiv:
License:
| #!/usr/bin/env python3 | |
| """Validate JL-AgentBehavior-10K without third-party dependencies.""" | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| from collections import Counter | |
| from pathlib import Path | |
| from typing import Any, Iterable | |
| EXPECTED_SPLITS = {"train": 9000, "validation": 500, "test": 500} | |
| EXPECTED_RECORD_TYPES = {"trajectory": 7000, "preference": 2000, "repair": 1000} | |
| EXPECTED_BEHAVIORS = { | |
| "repository_grounding": 1500, | |
| "planning_decomposition": 1200, | |
| "tool_selection_execution": 1500, | |
| "bounded_code_editing": 2000, | |
| "test_verification": 1200, | |
| "failure_diagnosis_repair": 1200, | |
| "code_review_security": 800, | |
| "permission_scope_safety": 400, | |
| "final_reporting": 200, | |
| } | |
| EXPECTED_LANGUAGES = { | |
| "python": 2500, | |
| "typescript": 2500, | |
| "php": 1500, | |
| "java": 1500, | |
| "go": 1000, | |
| "rust": 400, | |
| "csharp": 300, | |
| "cpp": 300, | |
| } | |
| REQUIRED = { | |
| "id", "version", "split", "record_type", "primary_behavior", "secondary_behaviors", | |
| "language", "ecosystem", "task_type", "difficulty", "task", "environment", | |
| "behavioral_labels", "provenance", "quality", "supervision", "fingerprint", | |
| } | |
| def canonical_json(value: Any) -> str: | |
| return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")) | |
| def expected_fingerprint(record: dict[str, Any]) -> str: | |
| clean = dict(record) | |
| clean.pop("fingerprint", None) | |
| return hashlib.sha256(canonical_json(clean).encode("utf-8")).hexdigest() | |
| def read_records(root: Path) -> Iterable[tuple[str, int, dict[str, Any]]]: | |
| for split in EXPECTED_SPLITS: | |
| path = root / "data" / f"{split}.jsonl" | |
| with path.open("r", encoding="utf-8") as handle: | |
| for line_number, line in enumerate(handle, 1): | |
| if line.strip(): | |
| yield split, line_number, json.loads(line) | |
| def validate(root: Path) -> dict[str, Any]: | |
| errors: list[str] = [] | |
| records: list[dict[str, Any]] = [] | |
| ids: set[str] = set() | |
| fingerprints: set[str] = set() | |
| instructions: set[str] = set() | |
| split_repositories: dict[str, set[str]] = {split: set() for split in EXPECTED_SPLITS} | |
| for file_split, line_number, record in read_records(root): | |
| location = f"data/{file_split}.jsonl:{line_number}" | |
| records.append(record) | |
| missing = REQUIRED - record.keys() | |
| if missing: | |
| errors.append(f"{location}: missing fields {sorted(missing)}") | |
| continue | |
| if record["split"] != file_split: | |
| errors.append(f"{location}: split field does not match file") | |
| if record["id"] in ids: | |
| errors.append(f"{location}: duplicate id {record['id']}") | |
| ids.add(record["id"]) | |
| if record["fingerprint"] in fingerprints: | |
| errors.append(f"{location}: duplicate fingerprint {record['fingerprint']}") | |
| fingerprints.add(record["fingerprint"]) | |
| instruction = record["task"].get("instruction") | |
| if instruction in instructions: | |
| errors.append(f"{location}: duplicate task instruction") | |
| instructions.add(instruction) | |
| if record["fingerprint"] != expected_fingerprint(record): | |
| errors.append(f"{location}: fingerprint mismatch") | |
| if record["provenance"].get("execution_verified") is not False: | |
| errors.append(f"{location}: v1 synthetic record must not claim execution verification") | |
| if record["quality"].get("quality_tier") != "silver_structural": | |
| errors.append(f"{location}: unexpected quality tier") | |
| repo = record["environment"].get("repository_id") | |
| if not repo: | |
| errors.append(f"{location}: missing repository_id") | |
| else: | |
| split_repositories[file_split].add(repo) | |
| counters = { | |
| "split": Counter(record["split"] for record in records), | |
| "record_type": Counter(record["record_type"] for record in records), | |
| "primary_behavior": Counter(record["primary_behavior"] for record in records), | |
| "language": Counter(record["language"] for record in records), | |
| } | |
| expected = { | |
| "split": Counter(EXPECTED_SPLITS), | |
| "record_type": Counter(EXPECTED_RECORD_TYPES), | |
| "primary_behavior": Counter(EXPECTED_BEHAVIORS), | |
| "language": Counter(EXPECTED_LANGUAGES), | |
| } | |
| for name in counters: | |
| if counters[name] != expected[name]: | |
| errors.append(f"{name} distribution mismatch: {dict(counters[name])}") | |
| split_names = list(EXPECTED_SPLITS) | |
| for i, left in enumerate(split_names): | |
| for right in split_names[i + 1:]: | |
| overlap = split_repositories[left] & split_repositories[right] | |
| if overlap: | |
| errors.append(f"repository leakage between {left} and {right}: {sorted(overlap)[:5]}") | |
| return { | |
| "dataset": "JL-AgentBehavior-10K", | |
| "version": "1.0.0", | |
| "status": "passed" if not errors else "failed", | |
| "records_checked": len(records), | |
| "unique_ids": len(ids), | |
| "unique_fingerprints": len(fingerprints), | |
| "unique_instructions": len(instructions), | |
| "repository_family_overlap": False if not any("repository leakage" in e for e in errors) else True, | |
| "execution_verified_records": sum(r["provenance"]["execution_verified"] for r in records), | |
| "errors": errors, | |
| "counts": {name: dict(sorted(counter.items())) for name, counter in counters.items()}, | |
| } | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1]) | |
| parser.add_argument("--report", type=Path) | |
| args = parser.parse_args() | |
| report = validate(args.root.resolve()) | |
| rendered = json.dumps(report, indent=2, ensure_ascii=False) + "\n" | |
| if args.report: | |
| args.report.write_text(rendered, encoding="utf-8") | |
| print(rendered, end="") | |
| raise SystemExit(0 if report["status"] == "passed" else 1) | |
| if __name__ == "__main__": | |
| main() | |