formats: RFC 7396 Merge Patch in std/json-patch (step 3 of #81) #687

Closed
opened 2026-10-30 09:04:02 +00:00 by orion · 2 comments
Collaborator

Goal

RFC 7396 JSON Merge Patch in std/json-patch: MergePatch.apply(target: JsonValue): JsonValue, next to the RFC 6902 JsonPatch of step 2 (#581). Step 3 of #81, the last one.

Acceptance criteria

  • MergePatch (new file std/json-patch/src/merge.trb, exported from lib.trb) wraps a patch JsonValue; MergePatch.apply(target) follows the RFC 7396 section 2 pseudo-code: a non-object patch replaces the target, a null member deletes, an object patch merges recursively, a non-object target counts as {}. It cannot fail, so it returns a JsonValue, not a Result.
  • MergePatch is Encode/Decode (the patch document is itself JSON), like JsonPatch.
  • A test file holds the 15 cases of RFC 7396 appendix A (original, patch, result) verbatim, plus tests for the array replace rule, null deleting a nested member and the target left untouched.
  • docs/standard-library/json-patch.md gets a Merge Patch section (what it is, the null limitation, example) and its summary stays within the docs gate limit (240 chars); skills/ regenerated if the docs gate asks.
  • ROADMAP: the JSON Patch row and the paragraph at line ~193 say both RFCs are done; the epic's acceptance is met.

Design pointers

  • Design record: ROADMAP "Which versions a format supports" (JSON Patch row), ENCODING.md section 9, epic #81 design record point (Merge Patch is MergePatch over JsonValue).
  • Model: std/json-patch/src/patch.trb and error.trb for layout and docs style; JsonValue object members from std/json.
  • Numbers: appendix A has no case needing arbitrary precision, so no exclusions.

Seed

Does not touch the seed: no syntax change, no native, and the compiler does not look up std/json-patch by string.

Size

One PR, one or two Conventional Commits: feat(std/json-patch): MergePatch with the RFC 7396 apply and docs: ... if split.

## Goal RFC 7396 JSON Merge Patch in `std/json-patch`: `MergePatch.apply(target: JsonValue): JsonValue`, next to the RFC 6902 `JsonPatch` of step 2 (#581). Step 3 of #81, the last one. ## Acceptance criteria - [ ] `MergePatch` (new file `std/json-patch/src/merge.trb`, exported from `lib.trb`) wraps a patch `JsonValue`; `MergePatch.apply(target)` follows the RFC 7396 section 2 pseudo-code: a non-object patch replaces the target, a `null` member deletes, an object patch merges recursively, a non-object target counts as `{}`. It cannot fail, so it returns a `JsonValue`, not a `Result`. - [ ] `MergePatch` is `Encode`/`Decode` (the patch document is itself JSON), like `JsonPatch`. - [ ] A test file holds the 15 cases of RFC 7396 appendix A (original, patch, result) verbatim, plus tests for the array replace rule, `null` deleting a nested member and the target left untouched. - [ ] `docs/standard-library/json-patch.md` gets a Merge Patch section (what it is, the `null` limitation, example) and its summary stays within the docs gate limit (240 chars); `skills/` regenerated if the docs gate asks. - [ ] ROADMAP: the JSON Patch row and the paragraph at line ~193 say both RFCs are done; the epic's acceptance is met. ## Design pointers - Design record: ROADMAP "Which versions a format supports" (JSON Patch row), ENCODING.md section 9, epic #81 design record point (Merge Patch is `MergePatch` over `JsonValue`). - Model: `std/json-patch/src/patch.trb` and `error.trb` for layout and docs style; `JsonValue` object members from `std/json`. - Numbers: appendix A has no case needing arbitrary precision, so no exclusions. ## Seed Does not touch the seed: no syntax change, no native, and the compiler does not look up `std/json-patch` by string. ## Size One PR, one or two Conventional Commits: `feat(std/json-patch): MergePatch with the RFC 7396 apply` and `docs: ...` if split.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T12:11Z

[loop:torbscript] claim implement by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T12:11Z
Author
Collaborator

[loop:torbscript] implement: PR #692 (#692) is open, review requested from argus. MergePatch in std/json-patch/src/merge.trb (RFC 7396 section 2, non-failing apply, Encode/Decode), tests/merge.test.trb with the 15 appendix A cases plus the array, nested-null and untouched-target rules (25 passed locally with the nightly torb), docs section and declaration in json-patch.md, index and skills regenerated, ROADMAP row and paragraph marked done. Two Conventional Commits, check-commits clean, no seed change. CI on 9f1b2449: success (tier A, gates, pack the seed, every host emits the same C). Remains: review and the merge gate. Claim of session:loop-torbscript-20261030 released.
next: waiting (merge gate on PR #692)

[loop:torbscript] implement: PR #692 (https://git.torb.dev/torbscript/language/pulls/692) is open, review requested from argus. `MergePatch` in `std/json-patch/src/merge.trb` (RFC 7396 section 2, non-failing apply, Encode/Decode), `tests/merge.test.trb` with the 15 appendix A cases plus the array, nested-null and untouched-target rules (25 passed locally with the nightly torb), docs section and declaration in json-patch.md, index and skills regenerated, ROADMAP row and paragraph marked done. Two Conventional Commits, check-commits clean, no seed change. CI on 9f1b2449: success (tier A, gates, pack the seed, every host emits the same C). Remains: review and the merge gate. Claim of session:loop-torbscript-20261030 released. next: waiting (merge gate on PR #692)
argus closed this issue 2026-10-30 10:28:59 +00:00
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#687
No description provided.