Skip to content

Реализация Solution v2#639

Merged
theshadowco merged 4 commits into
developfrom
feature/solution_v2
Jul 8, 2026
Merged

Реализация Solution v2#639
theshadowco merged 4 commits into
developfrom
feature/solution_v2

Conversation

@theshadowco

@theshadowco theshadowco commented Jul 8, 2026

Copy link
Copy Markdown
Member

Описание

Реализация Solution - объединения конфигурации и расширений в единый объект

  • Добавлены классы Solution и ObjectProvenance для слияния конфигураций с отслеживанием происхождения объектов. MDClasses.createSolution() теперь возвращает Solution вместо Configuration, содержа объединённую конфигурацию, базовую конфигурацию, список расширений и карту происхождений.

  • ConfigurationConverter разделён на реализации для каждого формата

  • Улучшен MDMerger с полной поддержкой дочерних типов:

    • копирование реквизитов, табличных частей, предопределённых значений для всех типов-владельцев
    • поддержка регистров, перечислений, задач, расчётов, внешних источников данных, планов счетов
    • добавлен mergeAll() с возвратом MergeResult и происхождений

Связанные задачи

Closes: #636

Чеклист

Общие

  • Ветка PR обновлена из develop
  • Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
  • Изменения покрыты тестами
  • Обязательные действия перед коммитом выполнены (запускал команду gradlew precommit)

Дополнительно

Summary by CodeRabbit

  • New Features

    • Added full solution resolution that returns merged configuration plus provenance, including correct base/extension ownership tracking.
    • Deprecated configuration-only creation overloads in favor of solution-based APIs.
  • Bug Fixes

    • Improved consistency when loading and merging metadata across formats, with more complete preservation of nested child content.
    • Refined owner lookup for objects from mixed base/extension results.
  • Tests

    • Expanded test coverage for merging, provenance correctness, and identical results across formats.

…объект

- Добавлены классы Solution и ObjectProvenance для слияния конфигураций
с отслеживанием происхождения объектов. MDClasses.createSolution()
теперь возвращает Solution вместо Configuration, содержа объединённую
конфигурацию, базовую конфигурацию, список расширений и карту происхождений.

- ConfigurationConverter разделён на реализации для каждого формата

- Улучшен MDMerger с полной поддержкой дочерних типов:
  - копирование реквизитов, табличных частей, предопределённых значений
  для всех типов-владельцев
  - поддержка регистров, перечислений, задач, расчётов,
  внешних источников данных, планов счетов
  - добавлен mergeAll() с возвратом MergeResult и происхождений
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1d8543cf-21b3-4875-9c8c-d4c631209bdc

📥 Commits

Reviewing files that changed from the base of the PR and between cc30bbe and f80b023.

📒 Files selected for processing (7)
  • src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java
  • src/main/java/com/github/_1c_syntax/bsl/mdclasses/Solution.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/MDMerger.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/ConfigurationConverter.java
  • src/test/java/com/github/_1c_syntax/bsl/mdclasses/ObjectProvenanceTest.java
  • src/test/java/com/github/_1c_syntax/bsl/mdclasses/SolutionTest.java
  • src/test/java/com/github/_1c_syntax/bsl/reader/MDMergerMergeTest.java
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/ConfigurationConverter.java
  • src/main/java/com/github/_1c_syntax/bsl/mdclasses/Solution.java
  • src/test/java/com/github/_1c_syntax/bsl/mdclasses/ObjectProvenanceTest.java
  • src/test/java/com/github/_1c_syntax/bsl/reader/MDMergerMergeTest.java
  • src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/MDMerger.java

📝 Walkthrough

Walkthrough

This PR adds Solution and ObjectProvenance to represent merged metadata with root ownership, changes MDClasses.createSolution(...) to return Solution, computes provenance during merges, removes configurationExtensionFilter() from readers, and adds new converter logic for Designer and EDT inputs.

Changes

Solution and provenance implementation

Layer / File(s) Summary
ObjectProvenance and Solution data types
src/main/java/.../mdclasses/ObjectProvenance.java, src/main/java/.../mdclasses/Solution.java, src/test/java/.../mdclasses/ObjectProvenanceTest.java, src/test/java/.../mdclasses/SolutionTest.java
Adds ObjectProvenance and Solution with provenance lookup, owner resolution, containment checks, and rights delegation; tests cover defaults, equality, owner lookup, and membership behavior.
MDMerger provenance computation and extended child copying
src/main/java/.../reader/MDMerger.java, src/test/java/.../reader/MDMergerMergeTest.java
Adds mergeAll, provenance accumulation, MergeResult, and broader child-copy dispatch for merged metadata; tests verify merge results, provenance, and EDT/Designer parity.
MDClasses.createSolution and buildSolution
src/main/java/.../mdclasses/MDClasses.java, src/test/java/.../mdclasses/MDClassesSolutionTest.java
Returns Solution from createSolution(...), builds provenance-aware results, removes deprecated overloads, and updates solution tests for merged configuration access and extension cases.
Reader filter removal and extension detection
src/main/java/.../reader/MDReader.java, .../reader/FakeReader.java, .../reader/designer/DesignerReader.java, .../reader/edt/EDTReader.java, .../reader/designer/converter/ConfigurationConverter.java, .../reader/edt/converter/ConfigurationConverter.java
Removes configurationExtensionFilter() from reader APIs and implementations, and replaces it with marker-based extension detection in the Designer and EDT converters.
Smoke and workspace updates
src/test/java/.../smoke/RightTest.java, .idea/vcs.xml
Updates the expected access-rights implementer count and changes the root Git VCS mapping.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MDClasses
  participant MDMerger
  participant Configuration
  participant Solution

  Caller->>MDClasses: createSolution(path)
  MDClasses->>MDClasses: buildSolution(base, extensions)
  alt no extensions
    MDClasses->>Configuration: getChildrenByMdoRef()
    MDClasses->>Solution: build with base provenance
  else has extensions
    MDClasses->>MDMerger: mergeAll(base, extensions)
    MDMerger->>MDMerger: initProvenance(base), initProvenance(each extension)
    MDMerger->>Configuration: merge(accumulated, extension)
    MDMerger-->>MDClasses: MergeResult(configuration, provenance)
    MDClasses->>Solution: build with merged config and provenance
  end
  MDClasses-->>Caller: Solution
Loading

Possibly related PRs

  • 1c-syntax/mdclasses#465: Adds possibleRights() / AccessRightsOwner logic that Solution.possibleRights() and the updated smoke test count use.
  • 1c-syntax/mdclasses#467: Introduces getChildrenByMdoRef() support that the new provenance-building path depends on.
  • 1c-syntax/mdclasses#456: Touches the same reader filter area around configurationExtensionFilter() that this PR removes.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The .idea/vcs.xml change is unrelated to #636 and the Solution v2 feature work. Remove the IDE/VCS config change from the PR unless it is required for the feature.
Title check ❓ Inconclusive The title is generic and does not clearly describe the actual changes in this PR. Rename it to something specific like "Return Solution with provenance for configuration extensions".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The changes satisfy #636 by returning Solution data plus per-object provenance to identify ownership across configuration and extensions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/solution_v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Test Results

  504 files  + 18    504 suites  +18   12m 7s ⏱️ - 1m 2s
1 250 tests + 22  1 247 ✅ + 22   3 💤 ±0  0 ❌ ±0 
7 524 runs  +156  7 506 ✅ +156  18 💤 ±0  0 ❌ ±0 

Results for commit f80b023. ± Comparison against base commit cdcc48d.

This pull request removes 1 and adds 23 tests. Note that renamed tests count towards both.
com.github._1c_syntax.bsl.mdclasses.MDClassesSolutionTest ‑ [3] "src/test/resources/ext/designer/mdclasses_ext/src/cf"
com.github._1c_syntax.bsl.mdclasses.MDClassesSolutionTest ‑ [1] "false", "mdclasses_ext"
com.github._1c_syntax.bsl.mdclasses.MDClassesSolutionTest ‑ [2] "true", "mdclasses_ext"
com.github._1c_syntax.bsl.mdclasses.MDClassesSolutionTest ‑ extensionFormatsProduceIdenticalResult()
com.github._1c_syntax.bsl.mdclasses.ObjectProvenanceTest ‑ testDefaultValues()
com.github._1c_syntax.bsl.mdclasses.ObjectProvenanceTest ‑ testEquality()
com.github._1c_syntax.bsl.mdclasses.ObjectProvenanceTest ‑ testFilledValues()
com.github._1c_syntax.bsl.mdclasses.ObjectProvenanceTest ‑ testToString()
com.github._1c_syntax.bsl.mdclasses.SolutionTest ‑ testContainsByObject()
com.github._1c_syntax.bsl.mdclasses.SolutionTest ‑ testContainsByReference()
com.github._1c_syntax.bsl.mdclasses.SolutionTest ‑ testDelegationToEffective()
…

♻️ This comment has been updated with latest results.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/test/java/com/github/_1c_syntax/bsl/reader/MDMergerMergeTest.java (1)

121-150: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Strengthen provenance assertions in testMergeAllReturnsProvenance.

The test verifies provenance is non-empty and objectBelonging is not null, but doesn't assert:

  1. ownerRef is the base configuration's MdoReference for objects originating from base
  2. modifiedByExtensionRefs contains the extension's ref for objects modified by the extension (once that field is populated)
  3. Provenance for objects added exclusively by the extension has the extension as ownerRef
♻️ Suggested additional assertions
     var prov = result.provenance().get(catalogRef);
     assertThat(prov).isNotNull();
     assertThat(prov.getObjectBelonging()).isNotNull();
+    assertThat(prov.getOwnerRef()).isEqualTo(base.getMdoReference());
+    // Once modifiedByExtensionRefs is populated:
+    // assertThat(prov.getModifiedByExtensionRefs()).contains(ext.getMdoReference());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/com/github/_1c_syntax/bsl/reader/MDMergerMergeTest.java` around
lines 121 - 150, Strengthen the provenance checks in
testMergeAllReturnsProvenance by asserting the full provenance state for both
base-origin and extension-origin objects. In MDMergerMergeTest, after obtaining
the catalog provenance for "Справочник1", verify that ownerRef matches the base
configuration’s MdoReference, add an assertion for modifiedByExtensionRefs once
MDMerger.mergeAll populates it, and include a case for an object introduced only
by the extension to confirm its ownerRef points to the extension’s MdoReference.
Keep the existing result and provenance lookups, but expand the assertions
around prov to cover these ownership and modification fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/github/_1c_syntax/bsl/mdclasses/ObjectProvenance.java`:
- Around line 53-54: The existing-entry path in MDMerger.initProvenance is
skipping extension provenance for base objects that already have provenance
entries, so modifiedByExtensionRefs never gets the current extension’s
MdoReference. Update the logic in initProvenance to append the current extension
reference to ObjectProvenance.modifiedByExtensionRefs when the entry already
exists, rather than only creating new entries for missing refs, and keep the
behavior aligned with the ObjectProvenance builder/@Singular list.

In `@src/main/java/com/github/_1c_syntax/bsl/mdclasses/Solution.java`:
- Around line 75-86: The `Solution` builder path leaves `provenance` null,
unlike `baseConfiguration` and `extensions`, which causes `getProvenance()`,
`getOwnerRef()`, and `getOwner()` to NPE when they read `provenance`. Add a
default initialization for the `provenance` field in `Solution` (matching the
existing `@Builder.Default` pattern used by the other fields) so the public
builder always creates a safe empty map unless explicitly overridden.

In
`@src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/ConfigurationConverter.java`:
- Around line 64-69: The hasExtensionMarker method in ConfigurationConverter
currently swallows IOException and returns false without any trace, so add error
logging in the catch block before returning false. Use the existing logging
approach in this class or nearby converter code, and include the caught
IOException details so failures in ExtendXStream.getCurrentPath(reader) or
Files.lines(...) are diagnosable while keeping the current fallback behavior.

---

Nitpick comments:
In `@src/test/java/com/github/_1c_syntax/bsl/reader/MDMergerMergeTest.java`:
- Around line 121-150: Strengthen the provenance checks in
testMergeAllReturnsProvenance by asserting the full provenance state for both
base-origin and extension-origin objects. In MDMergerMergeTest, after obtaining
the catalog provenance for "Справочник1", verify that ownerRef matches the base
configuration’s MdoReference, add an assertion for modifiedByExtensionRefs once
MDMerger.mergeAll populates it, and include a case for an object introduced only
by the extension to confirm its ownerRef points to the extension’s MdoReference.
Keep the existing result and provenance lookups, but expand the assertions
around prov to cover these ownership and modification fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2ceddfc0-e759-43ef-8a8b-f216452b225c

📥 Commits

Reviewing files that changed from the base of the PR and between cdcc48d and cc30bbe.

📒 Files selected for processing (16)
  • .idea/vcs.xml
  • src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java
  • src/main/java/com/github/_1c_syntax/bsl/mdclasses/ObjectProvenance.java
  • src/main/java/com/github/_1c_syntax/bsl/mdclasses/Solution.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/MDMerger.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/ConfigurationConverter.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/EDTReader.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/converter/ConfigurationConverter.java
  • src/test/java/com/github/_1c_syntax/bsl/mdclasses/MDClassesSolutionTest.java
  • src/test/java/com/github/_1c_syntax/bsl/mdclasses/ObjectProvenanceTest.java
  • src/test/java/com/github/_1c_syntax/bsl/mdclasses/SolutionTest.java
  • src/test/java/com/github/_1c_syntax/bsl/reader/MDMergerMergeTest.java
  • src/test/java/com/github/_1c_syntax/bsl/smoke/RightTest.java
💤 Files with no reviewable changes (5)
  • .idea/vcs.xml
  • src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/designer/DesignerReader.java
  • src/main/java/com/github/_1c_syntax/bsl/reader/edt/EDTReader.java

Comment thread src/main/java/com/github/_1c_syntax/bsl/mdclasses/Solution.java Outdated
Comment on lines +64 to +69
private static boolean hasExtensionMarker(HierarchicalStreamReader reader) {
try (var lines = Files.lines(ExtendXStream.getCurrentPath(reader))) {
return lines.anyMatch(line -> line.contains("ConfigurationExtensionPurpose"));
} catch (IOException e) {
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Log the IOException before returning false.

Silently swallowing the exception causes the converter to misclassify extensions as configurations without any trace. At minimum, log the error so the issue is diagnosable.

🔧 Proposed fix
 private static boolean hasExtensionMarker(HierarchicalStreamReader reader) {
   try (var lines = Files.lines(ExtendXStream.getCurrentPath(reader))) {
     return lines.anyMatch(line -> line.contains("ConfigurationExtensionPurpose"));
   } catch (IOException e) {
+    LOGGER.error("Failed to read configuration file for extension marker detection", e);
     return false;
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private static boolean hasExtensionMarker(HierarchicalStreamReader reader) {
try (var lines = Files.lines(ExtendXStream.getCurrentPath(reader))) {
return lines.anyMatch(line -> line.contains("ConfigurationExtensionPurpose"));
} catch (IOException e) {
return false;
}
private static boolean hasExtensionMarker(HierarchicalStreamReader reader) {
try (var lines = Files.lines(ExtendXStream.getCurrentPath(reader))) {
return lines.anyMatch(line -> line.contains("ConfigurationExtensionPurpose"));
} catch (IOException e) {
LOGGER.error("Failed to read configuration file for extension marker detection", e);
return false;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/_1c_syntax/bsl/reader/designer/converter/ConfigurationConverter.java`
around lines 64 - 69, The hasExtensionMarker method in ConfigurationConverter
currently swallows IOException and returns false without any trace, so add error
logging in the catch block before returning false. Use the existing logging
approach in this class or nearby converter code, and include the caught
IOException details so failures in ExtendXStream.getCurrentPath(reader) or
Files.lines(...) are diagnosable while keeping the current fallback behavior.

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@theshadowco theshadowco merged commit 4afe994 into develop Jul 8, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NEW] Отдача метаданных в разрезе корня

1 participant