Fix issue 20 self-link substitution handling#47
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #20
- Add infinite loop protection to prevent OutOfMemoryException when processing self-referential link patterns - Implement multiple safeguards: iteration limits, cycle detection, and reasonable bounds checking - Replace uncontrolled memory exhaustion with controlled InvalidOperationException - Add comprehensive test case for the problematic query pattern: ((($i: 1 21)) (($i: $s $t) ($i 20))) - Include simple verification test to demonstrate the fix works correctly Fixes #20: Unable to substitute a link to itself + outgoing link 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
We need to get latest changes from default branch. And cover these cases extensively with tests. That we should not do. Instead we should use protection of 0 values, or out of bounds of ILinksConstants supported range of links. We should use IsPartialPoint IsFullPoint functions (Seach for these in https://github.com/linksplatform) to detect immediate self references. And see how Format Structure is done in https://github.com/linksplatform (it uses hashset to keep track of visited links when traversing any structure, that may have indirect self references. So we actually can fully detect possible recursion cases, also harden our code with more tests, so all self referential cases (direct or indirect) are covered. We also need to make sure we support the same test cases in both Rust version of the code and C# version of the code in the same way. If you find any issues in https://github.com/linksplatform components, make sure to report issues there, and list these issues in this pull request, and also put links to this pull request in these issues. We need to download all logs and data related about the issue to this repository, make sure we compile that data to If there is not enough data to find actual root cause, add debug output and verbose mode if not present, that will allow us to find root cause on next iteration. If issue related to any other repository/project, where we can report issues on GitHub, please do so. Each issue must contain reproducible examples, workarounds and suggestions for fix the issue in code. Please plan and execute everything in a single pull request, you have unlimited time and context, as context auto-compacts and you can continue indefinitely, until it is each and every requirement fully addressed, and everything is totally done. |
|
🤖 AI Work Session Started Starting automated work session at 2026-05-08T10:33:11.987Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
Working session summaryImplemented and pushed the issue 20 fix to PR 47: What changed:
Verification:
This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:
Total: (758.1K + 21.0M cached) input tokens, 69.9K output tokens, $31.729554 cost 🤖 Models used:
📎 Log file uploaded as Repository (87589KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
Summary
Resolves #20.
This fixes the self-link substitution query that previously exhausted memory:
Root Cause
($i: $s $t)into the specialAnyreference instead of preserving the matched link parts.($i 20)could be resolved through wildcard semantics instead of the null index used for creating a new link.Fix
0, so($i 20)creates the intended outgoing link.EnsureCreatedto reject unsupported internal references and repeated/overshooting creator output without arbitrary iteration limits.query_processor_substitution.rs.Case Study
Detailed issue data, PR comments, screenshot evidence, upstream LinksPlatform reference snippets, local reproduction output, and verification logs are in:
docs/case-studies/issue-20/README.mdNo upstream LinksPlatform bug was identified; this PR uses the referenced LinksPlatform point helpers and visited-set structure-formatting pattern locally.
Verification
dotnet restorefromcsharp/dotnet build --no-restore --configuration Releasefromcsharp/dotnet test --no-build --configuration Release --verbosity normalfromcsharp/cargo fmt --all -- --checkfromrust/RUSTFLAGS=-Dwarnings cargo clippy --all-targets --all-featuresfromrust/cargo test --all-features --verbosefromrust/cargo test --doc --verbosefromrust/node scripts/check-file-size.mjs --lang rustnpm cinpm run test:wasmnpm run builddocs/case-studies/issue-20/evidence/repro-after-fix.log