ReceiptsRecorded runs, model-free verdicts
VERIFIED

s-knibbs__dataclasses-jsonschema-93

VERIFIED on first verdict

1 attempt, 0 appeals. 1 file, 39 added and 0 removed lines. Tokens: 151,118 tokens. Model cost: $0.05. Sandbox time: 51 s.

The plan

Repository
s-knibbs/dataclasses-jsonschema
Base commit
b5ccd44 (image tag)
Issue
Add to_json and from_json convenience methods It'd be nice to add `from_json` and `to_json` methods for convenience
Files to edit
  • dataclasses_jsonschema/__init__.py
Approach
add two new classmethods - from_json(json_str, *, encoding="utf-8", validate=True, skip_invalid=False) returning instance created via from_dict(json.loads(...)), and to_json(*, indent=None, ensure_ascii=True, validate=False) returning string of dump(to_dict()) after handling parameters; they must delegate to existing from_dict/to_dict respectively so nothing in core functionality changes beyond providing thin wrappers around stdlib json module imports already allowed elsewhere in file.

Attempt 1

VERIFIED

Agent branch

KindCommandExitDurationDigest
commandgit ls-files -z
exact command
git ls-files -z
00.004s4cdbba5d
commandgrep -n "test_from_json_to_json" tests/test_core.py
exact command
grep -n "test_from_json_to_json" tests/test_core.py
00.003s8531ba2e
writewrite dataclasses_jsonschema/__init__.py
exact command
/opt/receipts-a060393b8c1247ea9fb72fb17cb96bf8/bin/busybox sh -c 'mkdir -p /dataclasses-jsonschema/dataclasses_jsonschema && cp /opt/receipts-a060393b8c1247ea9fb72fb17cb96bf8/incoming/f9056d9788e2d23f7eb8628f5c3e26e2247944d0aa4efb257f3178ceedf686ab /dataclasses-jsonschema/dataclasses_jsonschema/__init__.py'
00.005scf514ad3
commandpytest tests/test_core.py::test_from_json_to_json -v
exact command
/opt/receipts-97a1eae3a3c3453fa493145e46b80656/bin/busybox mkdir -p /opt/receipts/reports && python -I /opt/receipts-97a1eae3a3c3453fa493145e46b80656/receipts_pytest.py tests/test_core.py::test_from_json_to_json -v -o junit_family=xunit1 -p no:cacheprovider -rA --continue-on-collection-errors --junitxml=/opt/receipts/reports/agent1-4.xml
00.278sd04c677ef71e
commandpytest tests/test_core.py
exact command
/opt/receipts-e545769109bb483e93e1660bfb720aac/bin/busybox mkdir -p /opt/receipts/reports && python -I /opt/receipts-e545769109bb483e93e1660bfb720aac/receipts_pytest.py tests/test_core.py --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning -o junit_family=xunit1 -p no:cacheprovider -rA --continue-on-collection-errors --junitxml=/opt/receipts/reports/agent1-5.xml
00.338sd04c677ef71e
writewrite /tmp/verify_methods.py
exact command
/opt/receipts-9fcf0eabff054898bd98eaad47fcc7c5/bin/busybox sh -c 'mkdir -p /tmp && cp /opt/receipts-9fcf0eabff054898bd98eaad47fcc7c5/incoming/ea57ff280ec5e9618bf4b9825cb6346a7f4a449e7ab686403fee0d8f5519ab1c /tmp/verify_methods.py'
00.005saf83156a
commandpython /tmp/verify_methods.py
exact command
python /tmp/verify_methods.py
00.114s288cd579
diffcapture patch
exact command
compute patch in executor staging agent1-9afe167a18174513bf42b83f24673c44: /opt/homebrew/Cellar/git/2.53.0/bin/git -c core.hooksPath=/dev/null -c core.attributesFile=/dev/null -c diff.external= -c core.quotePath=false add -A && /opt/homebrew/Cellar/git/2.53.0/bin/git -c core.hooksPath=/dev/null -c core.attributesFile=/dev/null -c diff.external= -c core.quotePath=false diff --cached --binary --no-ext-diff --no-textconv --no-renames b8ef5e8b0b6e2e0ddd53bb88f240ccde2456b59a
00.044s7cd1a70314d2
Finish summary
Added `from_json` and `to_json` convenience methods to the JsonSchemaMixin class in dataclasses_jsonschema/__init__.py. The `from_json` classmethod parses a JSON string and creates an instance using the existing `from_dict` method, with options for encoding, validation, and skipping invalid fields. The `to_json` instance method serializes the dataclass instance to a JSON string using the existing `to_dict` method, with options for indentation, ASCII encoding, and validation. Both methods properly delegate to the existing core functionality, maintaining backward compatibility while providing convenient JSON serialization/deserialization capabilities.
Worker outcome
finished
  • Target tests pass: yes
  • Full suite passes: yes
  • Files changed: dataclasses_jsonschema/__init__.py
  • Ran tests: yes

Witness branch w1

KindCommandExitDurationDigest
applyapply patch f1dbc1fde956
exact command
git update-index -q --refresh; git apply -v --3way --recount --ignore-space-change --whitespace=nowarn /opt/receipts-2b72c1ef2d5d4e168fbbbbf58ac28df7/incoming/f1dbc1fde956a4d13a4960a3ee8d5bdd5eed9f43e131bb3eef54c884c672927f.diff
00.008sd04c677ef71e
verificationpytest (witness) tests/test_core.py
exact command
/opt/receipts-23957c16bef043fab87fbb06f44ed4a7/bin/busybox mkdir -p /opt/receipts/reports && python -I /opt/receipts-23957c16bef043fab87fbb06f44ed4a7/receipts_pytest.py --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning tests/test_core.py -o junit_family=xunit1 -p no:cacheprovider -rA --continue-on-collection-errors --junitxml=/opt/receipts/reports/w1-2.xml
00.330sd04c677ef71e

Gate predicate checklist

PredicateNameStatusEvidence
R1_fail_to_passFailing specification tests now passPASStarget tests passed: tests/test_core.py::test_from_json_to_json
R2_pass_to_passPreviously passing tests keptPASS28 baseline-passing tests still pass
R3_no_shrinkNo removed tests or new skipsPASSall 29 baseline tests collected; skips unchanged (0)
R4_patch_scopePatch scopePASSpatch touches 1 file(s), all in scope
R5_provenanceWitness chain and patch digestPASSagent chain 4793f385 -> 288cd579 unbroken over 8 receipt(s); witness chain 4793f385 -> 27fe5068 unbroken over 2 receipt(s); applied digest matches
R6_claim_auditAgent claim audit (advisory)FAILclaimed green but the final tree differs from the tree its last test run saw (receipt agent1-5)

What it said

Finish summary
Added `from_json` and `to_json` convenience methods to the JsonSchemaMixin class in dataclasses_jsonschema/__init__.py. The `from_json` classmethod parses a JSON string and creates an instance using the existing `from_dict` method, with options for encoding, validation, and skipping invalid fields. The `to_json` instance method serializes the dataclass instance to a JSON string using the existing `to_dict` method, with options for indentation, ASCII encoding, and validation. Both methods properly delegate to the existing core functionality, maintaining backward compatibility while providing convenient JSON serialization/deserialization capabilities.
Worker outcome
finished
  • Target tests pass: yes
  • Full suite passes: yes
  • Files changed: dataclasses_jsonschema/__init__.py
  • Ran tests: yes

What the record shows

unsupported: claimed green but the final tree differs from the tree its last test run saw (receipt agent1-5)

SWE-rebench's official grader: resolved

Agrees with the gate

Shipped patch

diff --git a/dataclasses_jsonschema/__init__.py b/dataclasses_jsonschema/__init__.pyindex b17098d..0c2dacb 100644--- a/dataclasses_jsonschema/__init__.py+++ b/dataclasses_jsonschema/__init__.py@@ -487,6 +487,45 @@ class JsonSchemaMixin:             setattr(instance, field_name, value)         return instance +    @classmethod+    def from_json(cls: Type[T], json_str: str, *, encoding: str = "utf-8", validate: bool = True, skip_invalid: bool = False) -> T:+        """Creates a dataclass instance from a JSON string.+        +        Args:+            json_str: JSON string to parse+            encoding: Text encoding to use (default: utf-8)+            validate: Whether to validate against JSON schema (default: True)+            skip_invalid: Whether to skip invalid fields during parsing (default: False)+            +        Returns:+            Instance of the dataclass+        """+        import json+        data = json.loads(json_str)+        if skip_invalid:+            # Filter out fields that don't exist in the dataclass+            valid_fields = {f.name for f in fields(cls)}+            data = {k: v for k, v in data.items() if k in valid_fields or cls.field_mapping().get(k) in valid_fields}+            # Reverse map field mapping for validation+            reverse_mapping = {v: k for k, v in cls.field_mapping().items()}+            data = {reverse_mapping.get(k, k): v for k, v in data.items()}+        return cls.from_dict(data, validate=validate)++    def to_json(self, *, indent: int = None, ensure_ascii: bool = True, validate: bool = False) -> str:+        """Serializes the dataclass instance to a JSON string.+        +        Args:+            indent: Indentation level for pretty-printing (default: None)+            ensure_ascii: Whether to escape non-ASCII characters (default: True)+            validate: Whether to validate against JSON schema before serializing (default: False)+            +        Returns:+            JSON string representation of the instance+        """+        import json+        data = self.to_dict(validate=validate)+        return json.dumps(data, indent=indent, ensure_ascii=ensure_ascii)+     @staticmethod     def _is_json_schema_subclass(field_type) -> bool:         return issubclass_safe(field_type, JsonSchemaMixin)

Model and costs

Model
NVIDIA Nemotron 3 Super thinking off · temperature 1.0 · top_p 0.95
Tokens
151,118 tokens
Model cost
$0.05
Sandbox time
51 s
Sandbox cost
Token Factory reported cost: 0.025 (unit not published)
Full environment disclosure
{
  "executor_kind": "tokenfactory",
  "lock_sha256": "24d7a55880edf9937f02f9e2b49d31efcc2475b3fcd0dc56c9d8c6caf12bc9f8",
  "model": {
    "base_url": "https://api.tokenfactory.nebius.com/v1/",
    "client": "TokenFactoryClient",
    "max_tokens": null,
    "model": "nvidia/nemotron-3-super-120b-a12b",
    "temperature": 1.0,
    "thinking": false,
    "top_p": 0.95
  },
  "pytest_config_digests": {
    "setup.cfg": "80e8e83de1362869e593ff6fb612ea7c52f14c6138ed3351da3fc39ce6dcf16a",
    "tests/conftest.py": "ea68a672c0533fc5e1c72069bd9b2962a4c1fe81fde4e580a6e242db5620dbed",
    "tox.ini": "80c9a662737ab37d9631c1e73eb834273ee101357a8658be2f55268df1791333"
  },
  "receipts_version": "0.0.1",
  "test_digests": {
    "tests/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "tests/conftest.py": "ea68a672c0533fc5e1c72069bd9b2962a4c1fe81fde4e580a6e242db5620dbed",
    "tests/test_apispec_plugin.py": "f39ebfe8f8c469701fce48ec01269b4f944a03da7a1d824904c2c349cec46b36",
    "tests/test_core.py": "7a942621e5a7ef30afcf25d279a10f6e0e67736fe789d1729186df027c1beb53"
  }
}

The bundle

Recorded JSON and patches. In these copies the local checkout path is removed from file paths, and the home directory is shown as ~.