Skip to content

JSON-LD remote context & import - #481

Open
mcb5637 wants to merge 10 commits into
developfrom
feature/json_remote_context
Open

mcb5637 wants to merge 10 commits into
developfrom
feature/json_remote_context

Conversation

@mcb5637

@mcb5637 mcb5637 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

close #431

@mcb5637
mcb5637 marked this pull request as ready for review September 1, 2026 12:06

@bigerl bigerl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thx for the PR. I didn't have the time to faithfully review this PR fully by myself. So, all but one comment are essentially from Claude. I also asked claude to prepare a PR #500 with regression tests for the issues it reported. Feel free to merge or cherry pick it.

I went through the comments. They seem to be legit.

Comment thread private/rdf4cpp/parser/JsonLdContextParser.hpp Outdated
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp Outdated
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp Outdated
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread private/rdf4cpp/parser/JsonLdContextParser.hpp Outdated
Comment thread private/rdf4cpp/parser/JsonLdParserTypes.hpp Outdated
Comment thread private/rdf4cpp/parser/JsonLdParserPath.hpp
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread tests/parser/parser_test_helpers.hpp Outdated

@bigerl bigerl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for addressing. I have re-run the review skill. Please find the comments below.

New regression tests for eight of the comments are in PR #502. Closing #500 as obsolete.

Things found outside the changes:

  • docs/source/users_guide.rst line 52 and README.md line 14 still say that remote contexts and @import are not fetched.

Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp Outdated
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp Outdated
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread tests/parser/tests_JSON_LD_Parser.cpp
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread private/rdf4cpp/parser/JsonLdContextParser.cpp
Comment thread src/rdf4cpp/parser/ParsingState.hpp
}

// 5.2.3
if (p.remote_contexts.size() > remote_context_size_limit) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A remote context is processed again for every occurrence, and only the length of remote_contexts is bounded. The work doubles with each extra copy on the way down.

A chain of small remote documents where each one names its predecessor twice takes 693 ms at 18 documents, 2.2 s at 20, and does not finish in 25 s at 30 (1.8 kB of remote data in total, each URL is requested once because the cache keeps the body). A single self-reference is not the problem: it stops after 101 loads with "context overflow".

Bound the total number of remote context loads per parse, not only the depth. Skipping URLs that are already in remote_contexts is not enough: the same blowup works with distinct URLs on every path (each document names two children, both name the next, 5.6 s at depth 20 with 41 distinct URLs).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If the number of entries in the remote contexts array exceeds a processor defined limit, a context overflow error has been detected and processing is aborted; otherwise, add context to remote contexts.

It does not sound like i would be allowed to make that change.

@mcb5637
mcb5637 requested a review from bigerl September 15, 2026 14:31
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.

Json-LD remote context support

2 participants