Skip to content

feat: let extractLists tolerate lists with extra arcs - #627

Draft
jeswr wants to merge 3 commits into
rdfjs:mainfrom
jeswr:feat/extract-lists-extra-arcs
Draft

feat: let extractLists tolerate lists with extra arcs#627
jeswr wants to merge 3 commits into
rdfjs:mainfrom
jeswr:feat/extract-lists-extra-arcs

Conversation

@jeswr

@jeswr jeswr commented Jul 2, 2026

Copy link
Copy Markdown
Member

extractLists() currently declares a list malformed as soon as one of its nodes carries any arc besides rdf:first/rdf:rest (e.g. :1 a rdf:List), which is common in real-world ontologies.

This adds an opt-in allowExtraArcs option: such lists are returned in the mapping, but their quads are never pushed to the removal set, so with remove: true they are left fully intact (like malformed lists today) and nothing dangles. The default stays strict on purpose: the result typically feeds the writer's lists option, and silently dropping extra arcs there would make round-tripping lossy — with the option enabled, callers accept that remaining rdf:first/rdf:rest quads coexist with the returned mapping.

Also improves the error the reporter hit: :1 can't be subject and object now 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 — allowExtraArcs vs e.g. tolerateExtraArcs/lenient; happy to rename.

Closes #546

cc @jeswr

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@jeswr jeswr left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

@jeswr
jeswr marked this pull request as ready for review July 2, 2026 17:23
Copilot AI review requested due to automatic review settings July 2, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 allowExtraArcs option to extractLists() so lists with extra arcs can still be extracted without removing any of their list triples when remove: 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.

Comment thread src/N3Store.js Outdated
Comment thread src/N3Store.js
@jeswr jeswr added ai-generated Authored or prepared by an AI coding agent needs-author-review Awaiting author review; agent has done its part (author removes if follow-ups remain) labels Jul 9, 2026
Comment thread src/N3Store.js Outdated
@jeswr
jeswr marked this pull request as draft July 22, 2026 18:58
@jeswr jeswr removed the needs-author-review Awaiting author review; agent has done its part (author removes if follow-ups remain) label Jul 22, 2026
@jeswr jeswr added the needs-author-review Awaiting author review; agent has done its part (author removes if follow-ups remain) label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Authored or prepared by an AI coding agent needs-author-review Awaiting author review; agent has done its part (author removes if follow-ups remain)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

N3Store.exractLists() too restrictive

2 participants