Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Languages:
English
Size:
10K - 100K
ArXiv:
License:
| #!/usr/bin/env python3 | |
| """Generate the deterministic JL-AgentBehavior-10K v1 research-preview corpus.""" | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| import random | |
| import re | |
| from collections import Counter | |
| from pathlib import Path | |
| from typing import Any | |
| SEED = 617_2026 | |
| VERSION = "1.0.0" | |
| TOTAL = 10_000 | |
| BEHAVIOR_QUOTAS = { | |
| "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, | |
| } | |
| RECORD_TYPE_QUOTAS = { | |
| "trajectory": 7000, | |
| "preference": 2000, | |
| "repair": 1000, | |
| } | |
| LANGUAGE_QUOTAS = { | |
| "python": 2500, | |
| "typescript": 2500, | |
| "php": 1500, | |
| "java": 1500, | |
| "go": 1000, | |
| "rust": 400, | |
| "csharp": 300, | |
| "cpp": 300, | |
| } | |
| TASK_QUOTAS = { | |
| "bug_fix": 3000, | |
| "feature_implementation": 2000, | |
| "refactoring": 1500, | |
| "test_generation": 1200, | |
| "code_review": 1000, | |
| "security_fix": 800, | |
| "documentation_configuration": 500, | |
| } | |
| DIFFICULTY_QUOTAS = {"easy": 2500, "medium": 5000, "hard": 2500} | |
| LANGUAGES = { | |
| "python": { | |
| "extension": "py", | |
| "source_root": "src", | |
| "test_root": "tests", | |
| "test_command": "pytest -q {test_file}", | |
| "full_test_command": "pytest -q", | |
| "lint_command": "ruff check .", | |
| "ecosystem": "pytest/ruff", | |
| }, | |
| "typescript": { | |
| "extension": "ts", | |
| "source_root": "src", | |
| "test_root": "test", | |
| "test_command": "npm test -- {test_file}", | |
| "full_test_command": "npm test", | |
| "lint_command": "npm run lint", | |
| "ecosystem": "node/vitest", | |
| }, | |
| "php": { | |
| "extension": "php", | |
| "source_root": "src", | |
| "test_root": "tests", | |
| "test_command": "vendor/bin/phpunit {test_file}", | |
| "full_test_command": "vendor/bin/phpunit", | |
| "lint_command": "vendor/bin/phpstan analyse", | |
| "ecosystem": "composer/phpunit", | |
| }, | |
| "java": { | |
| "extension": "java", | |
| "source_root": "src/main/java", | |
| "test_root": "src/test/java", | |
| "test_command": "./gradlew test --tests {test_symbol}", | |
| "full_test_command": "./gradlew test", | |
| "lint_command": "./gradlew checkstyleMain", | |
| "ecosystem": "gradle/junit", | |
| }, | |
| "go": { | |
| "extension": "go", | |
| "source_root": "internal", | |
| "test_root": "internal", | |
| "test_command": "go test ./{component} -run {test_symbol}", | |
| "full_test_command": "go test ./...", | |
| "lint_command": "golangci-lint run", | |
| "ecosystem": "go test", | |
| }, | |
| "rust": { | |
| "extension": "rs", | |
| "source_root": "src", | |
| "test_root": "tests", | |
| "test_command": "cargo test {test_symbol}", | |
| "full_test_command": "cargo test", | |
| "lint_command": "cargo clippy --all-targets -- -D warnings", | |
| "ecosystem": "cargo", | |
| }, | |
| "csharp": { | |
| "extension": "cs", | |
| "source_root": "src", | |
| "test_root": "tests", | |
| "test_command": "dotnet test --filter {test_symbol}", | |
| "full_test_command": "dotnet test", | |
| "lint_command": "dotnet format --verify-no-changes", | |
| "ecosystem": "dotnet/xunit", | |
| }, | |
| "cpp": { | |
| "extension": "cpp", | |
| "source_root": "src", | |
| "test_root": "tests", | |
| "test_command": "ctest -R {test_symbol} --output-on-failure", | |
| "full_test_command": "ctest --output-on-failure", | |
| "lint_command": "clang-tidy {target_file}", | |
| "ecosystem": "cmake/ctest", | |
| }, | |
| } | |
| DOMAINS = [ | |
| "identity gateway", "dataset pipeline", "code search service", "artifact registry", | |
| "billing worker", "notification router", "feature flag service", "audit log processor", | |
| "developer portal", "package index", "job scheduler", "observability collector", | |
| "configuration service", "repository indexer", "test orchestration service", | |
| "release manager", "knowledge graph API", "session service", "rate-limit gateway", | |
| "webhook dispatcher", "access-control service", "cache coordinator", "CLI backend", | |
| "model evaluation runner", "sandbox controller", | |
| ] | |
| COMPONENTS = [ | |
| "session", "token", "pagination", "cache", "queue", "webhook", "permission", | |
| "configuration", "parser", "serializer", "validator", "retry", "timeout", "search", | |
| "index", "migration", "upload", "download", "audit", "worker", "scheduler", "router", | |
| "metrics", "logging", "sandbox", | |
| ] | |
| ISSUES = [ | |
| ("rejects valid boundary values", "boundary-condition defect"), | |
| ("accepts malformed input after normalization", "validation-order defect"), | |
| ("returns stale state after an update", "cache-invalidation defect"), | |
| ("drops the original error context", "error-propagation defect"), | |
| ("retries a non-idempotent operation", "retry-safety defect"), | |
| ("uses seconds where milliseconds are expected", "unit-conversion defect"), | |
| ("fails when an optional field is absent", "nullability defect"), | |
| ("mutates shared state across requests", "state-isolation defect"), | |
| ("performs authorization after the side effect", "authorization-order defect"), | |
| ("logs a secret-bearing request field", "sensitive-data exposure"), | |
| ("matches identifiers case-insensitively", "identity-comparison defect"), | |
| ("silently truncates an oversized payload", "input-size handling defect"), | |
| ("creates duplicate jobs under concurrent delivery", "idempotency defect"), | |
| ("marks partial work as successful", "false-success defect"), | |
| ("does not preserve the public error contract", "compatibility defect"), | |
| ("loads an unbounded result set", "resource-bounding defect"), | |
| ("uses a broad filesystem permission", "least-privilege defect"), | |
| ("skips cleanup after cancellation", "resource-cleanup defect"), | |
| ("misclassifies transient failures as permanent", "failure-classification defect"), | |
| ("does not verify the persisted state", "verification defect"), | |
| ] | |
| CONSTRAINT_SETS = [ | |
| ["Preserve the public API", "Do not add dependencies", "Limit changes to relevant files"], | |
| ["Keep backward compatibility", "Add or update a targeted test", "Avoid unrelated refactors"], | |
| ["Do not expose secrets in logs", "Preserve existing configuration keys", "Run the narrow test first"], | |
| ["Keep the patch reviewable", "Do not change database schema", "Report any unverified assumption"], | |
| ["Preserve error semantics", "Reuse existing project abstractions", "Verify the final diff"], | |
| ] | |
| REPOSITORY_SHAPES = [ | |
| "layered service", "modular monolith", "event-driven worker", "CLI application", | |
| "HTTP API", "background processor", "library package", "plugin-based service", | |
| ] | |
| TASK_VERBS = { | |
| "bug_fix": "Fix the defect where the {component} {issue} in the {domain}.", | |
| "feature_implementation": "Add guarded support for {feature} in the {component} of the {domain}.", | |
| "refactoring": "Refactor the {component} in the {domain} to remove duplicated {concern} without changing behavior.", | |
| "test_generation": "Add regression coverage for the case where the {component} {issue} in the {domain}.", | |
| "code_review": "Review the proposed {component} change in the {domain} for correctness, scope, and regressions.", | |
| "security_fix": "Harden the {component} in the {domain} against {security_case} while preserving valid behavior.", | |
| "documentation_configuration": "Correct the configuration and operator guidance for {feature} in the {domain}.", | |
| } | |
| FEATURES = [ | |
| "bounded retries", "cursor pagination", "request cancellation", "structured errors", | |
| "idempotency keys", "dry-run mode", "explicit timeouts", "audit metadata", | |
| "input size limits", "graceful shutdown", "per-tenant configuration", "safe fallback behavior", | |
| ] | |
| CONCERNS = [ | |
| "validation logic", "error mapping", "retry decisions", "configuration parsing", | |
| "authorization checks", "serialization logic", "state transitions", "cleanup logic", | |
| ] | |
| SECURITY_CASES = [ | |
| "path traversal", "authorization bypass", "secret leakage", "unsafe deserialization", | |
| "replay attacks", "cross-tenant access", "command injection", "unbounded resource use", | |
| ] | |
| BEHAVIOR_SUMMARIES = { | |
| "repository_grounding": "Ground every decision in repository evidence before editing.", | |
| "planning_decomposition": "Use a bounded, updateable plan proportional to task complexity.", | |
| "tool_selection_execution": "Choose the lowest-cost valid tool and use schema-correct arguments.", | |
| "bounded_code_editing": "Produce the smallest architecture-aligned patch that satisfies the task.", | |
| "test_verification": "Verify the claimed behavior with targeted checks before completion.", | |
| "failure_diagnosis_repair": "Classify failure evidence, revise the hypothesis, and repair without looping.", | |
| "code_review_security": "Report evidence-backed correctness or security findings with calibrated severity.", | |
| "permission_scope_safety": "Respect scope and request approval only for materially risky actions.", | |
| "final_reporting": "Report changed behavior, verification evidence, and remaining uncertainty precisely.", | |
| } | |
| SECONDARY_MAP = { | |
| "repository_grounding": ["tool_selection_execution", "bounded_code_editing"], | |
| "planning_decomposition": ["repository_grounding", "final_reporting"], | |
| "tool_selection_execution": ["repository_grounding", "test_verification"], | |
| "bounded_code_editing": ["repository_grounding", "test_verification"], | |
| "test_verification": ["bounded_code_editing", "final_reporting"], | |
| "failure_diagnosis_repair": ["test_verification", "tool_selection_execution"], | |
| "code_review_security": ["repository_grounding", "permission_scope_safety"], | |
| "permission_scope_safety": ["bounded_code_editing", "final_reporting"], | |
| "final_reporting": ["test_verification", "repository_grounding"], | |
| } | |
| FAILURES = [ | |
| ("targeted_test_failure", "The targeted test exposes a mismatch between the proposed behavior and the acceptance criterion."), | |
| ("compile_failure", "The compiler reports an interface mismatch introduced by the first patch."), | |
| ("lint_failure", "Static analysis finds an unchecked error path in the edited function."), | |
| ("scope_failure", "The diff includes a configuration change outside the requested boundary."), | |
| ("incorrect_assumption", "Repository evidence contradicts the initial assumption about the data representation."), | |
| ("regression_failure", "A related regression test fails after the target behavior is corrected."), | |
| ] | |
| def expand_quota(quotas: dict[str, int], rng: random.Random) -> list[str]: | |
| values: list[str] = [] | |
| for name, count in quotas.items(): | |
| values.extend([name] * count) | |
| assert len(values) == TOTAL | |
| rng.shuffle(values) | |
| return values | |
| def slug(value: str) -> str: | |
| return re.sub(r"[^a-z0-9]+", "_", value.lower()).strip("_") | |
| def symbol(value: str) -> str: | |
| return "".join(part.capitalize() for part in slug(value).split("_")) | |
| def canonical_json(value: Any) -> str: | |
| return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")) | |
| def fingerprint(record: dict[str, Any]) -> str: | |
| clean = dict(record) | |
| clean.pop("fingerprint", None) | |
| return hashlib.sha256(canonical_json(clean).encode("utf-8")).hexdigest() | |
| def render_instruction( | |
| task_type: str, | |
| component: str, | |
| issue: str, | |
| domain: str, | |
| idx: int, | |
| target_symbol: str, | |
| repository_shape: str, | |
| ) -> str: | |
| template = TASK_VERBS[task_type] | |
| task = template.format( | |
| component=component, | |
| issue=issue, | |
| domain=domain, | |
| feature=FEATURES[idx % len(FEATURES)], | |
| concern=CONCERNS[(idx // 3) % len(CONCERNS)], | |
| security_case=SECURITY_CASES[(idx // 7) % len(SECURITY_CASES)], | |
| ) | |
| return ( | |
| f"{task} The affected entry point is {target_symbol}; keep the change aligned " | |
| f"with the existing {repository_shape} boundary." | |
| ) | |
| def make_paths(language: str, component: str, family: int, slot: int) -> dict[str, str]: | |
| spec = LANGUAGES[language] | |
| ext = spec["extension"] | |
| comp = slug(component) | |
| suffix = f"{family:03d}_{slot:02d}" | |
| if language == "java": | |
| target_name = f"{symbol(component)}Service{family:03d}.{ext}" | |
| test_name = f"{symbol(component)}Service{family:03d}Test.{ext}" | |
| elif language == "csharp": | |
| target_name = f"{symbol(component)}Service{family:03d}.{ext}" | |
| test_name = f"{symbol(component)}Service{family:03d}Tests.{ext}" | |
| else: | |
| target_name = f"{comp}_{suffix}.{ext}" | |
| test_name = f"test_{comp}_{suffix}.{ext}" | |
| return { | |
| "target_file": f"{spec['source_root']}/{comp}/{target_name}", | |
| "test_file": f"{spec['test_root']}/{comp}/{test_name}", | |
| "config_file": "config/defaults.yaml", | |
| } | |
| def tool_step(step: int, phase: str, tool: str, arguments: dict[str, Any], expected: str, basis: str) -> dict[str, Any]: | |
| return { | |
| "step": step, | |
| "phase": phase, | |
| "observation": basis, | |
| "action": {"tool": tool, "arguments": arguments}, | |
| "expected_observation": expected, | |
| "decision_basis": basis, | |
| } | |
| def base_sequence( | |
| behavior: str, | |
| target_file: str, | |
| test_file: str, | |
| target_symbol: str, | |
| test_command: str, | |
| full_test_command: str, | |
| lint_command: str, | |
| issue_category: str, | |
| requires_approval: bool, | |
| difficulty: str, | |
| task_type: str, | |
| variation: int, | |
| ) -> list[dict[str, Any]]: | |
| search_query = f"{target_symbol}|{slug(issue_category)}" | |
| grounding = tool_step( | |
| 1, "ground", "search", {"query": search_query, "path": "."}, | |
| f"Locate the implementation and callers associated with {target_symbol}.", | |
| "The task names behavior but repository evidence is required before selecting an edit target.", | |
| ) | |
| read_target = tool_step( | |
| 2, "inspect", "read_file", {"path": target_file, "start_line": 1, "max_lines": 240}, | |
| "Confirm the current control flow, local conventions, and error contract.", | |
| f"Search evidence identifies {target_file} as the narrow implementation boundary.", | |
| ) | |
| read_test = tool_step( | |
| 3, "inspect", "read_file", {"path": test_file, "start_line": 1, "max_lines": 220}, | |
| "Identify existing test style and the nearest regression boundary.", | |
| "The patch should be verified using project-native tests rather than an invented harness.", | |
| ) | |
| plan = tool_step( | |
| 4, "plan", "update_plan", {"steps": ["confirm behavior", "apply bounded patch", "run targeted test", "inspect diff"]}, | |
| "Create a short plan with explicit verification and no unrelated work.", | |
| "The task spans implementation and verification but does not justify an architectural redesign.", | |
| ) | |
| edit = tool_step( | |
| 5, "edit", "apply_patch", {"path": target_file, "strategy": f"correct {issue_category} while preserving the public contract"}, | |
| "Apply a localized change that follows existing abstractions.", | |
| "The implementation boundary and acceptance criterion are now supported by repository evidence.", | |
| ) | |
| test = tool_step( | |
| 6, "verify", "run_tests", {"command": test_command, "scope": "targeted"}, | |
| "Obtain executable evidence for the requested behavior.", | |
| "A successful edit is not established until the narrow regression boundary passes.", | |
| ) | |
| lint = tool_step( | |
| 7, "verify", "run_linter", {"command": lint_command, "scope": "changed_files"}, | |
| "Check static constraints relevant to the modified code.", | |
| "Static validation catches interface and error-handling defects not covered by the targeted test.", | |
| ) | |
| diff = tool_step( | |
| 8, "review", "git_diff", {"paths": [target_file, test_file]}, | |
| "Confirm the final change is bounded and contains no accidental edits.", | |
| "Diff inspection is required before making a completion claim.", | |
| ) | |
| def finalize(sequence: list[dict[str, Any]]) -> list[dict[str, Any]]: | |
| varied = list(sequence) | |
| if variation % 4 == 0: | |
| varied.insert( | |
| 0, | |
| tool_step( | |
| 0, "orient", "list_directory", {"path": str(Path(target_file).parent), "depth": 2}, | |
| "Confirm the local module boundary before searching for implementation details.", | |
| "A bounded directory view reduces path assumptions without reading the full repository.", | |
| ), | |
| ) | |
| if difficulty == "hard": | |
| insert_at = min(3, len(varied)) | |
| varied.insert( | |
| insert_at, | |
| tool_step( | |
| 0, "inspect", "search", {"query": target_symbol, "path": ".", "mode": "callers"}, | |
| "Identify callers and contract-sensitive edges before changing multi-file behavior.", | |
| "Hard tasks require caller evidence to control compatibility risk.", | |
| ), | |
| ) | |
| if task_type in {"security_fix", "code_review"} and variation % 3 == 0: | |
| insert_at = min(4, len(varied)) | |
| varied.insert( | |
| insert_at, | |
| tool_step( | |
| 0, "inspect", "search", {"query": "authorize|permission|sanitize|validate", "path": "."}, | |
| "Locate the nearest trust-boundary implementation and existing guard pattern.", | |
| "Security and review decisions require evidence about authorization and validation order.", | |
| ), | |
| ) | |
| if variation % 5 == 0 and behavior not in {"permission_scope_safety", "code_review_security"}: | |
| insert_at = max(1, len(varied) - 1) | |
| varied.insert( | |
| insert_at, | |
| tool_step( | |
| 0, "verify", "run_tests", {"command": full_test_command, "scope": "full_suite_if_budget_allows"}, | |
| "Check for regressions beyond the targeted behavior when the execution budget permits.", | |
| "The targeted check establishes the fix; the wider suite provides additional regression evidence.", | |
| ), | |
| ) | |
| for position, item in enumerate(varied, 1): | |
| item["step"] = position | |
| return varied | |
| if behavior == "repository_grounding": | |
| return finalize([grounding, read_target, read_test, plan, edit, test, diff]) | |
| if behavior == "planning_decomposition": | |
| return finalize([grounding, read_target, plan, read_test, edit, test, diff]) | |
| if behavior == "tool_selection_execution": | |
| return finalize([grounding, read_target, edit, test, lint, diff]) | |
| if behavior == "bounded_code_editing": | |
| return finalize([grounding, read_target, read_test, edit, test, diff]) | |
| if behavior == "test_verification": | |
| return finalize([grounding, read_target, read_test, edit, test, lint, diff]) | |
| if behavior == "failure_diagnosis_repair": | |
| failed = dict(test) | |
| failed["expected_observation"] = "The first targeted test fails and provides a concrete counterexample." | |
| diagnose = tool_step( | |
| 7, "repair", "diagnose_failure", {"evidence": "targeted_test_output", "category": issue_category}, | |
| "Replace the disproven assumption with an evidence-backed failure hypothesis.", | |
| "Repeating the same patch would ignore the new test evidence.", | |
| ) | |
| repair = tool_step( | |
| 8, "repair", "apply_patch", {"path": target_file, "strategy": "revise the failed assumption without expanding scope"}, | |
| "Apply the second bounded patch addressing the diagnosed cause.", | |
| "The repair is tied to the observed failure rather than a speculative rewrite.", | |
| ) | |
| retest = tool_step( | |
| 9, "verify", "run_tests", {"command": test_command, "scope": "targeted_after_repair"}, | |
| "Confirm the revised patch satisfies the original acceptance criterion.", | |
| "The repaired behavior must be re-executed before completion.", | |
| ) | |
| return finalize([grounding, read_target, read_test, edit, failed, diagnose, repair, retest, diff]) | |
| if behavior == "code_review_security": | |
| review = tool_step( | |
| 4, "review", "review_diff", {"path": target_file, "focus": ["correctness", "security", "compatibility", "test_coverage"]}, | |
| "Produce only evidence-backed findings with severity and confidence.", | |
| "Review findings must point to a concrete execution path, not stylistic preference.", | |
| ) | |
| return finalize([grounding, read_target, read_test, review, diff]) | |
| if behavior == "permission_scope_safety": | |
| if requires_approval: | |
| approval = tool_step( | |
| 4, "authorize", "request_approval", {"operation": "destructive_or_external_change", "scope": target_file}, | |
| "Pause before a materially risky action and explain the bounded reason approval is required.", | |
| "The requested operation crosses a trust boundary that cannot be inferred from coding scope alone.", | |
| ) | |
| return finalize([grounding, read_target, approval]) | |
| safe = tool_step( | |
| 4, "authorize", "continue_without_approval", {"operation": "local_reversible_patch", "scope": target_file}, | |
| "Proceed because the operation is local, reversible, and within the explicit task boundary.", | |
| "Unnecessary approval requests would reduce agent usefulness without improving safety.", | |
| ) | |
| return finalize([grounding, read_target, safe, edit, test, diff]) | |
| if behavior == "final_reporting": | |
| return finalize([grounding, read_target, edit, test, lint, diff]) | |
| raise ValueError(f"Unknown behavior: {behavior}") | |
| def preference_supervision(steps: list[dict[str, Any]], behavior: str, target_file: str) -> dict[str, Any]: | |
| chosen = [{"tool": step["action"]["tool"], "arguments": step["action"]["arguments"]} for step in steps] | |
| rejected_by_behavior = { | |
| "repository_grounding": [ | |
| {"tool": "apply_patch", "arguments": {"path": "guessed/module.ext", "strategy": "edit before search"}}, | |
| {"tool": "run_tests", "arguments": {"command": "unknown-test-command"}}, | |
| ], | |
| "planning_decomposition": [ | |
| {"tool": "update_plan", "arguments": {"steps": ["rewrite subsystem", "replace dependencies", "change API"]}}, | |
| {"tool": "apply_patch", "arguments": {"path": target_file, "strategy": "unbounded redesign"}}, | |
| ], | |
| "tool_selection_execution": [ | |
| {"tool": "read_all_files", "arguments": {"path": "."}}, | |
| {"tool": "repeat_search", "arguments": {"query": "*"}}, | |
| ], | |
| "bounded_code_editing": [ | |
| {"tool": "apply_patch", "arguments": {"path": "multiple_unrelated_files", "strategy": "rewrite adjacent modules"}}, | |
| ], | |
| "test_verification": [ | |
| {"tool": "final_answer", "arguments": {"claim": "fixed and all tests pass", "evidence": None}}, | |
| ], | |
| "failure_diagnosis_repair": [ | |
| {"tool": "apply_patch", "arguments": {"path": target_file, "strategy": "repeat the failed patch unchanged"}}, | |
| ], | |
| "code_review_security": [ | |
| {"tool": "review_diff", "arguments": {"finding": "rename variable", "severity": "critical", "evidence": None}}, | |
| ], | |
| "permission_scope_safety": [ | |
| {"tool": "execute_external_change", "arguments": {"approval": False, "scope": "unbounded"}}, | |
| ], | |
| "final_reporting": [ | |
| {"tool": "final_answer", "arguments": {"claim": "done", "verification": "not reported"}}, | |
| ], | |
| } | |
| return { | |
| "chosen_sequence": chosen, | |
| "rejected_sequence": rejected_by_behavior[behavior], | |
| "preference_label": "chosen", | |
| "preference_reason": BEHAVIOR_SUMMARIES[behavior], | |
| "rejected_error_taxonomy": behavior, | |
| } | |
| def repair_supervision( | |
| steps: list[dict[str, Any]], behavior: str, issue_category: str, idx: int | |
| ) -> dict[str, Any]: | |
| failure_type, failure_signal = FAILURES[idx % len(FAILURES)] | |
| return { | |
| "initial_attempt": { | |
| "summary": "A bounded first attempt was applied after inspecting the target implementation.", | |
| "result": "failed", | |
| }, | |
| "failure_signal": {"type": failure_type, "evidence": failure_signal}, | |
| "diagnosis": { | |
| "category": issue_category, | |
| "updated_hypothesis": "The observed failure invalidates the first assumption; use the concrete signal to narrow the repair.", | |
| }, | |
| "repair_sequence": [ | |
| {"tool": "read_failure_output", "arguments": {"source": failure_type}}, | |
| {"tool": "read_file", "arguments": {"scope": "failing_path_and_nearest_caller"}}, | |
| {"tool": "apply_patch", "arguments": {"strategy": "repair diagnosed cause without broadening scope"}}, | |
| {"tool": "run_tests", "arguments": {"scope": "targeted_after_repair"}}, | |
| {"tool": "git_diff", "arguments": {"scope": "changed_files"}}, | |
| ], | |
| "reference_trajectory": steps, | |
| "success_criteria": [ | |
| "The original acceptance criterion passes", | |
| "The failure signal is no longer reproduced", | |
| "No unrelated file is modified", | |
| "The final report distinguishes executed evidence from assumptions", | |
| ], | |
| } | |
| def trajectory_supervision( | |
| steps: list[dict[str, Any]], behavior: str, target_file: str, test_file: str, full_test_command: str | |
| ) -> dict[str, Any]: | |
| return { | |
| "policy_summary": BEHAVIOR_SUMMARIES[behavior], | |
| "steps": steps, | |
| "candidate_patch": { | |
| "format": "patch_strategy", | |
| "target_files": [target_file, test_file], | |
| "strategy": "Preserve existing interfaces, correct only the evidenced behavior, and add narrow regression coverage.", | |
| "execution_status": "not_executed", | |
| }, | |
| "verification_plan": { | |
| "targeted_first": True, | |
| "full_suite_command": full_test_command, | |
| "diff_review_required": True, | |
| "do_not_claim_unexecuted_results": True, | |
| }, | |
| "final_response_contract": { | |
| "report_changed_behavior": True, | |
| "report_executed_checks_only": True, | |
| "report_remaining_uncertainty": True, | |
| "avoid_unsupported_success_claims": True, | |
| }, | |
| } | |
| def make_record( | |
| idx: int, | |
| family: int, | |
| slot: int, | |
| split: str, | |
| behavior: str, | |
| record_type: str, | |
| language: str, | |
| task_type: str, | |
| difficulty: str, | |
| ) -> dict[str, Any]: | |
| domain = DOMAINS[family % len(DOMAINS)] | |
| component = COMPONENTS[(family * 3 + slot) % len(COMPONENTS)] | |
| issue, issue_category = ISSUES[(family * 7 + slot * 3) % len(ISSUES)] | |
| paths = make_paths(language, component, family, slot) | |
| spec = LANGUAGES[language] | |
| target_symbol = f"{symbol(component)}Policy{family:03d}{slot:02d}" | |
| test_symbol = f"{symbol(component)}Regression{family:03d}{slot:02d}" | |
| test_command = spec["test_command"].format( | |
| test_file=paths["test_file"], test_symbol=test_symbol, component=slug(component), target_file=paths["target_file"] | |
| ) | |
| lint_command = spec["lint_command"].format(target_file=paths["target_file"]) | |
| constraints = CONSTRAINT_SETS[(family + slot) % len(CONSTRAINT_SETS)] | |
| repository_shape = REPOSITORY_SHAPES[family % len(REPOSITORY_SHAPES)] | |
| instruction = render_instruction( | |
| task_type, component, issue, domain, idx, target_symbol, repository_shape | |
| ) | |
| repository_id = f"jl-synrepo-{family:04d}" | |
| requires_approval = behavior == "permission_scope_safety" and ((family + slot) % 2 == 0) | |
| steps = base_sequence( | |
| behavior, | |
| paths["target_file"], | |
| paths["test_file"], | |
| target_symbol, | |
| test_command, | |
| spec["full_test_command"], | |
| lint_command, | |
| issue_category, | |
| requires_approval, | |
| difficulty, | |
| task_type, | |
| idx, | |
| ) | |
| record: dict[str, Any] = { | |
| "id": f"jlab-v1-{idx + 1:05d}", | |
| "version": VERSION, | |
| "split": split, | |
| "record_type": record_type, | |
| "primary_behavior": behavior, | |
| "secondary_behaviors": SECONDARY_MAP[behavior], | |
| "language": language, | |
| "ecosystem": spec["ecosystem"], | |
| "task_type": task_type, | |
| "difficulty": difficulty, | |
| "task": { | |
| "instruction": instruction, | |
| "constraints": constraints, | |
| "acceptance_criteria": [ | |
| f"The {component} no longer exhibits the specified behavior", | |
| "The public contract remains compatible", | |
| "A targeted verification path is identified", | |
| "The final change remains inside the requested scope", | |
| ], | |
| }, | |
| "environment": { | |
| "repository_id": repository_id, | |
| "repository_shape": repository_shape, | |
| "domain": domain, | |
| "synthetic_commit": hashlib.sha1(f"{repository_id}:before".encode()).hexdigest(), | |
| "target_file": paths["target_file"], | |
| "test_file": paths["test_file"], | |
| "target_symbol": target_symbol, | |
| "test_symbol": test_symbol, | |
| "targeted_test_command": test_command, | |
| "full_test_command": spec["full_test_command"], | |
| "lint_command": lint_command, | |
| }, | |
| "behavioral_labels": { | |
| "must_ground_before_edit": True, | |
| "must_verify_before_success_claim": True, | |
| "should_ask_clarification": False, | |
| "requires_approval": requires_approval, | |
| "expected_tool_sequence": [step["action"]["tool"] for step in steps], | |
| "target_behavior": BEHAVIOR_SUMMARIES[behavior], | |
| }, | |
| "provenance": { | |
| "origin": "synthetic", | |
| "generation_method": "deterministic_scenario_composition", | |
| "repository_materialized": False, | |
| "execution_verified": False, | |
| "tool_results": "expected_or_simulated", | |
| "human_reviewed": False, | |
| "release_stage": "research_preview", | |
| }, | |
| "quality": { | |
| "schema_validated": True, | |
| "exact_duplicate": False, | |
| "split_grouped_by_repository_family": True, | |
| "execution_verified": False, | |
| "quality_tier": "silver_structural", | |
| }, | |
| } | |
| if record_type == "trajectory": | |
| record["supervision"] = trajectory_supervision( | |
| steps, behavior, paths["target_file"], paths["test_file"], spec["full_test_command"] | |
| ) | |
| elif record_type == "preference": | |
| record["supervision"] = preference_supervision(steps, behavior, paths["target_file"]) | |
| else: | |
| record["supervision"] = repair_supervision(steps, behavior, issue_category, idx) | |
| record["fingerprint"] = fingerprint(record) | |
| return record | |
| def write_json(path: Path, value: Any) -> None: | |
| path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") | |
| def write_jsonl(path: Path, records: list[dict[str, Any]]) -> None: | |
| with path.open("w", encoding="utf-8", newline="\n") as handle: | |
| for record in records: | |
| handle.write(json.dumps(record, ensure_ascii=False, separators=(",", ":")) + "\n") | |
| def build_schema() -> dict[str, Any]: | |
| return { | |
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |
| "$id": "https://jumplander.org/schemas/jl-agentbehavior-10k-v1.schema.json", | |
| "title": "JL-AgentBehavior-10K v1 Record", | |
| "type": "object", | |
| "required": [ | |
| "id", "version", "split", "record_type", "primary_behavior", "language", | |
| "task_type", "difficulty", "task", "environment", "behavioral_labels", | |
| "provenance", "quality", "supervision", "fingerprint", | |
| ], | |
| "properties": { | |
| "id": {"type": "string", "pattern": "^jlab-v1-[0-9]{5}$"}, | |
| "version": {"const": VERSION}, | |
| "split": {"enum": ["train", "validation", "test"]}, | |
| "record_type": {"enum": list(RECORD_TYPE_QUOTAS)}, | |
| "primary_behavior": {"enum": list(BEHAVIOR_QUOTAS)}, | |
| "secondary_behaviors": {"type": "array", "items": {"type": "string"}}, | |
| "language": {"enum": list(LANGUAGE_QUOTAS)}, | |
| "ecosystem": {"type": "string"}, | |
| "task_type": {"enum": list(TASK_QUOTAS)}, | |
| "difficulty": {"enum": list(DIFFICULTY_QUOTAS)}, | |
| "task": { | |
| "type": "object", | |
| "required": ["instruction", "constraints", "acceptance_criteria"], | |
| }, | |
| "environment": { | |
| "type": "object", | |
| "required": ["repository_id", "target_file", "test_file", "targeted_test_command"], | |
| }, | |
| "behavioral_labels": {"type": "object"}, | |
| "provenance": { | |
| "type": "object", | |
| "required": ["origin", "execution_verified", "release_stage"], | |
| }, | |
| "quality": {"type": "object"}, | |
| "supervision": {"type": "object"}, | |
| "fingerprint": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, | |
| }, | |
| "additionalProperties": False, | |
| } | |
| def statistics(records: list[dict[str, Any]]) -> dict[str, Any]: | |
| dimensions = ["split", "record_type", "primary_behavior", "language", "task_type", "difficulty"] | |
| stats: dict[str, Any] = { | |
| "dataset": "JL-AgentBehavior-10K", | |
| "version": VERSION, | |
| "generated_with_seed": SEED, | |
| "total_records": len(records), | |
| "dimensions": {}, | |
| "verification": { | |
| "schema_validated_records": sum(r["quality"]["schema_validated"] for r in records), | |
| "execution_verified_records": sum(r["provenance"]["execution_verified"] for r in records), | |
| "human_reviewed_records": sum(r["provenance"]["human_reviewed"] for r in records), | |
| "unique_fingerprints": len({r["fingerprint"] for r in records}), | |
| "unique_instructions": len({r["task"]["instruction"] for r in records}), | |
| "unique_tool_sequences": len({tuple(r["behavioral_labels"]["expected_tool_sequence"]) for r in records}), | |
| "average_tool_steps": round( | |
| sum(len(r["behavioral_labels"]["expected_tool_sequence"]) for r in records) / len(records), 4 | |
| ), | |
| "unique_repository_families": len({r["environment"]["repository_id"] for r in records}), | |
| }, | |
| } | |
| for dimension in dimensions: | |
| stats["dimensions"][dimension] = dict(sorted(Counter(r[dimension] for r in records).items())) | |
| stats["split_repository_families"] = { | |
| split: len({r["environment"]["repository_id"] for r in records if r["split"] == split}) | |
| for split in ("train", "validation", "test") | |
| } | |
| return stats | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--output", type=Path, default=Path(__file__).resolve().parents[1]) | |
| args = parser.parse_args() | |
| root = args.output.resolve() | |
| data_dir = root / "data" | |
| data_dir.mkdir(parents=True, exist_ok=True) | |
| rng = random.Random(SEED) | |
| behaviors = expand_quota(BEHAVIOR_QUOTAS, rng) | |
| record_types = expand_quota(RECORD_TYPE_QUOTAS, rng) | |
| languages = expand_quota(LANGUAGE_QUOTAS, rng) | |
| task_types = expand_quota(TASK_QUOTAS, rng) | |
| difficulties = expand_quota(DIFFICULTY_QUOTAS, rng) | |
| records: list[dict[str, Any]] = [] | |
| for idx in range(TOTAL): | |
| family = idx // 20 | |
| slot = idx % 20 | |
| split = "train" if family < 450 else "validation" if family < 475 else "test" | |
| records.append( | |
| make_record( | |
| idx, family, slot, split, behaviors[idx], record_types[idx], | |
| languages[idx], task_types[idx], difficulties[idx] | |
| ) | |
| ) | |
| assert len({r["id"] for r in records}) == TOTAL | |
| assert len({r["fingerprint"] for r in records}) == TOTAL | |
| assert Counter(r["primary_behavior"] for r in records) == Counter(BEHAVIOR_QUOTAS) | |
| assert Counter(r["record_type"] for r in records) == Counter(RECORD_TYPE_QUOTAS) | |
| assert Counter(r["language"] for r in records) == Counter(LANGUAGE_QUOTAS) | |
| assert Counter(r["task_type"] for r in records) == Counter(TASK_QUOTAS) | |
| assert Counter(r["difficulty"] for r in records) == Counter(DIFFICULTY_QUOTAS) | |
| for split in ("train", "validation", "test"): | |
| write_jsonl(data_dir / f"{split}.jsonl", [r for r in records if r["split"] == split]) | |
| write_json(root / "schema.json", build_schema()) | |
| write_json(root / "stats.json", statistics(records)) | |
| (root / "VERSION").write_text(VERSION + "\n", encoding="utf-8") | |
| print(f"Generated {TOTAL:,} records in {root}") | |
| if __name__ == "__main__": | |
| main() | |