From 075731f8e2b74cefb315a0e5370c37fa4706a813 Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 27 Feb 2026 16:07:00 +0000 Subject: [PATCH 1/4] Initial commit with task details Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/netkeep80/jsonRVM/issues/10 --- CLAUDE.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index d4b0046..f6a2246 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,3 +5,16 @@ Your forked repository: konard/netkeep80-jsonRVM Original repository (upstream): netkeep80/jsonRVM Proceed. + +--- + +Issue to solve: https://github.com/netkeep80/jsonRVM/issues/10 +Your prepared branch: issue-10-bf572fdeec6d +Your prepared working directory: /tmp/gh-issue-solver-1772208412320 +Your forked repository: konard/netkeep80-jsonRVM +Original repository (upstream): netkeep80/jsonRVM + +Proceed. + + +Run timestamp: 2026-02-27T16:07:00.596Z \ No newline at end of file From bd0eedce3e7f5575d7e48da5fc13fda0b5edd7dc Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 27 Feb 2026 16:14:57 +0000 Subject: [PATCH 2/4] Add ordered pair format (<>) for Relations Model JSON representation Implements the second JSON representation format for the Relations Model based on the mathematical triplet-as-nested-ordered-pairs notation: ent = (rel, (obj, sub)) New format uses << and >> keys instead of $rel, $obj, $sub: { "<<": "", ">>": { "<<": "", ">>": "" } } Changes: - vm.rm.h: Added parsing of << / >> ordered pair format in exec_ent() - doc/relations-model-ru.md: Document both formats with comparison table - doc/relations-model-en.md: Document both formats with comparison table - modules/console/test/: Add test JSON files and test cases - examples/: Add example showing ordered pair format usage Closes netkeep80/jsonRVM#10 Co-Authored-By: Claude Opus 4.6 --- doc/relations-model-en.md | 34 +++++++++-- doc/relations-model-ru.md | 34 +++++++++-- examples/ordered_pair_format.json | 26 +++++++++ modules/common/include/vm.rm.h | 29 ++++++++++ modules/console/test/main.cpp | 56 +++++++++++++++++++ modules/console/test/ordered_pair_format.json | 3 + .../test/ordered_pair_format_where.json | 12 ++++ 7 files changed, 186 insertions(+), 8 deletions(-) create mode 100644 examples/ordered_pair_format.json create mode 100644 modules/console/test/ordered_pair_format.json create mode 100644 modules/console/test/ordered_pair_format_where.json diff --git a/doc/relations-model-en.md b/doc/relations-model-en.md index 5af4d78..f3fc721 100644 --- a/doc/relations-model-en.md +++ b/doc/relations-model-en.md @@ -251,16 +251,42 @@ The structure of the Relations Model is fractal: each entity contains three othe ### 7.2. Executable Constructs -An entity in JSON representation is defined by an object with fields: +An entity in JSON representation can be defined using two equivalent formats. + +**Format 1: Expanded notation (named fields)** + +```json +{ + "$rel": "", + "$obj": "", + "$sub": "" +} +``` + +**Format 2: Compact notation using ordered pairs (ordered pair format)** + +Based on the mathematical representation of a triplet as nested ordered pairs: +`ent = (rel, (obj, sub))` ```json { - "$rel": "", - "$sub": "", - "$obj": "" + "<<": "", + ">>": { + "<<": "", + ">>": "" + } } ``` +Field correspondence between formats: +| Format 1 | Format 2 | Role | +|----------|----------|------| +| `$rel` | `<<` | Relation-controller (Controller) | +| `$obj` | `>>/<<` | Object-model (Model) | +| `$sub` | `>>/>>` | Subject-view (View) | + +Note: in Format 2, the value of `>>` is an ordered pair `(obj, sub)`. If the `>>` field is absent or not an object, the object and subject are inherited from the parent context. + ## 8. Conclusion The mathematical formalization of the Relations Model in terms of set theory shows that: diff --git a/doc/relations-model-ru.md b/doc/relations-model-ru.md index ff7ff20..fb75046 100644 --- a/doc/relations-model-ru.md +++ b/doc/relations-model-ru.md @@ -251,16 +251,42 @@ anetl : L → NP ### 7.2. Исполняемые конструкции -Сущность в JSON-представлении определяется объектом с полями: +Сущность в JSON-представлении может быть задана двумя эквивалентными форматами. + +**Формат 1: Расширенная запись (с именованными полями)** + +```json +{ + "$rel": "<отношение-контроллер>", + "$obj": "<объект-модель>", + "$sub": "<субъект-представление>" +} +``` + +**Формат 2: Компактная запись через упорядоченные пары (ordered pair format)** + +Основан на математическом представлении триплета как вложенных упорядоченных пар: +`ent = (rel, (obj, sub))` ```json { - "$rel": "<отношение>", - "$sub": "<субъект>", - "$obj": "<объект>" + "<<": "<отношение-контроллер>", + ">>": { + "<<": "<объект-модель>", + ">>": "<субъект-представление>" + } } ``` +Соответствие полей между форматами: +| Формат 1 | Формат 2 | Роль | +|----------|----------|------| +| `$rel` | `<<` | Отношение-контроллер (Controller) | +| `$obj` | `>>/<<` | Объект-модель (Model) | +| `$sub` | `>>/>>` | Субъект-представление (View) | + +Примечание: в формате 2 значение `>>` является упорядоченной парой `(obj, sub)`. Если поле `>>` отсутствует или не является объектом, объект и субъект остаются унаследованными из родительского контекста. + ## 8. Заключение Математическая формализация Модели Отношений в терминах теории множеств показывает, что: diff --git a/examples/ordered_pair_format.json b/examples/ordered_pair_format.json new file mode 100644 index 0000000..4f86c72 --- /dev/null +++ b/examples/ordered_pair_format.json @@ -0,0 +1,26 @@ +{ + "_comment": "Example of ordered pair format (<>) for Relations Model", + "_description": "Demonstrates ent = (rel, (obj, sub)) representation", + "_format": { + "<<": "", + ">>": { + "<<": "", + ">>": "" + } + }, + "_equivalent_old_format": { + "$rel": "", + "$obj": "", + "$sub": "" + }, + "version_example": { + "<<": "rmvm/version" + }, + "addition_example": { + "<<": "+", + ">>": { + "<<": 1, + ">>": 1 + } + } +} diff --git a/modules/common/include/vm.rm.h b/modules/common/include/vm.rm.h index 6e6f011..883558d 100644 --- a/modules/common/include/vm.rm.h +++ b/modules/common/include/vm.rm.h @@ -567,6 +567,35 @@ namespace rm throw json({{"$rel"s, j}}); } } + else if (auto relop = ent.find("<<"); relop != end) + { // ordered pair format: ent = (rel, (obj, sub)) + // "<<" = relation (controller), ">>" = { "<<": obj (model), ">>": sub (view) } + json *obj_ptr = nullptr; + json *sub_ptr = nullptr; + + if (auto duplet = ent.find(">>"); duplet != end && duplet->is_object()) + { + if (auto obj_it = duplet->find("<<"); obj_it != duplet->end()) + obj_ptr = &(*obj_it); + if (auto sub_it = duplet->find(">>"); sub_it != duplet->end()) + sub_ptr = &(*sub_it); + } + + try + { + vm_ctx ctx( + $.rel, + obj_ptr ? val_or_ref_to($, *obj_ptr) : $.rel, + sub_ptr ? val_or_ref_to($, *sub_ptr) : $.rel, + ent, + $); + exec_ent(ctx, val_or_ref_to($, *relop)); + } + catch (json &j) + { + throw json({{"<<"s, j}}); + } + } else { // контроллер это лямбда структура, которая управляет параллельным проецированием сущностей auto it = ent.begin(); diff --git a/modules/console/test/main.cpp b/modules/console/test/main.cpp index aaa60d5..285bcca 100644 --- a/modules/console/test/main.cpp +++ b/modules/console/test/main.cpp @@ -197,6 +197,62 @@ TEST_CASE("testing base entity 'where'") { } +TEST_CASE("testing ordered pair format (<>) - version") { + MESSAGE("result:"); + file_database_t db("./"); + vm root(&db); + // base vocabulary + import_relations_model_to(root); + json res; + char* fileNameInput = "ordered_pair_format.json"; + + try + { + std::ifstream in(fileNameInput); + REQUIRE(in.good()); + json& root_json = static_cast(root); + in >> root_json[""]; + + vm_ctx $(res, root_json[""]); + root.exec_ent($, root_json[""]); + cout << res.dump(2) << endl; + CHECK(res.get_ref() == "3.0.0"s); + } + catch (json& j) { throw json({ { __func__, j } }); } + catch (json::exception& e) { throw json({ { __func__, "json::exception: "s + e.what() + ", id: "s + to_string(e.id) } }); } + catch (std::exception& e) { throw json({ { __func__, "std::exception: "s + e.what() } }); } + catch (...) { throw json({ { __func__, "unknown exception"s } }); } +} + + +TEST_CASE("testing ordered pair format (<>) - where filter") { + MESSAGE("result:"); + file_database_t db("./"); + vm root(&db); + // base vocabulary + import_relations_model_to(root); + json res; + char* fileNameInput = "ordered_pair_format_where.json"; + + try + { + std::ifstream in(fileNameInput); + REQUIRE(in.good()); + json& root_json = static_cast(root); + in >> root_json[""]; + + vm_ctx $(res, root_json[""]); + root.exec_ent($, root_json[""]); + cout << res.dump(2) << endl; + CHECK(res[0].get_ref() == "4"s); + } + catch (json& j) { throw json({ { __func__, j } }); } + catch (json::exception& e) { throw json({ { __func__, "json::exception: "s + e.what() + ", id: "s + to_string(e.id) } }); } + catch (std::exception& e) { throw json({ { __func__, "std::exception: "s + e.what() } }); } + catch (...) { throw json({ { __func__, "unknown exception"s } }); } +} + + TEST_CASE("performance test") { MESSAGE("result:"); file_database_t db("./"); diff --git a/modules/console/test/ordered_pair_format.json b/modules/console/test/ordered_pair_format.json new file mode 100644 index 0000000..3e674ce --- /dev/null +++ b/modules/console/test/ordered_pair_format.json @@ -0,0 +1,3 @@ +{ + "<<": "rmvm/version" +} diff --git a/modules/console/test/ordered_pair_format_where.json b/modules/console/test/ordered_pair_format_where.json new file mode 100644 index 0000000..b3927ca --- /dev/null +++ b/modules/console/test/ordered_pair_format_where.json @@ -0,0 +1,12 @@ +{ + "<<": "where", + ">>": { + "<<": [ null, 2, false, "4", {} ], + ">>": { + "<<": "is_string", + ">>": { + "<<": {"$ref": "$obj"} + } + } + } +} From 3e0e8140d581cc671d373817a5c08ff67c90b2f2 Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 27 Feb 2026 16:15:53 +0000 Subject: [PATCH 3/4] Revert "Initial commit with task details" This reverts commit 075731f8e2b74cefb315a0e5370c37fa4706a813. --- CLAUDE.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f6a2246..d4b0046 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,16 +5,3 @@ Your forked repository: konard/netkeep80-jsonRVM Original repository (upstream): netkeep80/jsonRVM Proceed. - ---- - -Issue to solve: https://github.com/netkeep80/jsonRVM/issues/10 -Your prepared branch: issue-10-bf572fdeec6d -Your prepared working directory: /tmp/gh-issue-solver-1772208412320 -Your forked repository: konard/netkeep80-jsonRVM -Original repository (upstream): netkeep80/jsonRVM - -Proceed. - - -Run timestamp: 2026-02-27T16:07:00.596Z \ No newline at end of file From bbfc7f9656b1b857df84ef5ce00b03c7177019b3 Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 20 Mar 2026 01:27:27 +0000 Subject: [PATCH 4/4] Fix const-correctness: use const char* for string literals in tests Co-Authored-By: Claude Opus 4.6 --- modules/console/test/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/console/test/main.cpp b/modules/console/test/main.cpp index 285bcca..5038014 100644 --- a/modules/console/test/main.cpp +++ b/modules/console/test/main.cpp @@ -204,7 +204,7 @@ TEST_CASE("testing ordered pair format (<>) - version") { // base vocabulary import_relations_model_to(root); json res; - char* fileNameInput = "ordered_pair_format.json"; + const char* fileNameInput = "ordered_pair_format.json"; try { @@ -232,7 +232,7 @@ TEST_CASE("testing ordered pair format (<>) - where filter") { // base vocabulary import_relations_model_to(root); json res; - char* fileNameInput = "ordered_pair_format_where.json"; + const char* fileNameInput = "ordered_pair_format_where.json"; try {