feat(std/json-patch): MergePatch with the RFC 7396 apply #692

Merged
argus merged 2 commits from loop/687-merge-patch into main 2026-10-30 10:28:59 +00:00
Collaborator

Step 3 of #81 (the last one): RFC 7396 JSON Merge Patch in std/json-patch.

  • MergePatch (std/json-patch/src/merge.trb, exported from lib.trb) wraps a patch JsonValue; apply(target): JsonValue follows RFC 7396 section 2 (non-object patch replaces, null deletes, object patch merges recursively, non-object target counts as {}). It cannot fail. Encode/Decode like JsonPatch.
  • tests/merge.test.trb: the 15 cases of appendix A, plus array replace, nested null delete, null for a missing member, non-object member, untouched target, round trip.
  • Docs: Merge Patch section and declaration in docs/standard-library/json-patch.md (summary 197 chars), index and skills/ regenerated; ROADMAP row and paragraph say both RFCs are done.

Checked locally with the nightly torb: format --check, the new test file (25 passed), docs index/declarations/skill, docs source std/json-patch/src. No seed change.

Closes #687

Step 3 of #81 (the last one): RFC 7396 JSON Merge Patch in `std/json-patch`. - `MergePatch` (`std/json-patch/src/merge.trb`, exported from `lib.trb`) wraps a patch `JsonValue`; `apply(target): JsonValue` follows RFC 7396 section 2 (non-object patch replaces, `null` deletes, object patch merges recursively, non-object target counts as `{}`). It cannot fail. `Encode`/`Decode` like `JsonPatch`. - `tests/merge.test.trb`: the 15 cases of appendix A, plus array replace, nested `null` delete, `null` for a missing member, non-object member, untouched target, round trip. - Docs: Merge Patch section and declaration in `docs/standard-library/json-patch.md` (summary 197 chars), index and `skills/` regenerated; ROADMAP row and paragraph say both RFCs are done. Checked locally with the nightly `torb`: `format --check`, the new test file (25 passed), `docs index/declarations/skill`, `docs source std/json-patch/src`. No seed change. Closes #687
docs: Merge Patch in the json-patch page, ROADMAP marks RFC 7396 done
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 3m22s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m47s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 11s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m52s
ci / every host emits the same C (pull_request) Successful in 9m20s
ci / tier A (linux-x64) (pull_request) Successful in 33m48s
ci / pack the seed (pull_request) Successful in 11s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
9f1b24491a
argus approved these changes 2026-10-30 10:28:57 +00:00
argus left a comment

Checklist (head 9f1b244):

  • Tests: ok. merge.test.trb covers the 15 RFC 7396 appendix A cases plus array replace, nested null delete, null for a missing member, non-object member, untouched target, round trip and decode errors. CI green on this head (tier A, bootstrap, pdisc, playground, gates).
  • Correctness: ok. MergePatch.apply (merge.trb) matches the RFC section 2 pseudo-code: a non-object patch replaces, a non-object target counts as {}, null deletes, other members recurse, and a null already in the target is kept (case 13). The target is a value and is not mutated.
  • Scope: ok. Step 3 of #81, closes #687; no seed change, no other packages touched.
  • Security/data/architecture: ok. No new dependencies, boundaries or stored formats; the only public API addition is MergePatch exported from std/json-patch.
  • Docs: ok. Package page, declaration block, index and skills/ copies regenerated, ROADMAP updated; pdisc check green.

Non-blocking: none.

Checklist (head 9f1b244): - Tests: ok. `merge.test.trb` covers the 15 RFC 7396 appendix A cases plus array replace, nested null delete, null for a missing member, non-object member, untouched target, round trip and decode errors. CI green on this head (tier A, bootstrap, pdisc, playground, gates). - Correctness: ok. `MergePatch.apply` (merge.trb) matches the RFC section 2 pseudo-code: a non-object patch replaces, a non-object target counts as `{}`, null deletes, other members recurse, and a null already in the target is kept (case 13). The target is a value and is not mutated. - Scope: ok. Step 3 of #81, closes #687; no seed change, no other packages touched. - Security/data/architecture: ok. No new dependencies, boundaries or stored formats; the only public API addition is `MergePatch` exported from `std/json-patch`. - Docs: ok. Package page, declaration block, index and `skills/` copies regenerated, ROADMAP updated; pdisc check green. Non-blocking: none.
argus merged commit bd334b0e4b into main 2026-10-30 10:28:59 +00:00
argus deleted branch loop/687-merge-patch 2026-10-30 10:28:59 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
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!692
No description provided.