formats: std/json-patch with RFC 6902 JSON Patch and the json-patch-tests suite (step 2 of #81) #581
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 2 of the epic #81 (JSON Patch). Step 1 (#435,
JsonPointerandJsonValue.getinstd/json) is onmain(merge commitb929c58). This step adds the packagestd/json-patchwith RFC 6902 JSON Patch: a patch document is a value onEncode/Decode, applying it works onJsonValue. RFC 7396 Merge Patch is step 3 and is not part of this issue.Source
EncodeandDecode.std/json-schema(package,src/lib.trb,tests/suite-cases.trbandtests/suite.test.trbwith its vendored public suite and exclusion list),std/yaml(generatedsuite-cases.trbwith the licence notice).Design record point
ROADMAP "Which versions a format supports" (JSON Patch row) and ENCODING.md section 9, as decided on #81:
std/json-patch(hyphenated likestd/json-schema), pure TorbScript onJsonValueandJsonPointer, not in the prelude.JsonPatchis a list of operations andEncode/Decode; the six operations are cases of onePatchOperationtype (add,remove,replace,move,copy,test). Decoding refuses an unknownop, a missingpath/value/from, and a malformed pointer, with an error that names the operation index.JsonPatch.apply(document: JsonValue): Result<JsonValue, PatchError>is a method (#146) and atomic as RFC 6902 section 5 requires: a failing operation or a failingtestreturns the error and no partial document.JsonValueis a value, so the input is untouched by construction.PatchErrornames the operation index, the operation and the reason.addinto an array inserts (index equal to the length and-append, larger index is an error), into an object sets the member;addwith the root pointer replaces the whole document;removeandreplaceneed an existing target;moveisremovefromfromthenaddatpathand refuses to move a value into one of its own children;copyisgetthenadd;testcompares with the RFC's equality (objects as unordered member sets, arrays ordered, numbers by value, strings by code points).diffgeneration, patching typed values throughDescribe, RFC 7396 (step 3).std/json-patch, and no std name is looked up by string for it. The new package is registered like the other std packages (workspace list, docs index, regeneratedskills/), none of which touchesseed/.Acceptance criteria
use JsonPatch, PatchOperation, PatchError from "std/json-patch"works;JsonPatchencodes to and decodes from the RFC 6902 JSON array form (Json.decode/Json.encoderound trip, tested).addat-and at the array length, the root pointer,moveinto own child refused, andtestequality rules; hand-written tests cover each operation and each error path.applyis atomic: a test where the third operation fails shows that the error is returned and the document value passed in is unchanged.tests.jsonandspec_tests.jsonof https://github.com/json-patch/json-patch-tests, MIT) is vendored as a generatedstd/json-patch/tests/suite-cases.trbwith the licence notice and the pinned commit, run bysuite.test.trb(one test per case, asstd/json-schema). Cases that need arbitrary-precision numbers (JsonValue.Numberis aFloat64) are excluded by name with the reason, and each exclusion is checked so it cannot go stale. No other exclusion.docs/standard-library/json-patch.md(types, operations, atomicity, error values, the non-goals);skills/regenerated; the ROADMAP JSON Patch row marked started (RFC 6902 done, 7396 open).sh tools/gates.sh agreen in forge CI;tools/check-commits.shclean.Size
One PR, two Conventional Commits (the loop's two-commit rule keeps each reviewable):
feat(std/json-patch): JsonPatch with the RFC 6902 operations and atomic apply(package, types, Encode/Decode, apply, hand-written tests, docs page).test(std/json-patch): run the public json-patch-tests suite(generatedsuite-cases.trbwith notice,suite.test.trb, exclusions, ROADMAP row).Dependencies
JsonPointer(#435, merged),std/json,std/test.Part of #81.
[loop:torbscript] claim implement by session:loop-torbscript-20261029-0858 until 2026-10-29T19:40Z
[loop:torbscript] release implement: the worker session was interrupted after 40 min; PR #584 (two commits, branch loop/581-json-patch) is open and its forge CI was still pending. A fresh worker takes over to read CI and fix rounds.
[loop:torbscript] claim implement by session:loop-torbscript-20261029-0858 until 2026-10-29T20:25Z
[loop:torbscript] implement checkpoint: PR #584 has
Closes #581and review requested from argus; diff checked against the acceptance criteria (package, tests, suite, docs, skills, ROADMAP, no seed files). Forge CI on703b9f91still running (gates, tier A, archives pending); waiting with ci-wait, next: fix rounds only if red.[loop:torbscript] release implement: the worker was interrupted by a gateway restart; PR #584 stays open, the next tick starts a fresh worker to read CI and fix rounds.
[loop:torbscript] claim implement by session:loop-torbscript-20261029-1532 until 2026-10-29T21:35Z
[loop:torbscript] implement: checkpoint, PR #584 head
703b9f91open; CI still running (gates, tier A, archives, pack the seed pending; bootstrap, commit messages, pdisc green), next: wait for CI (session:loop-torbscript-20261029-1532)[loop:torbscript] implement checkpoint: forge CI on
703b9f91was red on two gates only (format --check on std/json/src/lib.trb; docs summary of json-patch.md 250 > 240 chars). Fixed in place (folded into the feat commit, history still two commits), force-pushed19490735, waiting for the CI run, next: review if green.std/json-patch(step 3 of #81) #687