Skip to content

Make AasBuilder fragment batches transactional with rollback#23

Merged
Freezor merged 1 commit into12-enable-incremental-submodel-composition-via-addsubmodel-at-any-stage-of-the-build-processfrom
codex/update-aasbuilder-for-transactional-fragment-application
Mar 27, 2026
Merged

Make AasBuilder fragment batches transactional with rollback#23
Freezor merged 1 commit into12-enable-incremental-submodel-composition-via-addsubmodel-at-any-stage-of-the-build-processfrom
codex/update-aasbuilder-for-transactional-fragment-application

Conversation

@Freezor
Copy link
Copy Markdown
Owner

@Freezor Freezor commented Mar 27, 2026

Motivation

  • The builder previously applied staged submodel fragments directly to live Submodel instances, allowing partial mutations to persist when a fragment batch failed and causing duplicate SubmodelElements on subsequent Build() calls.
  • The change aims to ensure fragment batches are applied atomically so a failed batch does not leak partial changes and the failing test Build_WhenFragmentBatchFails_ShouldRollbackAppliedFragmentsBeforeRetry is satisfied.

Description

  • Replaced inline fragment application in AasBuilder.Build() with a call to a new helper ApplySubmodelFragmentsTransactionally().
  • Implemented ApplySubmodelFragmentsTransactionally() to pre-validate all target submodel ids, snapshot each touched submodel's SubmodelElements presence and count, apply all fragments, clear _submodelFragments only on success, and roll back appended elements (including restoring a null collection) on any exception.
  • The implementation preserves existing behavior for duplicate-id and shell reference validation while preventing in-place partial mutations from persisting across retries.

Testing

  • Attempted to run the builder unit tests with dotnet test FluentAAS/FluentAAS.Builder.Tests/FluentAAS.Builder.Tests.csproj --no-restore, but the execution environment does not have dotnet installed (dotnet: command not found), so automated tests could not be executed here.
  • Verified code compiles locally enough to commit the change and confirmed the change was committed; recommend running the test suite in a .NET-enabled environment to validate Build_WhenFragmentBatchFails_ShouldRollbackAppliedFragmentsBeforeRetry and related fragment tests.

Codex Task

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 27, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 44c245cf-66a5-4af7-a9d2-71a6e89b4ac0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/update-aasbuilder-for-transactional-fragment-application

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 and usage tips.

@Freezor Freezor merged commit 3468e05 into 12-enable-incremental-submodel-composition-via-addsubmodel-at-any-stage-of-the-build-process Mar 27, 2026
3 checks passed
@Freezor Freezor deleted the codex/update-aasbuilder-for-transactional-fragment-application branch March 27, 2026 12:50
Freezor added a commit that referenced this pull request Mar 27, 2026
#20)

* Add staged submodel composition and validation (fragments) with tests (#19)

* Update README for staged submodel composition and remove extra spec doc

* Fix staged fragment idempotency and preserve internal submodel compatibility

* 📝 Add docstrings to `12-enable-incremental-submodel-composition-via-addsubmodel-at-any-stage-of-the-build-process` (#21)

Docstrings generation was requested by @Freezor.

* #20 (comment)

The following files were modified:

* `FluentAAS/FluentAAS.Builder/AasBuilder.cs`
* `FluentAAS/FluentAAS.Builder/IAasBuilder.cs`
* `FluentAAS/FluentAAS.Builder/SubModel/SubmodelFragmentBuilder.cs`

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* 📝 CodeRabbit Chat: Add unit tests

* Fix malformed XML docs in builder interfaces (#22)

* FEAT Fix docs issue

* Make submodel fragment application transactional in Build (#23)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant