From 45f30061841586acd9320963868fe2ba621040ec Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 12:42:53 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #28 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Data.Doublets/issues/28 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 000000000..7ada6bdf1 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Data.Doublets/issues/28 +Your prepared branch: issue-28-86d6809c +Your prepared working directory: /tmp/gh-issue-solver-1757842917510 + +Proceed. \ No newline at end of file From 160c51265f455aa89e44462495c47c2fa0a0ce40 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 13:00:32 +0300 Subject: [PATCH 2/3] Implement Itself constant handling in LinksItselfConstantToSelfReferenceResolver.Each method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modified Each method to handle 'Itself' constant instead of skipping execution - Added HandleEachWithItselfConstant method to filter links matching self-referential patterns - Added MatchesItselfPattern method to validate links against restriction patterns containing 'Itself' - Resolves issue #28 by providing a version of resolver that can handle Itself constant 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- ...ksItselfConstantToSelfReferenceResolver.cs | 125 +++++++++++++++++- 1 file changed, 122 insertions(+), 3 deletions(-) diff --git a/csharp/Platform.Data.Doublets/Decorators/LinksItselfConstantToSelfReferenceResolver.cs b/csharp/Platform.Data.Doublets/Decorators/LinksItselfConstantToSelfReferenceResolver.cs index a1242c381..02cff53da 100644 --- a/csharp/Platform.Data.Doublets/Decorators/LinksItselfConstantToSelfReferenceResolver.cs +++ b/csharp/Platform.Data.Doublets/Decorators/LinksItselfConstantToSelfReferenceResolver.cs @@ -53,14 +53,133 @@ public override TLinkAddress Each(IList? restriction, ReadHandler< { var constants = _constants; var itselfConstant = constants.Itself; - if (constants.Any != itselfConstant && restriction.Contains(item: itselfConstant)) + if (constants.Any != itselfConstant && restriction != null && restriction.Contains(item: itselfConstant)) { - // Itself constant is not supported for Each method right now, skipping execution - return constants.Continue; + // Handle 'Itself' constant by filtering for self-referential links + return HandleEachWithItselfConstant(restriction, handler, itselfConstant); } return _links.Each(restriction: restriction, handler: handler); } + /// + /// + /// Handles Each operations when 'Itself' constant is present in the restriction. + /// + /// + /// + /// + /// The original restriction containing 'Itself' constants. + /// + /// + /// + /// The handler to execute for matching links. + /// + /// + /// + /// The 'Itself' constant value. + /// + /// + /// + /// The result of the Each operation. + /// + /// + [MethodImpl(methodImplOptions: MethodImplOptions.AggressiveInlining)] + private TLinkAddress HandleEachWithItselfConstant(IList restriction, ReadHandler? handler, TLinkAddress itselfConstant) + { + var constants = _constants; + + // Create a wrapper handler that filters for self-referential links + ReadHandler? filteringHandler = null; + if (handler != null) + { + filteringHandler = (link) => + { + var linkIndex = _links.GetIndex(link); + var linkSource = _links.GetSource(link); + var linkTarget = _links.GetTarget(link); + + // Check if this link matches the 'Itself' pattern in the restriction + if (MatchesItselfPattern(restriction, itselfConstant, linkIndex, linkSource, linkTarget)) + { + return handler(link); + } + + return constants.Continue; + }; + } + + // Get all links and let our filtering handler process them + return _links.Each(restriction: null, handler: filteringHandler); + } + + /// + /// + /// Checks if a link matches the pattern specified by the restriction with 'Itself' constants. + /// + /// + /// + /// + /// The restriction pattern. + /// + /// + /// + /// The 'Itself' constant value. + /// + /// + /// + /// The link's index. + /// + /// + /// + /// The link's source. + /// + /// + /// + /// The link's target. + /// + /// + /// + /// True if the link matches the pattern, false otherwise. + /// + /// + [MethodImpl(methodImplOptions: MethodImplOptions.AggressiveInlining)] + private bool MatchesItselfPattern(IList restriction, TLinkAddress itselfConstant, TLinkAddress linkIndex, TLinkAddress linkSource, TLinkAddress linkTarget) + { + var constants = _constants; + + // Check index (position 0) + if (restriction.Count > 0 && restriction[0] != constants.Any) + { + var expectedIndex = restriction[0] == itselfConstant ? linkIndex : restriction[0]; + if (linkIndex != expectedIndex) + { + return false; + } + } + + // Check source (position 1) + if (restriction.Count > 1 && restriction[1] != constants.Any) + { + var expectedSource = restriction[1] == itselfConstant ? linkIndex : restriction[1]; + if (linkSource != expectedSource) + { + return false; + } + } + + // Check target (position 2) + if (restriction.Count > 2 && restriction[2] != constants.Any) + { + var expectedTarget = restriction[2] == itselfConstant ? linkIndex : restriction[2]; + if (linkTarget != expectedTarget) + { + return false; + } + } + + return true; + } + /// /// /// Updates the restriction. From e3b8bdf0e4892f401dbae516463e17526381ff3e Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 13:01:23 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 7ada6bdf1..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Data.Doublets/issues/28 -Your prepared branch: issue-28-86d6809c -Your prepared working directory: /tmp/gh-issue-solver-1757842917510 - -Proceed. \ No newline at end of file