utils-repair-json.json 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {
  2. "name": "utils-repair-json",
  3. "description": "smartbotic.utils.repairJson, exercised against the exact reply that broke 35photo2anime - 791 characters taken verbatim from the stored execution, not retyped. The model dropped `{\"` as a pair, so the document begins at a key with no opening quote. jsonrepair 3.x does not fix this shape, and neither did the first version of this repairer - a reconstructed test string had put the quote back and hidden that. Also pins that valid JSON is left alone, that non-JSON is refused rather than guessed at, and that a brace inside a string value does not confuse the bracket count.",
  4. "nodes": [
  5. {
  6. "id": "n1",
  7. "name": "Trigger",
  8. "type": "click-trigger",
  9. "position": {
  10. "x": 0,
  11. "y": 0
  12. },
  13. "config": {}
  14. },
  15. {
  16. "id": "n2",
  17. "name": "Repair",
  18. "type": "code",
  19. "position": {
  20. "x": 0,
  21. "y": 100
  22. },
  23. "config": {
  24. "code": "// The reply minimax-m3:cloud actually returned on 2026-09-03, taken verbatim\n// from execution exec_a0cf664e. Not retyped: an earlier version of this test\n// used a hand-written approximation that had silently restored the opening\n// quote, so it passed against a repairer that could not fix the real thing.\nvar real = \"humanCount\\\": 0, \\\"people\\\": [], \\\"nsfw\\\": false, \\\"nsfwLevel\\\": \\\"none\\\", \\\"nsfwReason\\\": \\\"no people present\\\", \\\"description\\\": \\\"a black-backed jackal standing alert in tall golden-green savanna grass, its body angled to the right while its head turns back to look over its left shoulder, distinctive black and silver saddle across the back, rust-colored legs and flanks, pointed ears erect, muzzle closed, tall dry grass surrounding and partially obscuring its lower legs, natural outdoor setting\\\", \\\"person_count\\\": 0, \\\"genders\\\": [], \\\"eroticism_level\\\": \\\"none\\\", \\\"is_black_and_white\\\": false, \\\"face_visible\\\": false, \\\"described_image_content\\\": \\\"A black-backed jackal (Canis mesomelas) standing in tall savanna grass, body shown in profile with head turned looking backward. No humans present in the image.\\\"}\";\nvar a = smartbotic.utils.repairJson(real);\nvar b = smartbotic.utils.repairJson('{\"a\": 1}');\nvar c = smartbotic.utils.repairJson('not json at all <html>');\nvar d = smartbotic.utils.repairJson('{\"text\": \"a { brace\", \"n\": 1');\nreturn {\n realOk: a.ok,\n realRepairs: a.repairs.join('; '),\n realHumanCount: a.value ? a.value.humanCount : -1,\n realNsfw: a.value ? a.value.nsfw : null,\n validUntouched: b.ok && b.repairs.length === 0,\n brokenRefused: c.ok === false,\n braceInStringText: d.value ? d.value.text : ''\n};\n"
  25. }
  26. }
  27. ],
  28. "connections": [
  29. {
  30. "sourceNodeId": "n1",
  31. "sourceOutput": "main",
  32. "targetNodeId": "n2",
  33. "targetInput": "data"
  34. }
  35. ],
  36. "expect": {
  37. "n2": {
  38. "status": "completed",
  39. "output": {
  40. "result": {
  41. "realOk": true,
  42. "realRepairs": "added the missing opening brace and quote",
  43. "realHumanCount": 0,
  44. "realNsfw": false,
  45. "validUntouched": true,
  46. "brokenRefused": true,
  47. "braceInStringText": "a { brace"
  48. }
  49. }
  50. }
  51. }
  52. }