feat: let extractLists tolerate lists with extra arcs - #627
Draft
jeswr wants to merge 3 commits into
Draft
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates N3Store#extractLists() to optionally tolerate RDF list nodes that have additional (non-rdf:first/rdf:rest) outgoing arcs, improving interoperability with real-world ontologies while keeping strict behavior as the default.
Changes:
- Added an opt-in
allowExtraArcsoption toextractLists()so lists with extra arcs can still be extracted without removing any of their list triples whenremove: true. - Improved the strict-mode error message to name the offending predicate (e.g., “has non-list arc …”) instead of the generic subject/object message.
- Added test coverage for the new option and the updated error behavior, including a fixture based on issue #546.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/N3Store.js |
Adds allowExtraArcs handling, adjusts removal bookkeeping, and improves the reported error message for extra arcs. |
test/N3Store-test.js |
Adds regression tests for issue #546 plus tests for allowExtraArcs interactions with remove and ignoreErrors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jeswr
commented
Jul 22, 2026
jeswr
marked this pull request as draft
July 22, 2026 18:58
# Conflicts: # src/N3Store.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
extractLists()currently declares a list malformed as soon as one of its nodes carries any arc besidesrdf:first/rdf:rest(e.g.:1 a rdf:List), which is common in real-world ontologies.This adds an opt-in
allowExtraArcsoption: such lists are returned in the mapping, but their quads are never pushed to the removal set, so withremove: truethey are left fully intact (like malformed lists today) and nothing dangles. The default stays strict on purpose: the result typically feeds the writer'slistsoption, and silently dropping extra arcs there would make round-tripping lossy — with the option enabled, callers accept that remainingrdf:first/rdf:restquads coexist with the returned mapping.Also improves the error the reporter hit:
:1 can't be subject and objectnow reads:1 has non-list arc http://...ns#type, naming the offending predicate.Note: a list head that has no incoming arcs and carries both a subject-position use and an extra arc remains an error even with the option, since it is ambiguous which arc references the list.
Naming is up for debate —
allowExtraArcsvs e.g.tolerateExtraArcs/lenient; happy to rename.Closes #546
cc @jeswr